--- deliantra/server/common/living.C 2007/04/29 18:34:57 1.43 +++ deliantra/server/common/living.C 2007/05/11 19:41:05 1.48 @@ -359,7 +359,7 @@ * It is the calling functions responsibilty to check to see if the object * can be applied or not. * The main purpose of calling this function is the messages that are - * displayed - fix_player should really always be called after this when + * displayed - update_stats should really always be called after this when * removing an object - that is because it is impossible to know if some object * is the only source of an attacktype or spell attunement, so this function * will clear the bits, but the player may still have some other object @@ -400,14 +400,12 @@ */ if (nstat < 1 && i * flag < 0) nstat = 1; - else if (nstat > 20 + get_attr_value (&(op->arch->clone.stats), j)) - { - nstat = 20 + get_attr_value (&(op->arch->clone.stats), j); - } + else if (nstat > 20 + get_attr_value (&op->arch->clone.stats, j)) + nstat = 20 + get_attr_value (&op->arch->clone.stats, j); if (nstat != ostat) { - set_attr_value (&(op->contr->orig_stats), j, nstat); + set_attr_value (&op->contr->orig_stats, j, nstat); potion_max = 0; } else if (i) @@ -422,9 +420,9 @@ * recalculates this anyway. */ for (j = 0; j < NUM_STATS; j++) - change_attr_value (&(op->stats), j, flag * get_attr_value (&(tmp->stats), j)); + change_attr_value (&op->stats, j, flag * get_attr_value (&tmp->stats, j)); - check_stat_bounds (&(op->stats)); + check_stat_bounds (&op->stats); } /* end of potion handling code */ } @@ -433,18 +431,18 @@ */ if (flag == -1) { - op->attacktype &= ~tmp->attacktype; - op->path_attuned &= ~tmp->path_attuned; + op->attacktype &= ~tmp->attacktype; + op->path_attuned &= ~tmp->path_attuned; op->path_repelled &= ~tmp->path_repelled; - op->path_denied &= ~tmp->path_denied; + op->path_denied &= ~tmp->path_denied; /* Presuming here that creatures only have move_type, * and not the other move_ fields. */ - op->move_type &= ~tmp->move_type; + op->move_type &= ~tmp->move_type; } /* call fix_player since op object could have whatever attribute due - * to multiple items. if fix_player always has to be called after + * to multiple items. if fix_player always has to be called after * change_ability then might as well call it from here */ op->update_stats (); @@ -502,6 +500,7 @@ DIFF_MSG (flag, "You soar into the air air!.", (op->move_type & MOVE_FLY_LOW ? "You fly lower in the air" : "You float down to the ground.")); } + if (tmp->move_type & MOVE_SWIM) DIFF_MSG (flag, "You feel ready for a swim", "You no longer feel like swimming"); @@ -675,7 +674,6 @@ * Stat draining by Vick 930307 * (Feeling evil, I made it work as well now. -Frank 8) */ - void object::drain_stat () { @@ -852,18 +850,10 @@ contr->gen_grace = 0; contr->gen_sp_armour = 10; contr->item_power = 0; - - /* Don't clobber all the range_ values. range_golem otherwise - * gets reset for no good reason, and we don't want to reset - * range_magic (what spell is readied). These three below - * well get filled in based on what the player has equipped. - */ - contr->ranges[range_bow] = 0; - contr->ranges[range_misc] = 0; - contr->ranges[range_skill] = 0; } - memcpy (body_used, body_info, sizeof (body_info)); + for (int i = NUM_BODY_LOCATIONS; i--; ) + slot[i].used = slot[i].info; slaying = 0; @@ -888,7 +878,7 @@ glow_radius = arch->clone.glow_radius; move_type = arch->clone.move_type; - chosen_skill = NULL; + chosen_skill = 0; /* initializing resistances from the values in player/monster's * archetype clone @@ -901,6 +891,7 @@ prot[i] = resist[i], vuln[i] = 0; else vuln[i] = -(resist[i]), prot[i] = 0; + potion_resist[i] = 0; } @@ -981,11 +972,9 @@ { if (type == PLAYER) { - if (tmp->type == BOW) - contr->ranges[range_bow] = tmp; - - if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) - contr->ranges[range_misc] = tmp; + if ((tmp->type == WEAPON || tmp->type == BOW) + && tmp != current_weapon) + continue; for (i = 0; i < NUM_STATS; i++) change_attr_value (&stats, i, get_attr_value (&tmp->stats, i)); @@ -1011,11 +1000,16 @@ contr->item_power += tmp->item_power; } } /* if this is a player */ + else + { + if (tmp->type == WEAPON) + current_weapon = tmp; + } /* Update slots used for items */ if (QUERY_FLAG (tmp, FLAG_APPLIED)) for (i = 0; i < NUM_BODY_LOCATIONS; i++) - body_used[i] += tmp->body_info[i]; + slot[i].used += tmp->slot[i].info; if (tmp->type == SYMPTOM) { @@ -1052,14 +1046,16 @@ } /* There may be other things that should not adjust the attacktype */ - if (tmp->type != BOW && tmp->type != SYMPTOM) - attacktype |= tmp->attacktype; - - path_attuned |= tmp->path_attuned; - path_repelled |= tmp->path_repelled; - path_denied |= tmp->path_denied; - move_type |= tmp->move_type; - stats.luck += tmp->stats.luck; + if ((tmp->type != WEAPON && tmp->type != BOW && tmp->type != SYMPTOM) + || current_weapon == tmp) + { + attacktype |= tmp->attacktype; + path_attuned |= tmp->path_attuned; + path_repelled |= tmp->path_repelled; + path_denied |= tmp->path_denied; + move_type |= tmp->move_type; + stats.luck += tmp->stats.luck; + } if (QUERY_FLAG (tmp, FLAG_LIFESAVE )) SET_FLAG (this, FLAG_LIFESAVE); if (QUERY_FLAG (tmp, FLAG_REFL_SPELL )) SET_FLAG (this, FLAG_REFL_SPELL); @@ -1083,7 +1079,7 @@ if (tmp->stats.exp > 0) { added_speed += tmp->stats.exp / 3.f; - bonus_speed += 1.f + tmp->stats.exp / 3.f; + bonus_speed += tmp->stats.exp / 3.f + 1.f; } else added_speed += tmp->stats.exp; @@ -1091,6 +1087,15 @@ switch (tmp->type) { +#if 0 + case WAND: + case ROD: + case HORN: + if (type != PLAYER || current_weapon == tmp) + chosen_skill = tmp; + break; +#endif + /* skills modifying the character -b.t. */ /* for all skills and skill granting objects */ case SKILL: @@ -1121,20 +1126,17 @@ } if (tmp->stats.wc) - wc -= (tmp->stats.wc + tmp->magic); + wc -= tmp->stats.wc + tmp->magic; if (tmp->slaying) slaying = tmp->slaying; if (tmp->stats.ac) - ac -= (tmp->stats.ac + tmp->magic); + ac -= tmp->stats.ac + tmp->magic; if (settings.spell_encumbrance == TRUE && type == PLAYER) contr->encumbrance += (int) 3 *tmp->weight / 1000; - if (type == PLAYER) - contr->ranges[range_skill] = this; - break; case SKILL_TOOL: @@ -1142,9 +1144,6 @@ LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); chosen_skill = tmp; - - if (type == PLAYER) - contr->ranges[range_skill] = this; break; case SHIELD: @@ -1168,29 +1167,33 @@ break; + case BOW: case WEAPON: - wc -= tmp->stats.wc + tmp->magic; + if (type != PLAYER || current_weapon == tmp) + { + wc -= tmp->stats.wc + tmp->magic; - if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) - ac -= tmp->stats.ac + tmp->magic; + if (tmp->stats.ac && tmp->stats.ac + tmp->magic > 0) + ac -= tmp->stats.ac + tmp->magic; - stats.dam += tmp->stats.dam + tmp->magic; - weapon_weight = tmp->weight; - weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; - - if (weapon_speed < 0) - weapon_speed = 0; - - slaying = tmp->slaying; - - /* If there is desire that two handed weapons should do - * extra strength damage, this is where the code should - * go. - */ + stats.dam += tmp->stats.dam + tmp->magic; + weapon_weight = tmp->weight; + weapon_speed = (WEAPON_SPEED (tmp) * 2 - tmp->magic) / 2; - current_weapon = tmp; - if (type == PLAYER && settings.spell_encumbrance) - contr->encumbrance += tmp->weight * 3 / 1000; + if (weapon_speed < 0) + weapon_speed = 0; + + slaying = tmp->slaying; + + /* If there is desire that two handed weapons should do + * extra strength damage, this is where the code should + * go. + */ + + if (type == PLAYER) + if (settings.spell_encumbrance) + contr->encumbrance += tmp->weight * 3 / 1000; + } break; @@ -1825,11 +1828,11 @@ /* prevents some forms of abuse. */ if (op->contr->braced) - exp = exp / 5; + exp /= 5; /* Try to find the matching skill. * We do a shortcut/time saving mechanism first - see if it matches - * chosen_skill. This means we don't need to search through + * chosen_skill. This means we don't need to search through * the players inventory. */ if (skill_name)