OnTrapHit - ObjectReference

From the CreationKit Wiki
Jump to navigation Jump to search

Member of: ObjectReference Script

Event called when the object reference is a trap and has hit a live target. This event is sent every so often as long as a trap object is in contact with a live target.

Syntax[edit | edit source]

Event OnTrapHit(ObjectReference akTarget, float afXVel, float afYVel, float afZVel, float afXPos, float afYPos, \
    float afZPos, int aeMaterial, bool abInitialHit, int aeMotionType)

Parameters[edit | edit source]

  • akTarget: The ObjectReference that this reference just hit.
  • afXVel: The X velocity for our reference when it hit.
  • afYVel: The Y velocity for our reference when it hit.
  • afZVel: The Z velocity for our reference when it hit.
  • afXPos: The X position of our reference when it hit.
  • afYPos: The Y position of our reference when it hit.
  • afZPos: The Z position of our reference when it hit.
  • aeMaterial: Opaque integer value denoting what material the trap is. Not intended to be meaningful to script, just to be passed to other native functions that may use it.
  • abInitialHit: True if this is the first time the trap has hit the target.
  • aeMotionType: The motion type for the trap.
    • Note: Currently there are several read-only properties in the ObjectReference source file that match this, but it will later be changed to an enum and the possible list of values reduced to something more meaningful.

Examples[edit | edit source]

Event OnTrapHit(ObjectReference akTarget, float afXVel, float afYVel, float afZVel, float afXPos, float afYPos, \
  float afZPos, int aeMaterial, bool abInitialHit, int aeMotionType)
  ; Pass it on to the game trap system with a bit of damage
  akTarget.ProcessTrapHit(self, 10.0, 0.0, afXVel, afYVel, afZVel, afXPos, afYPos, afZPos, aeMaterial, 0.0)
EndEvent

Notes[edit | edit source]

This event can be sent quite rapidly, so be careful how you use it so you don't overstress the script system.

See Also[edit | edit source]