Did someone say Pokémon Sardonyx? ;)
Oh boy, I'm just gonna straight up say that we're working mainly on v16.2. (And before anyone butts in, my co-dev and I both have fresh v17.2 which we mostly pull code from to update/add certain features. And even then, I am aware of the different sections between both versions.) There is also A LOT that you'll need to do for this. So much so that if I went into every single step of this, this post would probably take allday to put together a post for it...
So instead, let's start with some basics. Brought to you by Nickaloose, who responded to my co-dev's request for help on the matter before we even made the pre-release alpha that Ruffled Rowlit played. And I feel bad for completely forgetting to credit the person, since Sardonyx probably would not have been possible without their help.
So let's start with
PokeBattle_Pokemon. Specifically under class PokeBattle_Pokemon:
Below all of the various attr_accessors, you're gonna want to add
attr_accessor(:dead).
Now somewehere in that same section of script, you're gonna want to add the following:
################################################################################
# Dead or not
################################################################################
# Kill this Pokémon
def makeDead
@dead=true
end
# Revive this Pokémon
def makeUndead
@dead=false
end
# Check if dead
def checkDead
return @dead
end
I suggest somewhere like under the section for shiny Pokemon to make it relatively easy to find.
And within def initialize further down, add
@dead=false to initialize the flag.
Next, search up
def pbFaint in
PokeBattle_Battler, look for the line
@pokemon.changeHappiness("faint"). Under that, add
@pokemon.makeDead if $game_switches[#]. (Important note: # should be a switch number that isn't already being used).
With what we have so far, we have a means to check to see if a Pokémon is dead, the means to kill and revive them, and set up a way to kill Pokémon if a switch is on during battle.
And now, you should find def pbHealAll, located either in
PSystem_Utilities or
PSystem_PokemonUtilities. In this bit of code, change
i.heal to
i.heal if i.checkDead==false. This will keep Pokémon from being healed from events using this script, and therefore keeping them unable to be healed at Pokémon Centers.
There's a lot of other things involved in this, like making sure items don't work on dead Pokémon, making them unable to be healed in PCs, etc. But again, we'd be here all day. Plus even then, a lot of adjustments can be figured out from this point with a bit of logic. Either way, I hope this serves as a good enough starting point as it did for me.