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.3 by root, Tue Aug 29 08:01:35 2006 UTC vs.
Revision 1.4 by elmex, Fri Sep 1 17:16:47 2006 UTC

1/* 1/*
2 * static char *rcsid_living_c = 2 * static char *rcsid_living_c =
3 * "$Id: living.C,v 1.3 2006/08/29 08:01:35 root Exp $"; 3 * "$Id: living.C,v 1.4 2006/09/01 17:16:47 elmex Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
1612 * NULL, in which case exp increases the players general 1612 * NULL, in which case exp increases the players general
1613 * total, but not any particular skill. 1613 * total, but not any particular skill.
1614 * flag is what to do if the player doesn't have the skill: 1614 * flag is what to do if the player doesn't have the skill:
1615 */ 1615 */
1616 1616
1617static void add_player_exp(object *op, sint64 exp, const char *skill_name, int flag) 1617static void add_player_exp (object * op, sint64 exp, const char *skill_name, int flag)
1618{ 1618{
1619 object *skill_obj=NULL; 1619 object *skill_obj = NULL;
1620 sint64 limit, exp_to_add; 1620 sint64 limit, exp_to_add;
1621 int i; 1621 int i;
1622 1622
1623 /* prevents some forms of abuse. */ 1623 /* prevents some forms of abuse. */
1624 if(op->contr->braced) exp=exp/5; 1624 if (op->contr->braced)
1625 exp = exp / 5;
1625 1626
1626 /* Try to find the matching skill. 1627 /* Try to find the matching skill.
1627 * We do a shortcut/time saving mechanism first - see if it matches 1628 * We do a shortcut/time saving mechanism first - see if it matches
1628 * chosen_skill. This means we don't need to search through 1629 * chosen_skill. This means we don't need to search through
1629 * the players inventory. 1630 * the players inventory.
1630 */ 1631 */
1631 if (skill_name) { 1632 if (skill_name)
1633 {
1632 if (op->chosen_skill && op->chosen_skill->type == SKILL && 1634 if (op->chosen_skill && op->chosen_skill->type == SKILL &&
1633 !strcmp(skill_name, op->chosen_skill->skill)) 1635 !strcmp (skill_name, op->chosen_skill->skill))
1634 skill_obj = op->chosen_skill; 1636 skill_obj = op->chosen_skill;
1635 else { 1637 else
1638 {
1636 for (i=0; i<NUM_SKILLS; i++) 1639 for (i = 0; i < NUM_SKILLS; i++)
1637 if (op->contr->last_skill_ob[i] && 1640 if (op->contr->last_skill_ob[i] &&
1638 !strcmp(op->contr->last_skill_ob[i]->skill, skill_name)) { 1641 !strcmp (op->contr->last_skill_ob[i]->skill, skill_name))
1642 {
1639 skill_obj = op->contr->last_skill_ob[i]; 1643 skill_obj = op->contr->last_skill_ob[i];
1640 break; 1644 break;
1641 } 1645 }
1642 1646
1643 /* Player doesn't have the skill. Check to see what to do, and give 1647 /* Player doesn't have the skill. Check to see what to do, and give
1644 * it to the player if necessary 1648 * it to the player if necessary
1645 */ 1649 */
1646 if (!skill_obj) { 1650 if (!skill_obj)
1651 {
1647 if (flag == SK_EXP_NONE) return; 1652 if (flag == SK_EXP_NONE)
1653 return;
1648 else if (flag == SK_EXP_ADD_SKILL) 1654 else if (flag == SK_EXP_ADD_SKILL)
1649 give_skill_by_name(op, skill_name); 1655 give_skill_by_name (op, skill_name);
1650 }
1651 } 1656 }
1657 }
1658 }
1659
1660 if (flag != SK_EXP_SKILL_ONLY)
1652 } 1661 {
1653
1654 /* Basically, you can never gain more experience in one shot 1662 /* Basically, you can never gain more experience in one shot
1655 * than half what you need to gain for next level. 1663 * than half what you need to gain for next level.
1656 */ 1664 */
1657 exp_to_add = exp;
1658 limit=(levels[op->level+1]-levels[op->level])/2;
1659 if (exp_to_add > limit) exp_to_add=limit;
1660
1661 ADD_EXP(op->stats.exp, (sint64) ((float) exp_to_add * (skill_obj? skill_obj->expmul:1)));
1662 if (settings.permanent_exp_ratio) {
1663 ADD_EXP(op->perm_exp, (sint64) ((float) exp_to_add * PERM_EXP_GAIN_RATIO * (skill_obj? skill_obj->expmul:1)));
1664 calc_perm_exp(op);
1665 }
1666
1667 player_lvl_adj(op,NULL);
1668 if (skill_obj) {
1669 exp_to_add = exp; 1665 exp_to_add = exp;
1666 limit = (levels[op->level + 1] - levels[op->level]) / 2;
1667 if (exp_to_add > limit)
1668 exp_to_add = limit;
1669
1670 ADD_EXP (op->stats.exp,
1671 (sint64) ((float) exp_to_add *
1672 (skill_obj ? skill_obj->expmul : 1)));
1673 if (settings.permanent_exp_ratio)
1674 {
1675 ADD_EXP (op->perm_exp,
1676 (sint64) ((float) exp_to_add * PERM_EXP_GAIN_RATIO *
1677 (skill_obj ? skill_obj->expmul : 1)));
1678 calc_perm_exp (op);
1679 }
1680
1681 player_lvl_adj (op, NULL);
1682 }
1683
1684 if (skill_obj)
1685 {
1686 exp_to_add = exp;
1670 limit=(levels[skill_obj->level+1]-levels[skill_obj->level])/2; 1687 limit = (levels[skill_obj->level + 1] - levels[skill_obj->level]) / 2;
1671 if (exp_to_add > limit) exp_to_add=limit; 1688 if (exp_to_add > limit)
1689 exp_to_add = limit;
1690
1672 ADD_EXP(skill_obj->stats.exp, exp_to_add); 1691 ADD_EXP (skill_obj->stats.exp, exp_to_add);
1673 if (settings.permanent_exp_ratio) { 1692 if (settings.permanent_exp_ratio)
1693 {
1694 skill_obj->perm_exp +=
1674 skill_obj->perm_exp += (sint64) ((float) exp_to_add * PERM_EXP_GAIN_RATIO); 1695 (sint64) ((float) exp_to_add * PERM_EXP_GAIN_RATIO);
1675 calc_perm_exp(skill_obj); 1696 calc_perm_exp (skill_obj);
1676 } 1697 }
1698
1677 player_lvl_adj(op,skill_obj); 1699 player_lvl_adj (op, skill_obj);
1678 } 1700 }
1679} 1701}
1680 1702
1681/* This function checks to make sure that object 'op' can 1703/* This function checks to make sure that object 'op' can
1682 * lost 'exp' experience. It returns the amount of exp 1704 * lost 'exp' experience. It returns the amount of exp

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines