• 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.

Automaticly store Pokemon when he/she faint

Qwertyis666

Dragon Trainer Since 1996
  • 60
    Posts
    11
    Years
    Hi,
    I add the Nuzlocke Challenge to my game (For now only the ''No revive'' part of Nuzlocke is done) and I want to know where should I add/change script to be able to automaticly store a Pokemon when they faint (preferably in Box 20 to 24) in a battle AND in the overworld by poison.
    I try to add pbStore script right after the pbFaint in Pokemon_Battler but this is not working. How should I do it to make it work?

    And maybe off-topic but can we ''close'' a PC box from the player? Example, you can watch what Pokemon are in box 20 to 24 but you can't Move them.
    (because they are only for fainted pokemon)

    Thanks in advance and sorry for my bad english
     
    Last edited:
    I'm not on my PC but.

    Look at the faint scripts and the computer scripts?
     
    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.
     
    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.

    One word: WOW ^^
    This is EXACLY what I was looking for! I will use it for sure if that does not bother you. I will give you BIG credit for this.
    Meanwhile I create a script to just remove(delete) the Pokemon when he faint but your graveward storage is too great for that I do not use it XD
    And yes I think you should add a new Thread with this Nuzlocke style scripts to the script/tuto section of the forum, I'm sure a lot of people will appreciate that :)

    Thanks again and sorry for my bad english
     
    After posting it in the 'Scripts & Tutorials' section ShadowFiendZX and mej71 pointed out two design problems with Pokémon being removed from the player's party. These being not having any Pokémon left in the party and getting stuck because the Pokémon knowing the HM died. I solved the first problem in the code itself by adding a game over and for the second problems solutions are described at the start of the post. In case you hadn't thought about this yet, I suggest you take a look (https://www.pokecommunity.com/showthread.php?t=342150)
     
    Back
    Top