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.129 by root, Mon Nov 12 03:14:32 2012 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,2011,2012 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
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
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)
730 */ 730 */
731void 731void
732object::update_stats () 732object::update_stats ()
733{ 733{
734 float 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
903 if (tmp->flag [FLAG_APPLIED]) // exclude praying... 904 if (tmp->flag [FLAG_APPLIED]) // exclude praying...
904 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 905 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
905 slot[i].used += tmp->slot[i].info; 906 slot[i].used += tmp->slot[i].info;
906 907
907 if (tmp->type == SYMPTOM) 908 if (tmp->type == SYMPTOM)
908 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);
909 910
910 /* Pos. and neg. protections are counted separate (-> pro/vuln). 911 /* Pos. and neg. protections are counted separate (-> pro/vuln).
911 * (Negative protections are calculated exactly like positive.) 912 * (Negative protections are calculated exactly like positive.)
912 * Resistance from potions are treated special as well. If there's 913 * Resistance from potions are treated special as well. If there's
913 * more than one potion-effect, the bigger prot.-value is taken. 914 * more than one potion-effect, the bigger prot.-value is taken.
914 */ 915 */
915 if (tmp->type == POTION_EFFECT) 916 if (tmp->type == POTION_EFFECT)
916 for (int i = 0; i < NROFATTACKS; i++) 917 for (int i = 0; i < NROFATTACKS; i++)
917 max_it (potion_resist[i], tmp->resist[i]); 918 max_it (potion_resist[i], tmp->resist[i]);
918 else if (tmp->type != POTION) 919 else if (tmp->type != POTION)
1103 1104
1104 /* 'total resistance = total protections - total vulnerabilities'. 1105 /* 'total resistance = total protections - total vulnerabilities'.
1105 * If there is an uncursed potion in effect, granting more protection 1106 * If there is an uncursed potion in effect, granting more protection
1106 * than that, we take: 'total resistance = resistance from potion'. 1107 * than that, we take: 'total resistance = resistance from potion'.
1107 * 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
1108 * 'total resistance = vulnerability from cursed potion'. 1109 * 'total resistance = vulnerability from cursed potion'.
1109 */ 1110 */
1110 for (int i = 0; i < NROFATTACKS; i++) 1111 for (int i = 0; i < NROFATTACKS; i++)
1111 { 1112 {
1112 resist[i] = prot[i] - vuln[i]; 1113 resist[i] = prot[i] - vuln[i];
1113 1114
1151 stats.maxhp += 2 * max (0, level - 10); 1152 stats.maxhp += 2 * max (0, level - 10);
1152 1153
1153 if (stats.hp > stats.maxhp) 1154 if (stats.hp > stats.maxhp)
1154 stats.hp = stats.maxhp; 1155 stats.hp = stats.maxhp;
1155 1156
1156 /* Sp gain is controlled by the level of the player's 1157 /* Sp gain is controlled by the level of the player's
1157 * relevant experience object (mana_obj, see above) 1158 * relevant experience object (mana_obj, see above)
1158 */ 1159 */
1159 /* following happen when skills system is not used */ 1160 /* following happen when skills system is not used */
1160 if (!mana_obj) 1161 if (!mana_obj)
1161 mana_obj = this; 1162 mana_obj = this;
1162 1163
1232 wc += 4; 1233 wc += 4;
1233 } 1234 }
1234 else 1235 else
1235 ac -= dex_bonus[stats.Dex]; 1236 ac -= dex_bonus[stats.Dex];
1236 1237
1237 /* In new exp/skills system, wc bonuses are related to 1238 /* In new exp/skills system, wc bonuses are related to
1238 * the players level in a relevant exp object (wc_obj) 1239 * the players level in a relevant exp object (wc_obj)
1239 * not the general player level -b.t. 1240 * not the general player level -b.t.
1240 * I changed this slightly so that wc bonuses are better 1241 * I changed this slightly so that wc bonuses are better
1241 * than before. This is to balance out the fact that 1242 * than before. This is to balance out the fact that
1242 * the player no longer gets a personal weapon w/ 1 1243 * the player no longer gets a personal weapon w/ 1
1243 * improvement every level, now its fighterlevel/5. So 1244 * improvement every level, now its fighterlevel/5. So
1244 * we give the player a bonus here in wc and dam 1245 * we give the player a bonus here in wc and dam
1245 * to make up for the change. Note that I left the 1246 * to make up for the change. Note that I left the
1246 * monster bonus the same as before. -b.t. 1247 * monster bonus the same as before. -b.t.
1247 */ 1248 */
1248 object *wc_obj = chosen_skill; 1249 object *wc_obj = chosen_skill;
1249 1250
1250 if (contr && wc_obj && wc_obj->level > 1) 1251 if (contr && wc_obj && wc_obj->level > 1)
1289 /* 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)
1290 * or below (negative number) that the player is carrying. If above 1291 * or below (negative number) that the player is carrying. If above
1291 * weight limit, then player suffers a speed reduction based on how 1292 * weight limit, then player suffers a speed reduction based on how
1292 * much above he is, and what is max carry is 1293 * much above he is, and what is max carry is
1293 */ 1294 */
1294 double f = weight_to_kg_approx (carrying) - max_carry[stats.Str]; 1295 float f = (sint32)weight_to_kg_approx (carrying) - max_carry[stats.Str];
1295 if (f > 0.f) 1296 if (f > 0.f)
1296 speed /= (1.f + f / max_carry[stats.Str]); 1297 speed /= (1.f + f / max_carry[stats.Str]);
1297 } 1298 }
1298 1299
1299 speed += bonus_speed / 10.f; /* Not affected by limits */ 1300 speed += bonus_speed / 10.f; /* Not affected by limits */
1377 update_all_los (env->map, env->x, env->y); 1378 update_all_los (env->map, env->x, env->y);
1378 } 1379 }
1379} 1380}
1380 1381
1381/* 1382/*
1382 * Returns true if the given player is a legal class.
1383 * The function to add and remove class-bonuses to the stats doesn't
1384 * check if the stat becomes negative, thus this function
1385 * merely checks that all stats are 1 or more, and returns
1386 * false otherwise.
1387 */
1388int
1389allowed_class (const object *op)
1390{
1391 return op->stats.Dex > 0
1392 && op->stats.Str > 0
1393 && op->stats.Con > 0
1394 && op->stats.Int > 0
1395 && op->stats.Wis > 0
1396 && op->stats.Pow > 0
1397 && op->stats.Cha > 0;
1398}
1399
1400/*
1401 * set the new dragon name after gaining levels or 1383 * set the new dragon name after gaining levels or
1402 * changing ability focus (later this can be extended to 1384 * changing ability focus (later this can be extended to
1403 * eventually change the player's face and animation) 1385 * eventually change the player's face and animation)
1404 */ 1386 */
1405void 1387void
1468 /* if the force is missing -> bail out */ 1450 /* if the force is missing -> bail out */
1469 if (abil == NULL) 1451 if (abil == NULL)
1470 return; 1452 return;
1471 1453
1472 /* The ability_force keeps track of maximum level ever achieved. 1454 /* The ability_force keeps track of maximum level ever achieved.
1473 * New abilties can only be gained by surpassing this max level 1455 * New abilties can only be gained by surpassing this max level
1474 */ 1456 */
1475 if (who->level > abil->level) 1457 if (who->level > abil->level)
1476 { 1458 {
1477 /* increase our focused ability */ 1459 /* increase our focused ability */
1478 abil->resist[abil->stats.exp]++; 1460 abil->resist[abil->stats.exp]++;
1623calc_perm_exp (object *op) 1605calc_perm_exp (object *op)
1624{ 1606{
1625 int p_exp_min; 1607 int p_exp_min;
1626 1608
1627 /* Ensure that our permanent experience minimum is met. 1609 /* Ensure that our permanent experience minimum is met.
1628 * permenent_exp_ratio is an integer percentage, we divide by 100 1610 * permenent_exp_ratio is an integer percentage, we divide by 100
1629 * to get the fraction */ 1611 * to get the fraction */
1630 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);
1631 1613
1632 if (op->perm_exp < p_exp_min) 1614 if (op->perm_exp < p_exp_min)
1633 op->perm_exp = p_exp_min; 1615 op->perm_exp = p_exp_min;
1831 * won't do anything if the value is 0 anyways. 1813 * won't do anything if the value is 0 anyways.
1832 */ 1814 */
1833 if (exp == 0) 1815 if (exp == 0)
1834 return; 1816 return;
1835 1817
1836 /* Monsters are easy - we just adjust their exp - we 1818 /* Monsters are easy - we just adjust their exp - we
1837 * 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
1838 * the exp they have - the monsters exp represents what its 1820 * the exp they have - the monsters exp represents what its
1839 * worth. 1821 * worth.
1840 */ 1822 */
1841 if (op->type != PLAYER) 1823 if (op->type != PLAYER)
1868 */ 1850 */
1869 subtract_player_exp (op, abs (exp), skill_name, flag); 1851 subtract_player_exp (op, abs (exp), skill_name, flag);
1870 } 1852 }
1871} 1853}
1872 1854
1873/* 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
1874 * settings death_penalty_percentage and death_penalty_levels, and by the 1856 * settings death_penalty_percentage and death_penalty_levels, and by the
1875 * amount of permenent experience, whichever gives the lowest loss. 1857 * amount of permenent experience, whichever gives the lowest loss.
1876 */ 1858 */
1877void 1859void
1878apply_death_exp_penalty (object *op) 1860apply_death_exp_penalty (object *op)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines