Help Problem with new Evolution method: Meltan Candy

Marina

Elite Trainer
Member
Posts
117
#1
Hello, I've successfully added two new Pokemon into my game: Meltan and Melmetal and added them into the pokemon.txt and I thought it would be kind of cool, if they'd evolve like in the original games in Pokemon GO where you can give him 400 Meltan Candies to evolve him into Melmetal. They didn't do that with Lets Go, Pikachu! & Let's Go, Eevee! So, I thought that kind of evolution would be kind of cool in a Pokémon Fangame. I'm using Essentials v.17.2.
The problem is that I get a syntaxError when I playtest my game, after these changes:

I went into the script editor in Pokemon_Evolution:

Ruby:
module PBEvolution
  Unknown           = 0 # Do not use
  Happiness         = 1
  HappinessDay      = 2
  HappinessNight    = 3
  Level             = 4
  Trade             = 5
  TradeItem         = 6
  Item              = 7
  AttackGreater     = 8
  AtkDefEqual       = 9
  DefenseGreater    = 10
  Silcoon           = 11
  Cascoon           = 12
  Ninjask           = 13
  Shedinja          = 14
  Beauty            = 15
  ItemMale          = 16
  ItemFemale        = 17
  DayHoldItem       = 18
  NightHoldItem     = 19
  HasMove           = 20
  HasInParty        = 21
  LevelMale         = 22
  LevelFemale       = 23
  Location          = 24
  TradeSpecies      = 25
  LevelDay          = 26
  LevelNight        = 27
  LevelDarkInParty  = 28
  LevelRain         = 29
  HappinessMoveType = 30
  MeltanBonbons     = 31 # 400 Meltan Candy to evolve Meltan
  Custom2           = 32
  Custom3           = 33
  Custom4           = 34
  Custom5           = 35

  EVONAMES=["Unknown",
     "Happiness","HappinessDay","HappinessNight","Level","Trade",
     "TradeItem","Item","AttackGreater","AtkDefEqual","DefenseGreater",
     "Silcoon","Cascoon","Ninjask","Shedinja","Beauty",
     "ItemMale","ItemFemale","DayHoldItem","NightHoldItem","HasMove",
     "HasInParty","LevelMale","LevelFemale","Location","TradeSpecies",
     "LevelDay","LevelNight","LevelDarkInParty","LevelRain","HappinessMoveType",
     "MeltanBonbons","Custom2","Custom3","Custom4","Custom5"
  ]

  # 0 = no parameter
  # 1 = Positive integer
  # 2 = Item internal name
  # 3 = Move internal name
  # 4 = Species internal name
  # 5 = Type internal name
  EVOPARAM=[0,    # Unknown (do not use)
     0,0,0,1,0,   # Happiness, HappinessDay, HappinessNight, Level, Trade
     2,2,1,1,1,   # TradeItem, Item, AttackGreater, AtkDefEqual, DefenseGreater
     1,1,1,1,1,   # Silcoon, Cascoon, Ninjask, Shedinja, Beauty
     2,2,2,2,3,   # ItemMale, ItemFemale, DayHoldItem, NightHoldItem, HasMove
     4,1,1,1,4,   # HasInParty, LevelMale, LevelFemale, Location, TradeSpecies
     1,1,1,1,5,   # LevelDay, LevelNight, LevelDarkInParty, LevelRain, HappinessMoveType
     2,1,1,1,1    # Custom 1-5, MeltanBonbons is 2 bc Item Internal Name
  ]
end

when PBEvolution::MeltanBonbons
return poke if isConst?(pokemon.item,PBItems,:MELTANBONBONS) && return true if !item || item<=400
return poke
end
end
# Add code for custom evolution type 1
# Add code for custom evolution type 1
when PBEvolution::Custom2
# Add code for custom evolution type 2
when PBEvolution::Custom3
# Add code for custom evolution type 3
when PBEvolution::Custom4
# Add code for custom evolution type 4
when PBEvolution::Custom5
# Add code for custom evolution type 5
end
return -1
end


Then for those who want to see my entire script Pokemon_Evolution:
Code:
module PBEvolution
  Unknown           = 0 # Do not use
  Happiness         = 1
  HappinessDay      = 2
  HappinessNight    = 3
  Level             = 4
  Trade             = 5
  TradeItem         = 6
  Item              = 7
  AttackGreater     = 8
  AtkDefEqual       = 9
  DefenseGreater    = 10
  Silcoon           = 11
  Cascoon           = 12
  Ninjask           = 13
  Shedinja          = 14
  Beauty            = 15
  ItemMale          = 16
  ItemFemale        = 17
  DayHoldItem       = 18
  NightHoldItem     = 19
  HasMove           = 20
  HasInParty        = 21
  LevelMale         = 22
  LevelFemale       = 23
  Location          = 24
  TradeSpecies      = 25
  LevelDay          = 26
  LevelNight        = 27
  LevelDarkInParty  = 28
  LevelRain         = 29
  HappinessMoveType = 30
  MeltanBonbons     = 31 # 400 Meltan Candies to evolve Meltan
  Custom2           = 32
  Custom3           = 33
  Custom4           = 34
  Custom5           = 35

  EVONAMES=["Unknown",
     "Happiness","HappinessDay","HappinessNight","Level","Trade",
     "TradeItem","Item","AttackGreater","AtkDefEqual","DefenseGreater",
     "Silcoon","Cascoon","Ninjask","Shedinja","Beauty",
     "ItemMale","ItemFemale","DayHoldItem","NightHoldItem","HasMove",
     "HasInParty","LevelMale","LevelFemale","Location","TradeSpecies",
     "LevelDay","LevelNight","LevelDarkInParty","LevelRain","HappinessMoveType",
     "MeltanBonbons","Custom2","Custom3","Custom4","Custom5"
  ]

  # 0 = no parameter
  # 1 = Positive integer
  # 2 = Item internal name
  # 3 = Move internal name
  # 4 = Species internal name
  # 5 = Type internal name
  EVOPARAM=[0,    # Unknown (do not use)
     0,0,0,1,0,   # Happiness, HappinessDay, HappinessNight, Level, Trade
     2,2,1,1,1,   # TradeItem, Item, AttackGreater, AtkDefEqual, DefenseGreater
     1,1,1,1,1,   # Silcoon, Cascoon, Ninjask, Shedinja, Beauty
     2,2,2,2,3,   # ItemMale, ItemFemale, DayHoldItem, NightHoldItem, HasMove
     4,1,1,1,4,   # HasInParty, LevelMale, LevelFemale, Location, TradeSpecies
     1,1,1,1,5,   # LevelDay, LevelNight, LevelDarkInParty, LevelRain, HappinessMoveType
     2,1,1,1,1    # Custom 1-5, MeltanBonbons is 2 bc Item Internal Name
  ]
end



#===============================================================================
# Evolution helper functions
#===============================================================================
def pbGetEvolvedFormData(species)
  ret=[]
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVONEXTFORM=0x00
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if (evo&_EVODATAMASK)==_EVONEXTFORM
           ret.push([evonib,level,poke])
         end
         i+=5
       end
     end
  }
  return ret
end

def pbGetPreviousForm(species)   # Unused
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if (evo&_EVODATAMASK)==_EVOPREVFORM
           return poke
         end
         i+=5
       end
     end
  }
  return species
end

def pbGetBabySpecies(species,item1=-1,item2=-1)
  ret=species
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if poke<=PBSpecies.maxValueF && (evo&_EVODATAMASK)==_EVOPREVFORM # evolved from
           if item1>=0 && item2>=0
             dexdata=pbOpenDexData
             pbDexDataOffset(dexdata,poke,54)
             incense=dexdata.fgetw
             dexdata.close
             ret=poke if item1==incense || item2==incense
           else
             ret=poke
           end
           break
         end
         i+=5
       end
     end
  }
  if ret!=species
    ret=pbGetBabySpecies(ret)
  end
  return ret
end

def pbGetMinimumLevel(species)
  ret=-1
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
    f.pos=(species-1)*8
    offset=f.fgetdw
    length=f.fgetdw
    if length>0
      f.pos=offset
      i=0; loop do break unless i<length
        evo=f.fgetb
        evonib=evo&_EVOTYPEMASK
        level=f.fgetw
        poke=f.fgetw
        if poke<=PBSpecies.maxValueF &&
           (evo&_EVODATAMASK)==_EVOPREVFORM && # evolved from
           [PBEvolution::Level,PBEvolution::LevelMale,
           PBEvolution::LevelFemale,PBEvolution::AttackGreater,
           PBEvolution::AtkDefEqual,PBEvolution::DefenseGreater,
           PBEvolution::Silcoon,PBEvolution::Cascoon,
           PBEvolution::Ninjask,PBEvolution::Shedinja,
           PBEvolution::LevelDay,PBEvolution::LevelNight,
           PBEvolution::LevelDarkInParty,PBEvolution::LevelRain].include?(evonib)
          ret=(ret==-1) ? level : [ret,level].min
          break
        end
        i+=5
      end
    end
  }
  return (ret==-1) ? 1 : ret
end

def pbEvoDebug   # Unused
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     for species in 1..PBSpecies.maxValueF
       f.pos=(species-1)*8
       offset=f.fgetdw
       length=f.fgetdw
       puts PBSpecies.getName(species)
       if length>0
         f.pos=offset
         i=0; loop do break unless i<length
           evo=f.fgetb
           evonib=evo&_EVOTYPEMASK
           level=f.fgetw
           poke=f.fgetw
           puts sprintf("type=%02X, data=%02X, name=%s, level=%d",
              evonib,evo&_EVODATAMASK,PBSpecies.getName(poke),level)
           if poke==0
             p f.eof?
             break
           end
           i+=5
         end
       end
     end
  }
end



#===============================================================================
# Evolution animation
#===============================================================================
class SpriteMetafile
  VIEWPORT      = 0
  TONE          = 1
  SRC_RECT      = 2
  VISIBLE       = 3
  X             = 4
  Y             = 5
  Z             = 6
  OX            = 7
  OY            = 8
  ZOOM_X        = 9
  ZOOM_Y        = 10
  ANGLE         = 11
  MIRROR        = 12
  BUSH_DEPTH    = 13
  OPACITY       = 14
  BLEND_TYPE    = 15
  COLOR         = 16
  FLASHCOLOR    = 17
  FLASHDURATION = 18
  BITMAP        = 19

  def length
    return @metafile.length
  end

  def [](i)
    return @metafile[i]
  end

  def initialize(viewport=nil)
    @metafile=[]
    @values=[
       viewport,
       Tone.new(0,0,0,0),Rect.new(0,0,0,0),
       true,
       0,0,0,0,0,100,100,
       0,false,0,255,0,
       Color.new(0,0,0,0),Color.new(0,0,0,0),
       0
    ]
  end

  def disposed?
    return false
  end

  def dispose
  end

  def flash(color,duration)
    if duration>0
      @values[FLASHCOLOR]=color.clone
      @values[FLASHDURATION]=duration
      @metafile.push([FLASHCOLOR,color])
      @metafile.push([FLASHDURATION,duration])
    end
  end

  def x
    return @values[X]
  end

  def x=(value)
    @values[X]=value
    @metafile.push([X,value])
  end

  def y
    return @values[Y]
  end

  def y=(value)
    @values[Y]=value
    @metafile.push([Y,value])
  end

  def bitmap
    return nil
  end

  def bitmap=(value)
    if value && !value.disposed?
      @values[SRC_RECT].set(0,0,value.width,value.height)
      @metafile.push([SRC_RECT,@values[SRC_RECT].clone])
    end
  end

  def src_rect
    return @values[SRC_RECT]
  end

  def src_rect=(value)
    @values[SRC_RECT]=value
   @metafile.push([SRC_RECT,value])
