useWeapon(number entity) → integer result
Uses the equipped weapon on the entity entity.
Example: using the pistol on the nearest enemy:
var enemy = getNearestEnemy()
setWeapon(WEAPON_PISTOL)
useWeapon(enemy)
const enemy = Fight.getNearestEnemy()
Fight.me.setWeapon(Weapon.pistol)
Fight.me.useWeapon(enemy)
enemy = Fight.getNearestEnemy()
Fight.me.setWeapon(Weapon.pistol)
Fight.me.useWeapon(enemy)
Since USE_SUCCESS and USE_CRITICAL are 1 and 2 respectively, and the other values are 0 or negative, you can tell whether the weapon was used successfully with this test:
if (useWeapon(entity) > 0) {
// It worked!
} else {
// It failed!
}
if (Fight.me.useWeapon(entity) > 0) {
// It worked!
} else {
// It failed!
}
if Fight.me.useWeapon(entity) > 0:
pass # It worked!
else:
pass # It failed!
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.