ChooseFoes ACE
#1
ChooseFoes ACE

by Kyonides

Introduction

This scriptlet allows you to open a simple menu where you can choose your enemy's troops based on the current map's random enemy encounter list.
It will use the map's battleback picture as its backdrop. Don't worry Worried about this, it will cover the whole RMXP game screen by default. Winking
You are encouraged to set a custom BGM, otherwise the scene will remain silent until you have finished picking a foe.

AVAILABLE MODES
  • :accessory
  • :levels

Accessory Mode

By the way, setting a specific "Choose Foe" accessory is mandatory here!

Actors' Level Average Mode

You must set a default level plus any specific map's average level.

The Script

Version 0.9.0
Code:
# * ChooseFoes ACE * #
#   Not Exactly a Plug-n-Play Script
#   Scripter : Kyonides
#   0.9.0 - 2026-06-16

# This scriptlet allows you to open a simple menu where you can choose your
# enemy's troops based on the current map's random enemy encounter list.

# - AVAILABLE MODES: :accessory and :levels

# * Accessory Mode * #
# Setting a specific "Choose Foe" accessory is mandatory here!
# * Average Level Mode * #
# You must set a default level plus any specific map's average level.

# * Optional Script Call * #
# $game_party.choose_foes_mode = :your_mode

module ChooseFoes
  MODE = :levels
  ACCESSORY_ID = 53
  MAP_ACTOR_LVL = {}
  MAP_ACTOR_LVL[1] = 4
  MAP_ACTOR_LVL.default = 5
  TITLE = "Pick Your Foe"
  @list = [] # Leave this array alone!
  extend self
  attr_accessor :list

  class Scene
    def initialize
      @list = $game_map.encounter_list.map(&:troop_id)
      @commands = @list.map {|n| $data_troops[n].name }
      ChooseFoes.list = @commands
    end

    def main
      BattleManager.play_battle_bgm
      @stage = true
      bn1 = $game_map.battleback1_name
      if bn1
        @backdrop = Sprite.new
        @backdrop.bitmap = Cache.battleback1(bn1)
      end
      bn2 = $game_map.battleback2_name
      if bn2
        @floor = Sprite.new
        @floor.bitmap = Cache.battleback2(bn2)
      end
      @help_window = Window_Help.new(1)
      @help_window.set_text(TITLE)
      @command_window = TroopListWindow.new(182, 80)
      Input.update
      Graphics.transition(Graphics.frame_rate)
      while @stage
        Graphics.update
        Input.update
        update
      end
      Graphics.freeze
      @command_window.dispose
      @help_window.dispose
      if bn2
        @floor.bitmap.dispose
        @floor.dispose
      end
      if bn1
        @backdrop.bitmap.dispose
        @backdrop.dispose
      end
    end

    def update
      @command_window.update
      if Input.trigger?(:B) or Input.trigger?(:C)
        Sound.play_battle_start
        @stage = nil
        n = @command_window.index
        troop_id = @list[n]
        ChooseFoes.list.clear
        BattleManager.setup(troop_id)
        BattleManager.save_bgm_and_bgs
        SceneManager.goto(Scene_Battle)
      end
    end
  end
end

class Game_BaseItem
  attr_reader :item_id
end

class Game_Actor
  FOES_ACCESSORY_ID = ChooseFoes::ACCESSORY_ID
  def armor_ids
    list = @equips.select(&:is_armor?)
    list.map(&:item_id)
  end

  def can_pick_foes?
    return false if FOES_ACCESSORY_ID == 0
    armor_ids.include?(FOES_ACCESSORY_ID)
  end
end

class Game_Party
  alias :kyon_chs_foes_gm_pty_init :initialize
  def initialize
    kyon_chs_foes_gm_pty_init
    @choose_foes_mode = ChooseFoes::MODE
  end

  def choose_foes_with_accessory?
    members.find {|a| a.can_pick_foes? } != nil
  end

  def choose_foes_level_avg?
    actors = members
    avg_level = actors.inject(0) {|t, a| t + a.level }
    avg_level /= actors.size
    map_level = ChooseFoes::MAP_ACTOR_LVL[$game_map.map_id]
    avg_level >= map_level
  end

  def choose_foes?
    case @choose_foes_mode
    when :accessory
      return choose_foes_with_accessory?
    when :levels
      return choose_foes_level_avg?
    end
  end
  attr_accessor :choose_foes_mode
end

class Game_Player
  def encounter
    return false if $game_map.interpreter.running?
    return false if $game_system.encounter_disabled
    return false if @encounter_count > 0
    make_encounter_count
    list = $game_map.encounter_list
    if list.size > 1 and $game_party.choose_foes?
      SceneManager.call(ChooseFoes::Scene)
      return false
    end
    troop_id = make_encounter_troop_id
    return false unless $data_troops[troop_id]
    BattleManager.setup(troop_id)
    BattleManager.on_encounter
    return true
  end
end

class TroopListWindow < Window_Command
  def make_command_list
    @list = ChooseFoes.list
  end

  def window_width
    180
  end

  def process_handling
    if Input.trigger?(:B) or Input.trigger?(:C)
      deactivate
    end
  end

  def draw_item(n)
    change_color(normal_color, true)
    draw_text(item_rect_for_text(n), @list[n], 0)
  end
end


Uploaded to the rpg-maker-scripts repository!

Terms & Conditions

MIT License.
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




Users browsing this thread: 2 Guest(s)