… | |
… | |
1149 | |
1149 | |
1150 | break; |
1150 | break; |
1151 | } /* switch tmp->type */ |
1151 | } /* switch tmp->type */ |
1152 | } /* item is equipped */ |
1152 | } /* item is equipped */ |
1153 | } /* for loop of items */ |
1153 | } /* for loop of items */ |
|
|
1154 | fprintf (stderr, "gr %s %d\n", &name, glow_radius);//D |
1154 | |
1155 | |
1155 | /* We've gone through all the objects the player has equipped. For many things, we |
1156 | /* We've gone through all the objects the player has equipped. For many things, we |
1156 | * have generated intermediate values which we now need to assign. |
1157 | * have generated intermediate values which we now need to assign. |
1157 | */ |
1158 | */ |
1158 | |
1159 | |
… | |
… | |
1698 | * flag is what to do if the player doesn't have the skill: |
1699 | * flag is what to do if the player doesn't have the skill: |
1699 | */ |
1700 | */ |
1700 | static void |
1701 | static void |
1701 | add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1702 | add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) |
1702 | { |
1703 | { |
1703 | object *skill_obj = NULL; |
1704 | object *skill_obj; |
1704 | sint64 limit, exp_to_add; |
1705 | sint64 limit, exp_to_add; |
1705 | int i; |
1706 | int i; |
1706 | |
1707 | |
1707 | /* prevents some forms of abuse. */ |
1708 | /* prevents some forms of abuse. */ |
1708 | if (op->contr->braced) |
1709 | if (op->contr->braced) |
… | |
… | |
1711 | /* Try to find the matching skill. |
1712 | /* Try to find the matching skill. |
1712 | * We do a shortcut/time saving mechanism first - see if it matches |
1713 | * We do a shortcut/time saving mechanism first - see if it matches |
1713 | * chosen_skill. This means we don't need to search through |
1714 | * chosen_skill. This means we don't need to search through |
1714 | * the players inventory. |
1715 | * the players inventory. |
1715 | */ |
1716 | */ |
|
|
1717 | skill_obj = 0; |
|
|
1718 | |
1716 | if (skill_name) |
1719 | if (skill_name) |
1717 | { |
1720 | { |
1718 | if (op->chosen_skill && op->chosen_skill->type == SKILL && !strcmp (skill_name, op->chosen_skill->skill)) |
1721 | skill_obj = op->contr->find_skill (skill_name); |
1719 | skill_obj = op->chosen_skill; |
|
|
1720 | else |
|
|
1721 | { |
|
|
1722 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
|
|
1723 | if (tmp->skill == skill_name && tmp->type == SKILL) |
|
|
1724 | { |
|
|
1725 | skill_obj = splay (tmp); |
|
|
1726 | break; |
|
|
1727 | } |
|
|
1728 | |
1722 | |
1729 | /* Player doesn't have the skill. Check to see what to do, and give |
1723 | /* Player doesn't have the skill. Check to see what to do, and give |
1730 | * it to the player if necessary |
1724 | * it to the player if necessary |
1731 | */ |
1725 | */ |
1732 | if (!skill_obj) |
1726 | if (!skill_obj) |
1733 | { |
1727 | { |
1734 | if (flag == SK_EXP_NONE) |
1728 | if (flag == SK_EXP_NONE) |
1735 | return; |
1729 | return; |
|
|
1730 | |
1736 | else if (flag == SK_EXP_ADD_SKILL) |
1731 | if (flag == SK_EXP_ADD_SKILL) |
1737 | skill_obj = give_skill_by_name (op, skill_name); |
1732 | skill_obj = give_skill_by_name (op, skill_name); |
1738 | } |
|
|
1739 | } |
1733 | } |
1740 | } |
1734 | } |
1741 | |
1735 | |
1742 | if (flag != SK_EXP_SKILL_ONLY) |
1736 | if (flag != SK_EXP_SKILL_ONLY) |
1743 | { |
1737 | { |
… | |
… | |
1809 | if (exp < 0) |
1803 | if (exp < 0) |
1810 | return check_exp_loss (op, exp); |
1804 | return check_exp_loss (op, exp); |
1811 | else |
1805 | else |
1812 | return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1806 | return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1813 | } |
1807 | } |
1814 | |
|
|
1815 | |
1808 | |
1816 | /* Subtracts experience from player. |
1809 | /* Subtracts experience from player. |
1817 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
1810 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
1818 | * only subtract from the matching skill. Otherwise, |
1811 | * only subtract from the matching skill. Otherwise, |
1819 | * this subtracts a portion from all |
1812 | * this subtracts a portion from all |
… | |
… | |
1833 | sint64 del_exp; |
1826 | sint64 del_exp; |
1834 | |
1827 | |
1835 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1828 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1836 | if (tmp->type == SKILL && tmp->stats.exp) |
1829 | if (tmp->type == SKILL && tmp->stats.exp) |
1837 | { |
1830 | { |
1838 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (tmp->skill, skill)) |
1831 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) |
1839 | { |
1832 | { |
1840 | del_exp = check_exp_loss (tmp, exp); |
1833 | del_exp = check_exp_loss (tmp, exp); |
1841 | tmp->stats.exp -= del_exp; |
1834 | tmp->stats.exp -= del_exp; |
1842 | player_lvl_adj (op, tmp); |
1835 | player_lvl_adj (op, tmp); |
1843 | } |
1836 | } |