How to reference the victim of an attack using onHit event?

Post » Sat Jan 26, 2013 4:22 pm

Hi,

I wanted to do something that, conceptually at least, seemed simple: every time the player gets hit by a melee attack, he has to stagger.

My idea was to...
1. create a magic effect of archetype 'stagger', casting type 'fire and forget' and deliver 'self' and then
2. attach that magic effect to a spell and then
3. make a script cast the spell when the player is hit by using the onHit event.

Script would like like this:

Scriptname aaPlayerStaggerScript extends ObjectReferenceEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	   aaBCstaggerSpell.Cast(Victim)EndEventSpell Property aaBCstaggerSpell Auto

My problem is that I don't know how to reference the victim that was hit. The syntaxis of the onHit event provides information about the agressor, the type of weapon used etc but it says nothing about the victim. How can I reference the victim of the hit then? If it's not possible, is there another way to make the player stagger every time he gets hit?

Many thanks in advance.
User avatar
michael flanigan
 
Posts: 3449
Joined: Thu Jun 14, 2007 2:33 pm

Post » Sat Jan 26, 2013 8:09 am

The "victim" is whatever has the OnHit() script attached to it. Like the thing that's activated in an OnActivate() event, is the object housing that script.
User avatar
lisa nuttall
 
Posts: 3277
Joined: Tue Jun 20, 2006 1:33 pm

Post » Sat Jan 26, 2013 3:44 am

The victim in this case is "self", the object that the script is attached too. i.e
aaBCstaggerSpell.Cast(Self)
User avatar
Charlotte X
 
Posts: 3318
Joined: Thu Dec 07, 2006 2:53 am

Post » Sat Jan 26, 2013 4:30 am

Wow...'self'...Let me try that ASAP.
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am


Return to V - Skyrim