Help Creating an ability that triggers a field effect

Goblin

The Worst Guy
Member
Posts
2
#1
Hello, I'm trying to create an ability that will trigger Tailwind whenever the Pokemon with the ability is dropped below half of its hp. I've looked around to see if I could perhaps splice the sand stream and torrent-like effects, but I really have no idea how to start implementing this - I suck at coding. Any help would be appreciated, thank you.
 

Senn62

There is water at the bottom of the ocean
Member
Posts
3
#2
Looking at Defeatist and the Tailwind code is certainly a good start (you can use Ctrl+Shift+F in the Script Editor to find all instances of both). An easy alternative is having only the current mon's speed doubled at half HP using

if attacker.hasWorkingAbility(:INSERTABILITYNAME) &&
attacker.hp<=(attacker.totalhp/2).floor
speedmult=speedmult*2

but that isn't what you're looking for.

The real issue I don't know how to solve is how to activate a function code through an ability. Sandstream produces a weather effect (Sandstorm) which is defined separately from function codes. If you could find the section in the Script Editor where it defines how function codes are activated then it would probably make it a lot easier to do, but it could be a dead end. Something minor to note is that if Tailwind is already active then the ability will fail to activate.

Another thing I just thought of is creating a new weather effect that acts exactly like Tailwind - it would last for 4 turns, not be able to be used while Tailwind or itself is in effect, and would have the same dialogues. That might be easier to code in but there's the glaring issue of it removing and being removed by the other weather effects.
 

Goblin

The Worst Guy
Member
Posts
2
#3
I believe I'm pretty close, this is what I have.

Code:
if self.hasWorkingAbility(:LASTBREATH) && self.pbOwnSide.effects[PBEffects::Tailwind]<=0 && self.hp<=(self.totalhp/2).floor
self.pbOwnSide.effects[PBEffects::Tailwind]=4
if !@battle.pbIsOpposing?(self.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
It works, however; if the pokemon stays alive with half of its health until the tailwind peters out, the ability triggers again. My problem now is that I want it to trigger once a battle for balance purposes. Not sure where else to look at to achieve this as I don't believe any other abilities set this precedent.
 

ArchyArc

Lead Developer of Pokemon Sacred Johto
Member
Posts
14
#4
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
Code:
        #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

Code:
    #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.
 
Top