Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #To do:
- #Make sure the Pokemon is removed from the array when caught (even defeated?)
- #Consider how this affects save data compatibility, esp with save call script
- #Add to the Trainer memo that they were reunited
- #Have a unique message for released encounter
- class PokemonGlobalMetadata
- attr_accessor :releasedPokemon
- end
- class PokemonStorageScreen
- def pbRelease(selected,heldpoke)
- box = selected[0]
- index = selected[1]
- pokemon = (heldpoke) ? heldpoke : @storage[box,index]
- return if !pokemon
- if pokemon.egg?
- pbDisplay(_INTL("You can't release an Egg."))
- return false
- elsif pokemon.mail
- pbDisplay(_INTL("Please remove the mail."))
- return false
- end
- if box==-1 && pbAbleCount<=1 && pbAble?(pokemon) && !heldpoke
- pbPlayBuzzerSE
- pbDisplay(_INTL("That's your last Pokémon!"))
- return
- end
- command = pbShowCommands(_INTL("Release this Pokémon?"),[_INTL("No"),_INTL("Yes")])
- if command==1
- $PokemonGlobal.releasedPokemon = [] if $PokemonGlobal.releasedPokemon == nil
- $PokemonGlobal.releasedPokemon.push(pokemon)
- pkmnname = pokemon.name
- @scene.pbRelease(selected,heldpoke)
- if heldpoke
- @heldpkmn = nil
- else
- @storage.pbDelete(box,index)
- end
- @scene.pbRefresh
- pbDisplay(_INTL("{1} was released.",pkmnname))
- pbDisplay(_INTL("Bye-bye, {1}!",pkmnname))
- @scene.pbRefresh
- end
- return
- end
- end
- Events.onWildBattleOverride += proc { |_sender,e|
- handled = e[2]
- next if handled[0]!=nil
- next if $PokemonGlobal.releasedPokemon == nil
- handled[0] = pbReleasedBattle
- }
- def pbReleasedBattle
- pokemon = $PokemonGlobal.releasedPokemon.sample
- index = $PokemonGlobal.releasedPokemon.find_index(pokemon)
- species = pokemon.species
- level = pokemon.level
- # Set some battle rules
- setBattleRule("single")
- # Perform the battle
- decision = pbWildBattleCore(pokemon)
- # Update Released Pokémon data based on result of battle
- if decision==1 || decision==4 # Defeated or caught
- $PokemonGlobal.releasedPokemon.delete_at(index)
- end
- # Used by the Poké Radar to update/break the chain
- Events.onWildBattleEnd.trigger(nil,species,level,decision)
- # Return false if the player lost or drew the battle, and true if any other result
- return (decision!=2 && decision!=5)
- end
Add Comment
Please, Sign In to add comment