12-03-2023, 03:41 AM (This post was last modified: 12-03-2023, 03:44 AM by DerVVulfman.)
Weapons Blocked from Attacks Version: 1.0
Introduction
This script disables the "ATTACK" menu option in the default battlesystem if the actor is equipped with a defined weapon. This may be useful if the weapon equipped is not meant for melee attack, but for some skill action in its place (a magic staff for example).
Just populate the LIST array within the BlockedWeapons module with the IDs of weapons that should not be allowed to make melee attacks.
Screenshots
All you'd see is that the "ATTACK" text in the Actor Command Window going Gray. Big Whoop.
Script
The Script
Code:
#==============================================================================
# ** Weapons Blocked from Attacks
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.0
# 12-02-2023
# RGSS / RMXP
#------------------------------------------------------------------------------
# This script disables the "ATTACK" menu option in the default battlesystem
# if the actor is equipped with a defined weapon. This may be useful if the
# weapon equipped is not meant for melee attack, but for some skill action
# in its place (a magic staff for example).
#
# Just populate the LIST array within the BlockedWeapons module with the IDs
# of weapons that should not be allowed to make melee attacks.
#------------------------------------------------------------------------------
#
# TERMS OF USE
# ===================
#
# Free for use, even in commercial products. Only due credit is needed.
#
#==============================================================================
module BlockedWeapons
LIST = [1]
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :m_slot_detected # MultiSlots Detection
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias system_blocked_weapon_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Perform the original method
system_blocked_weapon_initialize
# Add new values for the auto-detection feature
@m_slot_detected = nil
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias actor_blocked_weapon_setup setup
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
# Perform the original method
actor_blocked_weapon_setup(actor_id)
# Set auto-detection flag within Game_System if a MultiSlots method found
$game_system.m_slot_detected = true if defined?(custom_slot_names)
end
end
#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Enable Item
# index : item number
#--------------------------------------------------------------------------
def enable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
alias battle_blocked_weapon_p3scw phase3_setup_command_window
alias battle_blocked_weapon_up3bc update_phase3_basic_command
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
def phase3_setup_command_window
# Perform the original method
battle_blocked_weapon_p3scw
# Ensure Attack is enabled when drawn/redrawn
@actor_command_window.enable_item(0)
# Deactivate menu option appearance if using a no-attack weapon
@actor_command_window.disable_item(0) if phase3_no_attack_weapon?
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : basic command)
#--------------------------------------------------------------------------
def update_phase3_basic_command
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by actor command window cursor position
if @actor_command_window.index == 0
# Play Buzzer and exit if using a no-attack weapon
if phase3_no_attack_weapon?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
# Perform the original method
battle_blocked_weapon_up3bc
end
#--------------------------------------------------------------------------
# * Frame Update (Testing if hero using a no attack weapon)
#--------------------------------------------------------------------------
def phase3_no_attack_weapon?
if $game_system.m_slot_detected == true
for weapon in @active_battler.weapons
return true if BlockedWeapons::LIST.include?(weapon)
end
return false
end
return true if BlockedWeapons::LIST.include?(@active_battler.weapon_id)
end
end
Instructions
Paste below Scene_Debug and above Main. If using a custom battlesystem and/or MultiSlots!, then paste below those as well. Fill in the LIST array with IDs of weapons not allowing your hero to perform melee attacks.
Compatibility
Should be compatible with the default RPG combat system for RPGMaker XP. It attaches code to the method that reveals the combat window and to the method permitting action selection. Most anything else is either new or attached code.
Terms and Conditions
Free for use, even in commercial products. Only due credit is needed.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)