end

  def visible
    return @values[VISIBLE]
  end

  def visible=(value)
    @values[VISIBLE]=value
    @metafile.push([VISIBLE,value])
  end

  def z
    return @values[Z]
  end

  def z=(value)
    @values[Z]=value
    @metafile.push([Z,value])
  end

  def ox
    return @values[OX]
  end

  def ox=(value)
    @values[OX]=value
    @metafile.push([OX,value])
  end

  def oy
    return @values[OY]
  end

  def oy=(value)
    @values[OY]=value
    @metafile.push([OY,value])
  end

  def zoom_x
    return @values[ZOOM_X]
  end

  def zoom_x=(value)
    @values[ZOOM_X]=value
    @metafile.push([ZOOM_X,value])
  end

  def zoom_y
    return @values[ZOOM_Y]
  end

  def zoom_y=(value)
    @values[ZOOM_Y]=value
    @metafile.push([ZOOM_Y,value])
  end

  def zoom=(value)
    @values[ZOOM_X]=value
    @metafile.push([ZOOM_X,value])
    @values[ZOOM_Y]=value
    @metafile.push([ZOOM_Y,value])
  end

  def angle
    return @values[ANGLE]
  end

  def angle=(value)
    @values[ANGLE]=value
    @metafile.push([ANGLE,value])
  end

  def mirror
    return @values[MIRROR]
  end

  def mirror=(value)
    @values[MIRROR]=value
    @metafile.push([MIRROR,value])
  end

  def bush_depth
    return @values[BUSH_DEPTH]
  end

  def bush_depth=(value)
    @values[BUSH_DEPTH]=value
    @metafile.push([BUSH_DEPTH,value])
  end

  def opacity
    return @values[OPACITY]
  end

  def opacity=(value)
    @values[OPACITY]=value
    @metafile.push([OPACITY,value])
  end

  def blend_type
    return @values[BLEND_TYPE]
  end

  def blend_type=(value)
    @values[BLEND_TYPE]=value
    @metafile.push([BLEND_TYPE,value])
  end

  def color
    return @values[COLOR]
  end

  def color=(value)
    @values[COLOR]=value.clone
    @metafile.push([COLOR,@values[COLOR]])
  end

  def tone
    return @values[TONE]
  end

  def tone=(value)
    @values[TONE]=value.clone
    @metafile.push([TONE,@values[TONE]])
  end

  def update
    @metafile.push([-1,nil])
  end
end



class SpriteMetafilePlayer
  def initialize(metafile,sprite=nil)
    @metafile=metafile
    @sprites=[]
    @playing=false
    @index=0
    @sprites.push(sprite) if sprite
  end

  def add(sprite)
    @sprites.push(sprite)
  end

  def playing?
    return @playing
  end

  def play
    @playing=true
    @index=0
  end

  def update
    if @playing
      for j in @index...@metafile.length
        @index=j+1
        break if @metafile[j][0]<0
        code=@metafile[j][0]
        value=@metafile[j][1]
        for sprite in @sprites
          case code
          when SpriteMetafile::X; sprite.x=value
          when SpriteMetafile::Y; sprite.y=value
          when SpriteMetafile::OX; sprite.ox=value
          when SpriteMetafile::OY; sprite.oy=value
          when SpriteMetafile::ZOOM_X; sprite.zoom_x=value
          when SpriteMetafile::ZOOM_Y; sprite.zoom_y=value
          when SpriteMetafile::SRC_RECT; sprite.src_rect=value
          when SpriteMetafile::VISIBLE; sprite.visible=value
          when SpriteMetafile::Z; sprite.z=value # prevent crashes
          when SpriteMetafile::ANGLE; sprite.angle=(value==180) ? 179.9 : value
          when SpriteMetafile::MIRROR; sprite.mirror=value
          when SpriteMetafile::BUSH_DEPTH; sprite.bush_depth=value
          when SpriteMetafile::OPACITY; sprite.opacity=value
          when SpriteMetafile::BLEND_TYPE; sprite.blend_type=value
          when SpriteMetafile::COLOR; sprite.color=value
          when SpriteMetafile::TONE; sprite.tone=value
          end
        end
      end
      @playing=false if @index==@metafile.length
    end
  end
end



def pbSaveSpriteState(sprite)
  state=[]
  return state if !sprite || sprite.disposed?
  state[SpriteMetafile::BITMAP]     = sprite.x
  state[SpriteMetafile::X]          = sprite.x
  state[SpriteMetafile::Y]          = sprite.y
  state[SpriteMetafile::SRC_RECT]   = sprite.src_rect.clone
  state[SpriteMetafile::VISIBLE]    = sprite.visible
  state[SpriteMetafile::Z]          = sprite.z
  state[SpriteMetafile::OX]         = sprite.ox
  state[SpriteMetafile::OY]         = sprite.oy
  state[SpriteMetafile::ZOOM_X]     = sprite.zoom_x
  state[SpriteMetafile::ZOOM_Y]     = sprite.zoom_y
  state[SpriteMetafile::ANGLE]      = sprite.angle
  state[SpriteMetafile::MIRROR]     = sprite.mirror
  state[SpriteMetafile::BUSH_DEPTH] = sprite.bush_depth
  state[SpriteMetafile::OPACITY]    = sprite.opacity
  state[SpriteMetafile::BLEND_TYPE] = sprite.blend_type
  state[SpriteMetafile::COLOR]      = sprite.color.clone
  state[SpriteMetafile::TONE]       = sprite.tone.clone
  return state
end

def pbRestoreSpriteState(sprite,state)
  return if !state || !sprite || sprite.disposed?
  sprite.x          = state[SpriteMetafile::X]
  sprite.y          = state[SpriteMetafile::Y]
  sprite.src_rect   = state[SpriteMetafile::SRC_RECT]
  sprite.visible    = state[SpriteMetafile::VISIBLE]
  sprite.z          = state[SpriteMetafile::Z]
  sprite.ox         = state[SpriteMetafile::OX]
  sprite.oy         = state[SpriteMetafile::OY]
  sprite.zoom_x     = state[SpriteMetafile::ZOOM_X]
  sprite.zoom_y     = state[SpriteMetafile::ZOOM_Y]
  sprite.angle      = state[SpriteMetafile::ANGLE]
  sprite.mirror     = state[SpriteMetafile::MIRROR]
  sprite.bush_depth = state[SpriteMetafile::BUSH_DEPTH]
  sprite.opacity    = state[SpriteMetafile::OPACITY]
  sprite.blend_type = state[SpriteMetafile::BLEND_TYPE]
  sprite.color      = state[SpriteMetafile::COLOR]
  sprite.tone       = state[SpriteMetafile::TONE]
end

def pbSaveSpriteStateAndBitmap(sprite)
  return [] if !sprite || sprite.disposed?
  state=pbSaveSpriteState(sprite)
  state[SpriteMetafile::BITMAP]=sprite.bitmap
  return state
end

def pbRestoreSpriteStateAndBitmap(sprite,state)
  return if !state || !sprite || sprite.disposed?
  sprite.bitmap=state[SpriteMetafile::BITMAP]
  pbRestoreSpriteState(sprite,state)
  return state
end



class PokemonEvolutionScene
  private

  def pbGenerateMetafiles(s1x,s1y,s2x,s2y)
    sprite=SpriteMetafile.new
    sprite2=SpriteMetafile.new
    sprite.opacity=255
    sprite2.opacity=255
    sprite2.zoom=0.0
    sprite.ox=s1x
    sprite.oy=s1y
    sprite2.ox=s2x
    sprite2.oy=s2y
    alpha=0
    for j in 0...26
      sprite.color.red=255
      sprite.color.green=255
      sprite.color.blue=255
      sprite.color.alpha=alpha
      sprite.color=sprite.color
      sprite2.color=sprite.color
      sprite2.color.alpha=255
      sprite.update
      sprite2.update
      alpha+=5
    end
    totaltempo=0
    currenttempo=25
    maxtempo=7*Graphics.frame_rate
    while totaltempo<maxtempo
      for j in 0...currenttempo
        if alpha<255
          sprite.color.red=255
          sprite.color.green=255
          sprite.color.blue=255
          sprite.color.alpha=alpha
          sprite.color=sprite.color
          alpha+=10
        end
        sprite.zoom=[1.1*(currenttempo-j-1)/currenttempo,1.0].min
        sprite2.zoom=[1.1*(j+1)/currenttempo,1.0].min
        sprite.update
        sprite2.update
      end
      totaltempo+=currenttempo
      if totaltempo+currenttempo<maxtempo
        for j in 0...currenttempo
          sprite.zoom=[1.1*(j+1)/currenttempo,1.0].min
          sprite2.zoom=[1.1*(currenttempo-j-1)/currenttempo,1.0].min
          sprite.update
          sprite2.update
        end
      end
      totaltempo+=currenttempo
      currenttempo=[(currenttempo/1.5).floor,5].max
    end
    @metafile1=sprite
    @metafile2=sprite2
  end

  public

  def pbUpdate(animating=false)
    if animating      # Pokémon shouldn't animate during the evolution animation
      @sprites["background"].update
    else
      pbUpdateSpriteHash(@sprites)
    end
  end

  def pbUpdateNarrowScreen
    if @bgviewport.rect.y<20*4
      @bgviewport.rect.height-=2*4
      if @bgviewport.rect.height<Graphics.height-64
        @bgviewport.rect.y+=4
        @sprites["background"].oy=@bgviewport.rect.y
      end
    end
  end

  def pbUpdateExpandScreen
    if @bgviewport.rect.y>0
      @bgviewport.rect.y-=4
      @sprites["background"].oy=@bgviewport.rect.y
    end
    if @bgviewport.rect.height<Graphics.height
      @bgviewport.rect.height+=2*4
    end
  end

  def pbFlashInOut(canceled,oldstate,oldstate2)
    tone=0
    loop do
      Graphics.update
      pbUpdate(true)
      pbUpdateExpandScreen
      tone+=10
      @viewport.tone.set(tone,tone,tone,0)
      break if tone>=255
    end
    @bgviewport.rect.y=0
    @bgviewport.rect.height=Graphics.height
    @sprites["background"].oy=0
    if canceled
      pbRestoreSpriteState(@sprites["rsprite1"],oldstate)
      pbRestoreSpriteState(@sprites["rsprite2"],oldstate2)
      @sprites["rsprite1"].visible=true
      @sprites["rsprite1"].zoom_x=1.0
      @sprites["rsprite1"].zoom_y=1.0
      @sprites["rsprite1"].color.alpha=0
      @sprites["rsprite2"].visible=false
    else
      @sprites["rsprite1"].visible=false
      @sprites["rsprite2"].visible=true
      @sprites["rsprite2"].zoom_x=1.0
      @sprites["rsprite2"].zoom_y=1.0
      @sprites["rsprite2"].color.alpha=0
    end
    10.times do
      Graphics.update
      pbUpdate(true)
    end
    tone=255
    loop do
      Graphics.update
      pbUpdate
      tone=[tone-20,0].max
      @viewport.tone.set(tone,tone,tone,0)
      break if tone<=0
    end
  end

  def pbStartScreen(pokemon,newspecies)
    @pokemon = pokemon
    @newspecies = newspecies
    @sprites = {}
    @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @bgviewport.z = 99999
    @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z = 99999
    @msgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @msgviewport.z = 99999
    addBackgroundOrColoredPlane(@sprites,"background","evolutionbg",
       Color.new(248,248,248),@bgviewport)
    rsprite1 = PokemonSprite.new(@viewport)
    rsprite1.setOffset(PictureOrigin::Center)
    rsprite1.setPokemonBitmap(@pokemon,false)
    rsprite1.x = Graphics.width/2
    rsprite1.y = (Graphics.height-64)/2
    rsprite2 = PokemonSprite.new(@viewport)
    rsprite2.setOffset(PictureOrigin::Center)
    rsprite2.setPokemonBitmapSpecies(@pokemon,@newspecies,false)
    rsprite2.x       = rsprite1.x
    rsprite2.y       = rsprite1.y
    rsprite2.opacity = 0
    @sprites["rsprite1"] = rsprite1
    @sprites["rsprite2"] = rsprite2
    pbGenerateMetafiles(rsprite1.ox,rsprite1.oy,rsprite2.ox,rsprite2.oy)
    @sprites["msgwindow"] = Kernel.pbCreateMessageWindow(@msgviewport)
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  # Closes the evolution screen.
  def pbEndScreen
    Kernel.pbDisposeMessageWindow(@sprites["msgwindow"])
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
    @bgviewport.dispose
    @msgviewport.dispose
  end

  # Opens the evolution screen
  def pbEvolution(cancancel=true)
    metaplayer1 = SpriteMetafilePlayer.new(@metafile1,@sprites["rsprite1"])
    metaplayer2 = SpriteMetafilePlayer.new(@metafile2,@sprites["rsprite2"])
    metaplayer1.play
    metaplayer2.play
    pbBGMStop
    pbPlayCry(@pokemon)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("\\se[]What?\r\n{1} is evolving!\\^",@pokemon.name)) { pbUpdate }
    Kernel.pbMessageWaitForInput(@sprites["msgwindow"],100,true) { pbUpdate }
    pbPlayDecisionSE
    oldstate  = pbSaveSpriteState(@sprites["rsprite1"])
    oldstate2 = pbSaveSpriteState(@sprites["rsprite2"])
    pbMEPlay("Evolution start")
    pbBGMPlay("Evolution")
    canceled = false
    begin
      pbUpdateNarrowScreen
      metaplayer1.update
      metaplayer2.update
      Graphics.update
      Input.update
      pbUpdate(true)
      if Input.trigger?(Input::B) && cancancel
        pbBGMStop
        pbPlayCancelSE
        canceled = true
        break
      end
    end while metaplayer1.playing? && metaplayer2.playing?
    pbFlashInOut(canceled,oldstate,oldstate2)
    if canceled
      Kernel.pbMessageDisplay(@sprites["msgwindow"],
         _INTL("Huch\r\n{1} entwickelte sich nicht weiter!",@pokemon.name)) { pbUpdate }
    else
      pbEvolutionSuccess
    end
  end

  def pbEvolutionSuccess
    # Play cry of evolved species
    frames = pbCryFrameLength(@newspecies,@pokemon.form)
    pbBGMStop
    pbPlayCrySpecies(@newspecies,@pokemon.form)
    frames.times do
      Graphics.update
      pbUpdate
    end
    # Success jingle/message
    pbMEPlay("Evolution success")
    newspeciesname = PBSpecies.getName(@newspecies)
    oldspeciesname = PBSpecies.getName(@pokemon.species)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("\\se[]Glückwunsch! Dein {1} wurde zu einem {2}!\\wt[80]",
       @pokemon.name,newspeciesname)) { pbUpdate }
    @sprites["msgwindow"].text = ""
    # Check for consumed item and Pokémon duplication (i.e. Shedinja)
    removeItem = false
    createSpecies = pbCheckEvolutionEx(@pokemon){|pokemon,evonib,level,poke|
       case evonib
       when PBEvolution::Shedinja
         next poke if $PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL))
       when PBEvolution::TradeItem,PBEvolution::DayHoldItem,PBEvolution::NightHoldItem
         removeItem = true if poke==@newspecies   # Item is now consumed
       end
       next -1
    }
    @pokemon.setItem(0) if removeItem
    # Modify Pokémon to make it evolved
    @pokemon.species = @newspecies
    @pokemon.name    = newspeciesname if @pokemon.name==oldspeciesname
    @pokemon.form    = 0 if isConst?(@pokemon.species,PBSpecies,:MOTHIM)
    @pokemon.calcStats
    # See and own evolved species
    $Trainer.seen[@newspecies]  = true
    $Trainer.owned[@newspecies] = true
    pbSeenForm(@pokemon)
    # Learn moves upon evolution for evolved species
    movelist = @pokemon.getMoveList
    for i in movelist
      if i[0]==0 || i[0]==@pokemon.level          # Learned a new move
        pbLearnMove(@pokemon,i[1],true) { pbUpdate }
      end
    end
    # Duplicate Pokémon (i.e. Shedinja)
    if createSpecies>0 && $Trainer.party.length<6
      newpokemon = @pokemon.clone
      newpokemon.species = createSpecies
      newpokemon.name    = PBSpecies.getName(createSpecies)
      newpokemon.iv      = @pokemon.iv.clone
      newpokemon.ev      = @pokemon.ev.clone
      newpokemon.markings = 0
      newpokemon.ballused = 0
      newpokemon.setItem(0)
      newpokemon.clearAllRibbons
      newpokemon.calcStats
      newpokemon.heal
      # Add duplicate Pokémon to party
      $Trainer.party.push(newpokemon)
      # See and own duplicate Pokémon
      $Trainer.seen[createSpecies]  = true
      $Trainer.owned[createSpecies] = true
      pbSeenForm(newpokemon)
      # Consume Poké Ball
      $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
    end
  end
