Seen 2 Days Ago
Posted December 19th, 2020
20 posts
117 Days
So I've been practicing field effects using the Pokemon Reborn script as a base.

My question is how to add a second type to the attack depending on the field. (E.j: Smog doing POISON and FIRE damage on Burning Field)

I add this code in PokeBattle_Move, before the ´Move acurracy check´

 def pbTypeModMessages(type,attacker,opponent)
    return 8 if type<0
    typemod=pbTypeModifier(type,attacker,opponent)
    if typemod==0
      @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
    else
      return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
    end
    return typemod
    # Field Effect type changes go here
    
    typemod=FieldTypeChange(attacker,opponent,typemod,false)
    if typemod==0
      if @function==0x111
        return 1
      else            
        @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
        if (@function==0xC9 || @function==0xCA || @function==0xCB || @function==0xCC || @function==0xCD || @function==0xCE)
          @battle.scene.pbUnVanishSprite(attacker)
        end        
      end      
    end
    return typemod
  end
  
  #Add type to attack
  def FieldTypeChange(attacker,opponent,typemod,absorbtion=false)
    case $fieldeffectsbg
      when 4 # Burning Field
        if (id == PBMoves::SMACKDOWN || id == PBMoves::SMOG ||
         id == PBMoves::CLEARSMOG || id == PBMoves::THOUSANDARROWS)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.25).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
      end
  end

The script does not seem to run as it is not broken or applied.
I ask if anyone knows where I should check to make it work, or at least know if what i am doing is fine.
Male
Seen 8 Hours Ago
Posted 1 Week Ago
268 posts
2.5 Years
So I've been practicing field effects using the Pokemon Reborn script as a base.

My question is how to add a second type to the attack depending on the field. (E.j: Smog doing POISON and FIRE damage on Burning Field)

I add this code in PokeBattle_Move, before the ´Move acurracy check´

 def pbTypeModMessages(type,attacker,opponent)
    return 8 if type<0
    typemod=pbTypeModifier(type,attacker,opponent)
    if typemod==0
      @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
    else
      return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
    end
    return typemod
    # Field Effect type changes go here
    
    typemod=FieldTypeChange(attacker,opponent,typemod,false)
    if typemod==0
      if @function==0x111
        return 1
      else            
        @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
        if (@function==0xC9 || @function==0xCA || @function==0xCB || @function==0xCC || @function==0xCD || @function==0xCE)
          @battle.scene.pbUnVanishSprite(attacker)
        end        
      end      
    end
    return typemod
  end
  
  #Add type to attack
  def FieldTypeChange(attacker,opponent,typemod,absorbtion=false)
    case $fieldeffectsbg
      when 4 # Burning Field
        if (id == PBMoves::SMACKDOWN || id == PBMoves::SMOG ||
         id == PBMoves::CLEARSMOG || id == PBMoves::THOUSANDARROWS)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.25).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
      end
  end

The script does not seem to run as it is not broken or applied.
I ask if anyone knows where I should check to make it work, or at least know if what i am doing is fine.
Are you in v17? If you're in v18, I wouldn't recommend using Reborn as a base considering it's v15 and there's a big difference between those.

However, if you're in v17 or v16 I may be able to help here (the help I can provide is for v17, but v16 shouldn't be too different). (Note that the code here has a bunch of custom stuff from my game in terms of the specific field interactions, but you can obviously ignore those parts.)

