Help On a Script

Post » Tue Jan 01, 2013 8:38 am

is it possible to get how much damage done to an actor by adding a script to the target actor using an OnHit Event ?
let me show you what i want to do and if you can please show me how to type the right codes.

Spoiler
Scriptname GetDamage extends ActorEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)Actor PlayerPlayer = Game.GetPlayer()    If akAggressor == Player	Debug.Notification(Over Here Need To add code in order to print how much damage done)    EndIfEndEvent
User avatar
Benji
 
Posts: 3447
Joined: Tue May 15, 2007 11:58 pm

Post » Tue Jan 01, 2013 4:16 pm

You'd need to get the damage values from weapons in order to achieve what you want. I'm not sure of such a function exists, even with SKSE.

Or...use ints like...

int HealthBeforeHitint HealthAfterHit

...then caculate the health lost in between as int, and this is the value of damage you've done to an actor.
User avatar
Chelsea Head
 
Posts: 3433
Joined: Thu Mar 08, 2007 6:38 am

Post » Tue Jan 01, 2013 3:18 pm

I did use this before

Spoiler
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)Actor PlayerInt iHealth = GetAv("Health")Player = Game.GetPlayer()    If akAggressor == Player	Debug.Notification(iHealth)    EndIfEndEvent

it shows the health, but i don't know the code for getting the base actor value of health before hit in order to do this:
Int iBaseHealth = ; what code i need here to get actor base health before hit ?
Int iHealth = GetAv("Health") ; this will get new actor health after hit
Int iDamage = iBaseHealth - iHealth

in this case I can use this : Debug.Notification("iDamage")

User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Tue Jan 01, 2013 8:50 am

Hang on, there are old threads that deal with some very similar challenges.

http://www.gamesas.com/topic/1431539-possible-to-detect-if-player-is-charging-up-custom-spell/. http://www.gamesas.com/topic/1423288-detect-when-a-spell-is-charged-and-ready-to-fire/.
User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Tue Jan 01, 2013 2:43 pm

ok, on first hit calculation is done right, but on the second hit something is wrong.
can you tell me please how to fix it ?
here is my script

Spoiler
Scriptname GP_GetDamage extends Actor  Int iHitFunction PrintDamage()Int iBaseHealth = GetBaseAV("Health") As IntInt iHealth = GetAV("Health") As IntInt iDamage Int iHealthLeft 	If	iHealth > 0		If iHit == 1			iDamage = iBaseHealth - iHealth			Debug.Notification(iBaseHealth + " Base Health")			Debug.Notification(iDamage + " Damage")			Debug.Notification(iHealth + " Health Left")			iHealthLeft = iBaseHealth - iDamage			Debug.Notification(iHealthLeft + " Health Left")			ElseIf iHit == 2			iDamage = iHealthLeft - iHealth			Debug.Notification(iDamage + " Damage")			Debug.Notification(iHealth + " Health Left")		EndIf	EndIfEndFunctionEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)iHit = iHit + 1Actor PlayerPlayer = Game.GetPlayer()    If akAggressor == Player		PrintDamage()	EndIfEndEvent
User avatar
Ells
 
Posts: 3430
Joined: Thu Aug 10, 2006 9:03 pm

Post » Tue Jan 01, 2013 7:46 am

I'd need to see the error messages given to you by Papyrus, but I recon that this...

iHit = iHit + 1 

...can't be working.
User avatar
Nauty
 
Posts: 3410
Joined: Wed Jan 24, 2007 6:58 pm

Post » Tue Jan 01, 2013 8:00 am

I'd need to see the error messages given to you by Papyrus, but I recon that this...

iHit = iHit + 1 

...can't be working.
That's the equivalent of 'iHit += 1'. Nothing wrong with it.

Hmmm... Try with floats?
Spoiler
ScriptName GP_GetDamage Extends ActorInt iHitActor Property PlayerREF AutoFunction PrintDamage()	Float fBaseHealth = GetBaseAV("Health")	Float fHealth = GetAV("Health")	Float fDamage 	Float fHealthLeft 	If fHealth		If iHit == 1			fDamage = fBaseHealth - fHealth			fHealthLeft = fBaseHealth - fDamage			Debug.Notification("Base Health:" + fBaseHealth + ", Damage:" + fDamage + ", Health:" + fHealth + ", Health Left:" + fHealthLeft)		ElseIf iHit == 2			fDamage = fHealthLeft - fHealth			Debug.Notification("Damage:" + fDamage + ", Health Left:" + fHealthLeft)		EndIf	EndIfEndFunctionEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)	iHit += 1	If akAggressor == PlayerREF		PrintDamage()	EndIfEndEvent
User avatar
Juliet
 
Posts: 3440
Joined: Fri Jun 23, 2006 12:49 pm


Return to V - Skyrim