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.118 by root, Sun Apr 11 00:34:05 2010 UTC vs.
Revision 1.122 by root, Fri Apr 30 21:00:39 2010 UTC

139/* 139/*
140 Since this is nowhere defined ... 140 Since this is nowhere defined ...
141 Both come in handy at least in function add_exp() 141 Both come in handy at least in function add_exp()
142*/ 142*/
143 143
144#define MAX_EXPERIENCE levels[settings.max_level] 144#define MAX_EXPERIENCE levels [settings.max_level]
145 145
146/* because exp_obj sum to make the total score, 146/* because exp_obj sum to make the total score,
147 * we cannot allow that sum to exceed the maximum 147 * we cannot allow that sum to exceed the maximum
148 * amount of experience a player can gain. Thus 148 * amount of experience a player can gain. Thus
149 * we define MAX_EXP_IN_OBJ. It is important to try 149 * we define MAX_EXP_IN_OBJ. It is important to try
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 levels[settings.max_level]/(MAX_EXP_CAT - 1) 161#define MAX_EXP_IN_OBJ MAX_EXP_IN_OBJ / (MAX_EXP_CAT - 1)
162
163extern sint64 *levels;
164 162
165#define MAX_SAVE_LEVEL 110 163#define MAX_SAVE_LEVEL 110
166 164
167/* This no longer needs to be changed anytime the number of 165/* This no longer needs to be changed anytime the number of
168 * levels is increased - rather, did_make_save will do the 166 * levels is increased - rather, did_make_save will do the
872 * because the skill shouldn't count against body positions being used 870 * because the skill shouldn't count against body positions being used
873 * up, etc. 871 * up, etc.
874 */ 872 */
875 if ((tmp->flag [FLAG_APPLIED] 873 if ((tmp->flag [FLAG_APPLIED]
876 && tmp->type != CONTAINER 874 && tmp->type != CONTAINER
877 && tmp->type != CLOSE_CON) 875 && tmp->type != CLOSE_CON
876 && tmp->type != SPELL)
878 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING)) 877 || (tmp->type == SKILL && tmp->subtype == SK_PRAYING))
879 { 878 {
880 if (type == PLAYER) 879 if (type == PLAYER)
881 { 880 {
882 contr->item_power += tmp->item_power; 881 contr->item_power += tmp->item_power;
917 for (int i = 0; i < NROFATTACKS; i++) 916 for (int i = 0; i < NROFATTACKS; i++)
918 max_it (potion_resist[i], tmp->resist[i]); 917 max_it (potion_resist[i], tmp->resist[i]);
919 else if (tmp->type != POTION) 918 else if (tmp->type != POTION)
920 for (int i = 0; i < NROFATTACKS; i++) 919 for (int i = 0; i < NROFATTACKS; i++)
921 if (tmp->resist[i] > 0) 920 if (tmp->resist[i] > 0)
922 prot[i] += ((100 - prot[i]) * tmp->resist[i]) / 100; 921 prot[i] += (100 - prot[i]) * tmp->resist[i] / 100;
923 else if (tmp->resist[i] < 0) 922 else if (tmp->resist[i] < 0)
924 vuln[i] += ((100 - vuln[i]) * -tmp->resist[i]) / 100; 923 vuln[i] += (100 - vuln[i]) * -tmp->resist[i] / 100;
925 924
926 /* There may be other things that should not adjust the attacktype */ 925 /* There may be other things that should not adjust the attacktype */
927 if (tmp->type != SYMPTOM) 926 if (tmp->type != SYMPTOM)
928 { 927 {
929 attacktype |= tmp->attacktype; 928 attacktype |= tmp->attacktype;
940 this->set_flag (FLAG_UNDEAD); 939 this->set_flag (FLAG_UNDEAD);
941 940
942 //TODO: copy_flags? 941 //TODO: copy_flags?
943 if (tmp->flag [FLAG_MAKE_INVIS]) 942 if (tmp->flag [FLAG_MAKE_INVIS])
944 { 943 {
945 this->set_flag (FLAG_MAKE_INVIS); 944 set_flag (FLAG_MAKE_INVIS);
946 invisible = 1; 945 invisible = 1;
947 } 946 }
948 947
949 if (tmp->stats.exp && tmp->type != SKILL) 948 if (tmp->stats.exp && tmp->type != SKILL)
950 { 949 {
1612 */ 1611 */
1613 1612
1614sint64 1613sint64
1615level_exp (int level, double expmul) 1614level_exp (int level, double expmul)
1616{ 1615{
1617 if (level > settings.max_level) 1616 return expmul * level_to_min_exp (level);
1618 return (sint64) (expmul * levels[settings.max_level]);
1619
1620 return (sint64) (expmul * levels[level]);
1621} 1617}
1622 1618
1623/* 1619/*
1624 * Ensure that the permanent experience requirements in an exp object are met. 1620 * Ensure that the permanent experience requirements in an exp object are met.
1625 * This really just checks 'op to make sure the perm_exp value is within 1621 * This really just checks 'op to make sure the perm_exp value is within
1653 * NULL, in which case exp increases the players general 1649 * NULL, in which case exp increases the players general
1654 * total, but not any particular skill. 1650 * total, but not any particular skill.
1655 * flag is what to do if the player doesn't have the skill: 1651 * flag is what to do if the player doesn't have the skill:
1656 */ 1652 */
1657static void 1653static void
1658add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) 1654add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1659{ 1655{
1660 object *skill_obj; 1656 object *skill_obj;
1661 sint64 limit, exp_to_add; 1657 sint64 limit, exp_to_add;
1662 int i; 1658 int i;
1663 1659
1693 { 1689 {
1694 /* Basically, you can never gain more experience in one shot 1690 /* Basically, you can never gain more experience in one shot
1695 * than half what you need to gain for next level. 1691 * than half what you need to gain for next level.
1696 */ 1692 */
1697 exp_to_add = exp; 1693 exp_to_add = exp;
1698 limit = (levels[op->level + 1] - levels[op->level]) / 2; 1694 limit = (levels [op->level + 1] - levels [op->level]) / 2;
1699 if (exp_to_add > limit) 1695 if (exp_to_add > limit)
1700 exp_to_add = limit; 1696 exp_to_add = limit;
1701 1697
1702 ADD_EXP (op->stats.exp, (sint64) ((float) exp_to_add * (skill_obj ? skill_obj->expmul : 1))); 1698 ADD_EXP (op->stats.exp, (sint64) ((float) exp_to_add * (skill_obj ? skill_obj->expmul : 1)));
1703 if (settings.permanent_exp_ratio) 1699 if (settings.permanent_exp_ratio)
1710 } 1706 }
1711 1707
1712 if (skill_obj) 1708 if (skill_obj)
1713 { 1709 {
1714 exp_to_add = exp; 1710 exp_to_add = exp;
1715 limit = (levels[skill_obj->level + 1] - levels[skill_obj->level]) / 2; 1711 limit = (levels [skill_obj->level + 1] - levels [skill_obj->level]) / 2;
1716 if (exp_to_add > limit) 1712 if (exp_to_add > limit)
1717 exp_to_add = limit; 1713 exp_to_add = limit;
1718 1714
1719 ADD_EXP (skill_obj->stats.exp, exp_to_add); 1715 ADD_EXP (skill_obj->stats.exp, exp_to_add);
1720 if (settings.permanent_exp_ratio) 1716 if (settings.permanent_exp_ratio)
1777 * where everything is at the minimum perm exp, he would lose nothing. 1773 * where everything is at the minimum perm exp, he would lose nothing.
1778 * exp is the amount of exp to subtract - thus, it should be 1774 * exp is the amount of exp to subtract - thus, it should be
1779 * a postive number. 1775 * a postive number.
1780 */ 1776 */
1781static void 1777static void
1782subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) 1778subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag)
1783{ 1779{
1784 float fraction = (float) exp / (float) op->stats.exp; 1780 float fraction = (float) exp / (float) op->stats.exp;
1785 object *tmp; 1781 object *tmp;
1786 sint64 del_exp; 1782 sint64 del_exp;
1787 1783
1788 for (tmp = op->inv; tmp; tmp = tmp->below) 1784 for (tmp = op->inv; tmp; tmp = tmp->below)
1789 if (tmp->type == SKILL && tmp->stats.exp) 1785 if (tmp->type == SKILL && tmp->stats.exp)
1790 { 1786 {
1791 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) 1787 if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill)
1792 { 1788 {
1793 del_exp = check_exp_loss (tmp, exp); 1789 del_exp = check_exp_loss (tmp, exp);
1794 tmp->stats.exp -= del_exp; 1790 tmp->stats.exp -= del_exp;
1795 player_lvl_adj (op, tmp); 1791 player_lvl_adj (op, tmp);
1796 } 1792 }
1797 else if (flag != SK_SUBTRACT_SKILL_EXP) 1793 else if (flag != SK_SUBTRACT_SKILL_EXP)
1798 { 1794 {
1799 /* only want to process other skills if we are not trying 1795 /* only want to process other skills if we are not trying
1800 * to match a specific skill. 1796 * to match a specific skill.
1801 */ 1797 */
1802 del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); 1798 del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction);
1803 tmp->stats.exp -= del_exp; 1799 tmp->stats.exp -= del_exp;
1804 player_lvl_adj (op, tmp); 1800 player_lvl_adj (op, tmp);
1805 } 1801 }
1806 } 1802 }
1807 1803
1821 * skill_name is the skill that should get the exp added. 1817 * skill_name is the skill that should get the exp added.
1822 * flag is what to do if player doesn't have the skill. 1818 * flag is what to do if player doesn't have the skill.
1823 * these last two values are only used for players. 1819 * these last two values are only used for players.
1824 */ 1820 */
1825void 1821void
1826change_exp (object *op, sint64 exp, const char *skill_name, int flag) 1822change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag)
1827{ 1823{
1828#ifdef EXP_DEBUG 1824#ifdef EXP_DEBUG
1829 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp); 1825 LOG (llevDebug, "change_exp() called for %s, exp = %" PRId64 "\n", query_name (op), exp);
1830#endif 1826#endif
1831 1827

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines