ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/living.C
(Generate patch)

Comparing deliantra/server/common/living.C (file contents):
Revision 1.120 by root, Fri Apr 30 09:36:32 2010 UTC vs.
Revision 1.133 by root, Sun Jan 29 02:47:04 2017 UTC

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,2013,2014,2015,2016 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
33static const int con_bonus[MAX_STAT + 1] = { 33static 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 */
42static const int sp_bonus[MAX_STAT + 1] = { 42static 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,
47static const int grace_bonus[MAX_STAT + 1] = { 47static const int grace_bonus[MAX_STAT + 1] = {
48 -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, 48 -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,
49 30, 40, 50, 70, 100 49 30, 40, 50, 70, 100
50}; 50};
51 51
52/* 0.92.7 Changed way charisma works. Values now 52/* 0.92.7 Changed way charisma works. Values now
53 * represent how much more it costs to buy something than to sell it 53 * represent how much more it costs to buy something than to sell it
54 * (10, a value of 10 means it is that if it costs 50 gp to buy, you 54 * (10, a value of 10 means it is that if it costs 50 gp to buy, you
55 * would only get 5 gp when you sell.) Let query_cost do the calculations 55 * would only get 5 gp when you sell.) Let query_cost do the calculations
56 * on how to really do this. Buy keeping it this simple number, it is 56 * on how to really do this. Buy keeping it this simple number, it is
57 * much easier to know how things will be influenced. A value of '1' means 57 * much easier to know how things will be influenced. A value of '1' means
58 * buying and selling is both the same value - any value less than or equal 58 * buying and selling is both the same value - any value less than or equal
59 * to 1 should not be used. 59 * to 1 should not be used.
60 * At least as of now, the only place that uses this code is query_cost, 60 * At least as of now, the only place that uses this code is query_cost,
61 * in server/shop.c. This bonus is split evenly between buying and selling 61 * in server/shop.c. This bonus is split evenly between buying and selling
62 * (ie, if the bonus is 2.0, then items are bought for 1.33 list, and sold 62 * (ie, if the bonus is 2.0, then items are bought for 1.33 list, and sold
63 * at .667 63 * at .667
64 * This is figured by diff=(y-1)/(1+y), and for buy, it is 1+diff, for sell 64 * This is figured by diff=(y-1)/(1+y), and for buy, it is 1+diff, for sell
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
112const uint32 weight_limit[MAX_STAT + 1] = { 112const 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
122const int learn_spell[MAX_STAT + 1] = { 122const 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
150 * to make the value of MAX_EXP_CAT close to the 150 * to make the value of MAX_EXP_CAT close to the
151 * actual number of experience objects in the game, 151 * actual number of experience objects in the game,
152 * otherwise the maximum level in any experience 152 * otherwise the maximum level in any experience
153 * category could be quite low. To help the situation 153 * category could be quite low. To help the situation
154 * out a little I added 10 more levels, and jacked 154 * out a little I added 10 more levels, and jacked
155 * up the last level experience value. Its out of 155 * up the last level experience value. Its out of
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 MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1) 161#define MAX_EXP_IN_OBJ MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1)
337 check_stat_bounds (&op->stats); 337 check_stat_bounds (&op->stats);
338 } /* end of potion handling code */ 338 } /* end of potion handling code */
339 } 339 }
340 340
341 /* reset attributes that update_stats doesn't reset since it doesn't search 341 /* reset attributes that update_stats doesn't reset since it doesn't search
342 * everything to set 342 * everything to set
343 */ 343 */
344 if (flag == -1) 344 if (flag == -1)
345 { 345 {
346 op->attacktype &= ~tmp->attacktype; 346 op->attacktype &= ~tmp->attacktype;
347 op->path_attuned &= ~tmp->path_attuned; 347 op->path_attuned &= ~tmp->path_attuned;
416 if (tmp->move_type & MOVE_SWIM) 416 if (tmp->move_type & MOVE_SWIM)
417 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); 417 DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming");
418 } 418 }
419 419
420 /* becoming UNDEAD... a special treatment for this flag. Only those not 420 /* becoming UNDEAD... a special treatment for this flag. Only those not
421 * originally undead may change their status 421 * originally undead may change their status
422 */ 422 */
423 if (!op->arch->flag [FLAG_UNDEAD]) 423 if (!op->arch->flag [FLAG_UNDEAD])
424 if (op->flag [FLAG_UNDEAD] != prev_flag [FLAG_UNDEAD]) 424 if (op->flag [FLAG_UNDEAD] != prev_flag [FLAG_UNDEAD])
425 { 425 {
426 success = 1; 426 success = 1;
447 success = 1; 447 success = 1;
448 DIFF_MSG (flag, "You become transparent.", "You can see yourself."); 448 DIFF_MSG (flag, "You become transparent.", "You can see yourself.");
449 } 449 }
450 450
451 /* blinded you can tell if more blinded since blinded player has minimal 451 /* blinded you can tell if more blinded since blinded player has minimal
452 * vision 452 * vision
453 */ 453 */
454 if (tmp->flag [FLAG_BLIND]) 454 if (tmp->flag [FLAG_BLIND])
455 { 455 {
456 success = 1; 456 success = 1;
457 if (flag > 0) 457 if (flag > 0)
729 * spell system split, grace points now added to system --peterm 729 * spell system split, grace points now added to system --peterm
730 */ 730 */
731void 731void
732object::update_stats () 732object::update_stats ()
733{ 733{
734 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;
735 int weapon_weight = 0, weapon_speed = 0; 735 weight_t weapon_weight = 0;
736 int weapon_speed = 0;
736 int best_wc = 0, best_ac = 0, wc = 0, ac = 0; 737 int best_wc = 0, best_ac = 0, wc = 0, ac = 0;
737 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; 738 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS];
738 object *grace_obj = NULL, *mana_obj = NULL, *tmp; 739 object *grace_obj = NULL, *mana_obj = NULL, *tmp;
739 float old_speed = speed; 740 float old_speed = speed;
740 int stat_sum [NUM_STATS]; 741 int stat_sum [NUM_STATS];
805 806
806 wc = arch->stats.wc; 807 wc = arch->stats.wc;
807 stats.dam = arch->stats.dam; 808 stats.dam = arch->stats.dam;
808 809
809 /* for players which cannot use armour, they gain AC -1 per 3 levels, 810 /* for players which cannot use armour, they gain AC -1 per 3 levels,
810 * plus a small amount of physical resist, those poor suckers. ;) 811 * plus a small amount of physical resist, those poor suckers. ;)
811 * 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 -
812 * 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,
813 * 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
814 * that their protection from physical goes down 815 * that their protection from physical goes down
815 */ 816 */
861 } 862 }
862 } 863 }
863 864
864 /* Container objects are not meant to adjust players, but other applied 865 /* Container objects are not meant to adjust players, but other applied
865 * objects need to make adjustments. 866 * objects need to make adjustments.
866 * This block should handle all player specific changes 867 * This block should handle all player specific changes
867 * The check for Praying is a bit of a hack - god given bonuses are put 868 * The check for Praying is a bit of a hack - god given bonuses are put
868 * in the praying skill, and the player should always get those. 869 * in the praying skill, and the player should always get those.
869 * It also means we need to put in additional checks for applied below, 870 * It also means we need to put in additional checks for applied below,
870 * because the skill shouldn't count against body positions being used 871 * because the skill shouldn't count against body positions being used
871 * up, etc. 872 * up, etc.
872 */ 873 */
873 if ((tmp->flag [FLAG_APPLIED] 874 if ((tmp->flag [FLAG_APPLIED]
874 && tmp->type != CONTAINER 875 && tmp->type != CONTAINER
875 && tmp->type != CLOSE_CON) 876 && tmp->type != CLOSE_CON
877 && tmp->type != SPELL)
876 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) 878 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING))
877 { 879 {
878 if (type == PLAYER) 880 if (type == PLAYER)
879 { 881 {
880 contr->item_power += tmp->item_power; 882 contr->item_power += tmp->item_power;
902 if (tmp->flag [FLAG_APPLIED]) // exclude praying... 904 if (tmp->flag [FLAG_APPLIED]) // exclude praying...
903 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 905 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
904 slot[i].used += tmp->slot[i].info; 906 slot[i].used += tmp->slot[i].info;
905 907
906 if (tmp->type == SYMPTOM) 908 if (tmp->type == SYMPTOM)
907 min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f); 909 min_it (speed_reduce_from_disease, tmp->last_sp ? tmp->last_sp / 100.f : 1.f);
908 910
909 /* Pos. and neg. protections are counted separate (-> pro/vuln). 911 /* Pos. and neg. protections are counted separate (-> pro/vuln).
910 * (Negative protections are calculated exactly like positive.) 912 * (Negative protections are calculated exactly like positive.)
911 * Resistance from potions are treated special as well. If there's 913 * Resistance from potions are treated special as well. If there's
912 * more than one potion-effect, the bigger prot.-value is taken. 914 * more than one potion-effect, the bigger prot.-value is taken.
913 */ 915 */
914 if (tmp->type == POTION_EFFECT) 916 if (tmp->type == POTION_EFFECT)
915 for (int i = 0; i < NROFATTACKS; i++) 917 for (int i = 0; i < NROFATTACKS; i++)
916 max_it (potion_resist[i], tmp->resist[i]); 918 max_it (potion_resist[i], tmp->resist[i]);
917 else if (tmp->type != POTION) 919 else if (tmp->type != POTION)
918 for (int i = 0; i < NROFATTACKS; i++) 920 for (int i = 0; i < NROFATTACKS; i++)
919 if (tmp->resist[i] > 0) 921 if (tmp->resist[i] > 0)
920 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 922 prot[i] += (100 - prot[i]) * tmp->resist[i] / 100;
921 else if (tmp->resist[i] < 0) 923 else if (tmp->resist[i] < 0)
922 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 924 vuln[i] += (100 - vuln[i]) * -tmp->resist[i] / 100;
923 925
924 /* There may be other things that should not adjust the attacktype */ 926 /* There may be other things that should not adjust the attacktype */
925 if (tmp->type != SYMPTOM) 927 if (tmp->type != SYMPTOM)
926 { 928 {
927 attacktype |= tmp->attacktype; 929 attacktype |= tmp->attacktype;
995 997
996 if (tmp->stats.ac) 998 if (tmp->stats.ac)
997 ac -= tmp->stats.ac + tmp->magic; 999 ac -= tmp->stats.ac + tmp->magic;
998 1000
999 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1001 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1000 contr->encumbrance += 3 * tmp->weight / 1000; 1002 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1001 } 1003 }
1002 1004
1003 break; 1005 break;
1004 1006
1005 case SHIELD: 1007 case SHIELD:
1006 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1008 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1007 contr->encumbrance += tmp->weight / 2000; 1009 contr->encumbrance += weight_to_kg_approx (tmp->weight) >> 1;
1008 //FALLTHROUGH 1010 //FALLTHROUGH
1009 case RING: 1011 case RING:
1010 case AMULET: 1012 case AMULET:
1011 case GIRDLE: 1013 case GIRDLE:
1012 case HELMET: 1014 case HELMET:
1022 if (tmp->stats.ac) 1024 if (tmp->stats.ac)
1023 ac -= tmp->stats.ac + tmp->magic; 1025 ac -= tmp->stats.ac + tmp->magic;
1024 1026
1025 break; 1027 break;
1026 1028
1027 case WAND: 1029 case RANGED:
1028 case ROD:
1029 case HORN:
1030 break;
1031
1032 case BOW: 1030 case BOW:
1033 case WEAPON: 1031 case WEAPON:
1034 wc -= tmp->stats.wc + tmp->magic; 1032 wc -= tmp->stats.wc + tmp->magic;
1035 1033
1036 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1034 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1050 * go. 1048 * go.
1051 */ 1049 */
1052 1050
1053 if (type == PLAYER) 1051 if (type == PLAYER)
1054 if (settings.spell_encumbrance) 1052 if (settings.spell_encumbrance)
1055 contr->encumbrance += tmp->weight * 3 / 1000; 1053 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1056 1054
1057 break; 1055 break;
1058 1056
1059 case ARMOUR: /* Only the best of these three are used: */ 1057 case ARMOUR: /* Only the best of these three are used: */
1060 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1058 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1061 contr->encumbrance += tmp->weight / 1000; 1059 contr->encumbrance += weight_to_kg_approx (tmp->weight);
1062 1060
1063 case BRACERS: 1061 case BRACERS:
1064 case FORCE: 1062 case FORCE:
1065 if (tmp->stats.wc) 1063 if (tmp->stats.wc)
1066 { 1064 {
1089 1087
1090 if (tmp->stats.ac) 1088 if (tmp->stats.ac)
1091 ac -= tmp->stats.ac + tmp->magic; 1089 ac -= tmp->stats.ac + tmp->magic;
1092 1090
1093 if (ARMOUR_SPEED (tmp)) 1091 if (ARMOUR_SPEED (tmp))
1094 max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); 1092 min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f);
1095 1093
1096 break; 1094 break;
1097 } /* switch tmp->type */ 1095 } /* switch tmp->type */
1098 } /* item is equipped */ 1096 } /* item is equipped */
1099 } /* for loop of items */ 1097 } /* for loop of items */
1106 1104
1107 /* 'total resistance = total protections - total vulnerabilities'. 1105 /* 'total resistance = total protections - total vulnerabilities'.
1108 * If there is an uncursed potion in effect, granting more protection 1106 * If there is an uncursed potion in effect, granting more protection
1109 * than that, we take: 'total resistance = resistance from potion'. 1107 * than that, we take: 'total resistance = resistance from potion'.
1110 * If there is a cursed (and no uncursed) potion in effect, we take 1108 * If there is a cursed (and no uncursed) potion in effect, we take
1111 * 'total resistance = vulnerability from cursed potion'. 1109 * 'total resistance = vulnerability from cursed potion'.
1112 */ 1110 */
1113 for (int i = 0; i < NROFATTACKS; i++) 1111 for (int i = 0; i < NROFATTACKS; i++)
1114 { 1112 {
1115 resist[i] = prot[i] - vuln[i]; 1113 resist[i] = prot[i] - vuln[i];
1116 1114
1154 stats.maxhp += 2 * max (0, level - 10); 1152 stats.maxhp += 2 * max (0, level - 10);
1155 1153
1156 if (stats.hp > stats.maxhp) 1154 if (stats.hp > stats.maxhp)
1157 stats.hp = stats.maxhp; 1155 stats.hp = stats.maxhp;
1158 1156
1159 /* Sp gain is controlled by the level of the player's 1157 /* Sp gain is controlled by the level of the player's
1160 * relevant experience object (mana_obj, see above) 1158 * relevant experience object (mana_obj, see above)
1161 */ 1159 */
1162 /* following happen when skills system is not used */ 1160 /* following happen when skills system is not used */
1163 if (!mana_obj) 1161 if (!mana_obj)
1164 mana_obj = this; 1162 mana_obj = this;
1165 1163
1235 wc += 4; 1233 wc += 4;
1236 } 1234 }
1237 else 1235 else
1238 ac -= dex_bonus[stats.Dex]; 1236 ac -= dex_bonus[stats.Dex];
1239 1237
1240 /* In new exp/skills system, wc bonuses are related to 1238 /* In new exp/skills system, wc bonuses are related to
1241 * the players level in a relevant exp object (wc_obj) 1239 * the players level in a relevant exp object (wc_obj)
1242 * not the general player level -b.t. 1240 * not the general player level -b.t.
1243 * I changed this slightly so that wc bonuses are better 1241 * I changed this slightly so that wc bonuses are better
1244 * than before. This is to balance out the fact that 1242 * than before. This is to balance out the fact that
1245 * the player no longer gets a personal weapon w/ 1 1243 * the player no longer gets a personal weapon w/ 1
1246 * improvement every level, now its fighterlevel/5. So 1244 * improvement every level, now its fighterlevel/5. So
1247 * we give the player a bonus here in wc and dam 1245 * we give the player a bonus here in wc and dam
1248 * to make up for the change. Note that I left the 1246 * to make up for the change. Note that I left the
1249 * monster bonus the same as before. -b.t. 1247 * monster bonus the same as before. -b.t.
1250 */ 1248 */
1251 object *wc_obj = chosen_skill; 1249 object *wc_obj = chosen_skill;
1252 1250
1253 if (contr && wc_obj && wc_obj->level > 1) 1251 if (contr && wc_obj && wc_obj->level > 1)
1292 /* 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)
1293 * or below (negative number) that the player is carrying. If above 1291 * or below (negative number) that the player is carrying. If above
1294 * weight limit, then player suffers a speed reduction based on how 1292 * weight limit, then player suffers a speed reduction based on how
1295 * much above he is, and what is max carry is 1293 * much above he is, and what is max carry is
1296 */ 1294 */
1297 float f = (carrying / 1000) - max_carry[stats.Str]; 1295 float f = (sint32)weight_to_kg_approx (carrying) - max_carry[stats.Str];
1298 if (f > 0.f) 1296 if (f > 0.f)
1299 speed = speed / (1.f + f / max_carry[stats.Str]); 1297 speed /= (1.f + f / max_carry[stats.Str]);
1300 } 1298 }
1301 1299
1302 speed += bonus_speed / 10.f; /* Not affected by limits */ 1300 speed += bonus_speed / 10.f; /* Not affected by limits */
1303 speed *= speed_reduce_from_disease; 1301 speed *= speed_reduce_from_disease;
1304 1302
1380 update_all_los (env->map, env->x, env->y); 1378 update_all_los (env->map, env->x, env->y);
1381 } 1379 }
1382} 1380}
1383 1381
1384/* 1382/*
1385 * Returns true if the given player is a legal class.
1386 * The function to add and remove class-bonuses to the stats doesn't
1387 * check if the stat becomes negative, thus this function
1388 * merely checks that all stats are 1 or more, and returns
1389 * false otherwise.
1390 */
1391int
1392allowed_class (const object *op)
1393{
1394 return op->stats.Dex > 0
1395 && op->stats.Str > 0
1396 && op->stats.Con > 0
1397 && op->stats.Int > 0
1398 && op->stats.Wis > 0
1399 && op->stats.Pow > 0
1400 && op->stats.Cha > 0;
1401}
1402
1403/*
1404 * set the new dragon name after gaining levels or 1383 * set the new dragon name after gaining levels or
1405 * changing ability focus (later this can be extended to 1384 * changing ability focus (later this can be extended to
1406 * eventually change the player's face and animation) 1385 * eventually change the player's face and animation)
1407 */ 1386 */
1408void 1387void
1471 /* if the force is missing -> bail out */ 1450 /* if the force is missing -> bail out */
1472 if (abil == NULL) 1451 if (abil == NULL)
1473 return; 1452 return;
1474 1453
1475 /* The ability_force keeps track of maximum level ever achieved. 1454 /* The ability_force keeps track of maximum level ever achieved.
1476 * New abilties can only be gained by surpassing this max level 1455 * New abilties can only be gained by surpassing this max level
1477 */ 1456 */
1478 if (who->level > abil->level) 1457 if (who->level > abil->level)
1479 { 1458 {
1480 /* increase our focused ability */ 1459 /* increase our focused ability */
1481 abil->resist[abil->stats.exp]++; 1460 abil->resist[abil->stats.exp]++;
1626calc_perm_exp (object *op) 1605calc_perm_exp (object *op)
1627{ 1606{
1628 int p_exp_min; 1607 int p_exp_min;
1629 1608
1630 /* Ensure that our permanent experience minimum is met. 1609 /* Ensure that our permanent experience minimum is met.
1631 * permenent_exp_ratio is an integer percentage, we divide by 100 1610 * permenent_exp_ratio is an integer percentage, we divide by 100
1632 * to get the fraction */ 1611 * to get the fraction */
1633 p_exp_min = (int) (settings.permanent_exp_ratio * (float) (op->stats.exp) / 100); 1612 p_exp_min = (int) (settings.permanent_exp_ratio * (float) (op->stats.exp) / 100);
1634 1613
1635 if (op->perm_exp < p_exp_min) 1614 if (op->perm_exp < p_exp_min)
1636 op->perm_exp = p_exp_min; 1615 op->perm_exp = p_exp_min;
1648 * NULL, in which case exp increases the players general 1627 * NULL, in which case exp increases the players general
1649 * total, but not any particular skill. 1628 * total, but not any particular skill.
1650 * 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:
1651 */ 1630 */
1652static void 1631static void
1653add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) 1632add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1654{ 1633{
1655 object *skill_obj; 1634 object *skill_obj;
1656 sint64 limit, exp_to_add; 1635 sint64 limit, exp_to_add;
1657 int i;
1658 1636
1659 /* prevents some forms of abuse. */ 1637 /* prevents some forms of abuse. */
1660 if (op->contr->braced) 1638 if (op->contr->braced)
1661 exp /= 5; 1639 exp /= 5;
1662 1640
1772 * 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.
1773 * 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
1774 * a postive number. 1752 * a postive number.
1775 */ 1753 */
1776static void 1754static void
1777subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) 1755subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag)
1778{ 1756{
1779 float fraction = (float) exp / (float) op->stats.exp; 1757 float fraction = (float) exp / (float) op->stats.exp;
1780 object *tmp; 1758 object *tmp;
1781 sint64 del_exp; 1759 sint64 del_exp;
1782 1760
1783 for (tmp = op->inv; tmp; tmp = tmp->below) 1761 for (tmp = op->inv; tmp; tmp = tmp->below)
1784 if (tmp->type == SKILL && tmp->stats.exp) 1762 if (tmp->type == SKILL && tmp->stats.exp)
1785 { 1763 {
1786 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) 1764 if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill)
1787 { 1765 {
1788 del_exp = check_exp_loss (tmp, exp); 1766 del_exp = check_exp_loss (tmp, exp);
1789 tmp->stats.exp -= del_exp; 1767 tmp->stats.exp -= del_exp;
1790 player_lvl_adj (op, tmp); 1768 player_lvl_adj (op, tmp);
1791 } 1769 }
1792 else if (flag != SK_SUBTRACT_SKILL_EXP) 1770 else if (flag != SK_SUBTRACT_SKILL_EXP)
1793 { 1771 {
1794 /* only want to process other skills if we are not trying 1772 /* only want to process other skills if we are not trying
1795 * to match a specific skill. 1773 * to match a specific skill.
1796 */ 1774 */
1797 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1775 del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction);
1798 tmp->stats.exp -= del_exp; 1776 tmp->stats.exp -= del_exp;
1799 player_lvl_adj (op, tmp); 1777 player_lvl_adj (op, tmp);
1800 } 1778 }
1801 } 1779 }
1802 1780
1816 * skill_name is the skill that should get the exp added. 1794 * skill_name is the skill that should get the exp added.
1817 * 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.
1818 * these last two values are only used for players. 1796 * these last two values are only used for players.
1819 */ 1797 */
1820void 1798void
1821change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1799change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1822{ 1800{
1823#ifdef EXP_DEBUG 1801#ifdef EXP_DEBUG
1824 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);
1825#endif 1803#endif
1826 1804
1835 * won't do anything if the value is 0 anyways. 1813 * won't do anything if the value is 0 anyways.
1836 */ 1814 */
1837 if (exp == 0) 1815 if (exp == 0)
1838 return; 1816 return;
1839 1817
1840 /* Monsters are easy - we just adjust their exp - we 1818 /* Monsters are easy - we just adjust their exp - we
1841 * don't adjust level, since in most cases it is unrelated to 1819 * don't adjust level, since in most cases it is unrelated to
1842 * the exp they have - the monsters exp represents what its 1820 * the exp they have - the monsters exp represents what its
1843 * worth. 1821 * worth.
1844 */ 1822 */
1845 if (op->type != PLAYER) 1823 if (op->type != PLAYER)
1872 */ 1850 */
1873 subtract_player_exp (op, abs (exp), skill_name, flag); 1851 subtract_player_exp (op, abs (exp), skill_name, flag);
1874 } 1852 }
1875} 1853}
1876 1854
1877/* Applies a death penalty experience, the size of this is defined by the 1855/* Applies a death penalty experience, the size of this is defined by the
1878 * settings death_penalty_percentage and death_penalty_levels, and by the 1856 * settings death_penalty_percentage and death_penalty_levels, and by the
1879 * amount of permenent experience, whichever gives the lowest loss. 1857 * amount of permenent experience, whichever gives the lowest loss.
1880 */ 1858 */
1881void 1859void
1882apply_death_exp_penalty (object *op) 1860apply_death_exp_penalty (object *op)
1904 tmp->stats.exp -= loss; 1882 tmp->stats.exp -= loss;
1905 player_lvl_adj (op, tmp); 1883 player_lvl_adj (op, tmp);
1906 } 1884 }
1907 1885
1908 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1886 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100;
1909 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)];
1910 1888
1911 if (level_loss < 0) 1889 if (level_loss < 0)
1912 level_loss = 0; 1890 level_loss = 0;
1913 1891
1914 loss = check_exp_loss (op, min (level_loss, percentage_loss)); 1892 loss = check_exp_loss (op, min (level_loss, percentage_loss));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines