Jump to content

Script onHit reaction to spell


Toaster2a

Recommended Posts

Ok Folks, I need some help. I've been bound and determined I could work this out. But too many sleepless nights, have proven otherwise.

What I am trying to do, is similar to the second part of This Tutorial, except that I am trying to

get the event to trigger when hit with a Spell, I can make it work with an Axe, and if I take out the if statements then any hit including a spell will work, so i know that

the script runs. But I can't figure out how to write the code so that preferably only one specific custom spell will work.

 

I don't believe I mind what type of property is ultimately used, as long as it can be to a specific spell.

MagicEffect, Spell, Keyword. All my attempts have only worked with weapons.

 

 

 

Scriptname Myscript extends ReferenceAlias  

Keyword Property WeapTypeWarAxe Auto

Spell Property Firebolt  Auto  
Keyword Property MagicDamageFire  Auto  


Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
if (akAggressor == Game.GetPlayer())
	if (akSource.HasKeyword(WeapTypeWarAxe))	;This works
;		if (akSource.HasKeyword(MagicDamageFire))	;Doesn't work
;		if (akSource == Firebolt)			;Doesn't work
		Debug.Notification( "You Hit Me" )
	endif
endif
EndEvent

 

 

 

Any help in the right direction would be greatly appreciated. Thanks for your time.

Link to comment
Share on other sites

Try this. I haven't tested it.

 

Scriptname Myscript extends ReferenceAlias  

Keyword Property WeapTypeWarAxe Auto
Keyword Property MagicDamageFire  Auto  

Spell Property Firebolt  Auto  

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
If (akAggressor == Game.GetPlayer())
	If (akSource as Weapon).HasKeyword(WeapTypeWarAxe)
		Debug.Notification("[Myscript]You Hit Me with a War Axe")
	EndIf
	If (akSource as Spell).HasKeyword(MagicDamageFire)
		Debug.Notification("[Myscript]You Hit Me with MagicDefenseFire")
	EndIf
	If (akSource as Spell) == Firebolt
		Debug.Notification("[Myscript]You Hit Me with Firebolt")
	Endif
EndIf
EndEvent

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...