1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | |
26 | |
… | |
… | |
33 | static const int con_bonus[MAX_STAT + 1] = { |
33 | static const int con_bonus[MAX_STAT + 1] = { |
34 | -6, -5, -4, -3, -2, -1, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, |
34 | -6, -5, -4, -3, -2, -1, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, |
35 | 22, 25, 30, 40, 50 |
35 | 22, 25, 30, 40, 50 |
36 | }; |
36 | }; |
37 | |
37 | |
38 | /* changed the name of this to "sp_bonus" from "int_bonus" |
38 | /* changed the name of this to "sp_bonus" from "int_bonus" |
39 | * because Pow can now be the stat that controls spellpoint |
39 | * because Pow can now be the stat that controls spellpoint |
40 | * advancement. -b.t. |
40 | * advancement. -b.t. |
41 | */ |
41 | */ |
42 | static const int sp_bonus[MAX_STAT + 1] = { |
42 | static const int sp_bonus[MAX_STAT + 1] = { |
43 | -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 25, |
43 | -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 25, |
… | |
… | |
108 | * These limits are probably overly generous, but being there were no values |
108 | * These limits are probably overly generous, but being there were no values |
109 | * before, you need to start someplace. |
109 | * before, you need to start someplace. |
110 | */ |
110 | */ |
111 | |
111 | |
112 | const uint32 weight_limit[MAX_STAT + 1] = { |
112 | const uint32 weight_limit[MAX_STAT + 1] = { |
113 | 200000, /* 0 */ |
113 | 200000, /* 0 */ |
114 | 250000, 300000, 350000, 400000, 500000, /* 5 */ |
114 | 250000, 300000, 350000, 400000, 500000, /* 5 */ |
115 | 600000, 700000, 800000, 900000, 1000000, /* 10 */ |
115 | 600000, 700000, 800000, 900000, 1000000, /* 10 */ |
116 | 1100000, 1200000, 1300000, 1400000, 1500000, /* 15 */ |
116 | 1100000, 1200000, 1300000, 1400000, 1500000, /* 15 */ |
117 | 1650000, 1800000, 1950000, 2100000, 2250000, /* 20 */ |
117 | 1650000, 1800000, 1950000, 2100000, 2250000, /* 20 */ |
118 | 2400000, 2550000, 2700000, 2850000, 3000000, /* 25 */ |
118 | 2400000, 2550000, 2700000, 2850000, 3000000, /* 25 */ |
119 | 3250000, 3500000, 3750000, 4000000, 4500000 /*30 */ |
119 | 3250000, 3500000, 3750000, 4000000, 4500000 /* 30 */ |
120 | }; |
120 | }; |
121 | |
121 | |
122 | const int learn_spell[MAX_STAT + 1] = { |
122 | const int learn_spell[MAX_STAT + 1] = { |
123 | 0, 0, 0, 1, 2, 4, 8, 12, 16, 25, 36, 45, 55, 65, 70, 75, 80, 85, 90, 95, 100, 100, 100, 100, 100, |
123 | 0, 0, 0, 1, 2, 4, 8, 12, 16, 25, 36, 45, 55, 65, 70, 75, 80, 85, 90, 95, 100, 100, 100, 100, 100, |
124 | 100, 100, 100, 100, 100, 100 |
124 | 100, 100, 100, 100, 100, 100 |
… | |
… | |
139 | /* |
139 | /* |
140 | Since this is nowhere defined ... |
140 | Since this is nowhere defined ... |
141 | Both come in handy at least in function add_exp() |
141 | Both come in handy at least in function add_exp() |
142 | */ |
142 | */ |
143 | |
143 | |
144 | #define MAX_EXPERIENCE levels[settings.max_level] |
144 | #define MAX_EXPERIENCE levels [settings.max_level] |
145 | |
145 | |
146 | /* because exp_obj sum to make the total score, |
146 | /* because exp_obj sum to make the total score, |
147 | * we cannot allow that sum to exceed the maximum |
147 | * we cannot allow that sum to exceed the maximum |
148 | * amount of experience a player can gain. Thus |
148 | * amount of experience a player can gain. Thus |
149 | * we define MAX_EXP_IN_OBJ. It is important to try |
149 | * we define MAX_EXP_IN_OBJ. It is important to try |
… | |
… | |
156 | * line with progression of previous levels, so |
156 | * line with progression of previous levels, so |
157 | * if more levels are desired, this should be fixed. |
157 | * if more levels are desired, this should be fixed. |
158 | * -b.t. |
158 | * -b.t. |
159 | */ |
159 | */ |
160 | |
160 | |
161 | #define MAX_EXP_IN_OBJ levels[settings.max_level]/(MAX_EXP_CAT - 1) |
161 | #define MAX_EXP_IN_OBJ MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1) |
162 | |
|
|
163 | extern sint64 *levels; |
|
|
164 | |
162 | |
165 | #define MAX_SAVE_LEVEL 110 |
163 | #define MAX_SAVE_LEVEL 110 |
166 | |
164 | |
167 | /* This no longer needs to be changed anytime the number of |
165 | /* This no longer needs to be changed anytime the number of |
168 | * levels is increased - rather, did_make_save will do the |
166 | * levels is increased - rather, did_make_save will do the |
… | |
… | |
461 | if (op->flag [FLAG_WIZ]) |
459 | if (op->flag [FLAG_WIZ]) |
462 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self is blinded."); |
460 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self is blinded."); |
463 | else |
461 | else |
464 | { |
462 | { |
465 | new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); |
463 | new_draw_info (NDI_UNIQUE, 0, op, "You are blinded."); |
466 | SET_FLAG (op, FLAG_BLIND); |
464 | op->set_flag (FLAG_BLIND); |
467 | if (op->type == PLAYER) |
465 | if (op->type == PLAYER) |
468 | op->contr->do_los = 1; |
466 | op->contr->do_los = 1; |
469 | } |
467 | } |
470 | } |
468 | } |
471 | else |
469 | else |
… | |
… | |
473 | if (op->flag [FLAG_WIZ]) |
471 | if (op->flag [FLAG_WIZ]) |
474 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self can now see again."); |
472 | new_draw_info (NDI_UNIQUE, 0, op, "Your mortal self can now see again."); |
475 | else |
473 | else |
476 | { |
474 | { |
477 | new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); |
475 | new_draw_info (NDI_UNIQUE, 0, op, "Your vision returns."); |
478 | CLEAR_FLAG (op, FLAG_BLIND); |
476 | op->clr_flag (FLAG_BLIND); |
479 | if (op->type == PLAYER) |
477 | if (op->type == PLAYER) |
480 | op->contr->do_los = 1; |
478 | op->contr->do_los = 1; |
481 | } |
479 | } |
482 | } |
480 | } |
483 | } |
481 | } |
… | |
… | |
610 | |
608 | |
611 | if (!tmp) |
609 | if (!tmp) |
612 | { |
610 | { |
613 | tmp = at->instance (); |
611 | tmp = at->instance (); |
614 | tmp = insert_ob_in_ob (tmp, this); |
612 | tmp = insert_ob_in_ob (tmp, this); |
615 | SET_FLAG (tmp, FLAG_APPLIED); |
613 | tmp->set_flag (FLAG_APPLIED); |
616 | } |
614 | } |
617 | } |
615 | } |
618 | |
616 | |
619 | new_draw_info (NDI_UNIQUE, 0, this, drain_msg[deplete_stats]); |
617 | new_draw_info (NDI_UNIQUE, 0, this, drain_msg[deplete_stats]); |
620 | change_attr_value (&tmp->stats, deplete_stats, -1); |
618 | change_attr_value (&tmp->stats, deplete_stats, -1); |
… | |
… | |
640 | if (!value) |
638 | if (!value) |
641 | return; |
639 | return; |
642 | |
640 | |
643 | tmp = at->instance (); |
641 | tmp = at->instance (); |
644 | tmp = insert_ob_in_ob (tmp, this); |
642 | tmp = insert_ob_in_ob (tmp, this); |
645 | SET_FLAG (tmp, FLAG_APPLIED); |
643 | tmp->set_flag (FLAG_APPLIED); |
646 | } |
644 | } |
647 | |
645 | |
648 | if (value) |
646 | if (value) |
649 | { |
647 | { |
650 | /* Limit the luck value of the bad luck object to +/-100. This |
648 | /* Limit the luck value of the bad luck object to +/-100. This |
… | |
… | |
731 | * spell system split, grace points now added to system --peterm |
729 | * spell system split, grace points now added to system --peterm |
732 | */ |
730 | */ |
733 | void |
731 | void |
734 | object::update_stats () |
732 | object::update_stats () |
735 | { |
733 | { |
736 | float f, max_speed = 9, added_speed = 0, bonus_speed = 0, speed_reduce_from_disease = 1; |
734 | float max_speed = 9, added_speed = 0, bonus_speed = 0, speed_reduce_from_disease = 1; |
737 | int weapon_weight = 0, weapon_speed = 0; |
735 | weight_t weapon_weight = 0; |
|
|
736 | int weapon_speed = 0; |
738 | int best_wc = 0, best_ac = 0, wc = 0, ac = 0; |
737 | int best_wc = 0, best_ac = 0, wc = 0, ac = 0; |
739 | int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; |
738 | int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; |
740 | object *grace_obj = NULL, *mana_obj = NULL, *tmp; |
739 | object *grace_obj = NULL, *mana_obj = NULL, *tmp; |
741 | float old_speed = speed; |
740 | float old_speed = speed; |
742 | int stat_sum [NUM_STATS]; |
741 | int stat_sum [NUM_STATS]; |
… | |
… | |
767 | for (int i = NUM_BODY_LOCATIONS; i--; ) |
766 | for (int i = NUM_BODY_LOCATIONS; i--; ) |
768 | slot[i].used = slot[i].info; |
767 | slot[i].used = slot[i].info; |
769 | |
768 | |
770 | slaying = 0; |
769 | slaying = 0; |
771 | |
770 | |
772 | if (!QUERY_FLAG (this, FLAG_WIZ)) |
771 | if (!this->flag [FLAG_WIZ]) |
773 | { |
|
|
774 | CLEAR_FLAG (this, FLAG_XRAYS); |
|
|
775 | CLEAR_FLAG (this, FLAG_MAKE_INVIS); |
|
|
776 | } |
772 | { |
|
|
773 | this->clr_flag (FLAG_XRAYS); |
|
|
774 | this->clr_flag (FLAG_MAKE_INVIS); |
|
|
775 | } |
777 | |
776 | |
778 | CLEAR_FLAG (this, FLAG_LIFESAVE); |
777 | this->clr_flag (FLAG_LIFESAVE); |
779 | CLEAR_FLAG (this, FLAG_STEALTH); |
778 | this->clr_flag (FLAG_STEALTH); |
780 | CLEAR_FLAG (this, FLAG_BLIND); |
779 | this->clr_flag (FLAG_BLIND); |
781 | |
780 | |
782 | if (!QUERY_FLAG (arch, FLAG_REFL_SPELL )) CLEAR_FLAG (this, FLAG_REFL_SPELL); |
781 | if (!arch->flag [FLAG_REFL_SPELL ]) this->clr_flag (FLAG_REFL_SPELL); |
783 | if (!QUERY_FLAG (arch, FLAG_REFL_MISSILE)) CLEAR_FLAG (this, FLAG_REFL_MISSILE); |
782 | if (!arch->flag [FLAG_REFL_MISSILE]) this->clr_flag (FLAG_REFL_MISSILE); |
784 | if (!QUERY_FLAG (arch, FLAG_UNDEAD )) CLEAR_FLAG (this, FLAG_UNDEAD); |
783 | if (!arch->flag [FLAG_UNDEAD ]) this->clr_flag (FLAG_UNDEAD); |
785 | if (!QUERY_FLAG (arch, FLAG_SEE_IN_DARK )) CLEAR_FLAG (this, FLAG_SEE_IN_DARK); |
784 | if (!arch->flag [FLAG_SEE_IN_DARK ]) this->clr_flag (FLAG_SEE_IN_DARK); |
786 | |
785 | |
787 | path_attuned = arch->path_attuned; |
786 | path_attuned = arch->path_attuned; |
788 | path_repelled = arch->path_repelled; |
787 | path_repelled = arch->path_repelled; |
789 | path_denied = arch->path_denied; |
788 | path_denied = arch->path_denied; |
790 | glow_radius = arch->glow_radius; |
789 | glow_radius = arch->glow_radius; |
… | |
… | |
813 | * the fact that maxlevel is factored in could be considered sort of bogus - |
812 | * the fact that maxlevel is factored in could be considered sort of bogus - |
814 | * we should probably give them some bonus and cap it off - otherwise, |
813 | * we should probably give them some bonus and cap it off - otherwise, |
815 | * basically, if a server updates its max level, these playes may find |
814 | * basically, if a server updates its max level, these playes may find |
816 | * that their protection from physical goes down |
815 | * that their protection from physical goes down |
817 | */ |
816 | */ |
818 | if (!QUERY_FLAG (this, FLAG_USE_ARMOUR) && type == PLAYER) |
817 | if (!this->flag [FLAG_USE_ARMOUR] && type == PLAYER) |
819 | { |
818 | { |
820 | ac = max (-10, arch->stats.ac - level / 3); |
819 | ac = max (-10, arch->stats.ac - level / 3); |
821 | prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; |
820 | prot[ATNR_PHYSICAL] += ((100 - prot[AT_PHYSICAL]) * (80 * level / settings.max_level)) / 100; |
822 | } |
821 | } |
823 | else |
822 | else |
… | |
… | |
835 | { |
834 | { |
836 | /* This happens because apply_potion calls change_abil with the potion |
835 | /* This happens because apply_potion calls change_abil with the potion |
837 | * applied so we can tell the player what changed. But change_abil |
836 | * applied so we can tell the player what changed. But change_abil |
838 | * then calls this function. |
837 | * then calls this function. |
839 | */ |
838 | */ |
840 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) |
839 | if (tmp->flag [FLAG_APPLIED] && tmp->type == POTION) |
841 | continue; |
840 | continue; |
842 | |
841 | |
843 | glow_radius += tmp->glow_radius; |
842 | glow_radius += tmp->glow_radius; |
844 | |
843 | |
845 | /* For some things, we don't care what is equipped */ |
844 | /* For some things, we don't care what is equipped */ |
… | |
… | |
872 | * because the skill shouldn't count against body positions being used |
871 | * because the skill shouldn't count against body positions being used |
873 | * up, etc. |
872 | * up, etc. |
874 | */ |
873 | */ |
875 | if ((tmp->flag [FLAG_APPLIED] |
874 | if ((tmp->flag [FLAG_APPLIED] |
876 | && tmp->type != CONTAINER |
875 | && tmp->type != CONTAINER |
877 | && tmp->type != CLOSE_CON) |
876 | && tmp->type != CLOSE_CON |
|
|
877 | && tmp->type != SPELL) |
878 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
878 | || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) |
879 | { |
879 | { |
880 | if (type == PLAYER) |
880 | if (type == PLAYER) |
881 | { |
881 | { |
882 | contr->item_power += tmp->item_power; |
882 | contr->item_power += tmp->item_power; |
… | |
… | |
917 | for (int i = 0; i < NROFATTACKS; i++) |
917 | for (int i = 0; i < NROFATTACKS; i++) |
918 | max_it (potion_resist[i], tmp->resist[i]); |
918 | max_it (potion_resist[i], tmp->resist[i]); |
919 | else if (tmp->type != POTION) |
919 | else if (tmp->type != POTION) |
920 | for (int i = 0; i < NROFATTACKS; i++) |
920 | for (int i = 0; i < NROFATTACKS; i++) |
921 | if (tmp->resist[i] > 0) |
921 | if (tmp->resist[i] > 0) |
922 | prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; |
922 | prot[i] += (100 - prot[i]) * tmp->resist[i] / 100; |
923 | else if (tmp->resist[i] < 0) |
923 | else if (tmp->resist[i] < 0) |
924 | vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; |
924 | vuln[i] += (100 - vuln[i]) * -tmp->resist[i] / 100; |
925 | |
925 | |
926 | /* There may be other things that should not adjust the attacktype */ |
926 | /* There may be other things that should not adjust the attacktype */ |
927 | if (tmp->type != SYMPTOM) |
927 | if (tmp->type != SYMPTOM) |
928 | { |
928 | { |
929 | attacktype |= tmp->attacktype; |
929 | attacktype |= tmp->attacktype; |
… | |
… | |
934 | stats.luck += tmp->stats.luck; |
934 | stats.luck += tmp->stats.luck; |
935 | } |
935 | } |
936 | |
936 | |
937 | flag |= tmp->flag & copy_flags; |
937 | flag |= tmp->flag & copy_flags; |
938 | |
938 | |
939 | if (QUERY_FLAG (tmp, FLAG_UNDEAD) && !QUERY_FLAG (arch, FLAG_UNDEAD)) |
939 | if (tmp->flag [FLAG_UNDEAD] && !arch->flag [FLAG_UNDEAD]) |
940 | SET_FLAG (this, FLAG_UNDEAD); |
940 | this->set_flag (FLAG_UNDEAD); |
941 | |
941 | |
942 | //TODO: copy_flags? |
942 | //TODO: copy_flags? |
943 | if (QUERY_FLAG (tmp, FLAG_MAKE_INVIS)) |
943 | if (tmp->flag [FLAG_MAKE_INVIS]) |
944 | { |
944 | { |
945 | SET_FLAG (this, FLAG_MAKE_INVIS); |
945 | set_flag (FLAG_MAKE_INVIS); |
946 | invisible = 1; |
946 | invisible = 1; |
947 | } |
947 | } |
948 | |
948 | |
949 | if (tmp->stats.exp && tmp->type != SKILL) |
949 | if (tmp->stats.exp && tmp->type != SKILL) |
950 | { |
950 | { |
… | |
… | |
977 | |
977 | |
978 | chosen_skill = tmp; |
978 | chosen_skill = tmp; |
979 | |
979 | |
980 | if (tmp->stats.dam > 0) |
980 | if (tmp->stats.dam > 0) |
981 | { /* skill is a 'weapon' */ |
981 | { /* skill is a 'weapon' */ |
982 | if (!QUERY_FLAG (this, FLAG_READY_WEAPON)) |
982 | if (!this->flag [FLAG_READY_WEAPON]) |
983 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
983 | weapon_speed = max (0, WEAPON_SPEED (tmp)); |
984 | |
984 | |
985 | weapon_weight = tmp->weight; |
985 | weapon_weight = tmp->weight; |
986 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
986 | stats.dam += 1 + chosen_skill->level * tmp->stats.dam / 9; |
987 | |
987 | |
… | |
… | |
997 | |
997 | |
998 | if (tmp->stats.ac) |
998 | if (tmp->stats.ac) |
999 | ac -= tmp->stats.ac + tmp->magic; |
999 | ac -= tmp->stats.ac + tmp->magic; |
1000 | |
1000 | |
1001 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1001 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1002 | contr->encumbrance += 3 * tmp->weight / 1000; |
1002 | contr->encumbrance += weight_to_kg_approx (3 * tmp->weight); |
1003 | } |
1003 | } |
1004 | |
1004 | |
1005 | break; |
1005 | break; |
1006 | |
1006 | |
1007 | case SHIELD: |
1007 | case SHIELD: |
1008 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1008 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1009 | contr->encumbrance += tmp->weight / 2000; |
1009 | contr->encumbrance += weight_to_kg_approx (tmp->weight) >> 1; |
1010 | //FALLTHROUGH |
1010 | //FALLTHROUGH |
1011 | case RING: |
1011 | case RING: |
1012 | case AMULET: |
1012 | case AMULET: |
1013 | case GIRDLE: |
1013 | case GIRDLE: |
1014 | case HELMET: |
1014 | case HELMET: |
… | |
… | |
1024 | if (tmp->stats.ac) |
1024 | if (tmp->stats.ac) |
1025 | ac -= tmp->stats.ac + tmp->magic; |
1025 | ac -= tmp->stats.ac + tmp->magic; |
1026 | |
1026 | |
1027 | break; |
1027 | break; |
1028 | |
1028 | |
1029 | case WAND: |
1029 | case RANGED: |
1030 | case ROD: |
|
|
1031 | case HORN: |
|
|
1032 | break; |
|
|
1033 | |
|
|
1034 | case BOW: |
1030 | case BOW: |
1035 | case WEAPON: |
1031 | case WEAPON: |
1036 | wc -= tmp->stats.wc + tmp->magic; |
1032 | wc -= tmp->stats.wc + tmp->magic; |
1037 | |
1033 | |
1038 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
1034 | if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) |
… | |
… | |
1052 | * go. |
1048 | * go. |
1053 | */ |
1049 | */ |
1054 | |
1050 | |
1055 | if (type == PLAYER) |
1051 | if (type == PLAYER) |
1056 | if (settings.spell_encumbrance) |
1052 | if (settings.spell_encumbrance) |
1057 | contr->encumbrance += tmp->weight * 3 / 1000; |
1053 | contr->encumbrance += weight_to_kg_approx (3 * tmp->weight); |
1058 | |
1054 | |
1059 | break; |
1055 | break; |
1060 | |
1056 | |
1061 | case ARMOUR: /* Only the best of these three are used: */ |
1057 | case ARMOUR: /* Only the best of these three are used: */ |
1062 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1058 | if (settings.spell_encumbrance == TRUE && type == PLAYER) |
1063 | contr->encumbrance += tmp->weight / 1000; |
1059 | contr->encumbrance += weight_to_kg_approx (tmp->weight); |
1064 | |
1060 | |
1065 | case BRACERS: |
1061 | case BRACERS: |
1066 | case FORCE: |
1062 | case FORCE: |
1067 | if (tmp->stats.wc) |
1063 | if (tmp->stats.wc) |
1068 | { |
1064 | { |
… | |
… | |
1091 | |
1087 | |
1092 | if (tmp->stats.ac) |
1088 | if (tmp->stats.ac) |
1093 | ac -= tmp->stats.ac + tmp->magic; |
1089 | ac -= tmp->stats.ac + tmp->magic; |
1094 | |
1090 | |
1095 | if (ARMOUR_SPEED (tmp)) |
1091 | if (ARMOUR_SPEED (tmp)) |
1096 | max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); |
1092 | min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f); |
1097 | |
1093 | |
1098 | break; |
1094 | break; |
1099 | } /* switch tmp->type */ |
1095 | } /* switch tmp->type */ |
1100 | } /* item is equipped */ |
1096 | } /* item is equipped */ |
1101 | } /* for loop of items */ |
1097 | } /* for loop of items */ |
… | |
… | |
1294 | /* f is a number the represents the number of kg above (positive num) |
1290 | /* f is a number the represents the number of kg above (positive num) |
1295 | * or below (negative number) that the player is carrying. If above |
1291 | * or below (negative number) that the player is carrying. If above |
1296 | * weight limit, then player suffers a speed reduction based on how |
1292 | * weight limit, then player suffers a speed reduction based on how |
1297 | * much above he is, and what is max carry is |
1293 | * much above he is, and what is max carry is |
1298 | */ |
1294 | */ |
1299 | float f = (carrying / 1000) - max_carry[stats.Str]; |
1295 | float f = (sint32)weight_to_kg_approx (carrying) - max_carry[stats.Str]; |
1300 | if (f > 0.f) |
1296 | if (f > 0.f) |
1301 | speed = speed / (1.f + f / max_carry[stats.Str]); |
1297 | speed /= (1.f + f / max_carry[stats.Str]); |
1302 | } |
1298 | } |
1303 | |
1299 | |
1304 | speed += bonus_speed / 10.f; /* Not affected by limits */ |
1300 | speed += bonus_speed / 10.f; /* Not affected by limits */ |
1305 | speed *= speed_reduce_from_disease; |
1301 | speed *= speed_reduce_from_disease; |
1306 | |
1302 | |
… | |
… | |
1382 | update_all_los (env->map, env->x, env->y); |
1378 | update_all_los (env->map, env->x, env->y); |
1383 | } |
1379 | } |
1384 | } |
1380 | } |
1385 | |
1381 | |
1386 | /* |
1382 | /* |
1387 | * Returns true if the given player is a legal class. |
|
|
1388 | * The function to add and remove class-bonuses to the stats doesn't |
|
|
1389 | * check if the stat becomes negative, thus this function |
|
|
1390 | * merely checks that all stats are 1 or more, and returns |
|
|
1391 | * false otherwise. |
|
|
1392 | */ |
|
|
1393 | int |
|
|
1394 | allowed_class (const object *op) |
|
|
1395 | { |
|
|
1396 | return op->stats.Dex > 0 |
|
|
1397 | && op->stats.Str > 0 |
|
|
1398 | && op->stats.Con > 0 |
|
|
1399 | && op->stats.Int > 0 |
|
|
1400 | && op->stats.Wis > 0 |
|
|
1401 | && op->stats.Pow > 0 |
|
|
1402 | && op->stats.Cha > 0; |
|
|
1403 | } |
|
|
1404 | |
|
|
1405 | /* |
|
|
1406 | * set the new dragon name after gaining levels or |
1383 | * set the new dragon name after gaining levels or |
1407 | * changing ability focus (later this can be extended to |
1384 | * changing ability focus (later this can be extended to |
1408 | * eventually change the player's face and animation) |
1385 | * eventually change the player's face and animation) |
1409 | */ |
1386 | */ |
1410 | void |
1387 | void |
… | |
… | |
1525 | } |
1502 | } |
1526 | |
1503 | |
1527 | /* clear the flag - exp goes into this bucket, but player |
1504 | /* clear the flag - exp goes into this bucket, but player |
1528 | * still doesn't know it. |
1505 | * still doesn't know it. |
1529 | */ |
1506 | */ |
1530 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1507 | skill_obj->clr_flag (FLAG_CAN_USE_SKILL); |
1531 | skill_obj->stats.exp = 0; |
1508 | skill_obj->stats.exp = 0; |
1532 | skill_obj->level = 1; |
1509 | skill_obj->level = 1; |
1533 | op->insert (skill_obj); |
1510 | op->insert (skill_obj); |
1534 | |
1511 | |
1535 | if (player *pl = op->contr) |
1512 | if (player *pl = op->contr) |
… | |
… | |
1612 | */ |
1589 | */ |
1613 | |
1590 | |
1614 | sint64 |
1591 | sint64 |
1615 | level_exp (int level, double expmul) |
1592 | level_exp (int level, double expmul) |
1616 | { |
1593 | { |
1617 | if (level > settings.max_level) |
1594 | return expmul * level_to_min_exp (level); |
1618 | return (sint64) (expmul * levels[settings.max_level]); |
|
|
1619 | |
|
|
1620 | return (sint64) (expmul * levels[level]); |
|
|
1621 | } |
1595 | } |
1622 | |
1596 | |
1623 | /* |
1597 | /* |
1624 | * Ensure that the permanent experience requirements in an exp object are met. |
1598 | * Ensure that the permanent experience requirements in an exp object are met. |
1625 | * This really just checks 'op to make sure the perm_exp value is within |
1599 | * This really just checks 'op to make sure the perm_exp value is within |
… | |
… | |
1653 | * NULL, in which case exp increases the players general |
1627 | * NULL, in which case exp increases the players general |
1654 | * total, but not any particular skill. |
1628 | * total, but not any particular skill. |
1655 | * flag is what to do if the player doesn't have the skill: |
1629 | * flag is what to do if the player doesn't have the skill: |
1656 | */ |
1630 | */ |
1657 | static void |
1631 | static void |
1658 | add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1632 | add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) |
1659 | { |
1633 | { |
1660 | object *skill_obj; |
1634 | object *skill_obj; |
1661 | sint64 limit, exp_to_add; |
1635 | sint64 limit, exp_to_add; |
1662 | int i; |
|
|
1663 | |
1636 | |
1664 | /* prevents some forms of abuse. */ |
1637 | /* prevents some forms of abuse. */ |
1665 | if (op->contr->braced) |
1638 | if (op->contr->braced) |
1666 | exp /= 5; |
1639 | exp /= 5; |
1667 | |
1640 | |
… | |
… | |
1693 | { |
1666 | { |
1694 | /* Basically, you can never gain more experience in one shot |
1667 | /* Basically, you can never gain more experience in one shot |
1695 | * than half what you need to gain for next level. |
1668 | * than half what you need to gain for next level. |
1696 | */ |
1669 | */ |
1697 | exp_to_add = exp; |
1670 | exp_to_add = exp; |
1698 | limit = (levels[op->level + 1] - levels[op->level]) / 2; |
1671 | limit = (levels [op->level + 1] - levels [op->level]) / 2; |
1699 | if (exp_to_add > limit) |
1672 | if (exp_to_add > limit) |
1700 | exp_to_add = limit; |
1673 | exp_to_add = limit; |
1701 | |
1674 | |
1702 | ADD_EXP (op->stats.exp, (sint64) ((float) exp_to_add * (skill_obj ? skill_obj->expmul : 1))); |
1675 | ADD_EXP (op->stats.exp, (sint64) ((float) exp_to_add * (skill_obj ? skill_obj->expmul : 1))); |
1703 | if (settings.permanent_exp_ratio) |
1676 | if (settings.permanent_exp_ratio) |
… | |
… | |
1710 | } |
1683 | } |
1711 | |
1684 | |
1712 | if (skill_obj) |
1685 | if (skill_obj) |
1713 | { |
1686 | { |
1714 | exp_to_add = exp; |
1687 | exp_to_add = exp; |
1715 | limit = (levels[skill_obj->level + 1] - levels[skill_obj->level]) / 2; |
1688 | limit = (levels [skill_obj->level + 1] - levels [skill_obj->level]) / 2; |
1716 | if (exp_to_add > limit) |
1689 | if (exp_to_add > limit) |
1717 | exp_to_add = limit; |
1690 | exp_to_add = limit; |
1718 | |
1691 | |
1719 | ADD_EXP (skill_obj->stats.exp, exp_to_add); |
1692 | ADD_EXP (skill_obj->stats.exp, exp_to_add); |
1720 | if (settings.permanent_exp_ratio) |
1693 | if (settings.permanent_exp_ratio) |
… | |
… | |
1777 | * where everything is at the minimum perm exp, he would lose nothing. |
1750 | * where everything is at the minimum perm exp, he would lose nothing. |
1778 | * exp is the amount of exp to subtract - thus, it should be |
1751 | * exp is the amount of exp to subtract - thus, it should be |
1779 | * a postive number. |
1752 | * a postive number. |
1780 | */ |
1753 | */ |
1781 | static void |
1754 | static void |
1782 | subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) |
1755 | subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag) |
1783 | { |
1756 | { |
1784 | float fraction = (float) exp / (float) op->stats.exp; |
1757 | float fraction = (float) exp / (float) op->stats.exp; |
1785 | object *tmp; |
1758 | object *tmp; |
1786 | sint64 del_exp; |
1759 | sint64 del_exp; |
1787 | |
1760 | |
1788 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1761 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1789 | if (tmp->type == SKILL && tmp->stats.exp) |
1762 | if (tmp->type == SKILL && tmp->stats.exp) |
1790 | { |
1763 | { |
1791 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) |
1764 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill) |
1792 | { |
1765 | { |
1793 | del_exp = check_exp_loss (tmp, exp); |
1766 | del_exp = check_exp_loss (tmp, exp); |
1794 | tmp->stats.exp -= del_exp; |
1767 | tmp->stats.exp -= del_exp; |
1795 | player_lvl_adj (op, tmp); |
1768 | player_lvl_adj (op, tmp); |
1796 | } |
1769 | } |
1797 | else if (flag != SK_SUBTRACT_SKILL_EXP) |
1770 | else if (flag != SK_SUBTRACT_SKILL_EXP) |
1798 | { |
1771 | { |
1799 | /* only want to process other skills if we are not trying |
1772 | /* only want to process other skills if we are not trying |
1800 | * to match a specific skill. |
1773 | * to match a specific skill. |
1801 | */ |
1774 | */ |
1802 | del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); |
1775 | del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction); |
1803 | tmp->stats.exp -= del_exp; |
1776 | tmp->stats.exp -= del_exp; |
1804 | player_lvl_adj (op, tmp); |
1777 | player_lvl_adj (op, tmp); |
1805 | } |
1778 | } |
1806 | } |
1779 | } |
1807 | |
1780 | |
… | |
… | |
1821 | * skill_name is the skill that should get the exp added. |
1794 | * skill_name is the skill that should get the exp added. |
1822 | * flag is what to do if player doesn't have the skill. |
1795 | * flag is what to do if player doesn't have the skill. |
1823 | * these last two values are only used for players. |
1796 | * these last two values are only used for players. |
1824 | */ |
1797 | */ |
1825 | void |
1798 | void |
1826 | change_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1799 | change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) |
1827 | { |
1800 | { |
1828 | #ifdef EXP_DEBUG |
1801 | #ifdef EXP_DEBUG |
1829 | LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); |
1802 | LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); |
1830 | #endif |
1803 | #endif |
1831 | |
1804 | |
… | |
… | |
1848 | * worth. |
1821 | * worth. |
1849 | */ |
1822 | */ |
1850 | if (op->type != PLAYER) |
1823 | if (op->type != PLAYER) |
1851 | { |
1824 | { |
1852 | /* Sanity check */ |
1825 | /* Sanity check */ |
1853 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1826 | if (!op->flag [FLAG_ALIVE]) |
1854 | return; |
1827 | return; |
1855 | |
1828 | |
1856 | /* reset exp to max allowed value. We subtract from |
1829 | /* reset exp to max allowed value. We subtract from |
1857 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1830 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1858 | * more than max exp, just return. |
1831 | * more than max exp, just return. |
… | |
… | |
1909 | tmp->stats.exp -= loss; |
1882 | tmp->stats.exp -= loss; |
1910 | player_lvl_adj (op, tmp); |
1883 | player_lvl_adj (op, tmp); |
1911 | } |
1884 | } |
1912 | |
1885 | |
1913 | percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; |
1886 | percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; |
1914 | level_loss = op->stats.exp - levels[max (0, op->level - settings.death_penalty_level)]; |
1887 | level_loss = op->stats.exp - levels [max (0, op->level - settings.death_penalty_level)]; |
1915 | |
1888 | |
1916 | if (level_loss < 0) |
1889 | if (level_loss < 0) |
1917 | level_loss = 0; |
1890 | level_loss = 0; |
1918 | |
1891 | |
1919 | loss = check_exp_loss (op, min (level_loss, percentage_loss)); |
1892 | loss = check_exp_loss (op, min (level_loss, percentage_loss)); |