PlayerHealth: Difference between revisions

From Zandronum Wiki
(Created page with "{{Template:ACSWarning}} int '''PlayerHealth''' (void) ==Usage== Returns the amount of health the activator of the script has. Returns zero if the activator is world. This i...")
 
No edit summary
Tag: Source edit
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
int '''PlayerHealth''' (void)
int '''PlayerHealth''' (void)


==Usage==
== Usage ==
 
=== Return value ===
Returns the amount of health the activator of the script has. Returns zero if the activator is world.
Returns the amount of health the activator of the script has. Returns zero if the activator is world.


This is equivalent to '''{{ZDW|GetActorProperty}}''' (0, APROP_Health)
This function is equivalent to <code>{{Zdoomwiki|GetActorProperty}}(0, APROP_Health)</code>.
 
==Examples==


script 1 (void)
== Examples ==
{
<syntaxhighlight lang="c" line="1">
  if ([[PlayerHealth]]() > 75)
Script 1 (void)
      {{zdw|Print}}(s:"You have a lot of health!");
{
  else
    if (PlayerHealth() > 75)
      {{zdw|Print}}(s:"You might want to find a medkit!");
    {
}
        Print(s: "You have a lot of health!");
    }
    else
    {
        Print(s: "You might want to find a medkit!");
    }
}
</syntaxhighlight>


[[category:ACS Functions]]
[[category:ACS functions]]

Latest revision as of 00:33, 3 July 2022

This article documents a Zandronum-specific ACS feature which may not be supported by ZDoom and its other child ports.

int PlayerHealth (void)

Usage

Return value

Returns the amount of health the activator of the script has. Returns zero if the activator is world.

This function is equivalent to GetActorProperty(0, APROP_Health).

Examples

Script 1 (void)
{
    if (PlayerHealth() > 75)
    {
        Print(s: "You have a lot of health!");
    }
    else
    {
        Print(s: "You might want to find a medkit!");
    }
}