--- deliantra/server/common/living.C 2008/05/06 17:31:21 1.87 +++ deliantra/server/common/living.C 2009/08/28 22:19:38 1.97 @@ -860,10 +860,7 @@ if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->type == POTION) continue; - /* See note in map.c:update_position about making this additive - * since light sources are never applied, need to put check here. - */ - glow_radius = max (glow_radius, tmp->glow_radius); + glow_radius += tmp->glow_radius; /* For some things, we don't care what is equipped */ if (tmp->type == SKILL) @@ -1139,10 +1136,10 @@ } if (tmp->stats.wc) - wc -= (tmp->stats.wc + tmp->magic); + wc -= tmp->stats.wc + tmp->magic; if (tmp->stats.ac) - ac -= (tmp->stats.ac + tmp->magic); + ac -= tmp->stats.ac + tmp->magic; if (ARMOUR_SPEED (tmp)) max_speed = min (max_speed, ARMOUR_SPEED (tmp) / 10.f); @@ -1152,6 +1149,8 @@ } /* item is equipped */ } /* for loop of items */ + glow_radius = min (glow_radius, MAX_LIGHT_RADIUS); + /* We've gone through all the objects the player has equipped. For many things, we * have generated intermediate values which we now need to assign. */ @@ -1330,9 +1329,6 @@ if (settings.search_items && contr->search_str[0]) speed -= 1; - - if (attacktype == 0) - attacktype = arch->attacktype; } /* End if player */ if (added_speed >= 0) @@ -1421,6 +1417,22 @@ map->at (x, y).flags_ = 0; } +void +object::set_glow_radius (sint8 rad) +{ + glow_radius = rad; + + if (is_on_map ()) + update_all_los (map, x, y); + else if (object *env = outer_env ()) + { + env->update_stats (); + + if (env->is_on_map ()) + update_all_los (env->map, env->x, env->y); + } +} + /* * Returns true if the given player is a legal class. * The function to add and remove class-bonuses to the stats doesn't @@ -1444,11 +1456,6 @@ * set the new dragon name after gaining levels or * changing ability focus (later this can be extended to * eventually change the player's face and animation) - * - * Note that the title is written to 'own_title' in the - * player struct. This should be changed to 'ext_title' - * as soon as clients support this! - * Please, anyone, write support for 'ext_title'. */ void set_dragon_name (object *pl, const object *abil, const object *skin) @@ -1476,29 +1483,17 @@ if (atnr_is_dragon_enabled (abil->stats.exp) && abil->resist[abil->stats.exp] >= level) atnr = abil->stats.exp; - level = (int) (level / 25.); - /* now set the new title */ - if (pl->contr) + if (level < 25) sprintf (pl->contr->title, "%s hatchling", attacks[atnr]); + else if (level < 50) sprintf (pl->contr->title, "%s wyrm" , attacks[atnr]); + else if (level < 75) sprintf (pl->contr->title, "%s wyvern" , attacks[atnr]); + else if (level < 100) sprintf (pl->contr->title, "%s dragon" , attacks[atnr]); + else { - if (level == 0) - sprintf (pl->contr->title, "%s hatchling", attacks[atnr]); - else if (level == 1) - sprintf (pl->contr->title, "%s wyrm", attacks[atnr]); - else if (level == 2) - sprintf (pl->contr->title, "%s wyvern", attacks[atnr]); - else if (level == 3) - sprintf (pl->contr->title, "%s dragon", attacks[atnr]); - else - { - /* special titles for extra high resistance! */ - if (skin->resist[atnr] > 80) - sprintf (pl->contr->title, "legendary %s dragon", attacks[atnr]); - else if (skin->resist[atnr] > 50) - sprintf (pl->contr->title, "ancient %s dragon", attacks[atnr]); - else - sprintf (pl->contr->title, "big %s dragon", attacks[atnr]); - } + /* special titles for extra high resistance! */ + if (skin->resist[atnr] > 80) sprintf (pl->contr->title, "legendary %s dragon", attacks[atnr]); + else if (skin->resist[atnr] > 50) sprintf (pl->contr->title, "ancient %s dragon" , attacks[atnr]); + else sprintf (pl->contr->title, "big %s dragon" , attacks[atnr]); } strcpy (pl->contr->own_title, ""); @@ -1575,7 +1570,7 @@ skill_obj = get_archetype_by_skill_name (skill_name, SKILL); if (!skill_obj) { - LOG (llevError, "add_player_exp: couldn't find skill %s\n", skill_name); + LOG (llevError, "give_skill_by_name: couldn't find skill %s\n", skill_name); return NULL; } @@ -1585,14 +1580,10 @@ CLEAR_FLAG (skill_obj, FLAG_CAN_USE_SKILL); skill_obj->stats.exp = 0; skill_obj->level = 1; - insert_ob_in_ob (skill_obj, op); + op->insert (skill_obj); if (player *pl = op->contr) - { - 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 - } + pl->link_skills (); return skill_obj; } @@ -1721,7 +1712,7 @@ static void add_player_exp (object *op, sint64 exp, const char *skill_name, int flag) { - object *skill_obj = NULL; + object *skill_obj; sint64 limit, exp_to_add; int i; @@ -1734,29 +1725,22 @@ * chosen_skill. This means we don't need to search through * the players inventory. */ + skill_obj = 0; + if (skill_name) { - if (op->chosen_skill && op->chosen_skill->type == SKILL && !strcmp (skill_name, op->chosen_skill->skill)) - skill_obj = op->chosen_skill; - else + skill_obj = op->contr->find_skill (skill_name); + + /* Player doesn't have the skill. Check to see what to do, and give + * it to the player if necessary + */ + if (!skill_obj) { - for (i = 0; i < NUM_SKILLS; i++) - if (op->contr->last_skill_ob[i] && !strcmp (op->contr->last_skill_ob[i]->skill, skill_name)) - { - skill_obj = op->contr->last_skill_ob[i]; - break; - } + if (flag == SK_EXP_NONE) + return; - /* Player doesn't have the skill. Check to see what to do, and give - * it to the player if necessary - */ - if (!skill_obj) - { - if (flag == SK_EXP_NONE) - return; - else if (flag == SK_EXP_ADD_SKILL) - give_skill_by_name (op, skill_name); - } + if (flag == SK_EXP_ADD_SKILL) + skill_obj = give_skill_by_name (op, skill_name); } } @@ -1799,7 +1783,7 @@ } /* This function checks to make sure that object 'op' can - * lost 'exp' experience. It returns the amount of exp + * lose 'exp' experience. It returns the amount of exp * object 'op' can in fact lose - it basically makes * adjustments based on permanent exp and the like. * This function should always be used for losing experience - @@ -1813,14 +1797,18 @@ if (exp > op->stats.exp) exp = op->stats.exp; + if (settings.permanent_exp_ratio) { del_exp = (sint64) ((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; } + return exp; } @@ -1830,10 +1818,9 @@ if (exp < 0) return check_exp_loss (op, exp); else - return MIN (exp, (sint64) MAX_EXPERIENCE - op->stats.exp); + return min (exp, (sint64)MAX_EXPERIENCE - op->stats.exp); } - /* Subtracts experience from player. * if skill is set and flag == SK_SUBTRACT_SKILL_EXP, then we * only subtract from the matching skill. Otherwise, @@ -1856,7 +1843,7 @@ for (tmp = op->inv; tmp; tmp = tmp->below) if (tmp->type == SKILL && tmp->stats.exp) { - if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (tmp->skill, skill)) + if (flag == SK_SUBTRACT_SKILL_EXP && skill && !strcmp (&tmp->skill, skill)) { del_exp = check_exp_loss (tmp, exp); tmp->stats.exp -= del_exp; @@ -1954,15 +1941,13 @@ void apply_death_exp_penalty (object *op) { - object *tmp; sint64 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) + for (object *tmp = op->inv; tmp; tmp = tmp->below) if (tmp->type == SKILL && tmp->stats.exp) { - percentage_loss = tmp->stats.exp * settings.death_penalty_ratio / 100; level_loss = tmp->stats.exp - levels[MAX (0, tmp->level - settings.death_penalty_level)]; @@ -1974,18 +1959,19 @@ if (level_loss < 0) level_loss = 0; - loss = check_exp_loss (tmp, MIN (level_loss, percentage_loss)); + loss = check_exp_loss (tmp, min (level_loss, percentage_loss)); tmp->stats.exp -= loss; player_lvl_adj (op, tmp); } percentage_loss = op->stats.exp * settings.death_penalty_ratio / 100; - level_loss = op->stats.exp - levels[MAX (0, op->level - settings.death_penalty_level)]; + 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)); + + loss = check_exp_loss (op, min (level_loss, percentage_loss)); op->stats.exp -= loss; player_lvl_adj (op, NULL);