Help - Search - Members - Calendar
Full Version: Cannot target enemy until conditions met
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Tsukihime
I have a boss fight where 2 power generators supply energy to some shield that renders the boss immune to any attack.
To make it more intuitive I don't want players to be allowed to target him at all until the two machines are destroyed. So if you scroll through the enemy party it's like he's not even there. But he still attacks you.

How can I achieve this?
Night_Runner
Have a go at this script:

Night_Runner's Protected Enemies Script
CODE
#==============================================================================
# ** Night_Runner's Protected Enemies Script.
#-----------------------------------------------------------------------------
# History:
#  Date Created: 14/Oct/2011
#  Created for: Tkukihime
#   @> http://www.rpgrevolution.com/forums/index.php?showtopic=53444
#
# Description:
#  This script is designed to have enemies that cannot be selected until
#  the rest of their group have been knocked out.
#
# How to Install:
#  Highlight and copy this entire script. In your game editor, select
#  Tools >> Script Editor.
#  Along the left, scroll all the way to the bottom, right click on
#  'Main', select 'Insert', and paste the code on the blank window
#  on the right.
#
# How to Use:
#  Once the script is installed, tweak the customisation below (line 35)
#   so you can have more or less enemeis in the list.
#
#==============================================================================



#==============================================================================
# ** Customisation
#==============================================================================

module NR_LastBattleable_Enemies
  # Ghosts, Basilisks and Sahagin's are default list of the last selectable
  # battlers
  List = [1, 2, 3]
end


#==============================================================================
# ** Arrow_Enemy
#------------------------------------------------------------------------------
#  Edited to skip anemes as specified by the list above.
#==============================================================================

class Arrow_Enemy
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_unselectableEnemies_update  update  unless $@
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update(*args)
    # Run the original code
    nr_unselectableEnemies_update(*args)
    # Get the last enemy list
    en_list = NR_LastBattleable_Enemies::List
    # If the enemy highlighted is one of the last ones
    if en_list.include?(self.enemy.id)
      # Keep track of the original index
      starting_index = @index
      # Loop through for every enemy
      $game_troop.enemies.size.times do
        # Start with the next enemy
        @index += 1
        @index %= $game_troop.enemies.size
        # If this is a normal enemy
        if self.enemy.exist? and not en_list.include?(self.enemy.id)
          # Set sprite coordinates
          if self.enemy != nil
            self.x = self.enemy.screen_x
            self.y = self.enemy.screen_y
          end
          # Stop processing
          return
        end
      end
      # If there was no other enemies
      @index = starting_index
    end
  end
end



#==============================================================================
# ** End fo Script.
#==============================================================================


I was thinking of adding a few extra options, for example enemies that are only selectable when a variable or switch condition is met, or if a state has been included, or if there's only a certain number of enemies left, but I thought it would be getting to difficult to understand by that stage smile.gif
Tsukihime
It works great smile.gif

If you can add those options that would make it really flexible.

In the case of the power generators, you could define a state called "disabled" and during that time the invulnerability would be gone and so you could target the boss.

Of course, once they recover from that state you won't be able to target him again.
To make such a battle more complicated, I could make the generators immortal, and some player would have to disable them again and again just to beat the boss.

On top of that, is it possible to make it so that you simply cannot select any enemies and must defend?
Like in old final fantasy games you have a dragoon that jumps into the air and you can't target him until he comes back down, even if he's the last guy.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.