end



#===============================================================================
# Evolution methods
#===============================================================================
def pbMiniCheckEvolution(pokemon,evonib,level,poke)
  case evonib
  when PBEvolution::Happiness
    return poke if pokemon.happiness>=220
  when PBEvolution::HappinessDay
    return poke if pokemon.happiness>=220 && PBDayNight.isDay?
  when PBEvolution::HappinessNight
    return poke if pokemon.happiness>=220 && PBDayNight.isNight?
  when PBEvolution::HappinessMoveType
    if pokemon.happiness>=220
      for m in pokemon.moves
        return poke if m.id>0 && m.type==level
      end
    end
  when PBEvolution::Level
    return poke if pokemon.level>=level
  when PBEvolution::LevelDay
    return poke if pokemon.level>=level && PBDayNight.isDay?
  when PBEvolution::LevelNight
    return poke if pokemon.level>=level && PBDayNight.isNight?
  when PBEvolution::LevelMale
    return poke if pokemon.level>=level && pokemon.isMale?
  when PBEvolution::LevelFemale
    return poke if pokemon.level>=level && pokemon.isFemale?
  when PBEvolution::AttackGreater  # Hitmonlee
    return poke if pokemon.level>=level && pokemon.attack>pokemon.defense
  when PBEvolution::AtkDefEqual    # Hitmontop
    return poke if pokemon.level>=level && pokemon.attack==pokemon.defense
  when PBEvolution::DefenseGreater # Hitmonchan
    return poke if pokemon.level>=level && pokemon.attack<pokemon.defense
  when PBEvolution::Silcoon
    return poke if pokemon.level>=level && (((pokemon.personalID>>16)&0xFFFF)%10)<5
  when PBEvolution::Cascoon
    return poke if pokemon.level>=level && (((pokemon.personalID>>16)&0xFFFF)%10)>=5
  when PBEvolution::Ninjask
    return poke if pokemon.level>=level
  when PBEvolution::Shedinja
    return -1
  when PBEvolution::DayHoldItem
    return poke if pokemon.item==level && PBDayNight.isDay?
  when PBEvolution::NightHoldItem
    return poke if pokemon.item==level && PBDayNight.isNight?
  when PBEvolution::HasMove
    for m in pokemon.moves
      return poke if m.id==level
    end
  when PBEvolution::HasInParty
    for i in $Trainer.pokemonParty
      return poke if i.species==level
    end
  when PBEvolution::LevelDarkInParty
    if pokemon.level>=level
      for i in $Trainer.pokemonParty
        return poke if i.hasType?(:DARK)
      end
    end
  when PBEvolution::Location
    return poke if $game_map.map_id==level
  when PBEvolution::LevelRain
    if pokemon.level>=level
      if $game_screen && ($game_screen.weather==PBFieldWeather::Rain ||
                          $game_screen.weather==PBFieldWeather::HeavyRain ||
                          $game_screen.weather==PBFieldWeather::Storm)
        return poke
      end
    end
  when PBEvolution::Beauty   # Feebas
    return poke if pokemon.beauty>=level
  when PBEvolution::Trade, PBEvolution::TradeItem, PBEvolution::TradeSpecies
    return -1
  when PBEvolution::MeltanBonbons
    return poke if isConst?(pokemon.item,PBItems,:MELTANBONBONS) && return true if !item || item<=400
return poke
end
end
    # Add code for custom evolution type 1
    # Add code for custom evolution type 1
  when PBEvolution::Custom2
    # Add code for custom evolution type 2
  when PBEvolution::Custom3
    # Add code for custom evolution type 3
  when PBEvolution::Custom4
    # Add code for custom evolution type 4
  when PBEvolution::Custom5
    # Add code for custom evolution type 5
  end
  return -1
end

def pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
  # Checks for when an item is used on the Pokémon (e.g. an evolution stone)
  case evonib
  when PBEvolution::Item
    return poke if level==item
  when PBEvolution::ItemMale
    return poke if level==item && pokemon.isMale?
  when PBEvolution::ItemFemale
    return poke if level==item && pokemon.isFemale?
  end
  return -1
end

# Checks whether a Pokemon can evolve now. If a block is given, calls the block
# with the following parameters:
#  Pokemon to check; evolution type; level or other parameter; ID of the new Pokemon species
def pbCheckEvolutionEx(pokemon)
  return -1 if pokemon.species<=0 || pokemon.egg?
  return -1 if isConst?(pokemon.item,PBItems,:EVERSTONE)
  return -1 if isConst?(pokemon.species,PBSpecies,:PICHU) && pokemon.form==1
  ret=-1
  for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form))
    ret = yield pokemon,form[0],form[1],form[2]
    break if ret>0
  end
  return ret
end

# Checks whether a Pokemon can evolve now. If an item is used on the Pokémon,
# checks whether the Pokemon can evolve with the given item.
def pbCheckEvolution(pokemon,item=0)
  if item==0
    return pbCheckEvolutionEx(pokemon){|pokemon,evonib,level,poke|
       next pbMiniCheckEvolution(pokemon,evonib,level,poke)
    }
  else
    return pbCheckEvolutionEx(pokemon){|pokemon,evonib,level,poke|
       next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
    }
  end
end

I think that if we help each other, we can accomplish much more than doing it alone. And I just wanted to add a new evolution method, where Meltan needs 400 Meltan Candies to evolve into Melmetal.
 
Last edited:

NettoHikari

Novice
Member
Posts
23
#2
If you get a syntax error, you should always post the specific error message along with the code you changed because that provides a better starting point for locating the error. That said, I do see some syntax errors in the last section (lines 930 - 947). You put two "return" statements in the same line, and inside a conditional, which is not allowed, and you put an extra "end" where there shouldn't be one.

I also can't tell the exact situation you want the evolution to happen in. Are you checking if the Pokemon has 400 Meltan Bonbons? Because a Pokemon can only carry one at a time, so the Trainer can't "give" a Pokemon more than one candy. I assume you want to check if the bag has at least 400 Meltan Bonbons and remove those if that's true.

Replace lines 930-935 (the first six lines in that section):
Code:
  when PBEvolution::MeltanBonbons
    return poke if isConst?(pokemon.item,PBItems,:MELTANBONBONS) && return true if !item || item<=400
return poke
end
end
    # Add code for custom evolution type 1
with this:
Code:
# Add code for custom evolution type 1
when PBEvolution::MeltanBonbons
    if $PokemonBag.pbQuantity(:MELTANBONBONS) >= 400
        $PokemonBag.pbDeleteItem(:MELTANBONBONS, 400)
        return poke
    end
I hope this at least fixes your syntax error. Let me know if you wanted the condition to be slightly different or so.
 

Marina

Elite Trainer
Member
Posts
117
#3
I tried it out. I've added the script and the error is no longer displayed. I also added the Battlers sprites, the Icons and the following Pokémon character sprites of Meltan and Melmetal. But when I change my party from eevee to meltan, then I still have eevee following the player around instead of meltan. Meltan appears following the player just when entering a new map or when entering a house.

My problem now is that I added Meltan into my Team through debug mode and added x400 Meltan Bonbons (Candies) into the bag. But nothing happened. It doesn't evolve into Melmetal. Maybe because I changed the Bag pockets in my script editor:

