KMustSurvive
#1
KMustSurvive
XP + VX + 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! Grinning

Script Calls

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

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

XP Script

Code:
# * KMustSurvive XP * #
#   Scripter : Kyonides Arkanthes
#   v1.0.0 - 2024-02-19

# 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?
    @actors.any? {|a| a.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[enemy_index - 1] = [min_percent.to_i, max_percent.to_i]
  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[e.index])
    end
    true
  end
end

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

  def lose_scenario
    if $game_temp.battle_can_lose
      $game_system.bgm_play($game_temp.map_bgm)
      battle_end(2)
      return
    end
    $game_temp.gameover = true
  end

  def judge_enemy_survivors
    if $game_party.alive?
      if $game_troop.few_survivors?
        lose_scenario
        return true
      end
      return false unless $game_troop.only_survivors?
      if $game_troop.survivors_with_enough_hp?
        start_phase5
        return true
      end
      return false
    else
      lose_scenario
    end
  end
end

VX Script

Code:
# * KMustSurvive VX * #
#   Scripter : Kyonides Arkanthes
#   v1.0.0 - 2024-02-19

# 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[enemy_index - 1] = [min_percent.to_i, max_percent.to_i]
  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[e.index])
    end
    true
  end
end

class Scene_Battle
  alias :kyon_must_survive_scn_btl_judge :judge_win_loss
  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
end

VX ACE Script

Code:
# * KMustSurvive ACE * #
#  Scripter : Kyonides Arkanthes
#  v1.0.0 - 2024-02-19

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

class << BattleManager
  alias :kyon_must_survive_btlman_judge :judge_win_loss
  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
end

Terms & Conditions

Free for use in ANY Gamer 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! Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#2
The Night of the Scripts

Not too long after posting the XP port of KMustSurvive, I had to quickly update it because it did not contemplate all possible scenarios as I expected. Don't Worried worry, pals! Now it does! Grinning

Later on I was able to port the script to the other two engines, namely VX and VX ACE! Two Thumbs Up!

You can also download demos to better understand how it works, but I got to admit it is a very simple script indeed. Laughing
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }




Users browsing this thread: 1 Guest(s)