--- deliantra/server/server/spell_attack.C 2008/12/28 06:59:27 1.73 +++ deliantra/server/server/spell_attack.C 2008/12/28 07:48:44 1.74 @@ -1272,76 +1272,53 @@ int cast_destruction (object *op, object *caster, object *spell_ob) { - int i, j, range, mflags, friendly = 0, dam, dur; - sint16 sx, sy; - maptile *m; - object *tmp; - const char *skill; - - range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); - dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); - dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); - if (QUERY_FLAG (op, FLAG_FRIENDLY) || op->type == PLAYER) - friendly = 1; + int range = spell_ob->range + SP_level_range_adjust (caster, spell_ob); + int dam = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); + int dur = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); + + bool friendly = op->flag [FLAG_FRIENDLY] || op->is_player (); /* destruction doesn't use another spell object, so we need * update op's skill pointer so that exp is properly awarded. - * We do some shortcuts here - since this is just temporary - * and we'll reset the values back, we don't need to go through - * the full share string/free_string route. */ - skill = op->skill; + const shstr skill = op->skill; + if (caster == op) op->skill = spell_ob->skill; else if (caster->skill) op->skill = caster->skill; else - op->skill = NULL; + op->skill = 0; op->change_skill (find_skill_by_name (op, op->skill)); - for (i = -range; i <= range; i++) + unordered_mapwalk (op, -range, -range, range, range) { - for (j = -range; j <= range; j++) - { - m = op->map; - sx = op->x + i; - sy = op->y + j; - - mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); - if (mflags & P_OUT_OF_MAP) - continue; + mapspace &ms = m->at (nx, ny); - if (mflags & P_IS_ALIVE) + if (ms.flags () & P_IS_ALIVE) + for (object *tmp = ms.bot; tmp; tmp = tmp->above) + if (tmp->flag [FLAG_ALIVE] || tmp->is_player ()) { - for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) - if (QUERY_FLAG (tmp, FLAG_ALIVE) || tmp->type == PLAYER) - break; + tmp = tmp->head_ (); - if (tmp) + if ((friendly && !tmp->flag [FLAG_FRIENDLY] && !tmp->is_player ()) + || (!friendly && (tmp->flag [FLAG_FRIENDLY] || tmp->is_player ()))) { - if (tmp->head) - tmp = tmp->head; + if (spell_ob->subtype == SP_DESTRUCTION) + { + hit_player (tmp, dam, op, spell_ob->attacktype, 0); - if ((friendly && !QUERY_FLAG (tmp, FLAG_FRIENDLY) && tmp->type != PLAYER) || - (!friendly && (QUERY_FLAG (tmp, FLAG_FRIENDLY) || tmp->type == PLAYER))) + if (spell_ob->other_arch) + m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); + } + else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist [ATNR_MAGIC] != 100) { - if (spell_ob->subtype == SP_DESTRUCTION) - { - hit_player (tmp, dam, op, spell_ob->attacktype, 0); - - if (spell_ob->other_arch) - m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); - } - else if (spell_ob->subtype == SP_FAERY_FIRE && tmp->resist[ATNR_MAGIC] != 100) - { - if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) - m->insert (arch_to_object (spell_ob->other_arch), sx, sy, op); - } + if (make_object_glow (tmp, 1, dur) && spell_ob->other_arch) + m->insert (arch_to_object (spell_ob->other_arch), nx, ny, op); } } } - } } op->skill = skill;