- 117
- Posts
- 11
- Years
- Seen Sep 1, 2023
These script changes count Pokémon who have fainted as dead, and store them in a graveyard storage (after battle, or when dying from poison while walking around). This graveyard storage can be accessed from the PC and allows players to view their dead Pokémon (only summary, item, and markings are available). This can be great for a nuzlock challenge or maybe even standard in your game.
Implementing this script requires you to address a few problems caused by Pokémon dying in the players party (game design related);
The first problem is what happens when the player has no more Pokémon left in their party. The script below makes the player go game over. I emphasized the game over part of the code so you can remove it if this is not what you want. In case you remove that part the player will always end up in the last PokéCenter they visited, thus you can prevent them from leaving it without any Pokémon in their party and implement your solution there. Do note that the game crashes if the player enters a battle without any Pokémon in their party.
The second problem is what happens if the player gets stuck because the only Pokémon knowing a HM in their party died (i.e. when on a small island and the Pokémon which knew surf died). There are a few possible solutions to this problem;
1: Design the levels (maps) in such a way that this cannot happen. It's the most elegant solution, yet also the hardest to implement).
2: Use items for HMs instead of Pokémon. I know there's been quite some talk about it and I believe the code exists on this forum, yet this just might not be what you want for your game.
3: Give the player the ability to return to the last PokéCentre they visited (as if using teleport). The player would be able to use this anywhere and anytime, for the cost of 50% of their money. This is the easiest and most fail safe solution.
Pokémon 'dying'
A graveyard storage
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. Credit would be appreciated
Implementing this script requires you to address a few problems caused by Pokémon dying in the players party (game design related);
The first problem is what happens when the player has no more Pokémon left in their party. The script below makes the player go game over. I emphasized the game over part of the code so you can remove it if this is not what you want. In case you remove that part the player will always end up in the last PokéCenter they visited, thus you can prevent them from leaving it without any Pokémon in their party and implement your solution there. Do note that the game crashes if the player enters a battle without any Pokémon in their party.
The second problem is what happens if the player gets stuck because the only Pokémon knowing a HM in their party died (i.e. when on a small island and the Pokémon which knew surf died). There are a few possible solutions to this problem;
1: Design the levels (maps) in such a way that this cannot happen. It's the most elegant solution, yet also the hardest to implement).
2: Use items for HMs instead of Pokémon. I know there's been quite some talk about it and I believe the code exists on this forum, yet this just might not be what you want for your game.
3: Give the player the ability to return to the last PokéCentre they visited (as if using teleport). The player would be able to use this anywhere and anytime, for the cost of 50% of their money. This is the easiest and most fail safe solution.
Pokémon 'dying'
Spoiler:
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))"
Below that line add "$game_temp.gameover = true if $Trainer.party.length == 0"
Then add the code below to PokemonUtilities
- 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))"
Below that line add "$game_temp.gameover = true if $Trainer.party.length == 0"
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]) #use this line when using the graveyard storage explained below
$GraveyardStorage.pbStoreCaught($Trainer.party[i])
$Trainer.party[i]=nil
end
end
$Trainer.party = $Trainer.party.compact
# START GAME OVER PART (Remove this part, or change it, if you want to use a different solution)
if $Trainer.party.length == 0
Kernel.pbMessage(_INTL("{1} has no more living Pokémon with them.",$Trainer.name))
Kernel.pbMessage(_INTL("GAME OVER"))
$game_temp.to_title = true
end
# END GAME OVER PART
end #end remove dead
A graveyard storage
Spoiler:
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 the entire if function (5 lines in total to the following code:
- 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;
From there, find the next "case command" (a few lines below the section you just changed) and add the code below above it;
Add the code below above the line "def pbPokeCenterPC"
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 the entire if function (5 lines in total to the following code:
Code:
if selected[0]==-1 && !@graveyard ##### CHANGED LINE
commands[2]=_INTL("Store")
elsif selected[0]!=-1 && !@graveyard ##### CHANGED LINE
commands[2]=_INTL("Withdraw")
elsif selected[0]==-1 && @graveyard ##### ADDED LINE
commands[2]=_INTL("Mark") ##### ADDED LINE
end
- 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. Credit would be appreciated
Last edited: