Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Weapons that attack all enemies

Hello everyone. I was wondering if there was a way, either by events or through scripting, to be able to set a weapon (or specific character)'s attack to hit every enemy. I've tried the search function in these forums, and the results are far too broad to be able to find any help without browsing through endless pages of results.

The help would be much appreciated.
 
Hmmm... Try this:

Code:
#==============================================================================

# ** Weapon Scopes: Attack All

#------------------------------------------------------------------------------

# SephirothSpawn

# Version 1.0

# 2010-02-25

#==============================================================================

 

module WeaponScopes

  # weapon_id, ...

  Attack_All_Weapons = []

end

 

class Scene_Battle

  alias_method :seph_weaponscopesallenemies_ses, :start_enemy_select

  def start_enemy_select

    if @active_battler.current_action.kind == 0 && @active_battler.current_action.basic == 0

      if WeaponScopes::Attack_All_Weapons.include?(@active_battler.weapon_id)

        phase3_next_actor

        return

      end

    end

    seph_weaponscopesallenemies_ses

  end

  alias_method :seph_weaponscopesallenemies_mbar, :make_basic_action_result

  def make_basic_action_result

    if @active_battler.current_action.basic == 0 && @active_battler.is_a?(Game_Actor) && WeaponScopes::Attack_All_Weapons.include?(@active_battler.weapon_id)

      @animation1_id = @active_battler.animation1_id

      @animation2_id = @active_battler.animation2_id

      @target_battlers = []

      for enemy in $game_troop.enemies

        @target_battlers << enemy if enemy.exist?

      end

      for target in @target_battlers

        target.attack_effect(@active_battler)

      end

      return

    end

    seph_weaponscopesallenemies_mbar

  end

end

That should do the trick. Just change the line below with all weapons that attack all enemies:
Attack_All_Weapons = []

For example, if weapons 2, 3, 6, 7 & 12 all attack all enemies:
Attack_All_Weapons = [2, 3, 6, 7, 12]
 
Try this:

Code:
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

# ** Glitchfinder and theory's Target All Enemies DBS Addon      [RPG Maker XP]

#    Version 1.00

#------------------------------------------------------------------------------

#  This add-on enables Target All type weapons.

#==============================================================================

# * Version History

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#   Version 1.00 ------------------------------------------------- (2009-05-29)

#     - Initial version

#     - Authors: theory and Glitchfinder

#==============================================================================

# * Instructions

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Place this script above Main, and below the default scripts. (I realize this

#  is obvious to most, but some people don't get it.)

#

#  To use this script, simply create an element named "Target All" (without the

#  quotes), and add it to the weapons that you want to use this feature.

#==============================================================================

# *Glitchfinder's Advice

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  This script is plug 'n play. Simply insert in the proper location, and

#  any weapon that has a specifically named element will target all enemies.

#==============================================================================

# * Contact

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  Glitchfinder, the author of this script, may be contacted through his

#  website, found at [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#

#  You may also find Glitchfinder at [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#==============================================================================

# * Usage

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#  This script may be used with the following terms and conditions:

#

#    1. This script is free to use in any noncommercial project. If you wish to

#       use this script in a commercial (paid) project, please contact

#       Glitchfinder at his website.

#    2. This script may only be hosted at the following domains:

#         [url=http://www.glitchkey.com]http://www.glitchkey.com[/url]

#         [url=http://www.hbgames.org]http://www.hbgames.org[/url]

#    3. If you wish to host this script elsewhere, please contact Glitchfinder.

#    4. If you wish to translate this script, please contact Glitchfinder. He

#       will need the web address that you plan to host the script at, as well

#       as the language this script is being translated to.

#    5. This header must remain intact at all times.

#    6. Glitchfinder remains the sole owner of this code. He may modify or

#       revoke this license at any time, for any reason.

#    7. Any code derived from code within this script is owned by Glitchfinder,

#       and you must have his permission to publish, host, or distribute his

#       code.

#    8. This license applies to all code derived from the code within this

#       script.

#    9. If you use this script within your project, you must include visible

#       credit to Glitchfinder and theory, within reason.

#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

 

#==============================================================================

# ** Scene_Battle

#------------------------------------------------------------------------------

#  This class performs battle screen processing.

#==============================================================================

class Scene_Battle

  #--------------------------------------------------------------------------

  # * Alias Methods

  #--------------------------------------------------------------------------

  alias targetall_enemy_select start_enemy_select

  alias targetall_action make_basic_action_result

  #--------------------------------------------------------------------------

  # * Start Enemy Selection

  #--------------------------------------------------------------------------

  def start_enemy_select

    # Call original method

    targetall_enemy_select

    # Get current weapon's elements

    element_set = $data_weapons[@active_battler.weapon_id].element_set

    # Set up element name array

    element_names = []

    # Add the current weapon's element names to the element name array

    for i in element_set

      element_names.push($data_system.elements[i.to_s.to_i])

    end

    # If the current weapon targets all

    if element_names.include?('Target All')

      # End enemy selection

      end_enemy_select

      # Set action

      @active_battler.current_action.basic = 128

      # Go to command input for next actor

      phase3_next_actor

    end

  end

  #--------------------------------------------------------------------------

  # * Make Basic Action Result

  #--------------------------------------------------------------------------

  def make_basic_action_result

    # If the current actor's weapon does not target all

    if @active_battler.current_action.basic != 128

      # Call the original method

      targetall_action

    else

      # Set animation ID

      @animation1_id = @active_battler.animation1_id

      @animation2_id = @active_battler.animation2_id

      # check restrictions and set targets

      @target_battlers = []

      # If attacking allies

      if @active_battler.restriction == 3

        # Attack all allies

        set_target_battlers(4)

      # If attacking enemies

      else

        # Attack all enemies

        set_target_battlers(2)

      end

      # Apply normal attack results

      for target in @target_battlers

        target.attack_effect(@active_battler)

      end

    end

  end

end

theory and I made it on request a while back, and it's fairly simple to use. If you can't figure out how to get it to work from the posted script, look at the link above. The instructions are in the header.

The sad thing is that I've had this script linked in my signature for a while now.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top