28 lines
829 B
GDScript
28 lines
829 B
GDScript
class_name ConfusionEffect
|
|
extends BattleEffect
|
|
|
|
#effet temporaire (disparait au changement de pokemon) : 1 chance sur 3 de se blesser au lieu d'attaquer
|
|
|
|
const SELF_HIT_CHANCE : float = 1.0 / 3.0
|
|
|
|
var turns : int = 3
|
|
|
|
func _init(p_turns : int = 3) -> void:
|
|
id = &"confusion"
|
|
turns = p_turns
|
|
|
|
func before_action(battle : Battle, slot : BattleSlot, _action : BattleAction) -> bool:
|
|
var mon : BattleMon = slot.mon
|
|
if turns <= 0:
|
|
mon.remove_volatile(id)
|
|
await battle.message("%s n'est plus confus !" % mon.display_name())
|
|
return true
|
|
|
|
turns -= 1
|
|
await battle.message("%s est confus !" % mon.display_name())
|
|
if battle.rng.randf() < SELF_HIT_CHANCE:
|
|
var damage : int = DamageCalculator.confusion_damage(mon, battle.rng)
|
|
await battle.hurt(slot, damage, "Il se blesse dans sa confusion !")
|
|
return false
|
|
return true
|