Here's what my code looks like for "pbTypeModMessages":
Spoiler:
  def pbTypeModMessages(type,attacker,opponent)
    return 8 if type<0
    typemod=pbTypeModifier(type,attacker,opponent)
    typemod2= nil
    typemod3= nil
    # Field Type Effectiveness Changes
    if $fefieldeffect == 10
      if (isConst?(type,PBTypes,:POISON) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::POISON) && 
         opponent.pbHasType?(PBTypes::STEEL)
        typemod *= 2
      end
    end
    if $fefieldeffect == 22
      if (isConst?(type,PBTypes,:WATER) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::WATER) && 
         opponent.pbHasType?(PBTypes::WATER)
        typemod *= 2
      end
    end
    if $fefieldeffect == 24
      if isConst?(type,PBTypes,:DRAGON) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::DRAGON
        typemod = 8
      end
      if (isConst?(type,PBTypes,:GHOST) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::GHOST) && 
         opponent.pbHasType?(PBTypes::PSYCHIC)
        typemod = 0
      end
      if (isConst?(type,PBTypes,:BUG) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::BUG) && 
         opponent.pbHasType?(PBTypes::POISON)
        typemod *= 4
      end
      if (isConst?(type,PBTypes,:ICE) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::ICE) && 
         opponent.pbHasType?(PBTypes::FIRE)
        typemod *= 2
      end
      if (isConst?(type,PBTypes,:POISON) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::POISON) && 
         opponent.pbHasType?(PBTypes::BUG)
        typemod *= 2
      end
    end
    if $fefieldeffect == 29
      if (isConst?(type,PBTypes,:NORMAL) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::NORMAL) && 
         (opponent.pbHasType?(PBTypes::DARK) || opponent.pbHasType?(PBTypes::GHOST))
        typemod *= 2
      end
    end
    if $fefieldeffect == 31
      if (isConst?(type,PBTypes,:STEEL) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::STEEL) && 
         opponent.pbHasType?(PBTypes::DRAGON)
        typemod *= 2
      end
    end
    if $fefieldeffect == 34
      if (isConst?(type,PBTypes,:DARK) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::DARK) && 
         opponent.pbHasType?(PBTypes::PSYCHIC)
        typemod /= 2
      end
    end
    if $fefieldeffect == 40
      if (isConst?(type,PBTypes,:GHOST) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::GHOST) && 
         opponent.pbHasType?(PBTypes::NORMAL)
        typemod *= 2
      end
    end
    if id == PBMoves::CUT && opponent.pbHasType?(PBTypes::GRASS) &&
     $fefieldeffect == 33 && $fecounter > 0 
      typemod *= 2
    end   
    if $fefieldeffect == 42
      if (isConst?(type,PBTypes,:GRASS) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::GRASS) && 
         opponent.pbHasType?(PBTypes::STEEL)
        typemod *= 4
      end
      if (isConst?(type,PBTypes,:FAIRY) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::FAIRY) && 
         opponent.pbHasType?(PBTypes::STEEL)
        typemod *= 4
      end
      if (isConst?(type,PBTypes,:POISON) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::POISON) && 
         opponent.pbHasType?(PBTypes::GRASS)
        typemod /= 2
      end
      if (isConst?(type,PBTypes,:POISON) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::POISON) && 
         opponent.pbHasType?(PBTypes::FAIRY)
        typemod /= 4
      end
    end
    if $fefieldeffect == 45
      if (isConst?(type,PBTypes,:FIGHTING) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::FIGHTING) && 
         opponent.pbHasType?(PBTypes::BUG)
        typemod *= 4
      end
      if (isConst?(type,PBTypes,:FIGHTING) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::FIGHTING) && 
         opponent.pbHasType?(PBTypes::PSYCHIC)
        typemod *= 4
      end
      if (isConst?(type,PBTypes,:PSYCHIC) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::PSYCHIC) && 
         opponent.pbHasType?(PBTypes::FIGHTING)
        typemod /= 4
      end
    end
    if $fefieldeffect == 46
      if (isConst?(type,PBTypes,:ICE) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::ICE) && 
         opponent.pbHasType?(PBTypes::WATER)
        typemod *= 4
      end
    end
    if $fefieldeffect == 49
      if (isConst?(type,PBTypes,:GROUND) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::GROUND) && 
         opponent.pbHasType?(PBTypes::GRASS)
        typemod = 0
      end
      if (isConst?(type,PBTypes,:WATER) || FieldTypeChange(attacker,opponent,1,true) == PBTypes::WATER) && 
         opponent.pbHasType?(PBTypes::GROUND)
        typemod = 0
      end
    end
    if @battle.pbWeather==PBWeather::STRONGWINDS && (opponent.pbHasType?(PBTypes::FLYING) && 
       !opponent.effects[PBEffects::Roost]) && (isConst?(type,PBTypes,:ELECTRIC) || 
       isConst?(type,PBTypes,:ICE) || isConst?(type,PBTypes,:ROCK))
      typemod /= 2
    end
    if $fefieldeffect == 32 && opponent.hasWorkingAbility(:MULTISCALE) && 
       (isConst?(type,PBTypes,:FAIRY) || isConst?(type,PBTypes,:ICE) ||
       isConst?(type,PBTypes,:DRAGON)) && !opponent.moldbroken
      typemod /= 2
    end
    if $fefieldeffect == 22 && opponent.hasWorkingAbility(:MULTISCALE) && 
       (isConst?(type,PBTypes,:GRASS) || isConst?(type,PBTypes,:ELECTRIC)) && !opponent.moldbroken
      typemod /= 2
    end
    # Field Effect type changes go here
    typemod=FieldTypeChange(attacker,opponent,typemod,false)
    if typemod==0
      @battle.pbDisplay(_INTL("It doesn't affect {1}...",opponent.pbThis(true)))
    else
      return 0 if pbTypeImmunityByAbility(type,attacker,opponent)
    end
    return typemod
  end


