I believe the code below is does what you were looking for. I quickly extracted it from the game I'm working on. Credit would be appreciated.
Pokémon 'dying'
To store fainted Pokémon in the box after battle or after dying from poison:
- Look in PokemonField; find the "Events.onEndBattle+=proc {|sender,e|" add "pbPartyRemoveDead" at the end of it (create a new line after the last end, but before the "}").
- Again in PokemonField; find "def Kernel.pbStartOver(gameover=false)" and add "pbPartyRemoveDead" on the next line.
- Again in PokemonField; find "Events.onStepTakenTransferPossible+=proc {|sender,e|" and add "pbPartyRemoveDead" below the line "Kernel.pbMessage(_INTL("{1} fainted...\\1",i.name))"
Then add the code below to PokemonUtilities
Code:
def pbPartyRemoveDead
# Resolve Pokémon dying for the current character
for i in 0...$Trainer.party.length
if $Trainer.party[i].hp <= 0
Kernel.pbMessage(_INTL("Transferred {2}'s {1} to the Graveyard storage.",$Trainer.party[i].name,$Trainer.name))
$PokemonStorage.pbStoreCaught($Trainer.party[i])
#$GraveyardStorage.pbStoreCaught($Trainer.party[i]) #use this line when using the graveyard storage explained below
$Trainer.party[i]=nil
end
end
$Trainer.party = $Trainer.party.compact
end #end remove dead
A graveyard storage
In the game I'm working on I've also got some functionality revolving Pokémon dying. There I've created an alternate storage variable called the graveyard storage, which players can access when booting up the PC (before entering their own storage). In the graveyard storage players can only view their Pokémon (and take their hold item or change their markings).
In PokemonLoad; find "$PokemonStorage = Marshal.load(f)" and add "$GraveyardStorage = Marshal.load(f)" below it.
In PokemonLoad; find "$PokemonStorage = PokemonStorage.new" and add "$GraveyardStorage = PokemonStorage.new" below it.
In PokemonSave; find "Marshal.dump($PokemonStorage,f)" and add "Marshal.dump($GraveyardStorage,f)" below it.
Then in PokemonStorage:
- Change line "def initialize(scene,storage)" to "def initialize(scene,storage,graveyard=false)" and add "@graveyard=graveyard" below.
- Change line "commands[0]=_INTL("Move")" to "commands[0]=_INTL("Move") if !@graveyard"
- There should be a "if selected[0]==-1" a few lines later, change that one (and only that one) to "if selected[0]==-1 && !@graveyard"
- Find "PokemonPCList.registerPC(StorageSystemPC.new)" and add "PokemonPCList.registerPC(GraveyardSystemPC.new)" below it.
Search the line "_INTL("Move")," and replace the entire part (from "commands=[" to "]") to the code below;
Code:
if !@graveyard
commands=[
_INTL("Move"),
_INTL("Summary"),
_INTL("Withdraw"),
_INTL("Item"),
_INTL("Mark"),
_INTL("Release")
]
else
commands=[
_INTL("Summary"),
_INTL("Item"),
_INTL("Mark"),
]
end
From there, find the next "case command" (a few lines below the section you just changed) and add the code below
above it;
Code:
if @graveyard
case command
when 0 #summary
command = 1
when 1 #item
command = 3
when 2 #mark
command = 4
when 3 #debug
command = 6
when 4 #cancel
command = 7
end
end
Add the code below
above the line "def pbPokeCenterPC"
Code:
class GraveyardSystemPC
def shouldShow?
if $GraveyardStorage.boxes.empty? == false
return true
end
end
def name
return _INTL("Graveyard")
end
def access
pbFadeOutIn(99999){
scene=PokemonStorageScene.new
screen=PokemonStorageScreen.new(scene,$GraveyardStorage,true)
screen.pbStartScreen(2)
}
end
end
NOTE: Copying code from the PokéCommunity forum might still be broken, to solve this use 'Threat Tools' and click on 'Show printable version'
PS: If more people are interested in this I can add it to the 'Tutorials&Scripts' section to make it easier to find.