• 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.

[Custom Feature Question] Giving Pokemon ground immunity without Flying Type or Levitate

79
Posts
8
Years
    • Seen Jan 12, 2024
    Is there a way to code a list of Pokemon to be naturally immune to Ground Type moves? Essentially, this is for Pokemon like Mega Charizard X or Magnezone, who are clearly floating above the ground, yet don't fit being flying type, or having the ability levitate. The reverse is also true, so pokemon like Doduo and Dodrio that are clearly standing on the ground, would be affected by Ground moves by not being on the list of floating mons. This would allow a bunch of pokemon to not have to sacrifice their typing or ability and still be immune to Ground. I have no idea how to go about something like this, so any help would be appreciated. Thanks!
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Sure. Go find the bit of the code where levitate applies, it will look something like "pokemon.hasWorkingAbility(:LEVITATE)" and make it also check for particular species of Pokémon.

    If you ever have an idea that is similar to something that already exists, you should go look at how that thing works.
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    Sure. Go find the bit of the code where levitate applies, it will look something like "pokemon.hasWorkingAbility(:LEVITATE)" and make it also check for particular species of Pokémon.

    If you ever have an idea that is similar to something that already exists, you should go look at how that thing works.

    Thanks! I had a feeling it would be similar to levitate, but wasn't sure exactly where to put it. So would it look something like this?

    Code:
    # Airborne-based immunity to Ground moves
          if isConst?(type,PBTypes,:GROUND) && target.isAirborne?(user.hasMoldBreaker) &&
             !target.hasWorkingItem(:RINGTARGET) && thismove.function!=0x11C # Smack Down
            if !user.hasMoldBreaker && target.hasWorkingAbility(:LEVITATE)
              @battle.pbDisplay(_INTL("{1} makes Ground moves miss with Levitate!",target.pbThis))
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Levitate made the Ground-type move miss")
              return false
            end
           [COLOR="Red"] if ( isConst?(target.species,PBSpecies,:CHARIZARD) ||
                 isConst?(target.species,PBSpecies,:BUTTERFREE) ||
                 isConst?(target.species,PBSpecies,:BEEDRILL) ||
                 isConst?(target.species,PBSpecies,:Pidgey) ||
                 isConst?(target.species,PBSpecies,:Pidgeotto) ||
                 isConst?(target.species,PBSpecies,:Pidgeot))
              @battle.pbDisplay(_INTL("{1} is floating above the ground!",target.pbThis))
              return false
            end[/COLOR]
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Yeah, something like that looks good. Did it work? :)

    hmmm, but target is just for enemy?

    '( isConst?(target.species,PBSpecies,:CHARIZARD) ||'

    I mean, we have to put 'user.species' too for us? or 'target' is the same to us and our enemy?
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    hmmm, but target is just for enemy?

    target is whichever Pokémon is being attacked. So it's the enemy when you attack, and you when the enemy attacks.

    It appears to be doing nothing right now, I tried changing 'target' to 'opponent', and just removing target, but it still does nothing.

    Try simplifying your code—can you make it work for just one species and go from there?

    The code you posted looks like it should cause an error (because not all the species names are IN ALL CAPITALS). I would suggest trying to duplicate the species checks inside pbIsAirborne? because I doubt you're even getting to your new code.

    An easy way to check how far through the code you're getting is to call pbDisplay, e.g. @battle.pbDisplay(_INTL("Here"))
     
    Last edited:
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    The code you posted looks like it should cause an error (because not all the species names are IN ALL CAPITALS). I would suggest trying to duplicate the species checks inside pbIsAirborne? because I doubt you're even getting to your new code.

    An easy way to check how far through the code you're getting is to call pbDisplay, e.g. @battle.pbDisplay(_INTL("Here"))

    Yeah I realized I forgot to capitalize some of them, I fixed that before I started testing it. For putting the species checks inside pbIsAirborne, I couldn't find anything called that, do you mean 'def isAirborne?' ?

    Here's my attempt at putting the species check inside isAirborne?:

    Code:
     def isAirborne?(ignoreability=false)
        return false if self.hasWorkingItem(:IRONBALL)
        return false if @effects[PBEffects::Ingrain]
        return false if @effects[PBEffects::SmackDown]
        return false if @battle.field.effects[PBEffects::Gravity]>0
        return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
        return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
        return true if self.hasWorkingItem(:AIRBALLOON)
        return true if @effects[PBEffects::MagnetRise]>0
        return true if @effects[PBEffects::Telekinesis]>0
    [COLOR="Red"]    return true if self.species,PBSpecies,:CHARIZARD[/COLOR]
        return false
      end

    Doing this still ended up with nothing happening; Both my charizard and the opponent's charizard can be hit with ground type moves. I didn't get any errors, but the code appears to be doing nothing.

    EDIT: the red code now gives me a syntax error, for some reason it wasn't earlier.

    EDIT EDIT: Success! I changed the code to:

    Code:
    def isAirborne?(ignoreability=false)
        return false if self.hasWorkingItem(:IRONBALL)
        return false if @effects[PBEffects::Ingrain]
        return false if @effects[PBEffects::SmackDown]
        return false if @battle.field.effects[PBEffects::Gravity]>0
        return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
        return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
        return true if self.hasWorkingItem(:AIRBALLOON)
        return true if @effects[PBEffects::MagnetRise]>0
        return true if @effects[PBEffects::Telekinesis]>0
    [COLOR="Red"]    return true if isConst?(self.species,PBSpecies,:CHARIZARD)[/COLOR]
        return false
      end

    It now appears to be working for Charizard :D Should I put each species as its own "return true if..." or should they all be in one?
     
    Last edited:

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • Yeah I realized I forgot to capitalize some of them, I fixed that before I started testing it. For putting the species checks inside pbIsAirborne, I couldn't find anything called that, do you mean 'def isAirborne?' ?

    Here's my attempt at putting the species check inside isAirborne?:

    Code:
     def isAirborne?(ignoreability=false)
        return false if self.hasWorkingItem(:IRONBALL)
        return false if @effects[PBEffects::Ingrain]
        return false if @effects[PBEffects::SmackDown]
        return false if @battle.field.effects[PBEffects::Gravity]>0
        return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
        return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
        return true if self.hasWorkingItem(:AIRBALLOON)
        return true if @effects[PBEffects::MagnetRise]>0
        return true if @effects[PBEffects::Telekinesis]>0
    [COLOR="Red"]    return true if self.species,PBSpecies,:CHARIZARD[/COLOR]
        return false
      end

    Doing this still ended up with nothing happening; Both my charizard and the opponent's charizard can be hit with ground type moves. I didn't get any errors, but the code appears to be doing nothing.

    EDIT: the red code now gives me a syntax error, for some reason it wasn't earlier.

    EDIT EDIT: Success! I changed the code to:

    Code:
    def isAirborne?(ignoreability=false)
        return false if self.hasWorkingItem(:IRONBALL)
        return false if @effects[PBEffects::Ingrain]
        return false if @effects[PBEffects::SmackDown]
        return false if @battle.field.effects[PBEffects::Gravity]>0
        return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
        return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
        return true if self.hasWorkingItem(:AIRBALLOON)
        return true if @effects[PBEffects::MagnetRise]>0
        return true if @effects[PBEffects::Telekinesis]>0
    [COLOR="Red"]    return true if isConst?(self.species,PBSpecies,:CHARIZARD)[/COLOR]
        return false
      end

    It now appears to be working for Charizard :D Should I put each species as its own "return true if..." or should they all be in one?

    Sorry but how you put?

    I try (ONLY TEST) to put a RIOLU to have that and doenst work...

    Code:
        if thismove.basedamage>0 && thismove.function!=0x02 && # Struggle
           thismove.function!=0x111 # Future Sight
          type=thismove.pbType(thismove.type,user,target)
          typemod=thismove.pbTypeModifier(type,user,target)
          # Airborne-based immunity to Ground moves
          if isConst?(type,PBTypes,:GROUND) && target.isAirborne?(user.hasMoldBreaker) &&
             !target.hasWorkingItem(:RINGTARGET) && thismove.function!=0x11C # Smack Down
            if !user.hasMoldBreaker && target.hasWorkingAbility(:LEVITATE)
              @battle.pbDisplay(_INTL("{1} makes Ground moves miss with Levitate!",target.pbThis))
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Levitate made the Ground-type move miss")
              return false
            end
    [B][COLOR="Red"]        if isConst?(pokemon.species,PBSpecies,:RIOLU)
              @battle.pbDisplay(_INTL("{1} is floating above the ground!",target.pbThis))
              #PBDebug.log("#{target.pbThis}'s float made the Ground-type move miss")
              return false
            end
    [/COLOR][/B]

    and

    Code:
      def isAirborne?(ignoreability=false)
        return false if self.hasWorkingItem(:IRONBALL)
        return false if @effects[PBEffects::Ingrain]
        return false if @effects[PBEffects::SmackDown]
        return false if @battle.field.effects[PBEffects::Gravity]>0
        return true if self.pbHasType?(:FLYING) && !@effects[PBEffects::Roost]
        return true if self.hasWorkingAbility(:LEVITATE) && !ignoreability
        return true if self.hasWorkingItem(:AIRBALLOON)
        return true if @effects[PBEffects::MagnetRise]>0
        return true if @effects[PBEffects::Telekinesis]>0
    [COLOR="red"][B]    return true if isConst?(self.species,PBSpecies,:RIOLU)   
    [/B][/COLOR]    return false
      end
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    I think it's because you have the first code as "pokemon.species..." and not "target.species..."
    Does that fix it?
     

    WolfPP

    Spriter/ Pixel Artist
    1,309
    Posts
    5
    Years
  • I think it's because you have the first code as "pokemon.species..." and not "target.species..."
    Does that fix it?

    Oh God! Thank you very much.

    Now, lets work about all pokemon than will get it and all not (like Dodue etc) :D
     
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Glad to hear you got things working in the end! You can put them all in the same return if, or in separate, it doesn't make any difference :)
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    Glad to hear you got things working in the end! You can put them all in the same return if, or in separate, it doesn't make any difference :)

    Thanks for steering me in the right direction! ^ ^

    Is there a way to do this for specific forms as well? So Giratina's origin form can be floating but its altered form isn't, for example.
     
    Last edited:
    1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    Thanks for steering me in the right direction! ^ ^

    Is there a way to do this for specific forms as well? So Giratina's origin form can be floating but its altered form isn't, for example.

    pokemon.form=1

    :D

    Yeah, like WolfPP says, pokemon.form==1
    (Note that's two equals signs—x == y means "is x equal to y?", x = y means "set x to be y")
     
    11
    Posts
    4
    Years
    • Seen Apr 22, 2024
    Hello,

    Was wonder if any of you have gotten this to work for version 19.1?
     
    11
    Posts
    4
    Years
    • Seen Apr 22, 2024
    Yeah Pokeminer20 I've been trying to do just that. I had been trying for a few days myself before I decided to ask for help. Still a little new to this but I don't mind trying to figure out things. This version change so much of the scripting it was a bit hard to find the equivalents, at least for me personally. I have gotten to work in older versions so I'm pretty sure it is doable. I'm just struggling some. Not sure if you are able but if could post some things maybe you can steer me in the right direction? Of course, if you are willing and able to give some time
     
    11
    Posts
    4
    Years
    • Seen Apr 22, 2024
    So I think I figure something out to this so wanted to post an update and so far its seems to be working. The only thing now is to figure it out for multiple forms. but here is what I change just in case anyone else was stuck like me (I'm not the creator of this, I'm just editing from the post above).

    So in "PokeBattle_Battler" look for the line " def airborne?" and add the names above return to false.

    def airborne?
    return false if hasActiveItem?(:IRONBALL)
    return false if @effects[PBEffects::Ingrain]
    return false if @effects[PBEffects::SmackDown]
    return false if @battle.field.effects[PBEffects::Gravity] > 0
    return true if pbHasType?(:FLYING)
    return true if hasActiveAbility?(:LEVITATE) && [email protected]
    return true if hasActiveItem?(:AIRBALLOON)
    return true if @effects[PBEffects::MagnetRise] > 0
    return true if @effects[PBEffects::Telekinesis] > 0
    return true if isSpecies?(:CHARIZARD)
    return true if isSpecies?(:BEEDRILL)

    return false
    end

    Then in "Battler_UseMove_SuccessChecks" look for the line "# Airborne-based immunity to Ground moves". I put the names above the Air Balloon line.

    # Airborne-based immunity to Ground moves
    if move.damagingMove? && move.calcType == :GROUND &&
    target.airborne? && !move.hitsFlyingTargets?
    if target.hasActiveAbility?(:LEVITATE) && [email protected]
    @battle.pbShowAbilitySplash(target)
    if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
    @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
    else
    @battle.pbDisplay(_INTL("{1} avoided the attack with {2}!",target.pbThis,target.abilityName))
    end
    @battle.pbHideAbilitySplash(target)
    return false
    end
    if target.isSpecies?(:CHARIZARD) ||
    target.isSpecies?(:BEEDRILL)
    @battle.pbDisplay(_INTL("{1} avoided the attack!",target.pbThis))
    return false
    end

    if target.hasActiveItem?(:AIRBALLOON)
    @battle.pbDisplay(_INTL("{1}'s {2} makes Ground moves miss!",target.pbThis,target.itemName))
    return false
    end

    Check in-game and it works. Again can't get it to check for different forms so if I do figure it out will make an edit. Hope this helps and hopefully, I'm not breaking rules by posting this.
     
    Back
    Top