• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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] Checking for one ability

  • 16
    Posts
    5
    Years
    • Seen Aug 1, 2023
    I'm trying to make an item that reverts a Pokemon's hidden ability back to it's normal ability/abilities.
    The problems lies when I use it on a Pokemon with a single ability. I don't know how to make it check if the Pokemon only has one ability so it won't asks me twice and giving me a "?" where the second ability should be.
    Here's the script that I adapted from BulbasaurLvl5 Ability capsule
    Code:
    #DeDream capsule
    ItemHandlers::UseOnPokemon.add(:DEDREAMCAPSULE,proc{|item,poke,scene|
       abilityList=poke.getAbilityList
       abil1=0; abil2=0; abil3=0
         for i in abilityList
           abil1=i[0] if i[1]==0
           abil2=i[0] if i[1]==1
           abil3=i[0] if i[1]==2
         end
        if poke.abilityIndex() <=1
         scene.pbDisplay(_INTL("It won't have any effect."))
         next false  
       end
        if Kernel.pbConfirmMessage(_INTL("Do you want to change {1}'s ability?",
          poke.name))
          
          if poke.abilityIndex() == 2
            if Kernel.pbConfirmMessage(_INTL("Do you want to change it to {1}?",
          PBAbilities.getName(abil1)))
          poke.setAbility(0)
        else
            if Kernel.pbConfirmMessage(_INTL("Do you want to change it to {1}?",
          PBAbilities.getName(abil2)))
          poke.setAbility(1)
        else 
          scene.pbDisplay(_INTL("You changed your mind."))
          next false
          end
        end
      end
        scene.pbDisplay(_INTL("{1}'s ability was changed!",poke.name))
        next true
      end
      next false
    })

    Also if I make any mistake or something that shouldn't be in there, Please let me know.
    Thanks!
     
    I'm trying to make an item that reverts a Pokemon's hidden ability back to it's normal ability/abilities.
    The problems lies when I use it on a Pokemon with a single ability. I don't know how to make it check if the Pokemon only has one ability so it won't asks me twice and giving me a "?" where the second ability should be.
    Here's the script that I adapted from BulbasaurLvl5 Ability capsule
    Code:
    #DeDream capsule
    ItemHandlers::UseOnPokemon.add(:DEDREAMCAPSULE,proc{|item,poke,scene|
       abilityList=poke.getAbilityList
       abil1=0; abil2=0; abil3=0
         for i in abilityList
           abil1=i[0] if i[1]==0
           abil2=i[0] if i[1]==1
           abil3=i[0] if i[1]==2
         end
        if poke.abilityIndex() <=1
         scene.pbDisplay(_INTL("It won't have any effect."))
         next false  
       end
        if Kernel.pbConfirmMessage(_INTL("Do you want to change {1}'s ability?",
          poke.name))
          
          if poke.abilityIndex() == 2
            if Kernel.pbConfirmMessage(_INTL("Do you want to change it to {1}?",
          PBAbilities.getName(abil1)))
          poke.setAbility(0)
        [B]else[/B]
            if Kernel.pbConfirmMessage(_INTL("Do you want to change it to {1}?",
          PBAbilities.getName(abil2)))
          poke.setAbility(1)
        else 
          scene.pbDisplay(_INTL("You changed your mind."))
          next false
          end
        end
      end
        scene.pbDisplay(_INTL("{1}'s ability was changed!",poke.name))
        next true
      end
      next false
    })

    Also if I make any mistake or something that shouldn't be in there, Please let me know.
    Thanks!

    From what I gather from this code, it seems like if the Pokemon has its hidden ability, the player will be asked if they want to change the ability to the first non-hidden ability, and if they say no, they will be asked if they want to change it to the second non-hidden ability (sorry, the indentation makes it a little hard to read). If this is the case, you could maybe change the "else" that I bolded in the quote to "elsif abil2 != 0", though maybe it should be "elsif abil2 != nil" (should be whatever value abil2 would be if there was no ability there). If you did this, you would probably need another else statement after, to say "You changed your mind".
     
    Yes silverlime, that's is correct. I tried using both "elsif abil2 != 0" and "elsif abil2 != nil" but both of them didn't work. Turns out it is "elsif abil2 ==0" that made it work. So thanks!
    Here's the final script:
    Spoiler:
     
    Last edited:
    Back
    Top