public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

XPKGuard Rekovery XP

BMM Archive · July 16, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: KGuard Rekovery XP
  • Original author: kyonides
  • Original date: March 5, 2024
  • Source thread: https://forums.rpgmakerweb.com/threads/kguard-rekovery-xp.166489/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS Scripts (RMXP)

Summary

KGuard Rekovery XP by Kyonides​ Introduction This script will allow you to gain HP or SP or even both if guarding, but it depends on luck or a random number to be precise.

Archived First Post

KGuard Rekovery XP

by Kyonides

Introduction

This script will allow you to gain HP or SP or even both if guarding, but it depends on luck or a random number to be precise.

There are several CONSTANTS embedded in the script that seemed to be repeating themselves. That is totally fine. Just go configure them at any given time to suit your guarding needs.

All values stand for percentages. Never add their % symbols!
Accepted Range of Values: 0 through 100.

Since version 1.1.0 you can also add or remove or clear Guard States!

Warning

Scene_Battle#make_basic_action_result has been overwritten.
It won't work in old saved games! You got to delete them.

The Script

Ruby:
# * KGuard Rekovery XP * #
#   Scripter : Kyonides
#   v1.1.0 - 2025-05-15

# This script will allow you to gain HP or SP or even both if guarding.
# There are several CONSTANTS that seemed to be repeating themselves. That is
# totally fine. Just go configure them first to suit your guarding needs.
# All values stand for percentages. Never add their % symbols!
# Accepted Range of Values: 0 through 100.

# * Optional Script Calls * #
# - Add or Clear Guard States
# For Heroes:
#  actors = $game_party.actors
#  actors[ActorIndex].add_guard_states_plus(StateID1, etc.)
#  actors[ActorIndex].add_guard_states_minus(StateID1, etc.)
#  actors[ActorIndex].clear_guard_states_plus
#  actors[ActorIndex].clear_guard_states_minus
# For Enemies in Battle:
#  enemies = $game_troop.enemies
#  enemies[EnemyIndex].add_guard_states_plus(StateID1, etc.)
#  enemies[EnemyIndex].add_guard_states_minus(StateID1, etc.)
#  enemies[EnemyIndex].clear_guard_states_plus
#  enemies[EnemyIndex].clear_guard_states_minus

# * Warning * #
# Scene_Battle#make_basic_action_result has been overwritten.

module KGuard
  module LifeGain
    ACTOR_PERCENT = 7
    ACTOR_CHANCE  = 50
    ENEMY_PERCENT = 5
    ENEMY_CHANCE  = 25
  end

  module ManaGain
    ACTOR_PERCENT = 7
    ACTOR_CHANCE  = 50
    ENEMY_PERCENT = 5
    ENEMY_CHANCE  = 25
  end
end

