Save-Point
KAftermathHealing VX + ACE - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: KAftermathHealing VX + ACE (/thread-9848.html)



KAftermathHealing VX + ACE - kyonides - 10-02-2024

KAftermathHealing VX + ACE

by Kyonides

Introduction

The title tells you what this scriptlet is all about: healing based on the battle aftermath.

How does it work? Detective

It's very simple! Just set the values of a series of ranges, i.e.

Code:
HP_TOTAL_TURNS[min_value..max_value] = 100

...and the system will check how many turns it actually took you to defeat your opponents.

Did you need 11 turns to defeat some Ghost ghosts?
Was there a range like 10..20 included in your hash?
Does that range store 75 as its current value?
Then you already know the answer here: it will pick that very same range and assign your heroes a 75% HP recovery rate! Two Thumbs Up! 

VX Script

Code:
# * KAftermathHealing VX * #
#   Scripter : Kyonides Arkanthes
#   v0.3.1 - 2024-10-01

# This script lets you automatically heal your heroes after winning a battle
# based on the number of battle turns.

module KBattle
  # Leave these hashes alone!
  HP_TOTAL_TURNS = {}
  MP_TOTAL_TURNS = {}
  # If it took too long to defeat the enemy troopers...
  HP_TOTAL_TURNS.default = 0
  MP_TOTAL_TURNS.default = 0
  # Add as many Ranges, i.e. 1..50 as necessary:
  HP_TOTAL_TURNS[1..6]   = 100
  HP_TOTAL_TURNS[7..17]  = 75
  HP_TOTAL_TURNS[18..35] = 50
  HP_TOTAL_TURNS[36..60] = 25
  MP_TOTAL_TURNS[1..5]   = 100
  MP_TOTAL_TURNS[6..15]  = 75
  MP_TOTAL_TURNS[16..30] = 50
  MP_TOTAL_TURNS[31..50] = 25
end

class Range
  def <=>(other)
    to_a <=> other.to_a
  end
end

class Scene_Battle
  alias :kyon_btl_score_scn_btl_proc_victory :process_victory
  def process_aftermath_healing
    hp_perc = mp_perc = 0
    turns = $game_troop.turn_count
    KBattle::HP_TOTAL_TURNS.sort.reverse.each do |min_turns, percent|
      next unless min_turns.include?(turns)
      hp_perc = percent
      break
    end
    KBattle::MP_TOTAL_TURNS.sort.reverse.each do |min_turns, percent|
      next unless min_turns.include?(turns)
      mp_perc = percent
      break
    end
    $game_party.members.each do |actor|
      next if actor.dead?
      actor.hp += actor.maxhp * hp_perc / 100
      actor.mp += actor.maxmp * mp_perc / 100
    end
  end

  def process_victory
    process_aftermath_healing
    kyon_btl_score_scn_btl_proc_victory
  end
end

VX ACE Script

Code:
# * KAftermathHealing ACE * #
#   Scripter : Kyonides Arkanthes
#   v0.3.1 - 2024-10-01

# This script lets you automatically heal your heroes after winning a battle
# based on the number of battle turns.

module KBattle
  # Leave these hashes alone!
  HP_TOTAL_TURNS = {}
  MP_TOTAL_TURNS = {}
  # If it took too long to defeat the enemy troopers...
  HP_TOTAL_TURNS.default = 0
  MP_TOTAL_TURNS.default = 0
  # Add as many Ranges, i.e. 1..50 as necessary:
  HP_TOTAL_TURNS[1..6]   = 100
  HP_TOTAL_TURNS[7..17]  = 75
  HP_TOTAL_TURNS[18..35] = 50
  HP_TOTAL_TURNS[36..60] = 25
  MP_TOTAL_TURNS[1..5]   = 100
  MP_TOTAL_TURNS[6..15]  = 75
  MP_TOTAL_TURNS[16..30] = 50
  MP_TOTAL_TURNS[31..50] = 25
end

class Range
  def <=>(other)
    to_a <=> other.to_a
  end
end

class << BattleManager
  alias :kyon_btl_score_scn_btl_proc_victory :process_victory
  def process_aftermath_healing
    hp_perc = mp_perc = 0
    turns = $game_troop.turn_count
    KBattle::HP_TOTAL_TURNS.sort.reverse.each do |min_turns, percent|
      next unless min_turns.include?(turns)
      hp_perc = percent
      break
    end
    KBattle::MP_TOTAL_TURNS.sort.reverse.each do |min_turns, percent|
      next unless min_turns.include?(turns)
      mp_perc = percent
      break
    end
    $game_party.members.each do |actor|
      next if actor.dead?
      actor.hp += actor.mhp * hp_perc / 100
      actor.mp += actor.mmp * mp_perc / 100
    end
  end

  def process_victory
    process_aftermath_healing
    kyon_btl_score_scn_btl_proc_victory
  end
end


Terms & Conditions

Free for use in ANY game. Gamer
Due credit is mandatory!
Include this forum in your game credits as well!
That's it! Tongue sticking out