Looking for a someone to create a script that allows the player to target individual enemies for multiple attacks.

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
Instead of just 2, three, or 4 random targets. That way a player won't randomly hit targets with spells that might accidentally cure the enemy, etc. A Fire Spell on a Fire Elemental for example. I found one script that does this but it was for MV. And I found another that works just for the enemy A.I. But not the player.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
I just realized that I didn't make the script you wanted. I did something similar.
I'll work on it more, but if you can be more descriptive on EXACTLY how the script should function, that would be good.
For example you said fire elementals. So is it supposed to ignore them when choosing the skill?

The way I have it now is that it will pull up the enemy window and you get to select what group or specific enemies you want the spell to affect.
Not sure if that is better, so let me know.

Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Random Scope Target Select   ║  Version: 1.01     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function:                           ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║  Alter Random Selection             ║    20 May 2022     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Instructions:                                            ║
# ║     Place note tag on the skill you wish to alter        ║
# ║                                                          ║
# ║    Skill must be set to select random enemies 1-4        ║
# ║                                                          ║
# ║      <select random: indiv>                              ║
# ║     Allows choosing the enemies up to number of random   ║
# ║       enemies is set in the skill                        ║
# ║                                                          ║
# ║      <select random: group>                              ║
# ║     Will select all enemies of the same type up to       ║
# ║        the number of random enemies set for the skill.   ║
# ║        Example - two bats on screen. You select bat and  ║
# ║        skill is set to 4 random enemies. It will         ║
# ║        randomly select from the two to complete          ║
# ║        the taregets (bat1, bat1, bat2, bat1)             ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║   2022-May-20 - Initial publish                          ║
# ║   2022-May-30 - Fixed typo                               ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Free for all uses in RPG Maker VX Ace - except nudity    ║
# ╚══════════════════════════════════════════════════════════╝

module R2_Random_Enemy_Select
  X_POS = 100 # window x position
  Y_POS = 100 # window y position
  WIDTH = 270 # window width
  HEIGHT = 50 # window height
  Extra = false # add more to the window width if text is long
  Extra_Space = 20 # how much space to add.
  REGEX = /<select[-_ ]random:[ ](\w+)>/i # regex code for script
  Enemy_Text = "Choose the Targets" # text shown in window
  Enemy_Group = "Choose the Target Group" # text shown in window
  # IMPORTANT - set and forget. Used internally to hold targets
  Variable = 9
end

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
 
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_r2prev_esel load_database; end
  def self.load_database
    load_database_r2prev_esel
    load_notetags_r2_sk_esel
  end
 
  #--------------------------------------------------------------------------
  # new method: load_notetags_lse
  #--------------------------------------------------------------------------
  def self.load_notetags_r2_sk_esel
    for r2skesel in $data_skills
      next if r2skesel.nil?
      r2skesel.load_notetags_r2_sk_esel
    end
  end
 
end # DataManager

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
 
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :enm_sel_sk

  #--------------------------------------------------------------------------
  # common cache: load_notetags_lse
  #--------------------------------------------------------------------------
  def load_notetags_r2_sk_esel
    @enm_sel_sk = ""
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when R2_Random_Enemy_Select::REGEX
        return if $1.nil?
        @enm_sel_sk = ($1.upcase.to_s)
      end
    } # self.note.split
    #---
  end
 
end # RPG::Skill

class Window_Enemy_Random < Window_Base
  attr_accessor :enemy_selected
  attr_accessor :enemy_group
  attr_accessor :enemy_count
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    x = R2_Random_Enemy_Select::X_POS
    y = R2_Random_Enemy_Select::Y_POS
    super(x, y, window_width, window_height)
    self.width += R2_Random_Enemy_Select::Extra_Space if R2_Random_Enemy_Select::Extra == true
    @enemy_group = false
    @enemy_count = 0
    @enemy_selected = 0
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    R2_Random_Enemy_Select::WIDTH
  end
  #--------------------------------------------------------------------------
  # * Get Window Height
  #--------------------------------------------------------------------------
  def window_height
    R2_Random_Enemy_Select::HEIGHT
  end
  #--------------------------------------------------------------------------
  # * Set Skill
  #--------------------------------------------------------------------------
  def set_skill(skill)
    return if skill.enm_sel_sk == []
    skill.enm_sel_sk == "GROUP" ? @enemy_group = true : @enemy_group = false
    @enemy_count = skill.scope.to_i - 2
    @enemy_selected = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Set selected
  #--------------------------------------------------------------------------
  def add_selected(num)
    @enemy_selected += num
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    reset_font_settings
    text2 = @enemy_selected.to_s + "/" + @enemy_count.to_s
    if @enemy_group == false
      text1 = R2_Random_Enemy_Select::Enemy_Text.to_s
      text = text1 + ": " + text2
    else
      text = R2_Random_Enemy_Select::Enemy_Group.to_s
    end
    draw_text(0, -15, window_width, window_height, text, 0)
  end
