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.88 by root, Tue Jul 15 20:41:58 2008 UTC vs.
Revision 1.90 by root, Thu Sep 25 22:58:13 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines