GetTargetHP()

From ElectronicWar

Jump to: navigation, search
Function information for getTargetHP()
Function getTargetHP()
Parameters None
API Attack
Cost $1500
Level 25
CPU Usage 3
Description Returns a float representing the remaining hit-points of the port being targeted with the attack.


[edit] Basic Example

getTargetHP() could be used in an attack script to tell you when the target's port HP falls below 50:

if(getTargetHP()<50){
   message(getSourceIP(),"Target port now has less than 50 HP remaining.");
}

Placing this in the continue event of an attack script would send a message to back to you telling you when their port HP is lower than 50.

[edit] Advanced Example

getTargetHP() could also be used 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