|
  |
Attacking Allies (solved), Is it possible? |
|
|
|
|
Feb 13 2012, 11:35 AM
|

Atrius

Group: Revolutionary
Posts: 144
Type: Musician
RM Skill: Advanced

|
I was wondering if it was possible to allow/modify the attack command (using RMXP's default battle system) to allow targeting allies rather than just enemies. I need this for one particular fight only, and I would like to apply it only to one battle. This is extremely crucial for my game, please help!  It would be extremely beneficial if I could also make harmful spells target allies for this one particular fight as well, but that's not necessary.
This post has been edited by LostSamurai: Feb 22 2012, 06:48 PM
__________________________
|
|
|
|
|
|
|
|
|
Feb 14 2012, 12:24 AM
|

Dark Jentleman

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120

|
Urgh! Xcuse me, but this sounds... terrible. In my opinion, you should keep this setting active, it's the player choosing what to do. If he/she is dumb enough to attack their allies when not needed, well, it would not be your fault. You provide the mechanics, how to use them is to the player  Ok, then. Wait four days and I'll script it. Jens
__________________________
|
|
|
|
|
|
|
|
|
Feb 17 2012, 01:44 AM
|

Dark Jentleman

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120

|
QUOTE (TheCableGuy @ Feb 17 2012, 04:12 AM)  If it's only for one battle, sounds like you could do better with an Event. Make a Doppelganger Enemy and have the event switch out your Ally for the enemy.
Of course, I reckon it might depend on how you want the Fight to occur, but that's the first thing I thought of. I'm sorry, but it think this could be tremendously inefficient, since events are not so easy to manage in RMXP battle system. Moreover, if I understood correctly, you should be able to attak even enemies, not only allies in that battle. @LostSamurai Tell me if the script linked by Vexus works properly for you. If the answer is "No, it doesn't" I'll script it, if the answer is "Yes, it works in a perfect way" I'll consider this request solved. Jens
This post has been edited by Jens of Zanicuud: Feb 17 2012, 01:45 AM
__________________________
|
|
|
|
|
|
|
|
|
Feb 17 2012, 01:27 PM
|

Dark Jentleman

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120

|
This should let you to attack your allies. Beware this script could be not compatible with a custom battle script. Paste this above main. CODE #============================================================================== #=#============================================================================ # #** Jens of Zanicuud target script v 1.0 # # -free use, just credit # # -free customization, however, posting on RRR the modified version is # # mandatory # # -you can find me on www.rpgrevolution.com #=#============================================================================ #==============================================================================
#============================================================================== # ** Arrow_All #------------------------------------------------------------------------------ # This arrow cursor is used to choose targets. This class inherits from the # Arrow_Base class. #==============================================================================
class Arrow_All < Arrow_Base def initialize(viewport,for_actors) @for_actors = for_actors if for_actors @troop = $game_party.actors + $game_troop.enemies else @troop = $game_troop.enemies + $game_party.actors end super(viewport) end #-------------------------------------------------------------------------- # * Get Enemy Indicated by Cursor #-------------------------------------------------------------------------- def target return @troop[@index] end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # Skip if indicating a nonexistant target @troop.size.times do break if self.target.exist? @index += 1 @index %= @troop.size end # Cursor right if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) @troop.size.times do @index += 1 @index %= @troop.size break if self.target.exist? end end # Cursor left if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) @troop.size.times do @index += @troop.size - 1 @index %= @troop.size break if self.target.exist? end end # Set sprite coordinates if self.target != nil self.x = self.target.screen_x self.y = self.target.screen_y end end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help # Display enemy name and state in the help window if self.target.is_a?(Game_Enemy) @help_window.set_enemy(self.target) else @help_window.set_actor(self.target) end end end
#============================================================================== # ** Scene_Battle #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # * Start Actor Selection #-------------------------------------------------------------------------- def start_actor_select # Make actor arrow @actor_arrow = Arrow_All.new(@spriteset.viewport2,true) @actor_arrow.index = @actor_index # Associate help window @actor_arrow.help_window = @help_window # Disable actor command window @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # * Start Enemy Selection #-------------------------------------------------------------------------- def start_enemy_select # Make enemy arrow @enemy_arrow = Arrow_All.new(@spriteset.viewport2,false) # Associate help window @enemy_arrow.help_window = @help_window # Disable actor command window @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # * Set target for skills & items #-------------------------------------------------------------------------- def set_target_battlers(scope) # If battler performing action is enemy if @active_battler.is_a?(Game_Enemy) # Branch by effect scope case scope when 1 # single enemy index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # all enemies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3 # single ally index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # all allies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # single ally (HP 0) index = @active_battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end when 6 # all allies (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7 # user @target_battlers.push(@active_battler) end end # If battler performing action is actor if @active_battler.is_a?(Game_Actor) case scope when 1 # single enemy index = @active_battler.current_action.target_index if index < $game_troop.enemies.size @target_battlers.push($game_troop.smooth_target_enemy(index)) else @target_battlers.push($game_party.smooth_target_actor(index-$game_troop.enemies.size)) end when 2 # all enemies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 #fellow actor index = @active_battler.current_action.target_index if index > $game_party.actors.size-1 @target_battlers.push($game_troop.smooth_target_enemy(index-$game_party.actors.size)) else @target_battlers.push($game_party.smooth_target_actor(index)) end when 4 # all allies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 5 # fellow (HP 0) index = @active_battler.current_action.target_index if index>$game_party.actors.size-1 enemy = $game_troop.enemies[index-$game_party.actors.size] if enemy != nil @target_battlers.push(enemy) end else actor = $game_party.actors[index] if actor != nil @target_battlers.push(actor) end end when 6 # all allies (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end end when 7 # self @target_battlers.push(@active_battler) end end end #-------------------------------------------------------------------------- # * Make Basic Action Results #-------------------------------------------------------------------------- def make_basic_action_result # If attack if @active_battler.current_action.basic == 0 # Set anaimation ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # If action battler is enemy if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # If action battler is actor if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index
if index < $game_troop.enemies.size target = $game_troop.smooth_target_enemy(index) else target = $game_party.smooth_target_actor(index-$game_troop.enemies.size) end end end # Set array of targeted battlers @target_battlers = [target] # Apply normal attack results for target in @target_battlers target.attack_effect(@active_battler) end return end # If guard if @active_battler.current_action.basic == 1 # Display "Guard" in help window @help_window.set_text($data_system.words.guard, 1) return end # If escape if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # Display "Escape" in help window @help_window.set_text("Escape", 1) # Escape @active_battler.escape return end # If doing nothing if @active_battler.current_action.basic == 3 # Clear battler being forced into action $game_temp.forcing_battler = nil # Shift to step 1 @phase4_step = 1 return end end end BTW, rigene script is ready&working. Check the other topic's last post... Ask for troubleshooting anytime. I hope this can help... Jens
__________________________
|
|
|
|
|
|
|
|
|
Feb 18 2012, 09:06 PM
|

Level 4

Group: Member
Posts: 58
Type: Mapper
RM Skill: Beginner

|
QUOTE (Jens of Zanicuud @ Feb 17 2012, 02:44 AM)  I'm sorry, but it think this could be tremendously inefficient, since events are not so easy to manage in RMXP battle system. Moreover, if I understood correctly, you should be able to attak even enemies, not only allies in that battle. Understood. I'm not really a Scripter so that's outside my range. I've just been working with events lot so that's the limit of my knowledge. It was just a suggestion but maybe I should of kept it to myself.
|
|
|
|
|
|
|
|
|
Feb 19 2012, 10:09 AM
|

Atrius

Group: Revolutionary
Posts: 144
Type: Musician
RM Skill: Advanced

|
QUOTE It was just a suggestion but maybe I should of kept it to myself. Don't be silly! Suggestions are always welcome and appreciated. Sometimes they are just not what's needed at the time. But there's always multiple ways to solve a problem. I originally used events to pseudo-solve this problem, but it was very sloppy. The script made everything much... cleaner.
__________________________
|
|
|
|
|
|
|
|
|
Feb 22 2012, 12:55 PM
|

Dark Jentleman

Group: Local Mod
Posts: 904
Type: Scripter
RM Skill: Skilled
Rev Points: 120

|
Try replacing my old script with this: CODE #============================================================================== #=#============================================================================ # #** Jens of Zanicuud target script v 1.1 # # -free use, just credit # # -free customization, however, posting on RRR the modified version is # # mandatory # # -you can find me on www.rpgrevolution.com #=#============================================================================ #==============================================================================
#============================================================================== # ** Arrow_All #------------------------------------------------------------------------------ # This arrow cursor is used to choose targets. This class inherits from the # Arrow_Base class. #==============================================================================
class Arrow_All < Arrow_Base def initialize(viewport,for_actors) @for_actors = for_actors if for_actors @troop = $game_party.actors + $game_troop.enemies else @troop = $game_troop.enemies + $game_party.actors end super(viewport) end #-------------------------------------------------------------------------- # * Get Enemy Indicated by Cursor #-------------------------------------------------------------------------- def target return @troop[@index] end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # Skip if indicating a nonexistant target @troop.size.times do if (self.target.exist? or self.target.is_a?(Game_Actor)) break end @index += 1 @index %= @troop.size end # Cursor right if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) @troop.size.times do @index += 1 @index %= @troop.size if (self.target.exist? or self.target.is_a?(Game_Actor)) break end end end # Cursor left if Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) @troop.size.times do @index += @troop.size - 1 @index %= @troop.size if (self.target.exist? or self.target.is_a?(Game_Actor)) break end end end # Set sprite coordinates if self.target != nil self.x = self.target.screen_x self.y = self.target.screen_y end end #-------------------------------------------------------------------------- # * Help Text Update #-------------------------------------------------------------------------- def update_help # Display enemy name and state in the help window if self.target.is_a?(Game_Enemy) @help_window.set_enemy(self.target) else @help_window.set_actor(self.target) end end end
#============================================================================== # ** Scene_Battle #============================================================================== class Scene_Battle attr_reader :active_battler #-------------------------------------------------------------------------- # * Start Actor Selection #-------------------------------------------------------------------------- def start_actor_select # Make actor arrow @actor_arrow = Arrow_All.new(@spriteset.viewport2,true) @actor_arrow.index = @actor_index # Associate help window @actor_arrow.help_window = @help_window # Disable actor command window @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # * Start Enemy Selection #-------------------------------------------------------------------------- def start_enemy_select # Make enemy arrow @enemy_arrow = Arrow_All.new(@spriteset.viewport2,false) # Associate help window @enemy_arrow.help_window = @help_window # Disable actor command window @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # * Set target for skills & items #-------------------------------------------------------------------------- def set_target_battlers(scope) # If battler performing action is enemy if @active_battler.is_a?(Game_Enemy) # Branch by effect scope case scope when 1 # single enemy index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # all enemies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3 # single ally index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # all allies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # single ally (HP 0) index = @active_battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end when 6 # all allies (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7 # user @target_battlers.push(@active_battler) end end # If battler performing action is actor if @active_battler.is_a?(Game_Actor) case scope when 1 # single enemy index = @active_battler.current_action.target_index if index < $game_troop.enemies.size @target_battlers.push($game_troop.smooth_target_enemy(index)) else @target_battlers.push($game_party.smooth_target_actor(index-$game_troop.enemies.size)) end when 2 # all enemies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 #fellow actor index = @active_battler.current_action.target_index if index > $game_party.actors.size-1 @target_battlers.push($game_troop.smooth_target_enemy(index-$game_party.actors.size)) else @target_battlers.push($game_party.smooth_target_actor(index)) end when 4 # all allies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 5 # fellow (HP 0) index = @active_battler.current_action.target_index if index>$game_party.actors.size-1 enemy = $game_troop.enemies[index-$game_party.actors.size] if enemy != nil @target_battlers.push(enemy) end else actor = $game_party.actors[index] if actor != nil @target_battlers.push(actor) end end when 6 # all allies (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end end when 7 # self @target_battlers.push(@active_battler) end end end #-------------------------------------------------------------------------- # * Make Basic Action Results #-------------------------------------------------------------------------- def make_basic_action_result # If attack if @active_battler.current_action.basic == 0 # Set anaimation ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # If action battler is enemy if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # If action battler is actor if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index
if index < $game_troop.enemies.size target = $game_troop.smooth_target_enemy(index) else target = $game_party.smooth_target_actor(index-$game_troop.enemies.size) end end end # Set array of targeted battlers @target_battlers = [target] # Apply normal attack results for target in @target_battlers target.attack_effect(@active_battler) end return end # If guard if @active_battler.current_action.basic == 1 # Display "Guard" in help window @help_window.set_text($data_system.words.guard, 1) return end # If escape if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # Display "Escape" in help window @help_window.set_text("Escape", 1) # Escape @active_battler.escape return end # If doing nothing if @active_battler.current_action.basic == 3 # Clear battler being forced into action $game_temp.forcing_battler = nil # Shift to step 1 @phase4_step = 1 return end end end This should work, though I'm not certain at 100%. I hope this can help... Jens
This post has been edited by Jens of Zanicuud: Feb 22 2012, 01:00 PM
__________________________
|
|
|
|
|
|
|
|
  |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RPG RPG Revolution is an Privacy
Policy and Legal
|
|