• 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] Heal Pokemon over time (Overworld)

  • 4
    Posts
    1
    Years
    • Seen Dec 2, 2022
    Hoping someone can help me here. I'm looking to replace Pokecenters with healing over time. Preferably it would be tied to steps taken if not time itself, and ideally would be restricted to Pokemon in a PC Box.

    I see the game primarily uses "Recover All" when healing at Pokecenters and not a script call.

    Any advice?
     
  • 4
    Posts
    1
    Years
    • Seen Dec 2, 2022
    Great idea!

    I found the relevant code that calculates Poison as well as Happiness on step.

    Happiness:
    Spoiler:



    Poison:
    Spoiler:


    I think it should be easy to just add a third option in this area for healing, but could still use some guidance on how to correctly incorporate the below underlined areas.

    # Heal Party Pokémon
    EventHandlers.add(:on_player_step_taken_can_transfer, :heal_party,
    proc { |handled|
    # handled is an array: [nil]. If [true], a transfer has happened because of
    # this event, so don't do anything that might cause another one
    next if handled[0]
    pkmn.hp += 1 if pkmn.hp < pkmn.totalhp
    end
    }

    1.) What does the :poison_party and :gain_happiness commands do, and do I need to create :heal_party somewhere?
    2.) Am I using totalhp correctly here?
     
  • 188
    Posts
    9
    Years
    • Seen May 16, 2024
    Your code appears to be correct. I would suggest a larger HP gain rate for higher-level Pokémon unless you want to take hundreds of steps to fully heal a Pokémon. Perhaps an HP gain by a ceiling quotient of totalhp by the maximum number of steps as shown here:
    Code:
    hpgain = (pkmn.totalhp / maxSteps).ceil
     
    Back
    Top