• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Game Crashes When Encountering Wild Pokemon

SpartaLazor

Doofus Lunarius
184
Posts
8
Years
  • Hi all. Lately I've been having an issue where the game crashes upon starting a wild encounter. This is the error message:

    Capture01.PNG


    Based off of that, I think it means that there are a couple of sections of code that are calling the method "length" but that is missing. That's about as far as I can get, though. I really don't know how to rectify this. I've tried comparing several scripts to the default Essentials coding, but I've yet to find a discrepancy.

    This issue is kinda holding up all development, so any and all assistance would be appreciated.
     
    19
    Posts
    5
    Years
    • Seen Oct 12, 2018
    Could you post your script? Looking at mine, my script for generating a wild battle is. Another option would be booting up a clean slate of essentials and then copy-pasting those portions of script over to yours.

    ################################################################################
    # Main battle class.
    ################################################################################
    class PokeBattle_Battle
    attr_reader(:scene) # Scene object for this battle
    attr_accessor(:decision) # Decision: 0=undecided; 1=win; 2=loss; 3=escaped; 4=caught
    attr_accessor(:internalbattle) # Internal battle flag
    attr_accessor(:doublebattle) # Double battle flag
    attr_accessor(:cantescape) # True if player can't escape
    attr_accessor(:shiftStyle) # Shift/Set "battle style" option
    attr_accessor(:battlescene) # "Battle scene" option
    attr_accessor(:debug) # Debug flag
    attr_reader(:player) # Player trainer
    attr_reader(:opponent) # Opponent trainer
    attr_reader(:party1) # Player's Pok?mon party
    attr_reader(:party2) # Foe's Pok?mon party
    attr_reader(:party1order) # Order of Pok?mon in the player's party
    attr_reader(:party2order) # Order of Pok?mon in the opponent's party
    attr_accessor(:fullparty1) # True if player's party's max size is 6 instead of 3
    attr_accessor(:fullparty2) # True if opponent's party's max size is 6 instead of 3
    attr_reader(:battlers) # Currently active Pok?mon
    attr_accessor(:items) # Items held by opponents
    attr_reader(:sides) # Effects common to each side of a battle
    attr_reader(:field) # Effects common to the whole of a battle
    attr_accessor(:environment) # Battle surroundings
    attr_accessor(:weather) # Current weather, custom methods should use pbWeather instead
    attr_accessor(:weatherduration) # Duration of current weather, or -1 if indefinite
    attr_reader(:switching) # True if during the switching phase of the round
    attr_reader(:futuresight) # True if Future Sight is hitting
    attr_reader(:struggle) # The Struggle move
    attr_accessor(:choices) # Choices made by each Pok?mon this round
    attr_reader(:successStates) # Success states
    attr_accessor(:lastMoveUsed) # Last move used
    attr_accessor(:lastMoveUser) # Last move user
    attr_accessor(:megaEvolution) # Battle index of each trainer's Pok?mon to Mega Evolve
    attr_accessor(:amuletcoin) # Whether Amulet Coin's effect applies
    attr_accessor(:extramoney) # Money gained in battle by using Pay Day
    attr_accessor(:doublemoney) # Whether Happy Hour's effect applies
    attr_accessor(:endspeech) # Speech by opponent when player wins
    attr_accessor(:endspeech2) # Speech by opponent when player wins
    attr_accessor(:endspeechwin) # Speech by opponent when opponent wins
    attr_accessor(:endspeechwin2) # Speech by opponent when opponent wins
    attr_accessor(:rules)
    attr_reader(:turncount)
    attr_accessor :controlPlayer
    include PokeBattle_BattleCommon

    MAXPARTYSIZE = 6

    class BattleAbortedException < Exception; end

    def pbAbort
    raise BattleAbortedException.new("Battle aborted")
    end

    def pbDebugUpdate
    end

    def pbRandom(x)
    return rand(x)
    end

    def pbAIRandom(x)
    return rand(x)
    end

    ################################################################################
    # Initialise battle class.
    ################################################################################
    def initialize(scene,p1,p2,player,opponent)
    if p1.length==0
    raise ArgumentError.new(_INTL("Party 1 has no Pok?mon."))
    return
    end
    if p2.length==0
    raise ArgumentError.new(_INTL("Party 2 has no Pok?mon."))
    return
    end
    if p2.length>2 && !opponent
    raise ArgumentError.new(_INTL("Wild battles with more than two Pok?mon are not allowed."))
    return
    end
    @scene = scene
    @decision = 0
    @internalbattle = true
    @doublebattle = false
    @cantescape = false
    @shiftStyle = true
    @battlescene = true
    @debug = false
    @debugupdate = 0
    if opponent && player.is_a?(Array) && player.length==0
    player = player[0]
    end
    if opponent && opponent.is_a?(Array) && opponent.length==0
    opponent = opponent[0]
    end
    @player = player # PokeBattle_Trainer object
    @opponent = opponent # PokeBattle_Trainer object
    @party1 = p1
    @party2 = p2
    @party1order = []
    for i in 0...12; @party1order.push(i); end
    @party2order = []
    for i in 0...12; @party2order.push(i); end
    @fullparty1 = false
    @fullparty2 = false
    @battlers = []
    @items = nil
    @sides = [PokeBattle_ActiveSide.new, # Player's side
    PokeBattle_ActiveSide.new] # Foe's side
    @field = PokeBattle_ActiveField.new # Whole field (gravity/rooms)
    @environment = PBEnvironment::None # e.g. Tall grass, cave, still water
    @weather = 0
    @weatherduration = 0
    @switching = false
    @futuresight = false
    @choices = [ [0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1],[0,0,nil,-1] ]
    @successStates = []
    for i in 0...4
    @successStates.push(PokeBattle_SuccessState.new)
    end
    @lastMoveUsed = -1
    @lastMoveUser = -1
    @nextPickupUse = 0
    @megaEvolution = []
    if @player.is_a?(Array)
    @megaEvolution[0]=[-1]*@player.length
    else
    @megaEvolution[0]=[-1]
    end
    if @opponent.is_a?(Array)
    @megaEvolution[1]=[-1]*@opponent.length
    else
    @megaEvolution[1]=[-1]
    end
    @amuletcoin = false
    @extramoney = 0
    @doublemoney = false
    @endspeech = ""
    @endspeech2 = ""
    @endspeechwin = ""
    @endspeechwin2 = ""
    @rules = {}
    @turncount = 0
    @peer = PokeBattle_BattlePeer.create()
    @priority = []
    @usepriority = false
    @snaggedpokemon = []
    @runCommand = 0
    if hasConst?(PBMoves,:STRUGGLE)
    @struggle = PokeBattle_Move.pbFromPBMove(self,PBMove.new(getConst(PBMoves,:STRUGGLE)))
    else
    @struggle = PokeBattle_Struggle.new(self,nil)
    end
    @struggle.pp = -1
    for i in 0...4
    battlers = PokeBattle_Battler.new(self,i)
    end
    for i in @party1
    next if !i
    i.itemRecycle = 0
    i.itemInitial = i.item
    i.belch = false
    end
    for i in @party2
    next if !i
    i.itemRecycle = 0
    i.itemInitial = i.item
    i.belch = false
    end
    end
     

    SpartaLazor

    Doofus Lunarius
    184
    Posts
    8
    Years
  • Could you post your script? Looking at mine, my script for generating a wild battle is. Another option would be booting up a clean slate of essentials and then copy-pasting those portions of script over to yours.

    Actually it's been taken care of right now. It seems that I had completely screwed over that copy of Essentials, so I moved everything over to a fresh copy. So far, so good. I appreciate the response though.
     
    19
    Posts
    5
    Years
    • Seen Oct 12, 2018
    No problem. If it happens again, you could always try restarting your computer as well. Don't know why but I had a problem where it crashed every time I fought a trainer. Restarting it fixed the problem. Weirdest thing I've seen so far.
     
    Back
    Top