KMustSurvive ACE

KMustSurvive ACE

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 :editor: script :judge: 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 ACE * #
#   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_Unit
  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 must_survive(enemy_index, min_percent, max_percent=100)
    @survivors[enemy_index - 1] = [min_percent.to_i, max_percent.to_i]
  end

  def enemies_alive
    members.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.mhp
      return false unless percent.between?(*@survivors[e.index])
    end
    true
  end
end

class << BattleManager
  alias :kyon_must_survive_btlman_judge :judge_win_loss
  alias :kyon_must_survive_btlman_blt_end :battle_end
  def judge_win_loss
    if $game_troop.survivors.empty?
      kyon_must_survive_btlman_judge
    else
      judge_enemy_survivors
    end
  end

  def judge_enemy_survivors
    return false unless @phase
    return process_abort if $game_party.members.empty? or aborting?
    return process_defeat if $game_party.all_dead?
    return process_defeat if $game_troop.few_survivors?
    return false unless $game_troop.only_survivors?
    if $game_troop.survivors_with_enough_hp?
      return process_victory
    else
      return process_defeat
    end
  end

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


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! 😛
Hey! Thanks for creating this! Just tested the demo - very cool! Seems like I'm doing something wrong though because for some reason, when I kill the hostages, I get a game over. That's what happens what I try this in my current project. Perhaps there's a script that conflicting with this one?

I'll keep troubleshooting but do you have any suggestions on what to do? Thanks!

edit: disabled the gameover related script I had and still get the game over screen - unlike the demo.
heyguy said:
...because for some reason, when I kill the hostages, I get a game over.

Well, I gotta ask you something first. Did you allow the battle to continue even if you lose / kill the poor hostages? Just wanna make sure we're not skipping that important part here.

Does the same happen in any other game project of yours? With different sets of scripts, I mean.

EDIT

Another question here: are you using any other script that might have altered BattleManager's process_defeat method by any chance?
Well, I gotta ask you something first. Did you allow the battle to continue even if you lose / kill the poor hostages? Just wanna make sure we're not skipping that important part here.
I'm not sure how to allow the battle to continue. How would I do that? In your demo, when I kill the hostages, at the end of the turn, my party is "defeated". Then I'm taken back to the map. I figured if that's the only way it works, I'd have the bad guys insult the player after the battle then flee the map.

Another question here: are you using any other script that might have altered BattleManager's process_defeat method by any chance?
That answer to that question is...probably? I'm too coding illiterate to really know. 🙁 I've got a ton of scripts though. A bunch of random stuff, Yanfly, MOG and Victor Engine scripts. The MOG ones are combat related but using crtl+F didn't find me process_defeat. The game over script also doesn't include process_defeat and I don't see any other game over specific scripts. I'll keep troubleshooting though. Thanks!

edit: Take it back, some of the MOG related battle scripts do effect process_defeat 🙁 Below is the pieces of code from MOG Battle HUD EX and Battle Command EX. It's possible there are more

1708413582535.png

1708413620453.png
1. What I meant was that you gotta check the "continue even if lose" option while setting up the battle event. Nothing new here.

2. Weird. Those mods are insignificant, just turning on the same flag and that's it. They can't alter the way it works. This makes me wonder if losing the battle isn't the only end result being altered in your game project.
Maintenance Update​

A while ago I noticed that I had forgotten to clear the survivors list (an array) so this release adds that feature at the end of battle as first intended.

This port also called the enemies array as if it were containing the actual list of enemies present in battle. I had to correct this by calling the members method to prevent the game from crashing under specific circumstances.

Original thread: https://forums.rpgmakerweb.com/threads/kmustsurvive-ace.165933/