> Tutorial
In the previous chapter, we saw how to boost ourselves, give ourselves a shield and heal ourselves. You've probably noticed that boosting and protecting yourself is always useful, but healing is pointless when your life is already at its maximum.
To avoid casting a heal and wasting TP , we'll use a condition, which is written like this:
if (me.life < me.maxLife) {
me.useChip(Chip.bandage)
}
This code casts Bandage only if we're hurt, that is, when our current life me.life is less than ` Which code(s) are valid?
if me.life < me.maxLife { me.useChip(Chip.bandage) } if (me.life < me.maxLife { me.useChip(Chip.bandage) }) if (me.life < me.maxLife) { me.useChip(Chip.bandage) } else { me.useChip(Chip.helmet) } if { me.life < me.maxLife } { me.useChip(Chip.bandage) }
const me = Fight.me
// Equip the pistol
me.setWeapon(Weapon.pistol) // Careful: costs 1 TP
// Get the nearest enemy
const enemy = Fight.getNearestEnemy()
// Move toward the enemy
me.moveToward(enemy)
// Boosts, shield and heal
me.useChip(Chip.motivation)
me.useChip(Chip.protein)
me.useChip(Chip.helmet)
// Heal ourselves if our life is below our max life
if (me.life < me.maxLife) {
me.useChip(Chip.bandage)
}
// Try to shoot it!
me.useWeapon(enemy)
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.