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

[Scripting Question] [v18] Change HP in Mega evolution

  • 125
    Posts
    4
    Years
    • Seen Nov 20, 2023
    I am trying to add some Mega fakemon into the game,and I would like to change it's HP Basestat.
    The problem is after a battle,when it transform back to normal,it will lose some HP,which,may make it fainting.
    And if it is the only one in your party,it will cause bugs.
    So can anyone tell me how to solve it?I expect it will remain at least 1HP after battle.
     
  • 19
    Posts
    4
    Years
    • Seen Jan 14, 2021
    Alright so, this is the reason official mega evolutions never touch how much HP the pokemon has, because of his exact problem when it reverts back. The way to change this would be to edit the script that handles reverting the pokemon back to its pre-mega state. In theory, this would involve editing the definition (def) for makeUnmega in Pokemon_MegaEvolution so that, if the pokemon has more than 0 HP, it will unMega the pokemon and then set its hp to a minimum of 1, but if it was already fainted, it will leave it as fainted.

    Which version of Essentials are you using - 18.0 or 18.1?
     
    Last edited:
  • 125
    Posts
    4
    Years
    • Seen Nov 20, 2023
    v18.1
    Now I solve it with another way.
    I change the HP rule of calcStats
    from
    hpDiff = @totalhp-@hp
    @totalhp = stats[PBStats::HP]
    @hp = @totalhp-hpDiff
    to
    a = @hp*1000 / @totalhp
    @totalhp = stats[PBStats::HP]
    @hp = @totalhp*a/1000 if a!=0
    @hp = 1 if @totalhp*a/1000==0
    It works well,but maybe it will cause other bugs.
     
  • 19
    Posts
    4
    Years
    • Seen Jan 14, 2021
    Alright, if you got it working, I guess just try and test some other things that manipulate HP and see if they cause any errors. I recommend keeping the old code in the script, but commented out.
     
    Back
    Top