end

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Create All Windows
  #--------------------------------------------------------------------------
  alias r2_create_all_enemy_select_windows_824f7  create_all_windows
  def create_all_windows
    r2_create_all_enemy_select_windows_824f7
    enemy_selected_window
  end
  #--------------------------------------------------------------------------
  # * Create Message Window
  #--------------------------------------------------------------------------
  def enemy_selected_window
    @enemy_select_window = Window_Enemy_Random.new
    @enemy_select_window.hide
  end
 
  #--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def select_enemy_random_selection
    @enm_list = []
    @enm_selected = []
    $game_variables[R2_Random_Enemy_Select::Variable] = []
    @enemy_select_window.set_skill(@skill)
    @enemy_window.refresh
    @enemy_window.show.activate
    @enemy_select_window.show
  end
  #--------------------------------------------------------------------------
  # * Pick enemies from the group
  #--------------------------------------------------------------------------
  def pick_enemy
    amt = @enm_selected.size
    num = rand(amt)
    return @enm_selected[num]
  end
  #--------------------------------------------------------------------------
  # * Enemy [OK]
  #--------------------------------------------------------------------------
  def on_enemy_ok
    if (@actor_command_window.current_symbol == :skill) && (@skill.enm_sel_sk == "GROUP")
      BattleManager.actor.input.target_index = @enemy_window.enemy.index
      choosen = @enemy_window.enemy
      $game_troop.alive_members.each { |enemy|
        @enm_selected.push(enemy) if enemy.enemy_id == choosen.enemy_id
      }
      for i in 1..(@skill.scope.to_i - 2)
        @enm_list.push(pick_enemy)
      end
      $game_variables[R2_Random_Enemy_Select::Variable] = @enm_list
      @enemy_select_window.hide
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      next_command
    elsif (@actor_command_window.current_symbol == :skill) && (@skill.enm_sel_sk == "INDIV")
      BattleManager.actor.input.target_index = @enemy_window.enemy.index
      $game_variables[R2_Random_Enemy_Select::Variable].push(@enemy_window.enemy)
      @enemy_select_window.add_selected(1)
      if @enemy_select_window.enemy_selected == (@skill.scope.to_i - 2)
        @enemy_select_window.hide
        @enemy_window.hide
        @skill_window.hide
        @item_window.hide
        next_command
      else
        @enemy_window.refresh
        @enemy_window.show.activate
        @enemy_select_window.show
      end
    else
      BattleManager.actor.input.target_index = @enemy_window.enemy.index
      @enemy_window.hide
      @skill_window.hide
      @item_window.hide
      next_command
    end
  end
  #--------------------------------------------------------------------------
  # * Skill [OK]
  #--------------------------------------------------------------------------
  def on_skill_ok
    @skill = @skill_window.item
    BattleManager.actor.input.set_skill(@skill.id)
    BattleManager.actor.last_skill.object = @skill
    if @skill.enm_sel_sk == ""
      if !@skill.need_selection?
        @skill_window.hide
        next_command
      elsif @skill.for_opponent?
        select_enemy_selection
      else
        select_actor_selection
      end
    else
      select_enemy_random_selection
    end
  end
  #--------------------------------------------------------------------------
  # * Enemy [Cancel]
  #--------------------------------------------------------------------------
  def on_enemy_cancel
    @enemy_window.hide
    @enemy_select_window.hide
    case @actor_command_window.current_symbol
    when :attack
      @actor_command_window.activate
    when :skill
      @skill_window.activate
      @enemy_select_window.hide
    when :item
      @item_window.activate
    end
  end
end

class Game_Unit
  #--------------------------------------------------------------------------
  # * Random Selection of Target
  #--------------------------------------------------------------------------
  def random_specific
    select = $game_variables[R2_Random_Enemy_Select::Variable][0]
    return nil if select == nil
    $game_variables[R2_Random_Enemy_Select::Variable].shift
    return select
  end
end

class Game_Action
  #--------------------------------------------------------------------------
  # * OVERWRITE - Random Selection of Target
  #--------------------------------------------------------------------------
  def targets_for_opponents
    if item.for_random?
      if item.is_a?(RPG::Skill) && item.enm_sel_sk != ""
        Array.new(item.number_of_targets) { opponents_unit.random_specific }
      else
        Array.new(item.number_of_targets) { opponents_unit.random_target }
      end
    elsif item.for_one?
      num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
      if @target_index < 0
        [opponents_unit.random_target] * num
      else
        [opponents_unit.smooth_target(@target_index)] * num
      end
    else
      opponents_unit.alive_members
    end
  end
end
 
Last edited:

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
Nah, I didn't want to restrict the targeting. I didn't want people's brains on autopilot while playing. How is anyone supposed to learn without making mistakes? It sounds like what I was hoping for. Ok, I tested it out and that part works the way I want it to. On my game, I did notice that if you choose a skill and give it <select random: indiv> that doesn't randomly target an enemy it bugs out and can target infinite (I'm guessing) enemies but will never cast. And if an enemy that has a skill that can target two random enemies it won't attack at all. Regardless if it has <select random: indiv>, <select random: group> or if the skill note tag is left completely blank. So the only way an enemy can attack is if it has the scope on the skill set to one enemy or all enemies. So this is prolly because of conflicting scripts on my game.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
So this is prolly because of conflicting scripts on my game.
Likely. All my tests were with 3 random enemies.
Do I have a copy of your demo? I don't think so.
Would you like to share? I can see whats wrong much faster.
 

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
I don't think anyone has a copy of my demo. No one has played my game in like 5 years. And the one I did have up was a broken link because I forget to update it. I can prolly add all my scripts to a new game and send that to you. Because I have paid for packs on it. Unless you already have RPG MAKER DS RESOURCE PACK and ANCIENT DUNGEONS: BASE PACK.

 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
readme.txt

RPG MAKER DS+ Resource Pack
2013.09.06


readme.txt

Ancient Dungeons: Base Pack
2015.12.22
 

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
So are you saying you have those?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
So, I'm testing the demo You sent me and it works fine.
Did you fix it yourself?
 

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
No. What exactly are you testing? The problem I am having is that the enemy doesn't attack if he has a skill that attacks multiple random enemies. I've tried it on a new game and it works fine.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
Found the issue. It was basically a typo. The script above is updated.
 

Tanarex

Scrub
Veteran
Joined
Sep 14, 2014
Messages
617
Reaction score
420
First Language
English
Primarily Uses
RMVXA
I don't see any other script besides the one you posted on May 19th. I tried replacing it with the one you have up and it didn't do anything different. I was wrong about it working on a new game. I only checked last night if it would stop the enemy from attacking random characters. But now I see it wasn't activating the script at all. Maybe I have to have a prerequisite?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
4,124
Reaction score
1,107
First Language
English
Primarily Uses
RMVXA
Then I don't know what your doing. I updated the code in my post above and tested a battle with three enemies that used a skill which targeted 3 random enemies and it worked fine.
Yes the May 19th post. I edited it.
 

Latest Threads

Latest Posts

Latest Profile Posts

Couldn't sleep at all so I started working on the topmost deck. I've had to make several deviations from the Imperator/Berengaria's deck-plans to accommodate MV's movement, but 100% accuracy was never my intention.
Still no name for the poor ship...:kaodes:
Screenshot-2022-06-25-053308.png
ScreenShot_6_24_2022_9_20_7.png
Here's Mike when you get a preemptive strike in battle. There's another one for when an enemy sneaks up on you too.
Suddenly, games mean nothing. The money spent was worth it to bring souls towards the light of life. May God bless my path forever. I pray that all are shaken for truth and poured out flat on the table of true understanding, knowledge, and wisdom. Bless you.
Finally I bought OMORI...cant wait to get traumatised!!!
Finished making this pretty ambitious forest map. Was wondering what y'all think of it! :kaopride:
1656136876015.png

Forum statistics

Threads
123,023
Messages
1,153,467
Members
161,366
Latest member
Navhae
Top