Detecting caster on hit

Post » Fri May 13, 2011 4:13 pm

Hi, I'm working on a script that runs when someone gets hit with a restore health spell. My script runs at the right time, however getActiveEffectCodes fails to recognize the restore health effect as an active effect, which makes it impossible for me to determine the caster. If I cast restore health twice in succession, the second instance of the script does recognize the first heal if it is still active.

I'm starting to think is that this isn't going to work, especially with zero-duration spells like Convalescence.

Here's the script in question:
scn gDetectHealref targetref casterlong effectCodeint indexbegin Function { target, effectcode }	if target != PlayerRef		let index := (ar_Find effectcode target.getActiveEffectCodes)		print "=====Index of REHE: " + $index	;debug		print "=====Number of Active Effects: " + $target.getActiveEffectCount	;debug		let caster := target.getNthActiveEffectCaster index		;do stuff		print "=====$target + " was healed by " + $caster	;debug	endifend

Can this be salvaged, or is there a better way to detect the caster on hit?

edit: spelling
User avatar
Amy Gibson
 
Posts: 3540
Joined: Wed Oct 04, 2006 2:11 pm

Return to IV - Oblivion

cron