Code:
#===============================================================================
# * The names of each pocket of the Bag. Leave the first entry blank.
# * The maximum number of slots per pocket (-1 means infinite number). Ignore
#      the first number (0).
# * The maximum number of items each slot in the Bag can hold.
# * Whether each pocket in turn auto-sorts itself by item ID number. Ignore the
#      first entry (the 0).
#===============================================================================
def pbPocketNames; return ["",
   _INTL("Items"), # Items
   _INTL("Medizintasche"), #Medicine Pocket
   _INTL("Fangtasche"), #Catching Pocket
   _INTL("TM-Box"), #TM Case
   _INTL("Beerentasche"), #Berry Pocket (aka Berry Pouch)
   _INTL("Brieftasche"), #Mail Pocket
   _INTL("Kampftasche"), #Battle Pocket
   _INTL("Basisitemtasche"), #Key Items Pocket
   _INTL("Pokémon Box"), # Pokémon Box
   _INTL("Stärkungstasche"), # Power-Up Pocket
   _INTL("Bonbonglas"), # Candy Jar
   _INTL ("Klamottenkoffer") # Clothing Trunk

]; end
MAXPOCKETSIZE  = [0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]
BAGMAXPERSLOT  = 999
POCKETAUTOSORT = [0,false,false,false,true,true,false,false,false,false,false,false,false]

everything that's inside the hashtag is just the english translation of the pocket, which I didn't wrote in my script editor, just here - so you know what those means. I've also added all 12 backgrounds of the bag and I just don't know how to configure them to show the candies, clothings in those pocket's, but I'll leave that for later when I post it in the forum.

I'm thinking that maybe Meltan doesn't evolve into Melmetal because it has nothing written in the pbs files:

Code:
#-------------------------------
[701]
Name=Meltan
InternalName=MELTAN
Type1=STEEL
Type2=
BaseStats=46,65,65,34,55,35
GenderRate=Genderless
GrowthRate=MediumSlow
BaseEXP=101
EffortPoints=1,0,0,0,0,0
Rareness=3
Happiness=70
Abilities=MAGNETPULL
HiddenAbility=
Moves=1,HARDEN,1,HEADBUTT,9,TAILWHIP,18,THUNDERWAVE,27,THUNDERSHOCK,36,ACIDARMOR,45,FLASHCANNON
Compatibility=Undiscovered
StepsToHatch=120
Height=0.2
Weight=8.0
Color=Gray
Shape=1
Habitat=Rare
RegionalNumbers=3,233
Kind=Mutter
Pokedex=Sein Körper besteht aus geschmolzenem Stahl. Es bringt Eisen und andere Metalle im Boden zum Schmelzen, um sie dann zu absorbieren.
BattlerPlayerY=0
BattlerEnemyY=14
BattlerAltitude=0
Evolutions=
#-------------------------------
[702]
Name=Melmetal
InternalName=MELMETAL
Type1=STEEL
Type2=
BaseStats=46,65,65,34,55,35
GenderRate=Genderless
GrowthRate=MediumSlow
BaseEXP=101
EffortPoints=1,0,0,0,0,0
Rareness=3
Happiness=70
Abilities=MAGNETPULL
HiddenAbility=
Moves=1,HARDEN,1,HEADBUTT,9,TAILWHIP,18,THUNDERWAVE,27,THUNDERSHOCK,36,ACIDARMOR,45,FLASHCANNON
Compatibility=Undiscovered
StepsToHatch=120
Height=0.2
Weight=8.0
Color=Gray
Shape=1
Habitat=Rare
RegionalNumbers=3,233
Kind=Mutter
Pokedex=Sein Körper besteht aus geschmolzenem Stahl. Es bringt Eisen und andere Metalle im Boden zum Schmelzen, um sie dann zu absorbieren.
BattlerPlayerY=0
BattlerEnemyY=14
BattlerAltitude=0
Evolutions=

Code:
700,MELTANBONBONS,Meltan Bonbon,Meltan Bonbons,1,4800,"Ein Bonbon, das voller Energie steckt. Erhöht dauerhaft sämtliche Statuswerte eines bestimmten Pokémon.",1,0,0

I hope somebody can help me with this thanks in advance.
 

Marina

Elite Trainer
Member
Posts
117
#5
I added the line: Evolutions=MELMETAL,MeltanBonbons into pokemon.txt, but following error appears:

Code:
---------------------------
Pokémon Essentials
---------------------------
[Pokémon Essentials version 17.2]

Exception: RuntimeError

Message: Undefined value  in PBItems

File PBS/pokemon.txt, section 0, key Evolutions





Compiler:418:in `checkEnumField'

Compiler:403:in `csvEnumField!'

Compiler:1856:in `pbCompilePokemonData'

Compiler:1850:in `each'

Compiler:1850:in `pbCompilePokemonData'

Compiler:1847:in `each'

Compiler:1847:in `pbCompilePokemonData'

Compiler:4392:in `pbCompileAllData'

Compiler:4515



This exception was logged in

C:\Users\Users\Saved Games\Pokémon Essentials\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK 
---------------------------

The error shows up because "MELTANBONBONS" is written like "MeltanBonbons" (the evolution method) and the evolution method can't be inside pokemon.txt, so I replaced that with "Evolutions=MELMETAL,DayHoldItem,MELTANBONBONS


I wanted to use HoldItem but it doesn't exist. So, I used DayHoldItem, and MELTANBONBONS are the Internal Name of the Item"Meltan Candies" I will try it out now with this, hope it works.

PS: I downloaded the Meltan Cry and named it 701Cry and put it inside SE/Cry folder, I added Meltan into my Party and when I click on Summary his Cry is really too quiet, silent... I have redownload it again and try to make it louder or try to find another youtube video...

Edit: I changed the evolution in pokemon.txt -> Evolutions=MELMETAL,Item,MELTANBONBONS
and added ,1,0,7 in the items.txt, I added Melmetal Icons too but its to large. The result:
http://prntscr.com/nur48l
 
Last edited:

WolfPP

Discord Wolf#1235
Member
Posts
91
#6
Hmm, we can make a game switch for this case. Like:
Code:
  when PBEvolution::ItemQuantity
    return poke if $game_switches[ItemQuantity]
Also, in some script we need to put:
Code:
if $PokemonBag.pbHasItem?(:MELTANCANDY) && $PokemonBag.pbQuantity(:MELTANCANDY)>=400
  $game_switches[ItemQuantity]=true
else
  $game_switches[ItemQuantity]=false
end

All right, i made this code:
Into 'Pokemon_Evolution' add:
Code:
  ItemQuantity      = 32
Inside 'EVONAMES', add a new one, "ItemQuantity". Then, inside 'EVOPARAM' add "0" to that code.

Now, inside 'def pbEvolutionSuccess', below code to Shedinja ('# Duplicate Pokémon (i.e. Shedinja)'), add after the end, like this:
Code:
    # Duplicate Pokémon (i.e. Shedinja)
    if createSpecies>0 && $Trainer.party.length<6
      newpokemon = @pokemon.clone
      newpokemon.species = createSpecies
      newpokemon.name    = PBSpecies.getName(createSpecies)
      newpokemon.iv      = @pokemon.iv.clone
      newpokemon.ev      = @pokemon.ev.clone
      newpokemon.markings = 0
      newpokemon.ballused = 0
      newpokemon.setItem(0)
      newpokemon.clearAllRibbons
      newpokemon.calcStats
      newpokemon.heal
      # Add duplicate Pokémon to party
      $Trainer.party.push(newpokemon)
      # See and own duplicate Pokémon
      $Trainer.seen[createSpecies]  = true
      $Trainer.owned[createSpecies] = true
      pbSeenForm(newpokemon)
      # Consume Poké Ball
      $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
    end
    if isConst?(@pokemon.species,PBSpecies,:MELMETAL)
      $PokemonBag.pbDeleteItemToEvolve(getConst(PBItems,:MELTANCANDY))
    end

Now, inside '
def pbMiniCheckEvolution(pokemon,evonib,level,poke)', add:
Code:
  when PBEvolution::ItemQuantity
    return poke if $PokemonBag.pbHasItemQuantityToEvolve?(:MELTANCANDY)
Finally, inside 'PItem_Bag' script make a new def to Quantity:
Code:
  def pbHasItemQuantityToEvolve?(item)
    return pbQuantity(item)>=400
  end
Same to Delete Item:
Code:
  def pbDeleteItemToEvolve(item,qty=400)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length if maxsize<0
    ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty)
    return ret
  end
P.S: You need to have 400 MELTANCANDY into your Bag, also you need to level up using Rare Candy or fight against a other pokemon. To the item, i copied like RARECANDY works only into item.txt
 
Last edited:

Marina

Elite Trainer
Member
Posts
117
#7
Hmm, we can make a game switch for this case. Like:
Code:
  when PBEvolution::ItemQuantity
    return poke if $game_switches[ItemQuantity]
Also, in some script we need to put:
Code:
if $PokemonBag.pbHasItem?(:MELTANCANDY) && $PokemonBag.pbQuantity(:MELTANCANDY)>=400
  $game_switches[ItemQuantity]=true
else
  $game_switches[ItemQuantity]=false
end

All right, i made this code:
Into 'Pokemon_Evolution' add:
Code:
  ItemQuantity      = 32
Inside 'EVONAMES', add a new one, "ItemQuantity". Then, inside 'EVOPARAM' add "0" to that code.

Now, inside 'def pbEvolutionSuccess', below code to Shedinja ('# Duplicate Pokémon (i.e. Shedinja)'), add after the end, like this:
Code:
    # Duplicate Pokémon (i.e. Shedinja)
    if createSpecies>0 && $Trainer.party.length<6
      newpokemon = @pokemon.clone
      newpokemon.species = createSpecies
      newpokemon.name    = PBSpecies.getName(createSpecies)
      newpokemon.iv      = @pokemon.iv.clone
      newpokemon.ev      = @pokemon.ev.clone
      newpokemon.markings = 0
      newpokemon.ballused = 0
      newpokemon.setItem(0)
      newpokemon.clearAllRibbons
      newpokemon.calcStats
      newpokemon.heal
      # Add duplicate Pokémon to party
      $Trainer.party.push(newpokemon)
      # See and own duplicate Pokémon
      $Trainer.seen[createSpecies]  = true
      $Trainer.owned[createSpecies] = true
      pbSeenForm(newpokemon)
      # Consume Poké Ball
      $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
    end
    if isConst?(@pokemon.species,PBSpecies,:MELMETAL)
      $PokemonBag.pbDeleteItemToEvolve(getConst(PBItems,:MELTANCANDY))
    end

Now, inside '
def pbMiniCheckEvolution(pokemon,evonib,level,poke)', add:
Code:
  when PBEvolution::ItemQuantity
    return poke if $PokemonBag.pbHasItemQuantityToEvolve?(:MELTANCANDY)
Finally, inside 'PItem_Bag' script make a new def to Quantity:
Code:
  def pbHasItemQuantityToEvolve?(item)
    return pbQuantity(item)>=400
  end
Same to Delete Item:
Code:
  def pbDeleteItemToEvolve(item,qty=400)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length if maxsize<0
    ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty)
    return ret
  end
P.S: You need to have 400 MELTANCANDY into your Bag, also you need to level up using Rare Candy or fight against a other pokemon. To the item, i copied like RARECANDY works only into item.txt
I've got this Syntax Error after adding your code:



This is how I added the Code:

Code:
module PBEvolution
  Unknown           = 0 # Do not use
  Happiness         = 1
  HappinessDay      = 2
  HappinessNight    = 3
  Level             = 4
  Trade             = 5
  TradeItem         = 6
  Item              = 7
  AttackGreater     = 8
  AtkDefEqual       = 9
  DefenseGreater    = 10
  Silcoon           = 11
  Cascoon           = 12
  Ninjask           = 13
  Shedinja          = 14
  Beauty            = 15
  ItemMale          = 16
  ItemFemale        = 17
  DayHoldItem       = 18
  NightHoldItem     = 19
  HasMove           = 20
  HasInParty        = 21
  LevelMale         = 22
  LevelFemale       = 23
  Location          = 24
  TradeSpecies      = 25
  LevelDay          = 26
  LevelNight        = 27
  LevelDarkInParty  = 28
  LevelRain         = 29
  HappinessMoveType = 30
  MeltanBonbons     = 31
  ItemQuantity      = 32
  Custom3           = 33
  Custom4           = 34
  Custom5           = 35

  EVONAMES=["Unknown",
     "Happiness","HappinessDay","HappinessNight","Level","Trade",
     "TradeItem","Item","AttackGreater","AtkDefEqual","DefenseGreater",
     "Silcoon","Cascoon","Ninjask","Shedinja","Beauty",
     "ItemMale","ItemFemale","DayHoldItem","NightHoldItem","HasMove",
     "HasInParty","LevelMale","LevelFemale","Location","TradeSpecies",
     "LevelDay","LevelNight","LevelDarkInParty","LevelRain","HappinessMoveType",
     "MeltanBonbons","ItemQuantity","Custom3","Custom4","Custom5"
  ]

  # 0 = no parameter
  # 1 = Positive integer
  # 2 = Item internal name
  # 3 = Move internal name
  # 4 = Species internal name
  # 5 = Type internal name
  EVOPARAM=[0,    # Unknown (do not use)
     0,0,0,1,0,   # Happiness, HappinessDay, HappinessNight, Level, Trade
     2,2,1,1,1,   # TradeItem, Item, AttackGreater, AtkDefEqual, DefenseGreater
     1,1,1,1,1,   # Silcoon, Cascoon, Ninjask, Shedinja, Beauty
     2,2,2,2,3,   # ItemMale, ItemFemale, DayHoldItem, NightHoldItem, HasMove
     4,1,1,1,4,   # HasInParty, LevelMale, LevelFemale, Location, TradeSpecies
     1,1,1,1,5,   # LevelDay, LevelNight, LevelDarkInParty, LevelRain, HappinessMoveType
     2,0,0,0,0    # Custom 1-5, MeltanBonbons is 2 bc item internal name
  ]
end



#===============================================================================
# Evolution helper functions
#===============================================================================
def pbGetEvolvedFormData(species)
  ret=[]
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVONEXTFORM=0x00
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if (evo&_EVODATAMASK)==_EVONEXTFORM
           ret.push([evonib,level,poke])
         end
         i+=5
       end
     end
  }
  return ret
end

def pbGetPreviousForm(species)   # Unused
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if (evo&_EVODATAMASK)==_EVOPREVFORM
           return poke
         end
         i+=5
       end
     end
  }
  return species
end

def pbGetBabySpecies(species,item1=-1,item2=-1)
  ret=species
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     f.pos=(species-1)*8
     offset=f.fgetdw
     length=f.fgetdw
     if length>0
       f.pos=offset
       i=0; loop do break unless i<length
         evo=f.fgetb
         evonib=evo&_EVOTYPEMASK
         level=f.fgetw
         poke=f.fgetw
         if poke<=PBSpecies.maxValueF && (evo&_EVODATAMASK)==_EVOPREVFORM # evolved from
           if item1>=0 && item2>=0
             dexdata=pbOpenDexData
             pbDexDataOffset(dexdata,poke,54)
             incense=dexdata.fgetw
             dexdata.close
             ret=poke if item1==incense || item2==incense
           else
             ret=poke
           end
           break
         end
         i+=5
       end
     end
  }
  if ret!=species
    ret=pbGetBabySpecies(ret)
  end
  return ret
end

def pbGetMinimumLevel(species)
  ret=-1
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  _EVOPREVFORM=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
    f.pos=(species-1)*8
    offset=f.fgetdw
    length=f.fgetdw
    if length>0
      f.pos=offset
      i=0; loop do break unless i<length
        evo=f.fgetb
        evonib=evo&_EVOTYPEMASK
        level=f.fgetw
        poke=f.fgetw
        if poke<=PBSpecies.maxValueF &&
           (evo&_EVODATAMASK)==_EVOPREVFORM && # evolved from
           [PBEvolution::Level,PBEvolution::LevelMale,
           PBEvolution::LevelFemale,PBEvolution::AttackGreater,
           PBEvolution::AtkDefEqual,PBEvolution::DefenseGreater,
           PBEvolution::Silcoon,PBEvolution::Cascoon,
           PBEvolution::Ninjask,PBEvolution::Shedinja,
           PBEvolution::LevelDay,PBEvolution::LevelNight,
           PBEvolution::LevelDarkInParty,PBEvolution::LevelRain].include?(evonib)
          ret=(ret==-1) ? level : [ret,level].min
          break
        end
        i+=5
      end
    end
  }
  return (ret==-1) ? 1 : ret
end

def pbEvoDebug   # Unused
  _EVOTYPEMASK=0x7F
  _EVODATAMASK=0x80
  pbRgssOpen("Data/evolutions.dat","rb"){|f|
     for species in 1..PBSpecies.maxValueF
       f.pos=(species-1)*8
       offset=f.fgetdw
       length=f.fgetdw
       puts PBSpecies.getName(species)
       if length>0
         f.pos=offset
         i=0; loop do break unless i<length
           evo=f.fgetb
           evonib=evo&_EVOTYPEMASK
           level=f.fgetw
           poke=f.fgetw
           puts sprintf("type=%02X, data=%02X, name=%s, level=%d",
              evonib,evo&_EVODATAMASK,PBSpecies.getName(poke),level)
           if poke==0
             p f.eof?
             break
           end
           i+=5
         end
       end
     end
  }
end



#===============================================================================
# Evolution animation
#===============================================================================
class SpriteMetafile
  VIEWPORT      = 0
  TONE          = 1
  SRC_RECT      = 2
  VISIBLE       = 3
  X             = 4
  Y             = 5
  Z             = 6
  OX            = 7
  OY            = 8
  ZOOM_X        = 9
  ZOOM_Y        = 10
  ANGLE         = 11
  MIRROR        = 12
  BUSH_DEPTH    = 13
  OPACITY       = 14
  BLEND_TYPE    = 15
  COLOR         = 16
  FLASHCOLOR    = 17
  FLASHDURATION = 18
  BITMAP        = 19

  def length
    return @metafile.length
  end

  def [](i)
    return @metafile[i]
  end

  def initialize(viewport=nil)
    @metafile=[]
    @values=[
       viewport,
       Tone.new(0,0,0,0),Rect.new(0,0,0,0),
       true,
       0,0,0,0,0,100,100,
       0,false,0,255,0,
       Color.new(0,0,0,0),Color.new(0,0,0,0),
       0
    ]
  end

  def disposed?
    return false
  end

  def dispose
  end

  def flash(color,duration)
    if duration>0
      @values[FLASHCOLOR]=color.clone
      @values[FLASHDURATION]=duration
      @metafile.push([FLASHCOLOR,color])
      @metafile.push([FLASHDURATION,duration])
    end
  end

  def x
    return @values[X]
  end

  def x=(value)
    @values[X]=value
    @metafile.push([X,value])
  end

  def y
    return @values[Y]
  end

  def y=(value)
    @values[Y]=value
    @metafile.push([Y,value])
  end

  def bitmap
    return nil
  end

  def bitmap=(value)
    if value && !value.disposed?
      @values[SRC_RECT].set(0,0,value.width,value.height)
      @metafile.push([SRC_RECT,@values[SRC_RECT].clone])
    end
  end

  def src_rect
    return @values[SRC_RECT]
  end

  def src_rect=(value)
    @values[SRC_RECT]=value
   @metafile.push([SRC_RECT,value])
 end

  def visible
    return @values[VISIBLE]
  end

  def visible=(value)
    @values[VISIBLE]=value
    @metafile.push([VISIBLE,value])
  end

  def z
    return @values[Z]
  end

  def z=(value)
    @values[Z]=value
    @metafile.push([Z,value])
  end

  def ox
    return @values[OX]
  end

  def ox=(value)
    @values[OX]=value
    @metafile.push([OX,value])
  end

  def oy
    return @values[OY]
  end

  def oy=(value)
    @values[OY]=value
    @metafile.push([OY,value])
  end

  def zoom_x
    return @values[ZOOM_X]
  end

  def zoom_x=(value)
    @values[ZOOM_X]=value
    @metafile.push([ZOOM_X,value])
  end

  def zoom_y
    return @values[ZOOM_Y]
  end

  def zoom_y=(value)
    @values[ZOOM_Y]=value
    @metafile.push([ZOOM_Y,value])
  end

  def zoom=(value)
    @values[ZOOM_X]=value
    @metafile.push([ZOOM_X,value])
    @values[ZOOM_Y]=value
    @metafile.push([ZOOM_Y,value])
  end

  def angle
    return @values[ANGLE]
  end

  def angle=(value)
    @values[ANGLE]=value
    @metafile.push([ANGLE,value])
  end

  def mirror
    return @values[MIRROR]
  end

  def mirror=(value)
    @values[MIRROR]=value
    @metafile.push([MIRROR,value])
  end

  def bush_depth
    return @values[BUSH_DEPTH]
  end

  def bush_depth=(value)
    @values[BUSH_DEPTH]=value
    @metafile.push([BUSH_DEPTH,value])
  end

  def opacity
    return @values[OPACITY]
  end

  def opacity=(value)
    @values[OPACITY]=value
    @metafile.push([OPACITY,value])
  end

  def blend_type
    return @values[BLEND_TYPE]
  end

  def blend_type=(value)
    @values[BLEND_TYPE]=value
    @metafile.push([BLEND_TYPE,value])
  end

  def color
    return @values[COLOR]
  end

  def color=(value)
    @values[COLOR]=value.clone
    @metafile.push([COLOR,@values[COLOR]])
  end

  def tone
    return @values[TONE]
  end

  def tone=(value)
    @values[TONE]=value.clone
    @metafile.push([TONE,@values[TONE]])
  end

  def update
    @metafile.push([-1,nil])
  end
end



class SpriteMetafilePlayer
  def initialize(metafile,sprite=nil)
    @metafile=metafile
    @sprites=[]
    @playing=false
    @index=0
    @sprites.push(sprite) if sprite
  end

  def add(sprite)
    @sprites.push(sprite)
  end

  def playing?
    return @playing
  end

  def play
    @playing=true
    @index=0
  end

  def update
    if @playing
      for j in @index...@metafile.length
        @index=j+1
        break if @metafile[j][0]<0
        code=@metafile[j][0]
        value=@metafile[j][1]
        for sprite in @sprites
          case code
          when SpriteMetafile::X; sprite.x=value
          when SpriteMetafile::Y; sprite.y=value
          when SpriteMetafile::OX; sprite.ox=value
          when SpriteMetafile::OY; sprite.oy=value
          when SpriteMetafile::ZOOM_X; sprite.zoom_x=value
          when SpriteMetafile::ZOOM_Y; sprite.zoom_y=value
          when SpriteMetafile::SRC_RECT; sprite.src_rect=value
          when SpriteMetafile::VISIBLE; sprite.visible=value
          when SpriteMetafile::Z; sprite.z=value # prevent crashes
          when SpriteMetafile::ANGLE; sprite.angle=(value==180) ? 179.9 : value
          when SpriteMetafile::MIRROR; sprite.mirror=value
          when SpriteMetafile::BUSH_DEPTH; sprite.bush_depth=value
          when SpriteMetafile::OPACITY; sprite.opacity=value
          when SpriteMetafile::BLEND_TYPE; sprite.blend_type=value
          when SpriteMetafile::COLOR; sprite.color=value
          when SpriteMetafile::TONE; sprite.tone=value
          end
        end
      end
      @playing=false if @index==@metafile.length
    end
  end
end



def pbSaveSpriteState(sprite)
  state=[]
  return state if !sprite || sprite.disposed?
  state[SpriteMetafile::BITMAP]     = sprite.x
  state[SpriteMetafile::X]          = sprite.x
  state[SpriteMetafile::Y]          = sprite.y
  state[SpriteMetafile::SRC_RECT]   = sprite.src_rect.clone
  state[SpriteMetafile::VISIBLE]    = sprite.visible
  state[SpriteMetafile::Z]          = sprite.z
  state[SpriteMetafile::OX]         = sprite.ox
  state[SpriteMetafile::OY]         = sprite.oy
  state[SpriteMetafile::ZOOM_X]     = sprite.zoom_x
  state[SpriteMetafile::ZOOM_Y]     = sprite.zoom_y
  state[SpriteMetafile::ANGLE]      = sprite.angle
  state[SpriteMetafile::MIRROR]     = sprite.mirror
  state[SpriteMetafile::BUSH_DEPTH] = sprite.bush_depth
  state[SpriteMetafile::OPACITY]    = sprite.opacity
  state[SpriteMetafile::BLEND_TYPE] = sprite.blend_type
  state[SpriteMetafile::COLOR]      = sprite.color.clone
  state[SpriteMetafile::TONE]       = sprite.tone.clone
  return state
end

def pbRestoreSpriteState(sprite,state)
  return if !state || !sprite || sprite.disposed?
  sprite.x          = state[SpriteMetafile::X]
  sprite.y          = state[SpriteMetafile::Y]
  sprite.src_rect   = state[SpriteMetafile::SRC_RECT]
  sprite.visible    = state[SpriteMetafile::VISIBLE]
  sprite.z          = state[SpriteMetafile::Z]
  sprite.ox         = state[SpriteMetafile::OX]
  sprite.oy         = state[SpriteMetafile::OY]
  sprite.zoom_x     = state[SpriteMetafile::ZOOM_X]
  sprite.zoom_y     = state[SpriteMetafile::ZOOM_Y]
  sprite.angle      = state[SpriteMetafile::ANGLE]
  sprite.mirror     = state[SpriteMetafile::MIRROR]
  sprite.bush_depth = state[SpriteMetafile::BUSH_DEPTH]
  sprite.opacity    = state[SpriteMetafile::OPACITY]
  sprite.blend_type = state[SpriteMetafile::BLEND_TYPE]
  sprite.color      = state[SpriteMetafile::COLOR]
  sprite.tone       = state[SpriteMetafile::TONE]
end

def pbSaveSpriteStateAndBitmap(sprite)
  return [] if !sprite || sprite.disposed?
  state=pbSaveSpriteState(sprite)
  state[SpriteMetafile::BITMAP]=sprite.bitmap
  return state
end

def pbRestoreSpriteStateAndBitmap(sprite,state)
  return if !state || !sprite || sprite.disposed?
  sprite.bitmap=state[SpriteMetafile::BITMAP]
  pbRestoreSpriteState(sprite,state)
  return state
end



class PokemonEvolutionScene
  private

  def pbGenerateMetafiles(s1x,s1y,s2x,s2y)
    sprite=SpriteMetafile.new
    sprite2=SpriteMetafile.new
    sprite.opacity=255
    sprite2.opacity=255
    sprite2.zoom=0.0
    sprite.ox=s1x
    sprite.oy=s1y
    sprite2.ox=s2x
    sprite2.oy=s2y
    alpha=0
    for j in 0...26
      sprite.color.red=255
      sprite.color.green=255
      sprite.color.blue=255
      sprite.color.alpha=alpha
      sprite.color=sprite.color
      sprite2.color=sprite.color
      sprite2.color.alpha=255
      sprite.update
      sprite2.update
      alpha+=5
    end
    totaltempo=0
    currenttempo=25
    maxtempo=7*Graphics.frame_rate
    while totaltempo<maxtempo
      for j in 0...currenttempo
        if alpha<255
          sprite.color.red=255
          sprite.color.green=255
          sprite.color.blue=255
          sprite.color.alpha=alpha
          sprite.color=sprite.color
          alpha+=10
        end
        sprite.zoom=[1.1*(currenttempo-j-1)/currenttempo,1.0].min
        sprite2.zoom=[1.1*(j+1)/currenttempo,1.0].min
        sprite.update
        sprite2.update
      end
      totaltempo+=currenttempo
      if totaltempo+currenttempo<maxtempo
        for j in 0...currenttempo
          sprite.zoom=[1.1*(j+1)/currenttempo,1.0].min
          sprite2.zoom=[1.1*(currenttempo-j-1)/currenttempo,1.0].min
          sprite.update
          sprite2.update
        end
      end
      totaltempo+=currenttempo
      currenttempo=[(currenttempo/1.5).floor,5].max
    end
    @metafile1=sprite
    @metafile2=sprite2
  end

  public

  def pbUpdate(animating=false)
    if animating      # Pokémon shouldn't animate during the evolution animation
      @sprites["background"].update
    else
      pbUpdateSpriteHash(@sprites)
    end
  end

  def pbUpdateNarrowScreen
    if @bgviewport.rect.y<20*4
      @bgviewport.rect.height-=2*4
      if @bgviewport.rect.height<Graphics.height-64
        @bgviewport.rect.y+=4
        @sprites["background"].oy=@bgviewport.rect.y
      end
    end
  end

  def pbUpdateExpandScreen
    if @bgviewport.rect.y>0
      @bgviewport.rect.y-=4
      @sprites["background"].oy=@bgviewport.rect.y
    end
    if @bgviewport.rect.height<Graphics.height
      @bgviewport.rect.height+=2*4
    end
  end

  def pbFlashInOut(canceled,oldstate,oldstate2)
    tone=0
    loop do
      Graphics.update
      pbUpdate(true)
      pbUpdateExpandScreen
      tone+=10
      @viewport.tone.set(tone,tone,tone,0)
      break if tone>=255
    end
    @bgviewport.rect.y=0
    @bgviewport.rect.height=Graphics.height
    @sprites["background"].oy=0
    if canceled
      pbRestoreSpriteState(@sprites["rsprite1"],oldstate)
      pbRestoreSpriteState(@sprites["rsprite2"],oldstate2)
      @sprites["rsprite1"].visible=true
      @sprites["rsprite1"].zoom_x=1.0
      @sprites["rsprite1"].zoom_y=1.0
      @sprites["rsprite1"].color.alpha=0
      @sprites["rsprite2"].visible=false
    else
      @sprites["rsprite1"].visible=false
      @sprites["rsprite2"].visible=true
      @sprites["rsprite2"].zoom_x=1.0
      @sprites["rsprite2"].zoom_y=1.0
      @sprites["rsprite2"].color.alpha=0
    end
    10.times do
      Graphics.update
      pbUpdate(true)
    end
    tone=255
    loop do
      Graphics.update
      pbUpdate
      tone=[tone-20,0].max
      @viewport.tone.set(tone,tone,tone,0)
      break if tone<=0
    end
  end
 
  def pbStartScreen(pokemon,newspecies)
    @pokemon = pokemon
    @newspecies = newspecies
    @sprites = {}
    @bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @bgviewport.z = 99999
    @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z = 99999
    @msgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @msgviewport.z = 99999
    addBackgroundOrColoredPlane(@sprites,"background","evolutionbg",
       Color.new(248,248,248),@bgviewport)
    rsprite1 = PokemonSprite.new(@viewport)
    rsprite1.setOffset(PictureOrigin::Center)
    rsprite1.setPokemonBitmap(@pokemon,false)
    rsprite1.x = Graphics.width/2
    rsprite1.y = (Graphics.height-64)/2
    rsprite2 = PokemonSprite.new(@viewport)
    rsprite2.setOffset(PictureOrigin::Center)
    rsprite2.setPokemonBitmapSpecies(@pokemon,@newspecies,false)
    rsprite2.x       = rsprite1.x
    rsprite2.y       = rsprite1.y
    rsprite2.opacity = 0
    @sprites["rsprite1"] = rsprite1
    @sprites["rsprite2"] = rsprite2
    pbGenerateMetafiles(rsprite1.ox,rsprite1.oy,rsprite2.ox,rsprite2.oy)
    @sprites["msgwindow"] = Kernel.pbCreateMessageWindow(@msgviewport)
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  # Closes the evolution screen.
  def pbEndScreen
    Kernel.pbDisposeMessageWindow(@sprites["msgwindow"])
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
    @bgviewport.dispose
    @msgviewport.dispose
  end

  # Opens the evolution screen
  def pbEvolution(cancancel=true)
    metaplayer1 = SpriteMetafilePlayer.new(@metafile1,@sprites["rsprite1"])
    metaplayer2 = SpriteMetafilePlayer.new(@metafile2,@sprites["rsprite2"])
    metaplayer1.play
    metaplayer2.play
    pbBGMStop
    pbPlayCry(@pokemon)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("\\se[]What?\r\n{1} is evolving!\\^",@pokemon.name)) { pbUpdate }
    Kernel.pbMessageWaitForInput(@sprites["msgwindow"],100,true) { pbUpdate }
    pbPlayDecisionSE
    oldstate  = pbSaveSpriteState(@sprites["rsprite1"])
    oldstate2 = pbSaveSpriteState(@sprites["rsprite2"])
    pbMEPlay("Evolution start")
    pbBGMPlay("Evolution")
    canceled = false
    begin
      pbUpdateNarrowScreen
      metaplayer1.update
      metaplayer2.update
      Graphics.update
      Input.update
      pbUpdate(true)
      if Input.trigger?(Input::B) && cancancel
        pbBGMStop
        pbPlayCancelSE
        canceled = true
        break
      end
    end while metaplayer1.playing? && metaplayer2.playing?
    pbFlashInOut(canceled,oldstate,oldstate2)
    if canceled
      Kernel.pbMessageDisplay(@sprites["msgwindow"],
         _INTL("Huh?\r\n{1} stopped evolving!",@pokemon.name)) { pbUpdate }
    else
      pbEvolutionSuccess
    end
  end

  def pbEvolutionSuccess
    # Play cry of evolved species
    frames = pbCryFrameLength(@newspecies,@pokemon.form)
    pbBGMStop
    pbPlayCrySpecies(@newspecies,@pokemon.form)
    frames.times do
      Graphics.update
      pbUpdate
    end
    
    # Duplicate Pokémon (i.e. Shedinja)
    if createSpecies>0 && $Trainer.party.length<6
      newpokemon = @pokemon.clone
      newpokemon.species = createSpecies
      newpokemon.name    = PBSpecies.getName(createSpecies)
      newpokemon.iv      = @pokemon.iv.clone
      newpokemon.ev      = @pokemon.ev.clone
      newpokemon.markings = 0
      newpokemon.ballused = 0
      newpokemon.setItem(0)
      newpokemon.clearAllRibbons
      newpokemon.calcStats
      newpokemon.heal
      # Add duplicate Pokémon to party
      $Trainer.party.push(newpokemon)
      # See and own duplicate Pokémon
      $Trainer.seen[createSpecies]  = true
      $Trainer.owned[createSpecies] = true
      pbSeenForm(newpokemon)
      # Consume Poké Ball
      $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
    end
    if isConst?(@pokemon.species,PBSpecies,:MELMETAL)
      $PokemonBag.pbDeleteItemToEvolve(getConst(PBItems,:MELTANBONBONS))
    end
    
    # Success jingle/message
    pbMEPlay("Evolution success")
    newspeciesname = PBSpecies.getName(@newspecies)
    oldspeciesname = PBSpecies.getName(@pokemon.species)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
       _INTL("\\se[]Congratulations! Your {1} evolved into {2}!\\wt[80]",
       @pokemon.name,newspeciesname)) { pbUpdate }
    @sprites["msgwindow"].text = ""
    # Check for consumed item and Pokémon duplication (i.e. Shedinja)
    removeItem = false
    createSpecies = pbCheckEvolutionEx(@pokemon){|pokemon,evonib,level,poke|
       case evonib
       when PBEvolution::Shedinja
         next poke if $PokemonBag.pbHasItem?(getConst(PBItems,:POKEBALL))
       when PBEvolution::TradeItem,PBEvolution::DayHoldItem,PBEvolution::NightHoldItem
         removeItem = true if poke==@newspecies   # Item is now consumed
       end
       next -1
    }
    @pokemon.setItem(0) if removeItem
    # Modify Pokémon to make it evolved
    @pokemon.species = @newspecies
    @pokemon.name    = newspeciesname if @pokemon.name==oldspeciesname
    @pokemon.form    = 0 if isConst?(@pokemon.species,PBSpecies,:MOTHIM)
    @pokemon.calcStats
    # See and own evolved species
    $Trainer.seen[@newspecies]  = true
    $Trainer.owned[@newspecies] = true
    pbSeenForm(@pokemon)
    # Learn moves upon evolution for evolved species
    movelist = @pokemon.getMoveList
    for i in movelist
      if i[0]==0 || i[0]==@pokemon.level          # Learned a new move
        pbLearnMove(@pokemon,i[1],true) { pbUpdate }
      end
    end
    # Duplicate Pokémon (i.e. Shedinja)
    if createSpecies>0 && $Trainer.party.length<6
      newpokemon = @pokemon.clone
      newpokemon.species = createSpecies
      newpokemon.name    = PBSpecies.getName(createSpecies)
      newpokemon.iv      = @pokemon.iv.clone
      newpokemon.ev      = @pokemon.ev.clone
      newpokemon.markings = 0
      newpokemon.ballused = 0
      newpokemon.setItem(0)
      newpokemon.clearAllRibbons
      newpokemon.calcStats
      newpokemon.heal
      # Add duplicate Pokémon to party
      $Trainer.party.push(newpokemon)
      # See and own duplicate Pokémon
      $Trainer.seen[createSpecies]  = true
      $Trainer.owned[createSpecies] = true
      pbSeenForm(newpokemon)
      # Consume Poké Ball
      $PokemonBag.pbDeleteItem(getConst(PBItems,:POKEBALL))
    end
  end
