View Full Version : Cast Chain Lightning on Death


Ignatiuz
Tue, 3rd Feb '04, 9:20am
Hi, I was thinking of making one of my creature be able to cast chain lightning so as to cause some grief to whoever that murder it.

With my little scripting experience, I came up with this:

void main()
{
object oTarget = GetLastKiller();
ActionCastSpellAtObject(SPELL_CHAIN_LIGHTNING, oTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
}

I placed the script in the creature's onDeath.
Obviously it's not working.
Can anyone advise?

NeoXro
Tue, 3rd Feb '04, 10:25am
If your creature is dead, he can't cast spells, right? Make something else cast the spell at the killer... or use ApplyEffectToObject...

ArtEChoke
Tue, 3rd Feb '04, 3:19pm
I'm at work right now, so I can't be too specific... but I believe "ActionCastSpellAtObject" actually causes the dying critter to try to cast the spell, and as NeoXro said, if its dead, it ain't casting.

However, there is another function (looking it up now, will edit shortly.) which will trigger a spell effect without it needing to be cast (so to speak..).

EDIT: hmm I didn't come up with much, I'm not sure.. but you might be able to use ApplyEffectToObject, wish I had the toolset in front of me...

fade
Tue, 3rd Feb '04, 8:22pm
You could use the type of script that prevent certain characters from dieing before you talk to them. Have that kick in, have the creature cast chain lightning and then proceed to kill it.

NeoXro
Tue, 3rd Feb '04, 11:19pm
That would have a totally different effect... what he wants is a contingency to go off on death... I would suggest to use ApplyEffectToObject targeting every PC in the area, then use VFX_BEAM_LIGHTNING effect on everyone and apply electrical damage (include save throw possibilities if you want)

Alavin
Wed, 4th Feb '04, 7:17pm
Alternatively, use the CreateObject script to create a custom creature with no graphics on it in the OnDeath script. To define the location, use this:

location lSpawn = GetLocation(OBJECT_SELF);

then use this location to create the creature. In it's OnSpawn script, get it to cast Chain Lightning. This is a little more complicated than the other suggestions, but follows exactly what you wanted.

Ignatiuz
Sat, 7th Feb '04, 6:37am
Thanks for all the advices!
I'll go try out the solutions.
You guys rocks.