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.92 by root, Thu Dec 4 03:48:19 2008 UTC vs.
Revision 1.93 by root, Thu Dec 18 19:56:09 2008 UTC

1769 player_lvl_adj (op, skill_obj); 1769 player_lvl_adj (op, skill_obj);
1770 } 1770 }
1771} 1771}
1772 1772
1773/* This function checks to make sure that object 'op' can 1773/* This function checks to make sure that object 'op' can
1774 * lost 'exp' experience. It returns the amount of exp 1774 * lose 'exp' experience. It returns the amount of exp
1775 * object 'op' can in fact lose - it basically makes 1775 * object 'op' can in fact lose - it basically makes
1776 * adjustments based on permanent exp and the like. 1776 * adjustments based on permanent exp and the like.
1777 * This function should always be used for losing experience - 1777 * This function should always be used for losing experience -
1778 * the 'exp' value passed should be positive - this is the 1778 * the 'exp' value passed should be positive - this is the
1779 * amount that should get subtract from the player. 1779 * amount that should get subtract from the player.
1783{ 1783{
1784 sint64 del_exp; 1784 sint64 del_exp;
1785 1785
1786 if (exp > op->stats.exp) 1786 if (exp > op->stats.exp)
1787 exp = op->stats.exp; 1787 exp = op->stats.exp;
1788
1788 if (settings.permanent_exp_ratio) 1789 if (settings.permanent_exp_ratio)
1789 { 1790 {
1790 del_exp = (sint64) ((op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO); 1791 del_exp = (sint64) ((op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO);
1792
1791 if (del_exp < 0) 1793 if (del_exp < 0)
1792 del_exp = 0; 1794 del_exp = 0;
1795
1793 if (exp > del_exp) 1796 if (exp > del_exp)
1794 exp = del_exp; 1797 exp = del_exp;
1795 } 1798 }
1799
1796 return exp; 1800 return exp;
1797} 1801}
1798 1802
1799sint64 1803sint64
1800check_exp_adjust (const object *op, sint64 exp) 1804check_exp_adjust (const object *op, sint64 exp)
1801{ 1805{
1802 if (exp < 0) 1806 if (exp < 0)
1803 return check_exp_loss (op, exp); 1807 return check_exp_loss (op, exp);
1804 else 1808 else
1805 return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); 1809 return min (exp, (sint64)MAX_EXPERIENCE - op->stats.exp);
1806} 1810}
1807 1811
1808/* Subtracts experience from player. 1812/* Subtracts experience from player.
1809 * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we 1813 * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we
1810 * only subtract from the matching skill. Otherwise, 1814 * only subtract from the matching skill. Otherwise,
1923 * amount of permenent experience, whichever gives the lowest loss. 1927 * amount of permenent experience, whichever gives the lowest loss.
1924 */ 1928 */
1925void 1929void
1926apply_death_exp_penalty (object *op) 1930apply_death_exp_penalty (object *op)
1927{ 1931{
1928 object *tmp;
1929 sint64 loss; 1932 sint64 loss;
1930 sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */ 1933 sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */
1931 sint64 level_loss; /* defined by the setting 'death_penalty_levels */ 1934 sint64 level_loss; /* defined by the setting 'death_penalty_levels */
1932 1935
1933 for (tmp = op->inv; tmp; tmp = tmp->below) 1936 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1934 if (tmp->type == SKILL && tmp->stats.exp) 1937 if (tmp->type == SKILL && tmp->stats.exp)
1935 { 1938 {
1936
1937 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100; 1939 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100;
1938 level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)]; 1940 level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)];
1939 1941
1940 /* With the revised exp system, you can get cases where 1942 /* With the revised exp system, you can get cases where
1941 * losing several levels would still require that you have more 1943 * losing several levels would still require that you have more
1943 * tables is a lot harder. 1945 * tables is a lot harder.
1944 */ 1946 */
1945 if (level_loss < 0) 1947 if (level_loss < 0)
1946 level_loss = 0; 1948 level_loss = 0;
1947 1949
1948 loss = check_exp_loss (tmp, MIN (level_loss, percentage_loss)); 1950 loss = check_exp_loss (tmp, min (level_loss, percentage_loss));
1949 1951
1950 tmp->stats.exp -= loss; 1952 tmp->stats.exp -= loss;
1951 player_lvl_adj (op, tmp); 1953 player_lvl_adj (op, tmp);
1952 } 1954 }
1953 1955
1954 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1956 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100;
1955 level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)]; 1957 level_loss = op->stats.exp - levels[max (0, op->level - settings.death_penalty_level)];
1956 1958
1957 if (level_loss < 0) 1959 if (level_loss < 0)
1958 level_loss = 0; 1960 level_loss = 0;
1961
1959 loss = check_exp_loss (op, MIN (level_loss, percentage_loss)); 1962 loss = check_exp_loss (op, min (level_loss, percentage_loss));
1960 1963
1961 op->stats.exp -= loss; 1964 op->stats.exp -= loss;
1962 player_lvl_adj (op, NULL); 1965 player_lvl_adj (op, NULL);
1963} 1966}
1964 1967

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines