I just want to put my two cents in.
In PokeBattle_Battler on line 748 in a clean v16.2 (since I don't know what version you are using) is the code that executes when a pokemon faints.
Code:
def pbFaint(showMessage=true)
if !self.isFainted?
PBDebug.log("!!!***Can't faint with HP greater than 0")
return true
end
if @fainted
# PBDebug.log("!!!***Can't faint if already fainted")
return true
end
@battle.scene.pbFainted(self)
pbInitEffects(false)
# Reset status
self.status=0
self.statusCount=0
if @pokemon && @battle.internalbattle
@pokemon.changeHappiness("faint")
end
if self.isMega?
@pokemon.makeUnmega
end
if self.isPrimal?
@pokemon.makeUnprimal
end
@fainted=true
# reset choice
@battle.choices[@index]=[0,0,nil,-1]
pbOwnSide.effects[PBEffects::LastRoundFainted][email protected]
@battle.pbDisplayPaused(_INTL("{1} fainted!",pbThis)) if showMessage
PBDebug.log("[Pokémon fainted] #{pbThis}")
return true
end
And since you can force a pokemon to become an egg with Debug on, this is the code that runs on line 1727 of PScreen_Party.
Code:
elsif cmd==0
if pbHasEgg?(pkmn.species) ||
pbConfirm(_INTL("{1} cannot be an egg. Make egg anyway?",PBSpecies.getName(pkmn.species)))
pkmn.level=EGGINITIALLEVEL
pkmn.calcStats
pkmn.name=_INTL("Egg")
dexdata=pbOpenDexData
pbDexDataOffset(dexdata,pkmn.species,21)
pkmn.eggsteps=dexdata.fgetw
dexdata.close
pkmn.hatchedMap=0
pkmn.obtainMode=1
pbRefreshSingle(pkmnid)
I don't know exactly how you would put this together, but it's a start I suppose.