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.121 by root, Fri Apr 30 11:25:48 2010 UTC vs.
Revision 1.127 by root, Fri Jan 27 22:00:39 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
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;
1023 if (tmp->stats.ac) 1023 if (tmp->stats.ac)
1024 ac -= tmp->stats.ac + tmp->magic; 1024 ac -= tmp->stats.ac + tmp->magic;
1025 1025
1026 break; 1026 break;
1027 1027
1028 case WAND: 1028 case RANGED:
1029 case ROD:
1030 case HORN:
1031 break;
1032
1033 case BOW: 1029 case BOW:
1034 case WEAPON: 1030 case WEAPON:
1035 wc -= tmp->stats.wc + tmp->magic; 1031 wc -= tmp->stats.wc + tmp->magic;
1036 1032
1037 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) 1033 if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0)
1090 1086
1091 if (tmp->stats.ac) 1087 if (tmp->stats.ac)
1092 ac -= tmp->stats.ac + tmp->magic; 1088 ac -= tmp->stats.ac + tmp->magic;
1093 1089
1094 if (ARMOUR_SPEED (tmp)) 1090 if (ARMOUR_SPEED (tmp))
1095 max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); 1091 min_it (max_speed, ARMOUR_SPEED (tmp) / 10.f);
1096 1092
1097 break; 1093 break;
1098 } /* switch tmp->type */ 1094 } /* switch tmp->type */
1099 } /* item is equipped */ 1095 } /* item is equipped */
1100 } /* for loop of items */ 1096 } /* for loop of items */
1649 * NULL, in which case exp increases the players general 1645 * NULL, in which case exp increases the players general
1650 * total, but not any particular skill. 1646 * total, but not any particular skill.
1651 * 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:
1652 */ 1648 */
1653static void 1649static void
1654add_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)
1655{ 1651{
1656 object *skill_obj; 1652 object *skill_obj;
1657 sint64 limit, exp_to_add; 1653 sint64 limit, exp_to_add;
1658 int i;
1659 1654
1660 /* prevents some forms of abuse. */ 1655 /* prevents some forms of abuse. */
1661 if (op->contr->braced) 1656 if (op->contr->braced)
1662 exp /= 5; 1657 exp /= 5;
1663 1658
1773 * 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.
1774 * 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
1775 * a postive number. 1770 * a postive number.
1776 */ 1771 */
1777static void 1772static void
1778subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) 1773subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag)
1779{ 1774{
1780 float fraction = (float) exp / (float) op->stats.exp; 1775 float fraction = (float) exp / (float) op->stats.exp;
1781 object *tmp; 1776 object *tmp;
1782 sint64 del_exp; 1777 sint64 del_exp;
1783 1778
1784 for (tmp = op->inv; tmp; tmp = tmp->below) 1779 for (tmp = op->inv; tmp; tmp = tmp->below)
1785 if (tmp->type == SKILL && tmp->stats.exp) 1780 if (tmp->type == SKILL && tmp->stats.exp)
1786 { 1781 {
1787 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) 1782 if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill)
1788 { 1783 {
1789 del_exp = check_exp_loss (tmp, exp); 1784 del_exp = check_exp_loss (tmp, exp);
1790 tmp->stats.exp -= del_exp; 1785 tmp->stats.exp -= del_exp;
1791 player_lvl_adj (op, tmp); 1786 player_lvl_adj (op, tmp);
1792 } 1787 }
1793 else if (flag != SK_SUBTRACT_SKILL_EXP) 1788 else if (flag != SK_SUBTRACT_SKILL_EXP)
1794 { 1789 {
1795 /* only want to process other skills if we are not trying 1790 /* only want to process other skills if we are not trying
1796 * to match a specific skill. 1791 * to match a specific skill.
1797 */ 1792 */
1798 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1793 del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction);
1799 tmp->stats.exp -= del_exp; 1794 tmp->stats.exp -= del_exp;
1800 player_lvl_adj (op, tmp); 1795 player_lvl_adj (op, tmp);
1801 } 1796 }
1802 } 1797 }
1803 1798
1817 * skill_name is the skill that should get the exp added. 1812 * skill_name is the skill that should get the exp added.
1818 * 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.
1819 * these last two values are only used for players. 1814 * these last two values are only used for players.
1820 */ 1815 */
1821void 1816void
1822change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1817change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1823{ 1818{
1824#ifdef EXP_DEBUG 1819#ifdef EXP_DEBUG
1825 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);
1826#endif 1821#endif
1827 1822
1905 tmp->stats.exp -= loss; 1900 tmp->stats.exp -= loss;
1906 player_lvl_adj (op, tmp); 1901 player_lvl_adj (op, tmp);
1907 } 1902 }
1908 1903
1909 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1904 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)]; 1905 level_loss = op->stats.exp - levels [max (0, op->level - settings.death_penalty_level)];
1911 1906
1912 if (level_loss < 0) 1907 if (level_loss < 0)
1913 level_loss = 0; 1908 level_loss = 0;
1914 1909
1915 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