Page 1 of 1

[Morrowind] Scripted spells on dead NPCs?

PostPosted: Wed Jun 16, 2010 2:40 pm
by Near585
just a quick question on scripting in MW.

Is it possible to have a dead NPC be affected by spells, and have this caught by the "GetSpellEffects" function? This would be useful for the mod I'm working on.

And also, would it be possible to have one "If () EndIf" statement that could catch all NPCs(or even better, all non-essential NPCs) for that GetSpellEffects function(and more than likely an OnDeath function as well)? That'd also be quite helpful.

Thanks in advance.  :VivecSmile:y

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Wed Jun 16, 2010 3:43 pm
by Jac
Dead NPCs can still have scripts running on them, but for what you're asking, I think you'd need MWSE because regular scripting requires you to specify a target in the script itself for functions like GetSpellEffects, where MWSE can cycle through all of the NPCs in a cell.

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Wed Jun 16, 2010 7:24 pm
by peachykeen
I'm not sure if spells are applied to dead NPCs, though. You'd have to check on that, but my first guess is not. Try casting a long-term AoE spell, see if any dead characters have fire around them or anything. If so, then your idea will work, if not, then the engine skips applying spells to already dead characters.

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Thu Jun 17, 2010 12:40 am
by Fliggerty
A dead NPC has no active spells.  GetSpellEffects will always return 0.  You can use MWSE to get a reference to a dead NPC, but that's about it as far as this goes.

I did manage to do something similar in my Gravedigger mod.  But I had to actually place a tiny invisible NPC at the same place as the dead NPC and use it to see if a spell has been cast in that direction.  You have to be careful about getting a bounty or setting off AI in that case though.

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Thu Jun 17, 2010 9:33 am
by Near585
Hmm... Thanks, Fliggerty. I'll need to find a work-around then I suppose, maybe the NPC one you spoke of would work... I'm not sure exactly how I'd go about setting it up, but I think I'll take a look at your Gravedigger mod, if that's what you used for it.

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Fri Jun 18, 2010 9:47 am
by peachykeen
To get around bounties, you could use a creature. To get around AI, use a peaceful creature (guards don't attack Guar, IIRC, so use settings similar to that). You can still check for spells in a critter and if you add a paralyze constant effect, they'll never move, have their own AI, give bounties or set off guard AI.

Re: [Morrowind] Scripted spells on dead NPCs?

PostPosted: Fri Jun 18, 2010 9:55 am
by Fliggerty
I got around it by using an NPC that was in AIFollow mode.  No bounties or alarms.