Skip to content

Exploding Enemy

I've got an enemy that needs to explode when they take any amount of fire damage. This explosion needs to damage all creatures (friend and foe alike) but only about 1d6 or 2d6 fire damage and allow for a reflex save for half. I've managed to make enemies explode with SPELL_FIREBALL and with SPELL_GRENADE_FIRE but it usually either only damages the enemy or the PC, never the other nearby enemies. Ideally the player will lob an alchemist fire into a group of these explodey enemies and they start a chain reaction and explode the whole group. An irresponsible player and their allies might be too close though.

Right now I've got this in both the OnDamaged and OnDeath scripts. #include "x0_i0_corpses" is earlier in the script.
int hasExploded = GetLocalInt(OBJECT_SELF,"hasExploded");

    if(GetDamageDealtByType(DAMAGE_TYPE_FIRE) >= 1 && hasExploded != 1)
    {
         SendMessageToPC(GetFirstPC(),"Fire");

        ExplodeObject(OBJECT_SELF, SPELL_FIREBALL);
    }

Comments

  • ProlericProleric Member Posts: 1,316
    edited October 13
    I have this OnDeath script which results in a chain reaction:
    // Explode on death
    
    void bh_explode(int nVFX = VFX_FNF_FIREBALL)
    {
    //Goes in OnDeath for the creature
    //Script:  xph_dth_bozak
    //Author:  Jesse Williams (Xepherys)
    //Version: v0.2, 2002-06-21
    //Usage:   Caller explodes and damages nearby objects for d6 fire damage
    //Notes:   modified version of cal_explode by Albert Shih.
    //         Attempt at true representation of Bozak Draconian Death Throes
    
       DestroyObject(OBJECT_SELF);
       location lSelf = GetLocation(OBJECT_SELF);
       object oChar = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, lSelf);
       int    nDamage;
    
       ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
        EffectVisualEffect(nVFX), lSelf, 1.5f);
    
       do {
            if (oChar != OBJECT_SELF)
              if (!GetPlotFlag(oChar))
                if (!GetIsDead(oChar))
                {
                  location lChar = GetLocation(oChar);
                  nDamage = d6(1);
    
                  ApplyEffectToObject( DURATION_TYPE_INSTANT,
                                       EffectDamage(nDamage, DAMAGE_TYPE_FIRE), oChar);
    
                  ApplyEffectAtLocation(DURATION_TYPE_INSTANT,
                                       EffectVisualEffect(VFX_FNF_FIREBALL), lChar, 1.5f);
                }
          } while ((oChar = GetNextObjectInShape(SHAPE_SPHERE, 10.0, lSelf))
                   != OBJECT_INVALID);
    }
    
  • Dragonfolk2000Dragonfolk2000 Member Posts: 390
    I was able to modify this to mostly do everything I need it to. Right now, enemies caught in the chain explosions do not give xp to the player if they are killed by the explosion.
  • MelkiorMelkior Member Posts: 216
    There are some tricks with scripts, such as the awarding of XP only happening automatically if the effect which killed the enemy was run from the PC who is to get the XP. If the script which fired off the effect which killed the enemy wasn't a script running on the PC, then the PC won't get any XP unless the script has a separate way of finding the PC and awarding XP to the PC, other than by the built-in automatic method in the game.
Sign In or Register to comment.