Difference between revisions of "GetCombatState - Actor"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Jlundin
(Created page with 'Category:Scripting Category:Papyrus '''Member of:''' Actor Script Gets the actor's current combat state. == Syntax == <source lang="papyrus"> int Function GetCombat…')
 
imported>Enai Siaion
(Added combat state bug)
 
(One intermediate revision by one other user not shown)
Line 25: Line 25:
   Debug.Trace("Careful! That filthy pirate is looking around...")
   Debug.Trace("Careful! That filthy pirate is looking around...")
endIf
endIf
</source>
<source lang="papyrus">
;Is the player in combat?
If ( Game.GetPlayer().GetCombatState() == 0 ) ;State is 0, so player is peaceful
  Debug.Notification("Player is not in combat")
Else ;State is not 0, so player is not peaceful
  Debug.Notification("Player is in combat")
EndIf
</source>
== Bug ==
This function is unreliable the first time it is called after a certain amount of time has passed. You should call it on an empty line first before calling it for real.
<source lang="papyrus">
akTarget.GetCombatState()
If akTarget.GeTcombatState() == 1
  ;do something important
EndIf
</source>
</source>


== See Also ==
== See Also ==
*[[Actor Script]]
*[[Actor Script]]

Latest revision as of 15:12, 21 December 2014

Member of: Actor Script

Gets the actor's current combat state.

Syntax[edit | edit source]

int Function GetCombatState() native

Parameters[edit | edit source]

None.

Return Value[edit | edit source]

The actor's current combat state, which is one of the following values:

  • 0: Not in combat
  • 1: In combat
  • 2: Searching

Examples[edit | edit source]

; Is the pirate searching?
if (FilthyPirate.GetCombatState() == 2) ; 2 is "search"
  Debug.Trace("Careful! That filthy pirate is looking around...")
endIf
;Is the player in combat?
If ( Game.GetPlayer().GetCombatState() == 0 ) ;State is 0, so player is peaceful
  Debug.Notification("Player is not in combat")
Else ;State is not 0, so player is not peaceful
  Debug.Notification("Player is in combat")
EndIf

Bug[edit | edit source]

This function is unreliable the first time it is called after a certain amount of time has passed. You should call it on an empty line first before calling it for real.

akTarget.GetCombatState()
If akTarget.GeTcombatState() == 1
  ;do something important
EndIf

See Also[edit | edit source]