Difference between revisions of "OnActorAction - Form"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>CraftySentinel
m (Added Missing SKSE Category)
imported>Chesko
(Fixed documentation and example; akActor CAN be actors other than the player.)
 
(3 intermediate revisions by 2 users not shown)
Line 5: Line 5:
'''SKSE Member of:''' [[Form Script]]
'''SKSE Member of:''' [[Form Script]]


Listens for actor actions, for this event to be received the form must have been registered previously via [[RegisterForActorAction - Form|RegisterForActorAction]].
Listens for actor actions. For this event to be received, the form must have been registered previously via [[RegisterForActorAction - Form|RegisterForActorAction]].


== Syntax ==
=== Syntax ===
<source lang="papyrus">Event OnActorAction(int actionType, Actor akActor, Form source, int slot)</source>
<source lang="papyrus">Event OnActorAction(int actionType, Actor akActor, Form source, int slot)</source>


== Parameters ==
=== Parameters ===
*actionType - The actionType that triggered the event (See [[RegisterForActorAction - Form| RegisterForActorAction]] for a list of available action types).
*actionType - The actionType that triggered the event (See [[RegisterForActorAction - Form| RegisterForActorAction]] for a list of available action types).
*akActor - The actor that triggered the event (Always the Player).
*akActor - The actor that triggered the event.
*source - The Weapon or Spell that was used within the action.
*source - The Weapon or Spell that was used within the action.
*slot - The slot of the source item. Valid Slots:
*slot - The slot of the source item. Valid Slots:
Line 19: Line 19:
** 2 - Voice
** 2 - Voice


== Return Value ==
=== Examples ===
None
<source lang="papyrus">
Actor property PlayerRef auto


== Examples ==
<source lang="papyrus">
Event OnInit()
Event OnInit()
RegisterForActorAction(0);Register for melee swings.
RegisterForActorAction(0);Register for melee swings.
Line 29: Line 28:
   
   
Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
If !source ;Hand to Hand does not have a form of it's own so it will be none.
if akActor == PlayerRef
If !slot ;Left Hand slot
            If !source ;Hand to Hand does not have a form of its own so it will be none.
Debug.Trace("The player has swung their left fist.")
    If !slot ;Left Hand slot
Else
    Debug.Trace("The player has swung their left fist.")
Debug.Trace("The player has swung their right fist.")
    Else
EndIf
    Debug.Trace("The player has swung their right fist.")
EndIf
    EndIf
        EndIf
        Endif
EndEvent
EndEvent
</source>
</source>
== Notes ==
*This event cannot detect forms in the player's left hand when listening for Draw/Sheathe events (actionType 7-10). It will always return a value of 1 for ''slot'' (indicating the right hand), and the ''source'' will always only be whatever Form is wielded in the right hand (or NONE if there isn't something in the player's right hand).


== See Also ==
== See Also ==

Latest revision as of 19:41, 13 July 2015

SKSE Member of: Form Script

Listens for actor actions. For this event to be received, the form must have been registered previously via RegisterForActorAction.

Syntax

Event OnActorAction(int actionType, Actor akActor, Form source, int slot)

Parameters

  • actionType - The actionType that triggered the event (See RegisterForActorAction for a list of available action types).
  • akActor - The actor that triggered the event.
  • source - The Weapon or Spell that was used within the action.
  • slot - The slot of the source item. Valid Slots:
    • 0 - Left Hand
    • 1 - Right Hand
    • 2 - Voice

Examples

Actor property PlayerRef auto

Event OnInit()
	RegisterForActorAction(0);Register for melee swings.
EndEvent
 
Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
	if akActor == PlayerRef
            If !source ;Hand to Hand does not have a form of its own so it will be none.
	    	If !slot ;Left Hand slot
	    		Debug.Trace("The player has swung their left fist.")
	    	Else
	    		Debug.Trace("The player has swung their right fist.")
	    	EndIf
    	    EndIf
        Endif
EndEvent

Notes

  • This event cannot detect forms in the player's left hand when listening for Draw/Sheathe events (actionType 7-10). It will always return a value of 1 for slot (indicating the right hand), and the source will always only be whatever Form is wielded in the right hand (or NONE if there isn't something in the player's right hand).

See Also