• 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!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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