• Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Resource icon

v20.1 Auto Healing (like in SV) 0.1

This resource pertains to version 20.1 of Pokémon Essentials.
Pokémon Essentials Version
v20.1 ➖
Overview
  • Lets the player use the SPECIAL button when in the party screen to auto heal the selected Pokémon. The SPECIAL button needs to be pressed once for each of the actions mentioned below. I think this is more player-friendly because sometimes you don't want to completely heal your Pokémon. Maybe you just want to heal the status condition and not waste a Potion at the same time just because it lost 1 HP.
  • Auto Healing works as follows:
    • First, tries to revive the Pokémon if fainted (using Revive if the player has one).
    • Second, tries to heal status conditions (using Awakening, Antidote, etc., or Full Heal).
    • Third, tries to heal HP (using Potions, Sodas, or Moomoo Milk as in SV).
  • Plays a sound when something was healed and the buzzer if (further) healing is not possible.
  • Is only available when not in battle.
Installation
First, put the following script above Main.
Ruby:
def pbAutoHeal

  pkmn = $healpoke
 
  # Don't do anything (egg)
  if pkmn.egg?
    return pbPlayBuzzerSE
  end
 
  # Don't do anything (fully healed)
  if pkmn.hp == pkmn.totalhp && pkmn.status == :NONE
    return pbPlayBuzzerSE
  end
 
  # [1] Revive fainted Pokémon
  if pkmn.hp == 0 && $bag.has?(:REVIVE)
    pkmn.hp = (pkmn.totalhp / 2).floor
    $bag.remove(:REVIVE)
    return pbSEPlay("Mining reveal", 100)
  elsif pkmn.hp == 0
    # Don't do anything (KO but no Revives)
    return pbPlayBuzzerSE
  end
 
  # [2] Heal status condition
  statuses = [:SLEEP, :POISON, :BURN, :PARALYSIS, :FROZEN]
  items = [:AWAKENING, :ANTIDOTE, :BURNHEAL, :PARALYZEHEAL, :ICEHEAL]
  for i in 0..4
    if pkmn.status == statuses[i] && $bag.has?(items[i])
      $bag.remove(items[i])
      pkmn.heal_status
      return pbSEPlay("Mining reveal", 100)
    end
  end
  if pkmn.status != :NONE && $bag.has?(:FULLHEAL)
    $bag.remove(:FULLHEAL)
    pkmn.heal_status
    return pbSEPlay("Mining reveal", 100)
  end
 
  # Don't do anything (no status item)
  if pkmn.status != :NONE && pkmn.hp == pkmn.totalhp
    return pbPlayBuzzerSE
  end
 
  # [3] Heal HP
  if pkmn.hp < pkmn.totalhp &&  !$bag.has?(:POTION) && !$bag.has?(:FRESHWATER) &&
    !$bag.has?(:SODAPOP) && !$bag.has?(:SUPERPOTION) && !$bag.has?(:LEMONADE) &&
    !$bag.has?(:MOOMOOMILK) && !$bag.has?(:HYPERPOTION)
    return pbPlayBuzzerSE
  else
    loop do
      hptoheal = pkmn.totalhp - pkmn.hp
      if hptoheal > 0 && $bag.has?(:POTION)
        pkmn.hp += 20
        $bag.remove(:POTION)
      elsif hptoheal > 0 && $bag.has?(:FRESHWATER)
        pkmn.hp += 30
        $bag.remove(:FRESHWATER)
      elsif hptoheal > 0 && $bag.has?(:SODAPOP)
        pkmn.hp += 50
        $bag.remove(:SODAPOP)
      elsif hptoheal > 0 && $bag.has?(:SUPERPOTION)
        pkmn.hp += 60
        $bag.remove(:SUPERPOTION)
      elsif hptoheal > 0 && $bag.has?(:LEMONADE)
        pkmn.hp += 70
        $bag.remove(:LEMONADE)
      elsif hptoheal > 0 && $bag.has?(:MOOMOOMILK)
        pkmn.hp += 100
        $bag.remove(:MOOMOOMILK)
      elsif hptoheal > 0 && $bag.has?(:HYPERPOTION)
        pkmn.hp += 120
        $bag.remove(:HYPERPOTION)
      else
        break
      end
    end
    return pbSEPlay("Mining reveal", 100)
  end
 
end

Now go to UI_Party and search the following code:
Ruby:
@sprites["storagetext"] = Window_UnformattedTextPokemon.new(
      @can_access_storage ? _INTL("[Special]: To Boxes") : ""
    )

And replace it with this new code:
Ruby:
@sprites["storagetext"] = Window_UnformattedTextPokemon.new(
      $game_temp.in_battle ? "" : _INTL("SPECIAL: Auto Heal"))

Lastly, still in UI_Party, search for the following code:
Ruby:
if Input.trigger?(Input::SPECIAL) && @can_access_storage && canswitch != 2
  pbPlayDecisionSE
  pbFadeOutIn {
    scene = PokemonStorageScene.new
    screen = PokemonStorageScreen.new(scene, $PokemonStorage)
    screen.pbStartScreen(0)
    pbHardRefresh
  }

And replace it with this new code:
Ruby:
if Input.trigger?(Input::SPECIAL) && !$game_temp.in_battle && canswitch != 2
  $healpoke = $player.party[@activecmd]
  pbAutoHeal
  pbRefresh
Credits
Credits are not required. Note that I'm not a scripter. I created this in a few minutes, so feel free to adapt/optimize.
Please let me know if you find any errors. Tested only with Essentials v20.1.
Author
SunriseStudios
Views
1,748
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from SunriseStudios

Latest reviews

Does exactly what is advertised and is super easy to install!
Back
Top