The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: modern algebra on May 29, 2009, 03:21:09 AM

Title: Target-All Weapon Elements
Post by: modern algebra on May 29, 2009, 03:21:09 AM
Target-All Weapon Elements
Version: 1.0
Author: modern algebra
Date: May 29, 2009

Version History



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


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg11.imageshack.us%2Fimg11%2F6849%2Ftargetallscreen.png&hash=6309ed13a3ac97226e8ef3673242d9fc87636af8)

Instructions

Place above Main and below other default scripts

Please see the header of the script for setup details

Script


Code: [Select]
#==============================================================================
#  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



Thanks


Support


Please post in this topic for the swiftest response

Known Compatibility Issues

Obviously won't work with exotic battle systems