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.86 by root, Tue May 6 16:32:34 2008 UTC vs.
Revision 1.91 by root, Thu Dec 4 01:07:34 2008 UTC

917 917
918 if (digest_types [tmp->type]) 918 if (digest_types [tmp->type])
919 { 919 {
920 contr->digestion += tmp->stats.food; 920 contr->digestion += tmp->stats.food;
921 contr->gen_hp += tmp->stats.hp; 921 contr->gen_hp += tmp->stats.hp;
922 if (tmp->type != BOW) // ugly exception for bows
922 contr->gen_sp += tmp->stats.sp; 923 contr->gen_sp += tmp->stats.sp;
923 contr->gen_grace += tmp->stats.grace; 924 contr->gen_grace += tmp->stats.grace;
924 contr->gen_sp_armour += tmp->gen_sp_armour; 925 contr->gen_sp_armour += tmp->gen_sp_armour;
925 } 926 }
926 } /* if this is a player */ 927 } /* if this is a player */
927 else 928 else
1148 1149
1149 break; 1150 break;
1150 } /* switch tmp->type */ 1151 } /* switch tmp->type */
1151 } /* item is equipped */ 1152 } /* item is equipped */
1152 } /* for loop of items */ 1153 } /* for loop of items */
1154 fprintf (stderr, "gr %s %d\n", &name, glow_radius);//D
1153 1155
1154 /* 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
1155 * have generated intermediate values which we now need to assign. 1157 * have generated intermediate values which we now need to assign.
1156 */ 1158 */
1157 1159
1441 1443
1442/* 1444/*
1443 * set the new dragon name after gaining levels or 1445 * set the new dragon name after gaining levels or
1444 * changing ability focus (later this can be extended to 1446 * changing ability focus (later this can be extended to
1445 * eventually change the player's face and animation) 1447 * eventually change the player's face and animation)
1446 *
1447 * Note that the title is written to 'own_title' in the
1448 * player struct. This should be changed to 'ext_title'
1449 * as soon as clients support this!
1450 * Please, anyone, write support for 'ext_title'.
1451 */ 1448 */
1452void 1449void
1453set_dragon_name (object *pl, const object *abil, const object *skin) 1450set_dragon_name (object *pl, const object *abil, const object *skin)
1454{ 1451{
1455 int atnr = -1; /* attacknumber of highest level */ 1452 int atnr = -1; /* attacknumber of highest level */
1473 /* now if there are equals at highest level, pick the one with focus, 1470 /* now if there are equals at highest level, pick the one with focus,
1474 or else at random */ 1471 or else at random */
1475 if (atnr_is_dragon_enabled (abil->stats.exp) && abil->resist[abil->stats.exp] >= level) 1472 if (atnr_is_dragon_enabled (abil->stats.exp) && abil->resist[abil->stats.exp] >= level)
1476 atnr = abil->stats.exp; 1473 atnr = abil->stats.exp;
1477 1474
1478 level = (int) (level / 25.);
1479
1480 /* now set the new title */ 1475 /* now set the new title */
1481 if (pl->contr)
1482 {
1483 if (level == 0)
1484 sprintf (pl->contr->title, "%s hatchling", attacks[atnr]); 1476 if (level < 25) sprintf (pl->contr->title, "%s hatchling", attacks[atnr]);
1485 else if (level == 1)
1486 sprintf (pl->contr->title, "%s wyrm", attacks[atnr]); 1477 else if (level < 50) sprintf (pl->contr->title, "%s wyrm" , attacks[atnr]);
1487 else if (level == 2)
1488 sprintf (pl->contr->title, "%s wyvern", attacks[atnr]); 1478 else if (level < 75) sprintf (pl->contr->title, "%s wyvern" , attacks[atnr]);
1489 else if (level == 3)
1490 sprintf (pl->contr->title, "%s dragon", attacks[atnr]); 1479 else if (level < 100) sprintf (pl->contr->title, "%s dragon" , attacks[atnr]);
1491 else 1480 else
1492 { 1481 {
1493 /* special titles for extra high resistance! */ 1482 /* special titles for extra high resistance! */
1494 if (skin->resist[atnr] > 80)
1495 sprintf (pl->contr->title, "legendary %s dragon", attacks[atnr]); 1483 if (skin->resist[atnr] > 80) sprintf (pl->contr->title, "legendary %s dragon", attacks[atnr]);
1496 else if (skin->resist[atnr] > 50)
1497 sprintf (pl->contr->title, "ancient %s dragon", attacks[atnr]); 1484 else if (skin->resist[atnr] > 50) sprintf (pl->contr->title, "ancient %s dragon" , attacks[atnr]);
1498 else
1499 sprintf (pl->contr->title, "big %s dragon", attacks[atnr]); 1485 else sprintf (pl->contr->title, "big %s dragon" , attacks[atnr]);
1500 }
1501 } 1486 }
1502 1487
1503 strcpy (pl->contr->own_title, ""); 1488 strcpy (pl->contr->own_title, "");
1504} 1489}
1505 1490
1572 object *skill_obj; 1557 object *skill_obj;
1573 1558
1574 skill_obj = get_archetype_by_skill_name (skill_name, SKILL); 1559 skill_obj = get_archetype_by_skill_name (skill_name, SKILL);
1575 if (!skill_obj) 1560 if (!skill_obj)
1576 { 1561 {
1577 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);
1578 return NULL; 1563 return NULL;
1579 } 1564 }
1580 1565
1581 /* clear the flag - exp goes into this bucket, but player 1566 /* clear the flag - exp goes into this bucket, but player
1582 * still doesn't know it. 1567 * still doesn't know it.
1583 */ 1568 */
1584 CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); 1569 CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL);
1585 skill_obj->stats.exp = 0; 1570 skill_obj->stats.exp = 0;
1586 skill_obj->level = 1; 1571 skill_obj->level = 1;
1587 insert_ob_in_ob (skill_obj, op); 1572 op->insert (skill_obj);
1588 1573
1589 if (player *pl = op->contr) 1574 if (player *pl = op->contr)
1590 { 1575 pl->link_skills ();
1591 pl->last_skill_ob [skill_obj->subtype] = skill_obj;
1592 if (pl->ns)
1593 pl->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous
1594 }
1595 1576
1596 return skill_obj; 1577 return skill_obj;
1597} 1578}
1598 1579
1599/* 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
1718 * 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:
1719 */ 1700 */
1720static void 1701static void
1721add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) 1702add_player_exp (object *op, sint64 exp, const char *skill_name, int flag)
1722{ 1703{
1723 object *skill_obj = NULL; 1704 object *skill_obj;
1724 sint64 limit, exp_to_add; 1705 sint64 limit, exp_to_add;
1725 int i; 1706 int i;
1726 1707
1727 /* prevents some forms of abuse. */ 1708 /* prevents some forms of abuse. */
1728 if (op->contr->braced) 1709 if (op->contr->braced)
1731 /* Try to find the matching skill. 1712 /* Try to find the matching skill.
1732 * 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
1733 * chosen_skill. This means we don't need to search through 1714 * chosen_skill. This means we don't need to search through
1734 * the players inventory. 1715 * the players inventory.
1735 */ 1716 */
1717 skill_obj = 0;
1718
1736 if (skill_name) 1719 if (skill_name)
1737 { 1720 {
1738 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);
1739 skill_obj = op->chosen_skill;
1740 else
1741 {
1742 for (i = 0; i < NUM_SKILLS; i++)
1743 if (op->contr->last_skill_ob[i] && !strcmp (op->contr->last_skill_ob[i]->skill, skill_name))
1744 {
1745 skill_obj = op->contr->last_skill_ob[i];
1746 break;
1747 }
1748 1722
1749 /* 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
1750 * it to the player if necessary 1724 * it to the player if necessary
1751 */ 1725 */
1752 if (!skill_obj) 1726 if (!skill_obj)
1753 { 1727 {
1754 if (flag == SK_EXP_NONE) 1728 if (flag == SK_EXP_NONE)
1755 return; 1729 return;
1730
1756 else if (flag == SK_EXP_ADD_SKILL) 1731 if (flag == SK_EXP_ADD_SKILL)
1757 give_skill_by_name (op, skill_name); 1732 skill_obj = give_skill_by_name (op, skill_name);
1758 }
1759 } 1733 }
1760 } 1734 }
1761 1735
1762 if (flag != SK_EXP_SKILL_ONLY) 1736 if (flag != SK_EXP_SKILL_ONLY)
1763 { 1737 {
1829 if (exp < 0) 1803 if (exp < 0)
1830 return check_exp_loss (op, exp); 1804 return check_exp_loss (op, exp);
1831 else 1805 else
1832 return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); 1806 return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp);
1833} 1807}
1834
1835 1808
1836/* Subtracts experience from player. 1809/* Subtracts experience from player.
1837 * 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
1838 * only subtract from the matching skill. Otherwise, 1811 * only subtract from the matching skill. Otherwise,
1839 * this subtracts a portion from all 1812 * this subtracts a portion from all
1853 sint64 del_exp; 1826 sint64 del_exp;
1854 1827
1855 for (tmp = op->inv; tmp; tmp = tmp->below) 1828 for (tmp = op->inv; tmp; tmp = tmp->below)
1856 if (tmp->type == SKILL && tmp->stats.exp) 1829 if (tmp->type == SKILL && tmp->stats.exp)
1857 { 1830 {
1858 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (tmp->skill, skill)) 1831 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill))
1859 { 1832 {
1860 del_exp = check_exp_loss (tmp, exp); 1833 del_exp = check_exp_loss (tmp, exp);
1861 tmp->stats.exp -= del_exp; 1834 tmp->stats.exp -= del_exp;
1862 player_lvl_adj (op, tmp); 1835 player_lvl_adj (op, tmp);
1863 } 1836 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines