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.129 by root, Mon Nov 12 03:14:32 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
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 int weapon_weight = 0, weapon_speed = 0;
736 int best_wc = 0, best_ac = 0, wc = 0, ac = 0; 736 int best_wc = 0, best_ac = 0, wc = 0, ac = 0;
737 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; 737 int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS];
738 object *grace_obj = NULL, *mana_obj = NULL, *tmp; 738 object *grace_obj = NULL, *mana_obj = NULL, *tmp;
739 float old_speed = speed; 739 float old_speed = speed;
870 * because the skill shouldn't count against body positions being used 870 * because the skill shouldn't count against body positions being used
871 * up, etc. 871 * up, etc.
872 */ 872 */
873 if ((tmp->flag [FLAG_APPLIED] 873 if ((tmp->flag [FLAG_APPLIED]
874 && tmp->type != CONTAINER 874 && tmp->type != CONTAINER
875 && tmp->type != CLOSE_CON) 875 && tmp->type != CLOSE_CON
876 && tmp->type != SPELL)
876 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) 877 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING))
877 { 878 {
878 if (type == PLAYER) 879 if (type == PLAYER)
879 { 880 {
880 contr->item_power += tmp->item_power; 881 contr->item_power += tmp->item_power;
915 for (int i = 0; i < NROFATTACKS; i++) 916 for (int i = 0; i < NROFATTACKS; i++)
916 max_it (potion_resist[i], tmp->resist[i]); 917 max_it (potion_resist[i], tmp->resist[i]);
917 else if (tmp->type != POTION) 918 else if (tmp->type != POTION)
918 for (int i = 0; i < NROFATTACKS; i++) 919 for (int i = 0; i < NROFATTACKS; i++)
919 if (tmp->resist[i] > 0) 920 if (tmp->resist[i] > 0)
920 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 921 prot[i] += (100 - prot[i]) * tmp->resist[i] / 100;
921 else if (tmp->resist[i] < 0) 922 else if (tmp->resist[i] < 0)
922 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 923 vuln[i] += (100 - vuln[i]) * -tmp->resist[i] / 100;
923 924
924 /* There may be other things that should not adjust the attacktype */ 925 /* There may be other things that should not adjust the attacktype */
925 if (tmp->type != SYMPTOM) 926 if (tmp->type != SYMPTOM)
926 { 927 {
927 attacktype |= tmp->attacktype; 928 attacktype |= tmp->attacktype;
995 996
996 if (tmp->stats.ac) 997 if (tmp->stats.ac)
997 ac -= tmp->stats.ac + tmp->magic; 998 ac -= tmp->stats.ac + tmp->magic;
998 999
999 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1000 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1000 contr->encumbrance += 3 * tmp->weight / 1000; 1001 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1001 } 1002 }
1002 1003
1003 break; 1004 break;
1004 1005
1005 case SHIELD: 1006 case SHIELD:
1006 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1007 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1007 contr->encumbrance += tmp->weight / 2000; 1008 contr->encumbrance += weight_to_kg_approx (tmp->weight) >> 1;
1008 //FALLTHROUGH 1009 //FALLTHROUGH
1009 case RING: 1010 case RING:
1010 case AMULET: 1011 case AMULET:
1011 case GIRDLE: 1012 case GIRDLE:
1012 case HELMET: 1013 case HELMET:
1022 if (tmp->stats.ac) 1023 if (tmp->stats.ac)
1023 ac -= tmp->stats.ac + tmp->magic; 1024 ac -= tmp->stats.ac + tmp->magic;
1024 1025
1025 break; 1026 break;
1026 1027
1027 case WAND: 1028 case RANGED:
1028 case ROD:
1029 case HORN:
1030 break;
1031
1032 case BOW: 1029 case BOW:
1033 case WEAPON: 1030 case WEAPON:
1034 wc -= tmp->stats.wc + tmp->magic; 1031 wc -= tmp->stats.wc + tmp->magic;
1035 1032
1036 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1033 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1050 * go. 1047 * go.
1051 */ 1048 */
1052 1049
1053 if (type == PLAYER) 1050 if (type == PLAYER)
1054 if (settings.spell_encumbrance) 1051 if (settings.spell_encumbrance)
1055 contr->encumbrance += tmp->weight * 3 / 1000; 1052 contr->encumbrance += weight_to_kg_approx (3 * tmp->weight);
1056 1053
1057 break; 1054 break;
1058 1055
1059 case ARMOUR: /* Only the best of these three are used: */ 1056 case ARMOUR: /* Only the best of these three are used: */
1060 if (settings.spell_encumbrance == TRUE && type == PLAYER) 1057 if (settings.spell_encumbrance == TRUE && type == PLAYER)
1061 contr->encumbrance += tmp->weight / 1000; 1058 contr->encumbrance += weight_to_kg_approx (tmp->weight);
1062 1059
1063 case BRACERS: 1060 case BRACERS:
1064 case FORCE: 1061 case FORCE:
1065 if (tmp->stats.wc) 1062 if (tmp->stats.wc)
1066 { 1063 {
1089 1086
1090 if (tmp->stats.ac) 1087 if (tmp->stats.ac)
1091 ac -= tmp->stats.ac + tmp->magic; 1088 ac -= tmp->stats.ac + tmp->magic;
1092 1089
1093 if (ARMOUR_SPEED (tmp)) 1090 if (ARMOUR_SPEED (tmp))
1094 max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); 1091 min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f);
1095 1092
1096 break; 1093 break;
1097 } /* switch tmp->type */ 1094 } /* switch tmp->type */
1098 } /* item is equipped */ 1095 } /* item is equipped */
1099 } /* for loop of items */ 1096 } /* for loop of items */
1292 /* f is a number the represents the number of kg above (positive num) 1289 /* 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 1290 * or below (negative number) that the player is carrying. If above
1294 * weight limit, then player suffers a speed reduction based on how 1291 * weight limit, then player suffers a speed reduction based on how
1295 * much above he is, and what is max carry is 1292 * much above he is, and what is max carry is
1296 */ 1293 */
1297 float f = (carrying / 1000) - max_carry[stats.Str]; 1294 double f = weight_to_kg_approx (carrying) - max_carry[stats.Str];
1298 if (f > 0.f) 1295 if (f > 0.f)
1299 speed = speed / (1.f + f / max_carry[stats.Str]); 1296 speed /= (1.f + f / max_carry[stats.Str]);
1300 } 1297 }
1301 1298
1302 speed += bonus_speed / 10.f; /* Not affected by limits */ 1299 speed += bonus_speed / 10.f; /* Not affected by limits */
1303 speed *= speed_reduce_from_disease; 1300 speed *= speed_reduce_from_disease;
1304 1301
1648 * NULL, in which case exp increases the players general 1645 * NULL, in which case exp increases the players general
1649 * total, but not any particular skill. 1646 * total, but not any particular skill.
1650 * flag is what to do if the player doesn't have the skill: 1647 * flag is what to do if the player doesn't have the skill:
1651 */ 1648 */
1652static void 1649static void
1653add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) 1650add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1654{ 1651{
1655 object *skill_obj; 1652 object *skill_obj;
1656 sint64 limit, exp_to_add; 1653 sint64 limit, exp_to_add;
1657 int i;
1658 1654
1659 /* prevents some forms of abuse. */ 1655 /* prevents some forms of abuse. */
1660 if (op->contr->braced) 1656 if (op->contr->braced)
1661 exp /= 5; 1657 exp /= 5;
1662 1658
1772 * where everything is at the minimum perm exp, he would lose nothing. 1768 * 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 1769 * exp is the amount of exp to subtract - thus, it should be
1774 * a postive number. 1770 * a postive number.
1775 */ 1771 */
1776static void 1772static void
1777subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) 1773subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag)
1778{ 1774{
1779 float fraction = (float) exp / (float) op->stats.exp; 1775 float fraction = (float) exp / (float) op->stats.exp;
1780 object *tmp; 1776 object *tmp;
1781 sint64 del_exp; 1777 sint64 del_exp;
1782 1778
1783 for (tmp = op->inv; tmp; tmp = tmp->below) 1779 for (tmp = op->inv; tmp; tmp = tmp->below)
1784 if (tmp->type == SKILL && tmp->stats.exp) 1780 if (tmp->type == SKILL && tmp->stats.exp)
1785 { 1781 {
1786 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) 1782 if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill)
1787 { 1783 {
1788 del_exp = check_exp_loss (tmp, exp); 1784 del_exp = check_exp_loss (tmp, exp);
1789 tmp->stats.exp -= del_exp; 1785 tmp->stats.exp -= del_exp;
1790 player_lvl_adj (op, tmp); 1786 player_lvl_adj (op, tmp);
1791 } 1787 }
1792 else if (flag != SK_SUBTRACT_SKILL_EXP) 1788 else if (flag != SK_SUBTRACT_SKILL_EXP)
1793 { 1789 {
1794 /* only want to process other skills if we are not trying 1790 /* only want to process other skills if we are not trying
1795 * to match a specific skill. 1791 * to match a specific skill.
1796 */ 1792 */
1797 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1793 del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction);
1798 tmp->stats.exp -= del_exp; 1794 tmp->stats.exp -= del_exp;
1799 player_lvl_adj (op, tmp); 1795 player_lvl_adj (op, tmp);
1800 } 1796 }
1801 } 1797 }
1802 1798
1816 * skill_name is the skill that should get the exp added. 1812 * skill_name is the skill that should get the exp added.
1817 * flag is what to do if player doesn't have the skill. 1813 * flag is what to do if player doesn't have the skill.
1818 * these last two values are only used for players. 1814 * these last two values are only used for players.
1819 */ 1815 */
1820void 1816void
1821change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1817change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1822{ 1818{
1823#ifdef EXP_DEBUG 1819#ifdef EXP_DEBUG
1824 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); 1820 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp);
1825#endif 1821#endif
1826 1822
1904 tmp->stats.exp -= loss; 1900 tmp->stats.exp -= loss;
1905 player_lvl_adj (op, tmp); 1901 player_lvl_adj (op, tmp);
1906 } 1902 }
1907 1903
1908 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1904 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)]; 1905 level_loss = op->stats.exp - levels [max (0, op->level - settings.death_penalty_level)];
1910 1906
1911 if (level_loss < 0) 1907 if (level_loss < 0)
1912 level_loss = 0; 1908 level_loss = 0;
1913 1909
1914 loss = check_exp_loss (op, min (level_loss, percentage_loss)); 1910 loss = check_exp_loss (op, min (level_loss, percentage_loss));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines