• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Defense curl in the ability?

44
Posts
6
Years
  • Hi everyone!
    I'm new to Essentials and i am still trying to learn some basics.
    I am trying to write an ability that does:
    -increase defense by one upon entering into battle.
    -set the [PBEffects::DefenseCurl] to true

    In practice: the pokemon casts defense curl upon switching in. (useful for pokémon with rollout or ice ball like Spheal evolution line).
    The code is the following:

    # Iron Curl
    if self.hasWorkingAbility(:IRONCURL) && onactive
    self.effects[PBEffects::DefenseCurl]=true
    if pbIncreaseStatWithCause(PBStats::DEFENSE,1,self,PBAbilities.getName(ability))
    PBDebug.log("[Ability triggered] #{pbThis}'s Iron curl raises Defense")
    end
    end

    The increase of defense works fine (at least the animation works, i am not sure if the defense really grows). BUT the defense curl doesn't seem to work!
    I really don't know why.. Anyone got an idea?
     
    Last edited:
    423
    Posts
    13
    Years
    • Seen Aug 31, 2023
    what do you mean by the increase in defense works but defense curl doesnt?
     
    44
    Posts
    6
    Years
  • There's a mechanic where if you use defense curl and then Rollout or Ice ball, the damage is doubled. It was implemented with the second/third generation.
    The [PBEffects::DefenseCurl] doesn't work properly with this ability because the damage of rollout (or ice ball) doesn't double when I test it.
     
    423
    Posts
    13
    Years
    • Seen Aug 31, 2023
    ok so my knowledge on moves is a little lacking but
    under PokeBattle_MoveEffects
    find shift+=1 if attacker.effects[PBEffects::DefenseCurl]
    and change to
    shift+=1 if attacker.effects[PBEffects::DefenseCurl] || attacker.effects[PBEffects::IronCurl]

    no clue if it'll work but worth a try
     
    44
    Posts
    6
    Years
  • You gave me the perfect hint! It was kinda what you said but using attacker.hasWorkingAbility(:IRONCURL) instead. Thanks a lot!
    If someone is interested, here it is the code.
    Insert this in pokebattle_battler (near intimidate or download)
    Code:
    # Iron Curl
        if self.hasWorkingAbility(:IRONCURL) && onactive
          if pbIncreaseStatWithCause(PBStats::DEFENSE,1,self,PBAbilities.getName(ability))
              PBDebug.log("[Ability triggered] #{pbThis}'s Iron curl raises Defense")
          end
        end
    and add the Bold thing in pokebattle_moveeffects:
    Code:
    class PokeBattle_Move_0D3 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        shift=(4-attacker.effects[PBEffects::Rollout]) # from 0 through 4, 0 is most powerful
        shift+=1 if attacker.effects[PBEffects::DefenseCurl] [B]|| attacker.hasWorkingAbility(:IRONCURL)[/B]
    ...
    (if you have pokemon elite system, add in EliteBattle_0 the Bold thing)
    Code:
    if self.checkForAbilities(:FRISK,:FOREWARN,:BADDREAMS,:MOODY,:HARVEST,:TRACE,:INTIMIDATE,:[B]IRONCURL[/B])
     
    Last edited:
    Back
    Top