getCPULoad()

From Hack Wars Wiki

Jump to: navigation, search


Function information for getCPULoad()
Function getCPULoad()
API Attacking, Watch
Cost $10(attack) $100(watch)
Level 10
CPU Usage 2
Description Returns a float representing the current load in CPU units of the computer performing the attack or firing the watch.


This function only returns the taken CPU units. To get the current CPU balance use the following code

float CPUBalance = getCPULoad() / getMaximumCPULoad();


Watch Example

getCPULoad() can be used in Watch scripts to check whether or not the system would be able to handle counterattacking the attacker.

if(getMaximumCPULoad() - getCPULoad() >= 50.0){
  counterAttack();
}

This will only start a counterattack if the there are at least 50 CPU units left (20 for the attack script + 10 for a strong firewall + 20 spare CPU units).

Attack Example

getCPULoad() can be used in attack scripts to cancel your attack if your CPU is reaching a certain load:

if(getCPULoad() > 40.0){
  cancelAttack();
}

This would automatically cancel the attack if the CPU load goes over 40 CPU units and would prevent the system/port from overheating.

Personal tools