class Game_Battler
  include KGuard
  alias :kyon_kguard_rek_gm_btlr_init :initialize
  alias :kyon_kguard_rek_gm_btlr_atk_fx :attack_effect
  alias :kyon_kguard_rek_gm_btlr_skl_fx :skill_effect
  attr_accessor :guard_life_rate, :guard_life_chance
  attr_accessor :guard_mana_rate, :guard_mana_chance
  def initialize
    kyon_kguard_rek_gm_btlr_init
    setup_guard_gain_points
    setup_guard_states
  end

  def setup_guard_states
    @guard_states_plus = []
    @guard_states_minus = []
  end

  def guard_regain_life
    points = guard_life_gain * maxhp / 100
    self.hp += points
    @damage = -points
  end

  def guard_regain_mana
    points = guard_mana_gain * maxsp / 100
    self.sp += points
    @damage = -points
  end

  def guard_regain_points
    guard_regain_life if guard_gain_life?
    guard_regain_mana if guard_gain_mana?
  end

  def guard_life_gain
    @guard_life_rate
  end

  def guard_mana_gain
    @guard_mana_rate
  end

  def guard_gain_life?
    rand(100) <= @guard_life_chance
  end

  def guard_gain_mana?
    rand(100) <= @guard_mana_chance
  end

  def add_guard_states_plus(*new_states)
    @guard_states_plus += new_states
    @guard_states_plus = @guard_states_plus.uniq.sort
  end

  def add_guard_states_minus(*new_states)
    @guard_states_minus += new_states
    @guard_states_minus = @guard_states_minus.uniq.sort
  end

  def clear_guard_states_plus
    @guard_states_plus.clear
  end

  def clear_guard_states_minus
    @guard_states_minus.clear
  end

  def guard_trigger_states
    n = rand(@guard_states_plus.size)
    state_id = @guard_states_plus[n]
    add_state(state_id) if state_id
    n = rand(@guard_states_minus.size)
    state_id = @guard_states_minus[n]
    remove_state(state_id) if state_id
  end

  def attack_effect(attacker)
    guard_trigger_states if guarding?
    kyon_kguard_rek_gm_btlr_atk_fx(attacker)
  end

  def skill_effect(user, skill)
    guard_trigger_states if guarding?
    kyon_kguard_rek_gm_btlr_skl_fx(user, skill)
  end

  def attack?
    @current_action.basic == 0
  end

  def wanna_escape?
    @current_action.basic == 2
  end

  def do_nothing?
    @current_action.basic == 3
  end

  def actor?
    @actor_id != nil
  end

  def enemy?
    @enemy_id != nil
  end
end

class Game_Actor
  def setup_guard_gain_points
    @guard_life_rate   = LifeGain::ACTOR_PERCENT
    @guard_life_chance = LifeGain::ACTOR_CHANCE
    @guard_mana_rate   = ManaGain::ACTOR_PERCENT
    @guard_mana_chance = ManaGain::ACTOR_CHANCE
  end
end

class Game_Enemy
  def setup_guard_gain_points
    @guard_life_rate   = LifeGain::ENEMY_PERCENT
    @guard_life_chance = LifeGain::ENEMY_CHANCE
    @guard_mana_rate   = ManaGain::ENEMY_PERCENT
    @guard_mana_chance = ManaGain::ENEMY_CHANCE
  end
end

class Scene_Battle
  def make_basic_action_result
    if @active_battler.attack?
      prepare_basic_attack
      process_attack_action
      return
    end
    if @active_battler.guarding?
      prepare_guard_action
      return
    end
    if @active_battler.enemy? and @active_battler.wanna_escape?
      prepare_escape_action
      return
    end
    do_nothing if @active_battler.do_nothing?
  end

  def prepare_basic_attack
    @animation1_id = @active_battler.animation1_id
    @animation2_id = @active_battler.animation2_id
    if @active_battler.enemy?
      if @active_battler.restriction == 3
        target = $game_troop.random_target_enemy
      elsif @active_battler.restriction == 2
        target = $game_party.random_target_actor
      else
        index = @active_battler.current_action.target_index
        target = $game_party.smooth_target_actor(index)
      end
    end
    if @active_battler.actor?
      if @active_battler.restriction == 3
        target = $game_party.random_target_actor
      elsif @active_battler.restriction == 2
        target = $game_troop.random_target_enemy
      else
        index = @active_battler.current_action.target_index
        target = $game_troop.smooth_target_enemy(index)
      end
    end
    @target_battlers = [target].compact
  end

  def process_attack_action
    @target_battlers.each {|target| target.attack_effect(@active_battler) }
  end

  def prepare_guard_action
    @help_window.set_text($data_system.words.guard, 1)
    @active_battler.guard_regain_points
  end

  def prepare_escape_action
    @help_window.set_text("Escape", 1)
    @active_battler.escape
  end

  def do_nothing
    $game_temp.forcing_battler = nil
    @active_battler.guard_regain_points if @active_battler.enemy?
    @phase4_step = 1
  end
end

DOWNLOAD DEMO

Terms & Conditions

Free for use in ANY game.
Due credit is mandatory.
Mention this forum in your game credits as well.
That's it!

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

License / Terms Note

Due credit is mandatory. Mention this forum in your game credits as well. That's it!

Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rgss#script-archive

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar