Go Back   The PokéCommunity Forums > Cilerba
Reload this Page Conversation Between Cilerba and KitsuneKouta

Notices
For all updates, view the main page.



Conversation Between Cilerba and KitsuneKouta
Showing Visitor Messages 121 to 135 of 249
  1. KitsuneKouta
    December 17th, 2010 04:00 PM
    KitsuneKouta
    Do you have any auto run events too? I had problems some time ago where I had both a parallel process and an autorun that refused to work at the same time. Also, are you using loops or anything in the parallel processes? I think that's what gave me trouble before.
  2. Cilerba
    December 17th, 2010 12:13 PM
    Cilerba
    This is weird. It seems as if it's only happening with parallel process events. I'll let you know if it's ALL parallel process events.

    EDIT: Yup, it seems that every parallel process event I create, pops up with the error. >:
  3. Cilerba
    December 17th, 2010 11:58 AM
    Cilerba
    It works now. n__n
    Thanks a lot. :D
  4. KitsuneKouta
    December 16th, 2010 07:33 PM
    KitsuneKouta
    Maybe it's a problem with an event in the map. Try moving the map out of the data folder (unless you really want to erase it...), and see if the error still pops up. It may be that a call script (could be for anything) has an error in it (such as a typo) in one of the events. I don't know how likely that is, but if calling a non existent trainer in an event in a random map can cause a random error, then it's certainly possible.
  5. Cilerba
    December 16th, 2010 03:58 PM
    Cilerba
    Nope. Those are the only changes. Other than making two maps (well, one map, since they were both on the same map) there were no other changes.
  6. KitsuneKouta
    December 16th, 2010 03:35 PM
    KitsuneKouta
    Is there anything else at all, however small, that was edited remotely close to the time that the error popped up? Maybe you could do what thepsynergist did and just copy/paste your whole project into a new folder, lol. It worked for him. If nothing else, you may have to drop everything into a new kit. Hasn't something like this happened before? The errors you get always seem to be really bad.
  7. Cilerba
    December 16th, 2010 11:55 AM
    Cilerba
    There's no 'Continue' option. I have no save file. D:
  8. KitsuneKouta
    December 15th, 2010 08:05 PM
    KitsuneKouta
    Ok, try erasing (or just moving) the save file of your game (if you have one). It it's corrupted, it can give an error as well. And just to make sure, if you already have a save file, does the continue option work fine?
  9. Cilerba
    December 15th, 2010 05:21 PM
    Cilerba
    Nope, no changes there. ):
  10. KitsuneKouta
    December 15th, 2010 03:03 PM
    KitsuneKouta
    Hmm...the error comes up when you start a new game, and the new game handler is in PokemonLoad. So logically it should be a problem with PokemonLoad, or something it interacts with. Has there been any other edits, like in PokemonSave? Or anything?
  11. Cilerba
    December 15th, 2010 12:03 PM
    Cilerba
    This is what I have:

    Spoiler:

    STARTING_OVER_SWITCH=5
    GRASS_ANIMATION_ID=103
    EXCLAMATION_ANIMATION_ID=17
    FISHINGBEGINCOMMONEVENT=-1
    FISHINGENDCOMMONEVENT=-1
    HIDDENMACHINECOMMONEVENT=-1

    ####################################

    class RectInterpolator
    def initialize(oldrect,newrect,frames)
    restart(oldrect,newrect,frames)
    end
    def restart(oldrect,newrect,frames)
    @oldrect=oldrect
    @newrect=newrect
    @frames=[frames,1].max
    @curframe=0
    @rect=oldrect.clone
    end
    def set(rect)
    rect.set(@rect.x,@rect.y,@rect.width,@rect.height)
    end
    def done?
    @curframe>@frames
    end
    def update
    return if done?
    t=(@curframe*1.0/@frames)
    x1=@oldrect.x
    x2=@newrect.x
    x=x1+t*(x2-x1)
    y1=@oldrect.y
    y2=@newrect.y
    y=y1+t*(y2-y1)
    rx1=@[email protected]
    rx2=@[email protected]
    rx=rx1+t*(rx2-rx1)
    ry1=@[email protected]
    ry2=@[email protected]
    ry=ry1+t*(ry2-ry1)
    minx=x<rx ? x : rx
    maxx=x>rx ? x : rx
    miny=y<ry ? y : ry
    maxy=y>ry ? y : ry
    @rect.set(minx,miny,maxx-minx,maxy-miny)
    @curframe+=1
    end
    end

    class PointInterpolator
    def initialize(oldx,oldy,newx,newy,frames)
    restart(oldx,oldy,newx,newy,frames)
    end
    def restart(oldx,oldy,newx,newy,frames)
    @oldx=oldx
    @oldy=oldy
    @newx=newx
    @newy=newy
    @frames=frames
    @curframe=0
    @x=oldx
    @y=oldy
    end
    def x; @x;end
    def y; @y;end
    def done?
    @curframe>@frames
    end
    def update
    return if done?
    t=(@curframe*1.0/@frames)
    rx1=@oldx
    rx2=@newx
    @x=rx1+t*(rx2-rx1)
    ry1=@oldy
    ry2=@newy
    @y=ry1+t*(ry2-ry1)
    @curframe+=1
    end
    end

    ####################################
    #
    # Graphics objects
    #


    class DarknessSprite < SpriteWrapper
    attr_reader :radius
    def initialize(viewport=nil)
    super(viewport)
    @darkness=BitmapWrapper.new(Graphics.width,Graphics.height)
    @radius=48
    self.bitmap=@darkness
    self.z=99998
    refresh
    end
    def dispose
    @darkness.dispose
    super
    end
    def radius=(value)
    @radius=value
    refresh
    end
    def refresh
    @darkness.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0,255))
    cx=240
    cy=160
    cradius=@radius
    for i in cx-cradius..cx+cradius
    diff2 = (cradius * cradius) - ((i - cx) * (i - cx));
    diff = Math.sqrt( diff2);
    @darkness.fill_rect(i,cy-diff,1,diff*2,Color.new(0,0,0,0))
    end
    end
    end

    class LocationWindow
    def initialize(name)
    @window=Window_AdvancedTextPokemon.new(name)
    @window.resizeToFit(name,Graphics.width)
    @window.x=0
    @window.y=[email protected]
    @window.z=99999
    @currentmap=$game_map.map_id
    @frames=0
    end
    def disposed?
    @window.disposed?
    end
    def dispose
    @window.dispose
    end
    def update
    return if @window.disposed?
    @window.update
    if $game_temp.message_window_showing ||
    @currentmap!=$game_map.map_id
    @window.dispose
    return
    end
    if @frames>80
    @window.y-=4
    @window.dispose if @[email protected]<0
    else
    @window.y+=4 if @window.y<0
    @frames+=1
    end
    end
    end

    class LightEffect
    def initialize(event,map=nil)
    @light = IconSprite.new(0,0)
    @light.setBitmap("Graphics/Pictures/LE")
    @light.z = 1000
    @event = event
    @map=map ? map : $game_map
    @disposed=false
    end
    def disposed?
    return @disposed
    end
    def dispose
    @light.dispose
    @map=nil
    @event=nil
    @disposed=true
    end
    def update
    @light.update
    end
    end

    class LightEffect_Lamp < LightEffect
    def initialize(event,map=nil)
    @light = Sprite.new
    lamp = AnimatedBitmap.new("Graphics/Pictures/LE")
    @light.bitmap = Bitmap.new(128,64)
    src_rect = Rect.new(0, 0, 64, 64)
    @light.bitmap.blt(0, 0, lamp.bitmap, src_rect)
    @light.bitmap.blt(20, 0, lamp.bitmap, src_rect)
    lamp.dispose
    @light.visible = true
    @light.z = 1000
    @map=map ? map : $game_map
    @event = event
    end
    end

    class LightEffect_Basic < LightEffect
    def initialize(event,map=nil)
    super
    end
    def update
    return if !@light || !@event
    super
    @light.opacity = 100
    @light.ox=32
    @light.oy=48
    if (Object.const_defined?(:ScreenPosHelper) rescue false)
    @light.x = ScreenPosHelper.pbScreenX(@event)
    @light.y = ScreenPosHelper.pbScreenY(@event)
    @light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
    else
    @light.x = @event.screen_x
    @light.y = @event.screen_y
    @light.zoom_x = 1.0
    end
    @light.zoom_y = @light.zoom_x
    @light.tone=$game_screen.tone
    end
    end


    class LightEffect_DayNight < LightEffect
    def initialize(event,map=nil)
    super
    end
    def update
    return if !@light || !@event
    super
    shade=PBDayNight.getShade()
    if shade>=144
    shade=255
    elsif shade<=64
    shade=0
    else
    shade=255-(255*(144-shade)/(144-64))
    end
    @light.opacity = 255-shade
    if @light.opacity>0
    @light.ox=32
    @light.oy=48
    if (Object.const_defined?(:ScreenPosHelper) rescue false)
    @light.x = ScreenPosHelper.pbScreenX(@event)
    @light.y = ScreenPosHelper.pbScreenY(@event)
    @light.zoom_x = ScreenPosHelper.pbScreenZoomX(@event)
    @light.zoom_y = ScreenPosHelper.pbScreenZoomY(@event)
    else
    @light.x = @event.screen_x
    @light.y = @event.screen_y
    @light.zoom_x = 1.0
    @light.zoom_y = 1.0
    end
    @light.tone.set(
    $game_screen.tone.red,
    $game_screen.tone.green,
    $game_screen.tone.blue,
    $game_screen.tone.gray)
    end
    end
    end

    ####################################

    module EncounterModifier
    @@procs=[]
    def self.register(p)
    @@procs.push(p)
    end
    def self.trigger(encounter)
    for prc in @@procs
    encounter=prc.call(encounter)
    end
    return encounter
    end
    end

    module Events
    # This module stores events that can happen during
    # the game. A procedure can subscribe to an event by
    # adding itself to the event. It will then be called
    # whenever the event occurs.
    @@OnMapChange=Event.new
    @@OnMapSceneChange=Event.new
    @@OnMapUpdate=Event.new
    @@OnMapChanging=Event.new
    @@OnLeaveTile=Event.new
    @@OnStepTaken=Event.new
    @@OnStepTakenTransferPossible=Event.new
    @@OnStepTakenFieldMovement=Event.new
    @@OnWildBattleOverride=Event.new
    @@OnWildBattleEnd=Event.new
    @@OnWildPokemonCreate=Event.new
    @@OnSpritesetCreate=Event.new
    @@OnStartBattle=Event.new
    @@OnEndBattle=Event.new
    @@OnMapCreate=Event.new
    @@OnAction=Event.new
    # Triggers when the player presses the Action button
    # on the map.
    def self.onAction=(v)
    @@OnAction=v
    end
    def self.onAction
    @@OnAction
    end
    def self.onStartBattle=(v)
    @@OnStartBattle=v
    end
    def self.onStartBattle
    @@OnStartBattle
    end
    def self.onEndBattle=(v)
    @@OnEndBattle=v
    end
    def self.onEndBattle
    @@OnEndBattle
    end
    # Fires whenever a map is created.
    # Event handler receives two parameters: the map
    # (RPG::Map) and the tileset (RPG::Tileset)
    def self.onMapCreate=(v)
    @@OnMapCreate=v
    end
    def self.onMapCreate
    @@OnMapCreate
    end
    # Fires whenever the player moves to a new map.
    # Event handler receives the old map ID or 0 if none.
    # Also fires when the first map of the game is loaded
    def self.onMapChange=(v)
    @@OnMapChange=v
    end
    def self.onMapChange
    @@OnMapChange
    end
    # Fires whenever one map is about to change to a
    # different one. Event handler receives the new map ID
    # and the Game_Map object representing the new map.
    # When the event handler is called, $game_map still
    # refers to the old map.
    def self.onMapChanging=(v)
    @@OnMapChanging=v
    end
    def self.onMapChanging
    @@OnMapChanging
    end
    # Fires whenever the player takes a step.
    def self.onStepTaken=(v)
    @@OnStepTaken=v
    end
    def self.onStepTaken
    @@OnStepTaken
    end
    # Fires whenever the player or another event leaves a tile.
    # Parameters:
    # e[0] - Event that just left the tile.
    # e[1] - Map ID where the tile is located (not necessarily
    # the current map). Use "$MapFactory.getMap(e[1])" to
    # get the Game_Map object corresponding to that map.
    # e[2] - X-coordinate of the tile
    # e[3] - Y-coordinate of the tile
    def self.onLeaveTile=(v)
    @@OnLeaveTile=v
    end
    def self.onLeaveTile
    @@OnLeaveTile
    end
    # Fires whenever the player or another event enters a tile.
    # Parameters:
    # e[0] - Event that just entered a tile.
    def self.onStepTakenFieldMovement=(v)
    @@OnStepTakenFieldMovement=v
    end
    def self.onStepTakenFieldMovement
    @@OnStepTakenFieldMovement
    end
    # Fires whenever the player takes a step. The event
    # handler may possibly move the player elsewhere.
    # Parameters:
    # e[0] = Array that contains a single boolean value.
    # If an event handler moves the player to a new map,
    # it should set this value to true. Other event handlers
    # should check this parameter's value.
    def self.onStepTakenTransferPossible=(v)
    @@OnStepTakenTransferPossible=v
    end
    def self.onStepTakenTransferPossible
    @@OnStepTakenTransferPossible
    end
    # Fires each frame during a map update.
    def self.onMapUpdate=(v)
    @@OnMapUpdate=v
    end
    def self.onMapUpdate
    @@OnMapUpdate
    end
    # Triggers at the start of a wild battle
    # Event handlers can provide their own wild battle routines
    # to override the default behavior.
    def self.onWildBattleOverride=(v)
    @@OnWildBattleOverride=v
    end
    def self.onWildBattleOverride
    @@OnWildBattleOverride
    end
    # Triggers whenever a wild Pokémon battle ends
    # Parameters:
    # e[0] - Pokémon species
    # e[1] - Pokémon level
    # e[2] - Battle result (1-win, 2-loss, 3-escaped, 4-caught, 5-draw)
    def self.onWildBattleEnd=(v)
    @@OnWildBattleEnd=v
    end
    def self.onWildBattleEnd
    @@OnWildBattleEnd
    end
    # Triggers whenever a wild Pokémon is created
    # Parameters:
    # e[0] - Pokémon being created
    def self.onWildPokemonCreate=(v)
    @@OnWildPokemonCreate=v
    end
    def self.onWildPokemonCreate
    @@OnWildPokemonCreate
    end
    # Fires whenever the map scene is regenerated
    # and soon after the player moves to a new map.
    # Parameters:
    # e[0] = Scene_Map object.
    # e[1] = Whether the player just moved to a new map (either
    # true or false).
    # If false, some other code had called $scene.createSpritesets
    # to regenerate the map scene without transferring the player
    # elsewhere
    def self.onMapSceneChange=(v)
    @@OnMapSceneChange=v
    end
    def self.onMapSceneChange
    @@OnMapSceneChange
    end
    # Fires whenever a spriteset is created.
    # Parameters:
    # e[0] = Spriteset being created
    # e[1] = Viewport used for tilemap and characters
    # e[0].map = Map associated with the spriteset (not
    # necessarily the current map).
    def self.onSpritesetCreate=(v)
    @@OnSpritesetCreate=v
    end
    def self.onSpritesetCreate
    @@OnSpritesetCreate
    end
    end

    def pbNewBattleScene
    return PokeBattle_Scene.new
    end

    def pbSceneStandby
    if $scene && $scene.is_a?(Scene_Map)
    $scene.disposeSpritesets
    end
    GC.start
    Graphics.frame_reset
    yield
    if $scene && $scene.is_a?(Scene_Map)
    $scene.createSpritesets
    end
    end


    def pbLedge(xOffset,yOffset)
    facingTag=Kernel.pbFacingTerrainTag()
    if(facingTag==PBTerrain::Ledge) # ledge terrain tag
    if Kernel.pbJumpToward(2,true)
    $game_player.increase_steps
    $game_player.check_event_trigger_here([1,2])
    end
    return true
    end
    return false
    end


    class PBTerrain
    Ledge=1
    Grass=2
    Sand=3
    Rock=4
    DeepWater=5
    StillWater=6
    Water=7
    Waterfall=8
    WaterfallCrest=9
    TallGrass=10
    UnderwaterGrass=11
    Ice=12
    Neutral=13
    end

    def pbIsSurfableTag?(tag)
    return pbIsWaterTag?(tag)
    end

    def pbIsPassableWaterTag?(tag)
    return tag==PBTerrain::DeepWater||
    tag==PBTerrain::Water||
    tag==PBTerrain::StillWater||
    tag==PBTerrain::WaterfallCrest
    end

    def pbIsGrassTag?(tag)
    return tag==PBTerrain::Grass||
    tag==PBTerrain::TallGrass||
    tag==PBTerrain::UnderwaterGrass
    end

    def pbIsWaterTag?(tag)
    return tag==PBTerrain::DeepWater||
    tag==PBTerrain::Water||
    tag==PBTerrain::StillWater||
    tag==PBTerrain::WaterfallCrest||
    tag==PBTerrain::Waterfall
    end

    class Game_Temp
    attr_accessor :background_bitmap
    end

    def pbBattleAnimation(bgm=nil)
    handled=false
    playingBGS=$game_system.getPlayingBGS
    playingBGM=$game_system.getPlayingBGM
    $game_system.bgm_pause
    $game_system.bgs_pause
    if bgm
    pbBGMPlay(bgm)
    else
    pbBGMPlay(pbGetWildBattleBGM(0))
    end
    viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
    viewport.z=99999
    #
    # Fade to gray a few times.
    #
    viewport.color=Color.new(17*8,17*8,17*8)
    3.times do
    viewport.color.alpha=0
    6.times do
    viewport.color.alpha+=30
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    6.times do
    viewport.color.alpha-=30
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    end
    if $game_temp.background_bitmap
    $game_temp.background_bitmap.dispose
    end
    $game_temp.background_bitmap=Graphics.snap_to_bitmap
    #
    # Animate the screen ($game_temp.background_bitmap contains
    # the current game screen).
    #
    # The following example runs a common event that does
    # a custom animation if some condition is true. The screen
    # should fade to black when the common event is finished:
    #
    #if $game_map && $game_map.map_id==20 # If on map 20
    # pbCommonEvent(20)
    # handled=true # Note that the battle animation is done
    #end
    #
    if !handled
    if Sprite.method_defined?(:wave_amp) && rand(15)==0
    viewport.color=Color.new(0,0,0,255)
    sprite = Sprite.new
    bitmap=Graphics.snap_to_bitmap
    bm=bitmap.clone
    sprite.z=99999
    sprite.bitmap = bm
    sprite.wave_speed=500
    for i in 0..25
    sprite.opacity-=10
    sprite.wave_amp+=60
    sprite.update
    sprite.wave_speed+=30
    2.times do
    Graphics.update
    end
    end
    bitmap.dispose
    bm.dispose
    sprite.dispose
    elsif Bitmap.method_defined?(:radial_blur) && rand(15)==0
    viewport.color=Color.new(0,0,0,255)
    sprite = Sprite.new
    bitmap=Graphics.snap_to_bitmap
    bm=bitmap.clone
    sprite.z=99999
    sprite.bitmap = bm
    for i in 0..15
    bm.radial_blur(i,2)
    sprite.opacity-=15
    2.times do
    Graphics.update
    end
    end
    bitmap.dispose
    bm.dispose
    sprite.dispose
    elsif rand(15)==0
    scroll=["ScrollDown","ScrollLeft","ScrollRight","ScrollUp"]
    Graphics.freeze
    viewport.color=Color.new(0,0,0,255)
    Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(4)]))
    elsif rand(15)==0
    scroll=["ScrollDownRight","ScrollDownLeft","ScrollUpRight","ScrollUpLeft"]
    Graphics.freeze
    viewport.color=Color.new(0,0,0,255)
    Graphics.transition(50,sprintf("Graphics/Transitions/%s",scroll[rand(4)]))
    else
    transitions=["Splash","Image1","Image2",
    "Image3","Image4","Random_stripe_h",
    "Random_stripe_v","BreakingGlass",
    "RotatingPieces","022-Normal02",
    "021-Normal01","Battle","Mosaic","ShrinkingPieces","zoomin",
    "computertrclose",
    "hexatr",
    "hexatzr",
    "battle1",
    "battle2",
    "battle3",
    "battle4",
    "computertr",
    "hexatrc"
    ]
    rnd=rand(transitions.length)
    Graphics.freeze
    viewport.color=Color.new(0,0,0,255)
    Graphics.transition(40,
    sprintf("Graphics/Transitions/%s",transitions[rnd]))
    end
    end
    5.times do
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    pbPushFade
    yield if block_given?
    pbPopFade
    $game_system.bgm_resume(playingBGM)
    $game_system.bgs_resume(playingBGS)
    $PokemonGlobal.nextBattleBGM=nil
    $PokemonGlobal.nextBattleME=nil
    $PokemonGlobal.nextBattleBack=nil
    $PokemonEncounters.clearStepCount
    for j in 0..17
    viewport.color=Color.new(0,0,0,(17-j)*15)
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    viewport.dispose
    end

    def pbGenerateWildPokemon(species,level)
    genwildpoke=PokeBattle_Pokemon.new(species,level,$Trainer)
    dexdata=pbOpenDexData
    itemrnd=rand(100)
    if itemrnd<50
    pbDexDataOffset(dexdata,species,48)
    genwildpoke.item=dexdata.fgetw
    elsif itemrnd<55
    pbDexDataOffset(dexdata,species,50)
    genwildpoke.item=dexdata.fgetw
    end
    dexdata.close
    Events.onWildPokemonCreate.trigger(nil,genwildpoke)
    return genwildpoke
    end

    def pbPrepareBattle(battle)
    if $game_screen.weather_type==1 || $game_screen.weather_type==2
    battle.weather=PBWeather::RAINDANCE
    battle.weatherduration=-1
    elsif $game_screen.weather_type==3
    battle.weather=PBWeather::HAIL
    battle.weatherduration=-1
    elsif $game_screen.weather_type==4
    battle.weather=PBWeather::SANDSTORM
    battle.weatherduration=-1
    elsif $game_screen.weather_type==5
    battle.weather=PBWeather::SUNNYDAY
    battle.weatherduration=-1
    end
    battle.shiftStyle=($PokemonSystem.battlestyle==0)
    battle.battlescene=($PokemonSystem.battlescene==0)
    battle.environment=pbGetEnvironment
    end

    def pbEvolutionCheck(currentlevels)
    # Check conditions for evolution
    for i in 0...currentlevels.length
    pokemon=$Trainer.party[i]
    if pokemon && (!currentlevels[i] || pokemon.level!=currentlevels[i])
    newspecies=Kernel.pbCheckEvolution(pokemon)
    if newspecies>0
    # Start evolution scene
    evo=PokemonEvolutionScene.new
    evo.pbStartScreen(pokemon,newspecies)
    evo.pbEvolution
    evo.pbEndScreen
    end
    end
    end
    end


    def pbWildBattle(species,level,variable=nil,canescape=true)
    if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
    if $Trainer.pokemonCount>0
    Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
    end
    pbSet(variable,1)
    $PokemonGlobal.nextBattleBGM=nil
    $PokemonGlobal.nextBattleME=nil
    $PokemonGlobal.nextBattleBack=nil
    return true
    end
    handled=[nil]
    Events.onWildBattleOverride.trigger(nil,species,level,handled)
    if handled[0]!=nil
    return handled[0]
    end
    currentlevels=[]
    for i in $Trainer.party
    currentlevels.push(i.level)
    end
    genwildpoke=pbGenerateWildPokemon(species,level)
    Events.onStartBattle.trigger(nil,genwildpoke)
    scene=pbNewBattleScene
    battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke],$Trainer,nil)
    battle.internalbattle=true
    battle.cantescape=!canescape
    pbPrepareBattle(battle)
    restorebgm=true
    decision=0
    pbBattleAnimation(pbGetWildBattleBGM(species)) {
    pbSceneStandby {
    decision=battle.pbStartBattle
    }
    if decision==2 || decision==5 # if loss or draw
    $game_system.bgm_unpause
    $game_system.bgs_unpause
    Kernel.pbStartOver
    end
    Events.onEndBattle.trigger(nil,decision)
    }
    Input.update
    pbSet(variable,decision)
    Events.onWildBattleEnd.trigger(nil,species,level,decision)
    return (decision!=2)
    end

    def pbRegisterPartner(trainerid,trainername,partyid=0)
    trainer=pbLoadTrainer(trainerid,trainername,partyid)
    trainerobject=PokeBattle_Trainer.new(_INTL(trainername),trainerid)
    trainerobject.setForeignID($Trainer)
    for i in trainer[2]
    i.trainerID=trainerobject.id
    i.ot=trainerobject.name
    i.calcStats
    end
    $PokemonGlobal.partner=[trainerid,trainerobject.name,trainerobject.id,trainer[2]]
    end

    def pbDeregisterPartner
    $PokemonGlobal.partner=nil
    end

    def pbDoubleWildBattle(species1,level1,species2,level2,variable=nil,canescape=true)
    if (Input.press?(Input::CTRL) && $DEBUG) || $Trainer.pokemonCount==0
    if $Trainer.pokemonCount>0
    Kernel.pbMessage(_INTL("SKIPPING BATTLE..."))
    end
    pbSet(variable,1)
    $PokemonGlobal.nextBattleBGM=nil
    $PokemonGlobal.nextBattleME=nil
    $PokemonGlobal.nextBattleBack=nil
    return true
    end
    currentlevels=[]
    for i in $Trainer.party
    currentlevels.push(i.level)
    end
    genwildpoke=pbGenerateWildPokemon(species1,level1)
    genwildpoke2=pbGenerateWildPokemon(species2,level2)
    Events.onStartBattle.trigger(nil,genwildpoke)
    scene=pbNewBattleScene
    if $PokemonGlobal.partner
    othertrainer=PokeBattle_Trainer.new(
    $PokemonGlobal.partner[1],
    $PokemonGlobal.partner[0])
    othertrainer.id=$PokemonGlobal.partner[2]
    othertrainer.party=$PokemonGlobal.partner[3]
    combinedParty=[]
    pbHealAll()
    for i in 0...$Trainer.party.length
    combinedParty[i]=$Trainer.party[i]
    end
    for i in 0...othertrainer.party.length
    combinedParty[6+i]=othertrainer.party[i]
    end
    battle=PokeBattle_Battle.new(scene,combinedParty,[genwildpoke,genwildpoke2],
    [$Trainer,othertrainer],nil)
    battle.fullparty1=true
    else
    battle=PokeBattle_Battle.new(scene,$Trainer.party,[genwildpoke,genwildpoke2],
    $Trainer,nil)
    end
    battle.internalbattle=true
    battle.doublebattle=battle.pbDoubleBattleAllowed?()
    battle.cantescape=!canescape
    pbPrepareBattle(battle)
    decision=0
    pbBattleAnimation(pbGetWildBattleBGM(species1)) {
    pbSceneStandby {
    decision=battle.pbStartBattle
    }
    if $PokemonGlobal.partner
    pbHealAll()
    end
    if decision==2 || decision==5
    $game_system.bgm_unpause
    $game_system.bgs_unpause
    Kernel.pbStartOver
    end
    Events.onEndBattle.trigger(nil,decision)
    }
    Input.update
    pbSet(variable,decision)
    return (decision!=2 && decision!=5)
    end

    def pbDynamicItemList(*args)
    ret=[]
    for i in 0...args.length
    if hasConst?(PBItems,args[i])
    ret.push(getConst(PBItems,args[i].to_sym))
    end
    end
    return ret
    end

    def Kernel.pbPickup(pokemon)
    return if !isConst?(pokemon.ability,PBAbilities,:PICKUP) || pokemon.egg?
    return if pokemon.item!=0
    return if rand(10)!=0
    pickupList=pbDynamicItemList(
    :POTION,
    :ANTIDOTE,
    :SUPERPOTION,
    :GREATBALL,
    :REPEL,
    :ESCAPEROPE,
    :XATTACK,
    :FULLHEAL,
    :ULTRABALL,
    :HYPERPOTION,
    :RARECANDY,
    :PROTEIN,
    :REVIVE,
    :HPUP,
    :FULLRESTORE,
    :MAXREVIVE,
    :PPUP,
    :MAXELIXIR
    )
    pickupListRare=pbDynamicItemList(
    :HYPERPOTION,
    :NUGGET,
    :KINGSROCK,
    :FULLRESTORE,
    :ETHER,
    :WHITEHERB,
    :TM44,
    :ELIXIR,
    :TM01,
    :LEFTOVERS,
    :TM26
    )
    return if pickupList.length!=18
    return if pickupListRare.length!=11
    randlist=[30,10,10,10,10,10,10,5,3,1,1]
    items=[]
    rnd=rand(100)
    itemstart=(pokemon.level-1)/10
    itemstart=0 if itemstart<0
    for i in 0...9
    items.push(pickupList[i+itemstart])
    end
    items.push(pickupListRare[itemstart])
    items.push(pickupListRare[itemstart+1])
    cumnumber=0
    for i in 0...11
    cumnumber+=randlist[i]
    if rnd<cumnumber
    pokemon.item=items[i]
    break
    end
    end
    end

    class PokemonTemp
    attr_accessor :encounterType
    end

    def pbEncounter(enctype)
    if $PokemonGlobal.partner
    encounter1=$PokemonEncounters.pbEncounteredPokemon(enctype)
    return false if !encounter1
    encounter2=$PokemonEncounters.pbEncounteredPokemon(enctype)
    return false if !encounter2
    $PokemonTemp.encounterType=enctype
    pbDoubleWildBattle(encounter1[0],encounter1[1],
    encounter2[0],encounter2[1])
    $PokemonTemp.encounterType=-1
    return true
    else
    encounter=$PokemonEncounters.pbEncounteredPokemon(enctype)
    return false if !encounter
    $PokemonTemp.encounterType=enctype
    pbWildBattle(encounter[0],encounter[1])
    $PokemonTemp.encounterType=-1
    return true
    end
    end

    def pbCheckAllFainted()
    if pbAllFainted
    Kernel.pbMessage(_INTL("{1} has no usable Pokémon!\1",$Trainer.name))
    Kernel.pbMessage(_INTL("{1} whited out!",$Trainer.name))
    pbBGMFade(1.0)
    pbBGSFade(1.0)
    pbFadeOutIn(99999){
    Kernel.pbStartOver
    }
    end
    end

    class PokemonTemp
    attr_accessor :evolutionLevels
    end

    Events.onStartBattle+=proc {|sender,e|
    $PokemonTemp.evolutionLevels=[]
    for i in 0...$Trainer.party.length
    $PokemonTemp.evolutionLevels[i]=$Trainer.party[i].level
    end
    }

    Events.onEndBattle+=proc {|sender,e|
    decision=e[0]
    if decision!=2 && decision!=5 # not a loss or a draw
    if $PokemonTemp.evolutionLevels
    pbEvolutionCheck($PokemonTemp.evolutionLevels)
    $PokemonTemp.evolutionLevels=nil
    end
    end
    if decision==1
    for pkmn in $Trainer.party
    Kernel.pbPickup(pkmn)
    end
    end
    }

    # Poison event on each step taken
    Events.onStepTakenTransferPossible+=proc {|sender,e|
    handled=e[0]
    next if handled[0]
    if $PokemonGlobal.stepcount % 4 == 0
    flashed=false
    for i in $Trainer.party
    if i.status==PBStatuses::POISON && i.hp>0 && !i.egg?
    if !flashed
    $game_screen.start_flash(Color.new(255,0,0,128), 4)
    flashed=true
    end
    i.hp-=1
    if i.hp==0
    Kernel.pbMessage(_INTL("{1} fainted...",i.name))
    end
    handled[0]=true if pbAllFainted
    pbCheckAllFainted()
    end
    end
    end
    }


    Events.onStepTaken+=proc{
    $PokemonGlobal.happinessSteps=0 if !$PokemonGlobal.happinessSteps
    $PokemonGlobal.happinessSteps+=1
    if $PokemonGlobal.happinessSteps==256
    for pkmn in $Trainer.party
    if pkmn.hp>0 && !pkmn.egg?
    pkmn.happiness+=1
    if isConst?(pkmn.item,PBItems,:SHELLBELL)
    pkmn.happiness+=1
    end
    pkmn.happiness=255 if pkmn.happiness>255
    end
    end
    $PokemonGlobal.happinessSteps=0
    end
    }


    def Kernel.pbSlideOnIce(event=nil)
    event=$game_player if !event
    return if !event
    direction=event.direction
    continuing=true
    oldwalkanime=event.walk_anime
    event.straighten
    event.walk_anime=false
    begin
    break if !event.passable?(event.x,event.y,direction)
    case direction
    when 2
    event.move_down
    when 4
    event.move_left
    when 6
    event.move_right
    when 8
    event.move_up
    end
    while event.moving?
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    end while pbGetTerrainTag(event)==PBTerrain::Ice
    event.walk_anime=oldwalkanime
    end


    #############################################

    Events.onStepTakenFieldMovement+=proc{|sender,e|
    event=e[0] # Get the event affected by field movement
    currentTag=pbGetTerrainTag(event)
    if currentTag==PBTerrain::Grass
    $scene.spriteset.addUserAnimation(GRASS_ANIMATION_ID,event.x,event.y)
    elsif event==$game_player && currentTag==PBTerrain::WaterfallCrest
    # Descend waterfall, but only if this event is the player
    Kernel.pbDescendWaterfall(event)
    elsif $game_map.terrain_tag(event.x,event.y)==PBTerrain::Ice
    Kernel.pbSlideOnIce(event)
    end
    }

    def pbBattleOnStepTaken
    if $Trainer.party.length > 0
    encounterType=$PokemonEncounters.pbEncounterType
    if encounterType>=0
    encounter=$PokemonEncounters.pbGenerateEncounter(encounterType)
    if $PokemonEncounters.isEncounterPossibleHere?()
    encounter=EncounterModifier.trigger(encounter)
    if encounter && !$game_system.encounter_disabled &&
    !($DEBUG && Input.press?(Input::CTRL))
    if $PokemonGlobal.partner
    encounter2=$PokemonEncounters.pbEncounteredPokemon(encounterType)
    pbDoubleWildBattle(
    encounter[0],encounter[1],
    encounter2[0],encounter2[1])
    else
    pbWildBattle(encounter[0],encounter[1])
    end
    end
    end
    end
    end
    end

    def Kernel.pbOnStepTaken(eventTriggered)
    if $game_player.move_route_forcing || pbMapInterpreterRunning? || !$Trainer
    # if forced movement or if no trainer was created yet
    Events.onStepTakenFieldMovement.trigger(nil,$game_player)
    return
    end
    $PokemonGlobal.stepcount=0 if !$PokemonGlobal.stepcount
    $PokemonGlobal.stepcount+=1
    $PokemonGlobal.stepcount&=0x7FFFFFFF
    Events.onStepTaken.trigger(nil)
    Events.onStepTakenFieldMovement.trigger(nil,$game_player)
    handled=[nil]
    Events.onStepTakenTransferPossible.trigger(nil,handled)
    return if handled[0]
    if !eventTriggered
    pbBattleOnStepTaken()
    end
    end

    #############################################

    def pbGetEnvironment
    return PBEnvironment::None if !$game_map
    if $PokemonGlobal && $PokemonGlobal.diving
    return PBEnvironment::Underwater
    elsif $PokemonEncounters && $PokemonEncounters.isCave?
    return PBEnvironment::Cave
    elsif !pbGetMetadata($game_map.map_id,MetadataOutdoor)
    return PBEnvironment::None
    else
    terrain=$game_player.terrain_tag
    if terrain==PBTerrain::Grass # Normal grass
    return PBEnvironment::Grass
    elsif terrain==PBTerrain::TallGrass # Tall grass
    return PBEnvironment::TallGrass
    elsif terrain==PBTerrain::DeepWater || terrain==PBTerrain::Water
    return PBEnvironment::MovingWater
    elsif terrain==PBTerrain::StillWater
    return PBEnvironment::StillWater
    elsif terrain==PBTerrain::Rock
    return PBEnvironment::Rock
    elsif terrain==PBTerrain::Sand
    return PBEnvironment::Sand
    end
    return PBEnvironment::None
    end
    end



    Events.onMapChange+=proc {|sender,e|
    oldid=e[0] # previous map ID, 0 if no map ID
    healing=pbGetMetadata($game_map.map_id,MetadataHealingSpot)
    if healing
    $PokemonGlobal.healingSpot=healing
    end
    $PokemonMap.clear if $PokemonMap
    if $PokemonEncounters
    $PokemonEncounters.setup($game_map.map_id)
    end
    $PokemonGlobal.visitedMaps[$game_map.map_id]=true
    if oldid!=0 && oldid!=$game_map.map_id
    weather=pbGetMetadata($game_map.map_id,MetadataWeather)
    if weather && rand(100)<weather[1]
    $game_screen.weather(weather[0],8,20)
    end
    end
    }

    Events.onMapChanging+=proc {|sender,e|
    newmapID=e[0]
    newmap=e[1]
    # Undo the weather ($game_map still refers to the old map)
    weather=pbGetMetadata($game_map.map_id,MetadataWeather)
    if weather
    $game_screen.weather(0,0,0)
    end
    }


    Events.onMapSceneChange+=proc{|sender,e|
    scene=e[0]
    mapChanged=e[1]
    return if !scene || !scene.spriteset
    darkmap=pbGetMetadata($game_map.map_id,MetadataDarkMap)
    if darkmap && !$PokemonGlobal.flashUsed
    $PokemonTemp.darknessSprite=DarknessSprite.new
    scene.spriteset.addUserSprite($PokemonTemp.darknessSprite)
    else
    if !darkmap
    $PokemonGlobal.flashUsed=false
    end
    if $PokemonTemp.darknessSprite
    $PokemonTemp.darknessSprite.dispose if $PokemonTemp.darknessSprite
    $PokemonTemp.darknessSprite=nil
    end
    end
    if mapChanged
    if pbGetMetadata($game_map.map_id,MetadataShowArea)
    scene.spriteset.addUserSprite(LocationWindow.new($game_map.name))
    end
    end
    if pbGetMetadata($game_map.map_id,MetadataBicycleAlways)
    Kernel.pbMountBike
    else
    if !pbCanUseBike?($game_map.map_id)
    Kernel.pbDismountBike
    end
    end
    }

    Events.onSpritesetCreate+=proc{|sender,e|
    spriteset=e[0] # Spriteset being created
    viewport=e[1] # Viewport used for tilemap and characters
    map=spriteset.map # Map associated with the spriteset (not necessarily the current map).
    for i in map.events.keys
    if map.events[i].name=="OutdoorLight"
    spriteset.addUserSprite(LightEffect_DayNight.new(map.events[i],map))
    elsif map.events[i].name=="Light"
    spriteset.addUserSprite(LightEffect_Basic.new(map.events[i],map))
    end
    end
    spriteset.addUserSprite(Particle_Engine.new(viewport,map))
    }

    def Kernel.pbOnSpritesetCreate(spriteset,viewport)
    Events.onSpritesetCreate.trigger(nil,spriteset,viewport)
    end

    def pbCanUseBike?(mapid)
    return true if pbGetMetadata(mapid,MetadataBicycleAlways)
    val=pbGetMetadata(mapid,MetadataBicycle)
    val=pbGetMetadata(mapid,MetadataOutdoor) if val==nil
    return val ? true : false
    end


    def pbBatteryLow?
    power="\0"*12
    begin
    sps=Win32API.new('kernel32.dll','GetSystemPowerStatus','p','l')
    rescue
    return false
    end
    if sps.call(power)==1
    status=power.unpack("CCCCVV")
    # Battery Flag
    if status[1]!=255 && (status[1]&6)!=0 # Low or Critical
    return true
    end
    # Battery Life Percent
    if status[2]<3 # Less than 3 percent
    return true
    end
    # Battery Life Time
    if status[4]<300 # Less than 5 minutes
    return true
    end
    end
    return false
    end

    class Game_Event
    def cooledDown?(seconds)
    if !(expired?(seconds) && tsOff?("A"))
    self.need_refresh=true
    return false
    else
    return true
    end
    end
    end

    class PokemonTemp
    attr_accessor :batterywarning
    attr_accessor :cueBGM
    attr_accessor :cueFrames
    end

    Events.onMapUpdate+=proc {|sender,e|
    if Time.now.sec==0 && $Trainer && $PokemonGlobal && $game_player && $game_map &&
    !$PokemonTemp.batterywarning &&
    !$game_player.move_route_forcing &&
    !pbMapInterpreterRunning? &&
    !$game_temp.message_window_showing &&
    pbBatteryLow?
    $PokemonTemp.batterywarning=true
    if Kernel.pbConfirmMessage(_INTL("The game has detected that the battery is low. Would you like to save the game now?"))
    pbSaveScreen
    elsif Kernel.pbConfirmMessage(_INTL("You may lose your progress if you don't save. Would you like to save now?"))
    pbSaveScreen
    end
    end
    if $PokemonTemp.cueFrames
    $PokemonTemp.cueFrames-=1
    if $PokemonTemp.cueFrames<=0
    $PokemonTemp.cueFrames=nil
    if $game_system.getPlayingBGM==nil
    pbBGMPlay($PokemonTemp.cueBGM)
    end
    end
    end
    }

    def pbCueBGM(bgm,seconds,volume=nil,pitch=nil)
    return if !bgm
    bgm=pbResolveAudioFile(bgm,volume,pitch)
    playingBGM=$game_system.playing_bgm
    if !playingBGM || playingBGM.name!=bgm.name || playingBGM.pitch!=bgm.pitch
    pbBGMFade(seconds)
    if !$PokemonTemp.cueFrames
    $PokemonTemp.cueFrames=(seconds*Graphics.frame_rate)*3/5
    end
    $PokemonTemp.cueBGM=bgm;
    elsif playingBGM
    pbBGMPlay(bgm)
    end
    end


    def pbAutoplayOnTransition
    surfbgm=pbGetMetadata(0,MetadataSurfBGM)
    bikebgm=pbGetMetadata(0,MetadataBicycleBGM)
    if $PokemonGlobal.surfing && surfbgm
    pbBGMPlay(surfbgm)
    else
    $game_map.autoplayAsCue
    end
    end

    def pbAutoplayOnSave
    surfbgm=pbGetMetadata(0,MetadataSurfBGM)
    bikebgm=pbGetMetadata(0,MetadataBicycleBGM)
    if $PokemonGlobal.surfing && surfbgm
    pbBGMPlay(surfbgm)
    elsif $PokemonGlobal.bicycle && bikebgm
    pbBGMPlay(bikebgm)
    else
    $game_map.autoplay
    end
    end

    def Kernel.pbUpdateVehicle
    meta=pbGetMetadata(0,MetadataPlayerA+$PokemonGlobal.playerID)
    if meta
    if $PokemonGlobal.diving
    $game_player.character_name=meta[6] && meta[6]!="" ? meta[6] : meta[1] # Diving graphic
    elsif $PokemonGlobal.surfing
    $game_player.character_name=meta[4] && meta[4]!="" ? meta[4] : meta[1] # Surfing graphic
    elsif $PokemonGlobal.bicycle
    $game_player.character_name=meta[2] && meta[2]!="" ? meta[2] : meta[1] # Bicycle graphic
    else
    $game_player.character_name=meta[1] # Regular graphic
    end
    end
    end

    def pbStartSurfing()
    Kernel.pbCancelVehicles
    $PokemonEncounters.clearStepCount
    $PokemonGlobal.surfing=true
    Kernel.pbJumpToward
    Kernel.pbUpdateVehicle
    $game_player.check_event_trigger_here([1,2])
    end

    def Kernel.pbMountBike
    return if $PokemonGlobal.bicycle
    $PokemonGlobal.bicycle=true
    Kernel.pbUpdateVehicle
    bikebgm=pbGetMetadata(0,MetadataBicycleBGM)
    if bikebgm
    pbCueBGM(bikebgm,0.5)
    end
    end

    def Kernel.pbDismountBike
    return if !$PokemonGlobal.bicycle
    $PokemonGlobal.bicycle=false
    Kernel.pbUpdateVehicle
    $game_map.autoplayAsCue
    end

    def Kernel.pbCancelVehicles(destination=nil)
    $PokemonGlobal.surfing=false
    $PokemonGlobal.diving=false
    if !destination || !pbCanUseBike?(destination)
    $PokemonGlobal.bicycle=false
    end
    Kernel.pbUpdateVehicle
    end

    def pbFishingBegin
    if !pbCommonEvent(FISHINGBEGINCOMMONEVENT)
    pattern=0
    playertrainer=pbGetPlayerTrainerType
    5.times do |pattern|
    $game_player.setDefaultCharName(sprintf("fishing%03d",playertrainer),pattern)
    2.times do
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    end
    end
    end

    def pbFishingEnd(oldpattern)
    if !pbCommonEvent(FISHINGENDCOMMONEVENT)
    pattern=0
    playertrainer=pbGetPlayerTrainerType
    5.times do |pattern|
    $game_player.setDefaultCharName(sprintf("fishing%03d",playertrainer),4-pattern)
    pattern+=1
    2.times do
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end
    end
    end
    end

    def pbWaitMessage(msgwindow,time)
    message=""
    (time+1).times do |i|
    message+=". " if i>0
    Kernel.pbMessageDisplay(msgwindow,message,false)
    20.times do
    Graphics.update
    Input.update
    pbUpdateSceneMap
    if Input.trigger?(Input::C)||Input.trigger?(Input::B)
    return true
    end
    end
    end
    return false
    end

    def pbWaitForInput(msgwindow,message,frames)
    Kernel.pbMessageDisplay(msgwindow,message,false)
    frames.times do
    Graphics.update
    Input.update
    pbUpdateSceneMap
    if Input.trigger?(Input::C)||Input.trigger?(Input::B)
    return true
    end
    end
    return false
    end

    def pbRecord(text,maxtime=30.0)
    text="" if !text
    textwindow=Window_UnformattedTextPokemon.newWithSize(text,
    0,0,Graphics.width,Graphics.height-96)
    textwindow.z=99999
    if text==""
    textwindow.visible=false
    end
    wave=nil
    msgwindow=Kernel.pbCreateMessageWindow
    oldvolume=Kernel.Audio_bgm_get_volume()
    Kernel.Audio_bgm_set_volume(0)
    delay=2
    delay.times do |i|
    Kernel.pbMessageDisplay(msgwindow,
    _ISPRINTF("Recording in {1:d} second(s)...\nPress ESC to cancel.",delay-i),false)
    Graphics.frame_rate.times do
    Graphics.update
    Input.update
    textwindow.update
    msgwindow.update
    if Input.trigger?(Input::B)
    Kernel.Audio_bgm_set_volume(oldvolume)
    Kernel.pbDisposeMessageWindow(msgwindow)
    textwindow.dispose
    return nil
    end
    end
    end
    Kernel.pbMessageDisplay(msgwindow,
    _INTL("NOW RECORDING\nPress ESC to stop recording."),false)
    if beginRecordUI
    frames=(maxtime*Graphics.frame_rate).to_i
    frames.times do
    Graphics.update
    Input.update
    textwindow.update
    msgwindow.update
    if Input.trigger?(Input::B)
    break
    end
    end
    tmpFile=ENV["TEMP"]+"\\record.wav"
    endRecord(tmpFile)
    wave=getWaveDataUI(tmpFile,true)
    if wave
    Kernel.pbMessageDisplay(msgwindow,
    _INTL("PLAYING BACK..."),false)
    textwindow.update
    msgwindow.update
    Graphics.update
    Input.update
    wave.play
    (Graphics.frame_rate*wave.time).to_i.times do
    Graphics.update
    Input.update
    textwindow.update
    msgwindow.update
    end
    end
    end
    Kernel.Audio_bgm_set_volume(oldvolume)
    Kernel.pbDisposeMessageWindow(msgwindow)
    textwindow.dispose
    return wave
    end

    def pbFishing(hasencounter)
    bitechance=65
    hookchance=65
    oldpattern=$game_player.fullPattern
    pbFishingBegin
    msgwindow=Kernel.pbCreateMessageWindow
    loop do
    time=2+rand(10)
    message=""
    time.times do
    message+=". "
    end
    if pbWaitMessage(msgwindow,time)
    pbFishingEnd(oldpattern)
    $game_player.setDefaultCharName("",oldpattern)
    Kernel.pbMessageDisplay(msgwindow,_INTL("Not even a nibble..."))
    Kernel.pbDisposeMessageWindow(msgwindow)
    return false
    end
    rnd=rand(100)
    if rnd<bitechance && hasencounter
    frames=rand(6)+15
    if !pbWaitForInput(msgwindow,message+_INTL("\r\nOh! A bite!"),frames)
    pbFishingEnd(oldpattern)
    $game_player.setDefaultCharName("",oldpattern)
    Kernel.pbMessageDisplay(msgwindow,_INTL("It got away..."))
    Kernel.pbDisposeMessageWindow(msgwindow)
    return false
    end
    rnd=rand(100)
    if rnd<hookchance
    Kernel.pbMessageDisplay(msgwindow,_INTL("A Pokémon's on the hook!"))
    Kernel.pbDisposeMessageWindow(msgwindow)
    $game_player.setDefaultCharName("",oldpattern)
    return true
    end
    hookchance+=15
    bitechance+=15
    else
    pbFishingEnd(oldpattern)
    $game_player.setDefaultCharName("",oldpattern)
    Kernel.pbMessageDisplay(msgwindow,_INTL("Not even a nibble..."))
    Kernel.pbDisposeMessageWindow(msgwindow)
    return false
    end
    end
    Kernel.pbDisposeMessageWindow(msgwindow)
    return false
    end




    def Kernel.pbSetPokemonCenter
    $PokemonGlobal.pokecenterMapId=$game_map.map_id
    $PokemonGlobal.pokecenterX=$game_player.x
    $PokemonGlobal.pokecenterY=$game_player.y
    $PokemonGlobal.pokecenterDirection=$game_player.direction
    end

    def Kernel.pbRxdataExists?(file)
    if $RPGVX
    return pbRgssExists?(file+".rvdata")
    else
    return pbRgssExists?(file+".rxdata")
    end
    end

    def Kernel.pbStartOver(gameover=false)
    if pbInBugContest?
    Kernel.pbBugContestStartOver
    return
    end
    pbHealAll()
    if $PokemonGlobal.pokecenterMapId && $PokemonGlobal.pokecenterMapId>=0
    if gameover
    Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]After the unfortunate defeat, {1} scurried to a Pokémon Center.",$Trainer.name))
    else
    Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]{1} scurried to a Pokémon Center, protecting the exhausted and fainted Pokémon from further harm.",$Trainer.name))
    end
    Kernel.pbCancelVehicles
    pbRemoveDependencies()
    $game_switches[STARTING_OVER_SWITCH]=true
    $game_temp.player_new_map_id=$PokemonGlobal.pokecenterMapId
    $game_temp.player_new_x=$PokemonGlobal.pokecenterX
    $game_temp.player_new_y=$PokemonGlobal.pokecenterY
    $game_temp.player_new_direction=$PokemonGlobal.pokecenterDirection
    $scene.transfer_player
    $game_map.refresh
    else
    homedata=pbGetMetadata(0,MetadataHome)
    if (homedata && !pbRxdataExists?(sprintf("Data/Map%03d",homedata[0])) )
    if $DEBUG
    Kernel.pbMessage(_ISPRINTF("Can't find the map 'Map{1:03d}' in the Data folder. The game will resume at the player's position.",homedata[0]))
    end
    pbHealAll()
    return
    end
    if gameover
    Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]After the unfortunate defeat, {1} scurried home.",$Trainer.name))
    else
    Kernel.pbMessage(_INTL("\\w[]\\wm\\c[8]\\l[3]{1} scurried home, protecting the exhausted and fainted Pokémon from further harm.",$Trainer.name))
    end
    if homedata
    Kernel.pbCancelVehicles
    pbRemoveDependencies()
    $game_switches[STARTING_OVER_SWITCH]=true
    $game_temp.player_new_map_id=homedata[0]
    $game_temp.player_new_x=homedata[1]
    $game_temp.player_new_y=homedata[2]
    $game_temp.player_new_direction=homedata[3]
    $scene.transfer_player
    $game_map.refresh
    else
    pbHealAll()
    end
    end
    end


    def Kernel.pbItemBall(item)
    itemname=PBItems.getName(item)
    if $PokemonBag.pbStoreItem(item)
    if $ItemData[item][ITEMUSE]==3 || $ItemData[item][ITEMUSE]==4
    Kernel.pbMessage(_INTL("\\se[]{1} found {2}!\\se[itemlevel]\\nIt contained {2}.\\wtnp[30]",$Trainer.name,itemname,PBMoves.getName($ItemData[item][ITEMMACHINE])))
    else
    Kernel.pbMessage(_INTL("\\se[]{1} found one {2}!\\se[itemlevel]\\wtnp[30]",$Trainer.name,itemname))
    end
    case $ItemData[item][ITEMPOCKET]
    when 1
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Items Pocket.",$Trainer.name,itemname))
    when 2
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Poke Balls Pocket.",$Trainer.name,itemname))
    when 3
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the TMs/HMs Pocket.",$Trainer.name,itemname))
    when 4
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Berries Pocket.",$Trainer.name,itemname))
    when 5
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Key Items Pocket.",$Trainer.name,itemname))
    end
    return true
    else
    Kernel.pbMessage(_INTL("{1} found one {2}!\\wtnp[20]",$Trainer.name,itemname))
    Kernel.pbMessage(_INTL("Too bad... The Bag is full..."))
    return false
    end
    end

    def Kernel.pbReceiveItem(item)
    itemname=PBItems.getName(item)
    if $ItemData[item][ITEMUSE]==3 || $ItemData[item][ITEMUSE]==4
    Kernel.pbMessage(_INTL("\\se[]Obtained {2}!\\se[itemlevel]\\nIt contained {2}.\\wtnp[30]",$Trainer.name,itemname,PBMoves.getName($ItemData[item][ITEMMACHINE])))
    else
    Kernel.pbMessage(_INTL("\\se[]Obtained {2}!\\se[itemlevel]\\wtnp[30]",$Trainer.name,itemname))
    end
    if $PokemonBag.pbStoreItem(item)
    case $ItemData[item][ITEMPOCKET]
    when 1
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Items Pocket.",$Trainer.name,itemname))
    when 2
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Poke Balls Pocket.",$Trainer.name,itemname))
    when 3
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the TMs/HMs Pocket.",$Trainer.name,itemname))
    when 4
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Berries Pocket.",$Trainer.name,itemname))
    when 5
    Kernel.pbMessage(_INTL("{1} put the {2}\r\nin the Key Items Pocket.",$Trainer.name,itemname))
    end
    return true
    else
    return false
    end
    end

    def Kernel.pbPokerus?
    return false
    end


    module InterpreterFieldMixin
    # Used in boulder events. Allows an event to be pushed. To be used in
    # a script event command.
    def pbPushThisEvent
    event=get_character(0)
    oldx=event.x
    oldy=event.y
    # Apply strict version of passable, which makes impassable
    # tiles that are passable only from certain directions
    if !event.passableStrict?(event.x,event.y,$game_player.direction)
    return
    end
    case $game_player.direction
    when 2 # down
    event.move_down
    when 4 # left
    event.move_left
    when 6 # right
    event.move_right
    when 8 # up
    event.move_up
    end
    $PokemonMap.addMovedEvent(@event_id) if $PokemonMap
    if oldx!=event.x || oldy!=event.y
    $game_player.lock
    begin
    Graphics.update
    Input.update
    pbUpdateSceneMap
    end until !event.moving?
    $game_player.unlock
    end
    end
    def pbPushThisBoulder
    if $PokemonMap.strengthUsed
    pbPushThisEvent
    end
    return true
    end
    def pbHeadbutt
    Kernel.pbHeadbutt(get_character(0))
    return true
    end
    def pbTrainerEnd
    pbGlobalUnlock
    e=get_character(0)
    e.erase_route if e
    end
    def pbTrainerIntro(symbol)
    if $DEBUG
    return if !Kernel.pbTrainerTypeCheck(symbol)
    end
    trtype=PBTrainers.const_get(symbol)
    pbGlobalLock
    Kernel.pbPlayTrainerIntroME(trtype)
    return true
    end
    def pbParams
    @parameters ? @parameters : @params
    end
    def pbGetPokemon(id)
    return $Trainer.party[pbGet(id)]
    end
    def pbSetEventTime(*arg)
    $PokemonGlobal.eventvars={} if !$PokemonGlobal.eventvars
    time=Time.now.to_i
    pbSetSelfSwitch(@event_id,"A",true)
    $PokemonGlobal.eventvars[[@map_id,@event_id]]=time
    for otherevt in arg
    pbSetSelfSwitch(otherevt,"A",true)
    $PokemonGlobal.eventvars[[@map_id,otherevt]]=time
    end
    end
    def getVariable(*arg)
    if arg.length==0
    return nil if !$PokemonGlobal.eventvars
    return $PokemonGlobal.eventvars[[@map_id,@event_id]]
    else
    return $game_variables[arg[0]]
    end
    end
    def setVariable(*arg)
    if arg.length==1
    $PokemonGlobal.eventvars={} if !$PokemonGlobal.eventvars
    $PokemonGlobal.eventvars[[@map_id,@event_id]]=arg[0]
    else
    $game_variables[arg[0]]=arg[1]
    $game_map.need_refresh=true
    end
    end
    def tsOff?(c)
    get_character(0).tsOff?(c)
    end
    def tsOn?(c)
    get_character(0).tsOn?(c)
    end
    alias isTempSwitchOn? tsOn?
    alias isTempSwitchOff? tsOff?
    def setTempSwitchOn(c)
    get_character(0).setTempSwitchOn(c)
    end
    def setTempSwitchOff(c)
    get_character(0).setTempSwitchOff(c)
    end
    # Must use this approach to share the methods
    # because the methods already defined in a class
    # override those defined in an included module
    CustomEventCommands=<<_END_
    def command_352
    scene=PokemonSaveScene.new
    screen=PokemonSave.new(scene)
    screen.pbSaveScreen
    return true
    end
    def command_125
    value = operate_value(pbParams[0], pbParams[1], pbParams[2])
    $Trainer.money+=value
    return true
    end
    def command_132
    $PokemonGlobal.nextBattleBGM=(pbParams[0]) ? pbParams[0].clone : nil
    return true
    end
    def command_133
    $PokemonGlobal.nextBattleME=(pbParams[0]) ? pbParams[0].clone : nil
    return true
    end
    def command_353
    pbBGMFade(1.0)
    pbBGSFade(1.0)
    pbFadeOutIn(99999){
    Kernel.pbStartOver(true)
    }
    end
    def command_314
    if pbParams[0] == 0 && $Trainer && $Trainer.party
    pbHealAll()
    end
    return true
    end
    _END_
    end
    class Interpreter
    include InterpreterFieldMixin
    eval(InterpreterFieldMixin::CustomEventCommands)
    end
    class Game_Interpreter
    include InterpreterFieldMixin
    eval(InterpreterFieldMixin::CustomEventCommands)
    end

    def pbUseKeyItem
    if $PokemonBag.registeredItem==0
    Kernel.pbMessage(_INTL("A Key Item in the Bag can be registered to this key for instant use."))
    else
    Kernel.pbUseKeyItemInField($PokemonBag.registeredItem)
    end
    end

    def pbCaveEntranceEx(exiting)
    sprite=BitmapSprite.new(Graphics.width,Graphics.height)
    sprite.z=100000
    totalBands=15
    totalFrames=15
    bandheight=((Graphics.height/2)-10).to_f/totalBands
    bandwidth=((Graphics.width/2)-12).to_f/totalBands
    grays=[]
    tbm1=totalBands-1
    for i in 0...totalBands
    grays.push(exiting ? 0 : 255)
    end
    totalFrames.times do |j|
    x=0
    y=0
    rectwidth=Graphics.width
    rectheight=Graphics.height
    for k in 0...j
    t=(255.0)/totalFrames
    if exiting
    t=1.0-t
    t*=1.0+((k)/totalFrames.to_f)
    else
    t*=1.0+0.3*(((totalFrames-k)/totalFrames.to_f)**0.7)
    end
    grays[k]-=t
    grays[k]=0 if grays[k]<0
    end
    for i in 0...totalBands
    currentGray=grays[i]
    sprite.bitmap.fill_rect(Rect.new(x,y,rectwidth,rectheight),
    Color.new(currentGray,currentGray,currentGray))
    x+=bandwidth
    y+=bandheight
    rectwidth-=bandwidth*2
    rectheight-=bandheight*2
    end
    Graphics.update
    Input.update
    end
    for j in 0..5
    Graphics.update
    Input.update
    end
    if exiting
    pbToneChangeAll(Tone.new(255,255,255),0)
    else
    pbToneChangeAll(Tone.new(-255,-255,-255),0)
    end
    for j in 0..15
    if exiting
    sprite.color=Color.new(255,255,255,j*255/15)
    else
    sprite.color=Color.new(0,0,0,j*255/15)
    end
    Graphics.update
    Input.update
    end
    pbToneChangeAll(Tone.new(0,0,0),8)
    sprite.dispose
    end

    def pbCaveEntrance
    pbCaveEntranceEx(false)
    end


    class Transient
    def initialize(value)
    @value=value
    end
    attr_accessor :value
    def self._load(str)
    return Transient.new(nil)
    end
    def _dump(*arg)
    return ""
    end
    end


    So... I don't think so. :p
  12. KitsuneKouta
    December 14th, 2010 11:32 PM
    KitsuneKouta
    The bit on PokemonField line 1170 looks sort of odd, so maybe it has something to do with that. In my kit, it's a commented line about the weather system. Is there any new/edited code around there?
  13. Cilerba
    December 14th, 2010 05:30 PM
    Cilerba
    It's definitely not PokemonLoad. I just replaced it with a default PokemonLoad script without any changes, but I still get the error. I'll try replacing SpriteWindow and let you know what happens.

    EDIT: Nope. Doesn't do anything.
  14. Cilerba
    December 13th, 2010 12:05 PM
    Cilerba
    Well, the recent changes I made was to SpriteWindow

    DARKTEXTBASE=Color.new(0,0,0)
    DARKTEXTSHADOW=Color.new(248,248,248)


    and PokemonLoad

    addBackgroundOrColoredPlane(@sprites,"clrvp","loadbg",
    Color.new(248,248,248),@viewport)


    And it pops up right when I click 'New Game'.
  15. KitsuneKouta
    December 12th, 2010 04:40 PM
    KitsuneKouta
    I'll need a little more info to figure it out. Like any recent changes and when it pops up (I'm guessing right as you click playtest). The nil:NilClass errors are almost always completely ambiguous, and the error generally lies somewhere completely unrelated to what the message tells you.

All times are UTC -8. The time now is 09:21 PM.