Jump to content

[Sky] OnHit event not firing


DSoS

Recommended Posts

I'm not sure what I'm doing wrong, but my onHit event is not firing at all.
 
The properties are set properly, I've triple checked this, on the 3 different trigger zones that this is attached to.
 
There is no errors in the logs for this script, I checked all 4 logs using search.
 
The script compiles properly.
 
I've tested with arrows, fireball, mace, sword, unhanded, walking into it... nothing gets it to fire.

I've checked vanilla scripts and some don't use "if akAggressor == blah whatever"
 

FYI, onHit is the last event in the script.

 Scriptname DSoSKzMultiEnableOrDisable extends ObjectReference  
{Enable or Disable items.

Choose *ONLY ONE* of the following 
ActivateObject
OnTriggerObject
OnTriggerEnterObject

Then choose *ONLY ONE* for Enable, Disable or EnableAndDisable
}

Bool Property OnActivateObject Auto
{Set this for Levers, pressrue plates, etc.}

Bool Property OnTriggerObject Auto
{Set this for Trigger Zones.}

Bool Property OnTriggerEnterObject Auto
{Set this for Trigger Zones.}

Bool Property OnTriggerLeaveObject Auto
{Set this for Trigger Zones.}

Bool Property OnHitObject Auto
{Set this for Trigger Zones.}

Bool Property EnableOnly Auto
{Use only one at a time: EnableOnly | DisableOnly | EnableAndDisable
Will Enable only one object, unless objects are attached to a parent object.}

Bool Property DisableOnly Auto
{Use only one at a time: EnableOnly | DisableOnly | EnableAndDisable
Will Disable only one object, unless objects are attached to a parent object.}

Bool Property EnableAndDisable Auto
{Use only one at a time: EnableOnly | DisableOnly | EnableAndDisable
Will Enable one object and Disable one object, unless objects are attached to a parent object. Why this way? Well, sometimes you might want to enable or disable an item again, and if it's parented you can't.}

 Bool Property ActivateOnce  = True Auto
{Cannot Activate more than once at this time!
THIS NEEDS TO BE SET TO "TRUE" ANYWAY, SHOULD BE SET TRUE BY DEFAULT!!!
Allow Onactivate only once?}

Bool Property TriggerOnce  = True Auto
{Cannot Trigger more than once at this time!
THIS NEEDS TO BE SET TO "TRUE" ANYWAY, SHOULD BE SET TRUE BY DEFAULT!!!

Allow OnTrigger only once?}

; Bool Property OnTriggerEnterOnce  = True Auto
; {Allow TriggerEnter only once?
; Since we have OnTriggerLeave set to revert all changes back to their original states, we will NOT have this as DoOnce.} 

Bool Property OnHitOnce  = True Auto
{Cannot Hit more than once at this time!
THIS NEEDS TO BE SET TO "TRUE" ANYWAY, SHOULD BE SET TRUE BY DEFAULT!!!

Allow OnHit only once? This should allow a player to use a sword, arrow, bolt or magic to trigger the event.}

ObjectReference Property EnableObject Auto
{Object to Enable}

ObjectReference Property DisableObject Auto
{Object to Disable}

int InTrigger

