• 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!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] I need help with Terrain Pulse

DarkFoxVerdigris

Founder of Pokémon Verdigris
  • 11
    Posts
    5
    Years
    • Seen Nov 26, 2020
    I'm trying to script in Terrain Pulse, but it's not working at all.
    First I tried with this:

    Code:
    class PokeBattle_Move_219 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        if  @battle.field.effects!=0
          return basedmg*2
        end
        return basedmg
      end
    
      def pbModifyType(type,attacker,opponent)
        type=getConst(PBTypes,:NORMAL) || 0
        case @battle.field.effects
        when PBEffects::GrassyTerrain
          type=(getConst(PBTypes,:GRASS) || type)
        when PBEffects::PsychicTerrain
          type=(getConst(PBTypes,:PSYCHIC) || type)
        when PBEffects::MistyTerrain
          type=(getConst(PBTypes,:FAIRY) || type)
        when PBEffects::ElectricTerrain
          type=(getConst(PBTypes,:ELECTRIC) || type)
        when PBEffects::WarTerrain
          type=(getConst(PBTypes,:FIGHTING) || type)
        end
        return type
      end
    end

    But it didn't work, so under another user's suggestions I tried changing the first part of the script to this:

    Code:
    class PokeBattle_Move_219 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        if  @battle.field.effects[PBEffects::ElectricTerrain]>0 ||
            @battle.field.effects[PBEffects::GrassyTerrain]>0 ||
            @battle.field.effects[PBEffects::MistyTerrain]>0 ||
            @battle.field.effects[PBEffects::PsychicTerrain]>0 ||
            @battle.field.effects[PBEffects::WarTerrain]>0 
          return basedmg*2
        end
        return basedmg
      end

    And it still doesn't work. Any idea why?

    I'm also trying to get Scale shot and Grassy glide to work but neither do, so...
     
    Update: with the help of WolfPP from the Discord server I got it to work, here's the proper code:
    Code:
    class PokeBattle_Move_219 < PokeBattle_Move
      def pbBaseDamage(basedmg,attacker,opponent)
        if (@battle.field.effects[PBEffects::GrassyTerrain]   ||
            @battle.field.effects[PBEffects::ElectricTerrain] ||
            @battle.field.effects[PBEffects::MistyTerrain]    ||
            @battle.field.effects[PBEffects::PsychicTerrain])>0
          return basedmg*2
        else
          return basedmg
        end
      end
      
      def pbModifyType(type,attacker,opponent)
        type=getConst(PBTypes,:NORMAL) || 0
        type=(getConst(PBTypes,:GRASS) || type) if @battle.field.effects[PBEffects::GrassyTerrain]>0
        type=(getConst(PBTypes,:ELECTRIC) || type) if @battle.field.effects[PBEffects::ElectricTerrain]>0
        type=(getConst(PBTypes,:FAIRY) || type) if @battle.field.effects[PBEffects::MistyTerrain]>0
        type=(getConst(PBTypes,:PSYCHIC) || type) if @battle.field.effects[PBEffects::PsychicTerrain]>0
        return type
      end
    end
     
    Or you can use my own:
    Code:
    ################################################################################
    # Type varies between terrains. Power is doubled when executed within an active
    # terrain (Terrain Pulse)
    ################################################################################
    class PokeBattle_Move_219 < PokeBattle_Move
      def pbModifyDamage(damagemult,attacker,opponent)
        if @battle.field.effects[PBEffects::GrassyTerrain]==0 &&
           @battle.field.effects[PBEffects::ElectricTerrain]==0 &&
           @battle.field.effects[PBEffects::MistyTerrain]==0 &&
           @battle.field.effects[PBEffects::PsychicTerrain]==0 &&
          return damagemult
        end
        return (damagemult*2.0).round
      end
    
      def pbModifyType(type,attacker,opponent)
        type=getConst(PBTypes,:NORMAL) || 0
        if @battle.field.effects[PBEffects::ElectricTerrain]>0
          type=getConst(PBTypes,:ELECTRIC) if hasConst?(PBTypes,:ELECTRIC)
        elsif @battle.field.effects[PBEffects::GrassyTerrain]>0
          type=getConst(PBTypes,:GRASS) if hasConst?(PBTypes,:GRASS)
        elsif @battle.field.effects[PBEffects::MistyTerrain]>0
          type=getConst(PBTypes,:FAIRY) if hasConst?(PBTypes,:FAIRY)
        elsif @battle.field.effects[PBEffects::PsychicTerrain]>0
          type=getConst(PBTypes,:PSYCHIC) if hasConst?(PBTypes,:PSYCHIC)
        end
        return type
      end
    end

    You can tell me if this code works for you but I assume it will
     
    Back
    Top