• 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] Immunity Based on attack type and defender type

220
Posts
13
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