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.122 by root, Fri Apr 30 21:00:39 2010 UTC vs.
Revision 1.131 by root, Wed Nov 14 05:18:17 2012 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 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,
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
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];
996 997
997 if (tmp->stats.ac) 998 if (tmp->stats.ac)
998 ac -= tmp->stats.ac + tmp->magic; 999 ac -= tmp->stats.ac + tmp->magic;
999 1000
1000 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1001 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1001 contr->encumbrance += 3 * tmp->weight / 1000; 1002 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1002 } 1003 }
1003 1004
1004 break; 1005 break;
1005 1006
1006 case SHIELD: 1007 case SHIELD:
1007 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1008 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1008 contr->encumbrance += tmp->weight / 2000; 1009 contr->encumbrance += weight_to_kg_approx (tmp->weight) >> 1;
1009 //FALLTHROUGH 1010 //FALLTHROUGH
1010 case RING: 1011 case RING:
1011 case AMULET: 1012 case AMULET:
1012 case GIRDLE: 1013 case GIRDLE:
1013 case HELMET: 1014 case HELMET:
1023 if (tmp->stats.ac) 1024 if (tmp->stats.ac)
1024 ac -= tmp->stats.ac + tmp->magic; 1025 ac -= tmp->stats.ac + tmp->magic;
1025 1026
1026 break; 1027 break;
1027 1028
1028 case WAND: 1029 case RANGED:
1029 case ROD:
1030 case HORN:
1031 break;
1032
1033 case BOW: 1030 case BOW:
1034 case WEAPON: 1031 case WEAPON:
1035 wc -= tmp->stats.wc + tmp->magic; 1032 wc -= tmp->stats.wc + tmp->magic;
1036 1033
1037 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1034 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1051 * go. 1048 * go.
1052 */ 1049 */
1053 1050
1054 if (type == PLAYER) 1051 if (type == PLAYER)
1055 if (settings.spell_encumbrance) 1052 if (settings.spell_encumbrance)
1056 contr->encumbrance += tmp->weight * 3 / 1000; 1053 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1057 1054
1058 break; 1055 break;
1059 1056
1060 case ARMOUR: /* Only the best of these three are used: */ 1057 case ARMOUR: /* Only the best of these three are used: */
1061 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1058 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1062 contr->encumbrance += tmp->weight / 1000; 1059 contr->encumbrance += weight_to_kg_approx (tmp->weight);
1063 1060
1064 case BRACERS: 1061 case BRACERS:
1065 case FORCE: 1062 case FORCE:
1066 if (tmp->stats.wc) 1063 if (tmp->stats.wc)
1067 { 1064 {
1090 1087
1091 if (tmp->stats.ac) 1088 if (tmp->stats.ac)
1092 ac -= tmp->stats.ac + tmp->magic; 1089 ac -= tmp->stats.ac + tmp->magic;
1093 1090
1094 if (ARMOUR_SPEED (tmp)) 1091 if (ARMOUR_SPEED (tmp))
1095 max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); 1092 min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f);
1096 1093
1097 break; 1094 break;
1098 } /* switch tmp->type */ 1095 } /* switch tmp->type */
1099 } /* item is equipped */ 1096 } /* item is equipped */
1100 } /* for loop of items */ 1097 } /* for loop of items */
1293 /* 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)
1294 * or below (negative number) that the player is carrying. If above 1291 * or below (negative number) that the player is carrying. If above
1295 * weight limit, then player suffers a speed reduction based on how 1292 * weight limit, then player suffers a speed reduction based on how
1296 * much above he is, and what is max carry is 1293 * much above he is, and what is max carry is
1297 */ 1294 */
1298 float f = (carrying / 1000) - max_carry[stats.Str]; 1295 float f = (sint32)weight_to_kg_approx (carrying) - max_carry[stats.Str];
1299 if (f > 0.f) 1296 if (f > 0.f)
1300 speed = speed / (1.f + f / max_carry[stats.Str]); 1297 speed /= (1.f + f / max_carry[stats.Str]);
1301 } 1298 }
1302 1299
1303 speed += bonus_speed / 10.f; /* Not affected by limits */ 1300 speed += bonus_speed / 10.f; /* Not affected by limits */
1304 speed *= speed_reduce_from_disease; 1301 speed *= speed_reduce_from_disease;
1305 1302
1381 update_all_los (env->map, env->x, env->y); 1378 update_all_los (env->map, env->x, env->y);
1382 } 1379 }
1383} 1380}
1384 1381
1385/* 1382/*
1386 * Returns true if the given player is a legal class.
1387 * The function to add and remove class-bonuses to the stats doesn't
1388 * check if the stat becomes negative, thus this function
1389 * merely checks that all stats are 1 or more, and returns
1390 * false otherwise.
1391 */
1392int
1393allowed_class (const object *op)
1394{
1395 return op->stats.Dex > 0
1396 && op->stats.Str > 0
1397 && op->stats.Con > 0
1398 && op->stats.Int > 0
1399 && op->stats.Wis > 0
1400 && op->stats.Pow > 0
1401 && op->stats.Cha > 0;
1402}
1403
1404/*
1405 * set the new dragon name after gaining levels or 1383 * set the new dragon name after gaining levels or
1406 * changing ability focus (later this can be extended to 1384 * changing ability focus (later this can be extended to
1407 * eventually change the player's face and animation) 1385 * eventually change the player's face and animation)
1408 */ 1386 */
1409void 1387void
1653static void 1631static void
1654add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) 1632add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1655{ 1633{
1656 object *skill_obj; 1634 object *skill_obj;
1657 sint64 limit, exp_to_add; 1635 sint64 limit, exp_to_add;
1658 int i;
1659 1636
1660 /* prevents some forms of abuse. */ 1637 /* prevents some forms of abuse. */
1661 if (op->contr->braced) 1638 if (op->contr->braced)
1662 exp /= 5; 1639 exp /= 5;
1663 1640
1905 tmp->stats.exp -= loss; 1882 tmp->stats.exp -= loss;
1906 player_lvl_adj (op, tmp); 1883 player_lvl_adj (op, tmp);
1907 } 1884 }
1908 1885
1909 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1886 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100;
1910 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)];
1911 1888
1912 if (level_loss < 0) 1889 if (level_loss < 0)
1913 level_loss = 0; 1890 level_loss = 0;
1914 1891
1915 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