• Having trouble receiving email verification when signing up? Contact a staff member via our Discord server!
  • Consider joining our Discord server if you haven't already! Discord is a free voice and text chat platform that's more or less a combination of Skype and Teamspeak. Using Discord, you can chat with other Relic Castle members in real-time! Wowza! Click here for the details!
Resource icon

How to add Field Effects to your game

Pokémon Essentials Version
v17.2 ✅
Have you ever wanted to have Field Effects in your game?
It's personaly, one of my favorite mechanics of any fangame, so I'll teach you too how to do it too.

What are Field Effects?
If you have played Gen 6 or Gen 7, then you probably know about Terrains (Electric Terrain, Psychic Terrain ...)
Field Effects, are in a way, the exact same thing, but they are present from the very start of the battle, and are map based.
Because of this, it can be used to make fights more interesting, and based on what kind of effects those fields have, they can make the game more strategic.

What I will teach you will be:
How to make it be active from the get go-
How to let background change based on the field-
How to implement battle start up messages-
How to buff overall move types, specific moves, specific move kind-
and a couple other stuff...

Step 1: Implementing an automatic background changer:

This step is mostly for future use, it will not do anything on its own, but we will need it later on.
I will explain what it does when we get there.
In PokeBattle_Battle search for def pbCommonAnimation(name,attacker,opponent,hitnum=0)

It should look like this:


After the second end, we will define a new method,
let's call it pbChangeBGSprite



Inside of it, we will create a new variable, you can call it whatever you want, but you must remember it, as it will be the thing we will use the most.
Personally, I use $fieldeffectsbg , and I will do so for this tutorial too.



Once this new case has been created we will add 2 new cases, one for what I will call "Interior Field", which won't have anything special on it, it will be the default battle.
And, lets make, like, a Snow Field for example.
Default Essentials already comes with Backgrounds and Battle Bases for these two, so let's use those.

So, to define the background and battlebase for these fields, we will do it like this:

Ruby:
def pbChangeBGSprite
        case $fieldeffectsbg
          when 0 # Interior Field
            @scene.sprites["battlebg"].setBitmap("Graphics/Battlebacks/battlebgIndoorA.png")
            @scene.sprites["playerbase"].setBitmap("Graphics/Battlebacks/playerbaseIndoorA.png")
            @scene.sprites["enemybase"].setBitmap("Graphics/Battlebacks/enemybaseIndoorA.png")
          when 1 # Snow Field
            @scene.sprites["battlebg"].setBitmap("Graphics/Battlebacks/battlebgSnow.png")
            @scene.sprites["playerbase"].setBitmap("Graphics/Battlebacks/playerbaseSnow.png")
            @scene.sprites["enemybase"].setBitmap("Graphics/Battlebacks/enemybaseSnow.png")
         end
  end
This way, everytime we have to change to one of these fields, the game will know what background and battle bases to load.

And thats pretty much it for how this part, if you want to add more field effects, you just have to continue adding more when x, where x is the number of the field, its very important that the field always has that number, as it will now be defined as such.

Next, we will go toPokeBattle_Scene search for def pbBackDrop


Replace that entire section with:

