User:Alexanderpas/Attack/BeserkPreventOverheatFreeze

From Hack Wars Wiki

Jump to: navigation, search

Tries to prevent overheating by freezing the target port

Contents

Code

Initialize

int main() {

// Nothing special.

}

Finalize

int main() {

// Nothing special.

}

Continue

int main() {

if (portHealth() < 10) {
// port HP: 00-09
// CPU load: 00-99
cancelAttack();
} else if (CPUload() < 85) {
// port HP: 10-100
// CPU load: 00-84
berserk();
} else if (portHealth() == 100) {
// port HP: 100
// CPU load: 85-99
regularAttack();
} else if (CPUload() > 95) {
// port HP: 10-99
// CPU load: 95-99
cancelAttack();
} else {
// port HP: 10-99
// CPU load: 85-94
freeze();
}

}

int CPUload() {

float value = (getCPULoad() / getMaximumCPULoad());
return intValue(100 * value);

}

int portHealth() {

return intValue(getHP());

}

void regularAttack() {

// Nothing special.

}

Personal tools