end



#===============================================================================
# Evolution methods
#===============================================================================
def pbMiniCheckEvolution(pokemon,evonib,level,poke)
 #Changed this:
  when PBEvolution::ItemQuantity
    return poke if $PokemonBag.pbHasItemQuantityToEvolve?(:MELTANBONBONS)
#Changed this:
  case evonib
  when PBEvolution::Happiness
    return poke if pokemon.happiness>=220
  when PBEvolution::HappinessDay
    return poke if pokemon.happiness>=220 && PBDayNight.isDay?
  when PBEvolution::HappinessNight
    return poke if pokemon.happiness>=220 && PBDayNight.isNight?
  when PBEvolution::HappinessMoveType
    if pokemon.happiness>=220
      for m in pokemon.moves
        return poke if m.id>0 && m.type==level
      end
    end
  when PBEvolution::Level
    return poke if pokemon.level>=level
  when PBEvolution::LevelDay
    return poke if pokemon.level>=level && PBDayNight.isDay?
  when PBEvolution::LevelNight
    return poke if pokemon.level>=level && PBDayNight.isNight?
  when PBEvolution::LevelMale
    return poke if pokemon.level>=level && pokemon.isMale?
  when PBEvolution::LevelFemale
    return poke if pokemon.level>=level && pokemon.isFemale?
  when PBEvolution::AttackGreater  # Hitmonlee
    return poke if pokemon.level>=level && pokemon.attack>pokemon.defense
  when PBEvolution::AtkDefEqual    # Hitmontop
    return poke if pokemon.level>=level && pokemon.attack==pokemon.defense
  when PBEvolution::DefenseGreater # Hitmonchan
    return poke if pokemon.level>=level && pokemon.attack<pokemon.defense
  when PBEvolution::Silcoon
    return poke if pokemon.level>=level && (((pokemon.personalID>>16)&0xFFFF)%10)<5
  when PBEvolution::Cascoon
    return poke if pokemon.level>=level && (((pokemon.personalID>>16)&0xFFFF)%10)>=5
  when PBEvolution::Ninjask
    return poke if pokemon.level>=level
  when PBEvolution::Shedinja
    return -1
  when PBEvolution::DayHoldItem
    return poke if pokemon.item==level && PBDayNight.isDay?
  when PBEvolution::NightHoldItem
    return poke if pokemon.item==level && PBDayNight.isNight?
  when PBEvolution::HasMove
    for m in pokemon.moves
      return poke if m.id==level
    end
  when PBEvolution::HasInParty
    for i in $Trainer.pokemonParty
      return poke if i.species==level
    end
  when PBEvolution::LevelDarkInParty
    if pokemon.level>=level
      for i in $Trainer.pokemonParty
        return poke if i.hasType?(:DARK)
      end
    end
  when PBEvolution::Location
    return poke if $game_map.map_id==level
  when PBEvolution::LevelRain
    if pokemon.level>=level
      if $game_screen && ($game_screen.weather==PBFieldWeather::Rain ||
                          $game_screen.weather==PBFieldWeather::HeavyRain ||
                          $game_screen.weather==PBFieldWeather::Storm)
        return poke
      end
    end
  when PBEvolution::Beauty   # Feebas
    return poke if pokemon.beauty>=level
  when PBEvolution::Trade, PBEvolution::TradeItem, PBEvolution::TradeSpecies
    return -1
# Meltan evolution method
when PBEvolution::MeltanBonbons
    if $PokemonBag.pbQuantity(:MELTANBONBONS) >= 400
        $PokemonBag.pbDeleteItem(:MELTANBONBONS, 400)
        return poke
    end
  when PBEvolution::Custom2
    # Add code for custom evolution type 2
  when PBEvolution::Custom3
    # Add code for custom evolution type 3
  when PBEvolution::Custom4
    # Add code for custom evolution type 4
  when PBEvolution::Custom5
    # Add code for custom evolution type 5
  end
  return -1
end

def pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
  # Checks for when an item is used on the Pokémon (e.g. an evolution stone)
  case evonib
  when PBEvolution::Item
    return poke if level==item
  when PBEvolution::ItemMale
    return poke if level==item && pokemon.isMale?
  when PBEvolution::ItemFemale
    return poke if level==item && pokemon.isFemale?
  end
  return -1
end

# Checks whether a Pokemon can evolve now. If a block is given, calls the block
# with the following parameters:
#  Pokemon to check; evolution type; level or other parameter; ID of the new Pokemon species
def pbCheckEvolutionEx(pokemon)
  return -1 if pokemon.species<=0 || pokemon.egg?
  return -1 if isConst?(pokemon.item,PBItems,:EVERSTONE)
  return -1 if isConst?(pokemon.species,PBSpecies,:PICHU) && pokemon.form==1
  ret=-1
  for form in pbGetEvolvedFormData(pbGetFSpeciesFromForm(pokemon.species,pokemon.form))
    ret = yield pokemon,form[0],form[1],form[2]
    break if ret>0
  end
  return ret
end

# Checks whether a Pokemon can evolve now. If an item is used on the Pokémon,
# checks whether the Pokemon can evolve with the given item.
def pbCheckEvolution(pokemon,item=0)
  if item==0
    return pbCheckEvolutionEx(pokemon){|pokemon,evonib,level,poke|
       next pbMiniCheckEvolution(pokemon,evonib,level,poke)
    }
  else
    return pbCheckEvolutionEx(pokemon){|pokemon,evonib,level,poke|
       next pbMiniCheckEvolutionItem(pokemon,evonib,level,poke,item)
    }
  end
end

Code:
#===============================================================================
# The Bag object, which actually contains all the items
#===============================================================================
class PokemonBag
  attr_accessor :lastpocket
  attr_reader :pockets

  def self.pocketNames
    return pbPocketNames
  end

  def self.numPockets
    return self.pocketNames.length-1
  end

  def initialize
    @lastpocket = 1
    @pockets    = []
    @choices    = []
    for i in 0..PokemonBag.numPockets
      @pockets[i] = []
      @choices[i] = 0
    end
    @registeredItems = []
    @registeredIndex = [0,0,1]
  end

  def rearrange
    if (@pockets.length-1)!=PokemonBag.numPockets
      newpockets = []
      for i in 0..PokemonBag.numPockets
        newpockets[i] = []
        @choices[i]   = 0 if !@choices[i]
      end
      nump = PokemonBag.numPockets
      for i in 0...[@pockets.length,nump].min
        for item in @pockets[i]
          p = pbGetPocket(item[0])
          newpockets[p].push(item)
        end
      end
      @pockets = newpockets
    end
  end

  def clear
    for pocket in @pockets
      pocket.clear
    end
  end

  def pockets
    rearrange
    return @pockets
  end

  def maxPocketSize(pocket)
    maxsize = MAXPOCKETSIZE[pocket]
    return -1 if !maxsize
    return maxsize
  end

  # Gets the index of the current selected item in the pocket
  def getChoice(pocket)
    if pocket<=0 || pocket>PokemonBag.numPockets
      raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect))
    end
    rearrange
    return [@choices[pocket],@pockets[pocket].length].min || 0
  end

  # Sets the index of the current selected item in the pocket
  def setChoice(pocket,value)
    if pocket<=0 || pocket>PokemonBag.numPockets
      raise ArgumentError.new(_INTL("Invalid pocket: {1}",pocket.inspect))
    end
    rearrange
    @choices[pocket] = value if value<=@pockets[pocket].length
  end

  def getAllChoices
    ret = @choices.clone
    for i in 0...@choices.length; @choices[i] = 0; end
    return ret
  end

  def setAllChoices(choices)
    @choices = choices
  end

  def pbQuantity(item)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
  if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return 0
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length if maxsize<0
    return ItemStorageHelper.pbQuantity(@pockets[pocket],maxsize,item)
  end

  def pbHasItemQuantityToEvolve?(item)
    return pbQuantity(item)>=400
  end

  def pbCanStore?(item,qty=1)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length+1 if maxsize<0
    return ItemStorageHelper.pbCanStore?(@pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty)
  end

  def pbStoreAllOrNone(item,qty=1)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length+1 if maxsize<0
    return ItemStorageHelper.pbStoreAllOrNone(@pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty)
  end

  def pbStoreItem(item,qty=1)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length+1 if maxsize<0
    return ItemStorageHelper.pbStoreItem(@pockets[pocket],maxsize,BAGMAXPERSLOT,item,qty,true)
  end

  def pbChangeItem(olditem,newitem)
    if olditem.is_a?(String) || olditem.is_a?(Symbol)
      olditem = getID(PBItems,olditem)
    end
    if newitem.is_a?(String) || newitem.is_a?(Symbol)
      newitem = getID(PBItems,newitem)
    end
    if !olditem || olditem<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",olditem))
      return false
    elsif !newitem || newitem<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",newitem))
      return false
    end
    pocket = pbGetPocket(olditem)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length if maxsize<0
    ret = false
    for i in 0...maxsize
      itemslot = @pockets[pocket][i]
      if itemslot && itemslot[0]==olditem
        itemslot[0] = newitem
        ret = true
      end
    end
    return ret
  end

  def pbChangeQuantity(pocket,index,newqty=1)
    return false if pocket<=0 || pocket>self.numPockets
    return false if @pockets[pocket].length<index
    newqty = [newqty,maxPocketSize(pocket)].min
    @pockets[pocket][index][1] = newqty
    return true
  end

   def pbDeleteItemToEvolve(item,qty=400)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return false
    end
    pocket = pbGetPocket(item)
    maxsize = maxPocketSize(pocket)
    maxsize = @pockets[pocket].length if maxsize<0
    ret = ItemStorageHelper.pbDeleteItem(@pockets[pocket],maxsize,item,qty)
    return ret
  end

  def registeredItems
    @registeredItems = [] if !@registeredItems
    if @registeredItem && @registeredItem>0 && !@registeredItems.include?(@registeredItem)
      @registeredItems.push(@registeredItem)
      @registeredItem = nil
    end
    return @registeredItems
  end

  def registeredItem; redisteredItems; end

  def pbIsRegistered?(item)
    registeredlist = self.registeredItems
    return registeredlist.include?(item)
  end

  # Registers the item in the Ready Menu.
  def pbRegisterItem(item)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return
    end
    registeredlist = self.registeredItems
    registeredlist.push(item) if !registeredlist.include?(item)
  end

  # Unregisters the item from the Ready Menu.
  def pbUnregisterItem(item)
    if item.is_a?(String) || item.is_a?(Symbol)
      item = getID(PBItems,item)
    end
    if !item || item<1
      raise ArgumentError.new(_INTL("Item number {1} is invalid.",item))
      return
    end
    registeredlist = self.registeredItems
    if registeredlist.include?(item)
      for i in 0...registeredlist.length
        if registeredlist[i]==item
          registeredlist[i] = nil
          break
        end
      end
      registeredlist.compact!
    end
  end

  def registeredIndex
    @registeredIndex = [0,0,1] if !@registeredIndex
    return @registeredIndex
  end
end



