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.
Looking for a someone to create a script that allows the player to target individual enemies for multiple attacks.
RGSS3 Script RequestsI 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.
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.03 ║
# ║ 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 ║
# ║ 2022-Nov-03 - Fixed alias bug ║
# ║ 2022-Nov-03 - Added Support for Yanfly Battle Engine ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ 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]
#--------------------------------------------------------------------------
alias r2_enemy_ok_skill_check_group on_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
r2_enemy_ok_skill_check_group
end
end
#--------------------------------------------------------------------------
# * Skill [OK]
#--------------------------------------------------------------------------
if $imported["YEA-BattleEngine"]
def on_skill_ok
@skill = @skill_window.item
$game_temp.battle_aid = @skill
BattleManager.actor.input.set_skill(@skill.id)
BattleManager.actor.last_skill.object = @skill
if @skill.enm_sel_sk != ""
select_enemy_random_selection
elsif @skill.for_opponent?
select_enemy_selection
elsif @skill.for_friend?
select_actor_selection
else
@skill_window.hide
next_command
$game_temp.battle_aid = nil
end
end
else
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 != ""
select_enemy_random_selection
elsif [email protected]_selection?
@skill_window.hide
next_command
elsif @skill.for_opponent?
select_enemy_selection
else
select_actor_selection
end
end
end
#--------------------------------------------------------------------------
# * Enemy [Cancel]
#--------------------------------------------------------------------------
alias r2_on_enemy_cancel_group_enemy on_enemy_cancel
def on_enemy_cancel
@enemy_select_window.hide
r2_on_enemy_cancel_group_enemy
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
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.
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.
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.
readme.txt
RPG MAKER DS+ Resource Pack
2013.09.06
readme.txt
Ancient Dungeons: Base Pack
2015.12.22
RPG MAKER DS+ Resource Pack
2013.09.06
readme.txt
Ancient Dungeons: Base Pack
2015.12.22
So are you saying you have those?
So, I'm testing the demo You sent me and it works fine.
Did you fix it yourself?
Did you fix it yourself?
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.
Found the issue. It was basically a typo. The script above is updated.
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?
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.
Yes the May 19th post. I edited it.