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.71 by elmex, Sat Jul 21 14:37:25 2007 UTC vs.
Revision 1.73 by root, Tue Jul 31 18:08:58 2007 UTC

808 ac = arch->stats.ac; 808 ac = arch->stats.ac;
809 809
810 stats.luck = arch->stats.luck; 810 stats.luck = arch->stats.luck;
811 speed = arch->speed; 811 speed = arch->speed;
812 812
813 sint16 digestion = 0; // a local var to add digestion
814
815 /* OK - we've reset most all the objects attributes to sane values. 813 /* OK - we've reset most all the objects attributes to sane values.
816 * now go through and make adjustments for what the player has equipped. 814 * now go through and make adjustments for what the player has equipped.
817 */ 815 */
818 for (tmp = inv; tmp; tmp = tmp->below) 816 for (tmp = inv; tmp; tmp = tmp->below)
819 { 817 {
891 tmp->type == AMULET || tmp->type == GIRDLE || 889 tmp->type == AMULET || tmp->type == GIRDLE ||
892 tmp->type == BRACERS || tmp->type == CLOAK || 890 tmp->type == BRACERS || tmp->type == CLOAK ||
893 tmp->type == DISEASE || tmp->type == FORCE || 891 tmp->type == DISEASE || tmp->type == FORCE ||
894 tmp->type == SKILL) 892 tmp->type == SKILL)
895 { 893 {
896 digestion += tmp->stats.food; 894 contr->digestion = clamp (int (contr->digestion) + tmp->stats.food, MIN_DIGESTION, MAX_DIGESTION);
897 contr->gen_hp += tmp->stats.hp; 895 contr->gen_hp += tmp->stats.hp;
898 contr->gen_sp += tmp->stats.sp; 896 contr->gen_sp += tmp->stats.sp;
899 contr->gen_grace += tmp->stats.grace; 897 contr->gen_grace += tmp->stats.grace;
900 contr->gen_sp_armour += tmp->gen_sp_armour; 898 contr->gen_sp_armour += tmp->gen_sp_armour;
901 } 899 }
1135 break; 1133 break;
1136 } /* switch tmp->type */ 1134 } /* switch tmp->type */
1137 } /* item is equipped */ 1135 } /* item is equipped */
1138 } /* for loop of items */ 1136 } /* for loop of items */
1139 1137
1140 // now clamp digestion to our limits
1141 contr->digestion = clamp (digestion, MIN_DIGESTION, MAX_DIGESTION);
1142
1143 /* We've gone through all the objects the player has equipped. For many things, we 1138 /* We've gone through all the objects the player has equipped. For many things, we
1144 * have generated intermediate values which we now need to assign. 1139 * have generated intermediate values which we now need to assign.
1145 */ 1140 */
1146 1141
1147 /* 'total resistance = total protections - total vulnerabilities'. 1142 /* 'total resistance = total protections - total vulnerabilities'.
1604 */ 1599 */
1605void 1600void
1606player_lvl_adj (object *who, object *op) 1601player_lvl_adj (object *who, object *op)
1607{ 1602{
1608 char buf[MAX_BUF]; 1603 char buf[MAX_BUF];
1604 bool changed = false;
1609 1605
1610 if (!op) /* when rolling stats */ 1606 if (!op) /* when rolling stats */
1611 op = who; 1607 op = who;
1612 1608
1613 if (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul)) 1609 while (op->level < settings.max_level && op->stats.exp >= level_exp (op->level + 1, who->expmul))
1614 { 1610 {
1611 changed = true;
1612
1615 op->level++; 1613 op->level++;
1616 1614
1617 if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who)) 1615 if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who))
1618 dragon_level_gain (who); 1616 dragon_level_gain (who);
1619 1617
1623 who->contr->levhp[who->level] = die_roll (2, 4, who, PREFER_HIGH) + 1; 1621 who->contr->levhp[who->level] = die_roll (2, 4, who, PREFER_HIGH) + 1;
1624 who->contr->levsp[who->level] = die_roll (2, 3, who, PREFER_HIGH); 1622 who->contr->levsp[who->level] = die_roll (2, 3, who, PREFER_HIGH);
1625 who->contr->levgrace[who->level] = die_roll (2, 2, who, PREFER_HIGH) - 1; 1623 who->contr->levgrace[who->level] = die_roll (2, 2, who, PREFER_HIGH) - 1;
1626 } 1624 }
1627 1625
1628 who->update_stats ();
1629 if (op->level > 1) 1626 if (op->level > 1)
1630 { 1627 {
1631 if (op->type != PLAYER) 1628 if (op->type != PLAYER)
1629 {
1630 who->contr->play_sound (sound_find ("skill_up"));
1632 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); 1631 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name);
1632 }
1633 else 1633 else
1634 {
1635 who->contr->play_sound (sound_find ("level_up"));
1634 sprintf (buf, "You are now level %d.", op->level); 1636 sprintf (buf, "You are now level %d.", op->level);
1637 }
1635 1638
1636 if (who) 1639 if (who)
1637 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); 1640 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf);
1638 } 1641 }
1639
1640 player_lvl_adj (who, op); /* To increase more levels */
1641 } 1642 }
1643
1642 else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul)) 1644 while (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul))
1643 { 1645 {
1646 changed = true;
1647
1644 op->level--; 1648 op->level--;
1645 who->update_stats ();
1646 1649
1647 if (op->type != PLAYER) 1650 if (op->type != PLAYER)
1648 { 1651 {
1649 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); 1652 sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name);
1650 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); 1653 new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf);
1651 } 1654 }
1655 }
1652 1656
1653 player_lvl_adj (who, op); /* To decrease more levels */ 1657 if (changed)
1654 } 1658 {
1655 1659 who->update_stats ();
1660 esrv_update_stats (who->contr);
1656 /* check if the spell data has changed */ 1661 /* check if the spell data has changed */
1657 esrv_update_stats (who->contr);
1658 esrv_update_spells (who->contr); 1662 esrv_update_spells (who->contr);
1663 }
1659} 1664}
1660 1665
1661/* 1666/*
1662 * Returns how much experience is needed for a player to become 1667 * Returns how much experience is needed for a player to become
1663 * the given level. level should really never exceed max_level 1668 * the given level. level should really never exceed max_level

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines