--- deliantra/server/common/living.C 2007/04/30 04:25:29 1.45 +++ deliantra/server/common/living.C 2007/05/12 17:26:51 1.49 @@ -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 () { @@ -854,7 +852,8 @@ contr->item_power = 0; } - memcpy (body_used, body_info, sizeof (body_info)); + for (int i = NUM_BODY_LOCATIONS; i--; ) + slot[i].used = slot[i].info; slaying = 0; @@ -879,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 @@ -892,6 +891,7 @@ prot[i] = resist[i], vuln[i] = 0; else vuln[i] = -(resist[i]), prot[i] = 0; + potion_resist[i] = 0; } @@ -964,7 +964,7 @@ * because the skill shouldn't count against body positions being used * up, etc. */ - if ((QUERY_FLAG (tmp, FLAG_APPLIED) + if ((tmp->flag [FLAG_APPLIED] && tmp->type != CONTAINER && tmp->type != CLOSE_CON) || (tmp->type == SKILL @@ -972,6 +972,10 @@ { if (type == PLAYER) { + if (tmp == contr->combat_ob || tmp == contr->ranged_ob) + if (tmp != current_weapon && (tmp->type != SKILL || tmp->subtype != SK_PRAYING)) + continue; + for (i = 0; i < NUM_STATS; i++) change_attr_value (&stats, i, get_attr_value (&tmp->stats, i)); @@ -979,14 +983,14 @@ * 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) || - (tmp->type == ARMOUR) || (tmp->type == HELMET) || - (tmp->type == SHIELD) || (tmp->type == RING) || - (tmp->type == BOOTS) || (tmp->type == GLOVES) || - (tmp->type == AMULET) || (tmp->type == GIRDLE) || - (tmp->type == BRACERS) || (tmp->type == CLOAK) || - (tmp->type == DISEASE) || (tmp->type == FORCE) || - (tmp->type == SKILL)) + if (tmp->type == WEAPON || tmp->type == BOW || + tmp->type == ARMOUR || tmp->type == HELMET || + tmp->type == SHIELD || tmp->type == RING || + tmp->type == BOOTS || tmp->type == GLOVES || + tmp->type == AMULET || tmp->type == GIRDLE || + tmp->type == BRACERS || tmp->type == CLOAK || + tmp->type == DISEASE || tmp->type == FORCE || + tmp->type == SKILL) { contr->digestion += tmp->stats.food; contr->gen_hp += tmp->stats.hp; @@ -996,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) { @@ -1037,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); @@ -1076,15 +1087,14 @@ switch (tmp->type) { +#if 0 case WAND: case ROD: case HORN: - if (type == PLAYER) - { - contr->ranged_skill = this; - contr->ranged_ob = tmp; - } + if (type != PLAYER || current_weapon == tmp) + chosen_skill = tmp; break; +#endif /* skills modifying the character -b.t. */ /* for all skills and skill granting objects */ @@ -1127,12 +1137,6 @@ if (settings.spell_encumbrance == TRUE && type == PLAYER) contr->encumbrance += (int) 3 *tmp->weight / 1000; - if (type == PLAYER) - { - contr->ranged_skill = this; - contr->ranged_ob = tmp; - } - break; case SKILL_TOOL: @@ -1140,12 +1144,6 @@ LOG (llevDebug, "fix_player, op %s has multiple skills applied\n", &name); chosen_skill = tmp; - - if (type == PLAYER) - { - contr->ranged_skill = this; - contr->ranged_ob = tmp; - } break; case SHIELD: @@ -1171,9 +1169,7 @@ case BOW: case WEAPON: - if (type != PLAYER - || (contr->combat_skill && contr->combat_skill->type == SKILL && (skill_flags [contr->combat_skill->subtype] & SF_NEED_BOW ) && tmp->type == BOW ) - || (contr->combat_skill && contr->combat_skill->type == SKILL && (skill_flags [contr->combat_skill->subtype] & SF_NEED_WEAPON) && tmp->type == WEAPON)) + if (type != PLAYER || current_weapon == tmp) { wc -= tmp->stats.wc + tmp->magic; @@ -1194,15 +1190,9 @@ * go. */ - current_weapon = tmp; - if (type == PLAYER) - { - contr->combat_ob = tmp; - - if (settings.spell_encumbrance) - contr->encumbrance += tmp->weight * 3 / 1000; - } + if (settings.spell_encumbrance) + contr->encumbrance += tmp->weight * 3 / 1000; } break; @@ -1838,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)