--- deliantra/server/common/living.C 2007/05/12 18:34:19 1.52 +++ deliantra/server/common/living.C 2007/05/17 00:33:29 1.59 @@ -725,7 +725,7 @@ int weapon_weight = 0, weapon_speed = 0; int best_wc = 0, best_ac = 0, wc = 0, ac = 0; int prot[NROFATTACKS], vuln[NROFATTACKS], potion_resist[NROFATTACKS]; - object *grace_obj = NULL, *mana_obj = NULL, *wc_obj = NULL, *tmp; + object *grace_obj = NULL, *mana_obj = NULL, *tmp; float old_speed = speed; /* First task is to clear all the values back to their original values */ @@ -868,14 +868,17 @@ if (type == PLAYER) { if (tmp == contr->combat_ob || tmp == contr->ranged_ob) - if (tmp != current_weapon && (tmp->type != SKILL || tmp->subtype != SK_PRAYING)) + if (tmp != current_weapon + && (tmp->type != SKILL || tmp->subtype != SK_PRAYING) + && !tmp->flag [FLAG_CURSED] + && !tmp->flag [FLAG_DAMNED]) continue; for (i = 0; i < NUM_STATS; i++) change_attr_value (&stats, i, tmp->stats.stat (i)); - /* these are the items that currently can change digestion, regeneration, - * spell point recovery and mana point recovery. Seems sort of an arbitary + /* These are the items that currently can change digestion, regeneration, + * spell point recovery and mana point recovery. Seems sort of an arbitary * list, but other items store other info into stats array. */ if (tmp->type == WEAPON || tmp->type == BOW || @@ -941,8 +944,7 @@ } /* There may be other things that should not adjust the attacktype */ - if ((tmp->type != WEAPON && tmp->type != BOW && tmp->type != SYMPTOM) - || current_weapon == tmp) + if (tmp->type != SYMPTOM) { attacktype |= tmp->attacktype; path_attuned |= tmp->path_attuned; @@ -997,9 +999,6 @@ if (!QUERY_FLAG (tmp, FLAG_APPLIED)) break; - if (IS_COMBAT_SKILL (tmp->subtype)) - wc_obj = tmp; - if (chosen_skill) LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); @@ -1014,7 +1013,7 @@ weapon_speed = 0; weapon_weight = tmp->weight; - stats.dam += tmp->stats.dam * (1 + (chosen_skill->level / 9)); + stats.dam += 1 + (chosen_skill->level * tmp->stats.dam / 9); if (tmp->magic) stats.dam += tmp->magic; @@ -1034,13 +1033,6 @@ break; - case SKILL_TOOL: - if (chosen_skill) - LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); - - chosen_skill = tmp; - break; - case SHIELD: if (settings.spell_encumbrance == TRUE && type == PLAYER) contr->encumbrance += (int) tmp->weight / 2000; @@ -1228,6 +1220,7 @@ for (i = 11; i <= mana_obj->level; i++) stats.maxsp += 2; } + /* Characters can get their sp supercharged via rune of transferrance */ if (stats.sp > stats.maxsp * 2) stats.sp = stats.maxsp * 2; @@ -1268,6 +1261,7 @@ for (i = 11; i <= grace_obj->level; i++) stats.maxgrace += 2; } + /* No limit on grace vs maxgrace */ if (contr->braced) @@ -1289,18 +1283,19 @@ * to make up for the change. Note that I left the * monster bonus the same as before. -b.t. */ + object *wc_obj = chosen_skill; - if (type == PLAYER && wc_obj && wc_obj->level > 1) + if (contr && wc_obj && wc_obj->level > 1) { wc -= wc_obj->level + thaco_bonus[stats.Str]; for (i = 1; i < wc_obj->level; i++) { - /* addtional wc every 6 levels */ + /* additional wc every 6 levels */ if (!(i % 6)) wc--; - /* addtional dam every 4 levels. */ + /* additional dam every 4 levels. */ if (!(i % 4) && dam_bonus[stats.Str] >= 0) stats.dam += 1 + dam_bonus[stats.Str] / 5; } @@ -1320,7 +1315,6 @@ if (attacktype == 0) attacktype = arch->clone.attacktype; - } /* End if player */ if (added_speed >= 0) @@ -1364,13 +1358,13 @@ float M = (max_carry[stats.Str] - 121) / 121.f; float M2 = max_carry[stats.Str] / 100.f; float W = weapon_weight / 20000.f; - float s = 2 - weapon_speed / 10.f; + float s = (20 - weapon_speed) / 10.f; float D = (stats.Dex - 14) / 14.f; float K = 1 + M / 3.f - W / (3 * M2) + speed / 5.f + D / 2.f; - K *= (4 + level) *1.2f / (6 + level); + K *= (4 + level) * 1.2f / (6 + level); - if (K <= 0.f) + if (K <= 0.01f) K = 0.01f; float S = speed / (K * s); @@ -1382,23 +1376,8 @@ if (type != PLAYER && arch && stats.dam > arch->clone.stats.dam * 3) stats.dam = arch->clone.stats.dam * 3; - /* Prevent overflows of wc - best you can get is ABS(120) - this - * should be more than enough - remember, AC is also in 8 bits, - * so its value is the same. - */ - if (wc > 120) - wc = 120; - else if (wc < -120) - wc = -120; - - stats.wc = wc; - - if (ac > 120) - ac = 120; - else if (ac < -120) - ac = -120; - - stats.ac = ac; + stats.wc = clamp (wc, MIN_WC, MAX_WC); + stats.ac = clamp (ac, MIN_AC, MAX_AC); /* if for some reason the creature doesn't have any move type, * give them walking as a default. @@ -1588,6 +1567,7 @@ LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); return NULL; } + /* clear the flag - exp goes into this bucket, but player * still doesn't know it. */ @@ -1596,17 +1576,16 @@ skill_obj->level = 1; insert_ob_in_ob (skill_obj, op); - if (op->contr) + if (player *pl = op->contr) { - op->contr->last_skill_ob [skill_obj->subtype] = skill_obj; - if (op->contr->ns) - op->contr->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous + pl->last_skill_ob [skill_obj->subtype] = skill_obj; + if (pl->ns) + pl->ns->last_skill_exp[skill_obj->subtype] = -1;//TODO: should be made superfluous } return skill_obj; } - /* player_lvl_adj() - for the new exp system. we are concerned with * whether the player gets more hp, sp and new levels. * Note this this function should only be called for players. Monstes @@ -1626,7 +1605,7 @@ { op->level++; - if (op != NULL && op == who && op->stats.exp > 1 && is_dragon_pl (who)) + if (op && op == who && op->stats.exp > 1 && is_dragon_pl (who)) dragon_level_gain (who); /* Only roll these if it is the player (who) that gained the level */ @@ -1644,20 +1623,24 @@ sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); else sprintf (buf, "You are now level %d.", op->level); + if (who) new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); } + player_lvl_adj (who, op); /* To increase more levels */ } else if (op->level > 1 && op->stats.exp < level_exp (op->level, who->expmul)) { op->level--; who->update_stats (); + if (op->type != PLAYER) { sprintf (buf, "You are now level %d in the %s skill.", op->level, &op->name); new_draw_info (NDI_UNIQUE | NDI_RED, 0, who, buf); } + player_lvl_adj (who, op); /* To decrease more levels */ } @@ -1978,6 +1961,7 @@ 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));