version 1.56 | | version 1.57 |
---|
| | |
/* | | /* |
* static char *rcsid_living_c = | | * static char *rcsid_living_c = |
* "$Id: living.c,v 1.56 2003/11/07 19:54:49 ryo_saeba Exp $"; | | * "$Id: living.c,v 1.57 2003/11/10 05:39:50 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* flag is what to do if the player doesn't have the skill: | | * flag is what to do if the player doesn't have the skill: |
*/ | | */ |
| | |
static void add_player_exp(object *op, int exp, char *skill_name, int flag) | | static void add_player_exp(object *op, sint64 exp, char *skill_name, int flag) |
{ | | { |
object *skill_obj=NULL; | | object *skill_obj=NULL; |
sint64 limit, exp_to_add; | | sint64 limit, exp_to_add; |
| | |
* exp is the amount of exp to subtract - thus, it should be | | * exp is the amount of exp to subtract - thus, it should be |
* a postive number. | | * a postive number. |
*/ | | */ |
static void subtract_player_exp(object *op, int exp, char *skill, int flag) | | static void subtract_player_exp(object *op, sint64 exp, char *skill, int flag) |
{ | | { |
float fraction = (float) exp/(float) op->stats.exp; | | float fraction = (float) exp/(float) op->stats.exp; |
object *tmp; | | object *tmp; |
int del_exp; | | sint64 del_exp; |
| | |
for(tmp=op->inv;tmp;tmp=tmp->below) | | for(tmp=op->inv;tmp;tmp=tmp->below) |
if(tmp->type==SKILL && tmp->stats.exp) { | | if(tmp->type==SKILL && tmp->stats.exp) { |
| | |
player_lvl_adj(op, tmp); | | player_lvl_adj(op, tmp); |
} | | } |
} | | } |
| | if (flag != SK_SUBTRACT_SKILL_EXP) { |
op->stats.exp -= exp; | | del_exp = check_exp_loss(op, exp); |
| | op->stats.exp -= del_exp; |
player_lvl_adj(op,NULL); | | player_lvl_adj(op,NULL); |
} | | } |
| | } |
| | |
| | |
| | |
| | |
* these last two values are only used for players. | | * these last two values are only used for players. |
*/ | | */ |
| | |
void change_exp(object *op, int exp, char *skill_name, int flag) { | | void change_exp(object *op, sint64 exp, char *skill_name, int flag) { |
uint64 exp_to_add = exp; | | |
| | |
| | |
#ifdef EXP_DEBUG | | #ifdef EXP_DEBUG |
LOG(llevDebug,"add_exp() called for %s, exp = %lld\n",query_name(op),exp); | | LOG(llevDebug,"chnage_exp() called for %s, exp = %lld\n",query_name(op),exp); |
#endif | | #endif |
| | |
/* safety */ | | /* safety */ |
| | |
* MAX_EXPERIENCE to prevent overflows. If the player somehow has | | * MAX_EXPERIENCE to prevent overflows. If the player somehow has |
* more than max exp, just return. | | * more than max exp, just return. |
*/ | | */ |
if (exp_to_add > 0 && ( op->stats.exp > (MAX_EXPERIENCE - exp_to_add))) { | | if (exp > 0 && ( op->stats.exp > (MAX_EXPERIENCE - exp))) { |
exp_to_add = MAX_EXPERIENCE - op->stats.exp; | | exp = MAX_EXPERIENCE - op->stats.exp; |
if (exp_to_add < 0) return; | | if (exp < 0) return; |
} | | } |
| | |
/* Monsters are easy - we just adjust their exp - we | | /* Monsters are easy - we just adjust their exp - we |
| | |
if(op->type != PLAYER) { | | if(op->type != PLAYER) { |
/* Sanity check */ | | /* Sanity check */ |
if (!QUERY_FLAG(op, FLAG_ALIVE)) return; | | if (!QUERY_FLAG(op, FLAG_ALIVE)) return; |
op->stats.exp += exp_to_add; | | op->stats.exp += exp; |
} | | } |
else { /* Players only */ | | else { /* Players only */ |
if(exp>0) | | if(exp>0) |