… | |
… | |
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 | |
… | |
… | |
1556 | object *skill_obj; |
1557 | object *skill_obj; |
1557 | |
1558 | |
1558 | skill_obj = get_archetype_by_skill_name (skill_name, SKILL); |
1559 | skill_obj = get_archetype_by_skill_name (skill_name, SKILL); |
1559 | if (!skill_obj) |
1560 | if (!skill_obj) |
1560 | { |
1561 | { |
1561 | LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); |
1562 | LOG (llevError, "give_skill_by_name: couldn't find skill %s\n", skill_name); |
1562 | return NULL; |
1563 | return NULL; |
1563 | } |
1564 | } |
1564 | |
1565 | |
1565 | /* clear the flag - exp goes into this bucket, but player |
1566 | /* clear the flag - exp goes into this bucket, but player |
1566 | * still doesn't know it. |
1567 | * still doesn't know it. |
1567 | */ |
1568 | */ |
1568 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1569 | CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); |
1569 | skill_obj->stats.exp = 0; |
1570 | skill_obj->stats.exp = 0; |
1570 | skill_obj->level = 1; |
1571 | skill_obj->level = 1; |
1571 | insert_ob_in_ob (skill_obj, op); |
1572 | op->insert (skill_obj); |
1572 | |
1573 | |
1573 | if (player *pl = op->contr) |
1574 | if (player *pl = op->contr) |
1574 | { |
1575 | pl->link_skills (); |
1575 | pl->last_skill_ob [skill_obj->subtype] = skill_obj; |
|
|
1576 | if (pl->ns) |
|
|
1577 | pl->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous |
|
|
1578 | } |
|
|
1579 | |
1576 | |
1580 | return skill_obj; |
1577 | return skill_obj; |
1581 | } |
1578 | } |
1582 | |
1579 | |
1583 | /* player_lvl_adj() - for the new exp system. we are concerned with |
1580 | /* player_lvl_adj() - for the new exp system. we are concerned with |
… | |
… | |
1702 | * 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: |
1703 | */ |
1700 | */ |
1704 | static void |
1701 | static void |
1705 | 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) |
1706 | { |
1703 | { |
1707 | object *skill_obj = NULL; |
1704 | object *skill_obj; |
1708 | sint64 limit, exp_to_add; |
1705 | sint64 limit, exp_to_add; |
1709 | int i; |
1706 | int i; |
1710 | |
1707 | |
1711 | /* prevents some forms of abuse. */ |
1708 | /* prevents some forms of abuse. */ |
1712 | if (op->contr->braced) |
1709 | if (op->contr->braced) |
… | |
… | |
1715 | /* Try to find the matching skill. |
1712 | /* Try to find the matching skill. |
1716 | * 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 |
1717 | * chosen_skill. This means we don't need to search through |
1714 | * chosen_skill. This means we don't need to search through |
1718 | * the players inventory. |
1715 | * the players inventory. |
1719 | */ |
1716 | */ |
|
|
1717 | skill_obj = 0; |
|
|
1718 | |
1720 | if (skill_name) |
1719 | if (skill_name) |
1721 | { |
1720 | { |
1722 | 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); |
1723 | skill_obj = op->chosen_skill; |
|
|
1724 | else |
|
|
1725 | { |
|
|
1726 | for (i = 0; i < NUM_SKILLS; i++) |
|
|
1727 | if (op->contr->last_skill_ob[i] && !strcmp (op->contr->last_skill_ob[i]->skill, skill_name)) |
|
|
1728 | { |
|
|
1729 | skill_obj = op->contr->last_skill_ob[i]; |
|
|
1730 | break; |
|
|
1731 | } |
|
|
1732 | |
1722 | |
1733 | /* 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 |
1734 | * it to the player if necessary |
1724 | * it to the player if necessary |
1735 | */ |
1725 | */ |
1736 | if (!skill_obj) |
1726 | if (!skill_obj) |
1737 | { |
1727 | { |
1738 | if (flag == SK_EXP_NONE) |
1728 | if (flag == SK_EXP_NONE) |
1739 | return; |
1729 | return; |
|
|
1730 | |
1740 | else if (flag == SK_EXP_ADD_SKILL) |
1731 | if (flag == SK_EXP_ADD_SKILL) |
1741 | give_skill_by_name (op, skill_name); |
1732 | skill_obj = give_skill_by_name (op, skill_name); |
1742 | } |
|
|
1743 | } |
1733 | } |
1744 | } |
1734 | } |
1745 | |
1735 | |
1746 | if (flag != SK_EXP_SKILL_ONLY) |
1736 | if (flag != SK_EXP_SKILL_ONLY) |
1747 | { |
1737 | { |
… | |
… | |
1813 | if (exp < 0) |
1803 | if (exp < 0) |
1814 | return check_exp_loss (op, exp); |
1804 | return check_exp_loss (op, exp); |
1815 | else |
1805 | else |
1816 | return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1806 | return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1817 | } |
1807 | } |
1818 | |
|
|
1819 | |
1808 | |
1820 | /* Subtracts experience from player. |
1809 | /* Subtracts experience from player. |
1821 | * 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 |
1822 | * only subtract from the matching skill. Otherwise, |
1811 | * only subtract from the matching skill. Otherwise, |
1823 | * this subtracts a portion from all |
1812 | * this subtracts a portion from all |
… | |
… | |
1837 | sint64 del_exp; |
1826 | sint64 del_exp; |
1838 | |
1827 | |
1839 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1828 | for (tmp = op->inv; tmp; tmp = tmp->below) |
1840 | if (tmp->type == SKILL && tmp->stats.exp) |
1829 | if (tmp->type == SKILL && tmp->stats.exp) |
1841 | { |
1830 | { |
1842 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (tmp->skill, skill)) |
1831 | if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) |
1843 | { |
1832 | { |
1844 | del_exp = check_exp_loss (tmp, exp); |
1833 | del_exp = check_exp_loss (tmp, exp); |
1845 | tmp->stats.exp -= del_exp; |
1834 | tmp->stats.exp -= del_exp; |
1846 | player_lvl_adj (op, tmp); |
1835 | player_lvl_adj (op, tmp); |
1847 | } |
1836 | } |