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.119 by root, Thu Apr 15 04:56:46 2010 UTC vs.
Revision 1.126 by root, Tue Jan 3 11:25:31 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
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;
938 this->set_flag (FLAG_UNDEAD); 939 this->set_flag (FLAG_UNDEAD);
939 940
940 //TODO: copy_flags? 941 //TODO: copy_flags?
941 if (tmp->flag [FLAG_MAKE_INVIS]) 942 if (tmp->flag [FLAG_MAKE_INVIS])
942 { 943 {
943 this->set_flag (FLAG_MAKE_INVIS); 944 set_flag (FLAG_MAKE_INVIS);
944 invisible = 1; 945 invisible = 1;
945 } 946 }
946 947
947 if (tmp->stats.exp && tmp->type != SKILL) 948 if (tmp->stats.exp && tmp->type != SKILL)
948 { 949 {
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)
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 */
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; 1654 int i;
1658 1655
1772 * where everything is at the minimum perm exp, he would lose nothing. 1769 * 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 1770 * exp is the amount of exp to subtract - thus, it should be
1774 * a postive number. 1771 * a postive number.
1775 */ 1772 */
1776static void 1773static void
1777subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) 1774subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag)
1778{ 1775{
1779 float fraction = (float) exp / (float) op->stats.exp; 1776 float fraction = (float) exp / (float) op->stats.exp;
1780 object *tmp; 1777 object *tmp;
1781 sint64 del_exp; 1778 sint64 del_exp;
1782 1779
1783 for (tmp = op->inv; tmp; tmp = tmp->below) 1780 for (tmp = op->inv; tmp; tmp = tmp->below)
1784 if (tmp->type == SKILL && tmp->stats.exp) 1781 if (tmp->type == SKILL && tmp->stats.exp)
1785 { 1782 {
1786 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) 1783 if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill)
1787 { 1784 {
1788 del_exp = check_exp_loss (tmp, exp); 1785 del_exp = check_exp_loss (tmp, exp);
1789 tmp->stats.exp -= del_exp; 1786 tmp->stats.exp -= del_exp;
1790 player_lvl_adj (op, tmp); 1787 player_lvl_adj (op, tmp);
1791 } 1788 }
1792 else if (flag != SK_SUBTRACT_SKILL_EXP) 1789 else if (flag != SK_SUBTRACT_SKILL_EXP)
1793 { 1790 {
1794 /* only want to process other skills if we are not trying 1791 /* only want to process other skills if we are not trying
1795 * to match a specific skill. 1792 * to match a specific skill.
1796 */ 1793 */
1797 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1794 del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction);
1798 tmp->stats.exp -= del_exp; 1795 tmp->stats.exp -= del_exp;
1799 player_lvl_adj (op, tmp); 1796 player_lvl_adj (op, tmp);
1800 } 1797 }
1801 } 1798 }
1802 1799
1816 * skill_name is the skill that should get the exp added. 1813 * skill_name is the skill that should get the exp added.
1817 * flag is what to do if player doesn't have the skill. 1814 * flag is what to do if player doesn't have the skill.
1818 * these last two values are only used for players. 1815 * these last two values are only used for players.
1819 */ 1816 */
1820void 1817void
1821change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1818change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1822{ 1819{
1823#ifdef EXP_DEBUG 1820#ifdef EXP_DEBUG
1824 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); 1821 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp);
1825#endif 1822#endif
1826 1823
1904 tmp->stats.exp -= loss; 1901 tmp->stats.exp -= loss;
1905 player_lvl_adj (op, tmp); 1902 player_lvl_adj (op, tmp);
1906 } 1903 }
1907 1904
1908 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1905 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)]; 1906 level_loss = op->stats.exp - levels [max (0, op->level - settings.death_penalty_level)];
1910 1907
1911 if (level_loss < 0) 1908 if (level_loss < 0)
1912 level_loss = 0; 1909 level_loss = 0;
1913 1910
1914 loss = check_exp_loss (op, min (level_loss, percentage_loss)); 1911 loss = check_exp_loss (op, min (level_loss, percentage_loss));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines