• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • 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] Immunity Based on attack type and defender type

  • 217
    Posts
    15
    Years
    • Seen Nov 29, 2021
    It seemed so simple, the pokemon with the ability is immune to moves with the same type as it.
    This is what I've got. As you can see, I've no idea to check if the attack's type is equal to a type the defender has (other than a long list checking each type).
    Code:
        if opponent.hasWorkingAbility(:ELEMENTSHIELD)# && 
          PBDebug.log("[Ability triggered] #{opponent.pbThis}'s #{PBAbilities.getName(opponent.ability)} (made #{@name} ineffective)")
          @battle.pbDisplay(_INTL("{1}'s {2} made {3} useless!",
            opponent.pbThis,PBAbilities.getName(opponent.ability),@name))
          return true
        end

    Is there a way to simply check if opponent.pbHasType?=attacktype? (to mix code and totally not code together in a mess that probably makes many wince.)
     
    Back
    Top