--- deliantra/server/server/spell_attack.C 2008/09/29 10:20:49 1.65 +++ deliantra/server/server/spell_attack.C 2008/12/21 20:35:37 1.70 @@ -167,8 +167,7 @@ if (--op->duration < 0) { - op->destroy_inv (true); // be explicit about dropping - op->destroy (true); + op->drop_and_destroy (); return; } @@ -310,8 +309,7 @@ mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy_inv (true); // be explicit about dropping - tmp->destroy (true); + tmp->drop_and_destroy (); return 0; } @@ -321,8 +319,7 @@ { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy_inv (true); // be explicit about dropping - tmp->destroy (true); + tmp->drop_and_destroy (); return 0; } @@ -356,7 +353,7 @@ if (--op->duration < 0) { - op->destroy (true); + op->destroy (); return; } @@ -401,7 +398,7 @@ if (!op->other_arch) { LOG (llevError, "BUG: explode_bullet(): op without other_arch\n"); - op->destroy (true); + op->destroy (); return; } @@ -412,7 +409,7 @@ if (!env->map || out_of_map (env->map, env->x, env->y)) { LOG (llevError, "BUG: explode_bullet(): env out of map\n"); - op->destroy (true); + op->destroy (); return; } @@ -421,7 +418,7 @@ else if (out_of_map (op->map, op->x, op->y)) { LOG (llevError, "BUG: explode_bullet(): op out of map\n"); - op->destroy (true); + op->destroy (); return; } @@ -430,7 +427,7 @@ // bad at the moment that might happen from this. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - op->destroy (true); + op->destroy (); return; } @@ -455,7 +452,7 @@ && owner && !tailor_god_spell (tmp, owner)) { - op->destroy (true); + op->destroy (); return; } @@ -493,7 +490,7 @@ tmp->play_sound (tmp->sound); /* remove the firebullet */ - op->destroy (true); + op->destroy (); } /* checks to see what op should do, given the space it is on @@ -534,7 +531,7 @@ { if (!QUERY_FLAG (op, FLAG_REMOVED)) { - op->destroy (true); + op->destroy (); return; } } @@ -573,7 +570,7 @@ if (op->other_arch) explode_bullet (op); else - op->destroy (true); + op->destroy (); return; } @@ -585,7 +582,7 @@ if (mflags & P_OUT_OF_MAP) { - op->destroy (true); + op->destroy (); return; } @@ -594,7 +591,7 @@ if (op->other_arch) explode_bullet (op); else - op->destroy (true); + op->destroy (); return; } @@ -660,7 +657,7 @@ mflags = get_map_flags (tmp->map, &newmap, tmp->x, tmp->y, &tmp->x, &tmp->y); if (mflags & P_OUT_OF_MAP) { - tmp->destroy (true); + tmp->destroy (); return 0; } @@ -670,7 +667,7 @@ { if (!QUERY_FLAG (tmp, FLAG_REFLECTING)) { - tmp->destroy (true); + tmp->destroy (); return 0; } @@ -735,26 +732,31 @@ /* If no owner left, the spell dies out. */ if (op->owner == NULL) { - op->destroy (true); + op->destroy (); return; } #endif hit_map (op, 0, op->attacktype, 0); + if (!op->is_on_map ()) + return; + /* Check to see if we should push anything. * Spell objects with weight push whatever they encounter to some * degree. */ if (op->weight) - check_spell_knockback (op); + { + check_spell_knockback (op); - if (op->destroyed ()) - return; + if (!op->is_on_map ()) + return; + } if (op->duration-- < 0) { - op->destroy (true); + op->destroy (); return; } /* Object has hit maximum range, so don't have it move @@ -963,7 +965,7 @@ // as bombs can be carried. if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) { - op->destroy (true); + op->destroy (); return; } @@ -1008,10 +1010,18 @@ maptile *m; mflags = get_map_flags (op->map, &m, dx, dy, &dx, &dy); - if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) + + // when creating a bomb below ourself it should always work, even + // when movement is blocked (somehow we got here, somehow we are here, + // so we should also be able to make a bomb here). (originally added + // to fix create bomb traps in doors, which cast with dir=0). + if (dir) { - new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); - return 0; + if ((mflags & P_OUT_OF_MAP) || (GET_MAP_MOVE_BLOCK (m, dx, dy) & MOVE_WALK)) + { + new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); + return 0; + } } tmp = arch_to_object (spell->other_arch); @@ -1155,7 +1165,7 @@ { new_draw_info_format (NDI_UNIQUE, 0, op, "The %s looks stronger!", query_name (target)); target->stats.hp = target->stats.maxhp * 2; - effect->destroy (true); + effect->destroy (); return 0; } } @@ -1188,8 +1198,7 @@ { if (op->range-- <= 0) { - op->destroy_inv (true); // be explicit about dropping - op->destroy (true); + op->drop_and_destroy (); return; } @@ -1198,7 +1207,7 @@ if (!pos.normalise ()) { - op->destroy (true); + op->destroy (); return; } @@ -1210,13 +1219,13 @@ /* Basically, missile only hits one thing then goes away. * we need to remove it if someone hasn't already done so. */ - op->destroy (true); + op->destroy (); return; } if (!op->direction) { - op->destroy (true); + op->destroy (); return; } @@ -1251,10 +1260,7 @@ tmp->speed = 0.01; tmp->stats.food = time; SET_FLAG (tmp, FLAG_IS_USED_UP); - tmp->glow_radius = radius; - if (tmp->glow_radius > MAX_LIGHT_RADII) - tmp->glow_radius = MAX_LIGHT_RADII; - + tmp->glow_radius = min (MAX_LIGHT_RADIUS, radius); tmp = insert_ob_in_ob (tmp, op); if (tmp->glow_radius > op->glow_radius) @@ -1743,14 +1749,13 @@ if (!owner) // MUST not happen, remove when true TODO { LOG (llevError, "swarm spell found outside inventory: %s\n", op->debug_desc ()); - op->destroy (true); + op->destroy (); return; } if (!op->duration || !owner->is_on_map ()) { - op->destroy_inv (true); // be explicit about dropping - op->destroy (true); + op->drop_and_destroy (); return; } @@ -1892,43 +1897,40 @@ dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); - if (!dir) + if (dir) { - new_draw_info (NDI_UNIQUE, 0, op, "In what direction?"); - return 0; - } - - x = op->x + freearr_x[dir]; - y = op->y + freearr_y[dir]; - m = op->map; + x = op->x + freearr_x[dir]; + y = op->y + freearr_y[dir]; + m = op->map; - mflags = get_map_flags (m, &m, x, y, &x, &y); + mflags = get_map_flags (m, &m, x, y, &x, &y); - if (mflags & P_OUT_OF_MAP) - { - new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); - return 0; - } + if (mflags & P_OUT_OF_MAP) + { + new_draw_info (NDI_UNIQUE, 0, op, "Nothing is there."); + return 0; + } - if (mflags & P_IS_ALIVE && spell->attacktype) - { - for (target = GET_MAP_OB (m, x, y); target; target = target->above) - if (QUERY_FLAG (target, FLAG_MONSTER)) - { - /* oky doky. got a target monster. Lets make a blinding attack */ - if (target->head) - target = target->head; + if (mflags & P_IS_ALIVE && spell->attacktype) + { + for (target = GET_MAP_OB (m, x, y); target; target = target->above) + if (QUERY_FLAG (target, FLAG_MONSTER)) + { + /* oky doky. got a target monster. Lets make a blinding attack */ + if (target->head) + target = target->head; - hit_player (target, dam, op, spell->attacktype, 1); - return 1; /* one success only! */ - } - } + hit_player (target, dam, op, spell->attacktype, 1); + return 1; /* one success only! */ + } + } - /* no live target, perhaps a wall is in the way? */ - if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) - { - new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); - return 0; + /* no live target, perhaps a wall is in the way? */ + if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, x, y))) + { + new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); + return 0; + } } /* ok, looks groovy to just insert a new light on the map */ @@ -1938,15 +1940,17 @@ LOG (llevError, "Error: spell arch for cast_light() missing.\n"); return 0; } + tmp->stats.food = spell->duration + SP_level_duration_adjust (caster, spell); + if (tmp->glow_radius) - { - tmp->glow_radius = spell->range + SP_level_range_adjust (caster, spell); - if (tmp->glow_radius > MAX_LIGHT_RADII) - tmp->glow_radius = MAX_LIGHT_RADII; - } + tmp->glow_radius = min (MAX_LIGHT_RADIUS, spell->range + SP_level_range_adjust (caster, spell)); + + if (dir) + m->insert (tmp, x, y, op); + else + caster->outer_env ()->insert (tmp); - m->insert (tmp, x, y, op); return 1; } @@ -2063,12 +2067,12 @@ { new_draw_info_format (NDI_UNIQUE, 0, op, "You inflict %s on %s!", &disease->name, &walk->name); - disease->destroy (true); /* don't need this one anymore */ + disease->destroy (); /* don't need this one anymore */ walk->map->insert (get_archetype ("detect_magic"), x, y, op); return 1; } - disease->destroy (true); + disease->destroy (); } } /* if living creature */ } /* for range of spaces */