ExplodeObject(object, int)

Blow up an object with the given spell.

void ExplodeObject(
    object oOrigin,
    int nSpell = SPELL_FIREBALL
);

Parameters

oOrigin

The object to slaughter.

nSpell

The SPELL_* to cast. (Default: SPELL_FIREBALL)


Description

Blow up an object with the given spell. This will actually cast the spell, causing injury to those around the object.



Remarks

oOrigin can be any valid object.

nSpell is cast, regardless of if the calling object can actually cast the spell or not. The spell is also cast immediately.

A temporary placeable is created at the location of oOrigin and used as the target location in a call to ActionCastSpellAtLocation. Once the spell is cast, the temporary placeable is destroyed.

This function is fatal to oOrigin. If oOrigin is alive, the plot flag is ignored and EffectDeath is called to cause them to die in the bloodiest, most gruesome explosion possible. If oOrigin is not alive (for example it is a placeable) then DestroyObject is called.

Known Bugs

Sadly, in the testing of the sample code below, one oOrigin PC did survive the lighting blast by making their spell resistance roll.

Requirements

#include "x0_i0_corpses"


Version

???

Example

// Kill a player who is foolish enough to use a placeable.  In this example, the placeable is a lever.
// This script goes in the placeables "OnUsed" script event.

#include "x0_i0_corpses"

void main()
{
    // Who pulled the lever.
    object oFutureCorpse = GetLastUsedBy();

    // We are only interested in exploding a player.  *evil cackles*
    if(TRUE == GetIsPC(oFutureCorpse))
    {
        // Feedback on the lever pull.
        FloatingTextStringOnCreature("*" + GetName(oFutureCorpse) + " pulls the lever.*", oFutureCorpse);

        // Shake the screen.
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SCREEN_SHAKE), oFutureCorpse);

        // Make the player talk.
        AssignCommand(oFutureCorpse, SpeakString("Oh maaaaan, that can't be good..."));

        // BOOOOM!
        ExplodeObject(oFutureCorpse, SPELL_CALL_LIGHTNING);
    } 
}

See Also

functions:  DestroyObject
constants:  SPELL_*


author: Mistress