• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Handling Pokémon Death?

  • 21
    Posts
    11
    Years
    • Seen May 23, 2024
    Hello, community!

    I was wondering where/if there is anyway that I can handle Pokémon Deaths?

    The idea behind this would be to make a permadeath game, where when your pokémon dies, it returns to its egg!

    Thanks for your time!
     
    Last edited by a moderator:
    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.
     
    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.

    It's a great start! Thank you!

    However, I thought of going that way aswell, but this is in a battle only, right? I figured that wouldn't work with Poison outside of it, for example.

    But, it's a great start, if nobody knows for sure I might be able to make it in a few days.

    See ya!
     
    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]
        [COLOR="Blue"]eggSpecies=self.species
        if !pbHasEgg?(self.species)
          eggSpecies=pbGetBabySpecies(self.species)
          [COLOR="DeepSkyBlue"]eggSpecies=pbGetNonIncenseLowestSpecies(eggSpecies)[/COLOR]
        end
        self.species=eggSpecies[/COLOR]
        [COLOR="Red"]self.level=EGGINITIALLEVEL
        self.calcStats
        self.name=_INTL("Egg")
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.species,21)
        pkmn.eggsteps=dexdata.fgetw
        dexdata.close
        self.hatchedMap=0
        self.obtainMode=1[/COLOR]
        @battle.pbDisplayPaused(_INTL("{1} fainted!",pbThis)) if showMessage
        PBDebug.log("[Pokémon fainted] #{pbThis}")
        return true
      end

    The blue text makes the Pokemon become the Pokemon's baby form - i.e., if it was a Pikachu or a Riachu it'll become a Pichu. The light blue text alters that for the baby Pokemon that only appear with incense breeding - so no random Munchlaxes.

    The red text makes the Pokemon become an egg.

    This only applies to fainting in battle. I still need to look at the code for fainting in the overworld due to poison and burn.
     
    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]
        [COLOR="Blue"]eggSpecies=self.species
        if !pbHasEgg?(self.species)
          eggSpecies=pbGetBabySpecies(self.species)
          [COLOR="DeepSkyBlue"]eggSpecies=pbGetNonIncenseLowestSpecies(eggSpecies)[/COLOR]
        end
        self.species=eggSpecies[/COLOR]
        [COLOR="Red"]self.level=EGGINITIALLEVEL
        self.calcStats
        self.name=_INTL("Egg")
        dexdata=pbOpenDexData
        pbDexDataOffset(dexdata,self.species,21)
        pkmn.eggsteps=dexdata.fgetw
        dexdata.close
        self.hatchedMap=0
        self.obtainMode=1[/COLOR]
        @battle.pbDisplayPaused(_INTL("{1} fainted!",pbThis)) if showMessage
        PBDebug.log("[Pokémon fainted] #{pbThis}")
        return true
      end

    The blue text makes the Pokemon become the Pokemon's baby form - i.e., if it was a Pikachu or a Riachu it'll become a Pichu. The light blue text alters that for the baby Pokemon that only appear with incense breeding - so no random Munchlaxes.

    The red text makes the Pokemon become an egg.

    This only applies to fainting in battle. I still need to look at the code for fainting in the overworld due to poison and burn.

    Thanks for your answer, man! It means a lot to me.

    I have a few follow up questions if it's alright:

    • The (dark) blue returns the pokémon to its prior form, is that it? ( I'm not so familiar with the new (post-Generation Three) terminology. If it does, how does it handle the evolution back? I.E: Charizard LVL 60 dies and becomes Charmelon LVL 60, how does it comes back?
    • The red script returns the Pokémon for its egg, right? Do I have to create an Egg for each Pokémon? For example: Egg -> Pokémon One -> Pokémon Two -> Pokémon Three. If the third dies, it will turn to an Egg to become Pok. Three or the Initial Egg in the chain?
    • Do I have to keep only the part I want? Like, if I want the script to transform the pokémon in Egg, I delete the blue part and keep the red and vice versa?

    Thanks!
     
    When your Pokemon dies, it becomes a level 1 Pokemon again. It will also revert to the baby form (Pichu, Charmander, Squirtle, etc.). So you have to hatch it and raise it again, sort of like a phoenix.

    It will, however, keep any EVs you gave it, its IVs, and its moveset. So it's not a complete start-over.
     
    When your Pokemon dies, it becomes a level 1 Pokemon again. It will also revert to the baby form (Pichu, Charmander, Squirtle, etc.). So you have to hatch it and raise it again, sort of like a phoenix.

    It will, however, keep any EVs you gave it, its IVs, and its moveset. So it's not a complete start-over.

    Thank you so much!
     
    You're welcome. I'm seeing if I can add this as a variation of Nuzlockes in my own game, call it maybe a Phoenixlocke or something.

    I'd love to play when you finish! Keep up the work, man!

    May I PM you if I encounter any troubles adding the script discussed here? I'm traveling right now, so I can't add it to the project yet!
     
    Back
    Top