RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

Target-All Weapon Elements

Started by modern algebra, May 29, 2009, 03:21:09 AM

0 Members and 1 Guest are viewing this topic.

modern algebra

Target-All Weapon Elements
Version: 1.0
Author: modern algebra
Date: May 29, 2009

Version History




  • <Version 1.0> 05.29.2009 - Original Release

Description



This script allows you to assign a target-all property to weapons that makes those weapons target all opponents. It can also be set as a property to enemies.

Features


  • Allows you to make weapons that target all enemies
  • Allows you to make enemies whose regular attack targets all actors
  • Can set multiple elements to have the target-all property
  • Easy element configuration

Screenshots



Instructions

Place above Main and below other default scripts

Please see the header of the script for setup details

Script



#==============================================================================
#  Target-All Weapon Element
#  Version 1.0
#  Author: modern algebra
#  Date: May 29, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#  
#    This script allows you to assign a target-all property to weapons that
#   makes those weapons target all opponents. It can also be set as a property
#   to enemies.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below all other default scripts.
#
#    To set the IDs of what elements grant this property to weapons, go down to
#   line 35 and alter the array to include the IDs of the elements that you
#   want to grant the target-all property. Thus:
#
#     MA_TARGETALL_ELEMENTS = [12, 13, 17]
#
#   means that weapons with elements 12, 13, or 17 will target all opponents.
#
#    For weapons to have this property, merely give them one of the elements
#   you set in that array. For enemies to be given this property, just change
#   any of those element ranks to something other than C and their attack will
#   target all.
#==============================================================================

#==============================================================================
# ** Global Constant
#==============================================================================

MA_TARGETALL_ELEMENTS = [17]

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - ma_weapon_target_all?
#==============================================================================

class Game_Actor
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Weapon Target All?
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def ma_weapon_target_all?
   weapon = $data_weapons[@weapon_id]
   # If no weapon, return false
   return false if weapon == nil
   # Return true if
   MA_TARGETALL_ELEMENTS.each { |element_id|
     return true if weapon.element_set.include? (element_id)
   }
   return false
 end
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - ma_weapon_target_all?
#    aliased method - element_rate
#==============================================================================

class Game_Enemy
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Element Rate
 #    element_id : the ID of the element being checked
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias maga_targtallelmnt_elmntrate_74b5 element_rate
 def element_rate (element_id, *args)
   # Nullify Target-All element bonuses
   return 100 if MA_TARGETALL_ELEMENTS.include? (element_id)
   # Run Original Method
   return maga_targtallelmnt_elmntrate_74b5 (element_id, *args)
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Weapon Target All?
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 def ma_weapon_target_all?
   # CHeck Element Ranks
   MA_TARGETALL_ELEMENTS.each { |element_id|
     # If not C, return true
     return true if element_rate (element_id) != 100
   }
   return false
 end
end

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - start_enemy_select
#==============================================================================

class Scene_Battle
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Start Enemy Select
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias modernalg_strt_emy_slct_trgtall_84b56 start_enemy_select
 def start_enemy_select (*args)
   if @active_battler.current_action.kind == 0 &&
         @active_battler.current_action.basic == 0 &&
         @active_battler.ma_weapon_target_all?
     phase3_next_actor
     return
   end
   # Run Original Method
   modernalg_strt_emy_slct_trgtall_84b56 (*args)
 end
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # * Make Basic Action Results
 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 alias mdrnalgbra_mkbsc_actrslt_trgtall_73b5 make_basic_action_result
 def make_basic_action_result (*args)
   # Run Original Method
   mdrnalgbra_mkbsc_actrslt_trgtall_73b5 (*args)
   # If attack
   if @active_battler.current_action.basic == 0 && @active_battler.ma_weapon_target_all?
     targets = []
     # If action battler is enemy
     if @active_battler.is_a?(Game_Enemy)
       for actor in $game_party.actors
         targets.push (actor) if actor.exist?
       end
     end
     # If action battler is actor
     if @active_battler.is_a?(Game_Actor)
       for enemy in $game_troop.enemies
         targets.push (enemy) if enemy.exist?
       end
     end
     # Set array of targeted battlers
     targets.each { |target|
       next if @target_battlers.include? (target)
       target.attack_effect(@active_battler)
     }
     # Get the intersection of actors
     @target_battlers |= targets
   end
 end
end


Credit




  • modern algebra

Thanks


  • GreenBanana, for the request

Support



Please post in this topic for the swiftest response

Known Compatibility Issues

Obviously won't work with exotic battle systems