• 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] I need help with Terrain Pulse

DarkFoxVerdigris

Founder of Pokémon Verdigris
11
Posts
4
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...
     

    DarkFoxVerdigris

    Founder of Pokémon Verdigris
    11
    Posts
    4
    Years
    • Seen Nov 26, 2020
    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
     

    HM100

    HM100 the Techno
    113
    Posts
    7
    Years
    • Seen Apr 27, 2024
    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