Auto State Waiting
	Event OnActivate(ObjectReference akTriggerRef)
		If OnActivateObject == True
			If ActivateOnce == True
				If EnableOnly == True
					EnableObject.Enable()
					BlockActivation(true)
					
				ElseIf DisableOnly == True
					DisableObject.Disable()
					BlockActivation(true)
					
				ElseIf EnableAndDisable == True
					EnableObject.Enable()
					DisableObject.Disable()
					BlockActivation(true)
				EndIf
			EndIf
		EndIf
	EndEvent
	
	Event OnTrigger(ObjectReference akTriggerRef)
		If OnTriggerObject == True
			If TriggerOnce == True
				If EnableOnly == True
					EnableObject.Enable()
					BlockActivation(true)
					
				ElseIf DisableOnly == True
					DisableObject.Disable()
					BlockActivation(true)
					
				ElseIf EnableAndDisable == True
					EnableObject.Enable()
					DisableObject.Disable()
					BlockActivation(true)
				EndIf
			Else
				;Do Nothing for now
			EndIf
		EndIf
	EndEvent

	Event OnTriggerEnter(ObjectReference akTriggerRef)
		If OnTriggerEnterObject == True
			if (InTrigger == 0)
				if akTriggerRef == Game.GetPlayer()
					InTrigger += 1
					debug.notification("Player Entered Trigger")
					If EnableOnly == True
						EnableObject.Enable()
					
					ElseIf DisableOnly == True
						DisableObject.Disable()
						
					ElseIf EnableAndDisable == True
						EnableObject.Enable()
						DisableObject.Disable()
					EndIf
				endif
			endif
		EndIf
	EndEvent

	Event OnTriggerLeave(ObjectReference akTriggerRef)
		if OnTriggerLeaveObject == True
			if (InTrigger > 0)
				if akTriggerRef == Game.GetPlayer()
					InTrigger -= 1
					debug.notification("Player Left Trigger")
					If EnableOnly == True
						EnableObject.Disable()
						
					ElseIf DisableOnly == True
						DisableObject.Enable()
						
					ElseIf EnableAndDisable == True
						EnableObject.Disable()
						DisableObject.Enable()
					EndIf
				endif
			endif
		
		; Elseif OnTriggerEnterAndLeaveObject == True ; How to set this up to allow OnTriggerEnter and OnTriggerLeave to work together? ; We will set everything back to the original state when the player leaves the trigger. It was was originally enabled, then disabled, it was be re-enabled.
			; if (InTrigger > 0)
				; if akTriggerRef == Game.GetPlayer()
					; InTrigger -= 1
					; debug.notification("Player Left Trigger")
					; If EnableOnly == True
						; EnableObject.Disable()
						
					; ElseIf DisableOnly == True
						; DisableObject.Enable()
						
					; ElseIf EnableAndDisable == True
						; EnableObject.Disable()
						; DisableObject.Enable()
					; EndIf
				; endif
			; endif
		EndIf
	EndEvent
	
	Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
	If OnHitObject == True
	debug.notification("OnHit is Enabled!") ; This does NOT fire. Logs show no error with this script.
		;if (akAggressor == Game.GetPlayer()) ;Tried this and didn't work either.
				If OnHitOnce == True
					If EnableOnly == True
						debug.notification("I was hit!!! Enable") ;Never shows on screen and same goes for the others below.
						EnableObject.Enable()
						;BlockActivation(true)
					
					ElseIf DisableOnly == True
						debug.notification("I was hit!!! Disable")
						DisableObject.Disable()
						;BlockActivation(true)
						
					ElseIf EnableAndDisable == True
						debug.notification("I was hit!!! Enable and Disable")
						EnableObject.Enable()
						DisableObject.Disable()
						;BlockActivation(true)
					EndIf
				;Else
					;Do Nothing for now.
				EndIf
			EndIf	
		;EndIf
	EndEvent
	
EndState
 

I'm at a loss on why it's not doing anything.

OnActivate, OnTrigger, OnTriggerEnter and OnTriggerLeave all work properly.

Link to comment
Share on other sites

Disregard

 

Iif this script is set on a Triggerzone, you have to set the collision layer as L_ProjectileZone for some reason, however setting the collision layer to that doesn't work with blades.

 

I can attach the script to, say a Haybale, and arrows, spells and blades work that way, since the object is detecting the hit.

 

Just weird :shrug:

Link to comment
Share on other sites

Who's the akAggressor? Are you working with traps? You'll be wanting OnTrapHitStartOnTrapHitStop and OnTrapHit.

 

Usually wiht onHit, it doesn't require akAggressor to be set to anything specific, only in certain circumstances.

 

No, no traps, just arrows or magic spells.

 

Anywho, I got it working the way I wanted to as described above. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...