GetHP()

From ElectronicWar

Jump to: navigation, search
Function information for getHP()
Function getHP()
Parameters None
API Attack
Cost $500
Level 25
CPU Usage 5
Description Returns a float representing the hit-points of the port performing the attack.


[edit] Basic Example

getHP() could be used in an attack script to automatically cancel your attack if the port's health falls below 50:

if(getHP()<50){
   cancelAttack();
}

Placing this in the continue event of your attack script would make it automatically cancel the attack if the port's HP falls below 50 and therefore, preventing an overheat.

[edit] Advanced Example

getHP() could also be used in a calculation to compare your port's HP to the target's port HP and decide whether or not to continue the attack:

if(getHP()<30 && getTargetHP()>30){
   cancelAttack();
   message(getSourceIP(),"Attack was cancelled: Your port HP fell quicker than the Target port.");
}

Placing this in the continue event of an attack script would automatically cancel the attack if your port's HP falls below 30 and the target's port is still above 30.

Personal tools