And "FieldTypeChange":
Spoiler:
  # Adds an additional type to the attack
  def FieldTypeChange(attacker,opponent,typemod,absorbtion=false)
    case $fefieldeffect
      when 1 # Electric Field
        if (id == PBMoves::EXPLOSION || id == PBMoves::SELFDESTRUCT ||
         id == PBMoves::SMACKDOWN || id == PBMoves::SURF ||
         id == PBMoves::MUDDYWATER || id == PBMoves::HURRICANE ||
         id == PBMoves::THOUSANDARROWS)
          typemod2=pbTypeModifier(PBTypes::ELECTRIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ELECTRIC
        end
      when 3 # Misty Terrain
        if isConst?(type,PBTypes,:WATER)
          typemod2=pbTypeModifier(PBTypes::FAIRY,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FAIRY
        end
      when 4 # Dark Crystal Cavern
        if isConst?(type,PBTypes,:GHOST)
          typemod2=pbTypeModifier(PBTypes::DARK,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::DARK
        end
      when 5 # Chess Field
        if (id == PBMoves::STRENGTH || id == PBMoves::PSYCHIC ||
         id == PBMoves::ANCIENTPOWER)
          typemod2=pbTypeModifier(PBTypes::ROCK,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ROCK
        end
        if ($fecounter%6 == 2 || @battle.field.effects[PBEffects::PrevFECounter]%6 == 2 &&
           attacker.hasWorkingAbility(:SKILLLINK)) && @battle.doublebattle # Queen (Doubles)
          temptypemod = typemod
          temptypemod = 16 if typemod == 4
          temptypemod = 32 if typemod == 2
          temptypemod = 64 if typemod <= 1
          temptypemod = 4 if typemod == 16
          temptypemod = 2 if typemod == 32
          temptypemod = 1 if typemod == 64
          typemod = temptypemod
        end
      when 7 # Burning Field
        if (id == PBMoves::SMACKDOWN || id == PBMoves::THOUSANDARROWS || 
           id == PBMoves::ROCKSLIDE || id == PBMoves::SMOG ||
           id == PBMoves::CLEARSMOG)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
        if isConst?(type,PBTypes,:ROCK)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
      when 8 # Swamp Field
        if (id == PBMoves::SMACKDOWN)
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
        if isConst?(type,PBTypes,:GROUND)
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
      when 9 # Rainbow Field
        if isConst?(type,PBTypes,:NORMAL) && !pbIsPhysical?(pbType(@type,attacker,opponent))
          if attacker.hasWorkingAbility(:SKILLLINK)
            for i in 1...18 # Excludes Normal/Shadow/Fairy, but includes ???
              if i == PBTypes::QMARKS
                typemod2=pbTypeModifier(PBTypes::FAIRY,attacker,opponent)
                typemod3= ((typemod*typemod2) * 0.125).ceil
                typemod=typemod3
              else
                typemod2=pbTypeModifier(i,attacker,opponent)
                typemod3= ((typemod*typemod2) * 0.125).ceil
                typemod=typemod3
              end
            end
            typeChange=rand(20) # Purely for Type Effectiveness Display
          else
            randoms=[]
            [email protected](17) # 0 is Normal, 9 is ???, 18 is Shadow, 19 is Fairy
            if rand == PBTypes::QMARKS
              randoms.push(PBTypes::FAIRY)
            else
              randoms.push(rand)
            end
            typemod2=pbTypeModifier(randoms[0],attacker,opponent)
            typemod3= ((typemod*typemod2) * 0.125).ceil
            typemod=typemod3
            typeChange=randoms[0]
          end
        end
      when 10 # Corrosive Field
        if isConst?(type,PBTypes,:GRASS)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if (id == PBMoves::SMACKDOWN || id == PBMoves::MUDDYWATER ||
           id == PBMoves::WHIRLPOOL)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if isConst?(type,PBTypes,:GROUND)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
      when 11 # Corrosive Mist Field
        if isConst?(type,PBTypes,:FLYING) &&
        !pbIsPhysical?(pbType(@type,attacker,opponent))
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if (id == PBMoves::BUBBLE || id == PBMoves::BUBBLEBEAM ||
         id == PBMoves::ENERGYBALL || id == PBMoves::SPARKLINGARIA)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
      when 14 # Rocky Field
        if (id == PBMoves::ROCKCLIMB || id == PBMoves::EARTHQUAKE ||
         id == PBMoves::MAGNITUDE || id == PBMoves::STRENGTH ||
         id == PBMoves::BULLDOZE)
          typemod2=pbTypeModifier(PBTypes::ROCK,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ROCK
        end
      when 15 # Forest Field
        if (id == PBMoves::CUT || id == PBMoves::AIRSLASH ||
            id == PBMoves::SLASH || id == PBMoves::PSYCHOCUT ||
            id == PBMoves::FURYCUTTER || id == PBMoves::AIRCUTTER)
          typemod2=pbTypeModifier(PBTypes::GRASS,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::GRASS
        end
      when 16 # Volcanic Top
        if isConst?(type,PBTypes,:ROCK)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
        if (id == PBMoves::EXPLOSION || id == PBMoves::SELFDESTRUCT ||
           id == PBMoves::MAGNETBOMB || id == PBMoves::EGGBOMB ||
           id == PBMoves::DIVE || id == PBMoves::SEISMICTOSS ||
           id == PBMoves::SEISMICTOSS || id == PBMoves::DIG)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
        if (id == PBMoves::OMINOUSWIND || id == PBMoves::SILVERWIND ||
         id == PBMoves::RAZORWIND || id == PBMoves::ICYWIND ||
         id == PBMoves::GUST || id == PBMoves::TWISTER ||
         id == PBMoves::PRECIPICEBLADES || id == PBMoves::SMOG ||
         id == PBMoves::CLEARSMOG)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
      when 17 # Factory Field
        if attacker.hasWorkingAbility(:IRONFIST) && isPunchingMove?
          typemod2=pbTypeModifier(PBTypes::STEEL,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::STEEL
        end
      when 18 # Shortcircuit Field
        if (id == PBMoves::SURF || id == PBMoves::MUDDYWATER ||
         id == PBMoves::MAGNETBOMB || id == PBMoves::GYROBALL ||
         id == PBMoves::FLASHCANNON || id == PBMoves::GEARGRIND)
          typemod2=pbTypeModifier(PBTypes::ELECTRIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ELECTRIC
        end
        if isConst?(type,PBTypes,:STEEL) && attacker.hasWorkingAbility(:STEELWORKER)
          typemod2=pbTypeModifier(PBTypes::ELECTRIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ELECTRIC
        end        
      when 19 # Wasteland Field
        if (id == PBMoves::MUDBOMB || id == PBMoves::MUDSLAP ||
         id == PBMoves::MUDSHOT)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if isConst?(type,PBTypes,:PSYCHIC)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
      when 20 # Ashen Beach
        if (id == PBMoves::STRENGTH)
          typemod2=pbTypeModifier(PBTypes::PSYCHIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::PSYCHIC
        end
      when 22 # Underwater
        if isConst?(type,PBTypes,:GROUND)
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
      when 25 # Crystal Cavern
        if isConst?(type,PBTypes,:ROCK) || (id == PBMoves::JUDGMENT ||
           id == PBMoves::ROCKCLIMB || id == PBMoves::STRENGTH ||
           id == PBMoves::MULTIATTACK || id == PBMoves::PRISMATICLASER)
          if attacker.hasWorkingAbility(:SKILLLINK)
            crystalTypes = [PBTypes::WATER,PBTypes::GRASS,PBTypes::FIRE,PBTypes::PSYCHIC,
                            PBTypes::FAIRY,PBTypes::GHOST,PBTypes::ELECTRIC]
            for t in crystalTypes
              typemod2=pbTypeModifier(i,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
            end
            typeChange=crystalTypes[@battle.pbRandom(7)] # Purely for Type Effectiveness Display
          else
            randtype = @battle.pbRandom(7)
            case randtype
            when 0
              typemod2=pbTypeModifier(PBTypes::ELECTRIC,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::ELECTRIC
            when 1
              typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::WATER
            when 2
              typemod2=pbTypeModifier(PBTypes::GRASS,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::GRASS
            when 3
              typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::FIRE
            when 4
              typemod2=pbTypeModifier(PBTypes::PSYCHIC,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::PSYCHIC
            when 5
              typemod2=pbTypeModifier(PBTypes::FAIRY,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::FAIRY
            when 6
              typemod2=pbTypeModifier(PBTypes::GHOST,attacker,opponent)
              typemod3= ((typemod*typemod2) * 0.125).ceil
              typemod=typemod3
              typeChange=PBTypes::GHOST
            end
          end  
        end
      when 26 # Murkwater Surface
        if isConst?(type,PBTypes,:WATER) || isConst?(type,PBTypes,:GROUND)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if id == PBMoves::SLUDGEWAVE
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
      when 28 # Snowy Mountain
        if isConst?(type,PBTypes,:ROCK)
          typemod2=pbTypeModifier(PBTypes::ICE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ICE
        end
      when 29 # Holy Field
=begin
        if (id == PBMoves::MULTIPULSE)
         !pbIsPhysical?(pbType(@type,attacker,opponent)) # Rainbow Field
          randoms=[]
          rand=1+rand(17)
          randoms.push(rand)
          typemod2=pbTypeModifier(randoms[0],attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.25).ceil
          typemod=typemod3
          typeChange=randoms[0]
        end
=end
      when 31 # Fairy Tale
        if isConst?(type,PBTypes,:FIRE)
          typemod2=pbTypeModifier(PBTypes::DRAGON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::DRAGON
        end
      when 32 # Dragon's Den
        if (id == PBMoves::SMACKDOWN || id == PBMoves::THOUSANDARROWS)
          typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FIRE
        end
      when 34 # Starlight Arena
        if isConst?(type,PBTypes,:DARK)
          typemod2=pbTypeModifier(PBTypes::FAIRY,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FAIRY
        end
      when 36 # Inverse Field
        if !attacker.hasWorkingAbility([:SIMPLE,:UNAWARE,:AURABREAK,:INFILTRATOR]) && 
           !opponent.hasWorkingAbility([:SIMPLE,:UNAWARE,:AURABREAK])
          temptypemod = typemod
          temptypemod = 16 if typemod == 4
          temptypemod = 32 if typemod == 2
          temptypemod = 64 if typemod <= 1
          temptypemod = 4 if typemod == 16
          temptypemod = 2 if typemod == 32
          temptypemod = 1 if typemod == 64
          typemod = temptypemod
        end
      when 37 # Psychic Terrain
        if (id == PBMoves::STRENGTH || id == PBMoves::ANCIENTPOWER ||
         id == PBMoves::DRAGONPULSE|| id == PBMoves::WATERPULSE)
          typemod2=pbTypeModifier(PBTypes::PSYCHIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::PSYCHIC
        end
      when 39 # Angie
        if (id == PBMoves::SURF || id == PBMoves::WATERPULSE ||
         id == PBMoves::DARKPULSE || id == PBMoves::NIGHTSLASH ||
         id == PBMoves::HYDROPUMP|| id == PBMoves::MUDDYWATER)
          typemod2=pbTypeModifier(PBTypes::ICE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ICE
        end
      when 40 # Haunted
        if (id == PBMoves::FLAMECHARGE || id == PBMoves::FLAMEBURST ||
         id == PBMoves::FIRESPIN || id == PBMoves::INFERNO)
          typemod2=pbTypeModifier(PBTypes::GHOST,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::GHOST
        end
      when 41 # Corrupted Cave
        if (id == PBMoves::ROCKSLIDE || id == PBMoves::SMACKDOWN ||
         id == PBMoves::STONEEDGE|| id == PBMoves::ROCKTOMB)
          typemod2=pbTypeModifier(PBTypes::POISON,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::POISON
        end
        if (id == PBMoves::GUNKSHOT || id == PBMoves::SLUDGEWAVE)
          typemod2=pbTypeModifier(PBTypes::ROCK,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ROCK
        end
      when 43 # Sky Field
        if (id == PBMoves::DIVE || id == PBMoves::TWISTER)
          typemod2=pbTypeModifier(PBTypes::FLYING,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::FLYING
        end
      when 46 # Subzero
        if (id == PBMoves::GUST || id == PBMoves::RAZORWIND || id == PBMoves::SILVERWIND || id == PBMoves::OMINOUSWIND || id == PBMoves::FAIRYWIND)
          typemod2=pbTypeModifier(PBTypes::ICE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ICE
        end
        if isConst?(type,PBTypes,:GROUND)
          typemod2=pbTypeModifier(PBTypes::ICE,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::ICE
        end
      when 48 # Beach
        if (id == PBMoves::STRENGTH)
          typemod2=pbTypeModifier(PBTypes::PSYCHIC,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::PSYCHIC
        end
        if (id == PBMoves::MUDSHOT || id == PBMoves::MUDSLAP || id == PBMoves::MUDBOMB)
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
        if (id == PBMoves::MUDDYWATER)
          typemod2=pbTypeModifier(PBTypes::GROUND,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::GROUND
        end
      when 49 # Xeric Shrubland
        if isConst?(type,PBTypes,:ROCK)
          typemod2=pbTypeModifier(PBTypes::GROUND,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::GROUND
        end
        if isConst?(type,PBTypes,:ICE)
          typemod2=pbTypeModifier(PBTypes::WATER,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::WATER
        end
        if (id == PBMoves::ICYWIND || id == PBMoves::OMINOUSWIND || 
           id == PBMoves::SILVERWIND || id == PBMoves::RAZORWIND ||
           id == PBMoves::FAIRYWIND || id == PBMoves::AEROBLAST ||
           id == PBMoves::TWISTER || id == PBMoves::HURRICANE || id == PBMoves::GUST)
          typemod2=pbTypeModifier(PBTypes::GROUND,attacker,opponent)
          typemod3= ((typemod*typemod2) * 0.125).ceil
          typemod=typemod3
          typeChange=PBTypes::GROUND
        end
    end   
    if attacker.hasWorkingAbility(:KICKIGNITION) && isKickingMove? && !pbType == PBTypes::FIRE
      typemod2=pbTypeModifier(PBTypes::FIRE,attacker,opponent)
      typemod3= ((typemod*typemod2) * 0.125).ceil
      typemod=typemod3
      typeChange=PBTypes::FIRE
    end
    if absorbtion
      return typeChange
    else
      return typemod
    end
  end


I'm not sure what you mean by "I add this code in PokeBattle_Move, before the ´Move acurracy check´". I couldn't find any instance of "Move accuracy check" (or the misspelling you gave) in default Essentials or my code with field effects. If you're talking about where you're adding the definition for these methods, "pbTypeModMessages" already exists, and "FieldTypeChange" should go right after that (though I don't think the order of the definitions matter very much).

Let me know if you need any more help or if any of this doesn't make sense.

EDIT: Also note that pbUnVanishSprite (and pbVanishSprite) do not exist in Essentials v17 or later (not even sure if they originally existed in earlier versions), so make sure to get rid of those calls.