#===============================================================================
# The PC item storage object, which actually contains all the items
#===============================================================================
class PCItemStorage
  MAXSIZE    = 50    # Number of different slots in storage
  MAXPERSLOT = 999   # Max. number of items per slot

  def initialize
    @items = []
    # Start storage with a Potion
    if hasConst?(PBItems,:POTION)
      pbStoreItem(getConst(PBItems,:POTION))
    end
  end

  def [](i)
    @items[i]
  end

  def length
    @items.length
  end

  def empty?
    return @items.length==0
  end

  def clear
    @items.clear
  end

  def getItem(index)
    return (index<0 || index>=@items.length) ? 0 : @items[index][0]
  end

  def getCount(index)
    return (index<0 || index>=@items.length) ? 0 : @items[index][1]
  end

  def pbQuantity(item)
    return ItemStorageHelper.pbQuantity(@items,MAXSIZE,item)
  end

  def pbCanStore?(item,qty=1)
    return ItemStorageHelper.pbCanStore?(@items,MAXSIZE,MAXPERSLOT,item,qty)
  end

  def pbStoreItem(item,qty=1)
    return ItemStorageHelper.pbStoreItem(@items,MAXSIZE,MAXPERSLOT,item,qty)
  end

  def pbDeleteItem(item,qty=1)
    return ItemStorageHelper.pbDeleteItem(@items,MAXSIZE,item,qty)
  end
end



#===============================================================================
# Implements methods that act on arrays of items.  Each element in an item
# array is itself an array of [itemID, itemCount].
# Used by the Bag, PC item storage, and Triple Triad.
#===============================================================================
module ItemStorageHelper
  # Returns the quantity of the given item in the items array, maximum size per slot, and item ID
  def self.pbQuantity(items,maxsize,item)
    ret = 0
    for i in 0...maxsize
      itemslot = items[i]
      ret += itemslot[1] if itemslot && itemslot[0]==item
    end
    return ret
  end

  # Deletes an item from items array, maximum size per slot, item, and number of items to delete
  def self.pbDeleteItem(items,maxsize,item,qty)
    raise "Invalid value for qty: #{qty}" if qty<0
    return true if qty==0
    ret = false
    for i in 0...maxsize
      itemslot=items[i]
      if itemslot && itemslot[0]==item
        amount = [qty,itemslot[1]].min
        itemslot[1] -= amount
        qty -= amount
        items[i] = nil if itemslot[1]==0
        if qty==0
          ret = true
          break
        end
      end
    end
    items.compact!
    return ret
  end

  def self.pbCanStore?(items,maxsize,maxPerSlot,item,qty)
    raise "Invalid value for qty: #{qty}" if qty<0
    return true if qty==0
    for i in 0...maxsize
      itemslot = items[i]
      if !itemslot
        qty -= [qty,maxPerSlot].min
        return true if qty==0
      elsif itemslot[0]==item && itemslot[1]<maxPerSlot
        newamt = itemslot[1]
        newamt = [newamt+qty,maxPerSlot].min
        qty -= (newamt-itemslot[1])
        return true if qty==0
      end
    end
    return false
  end

  def self.pbStoreItem(items,maxsize,maxPerSlot,item,qty,sorting=false)
    raise "Invalid value for qty: #{qty}" if qty<0
    return true if qty==0
    for i in 0...maxsize
      itemslot = items[i]
      if !itemslot
        items[i] = [item,[qty,maxPerSlot].min]
        qty -= items[i][1]
        if sorting
          items.sort! if POCKETAUTOSORT[$ItemData[item][ITEMPOCKET]]
        end
        return true if qty==0
      elsif itemslot[0]==item && itemslot[1]<maxPerSlot
        newamt = itemslot[1]
        newamt = [newamt+qty,maxPerSlot].min
        qty -= (newamt-itemslot[1])
        itemslot[1] = newamt
        return true if qty==0
      end
    end
    return false
  end
end

Then I added this line in items.txt:


And I don't understand where I put the code you mentioned above:

Code:
  when PBEvolution::ItemQuantity
    return poke if $game_switches[ItemQuantity]
where do I put this and this:

Code:
if $PokemonBag.pbHasItem?(:MELTANCANDY) && $PokemonBag.pbQuantity(:MELTANCANDY)>=400
  $game_switches[ItemQuantity]=true
else
  $game_switches[ItemQuantity]=false
end
 

WolfPP

Discord Wolf#1235
Member
Posts
91
#8
I've got this Syntax Error after adding your code:



]
Syntax because you added this:
Code:
  when PBEvolution::ItemQuantity
    return poke if $PokemonBag.pbHasItemQuantityToEvolve?(:MELTANBONBONS)
above this:
Code:
  case evonib
  when PBEvolution::Happiness
    return poke if pokemon.happiness>=220
You must add inside 'case evonib':
Code:
#Changed this:
  case evonib
  when PBEvolution::Happiness
    return poke if pokemon.happiness>=220
  when PBEvolution::ItemQuantity
    return poke if $PokemonBag.pbHasItemQuantityToEvolve?(:MELTANBONBONS)
 

Marina

Elite Trainer
Member
Posts
117
#9
It helped alot thanks, now I just a have another issue not related to this post, maybe I have to post it in Marin's DP Pause Menu
instead of here. It's strange the Debug Menu opens by itself every 1 second, it just stops doing that when I press X and stay at the Pause Menu, if I close the Pause Menu it continues opening the Debug Menu. I have to ask Marin if he can help me or someone there, because this isn't the right section for this. But thank you for now, even though I couldn't test the evolution,

If Marin or someone can help me with the problem I stated above, then I'll try evolving Meltan into Melmetal.
Thanks again for your quick answer and help :)
 

WolfPP

Discord Wolf#1235
Member
Posts
91
#10
Hmmm you can remove this code to test if Meltan evolves or not and then, turn back DP Pause Menu code into Script...
 

Marina

Elite Trainer
Member
Posts
117
#11
It still happens =S

Edit: I tried to give Meltan the Meltan Candy but this happened:

Code:
---------------------------
Pokémon Let's Go, Evoli!
---------------------------
[Pokémon Essentials version 17.2]

Exception: NoMethodError

Message: undefined method `pbDeleteItem' for #<PokemonBag:0x85e1130>

PItem_Items:785:in `pbGiveItemToPokemon'

Heart Symbol:1396:in `pbPokemonScreen'

Heart Symbol:1250:in `loop'

Heart Symbol:1450:in `pbPokemonScreen'

PScreen_PauseMenu:176:in `pbStartPokemonMenu'

PScreen_PauseMenu:173:in `pbFadeOutIn'

PScreen_PauseMenu:173:in `pbStartPokemonMenu'

PScreen_PauseMenu:142:in `loop'

PScreen_PauseMenu:271:in `pbStartPokemonMenu'

Scene_Map:127:in `call_menu'



This exception was logged in

C:\Users\FATIMA\Saved Games\Pokémon Essentials_\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK   
---------------------------
 

WolfPP

Discord Wolf#1235
Member
Posts
91
#12
Give? With my code you only need to have 400 MELTANCANDY into the bag and level up the Meltan (giving an Rare Candy or fight against other pokemon and level up). Don't need to give nothing to Meltan.
 

Marina

Elite Trainer
Member
Posts
117
#13
Now this happened, I don't know if the order of the scripts are ok:

Code:
---------------------------
Error
---------------------------
Script 'Following Pokemon v.1.4' line 1203: SystemStackError occurred.

stack level too deep

from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
from 'Following Pokemon v.1.4' line 1203 in `follow_pbGetTerrainTag'
---------------------------
OK
---------------------------



Edit: Now it works, I had the Pokemon Amie Script 2 in the script editor, I removed it now and it works
now I'll test the evolution with Meltan

Edit: Now I used a Rare Candy on Meltan and this error popped up:
Code:
---------------------------
Error
---------------------------
Script 'Pokemon_Evolution' line 967: NameError occurred.

uninitialized constant PBEvolution::Custom2

from 'Pokemon_Evolution' line 967 in `pbMiniCheckEvolution'
from 'Pokemon_Evolution' line 1012 in `pbCheckEvolution'
from 'Pokemon_Evolution' line 1011 in `pbCheckEvolutionEx'
from 'Pokemon_Evolution' line 1000 in `each'
from 'Pokemon_Evolution' line 1000 in `pbCheckEvolutionEx'
from 'Pokemon_Evolution' line 1011 in `pbCheckEvolution'
from 'Pokémon Amie by Pizza Sun' line 352 in `pbChangeLevel'
from 'Pokémon Amie by Pizza Sun' line 268
from 'Pokémon Amie by Pizza Sun' line 263 in `call'
from 'EventHandlers' line 150 in `trigger'
from 'PItem_Items' line 228 in `follow_triggerUseOnPokemon'
from 'Following Pokemon v.1.4' line 1891 in `triggerUseOnPokemon'
---------------------------
OK  
---------------------------

Edit: Now I tried again added the code you mentioned on custom 2 and this happened:
Code:
---------------------------
Error
---------------------------
Script 'PItem_Items' line 636: NoMethodError occurred.

undefined method `pbDeleteItem' for #<PokemonBag:0x9385a98>

from 'PItem_Items' line 636 in `pbUseItem'
from 'PItem_Items' line 628 in `loop'
from 'PItem_Items' line 647 in `pbUseItem'
from 'PItem_Items' line 624 in `pbFadeOutIn'
from 'PItem_Items' line 624 in `pbUseItem'
from 'PScreen_Bag' line 485 in `pbStartScreen'
from 'PScreen_Bag' line 449 in `loop'
from 'PScreen_Bag' line 558 in `pbStartScreen'
from 'DP Menu' line 104 in `initialize'
from 'DP Menu' line 101 in `pbFadeOutIn'
from 'DP Menu' line 101 in `initialize'
from 'DP Menu' line 99 in `call'
---------------------------
OK   
---------------------------
 
Last edited:

WolfPP

Discord Wolf#1235
Member
Posts
91
#14
You have to many custom script, maybe you need to fix some of them. Your error is nothing about the code than i made. I made a new code pbDeleteitem, called by 'pbDeleteItemToEvolve(item,qty=400)', nothing about your error.
 

Marina

Elite Trainer
Member
Posts
117
#15
I think pbDeleteItem isn't defined in the script editor
and this Error appears when I use a Rare Candy on Meltan:
Code:
---------------------------
Error
---------------------------
Script 'Pokémon Amie by Pizza Sun' line 352: NoMethodError occurred.

undefined method `pbCheckEvolution' for nil:NilClass

from 'Pokémon Amie by Pizza Sun' line 352 in `pbChangeLevel'
from 'Pokémon Amie by Pizza Sun' line 268
from 'Pokémon Amie by Pizza Sun' line 263 in `call'
from 'EventHandlers' line 150 in `trigger'
from 'PItem_Items' line 228 in `follow_triggerUseOnPokemon'
from 'Following Pokemon v.1.4' line 1891 in `triggerUseOnPokemon'
from 'PItem_Items' line 634 in `pbUseItem'
from 'PItem_Items' line 628 in `loop'
from 'PItem_Items' line 647 in `pbUseItem'
from 'PItem_Items' line 624 in `pbFadeOutIn'
from 'PItem_Items' line 624 in `pbUseItem'
from 'PScreen_Bag' line 485 in `pbStartScreen'
---------------------------
OK  
---------------------------

I searched all the lines in the script editor:

Code:
    return handler ? handler.call(fromSymbol(sym),*args) : nil
Code:
    return UseOnPokemon.trigger(item,pokemon,scene)
Code:
    ret=ItemHandlers.triggerUseOnPokemon(item,pokemon,screen)
Code:
      loop do
Code:
      end
Code:
    pbFadeOutIn(99999){
Code:
        ret = pbUseItem(@bag,item,@scene)
Code:
    ret = follow_triggerUseOnPokemon(item,pokemon,scene)
Code:
    newspecies=pbCheckEvolution(pokemon)
Code:
     pbChangeLevel(pokemon,pokemon.level+1,scene)
Code:
ItemHandlers::UseOnPokemon.add(:RARECANDY,proc{|item,pokemon,scene|
 
Last edited:
Top