• The Relic Castle Game Jam #4 is almost halfway done! From June 30th to August 10th, users have just a bit over a month to make an entire game. Check this thread for details!

Help Creating an ability that triggers a field effect

Goblin

Rookie
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

Rookie
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.
 
Top