设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 87|回复: 0

[转载发布] KGuard Rekovery XP

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9015

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58751
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68660

    灌水之王

    发表于 2026-7-27 08:27:41 | 显示全部楼层 |阅读模式
    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

    Spoiler: KGuard Rekovery XP
                    Ruby:       
    1. # * KGuard Rekovery XP * #
    2. #   Scripter : Kyonides
    3. #   v1.1.0 - 2025-05-15
    4. # This script will allow you to gain HP or SP or even both if guarding.
    5. # There are several CONSTANTS that seemed to be repeating themselves. That is
    6. # totally fine. Just go configure them first to suit your guarding needs.
    7. # All values stand for percentages. Never add their % symbols!
    8. # Accepted Range of Values: 0 through 100.
    9. # * Optional Script Calls * #
    10. # - Add or Clear Guard States
    11. # For Heroes:
    12. #  actors = $game_party.actors
    13. #  actors[ActorIndex].add_guard_states_plus(StateID1, etc.)
    14. #  actors[ActorIndex].add_guard_states_minus(StateID1, etc.)
    15. #  actors[ActorIndex].clear_guard_states_plus
    16. #  actors[ActorIndex].clear_guard_states_minus
    17. # For Enemies in Battle:
    18. #  enemies = $game_troop.enemies
    19. #  enemies[EnemyIndex].add_guard_states_plus(StateID1, etc.)
    20. #  enemies[EnemyIndex].add_guard_states_minus(StateID1, etc.)
    21. #  enemies[EnemyIndex].clear_guard_states_plus
    22. #  enemies[EnemyIndex].clear_guard_states_minus
    23. # * Warning * #
    24. # Scene_Battle#make_basic_action_result has been overwritten.
    25. module KGuard
    26.   module LifeGain
    27.     ACTOR_PERCENT = 7
    28.     ACTOR_CHANCE  = 50
    29.     ENEMY_PERCENT = 5
    30.     ENEMY_CHANCE  = 25
    31.   end
    32.   module ManaGain
    33.     ACTOR_PERCENT = 7
    34.     ACTOR_CHANCE  = 50
    35.     ENEMY_PERCENT = 5
    36.     ENEMY_CHANCE  = 25
    37.   end
    38. end
    39. class Game_Battler
    40.   include KGuard
    41.   alias :kyon_kguard_rek_gm_btlr_init :initialize
    42.   alias :kyon_kguard_rek_gm_btlr_atk_fx :attack_effect
    43.   alias :kyon_kguard_rek_gm_btlr_skl_fx :skill_effect
    44.   attr_accessor :guard_life_rate, :guard_life_chance
    45.   attr_accessor :guard_mana_rate, :guard_mana_chance
    46.   def initialize
    47.     kyon_kguard_rek_gm_btlr_init
    48.     setup_guard_gain_points
    49.     setup_guard_states
    50.   end
    51.   def setup_guard_states
    52.     @guard_states_plus = []
    53.     @guard_states_minus = []
    54.   end
    55.   def guard_regain_life
    56.     points = guard_life_gain * maxhp / 100
    57.     self.hp += points
    58.     @damage = -points
    59.   end
    60.   def guard_regain_mana
    61.     points = guard_mana_gain * maxsp / 100
    62.     self.sp += points
    63.     @damage = -points
    64.   end
    65.   def guard_regain_points
    66.     guard_regain_life if guard_gain_life?
    67.     guard_regain_mana if guard_gain_mana?
    68.   end
    69.   def guard_life_gain
    70.     @guard_life_rate
    71.   end
    72.   def guard_mana_gain
    73.     @guard_mana_rate
    74.   end
    75.   def guard_gain_life?
    76.     rand(100) <= @guard_life_chance
    77.   end
    78.   def guard_gain_mana?
    79.     rand(100) <= @guard_mana_chance
    80.   end
    81.   def add_guard_states_plus(*new_states)
    82.     @guard_states_plus += new_states
    83.     @guard_states_plus = @guard_states_plus.uniq.sort
    84.   end
    85.   def add_guard_states_minus(*new_states)
    86.     @guard_states_minus += new_states
    87.     @guard_states_minus = @guard_states_minus.uniq.sort
    88.   end
    89.   def clear_guard_states_plus
    90.     @guard_states_plus.clear
    91.   end
    92.   def clear_guard_states_minus
    93.     @guard_states_minus.clear
    94.   end
    95.   def guard_trigger_states
    96.     n = rand(@guard_states_plus.size)
    97.     state_id = @guard_states_plus[n]
    98.     add_state(state_id) if state_id
    99.     n = rand(@guard_states_minus.size)
    100.     state_id = @guard_states_minus[n]
    101.     remove_state(state_id) if state_id
    102.   end
    103.   def attack_effect(attacker)
    104.     guard_trigger_states if guarding?
    105.     kyon_kguard_rek_gm_btlr_atk_fx(attacker)
    106.   end
    107.   def skill_effect(user, skill)
    108.     guard_trigger_states if guarding?
    109.     kyon_kguard_rek_gm_btlr_skl_fx(user, skill)
    110.   end
    111.   def attack?
    112.     @current_action.basic == 0
    113.   end
    114.   def wanna_escape?
    115.     @current_action.basic == 2
    116.   end
    117.   def do_nothing?
    118.     @current_action.basic == 3
    119.   end
    120.   def actor?
    121.     @actor_id != nil
    122.   end
    123.   def enemy?
    124.     @enemy_id != nil
    125.   end
    126. end
    127. class Game_Actor
    128.   def setup_guard_gain_points
    129.     @guard_life_rate   = LifeGain::ACTOR_PERCENT
    130.     @guard_life_chance = LifeGain::ACTOR_CHANCE
    131.     @guard_mana_rate   = ManaGain::ACTOR_PERCENT
    132.     @guard_mana_chance = ManaGain::ACTOR_CHANCE
    133.   end
    134. end
    135. class Game_Enemy
    136.   def setup_guard_gain_points
    137.     @guard_life_rate   = LifeGain::ENEMY_PERCENT
    138.     @guard_life_chance = LifeGain::ENEMY_CHANCE
    139.     @guard_mana_rate   = ManaGain::ENEMY_PERCENT
    140.     @guard_mana_chance = ManaGain::ENEMY_CHANCE
    141.   end
    142. end
    143. class Scene_Battle
    144.   def make_basic_action_result
    145.     if @active_battler.attack?
    146.       prepare_basic_attack
    147.       process_attack_action
    148.       return
    149.     end
    150.     if @active_battler.guarding?
    151.       prepare_guard_action
    152.       return
    153.     end
    154.     if @active_battler.enemy? and @active_battler.wanna_escape?
    155.       prepare_escape_action
    156.       return
    157.     end
    158.     do_nothing if @active_battler.do_nothing?
    159.   end
    160.   def prepare_basic_attack
    161.     @animation1_id = @active_battler.animation1_id
    162.     @animation2_id = @active_battler.animation2_id
    163.     if @active_battler.enemy?
    164.       if @active_battler.restriction == 3
    165.         target = $game_troop.random_target_enemy
    166.       elsif @active_battler.restriction == 2
    167.         target = $game_party.random_target_actor
    168.       else
    169.         index = @active_battler.current_action.target_index
    170.         target = $game_party.smooth_target_actor(index)
    171.       end
    172.     end
    173.     if @active_battler.actor?
    174.       if @active_battler.restriction == 3
    175.         target = $game_party.random_target_actor
    176.       elsif @active_battler.restriction == 2
    177.         target = $game_troop.random_target_enemy
    178.       else
    179.         index = @active_battler.current_action.target_index
    180.         target = $game_troop.smooth_target_enemy(index)
    181.       end
    182.     end
    183.     @target_battlers = [target].compact
    184.   end
    185.   def process_attack_action
    186.     @target_battlers.each {|target| target.attack_effect(@active_battler) }
    187.   end
    188.   def prepare_guard_action
    189.     @help_window.set_text($data_system.words.guard, 1)
    190.     @active_battler.guard_regain_points
    191.   end
    192.   def prepare_escape_action
    193.     @help_window.set_text("Escape", 1)
    194.     @active_battler.escape
    195.   end
    196.   def do_nothing
    197.     $game_temp.forcing_battler = nil
    198.     @active_battler.guard_regain_points if @active_battler.enemy?
    199.     @phase4_step = 1
    200.   end
    201. end
    复制代码




    Terms & Conditions

    Free for use in ANY game.

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



    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/kguard-rekovery-xp.166489/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-4 12:51 , Processed in 0.064886 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表