--- deliantra/server/common/living.c 2006/02/09 02:22:04 1.4 +++ deliantra/server/common/living.c 2006/06/25 22:19:41 1.8 @@ -70,10 +70,13 @@ * it is 1-diff */ -const float cha_bonus[MAX_STAT + 1]={10.0, 10.0, 9.0, 8.0, 7.0, 6.0, /*<-5*/ - 5.0, 4.5, 4.0, 3.5, 3.0, /*<-10*/ 2.9, 2.8, 2.7, 2.6, 2.5, /*<-15*/ - 2.4, 2.3, 2.2, 2.1, 2.0, /*<-20*/ 1.95, 1.90, 1.85, 1.80, 1.75, /*25 */ - 1.70, 1.65, 1.60, 1.55, 1.50 /*30 */ +const float cha_bonus[MAX_STAT + 1] = { 10.0, + 10.0, 9.0, 8.0, 7.0, 6.0, /* 5 */ + 5.0, 4.5, 4.0, 3.5, 3.0, /* 10 */ + 2.9, 2.8, 2.7, 2.6, 2.5, /* 15 */ + 2.4, 2.3, 2.2, 2.1, 2.0, /* 20 */ + 1.9, 1.8, 1.7, 1.6, 1.5, /* 25 */ + 1.4, 1.3, 1.2, 1.1, 1.0 /* 30 */ }; const int dex_bonus[MAX_STAT + 1]={ @@ -82,7 +85,7 @@ /* speed_bonus uses dex as its stat */ const float speed_bonus[MAX_STAT + 1]={ - -0.4, -0.4, -0.3, -0.3, -0.2, -0.2, -0.2, -0.1, -0.1, -0.1, -0.05, 0, 0, 0, + -0.4, -0.35, -0.3, -0.25, -0.2, -0.16, -0.12, -0.09, -0.06, -0.03, -0.01, 0, 0.01, 0.03, 0.05, 0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0 }; @@ -310,7 +313,7 @@ */ sint8 -get_attr_value(living *stats,int attr) { +get_attr_value(const living *stats,int attr) { switch(attr) { case STR: return(stats->Str); @@ -1374,7 +1377,7 @@ * false otherwise. */ -int allowed_class(object *op) { +int allowed_class(const object *op) { return op->stats.Dex>0&&op->stats.Str>0&&op->stats.Con>0&& op->stats.Int>0&&op->stats.Wis>0&&op->stats.Pow>0&& op->stats.Cha>0; @@ -1390,7 +1393,7 @@ * as soon as clients support this! * Please, anyone, write support for 'ext_title'. */ -void set_dragon_name(object *pl, object *abil, object *skin) { +void set_dragon_name(object *pl, const object *abil, const object *skin) { int atnr=-1; /* attacknumber of highest level */ int level=0; /* highest level */ int i; @@ -1543,13 +1546,13 @@ dragon_level_gain(who); /* Only roll these if it is the player (who) that gained the level */ - if(who && op==who && (who->level < 11) && who->type==PLAYER) { + if(op==who && (who->level < 11) && who->type==PLAYER) { who->contr->levhp[who->level] = die_roll(2, 4, who, PREFER_HIGH)+1; who->contr->levsp[who->level] = die_roll(2, 3, who, PREFER_HIGH); who->contr->levgrace[who->level]=die_roll(2, 2, who, PREFER_HIGH)-1; } - if(who) fix_player(who); + fix_player(who); if(op->level>1) { if (op->type!=PLAYER) sprintf(buf,"You are now level %d in the %s skill.",op->level,op->name); @@ -1560,10 +1563,10 @@ player_lvl_adj(who,op); /* To increase more levels */ } else if (op->level>1 && op->stats.explevel,who->expmul)) { op->level--; - if(who) fix_player(who); + fix_player(who); if(op->type!=PLAYER) { sprintf(buf,"You are now level %d in the %s skill.",op->level,op->name); - if(who) new_draw_info(NDI_UNIQUE|NDI_RED, 0, who,buf); + new_draw_info(NDI_UNIQUE|NDI_RED, 0, who,buf); } player_lvl_adj(who,op); /* To decrease more levels */ } @@ -1593,8 +1596,10 @@ { int p_exp_min; - /* Ensure that our permanent experience minimum is met. */ - p_exp_min = (int)(PERM_EXP_MINIMUM_RATIO * (float)(op->stats.exp)); + /* Ensure that our permanent experience minimum is met. + * permenent_exp_ratio is an integer percentage, we divide by 100 + * to get the fraction */ + p_exp_min = (int)(settings.permanent_exp_ratio * (float)(op->stats.exp)/100); if (op->perm_exp < p_exp_min) op->perm_exp = p_exp_min; @@ -1660,7 +1665,7 @@ if (exp_to_add > limit) exp_to_add=limit; ADD_EXP(op->stats.exp, (float) exp_to_add * (skill_obj? skill_obj->expmul:1)); - if (settings.use_permanent_experience) { + if (settings.permanent_exp_ratio) { ADD_EXP(op->perm_exp, (float) exp_to_add * PERM_EXP_GAIN_RATIO * (skill_obj? skill_obj->expmul:1)); calc_perm_exp(op); } @@ -1671,7 +1676,7 @@ limit=(levels[skill_obj->level+1]-levels[skill_obj->level])/2; if (exp_to_add > limit) exp_to_add=limit; ADD_EXP(skill_obj->stats.exp, exp_to_add); - if (settings.use_permanent_experience) { + if (settings.permanent_exp_ratio) { skill_obj->perm_exp += exp_to_add * PERM_EXP_GAIN_RATIO; calc_perm_exp(skill_obj); } @@ -1687,12 +1692,12 @@ * the 'exp' value passed should be positive - this is the * amount that should get subtract from the player. */ -sint64 check_exp_loss(object *op, sint64 exp) +sint64 check_exp_loss(const object *op, sint64 exp) { sint64 del_exp; if (exp > op->stats.exp) exp = op->stats.exp; - if (settings.use_permanent_experience) { + if (settings.permanent_exp_ratio) { del_exp = (op->stats.exp - op->perm_exp) * PERM_EXP_MAX_LOSS_RATIO; if (del_exp < 0) del_exp = 0; if (exp > del_exp) exp=del_exp; @@ -1700,7 +1705,7 @@ return exp; } -sint64 check_exp_adjust(object *op, sint64 exp) +sint64 check_exp_adjust(const object *op, sint64 exp) { if (exp<0) return check_exp_loss(op, exp); else return MIN(exp, MAX_EXPERIENCE - op->stats.exp); @@ -1813,47 +1818,40 @@ } } -/* Applies a death penalty experience. 20% or 3 levels, whichever is - * less experience lost. +/* Applies a death penalty experience, the size of this is defined by the + * settings death_penalty_percentage and death_penalty_levels, and by the + * amount of permenent experience, whichever gives the lowest loss. */ void apply_death_exp_penalty(object *op) { object *tmp; sint64 loss; - sint64 loss_20p; /* 20 percent experience loss */ - sint64 loss_3l; /* 3 level experience loss */ + sint64 percentage_loss; /* defined by the setting 'death_penalty_percent' */ + sint64 level_loss; /* defined by the setting 'death_penalty_levels */ for(tmp=op->inv;tmp;tmp=tmp->below) if(tmp->type==SKILL && tmp->stats.exp) { -#ifdef COZY_SERVER - loss_20p = tmp->stats.exp * 0.05; -#else - loss_20p = tmp->stats.exp * 0.20; -#endif - loss_3l = tmp->stats.exp - levels[MAX(0,tmp->level -3)]; + percentage_loss = tmp->stats.exp * settings.death_penalty_ratio/100; + level_loss = tmp->stats.exp - levels[MAX(0,tmp->level - settings.death_penalty_level)]; /* With the revised exp system, you can get cases where - * losing 3 levels would still require that you have more - * exp than you current have - this is true if the levels + * losing several levels would still require that you have more + * exp than you currently have - this is true if the levels * tables is a lot harder. */ - if (loss_3l < 0) loss_3l = 0; + if (level_loss < 0) level_loss = 0; - loss = check_exp_loss(tmp, MIN(loss_3l, loss_20p)); + loss = check_exp_loss(tmp, MIN(level_loss, percentage_loss)); tmp->stats.exp -= loss; player_lvl_adj(op,tmp); } -#ifdef COZY_SERVER - loss_20p = op->stats.exp * 0.05; -#else - loss_20p = op->stats.exp * 0.20; -#endif - loss_3l = op->stats.exp - levels[MAX(0,op->level -3)]; - if (loss_3l < 0) loss_3l = 0; - loss = check_exp_loss(op, MIN(loss_3l, loss_20p)); + percentage_loss = op->stats.exp * settings.death_penalty_ratio/100; + level_loss = op->stats.exp - levels[MAX(0,op->level - settings.death_penalty_level)]; + if (level_loss < 0) level_loss = 0; + loss = check_exp_loss(op, MIN(level_loss, percentage_loss)); op->stats.exp -= loss; player_lvl_adj(op,NULL); @@ -1866,7 +1864,7 @@ * resistance to particular attacktype. * Returns 1 if op makes his save, 0 if he failed */ -int did_make_save(object *op, int level, int bonus) +int did_make_save(const object *op, int level, int bonus) { if (level > MAX_SAVE_LEVEL) level = MAX_SAVE_LEVEL;