so the only way i could think is how the primal weather abilities work. it last all the time while they are in battle so essentially a infinite tailwind as they hit half health.
however im not overly sure if it'd work for the move tailwind. as in it might just instantly stop working due to not having Last Breath.
but i may have found a way for it to work the way you did it, seems due to it being less than half health even though its been activated, it activates again. how intimidate or like the terrain surge abilities work is on send in, and then it only activates once, thats your issue:
At half health
#Last Breath
if self.hasWorkingAbility(:LASTBREATH) && @hp<=((@totalhp/2).floor)
if @attacker.pbOwnSide.effects[PBEffects::Tailwind]<1
@battle.pbCommonAnimation("Tailwind",self,nil)
@battle.field.effects[PBEffects::Tailwind]=4
if !@battle.pbIsOpposing?(attacker.index)
@battle.pbDisplay(_INTL("The tailwind blew from behind your team!"))
else
@battle.pbDisplay(_INTL("The tailwind blew from behind the opposing team!"))
end
end
end
On send in
#Last Breath
if self.hasWorkingAbility(:LASTBREATH) && onactive
if @attacker.pbOwnSide.effects[PBEffects::Tailwind]<1
@battle.pbCommonAnimation("Tailwind",self,nil)
@battle.field.effects[PBEffects::Tailwind]=4
if !@battle.pbIsOpposing?(attacker.index)
@battle.pbDisplay(_INTL("The tailwind blew from behind your team!"))
else
@battle.pbDisplay(_INTL("The tailwind blew from behind the opposing team!"))
end
end
end
The second one will only activate when sent in but at full health/health it has on send in. the first activates when they hit 50%/lower than 50% but also reactivates the ability if tailwind runs out and they are below 50% health.
Hope this helped even a little bit. one way you could have it work is have two abilities that internally are LASTBREATH1 and LASTBREATH2 but to the player are the exact same thing being Last Breath. you would give the pokemon that has the ability LASTBREATH1 and have it have a multiple form that the only thing that changes is its ability to LASTBREATH2.
In the battler section you'd have it so that when said pokemon hits 50% health and has LASTBREATH1, they change to form 1 (or the form that has LASTBREATH2) then do the onactive one and change it to LASTBREATH2 from LASTBREATH. that might sound confusing, but if you want to go that way i can help show you how to do it.