Ruby:
def pbBackdrop
    outdoor=false
    maps=[11] # Indoor Maps
    if $game_map && pbGetMetadata($game_map.map_id,MetadataOutdoor)
      outdoor=true
    elsif maps.include?($game_map.map_id)
         outdoor=true
    end
    environ=@battle.environment
    # Choose backdrop
    # Choose backdrop
    $fieldoverride = 0
    $tempfield = 0
    $fieldcounter = 0
    $fieldcollapse = 0
    backdrop="Field"
    if environ==PBEnvironment::Cave
      backdrop="Cave"
    elsif environ==PBEnvironment::MovingWater || environ==PBEnvironment::StillWater
      backdrop="Water"
    elsif environ==PBEnvironment::Underwater
      backdrop="Underwater"
    elsif environ==PBEnvironment::Rock
      backdrop="Mountain"
    elsif !outdoor
      backdrop="IndoorA"
    end
    if $game_map
      back=pbGetMetadata($game_map.map_id,MetadataBattleBack)
      if back && back !=""
        backdrop=back
        backdrop2 = backdrop
      end
    end
    # Field Effect override from variable 
    if $game_variables[29] != 0
      $fieldoverride = $game_variables[29]
    end   
    # Field Effect - in battle
    if $tempfield != 0
      $fieldoverride = $tempfield
    end
    # Apply override
    # Field Background
    if $fieldoverride != 0
      if $fieldoverride == 1
        backdrop="Snow"
      #elsif $fieldoverride == 2
      #  backdrop="Forest"
      else
        $tempfield = 0
      end
    backdrop3 = backdrop
    end
    if $PokemonGlobal && $PokemonGlobal.nextBattleBack
      backdrop=$PokemonGlobal.nextBattleBack
    end
    # Choose bases
    base=""
    trialname=""
    if environ==PBEnvironment::Grass || environ==PBEnvironment::TallGrass
      trialname="Grass"
    elsif environ==PBEnvironment::Sand
      trialname="Sand"
    elsif $PokemonGlobal.surfing
      trialname="Water"
    end
    if pbResolveBitmap(sprintf("Graphics/Battlebacks/playerbase"+backdrop+trialname))
      base=trialname
    end
    # Choose time of day
    time=""
    if ENABLESHADING
      trialname=""
      timenow=pbGetTimeNow
      if PBDayNight.isNight?(timenow)
        trialname="Night"
      elsif PBDayNight.isEvening?(timenow)
        trialname="Eve"
      end
      if pbResolveBitmap(sprintf("Graphics/Battlebacks/battlebg"+backdrop+trialname))
        time=trialname
      end
    end
    # Apply graphics
    if $fieldoverride != 0
      backdrop = backdrop2
    end
    # Field Effects
    if backdrop=="Snowy"
      fieldbd = 1
    #elsif backdrop=="Forest"
    #  fieldbd = 2
    else
      fieldbd = 0
    end
    #if $PokemonGlobal.surfing
    #  fieldbd = 21
    #  backdrop = "WaterSurface"
    #end
    $fieldeffectsbg = fieldbd
    $fieldbackup = $fieldeffectsbg 
    $fieldeffectsbg = $fieldoverride if $fieldoverride != 0
    backdrop = backdrop3 if backdrop3
    # Apply graphics
    battlebg="Graphics/Battlebacks/battlebg"+backdrop+time
    enemybase="Graphics/Battlebacks/enemybase"+backdrop+base+time
    playerbase="Graphics/Battlebacks/playerbase"+backdrop+base+time
    pbAddPlane("battlebg",battlebg,@viewport)
    pbAddSprite("playerbase",
       PokeBattle_SceneConstants::PLAYERBASEX,
       PokeBattle_SceneConstants::PLAYERBASEY,playerbase,@viewport)
    @sprites["playerbase"].x-=@sprites["playerbase"].bitmap.width/2 if @sprites["playerbase"].bitmap!=nil
    @sprites["playerbase"].y-=@sprites["playerbase"].bitmap.height if @sprites["playerbase"].bitmap!=nil
    pbAddSprite("enemybase",
       PokeBattle_SceneConstants::FOEBASEX,
       PokeBattle_SceneConstants::FOEBASEY,enemybase,@viewport)
    @sprites["enemybase"].x-=@sprites["enemybase"].bitmap.width/2 if @sprites["enemybase"].bitmap!=nil
    @sprites["enemybase"].y-=@sprites["enemybase"].bitmap.height/2 if @sprites["enemybase"].bitmap!=nil
    @sprites["battlebg"].z=0
    @sprites["playerbase"].z=1
    @sprites["enemybase"].z=1
  end
