Tes3Mod talk:GetEffect

The UESPWiki – Your source for The Elder Scrolls since 1995

 
Jump to: navigation, search

[edit] OnDeath & GetEffect Bug

I've been developing some scripts to allow limited soultrapping of NPCs like vampires, or new creatures that modders have added via custom NPC races. I noticed something odd when checking my practice npc for (OnDeath == 1) and (getEffect sEffectStuntedMagica) in the same frame - I can detect the OnDeath event, but it appears that all spell effects are cleared off the npc just prior to the death frame - so I had to use a workaround (detailed below) to determine if the actor was affected in the frame just prior to dying.

begin __halo_targetPractice

short foo
short flagLastFrame

if ( menumode == 1 )
	return
endif

stopcombat

; I'm not dead yet!
if ( ondeath == 0 )
	if ( geteffect, seffectstuntedmagicka == 1 )
		if ( foo == 0 )
			messagebox "oy! oy! oy!"
			set foo to 1
		endif

		set flagLastFrame to 1
	else
		set flagLastFrame to 0
	endif
	return
endif

; note:	I can never seem to detect the spell effect in the same frame as death, I think
; 	it's removed during the same frame & before the script is called
if ( geteffect, seffectstuntedmagicka == 1 )
	messagebox "targetpractice died, flag found"
	; npc is flagged, do some work..
	; note that this condition will never be met
elseif ( flagLastFrame == 1 )
	messagebox "targetpractice died, and was flagged last frame"
	; workaround, all spell effects cleared on death - so you can't test for effects
	; directly
else
	messagebox "targetpractice died, the end"
endif

end

--Halo112358 01:13, 12 Apr 2005 (EDT)

Sponsored Links
Personal tools