… | |
… | |
1649 | * NULL, in which case exp increases the players general |
1649 | * NULL, in which case exp increases the players general |
1650 | * total, but not any particular skill. |
1650 | * total, but not any particular skill. |
1651 | * 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: |
1652 | */ |
1652 | */ |
1653 | static void |
1653 | static void |
1654 | add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1654 | add_player_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) |
1655 | { |
1655 | { |
1656 | object *skill_obj; |
1656 | object *skill_obj; |
1657 | sint64 limit, exp_to_add; |
1657 | sint64 limit, exp_to_add; |
1658 | int i; |
1658 | int i; |
1659 | |
1659 | |
… | |
… | |
1773 | * 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. |
1774 | * 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 |
1775 | * a postive number. |
1775 | * a postive number. |
1776 | */ |
1776 | */ |
1777 | static void |
1777 | static void |
1778 | subtract_player_exp (object *op, sint64 exp, const char *skill, int flag) |
1778 | subtract_player_exp (object *op, sint64 exp, shstr_tmp skill, int flag) |
1779 | { |
1779 | { |
1780 | float fraction = (float) exp / (float) op->stats.exp; |
1780 | float fraction = (float) exp / (float) op->stats.exp; |
1781 | object *tmp; |
1781 | object *tmp; |
1782 | sint64 del_exp; |
1782 | sint64 del_exp; |
1783 | |
1783 | |
1784 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1784 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1785 | if (tmp->type == SKILL && tmp->stats.exp) |
1785 | if (tmp->type == SKILL && tmp->stats.exp) |
1786 | { |
1786 | { |
1787 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) |
1787 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && tmp->skill == skill) |
1788 | { |
1788 | { |
1789 | del_exp = check_exp_loss (tmp, exp); |
1789 | del_exp = check_exp_loss (tmp, exp); |
1790 | tmp->stats.exp -= del_exp; |
1790 | tmp->stats.exp -= del_exp; |
1791 | player_lvl_adj (op, tmp); |
1791 | player_lvl_adj (op, tmp); |
1792 | } |
1792 | } |
1793 | else if (flag != SK_SUBTRACT_SKILL_EXP) |
1793 | else if (flag != SK_SUBTRACT_SKILL_EXP) |
1794 | { |
1794 | { |
1795 | /* only want to process other skills if we are not trying |
1795 | /* only want to process other skills if we are not trying |
1796 | * to match a specific skill. |
1796 | * to match a specific skill. |
1797 | */ |
1797 | */ |
1798 | del_exp = check_exp_loss (tmp, (sint64) (tmp->stats.exp * fraction)); |
1798 | del_exp = check_exp_loss (tmp, tmp->stats.exp * fraction); |
1799 | tmp->stats.exp -= del_exp; |
1799 | tmp->stats.exp -= del_exp; |
1800 | player_lvl_adj (op, tmp); |
1800 | player_lvl_adj (op, tmp); |
1801 | } |
1801 | } |
1802 | } |
1802 | } |
1803 | |
1803 | |
… | |
… | |
1817 | * skill_name is the skill that should get the exp added. |
1817 | * skill_name is the skill that should get the exp added. |
1818 | * 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. |
1819 | * these last two values are only used for players. |
1819 | * these last two values are only used for players. |
1820 | */ |
1820 | */ |
1821 | void |
1821 | void |
1822 | change_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1822 | change_exp (object *op, sint64 exp, shstr_tmp skill_name, int flag) |
1823 | { |
1823 | { |
1824 | #ifdef EXP_DEBUG |
1824 | #ifdef EXP_DEBUG |
1825 | 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); |
1826 | #endif |
1826 | #endif |
1827 | |
1827 | |