This piece of code does a couple different things:
  1. Decides the field effect based on the background of the battle (decided in the metadata)
  2. Makes the background load automaticaly without any problem
  3. Adds a variable which in this case is
    Ruby:
    $game_variables[29]
    which will help you override field effects in any battle, ignoring the battle background (I'll show in an example later)
  4. Adds a method for Water Field if you use one with
    Code:
    #if $PokemonGlobal.surfing 
    #  fieldbd = 21
    #  backdrop = "WaterSurface"
    #end
    Change the 21 for whichever number the Field is, and WaterSurface for the name of your background in Graphics/Backgrounds
Now, go to
Code:
PBEffects
and search for:

Code:
# These effects apply to the battle (i.e. both sides)
add,

Code:
Terrain     =  xx
Replace xx with whatever number you have afterwards, for me it's 13:



Don't forget to go to the metadata of the map and add the correct background:

Since we are going to do a Snow Field I'm using the Snow background.


Step 2: Basic Battle Boosts

In this step I will teach you how to boost specific types of moves, specific kind of moves (physical or special) and specific moves.

Since we went with a Snow Field for our example, I will continue to use that one, though I will take some creative liberty, so I can teach you how to do all of those kinds of things.

Let's start with Type Boosts, since we are on a Snow Field, lets boost Ice Type moves.

In PokeBattle_Move search for this piece of code:


Directly under it, lets start our Case $fieldeffectsbg.


Since Interior Field has no boosts or anything special about it, it won't appear anywhere if you're wondering.

Okay, so, once that is done, lets boost Ice type moves.

Ruby:
case $fieldeffectsbg
       when 1 # Snow Field
         if isConst?(type,PBTypes,:ICE)
              damagemult=(damagemult*1.5).round
              @battle.pbDisplay(_INTL("The cold powered up the attack!",opponent.pbThis))
         end
    end
The first line directly under when 1, checks the type of the move, in this case ICE, the line under that will multiply that moves power by x1.5, and the last line will pop up a message whenever that happens.
These messages don't really have any impact, and I guess you can delete them, but I feel like they are fairly important as it helps knowing what is being boosted or not.

Now, this code will boost any Ice Type moves, lets get a bit creative shall we?
Lets make grass moves weaker in this field, but ONLY, if the Pokémon using the Grass Type Move is grounded.

Ruby:
case $fieldeffectsbg
       when 1 # Snow Field
         if isConst?(type,PBTypes,:ICE)
              damagemult=(damagemult*1.5).round
              @battle.pbDisplay(_INTL("The cold powered up the attack!",opponent.pbThis))
         end
         if !attacker.isAirborne? && isConst?(type,PBTypes,:GRASS)
               damagemult=(damagemult*0.5).round
               @battle.pbDisplay(_INTL("The snow field made the attack weaker!",opponent.pbThis))
         end
    end
What we are doing here is basicaly checking if the used is Airborne, this mean checking if its a Flying Type, has the Levitate ability, is levitating because of moves like Magnet Rise, etc...

This way we have Ice Moves that have a 50% power boost, Grass moves on non-airborne Pokémon that have a 50% power decrease.
Now let's do Move category specific, either Physical or Special, you should be able to do it on your own now:
But here's my example, in this case Im buffing Special Water Type Moves, and decreasing physical Flying type moves.

Ruby:
         if isConst?(type,PBTypes,:FLYING) &&
             pbIsPhysical?(pbType(@type,attacker,opponent))
              damagemult=(damagemult*0.5).round
              @battle.pbDisplay(_INTL("The field weakened the attack!",opponent.pbThis))
         end
         if isConst?(type,PBTypes,:WATER) &&
             pbIsSpecial?(pbType(@type,attacker,opponent))
              damagemult=(damagemult*1.5).round
              @battle.pbDisplay(_INTL("The attack got cold!",opponent.pbThis))
         end
So that was the code for specific Move category and specific move types.
But now, lets go for specific moves.

In PokeBattle_Move search for:


Directly under it, start the $fieldeffectsbg case again.
For this part, lets buff all the "Wind" related moves I can think of.



With this all Wind moves are boosted by 50%, you can use the same method to make moves weaker too.

PS: If you're using default Essentials, your game probably doesn't have Fairy Wind, so it might cause an error pop up while testing, either add the move to the moves.txt pbs file, or delete that part from my example!

That should be it for this part then!

Step 3: Starting the field ingame

None of the first two steps will do anything without this one, I guess this should've been the second step then oops.

Anyway, this step is still kinda of confusing for me, but lets do this then.

In PokeBattle_Battle search for the line # Initialize Battle.
You should have this:

Now, lets add the start up battle message shall we?

Directly under that
Ruby:
end
add:

Ruby:
# Field Effects BEGIN UPDATE
    $fieldstartup = 0
    case $fieldeffectsbg
      when 1 # Snowy Field
       pbDisplayPaused(_INTL("The snow shines white in the ground!"))
      #when 2 # Forest Field
      #  pbDisplayPaused(_INTL("Trees surround the area!"))
    end
You don't really need the Forest Field part, but it's there as an example of how you should add more field effects, just keep on adding when x.

If you go test it in game, it should be good to go!



Now all you have to do is test some moves, to see if it all works correctly.



That's all I can think of doing for now, if theres other specific things that could be interesting to do Ill update this post.

Thank you!

Extra Stuff:
Abilities and moves starting up the field:


First, go in
Ruby:
PokeBattle_ActiveSideField
And search for:


You might have added more things to it, but it's not a problem.
In my case, right after
Ruby:
@effects[PBEffects::WonderRoom]      = 0
I will add:
Ruby:
@effects[PBEffects::Terrain]         = 0
Next go to
Code:
PokeBattle_Battle
, and find:

Directly above #Uproar, add:

Ruby:
# Terrain Moves
    if @field.effects[PBEffects::Terrain]>0
      terrain=[@field.effects[PBEffects::Terrain]].max
      terrain-=1
      @field.effects[PBEffects::Terrain] = terrain
      if terrain==0
        $fieldeffectsbg = $fieldbackup
        pbDisplay(_INTL("The terrain returned to normal."))
        pbChangeBGSprite
        PBDebug.log("[End of effect] Terrain ended")
      end
    end
This gives a coutdown system to the Terrain moves and Abilities, so that it changes back after x turns.

Now let's make a new move, called Snowy Terrain!
I'm gonna use Electric Terrain as the base, do the same, its way easier that way:

In PokeBattle_MoveEffects, goooo allllll theeee wayyyy dowwwnnn, and add:


Ruby:
################################################################################
# For 5 rounds, creates the snowy terrain effect
# (Snowy Terrain)
################################################################################
class PokeBattle_Move_159 < PokeBattle_Move
  def pbEffect(attacker,opponent,hitnum=0,alltargets=nil,showanimation=true)
    if @battle.field.effects[PBEffects::Terrain]>0
      @battle.pbDisplay(_INTL("But it failed!"))
      return -1
    end
    pbShowAnimation(@id,attacker,nil,hitnum,alltargets,showanimation)
    $fieldbackup = $fieldeffectsbg
    $tempfield = 1
    $fieldeffectsbg = $tempfield
    @battle.pbChangeBGSprite
    @battle.field.effects[PBEffects::Terrain]=5
    #@battle.field.effects[PBEffects::Terrain]=8 if attacker.hasWorkingItem(:TERRAINEXTENDER)
    @battle.pbDisplay(_INTL("The terrain was filled with white snow!"))
    return 0
  end
end
In this piece of code, we have $tempfield = 1, change the 1 with whatever the number of your field is.
We also have #@battle.field.effects[PBEffects::Terrain]=8 if attacker.hasWorkingItem(:TERRAINEXTENDER)
This checks if the user is holding an item that can extend the duration of terrain moves, if you have such an item, uncomment this line.

Before we go to abilities, quick side note, if you have Electric, Misty, Psychic and Grassy Terrain moves, do the same thing to them:

If you don't change their code too, you will be able to put the Snowy Field + Electric Terrain combo for example, you don't want that. (Unless that is a new mechanic you want to do? Up to you)

Next, abilities!!

In
Ruby:
PokeBattle_Battler
, find
Code:
if self.hasWorkingAbility(:DELTASTREAM)


Directly under it, add:
Ruby:
      if self.hasWorkingAbility(:SNOWYSURGE) && ($fieldeffectsbg!=1) # Snowy Field
        showAbilityMessage(self)
        $fieldbackup = $fieldeffectsbg
        $tempfield = 1
        $fieldeffectsbg = $tempfield
        @battle.pbChangeBGSprite
        @battle.field.effects[PBEffects::Terrain]=5
        #@battle.field.effects[PBEffects::Terrain]=8 if self.hasWorkingItem(:TERRAINEXTENDER)
        @battle.pbDisplay(_INTL("The terrain was filled with white snow!"))
        PBDebug.log("[#{pbThis}: Snowy Surge made Snowy Terrain]")
      end
Change $tempfield = 1 and ($fieldeffectsbg!=1) with the number of the field you want it to change to.
And that is it!
Don't forget to do one for Grassy Surge etc too if you don't have those yet.

Thank you. <o/
Credits
Amethyst
Blind Guardian
BIGFriv
Groniack
Author
BIGFriv
First release
Last update
Rating
0.00 star(s) 0 ratings

Latest updates

  1. Overhaul

    Overhauled the script a bit, so that it works better. Also added a section of how to make moves...
Top