じ☆ve冰风 发表于 2026-7-23 19:46:47

KMustSurvive VX

KMustSurvive VX

by Kyonides​

Introduction

When I played Breath of Fire II back in the days, I noticed that there was a village where fights were a bit different. There you had to rescue the villagers by not killing them but just the scorpions that controlled them. You were still able to kill the people but it was not recommended.

This scriptlet would let the battle script judge the end result of the battle without any external interference. This means that you will not be in a dire need to keep checking your enemies' current HP every single turn via event commands!


Script Calls

                Ruby:       
$game_troop.must_survive(EnemyIndex, MinimumHP%)

                Ruby:       
$game_troop.must_survive(EnemyIndex, MinimumHP%, MaximumHP%)


There no MaxHP% is just the same as 100% of its HP.

The Script

                Ruby:       
# * KMustSurvive VX * #
#   Scripter : Kyonides Arkanthes
#   v1.0.1 - 2025-08-31

# This scriptlet allows you to set any enemy as some sort of victim that should
# be rescued during battle by NOT KILLING the victim!
# No event command will be needed during battle!

# This is a very simplistic approach to a feature in Breath of Fire II where
# you were supposed to kill the scorpion but not the villager.

# * Script Call * #
# - Warning: Both HP% parameters should be Integers.
#            If no maximum percent is entered, it will be equal to 100%
# $game_troop.must_survive(EnemyIndex, MinimumHP%)
# $game_troop.must_survive(EnemyIndex, MinimumHP%, MaximumHP%)

class Game_Actor
def alive?
    @hp > 0
end
end

class Game_Enemy
def alive?
    @hp > 0
end
end

class Game_Party
def alive?
    members.any? {|m| m.alive? }
end
end

class Game_Troop
alias :kyon_must_survive_gm_trp_init :initialize
attr_reader :survivors
def initialize
    kyon_must_survive_gm_trp_init
    @survivors = {}
end

def alive?
    @enemies.any? {|a| a.alive? }
end

def must_survive(enemy_index, min_percent, max_percent=100)
    @survivors =
end

def enemies_alive
    @enemies.select {|e| e.alive? }
end

def few_survivors?
    enemies_alive.size < @survivors.size
end

def only_survivors?
    list = enemies_alive.map {|e| e.index }
    list.sort == @survivors.keys.sort
end

def survivors_with_enough_hp?
    enemies_alive.each do |e|
      percent = e.hp * 100 / e.maxhp
      return false unless percent.between?(*@survivors)
    end
    true
end
end

class Scene_Battle
alias :kyon_must_survive_scn_btl_judge :judge_win_loss
alias :kyon_must_survive_scn_btl_blt_end :battle_end
def judge_win_loss
    if $game_troop.survivors.empty?
      kyon_must_survive_scn_btl_judge
    else
      judge_enemy_survivors
    end
end

def judge_enemy_survivors
    return true unless $game_temp.in_battle
    if $game_party.alive?
      if $game_troop.few_survivors?
      process_defeat
      return true
      end
      return false unless $game_troop.only_survivors?
      if $game_troop.survivors_with_enough_hp?
      process_victory
      return true
      end
      return false
    else
      process_defeat
      return true
    end
end

def battle_end(result)
    $game_troop.survivors.clear
    kyon_must_survive_scn_btl_blt_end(result)
end
end


Download Demo​

Terms & Conditions

Free for use in ANY game.

Due credit is mandatory.
Please include the URL of the website or forum where you found this script in your credits file.
That's it!



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