Abilities that raise stats other than Speed?

MagentaGiratina

Distortion World Enthusiast
Member
Joined
Jun 16, 2019
Posts
46
I'm trying to implement an ability which doubles Special Defense under a specific weather condition, so I looked up how the scripts handle Swift Swim to manage that. While I was doing that, I noticed that there wasn't a script section for things that raised Sp. Defense, or any stat other than Speed, actually. With that as the case, how do I add something that raises another stat? Do I need to make a new section in the script for it?
 

Phoenixsong

mulberry ambush
Member
Joined
Apr 2, 2017
Posts
39
With the caveat that I haven't looked at Essentials in ages (so anyone who has is absolutely free to tell me I'm super wrong), aren't the ability effects kind of all over the place anyway? Last I looked, ability checks were just added wherever the thing that the ability was related to was. IIRC the weather effects were all grouped together in one script, and any related ability checks and effects were just sprinkled in throughout the weather code wherever it made sense for them to be. So I wouldn't worry too much about needing a new "section", personally. I guess I can see why speed-related stuff might be in its own section, but that's because speed functions differently from stats that affect damage, not because each stat would need its own section.

At any rate, I'd think you'd be able to do what you want by emulating the effect of sandstorm. It raises Sp. Def if the pokémon is a rock-type, so I'd guess that you could simply copy that condition (for whatever your weather is) but replace "is rock-type" with "has [new ability]", yes?

Again, anyone else feel free to correct me/provide better advice, but that's what I think I recall doing back when I was messing around with similar abilities...

EDIT: Didn't want to waste anyone's time with an inaccurate answer, so I double-checked: yeah, you want the section on damage multipliers in script PokeBattle_Move (it applies a temporary Sp. Def boost while the attack is happening). This is the relevant piece of code:

Ruby:
if @battle.pbWeather==PBWeather::SANDSTORM &&
       opponent.pbHasType?(:ROCK) && applysandstorm
      defense=(defense*1.5).round
    end

The simplest thing would be copy-pasting this right under original for the weather you're using, then checking whether opponent has your new ability instead of checking the type. (Unless you're also using sandstorm, in which case just add that to the existing condition.) There's a bit more going on with the "applysandstorm" variable that's a little ways above that (basically that becomes true when the attack is special, if I'm reading that correctly?), so you may have to play with that a bit as well, but that's the gist of it.
 
Last edited:
Top