ivegotfrostbyte

She/her/they/them
United States
Seen October 6th, 2022
Posted September 24th, 2022
17 posts
1.7 Years
I'm curious on how to make an ability in v19, I all the tutorials I can find are outdated, and the wiki has the one for v20, which I am currently not willing to put in the effort to upgrade to lol.

I defined my ability in the pbs, abilities.txt
268,RUBYCORE,Ruby Core,"Attack and Speed are sharply raised in a pinch."
Then I went into BattleHandlers_Abilities.rb and made an attempt at making it so attack and speed are raised by 2 when at 1/3hp or lower
#==============================================================================
# Ability: Ruby Core
#==============================================================================
BattleHandlers::DamageCalcUserAbility.add(:RUBYCORE,
  proc { |ability,user,target,move,mults,baseDmg,type|
    if user.hp <= user.totalhp / 3
      battle.pbShowAbilitySplash(battler)
      battler.pbRaiseStatStageByAbility(:ATTACK,2,SPEED,2,battler)
  }
)
What else do I need to do, as it currently doesn't work, and if needed, what needs to be corrected?
Seen October 30th, 2022
Posted October 9th, 2022
99 posts
333 Days
The easiest way to make new abilities (or moves and items for that matter) is to find a like-styled ability and copy it. There is two abilities that kind of do what you want. The first, and easier one to copy is Berserk.

BattleHandlers::TargetAbilityAfterMoveUse.add(:BERSERK,
  proc { |ability,target,user,move,switched,battle|
    next if !move.damagingMove?
    next if target.damageState.initialHP<target.totalhp/2 || target.hp>=target.totalhp/2
    next if !target.pbCanRaiseStatStage?(:SPECIAL_ATTACK,target)
    target.pbRaiseStatStageByAbility(:SPECIAL_ATTACK,1,target)
  }
)
All you would have to do is change the hp amount to 1/3 instead of 1/2, and change the stat gains.

BattleHandlers::TargetAbilityAfterMoveUse.add(:RUBYCORE,
  proc { |ability,target,user,move,switched,battle|
    next if !move.damagingMove?
    next if target.damageState.initialHP<target.totalhp/3 || target.hp>=target.totalhp/3
    next if !target.pbCanRaiseStatStage?(:ATTACK,target)
    target.pbRaiseStatStageByAbility(:ATTACK,2,target)
    next if !target.pbCanRaiseStatStage?(:SPEED,target)
    target.pbRaiseStatStageByAbility(:SPEED,2,target)
  }
)
That will only proc when a Pokemon takes damage from a move that drops it below 1/3. So not from Toxic, Leech Seed damage, etc.

To make it proc on passive damage, you would have to copy the way Wimp Out/Emergency Exit is made, as it is the only ability that procs on passive damage that isn't a form change. However, I couldn't get that to work, and requires alot of script edits and additions. I would recommend making it act like Beserk.