1 | /* |
1 | /* |
2 | * static char *rcsid_living_c = |
2 | * static char *rcsid_living_c = |
3 | * "$Id: living.C,v 1.5 2006/09/03 00:18:40 root Exp $"; |
3 | * "$Id: living.C,v 1.8 2006/09/09 22:09:19 root 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 | |
… | |
… | |
368 | * will clear the bits, but the player may still have some other object |
368 | * will clear the bits, but the player may still have some other object |
369 | * that gives them that ability. |
369 | * that gives them that ability. |
370 | */ |
370 | */ |
371 | int change_abil(object *op, object *tmp) { |
371 | int change_abil(object *op, object *tmp) { |
372 | int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1,i,j,success=0; |
372 | int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1,i,j,success=0; |
373 | object refop; |
|
|
374 | char message[MAX_BUF]; |
373 | char message[MAX_BUF]; |
375 | int potion_max=0; |
374 | int potion_max=0; |
376 | |
375 | |
377 | /* remember what object was like before it was changed. note that |
376 | /* remember what object was like before it was changed. note that |
378 | * refop is a local copy of op only to be used for detecting changes |
377 | * refop is a local copy of op only to be used for detecting changes |
379 | * found by fix_player. refop is not a real object |
378 | * found by fix_player. refop is not a real object |
380 | */ |
379 | */ |
381 | memcpy(&refop, op, sizeof(object)); |
380 | object_pod refop = *op; |
382 | |
381 | |
383 | if(op->type==PLAYER) { |
382 | if(op->type==PLAYER) { |
384 | if (tmp->type==POTION) { |
383 | if (tmp->type==POTION) { |
385 | potion_max=1; |
384 | potion_max=1; |
386 | for(j=0;j<NUM_STATS;j++) { |
385 | for(j=0;j<NUM_STATS;j++) { |
… | |
… | |
1584 | op->perm_exp = p_exp_min; |
1583 | op->perm_exp = p_exp_min; |
1585 | |
1584 | |
1586 | /* Cap permanent experience. */ |
1585 | /* Cap permanent experience. */ |
1587 | if (op->perm_exp < 0) |
1586 | if (op->perm_exp < 0) |
1588 | op->perm_exp = 0; |
1587 | op->perm_exp = 0; |
1589 | else if (op->perm_exp > MAX_EXPERIENCE) |
1588 | else if (op->perm_exp > (sint64) MAX_EXPERIENCE) |
1590 | op->perm_exp = MAX_EXPERIENCE; |
1589 | op->perm_exp = MAX_EXPERIENCE; |
1591 | } |
1590 | } |
1592 | |
1591 | |
1593 | |
1592 | |
1594 | /* Add experience to a player - exp should only be positive. |
1593 | /* Add experience to a player - exp should only be positive. |
… | |
… | |
1707 | } |
1706 | } |
1708 | |
1707 | |
1709 | sint64 check_exp_adjust(const object *op, sint64 exp) |
1708 | sint64 check_exp_adjust(const object *op, sint64 exp) |
1710 | { |
1709 | { |
1711 | if (exp<0) return check_exp_loss(op, exp); |
1710 | if (exp<0) return check_exp_loss(op, exp); |
1712 | else return MIN(exp, MAX_EXPERIENCE - op->stats.exp); |
1711 | else return MIN(exp, (sint64) MAX_EXPERIENCE - op->stats.exp); |
1713 | } |
1712 | } |
1714 | |
1713 | |
1715 | |
1714 | |
1716 | /* Subtracts experience from player. |
1715 | /* Subtracts experience from player. |
1717 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
1716 | * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we |
… | |
… | |
1797 | |
1796 | |
1798 | /* reset exp to max allowed value. We subtract from |
1797 | /* reset exp to max allowed value. We subtract from |
1799 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1798 | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
1800 | * more than max exp, just return. |
1799 | * more than max exp, just return. |
1801 | */ |
1800 | */ |
1802 | if (exp > 0 && ( op->stats.exp > (MAX_EXPERIENCE - exp))) { |
1801 | if (exp > 0 && ( op->stats.exp > (sint64) (MAX_EXPERIENCE - exp))) { |
1803 | exp = MAX_EXPERIENCE - op->stats.exp; |
1802 | exp = MAX_EXPERIENCE - op->stats.exp; |
1804 | if (exp < 0) return; |
1803 | if (exp < 0) return; |
1805 | } |
1804 | } |
1806 | |
1805 | |
1807 | op->stats.exp += exp; |
1806 | op->stats.exp += exp; |