The PokéCommunity Forums Fan Games Game Development Scripts & Tutorials
Essentials Script Pokémon Dying

Scripts & Tutorials This forum is for scripts and code, as well as all kinds of tutorials, software, tools and so forth. Remember to give credit!
The thread revival limit does not apply here.


Reply
 
Thread Tools
  #1    
Old January 10th, 2015 (4:11 AM). Edited May 20th, 2015 by Badhaas.
Badhaas's Avatar
Badhaas Badhaas is offline
     
    Join Date: Jul 2013
    Gender: Male
    Posts: 118
    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'
    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
    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 [email protected]"
    - 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 && [email protected]      ##### CHANGED LINE
                commands[2]=_INTL("Store")
              elsif selected[0]!=-1 && [email protected]      ##### 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 [email protected]
                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
    __________________

    View my profile page for scripts/tutorials made by me, even ones which aren't posted yet.
    Currently working on a demo for Tales from the Pokémon World (based on the World of Pokémon project)
    Reply With Quote

    Relevant Advertising!

      #2    
    Old January 10th, 2015 (7:48 AM).
    ShadowFiendZX's Avatar
    ShadowFiendZX ShadowFiendZX is offline
    Gym Leader
       
      Join Date: Jan 2013
      Location: Hamden Connecticut
      Age: 21
      Gender: Male
      Nature: Serious
      Posts: 59
      While this is a nice feature, and something my friends and I have always joked about adding to our game, what happens if you've got no pokemon whatsoever even in regular storage? How would you get pokemon, especially before given access to the safari zone or something similar?
      __________________
      BEHOLD THE FLOPPY MAGIKARP IN ALL ITS GLORY AND WISDOM

      Reply With Quote
        #3    
      Old January 10th, 2015 (8:33 AM).
      mej71's Avatar
      mej71 mej71 is offline
         
        Join Date: Mar 2014
        Location: Omnipresence
        Gender: Male
        Posts: 1,226
        A big problem I see is in games that use HMs. You surf to an island, that pokemon dies, you're stuck. Game over. You're in the middle of surfing and that pokemon dies, possible errors. etc.
        Reply With Quote
          #4    
        Old January 10th, 2015 (2:29 PM).
        Badhaas's Avatar
        Badhaas Badhaas is offline
           
          Join Date: Jul 2013
          Gender: Male
          Posts: 118
          Those are good points which, to be honest, I hadn't thought about yet. I quickly made the code for someone and thought more people might be interested in it. After running some tests the code doesn't cause errors by removing the only Pokémon which knows surf, or by removing the last Pokémon from the players party. It does indirectly cause 2 problems;

          Starting a battle without any Pokémon in the party causes the game to crash. Do note that the code causes the player to always return to the Pokémon center when this happens (blacking out). This gives two ways to solve the problem; 1, the player goes game over when all pokemon in their party are dead; 2, the player isn't allowed to leave the pokemon center with an empty party and goes game over when the player doesn't have any pokemon in either their party or their storage. (I updated the first post to include the first solution).

          the second problem is slightly more complex; if the player loses a Pokémon which knows a HM they can get stuck (i.e. the player surfs to an island). 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.

          Note: I've updated the OP to include this information.
          __________________

          View my profile page for scripts/tutorials made by me, even ones which aren't posted yet.
          Currently working on a demo for Tales from the Pokémon World (based on the World of Pokémon project)
          Reply With Quote
            #5    
          Old January 10th, 2015 (3:31 PM).
          LastOne's Avatar
          LastOne LastOne is offline
             
            Join Date: Jun 2014
            Age: 20
            Gender: Male
            Nature: Careful
            Posts: 133
            I really wouldn't be discouraged by those obstacles. Most fangames like ZetaOmicron, who's popularity is on par with Reborn and Raptor, have Nuzlockes as optional anyway. So it's really a quick and easy switch on/off. There's also the unconventional method of doing what the creator of SPEE did, before Gold had gained Eevee, by making the player a "Pokemon", except the only options available were to run away. In the situations you listed, it's an easy fix for going this route.
            __________________
            Reply With Quote
              #6    
            Old March 1st, 2015 (12:35 PM).
            shiney570 shiney570 is offline
               
              Join Date: Aug 2014
              Location: Germany
              Gender: Male
              Posts: 95
              Why don't you combine this with the Random Nuzlocke Script? :)
              Reply With Quote
                #7    
              Old March 2nd, 2015 (3:21 PM).
              Badhaas's Avatar
              Badhaas Badhaas is offline
                 
                Join Date: Jul 2013
                Gender: Male
                Posts: 118
                In case you're referring to JV's nuzlock mode script, I believe that one already has some functionality in it for dying Pokémon. Though I don't exactly know how that one works. If not, then please tell me which one you're referring to.
                __________________

                View my profile page for scripts/tutorials made by me, even ones which aren't posted yet.
                Currently working on a demo for Tales from the Pokémon World (based on the World of Pokémon project)
                Reply With Quote
                  #8    
                Old March 2nd, 2015 (3:27 PM).
                mej71's Avatar
                mej71 mej71 is offline
                   
                  Join Date: Mar 2014
                  Location: Omnipresence
                  Gender: Male
                  Posts: 1,226
                  Quote:
                  Originally Posted by Badhaas View Post
                  In case you're referring to JV's nuzlock mode script, I believe that one already has some functionality in it for dying Pokémon. Though I don't exactly know how that one works. If not, then please tell me which one you're referring to.
                  That one just prevents healing scripts from healing fainted pokemon is all. It doesn't remove them from your party or anything.
                  Reply With Quote
                    #9    
                  Old March 26th, 2015 (12:02 AM).
                  Tricko's Avatar
                  Tricko Tricko is offline
                  Developing Pokémon Dark Leaf
                     
                    Join Date: Apr 2012
                    Location: Alamos Town
                    Gender: Male
                    Nature: Jolly
                    Posts: 45
                    Quote:
                    Originally Posted by mej71 View Post
                    A big problem I see is in games that use HMs. You surf to an island, that pokemon dies, you're stuck. Game over. You're in the middle of surfing and that pokemon dies, possible errors. etc.
                    Mej, Is absolutely right...
                    __________________
                    Hacks I Love



                    <><><><><><><><><><><><><><><>

                    http://tricko1.deviantart.com/
                    Reply With Quote
                      #10    
                    Old May 3rd, 2015 (11:55 AM). Edited May 3rd, 2015 by Joltik.
                    Joltik's Avatar
                    Joltik Joltik is offline
                       
                      Join Date: Jan 2010
                      Gender: Male
                      Nature: Modest
                      Posts: 116
                      Very nice! Thank you very much for the script.

                      Well, I have a small correction, just a subltety (however, it is important):
                      When you say:
                      Quote:
                      There should be a "if selected[0]==-1" a few lines later, change that one (and only that one) to "if selected[0]==-1 && [email protected]"
                      Actually, if you simple do this, the code will look like:
                      Quote:
                      if selected[0]==-1&& [email protected]
                      commands[2]=_INTL("Store")
                      else
                      commands[2]=_INTL("Withdraw")

                      end
                      I highlight the yellow part, because it means that it will not only write "withdraw" when the left side of the "if" is not satisfied, but also when [email protected] is not satisfied. In order words, it will write Withdraw inside of the graveyard box.
                      I believe it should be:
                      Quote:
                      if selected[0]==-1 && [email protected]
                      commands[2]=_INTL("Store")
                      elsif selected[0]==-1 && @graveyard
                      commands[2]=_INTL("Mark")
                      elsif selected[0]!=-1 && [email protected]
                      commands[2]=_INTL("Withdraw")
                      end
                      Again, thank you for the script! I was really looking for something on these lines!

                      As a side question, I was wondering if it would be possible to still give a use to the item Revive. Maybe turning it into a very rare item, that would really Revive the pokemon, and not "unfaint" it, as usual. Do you think it is possible?


                      Other than that, I get an error when picking a pokémon in the box, using "Move".
                      Spoiler:
                      Exception: NameError
                      Message: Section111:363:in `pbHold'undefined local variable or method `pokemon' for #<PokemonStorageScreen:0x82b7988>
                      ***Full script:
                      pbPokeCenterPC

                      Interpreter:243:in `pbExecuteScript'
                      PokemonStorage:795:in `pbStartScreen'
                      PokemonStorage:692:in `loop'
                      PokemonStorage:820:in `pbStartScreen'
                      PokemonStorage:3172:in `access'
                      PokemonStorage:3169:in `pbFadeOutIn'
                      PokemonStorage:3169:in `access'
                      PokemonStorage:3145:in `loop'
                      PokemonStorage:3177:in `access'
                      PokemonStorage:3093:in `callCommand'

                      Interpreter:276:in `pbExecuteScript'
                      Interpreter:1600:in `command_355'
                      Interpreter:494:in `execute_command'
                      Interpreter:193:in `update'
                      Interpreter:106:in `loop'
                      Interpreter:198:in `update'
                      Scene_Map:103:in `update'
                      Scene_Map:101:in `loop'
                      Scene_Map:114:in `update'


                      Cheers!
                      __________________

                      Check out my DeviantArt account! My game project is called Pokemon Subrosia.
                      My DeviantArt | Old DeviantArt
                      Reply With Quote
                        #11    
                      Old May 3rd, 2015 (12:47 PM).
                      Yero's Avatar
                      Yero Yero is offline
                         
                        Join Date: Aug 2011
                        Location: Australia
                        Gender: Male
                        Nature: Brave
                        Posts: 65
                        I quite like the idea to have a pokemon dying in an way overpowered battle. (alright, that sounded grim) but having it die everytime it faints goes quite far and makes it very difficult to have any pokemon on your team for the entire game. So how about a conditional variable in the script? Let say that the pokemon only dies when the landing attack does twice the amount of damage as the pokemon's full hp. So say if you have a level 30 Quilava (total hp 120) facing a, say, level 80 Kyogre using waterspout at full hp and ability drizzle; the damage dealt to Quilava would be like off the chart! (Way more then 240 hp points, that's a for sure) It stands to reason that it won't survive such an attack and dies. But, if you have that same Quilava facing off against a level 35 Geodude which just tossed some rocks at it and gradiently weakens it down till Quilava has no hp left, Quilava faints and can be recovered using either a Revive or PokeCenter. So the dev will look at the total hp of the battler, doubles this into a set variable, then looks at every individual move and its damage dealt during the battle and checks if this is more or less then the amount in the variable and treats it as a conditional branch. Is it more; it dies, is it less; it faints.
                        Reply With Quote
                          #12    
                        Old May 20th, 2015 (11:17 AM).
                        Badhaas's Avatar
                        Badhaas Badhaas is offline
                           
                          Join Date: Jul 2013
                          Gender: Male
                          Posts: 118
                          Updated the script in the first post to fix the withdraw/mark text error. I've pm'd you about the crash to see if we can find a solution (I'll post it here if it affects the script or if more people encounter the same problem).

                          With regards to the revive item, if I'm not mistaken it should still be possible to revive fainted Pokémon during battle. If you'd like to use it outside of battle you'd need a way to select a single Pokémon from the Graveyard Storage.

                          @Yero; Actually this script is the dying functionality from a more elaborate script I've made where Pokémon receive wounds over multiple battle and die as a result thereof (which I'm using in the game I'm working on, of course players also have a way to heal these wounds).
                          With regards to your idea: you'de have to edit 'pbReduceHPDamage' in PokeBattle_Move, that function deals damage to the Pokémon (and currently caps the damage to the amount of hp the Pokémon has left). From there it's probably the easiest to add an extra variable to the battler/pokemon where the excessive amount of damage is stored, and a check in the faint function whether this excessive amount of damage would kill the Pokémon (or the check in the damage function with a variable which stores if the Pokémon dies).

                          ps. @Yero, tip: adding line breaks to your post makes it a lot more readable ;)
                          __________________

                          View my profile page for scripts/tutorials made by me, even ones which aren't posted yet.
                          Currently working on a demo for Tales from the Pokémon World (based on the World of Pokémon project)
                          Reply With Quote
                            #13    
                          Old February 3rd, 2018 (5:17 PM).
                          PokeMetal's Avatar
                          PokeMetal PokeMetal is offline
                             
                            Join Date: Feb 2018
                            Posts: 31
                            I find this script really cool, tho I when I tried to injected i had trouble finding some of the scripts i needed to change .. im literally new to this whole deal, but could it be because the newer versions of PE have changed their script files in some way?
                            or am i just blind -
                            Reply With Quote
                              #14    
                            Old 3 Weeks Ago (7:21 PM).
                            Sapph the Knight's Avatar
                            Sapph the Knight Sapph the Knight is offline
                               
                              Join Date: Jun 2014
                              Location: Northwest US
                              Gender: Male
                              Nature: Docile
                              Posts: 45
                              Hmm... A thought. Why not add some compatibility to the code to allow for a switch to be used for whether or not blackout = game over?
                              Reply With Quote
                              Reply

                              Quick Reply

                              Join the conversation!

                              Create an account to post a reply in this thread, participate in other discussions, and more!

                              Create a PokéCommunity Account

                              Sponsored Links
                              Thread Tools

                              Posting Rules
                              You may not post new threads
                              You may not post replies
                              You may not post attachments
                              You may not edit your posts

                              BB code is On
                              Smilies are On
                              [IMG] code is On
                              HTML code is Off

                              Forum Jump


                              All times are GMT -8. The time now is 2:47 AM.