• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • 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.

Killing Pokemon

pokemonmasteraaron

The blind Pokémon Master!
323
Posts
13
Years
  • Hi!
    I would like to remove a Pokemon from the player's party when it faints, meaning it dies.
    I won't worry about changing the text, not yet anyway. String manipulation is easy.
    Anyway, I am wanting to know how this would be done?
    I know of the pbRemovePokemonAt(index) function.
    Where would I put this in the script? I don't know my way around essentials very well. Additionally, I want to store the most recently killed Pokemon in a variable for a potential method of revival.
    This whole thing seems very easy, I'm just not sure where it goes. Will it need to be changed in multiple locations?
    Thanks!
     

    zingzags

    PokemonGDX creator
    536
    Posts
    15
    Years
  • You put it where the faint function is called which should be in PokeBattle_ActualScene or w.e. I do not think you should need to use a game variable, I bet it already gets the index of the pokemon in the party. Then again, its been awhile since I opened up essentials.
     

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    It's a whole can of worms, actually. The main issue is that there's no support for adding/removing Pokémon in the player's party during a battle. Trying to do so will quickly result in a mess.

    My suggestion would be to check after every battle for fainted Pokémon and delete them then (and then check for an empty party for a black-out). However, this wouldn't take into account the order in which they fainted. It'd also leave fainted Pokémon in the party (albeit unusable) until the end of the battle. Still, I think it's the best option, unless you want to change how your Nuzlocke mode works.

    There are of course other problems with deleting Pokémon, such as the player getting trapped in an area which they needed an HM to get into but the only Pokémon that could learn it was killed. This looks particularly odd if you find yourself surfing on a dead Pokémon (lingering effects like surfing/diving/Strength would need to be stopped once the user dies and there's no replacement user).
     

    Maruno

    Lead Dev of Pokémon Essentials
    5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    It really depends on how you want it to work. If you want the deletion to occur at the end of a battle, then find the parts of the code where ends of battles occur. An easy way is to find instances of the line:

    Code:
    if decision==2 || decision==5
    ...and stick something in just before it. That "something" could be:

    Code:
    for i in 0...$Trainer.party.length
      $Trainer.party[i]=nil if $Trainer.party[i].hp==0
    end
    $Trainer.party.compact!
    This code is used because it can delete the player's last usable Pokémon, which pbRemovePokemonAt can't do. This code, of course, outright deletes the Pokémon rather than putting them into a "last fainted Pokémon" variable to wait for a potential revive.

    If Pokémon can faint from poison while walking around, or faint for any other reason while walking around, you should also put this code in the appropriate script(s) to make sure they die rather than just faint.

    This approach is untested.
     
    Back
    Top