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.85 by root, Sun May 4 19:14:23 2008 UTC vs.
Revision 1.94 by root, Tue Dec 23 00:39:48 2008 UTC

400 /* MOVE_FLY_HIGH trumps MOVE_FLY_LOW - changing your move_fly_low 400 /* MOVE_FLY_HIGH trumps MOVE_FLY_LOW - changing your move_fly_low
401 * status doesn't make a difference if you are flying high 401 * status doesn't make a difference if you are flying high
402 */ 402 */
403 if (tmp->move_type & MOVE_FLY_LOW && !(op->move_type & MOVE_FLY_HIGH)) 403 if (tmp->move_type & MOVE_FLY_LOW && !(op->move_type & MOVE_FLY_HIGH))
404 { 404 {
405 DIFF_MSG (flag, "You start to float in the air!.", "You float down to the ground."); 405 DIFF_MSG (flag, "You start to float in the air!", "You float down to the ground.");
406 } 406 }
407 407
408 if (tmp->move_type & MOVE_FLY_HIGH) 408 if (tmp->move_type & MOVE_FLY_HIGH)
409 { 409 {
410 /* double conditional - second case covers if you have move_fly_low - 410 /* double conditional - second case covers if you have move_fly_low -
858 * then calls this function. 858 * then calls this function.
859 */ 859 */
860 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) 860 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION)
861 continue; 861 continue;
862 862
863 /* See note in map.c:update_position about making this additive
864 * since light sources are never applied, need to put check here.
865 */
866 glow_radius = max (glow_radius, tmp->glow_radius); 863 glow_radius += tmp->glow_radius;
867 864
868 /* For some things, we don't care what is equipped */ 865 /* For some things, we don't care what is equipped */
869 if (tmp->type == SKILL) 866 if (tmp->type == SKILL)
870 { 867 {
871 /* Want to take the highest skill here. */ 868 /* Want to take the highest skill here. */
917 914
918 if (digest_types [tmp->type]) 915 if (digest_types [tmp->type])
919 { 916 {
920 contr->digestion += tmp->stats.food; 917 contr->digestion += tmp->stats.food;
921 contr->gen_hp += tmp->stats.hp; 918 contr->gen_hp += tmp->stats.hp;
919 if (tmp->type != BOW) // ugly exception for bows
922 contr->gen_sp += tmp->stats.sp; 920 contr->gen_sp += tmp->stats.sp;
923 contr->gen_grace += tmp->stats.grace; 921 contr->gen_grace += tmp->stats.grace;
924 contr->gen_sp_armour += tmp->gen_sp_armour; 922 contr->gen_sp_armour += tmp->gen_sp_armour;
925 } 923 }
926 } /* if this is a player */ 924 } /* if this is a player */
927 else 925 else
1149 break; 1147 break;
1150 } /* switch tmp->type */ 1148 } /* switch tmp->type */
1151 } /* item is equipped */ 1149 } /* item is equipped */
1152 } /* for loop of items */ 1150 } /* for loop of items */
1153 1151
1152 glow_radius = min (glow_radius, MAX_LIGHT_RADIUS);
1153
1154 /* We've gone through all the objects the player has equipped. For many things, we 1154 /* 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. 1155 * have generated intermediate values which we now need to assign.
1156 */ 1156 */
1157 1157
1158 /* 'total resistance = total protections - total vulnerabilities'. 1158 /* 'total resistance = total protections - total vulnerabilities'.
1441 1441
1442/* 1442/*
1443 * set the new dragon name after gaining levels or 1443 * set the new dragon name after gaining levels or
1444 * changing ability focus (later this can be extended to 1444 * changing ability focus (later this can be extended to
1445 * eventually change the player's face and animation) 1445 * 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 */ 1446 */
1452void 1447void
1453set_dragon_name (object *pl, const object *abil, const object *skin) 1448set_dragon_name (object *pl, const object *abil, const object *skin)
1454{ 1449{
1455 int atnr = -1; /* attacknumber of highest level */ 1450 int atnr = -1; /* attacknumber of highest level */
1473 /* now if there are equals at highest level, pick the one with focus, 1468 /* now if there are equals at highest level, pick the one with focus,
1474 or else at random */ 1469 or else at random */
1475 if (atnr_is_dragon_enabled (abil->stats.exp) && abil->resist[abil->stats.exp] >= level) 1470 if (atnr_is_dragon_enabled (abil->stats.exp) && abil->resist[abil->stats.exp] >= level)
1476 atnr = abil->stats.exp; 1471 atnr = abil->stats.exp;
1477 1472
1478 level = (int) (level / 25.);
1479
1480 /* now set the new title */ 1473 /* now set the new title */
1481 if (pl->contr)
1482 {
1483 if (level == 0)
1484 sprintf (pl->contr->title, "%s hatchling", attacks[atnr]); 1474 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]); 1475 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]); 1476 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]); 1477 else if (level < 100) sprintf (pl->contr->title, "%s dragon" , attacks[atnr]);
1491 else 1478 else
1492 { 1479 {
1493 /* special titles for extra high resistance! */ 1480 /* special titles for extra high resistance! */
1494 if (skin->resist[atnr] > 80)
1495 sprintf (pl->contr->title, "legendary %s dragon", attacks[atnr]); 1481 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]); 1482 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]); 1483 else sprintf (pl->contr->title, "big %s dragon" , attacks[atnr]);
1500 }
1501 } 1484 }
1502 1485
1503 strcpy (pl->contr->own_title, ""); 1486 strcpy (pl->contr->own_title, "");
1504} 1487}
1505 1488
1572 object *skill_obj; 1555 object *skill_obj;
1573 1556
1574 skill_obj = get_archetype_by_skill_name (skill_name, SKILL); 1557 skill_obj = get_archetype_by_skill_name (skill_name, SKILL);
1575 if (!skill_obj) 1558 if (!skill_obj)
1576 { 1559 {
1577 LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); 1560 LOG (llevError, "give_skill_by_name: couldn't find skill %s\n", skill_name);
1578 return NULL; 1561 return NULL;
1579 } 1562 }
1580 1563
1581 /* clear the flag - exp goes into this bucket, but player 1564 /* clear the flag - exp goes into this bucket, but player
1582 * still doesn't know it. 1565 * still doesn't know it.
1583 */ 1566 */
1584 CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); 1567 CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL);
1585 skill_obj->stats.exp = 0; 1568 skill_obj->stats.exp = 0;
1586 skill_obj->level = 1; 1569 skill_obj->level = 1;
1587 insert_ob_in_ob (skill_obj, op); 1570 op->insert (skill_obj);
1588 1571
1589 if (player *pl = op->contr) 1572 if (player *pl = op->contr)
1590 { 1573 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 1574
1596 return skill_obj; 1575 return skill_obj;
1597} 1576}
1598 1577
1599/* player_lvl_adj() - for the new exp system. we are concerned with 1578/* 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: 1697 * flag is what to do if the player doesn't have the skill:
1719 */ 1698 */
1720static void 1699static void
1721add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) 1700add_player_exp (object *op, sint64 exp, const char *skill_name, int flag)
1722{ 1701{
1723 object *skill_obj = NULL; 1702 object *skill_obj;
1724 sint64 limit, exp_to_add; 1703 sint64 limit, exp_to_add;
1725 int i; 1704 int i;
1726 1705
1727 /* prevents some forms of abuse. */ 1706 /* prevents some forms of abuse. */
1728 if (op->contr->braced) 1707 if (op->contr->braced)
1731 /* Try to find the matching skill. 1710 /* Try to find the matching skill.
1732 * We do a shortcut/time saving mechanism first - see if it matches 1711 * We do a shortcut/time saving mechanism first - see if it matches
1733 * chosen_skill. This means we don't need to search through 1712 * chosen_skill. This means we don't need to search through
1734 * the players inventory. 1713 * the players inventory.
1735 */ 1714 */
1715 skill_obj = 0;
1716
1736 if (skill_name) 1717 if (skill_name)
1737 { 1718 {
1738 if (op->chosen_skill && op->chosen_skill->type == SKILL && !strcmp (skill_name, op->chosen_skill->skill)) 1719 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 1720
1749 /* Player doesn't have the skill. Check to see what to do, and give 1721 /* Player doesn't have the skill. Check to see what to do, and give
1750 * it to the player if necessary 1722 * it to the player if necessary
1751 */ 1723 */
1752 if (!skill_obj) 1724 if (!skill_obj)
1753 { 1725 {
1754 if (flag == SK_EXP_NONE) 1726 if (flag == SK_EXP_NONE)
1755 return; 1727 return;
1728
1756 else if (flag == SK_EXP_ADD_SKILL) 1729 if (flag == SK_EXP_ADD_SKILL)
1757 give_skill_by_name (op, skill_name); 1730 skill_obj = give_skill_by_name (op, skill_name);
1758 }
1759 } 1731 }
1760 } 1732 }
1761 1733
1762 if (flag != SK_EXP_SKILL_ONLY) 1734 if (flag != SK_EXP_SKILL_ONLY)
1763 { 1735 {
1796 player_lvl_adj (op, skill_obj); 1768 player_lvl_adj (op, skill_obj);
1797 } 1769 }
1798} 1770}
1799 1771
1800/* This function checks to make sure that object 'op' can 1772/* This function checks to make sure that object 'op' can
1801 * lost 'exp' experience. It returns the amount of exp 1773 * lose 'exp' experience. It returns the amount of exp
1802 * object 'op' can in fact lose - it basically makes 1774 * object 'op' can in fact lose - it basically makes
1803 * adjustments based on permanent exp and the like. 1775 * adjustments based on permanent exp and the like.
1804 * This function should always be used for losing experience - 1776 * This function should always be used for losing experience -
1805 * the 'exp' value passed should be positive - this is the 1777 * the 'exp' value passed should be positive - this is the
1806 * amount that should get subtract from the player. 1778 * amount that should get subtract from the player.
1810{ 1782{
1811 sint64 del_exp; 1783 sint64 del_exp;
1812 1784
1813 if (exp > op->stats.exp) 1785 if (exp > op->stats.exp)
1814 exp = op->stats.exp; 1786 exp = op->stats.exp;
1787
1815 if (settings.permanent_exp_ratio) 1788 if (settings.permanent_exp_ratio)
1816 { 1789 {
1817 del_exp = (sint64) ((op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO); 1790 del_exp = (sint64) ((op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO);
1791
1818 if (del_exp < 0) 1792 if (del_exp < 0)
1819 del_exp = 0; 1793 del_exp = 0;
1794
1820 if (exp > del_exp) 1795 if (exp > del_exp)
1821 exp = del_exp; 1796 exp = del_exp;
1822 } 1797 }
1798
1823 return exp; 1799 return exp;
1824} 1800}
1825 1801
1826sint64 1802sint64
1827check_exp_adjust (const object *op, sint64 exp) 1803check_exp_adjust (const object *op, sint64 exp)
1828{ 1804{
1829 if (exp < 0) 1805 if (exp < 0)
1830 return check_exp_loss (op, exp); 1806 return check_exp_loss (op, exp);
1831 else 1807 else
1832 return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); 1808 return min (exp, (sint64)MAX_EXPERIENCE - op->stats.exp);
1833} 1809}
1834
1835 1810
1836/* Subtracts experience from player. 1811/* Subtracts experience from player.
1837 * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we 1812 * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we
1838 * only subtract from the matching skill. Otherwise, 1813 * only subtract from the matching skill. Otherwise,
1839 * this subtracts a portion from all 1814 * this subtracts a portion from all
1853 sint64 del_exp; 1828 sint64 del_exp;
1854 1829
1855 for (tmp = op->inv; tmp; tmp = tmp->below) 1830 for (tmp = op->inv; tmp; tmp = tmp->below)
1856 if (tmp->type == SKILL && tmp->stats.exp) 1831 if (tmp->type == SKILL && tmp->stats.exp)
1857 { 1832 {
1858 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (tmp->skill, skill)) 1833 if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill))
1859 { 1834 {
1860 del_exp = check_exp_loss (tmp, exp); 1835 del_exp = check_exp_loss (tmp, exp);
1861 tmp->stats.exp -= del_exp; 1836 tmp->stats.exp -= del_exp;
1862 player_lvl_adj (op, tmp); 1837 player_lvl_adj (op, tmp);
1863 } 1838 }
1951 * amount of permenent experience, whichever gives the lowest loss. 1926 * amount of permenent experience, whichever gives the lowest loss.
1952 */ 1927 */
1953void 1928void
1954apply_death_exp_penalty (object *op) 1929apply_death_exp_penalty (object *op)
1955{ 1930{
1956 object *tmp;
1957 sint64 loss; 1931 sint64 loss;
1958 sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */ 1932 sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */
1959 sint64 level_loss; /* defined by the setting 'death_penalty_levels */ 1933 sint64 level_loss; /* defined by the setting 'death_penalty_levels */
1960 1934
1961 for (tmp = op->inv; tmp; tmp = tmp->below) 1935 for (object *tmp = op->inv; tmp; tmp = tmp->below)
1962 if (tmp->type == SKILL && tmp->stats.exp) 1936 if (tmp->type == SKILL && tmp->stats.exp)
1963 { 1937 {
1964
1965 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100; 1938 percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100;
1966 level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)]; 1939 level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)];
1967 1940
1968 /* With the revised exp system, you can get cases where 1941 /* With the revised exp system, you can get cases where
1969 * losing several levels would still require that you have more 1942 * losing several levels would still require that you have more
1971 * tables is a lot harder. 1944 * tables is a lot harder.
1972 */ 1945 */
1973 if (level_loss < 0) 1946 if (level_loss < 0)
1974 level_loss = 0; 1947 level_loss = 0;
1975 1948
1976 loss = check_exp_loss (tmp, MIN (level_loss, percentage_loss)); 1949 loss = check_exp_loss (tmp, min (level_loss, percentage_loss));
1977 1950
1978 tmp->stats.exp -= loss; 1951 tmp->stats.exp -= loss;
1979 player_lvl_adj (op, tmp); 1952 player_lvl_adj (op, tmp);
1980 } 1953 }
1981 1954
1982 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; 1955 percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100;
1983 level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)]; 1956 level_loss = op->stats.exp - levels[max (0, op->level - settings.death_penalty_level)];
1984 1957
1985 if (level_loss < 0) 1958 if (level_loss < 0)
1986 level_loss = 0; 1959 level_loss = 0;
1960
1987 loss = check_exp_loss (op, MIN (level_loss, percentage_loss)); 1961 loss = check_exp_loss (op, min (level_loss, percentage_loss));
1988 1962
1989 op->stats.exp -= loss; 1963 op->stats.exp -= loss;
1990 player_lvl_adj (op, NULL); 1964 player_lvl_adj (op, NULL);
1991} 1965}
1992 1966

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines