Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Rajaat99

Change equipment during battle

Recommended Posts

First, this script is not mine. It took me awhile to find and I thought others might get some use out of it, so I'm sharing.

The instructions state to place it below your custom fighting system, but that caused bugs for me. I placed it above and it works fine.

 

 

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

# ** Eladia's Battle Equipment Menu v. 1.2 (04-11-2007)

# by DerVVulfman

#

# Based on "While Fighting Equipment" version 1.00

# by 'an unknown Japanese scripter'

# original code found at a RMXP Wiki site by Landarma

#

# Additional code:

# Modified version of XRXS's Window Module and edited code exerpts used in

# order to multi-platform with other battlesystems.

#

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

#

# ORIGINAL INTRODUCTION (Translated from Japanese:

#

# This system allows the battler to change their designated equipment while in

# combat. It adds an equipment script, and places the equipment command into

# your actor command window.

#

# This system uses a default equipment menu and hasn't modified the display.

# It is a blank slate for you to modify.

#

# In other words, modifying the equipment windows will be the next step in

# your project. It has been left for you to work that problem out.

#

# It is merely a rewrite of Scene_Equip's system...

#

# Furthermore, the battlesystem's Item or Skill window is now the window that

# will hold/display the equipment you can use or remove.

#

# The modification of the window design is the basic technology of RGSS, which

# must be learned before you attempt to perform any edits.

#

# Basic Equipment scripts in use:

# * Window_EquipLeft

# * Window_EquipRight

# * Window_EquipItem

#

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

#

# INTRODUCTION:

#

# Greetings!

#

# This script, like you must know by now, allows you to change your equipment

# while in combat. Originally designed for the default battle system, it has

# now been modified to permit it's use in a number of battlesystems.

#

# Unlike its predecessor, no modifiecation to Custom Battlesystems's def main

# is necessary to insert the 'Equip' command. Through the use of XRSX's won-

# derful Command Window Add-on, the option has been added by 'ALIAS'ing it to

# the battlesystem. In fact, the only def in the entire Scene_Battle that had

# to be re-written (and not aliased) is 'update_phase3', which is primarily a

# universal def that allows the equipment menu to be turned on.

#

# The Equipment menu, when used, appears like the default menu system, with

# the exception of not seeing the possible changes in your stats until you

# activly change your equipment. The original Japanese version didn't even

# have the left 'stat' window. I will leave it to you to modify the appearance

# or behavior of this window.

#

# NOTE: The equipment menu is set to full opacity so as to hide battlers and

# certain forms of AT bar sprites in certain battlesystems. The 'Z-Depth' was

# increased by '700' in order to accomplish this. Without this, the appearance

# of various forms of sprites could distract or obscure the menu.

#

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

#

# INSTRUCTIONS:

#

# This script is about as plug & play as they come. Unless some form of con-

# flict occurs, you merely paste this script below your Custom Battle System

# for it to work, or just paste it above 'MAIN' if you are using the default

# battle system.

#

# It aliases nearly every statement necessary for it to work, other than the

# 'def update_phase3' as stated earlier, so you want it below your custom bat-

# tlesystem.

#

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

#

# REGARDING XRXS's #65 BATTLESYSTEM:

#

# Both this, and XRXS's script adds an additional command into the actor com-

# mand window. XRXS's system adds the "ESCAPE" command, and this one adds the

# "EQUIP" command. Normally, you would paste this script below the any custom

# battlesystem, but this would leave the 'EQUIP' option to be shown below the

# 'ESCAPE' option. This script can be placed 'ABOVE' XRXS's system to reverse

# this and have 'ESCAPE' be the bottommost option.

#

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

#

# REGARDING LAURA'S ESCAPE BAR REMOVAL SCRIPTS (RTAB & DBS):

# This system is compatible with said system. Both IT and this system uses

# a modified version of XRXS's Window Module, and the placement of the scripts

# influences the options position. If this script is placed 'BELOW' Laura's

# script, then the 'Equip' option will be below the 'Escape' option... and

# visa versa.

#

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

#

# COMPATABILITY:

#

# Originally, this system was designed for the 'default' battlesystem. It is

# now able to support the following systems:

#

# Agility Based Battle - Syvkal (an XRXS edit)

# The default system - Yoji Ojima / Enterbrain, Inc.

# ParaDog's CTB v 2.58 - ParaDog

# RTAB - Cogwheel

# SoulRage - Blizzard

# XRXS #65 & 65a addon - by XRXS

#

# Currently incompatible with the Action Cost CBS by Fomar0153, yet...

#

# Currently not compatible with Trickster's Conditional CTB, or his Active

# Timer Battle system. It would probably need a SDK 2.0 makeover.

#

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

 

# Command Window size controls

$command_height = 160 # Sets how many options are visible (nil auto-resizes)

$command_y_pos = 160 # Sets the height position (160 is default, nil is auto)

 

# Disable/Enable slot control (1 allows, 0 disallows)

# Syntax = actor.id => [weapon, shield, armor, helmet, accessory ], ...

$ebem_slot = { 1 => [ 1, 0, 1, 1, 1],

7 => [ 0, 1, 1, 1, 1],

8 => [ 1, 0, 0, 0, 0] }

 

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

# ** Scene_Battle

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

# This class performs battle screen processing.

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

 

class Scene_Battle

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

# * Add Equip

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

alias ebem_sp1 start_phase1

def start_phase1

# Original Call

ebem_sp1

# Get index of Equip Command

@equip_actor_command_index = @actor_command_window.height / 32 - 1

# Add the Equip Command

@actor_command_window.add_command($data_system.words.equip)

end

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

# * Frame Update (actor command phase)

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

def update_phase3

# Allow for RTAB system

if $r_detected

if victory? and @command_a

command_delete

@command.push(@active_actor)

return

end

end

# If enemy arrow is enabled

if @enemy_arrow != nil

update_phase3_enemy_select

# If actor arrow is enabled

elsif @actor_arrow != nil

update_phase3_actor_select

# If skill window is enabled

elsif @skill_window != nil

update_phase3_skill_select

# If item window is enabled

elsif @item_window != nil

update_phase3_item_select

# If equip window is enabled

elsif @right_window != nil

update_phase3_equip_select

# If actor command window is enabled

elsif @actor_command_window.active

update_phase3_basic_command

end

end

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

# * Frame Update (actor command phase : basic command)

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

alias ebem_up3bc update_phase3_basic_command

def update_phase3_basic_command

# If C button was pressed

if Input.trigger?(Input::C)

# Branch by actor command window cursor position

case @actor_command_window.index

when @equip_actor_command_index # Equip

# Play decision SE

$game_system.se_play($data_system.decision_se)

# Start equip selection

start_equip_select

end

end

# Original Call

ebem_up3bc

end

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

# * Frame Update (actor command phase : equip selection)

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

def update_phase3_equip_select

ebem_array = []

# Allow for RTAB system

if $r_detected

battler = @active_actor

else

battler = @active_battler

end

# Enable equip window

@right_window.visible = true

# Update Equip selection Windows

@right_window.update

if @right_window.index != @now_right_window

@now_right_window =@right_window.index

if @equip_item_window.index == -1

@equip_item_window.index = 0

@equip_item_window.refresh

@equip_item_window.index = -1

end

end

# Update windows

@equip_item_window.update

equip_item_window_select

# If equip_item window is active: call update_phase3_equip_i_select

if @equip_item_window.active

update_phase3_equip_i_select

return

end

# If B button was pressed

if Input.trigger?(Input::B)

# Play cancel SE

$game_system.se_play($data_system.cancel_se)

# End equip selection

end_equip_select

return

end

# If C button was pressed

if Input.trigger?(Input::C)

# If equipment is fixed

if battler.equip_fix?(@right_window.index)

# Play buzzer SE

$game_system.se_play($data_system.buzzer_se)

return

end

# Obtain equipment slot information for actor (if any)

ebem_array = $ebem_slot[battler.id] if $ebem_slot.include?(battler.id)

# If equipment cannot be changed

if ebem_array[@right_window.index] == 0

# Play buzzer SE

$game_system.se_play($data_system.buzzer_se)

return

end

# Play decision SE

$game_system.se_play($data_system.decision_se)

# Activate item window

@right_window.active = false

@equip_item_window.active = true

@equip_item_window.index = 0

@now_right_window = -1

return

end

end

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

# * Frame Update (when equipment item window is active)

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

def update_phase3_equip_i_select

# Allow for RTAB system

if $r_detected

battler = @active_actor

else

battler = @active_battler

end

# If B button was pressed

if Input.trigger?(Input::B)

# Play cancel SE

$game_system.se_play($data_system.cancel_se)

@now_item_window = -1

# Activate right window

@right_window.active = true

@equip_item_window.active = false

@equip_item_window.index = -1

return

end

# If C button was pressed

if Input.trigger?(Input::C)

# Play equip SE

$game_system.se_play($data_system.equip_se)

# Get currently selected data on the equip window

item = @equip_item_window.item

# change battler equipment

battler.equip(@right_window.index, item == nil ? 0 : item.id)

# Activate right window

@right_window.active = true

@equip_item_window.active = false

@equip_item_window.index = -1

# Remake left window with new stats

@left_window.refresh

# Remake right window and item window contents

@right_window.refresh

@equip_item_window.refresh

return

end

end

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

# * Start Equipment Selection

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

def start_equip_select

# Allow for RTAB system

if $r_detected

battler = @active_actor

else

battler = @active_battler

end

# Hide Battlestatus Window

@status_window.visible = false

# Toggle the help window's transparency

@help_trans = @help_window.back_opacity

@help_window.back_opacity = 255

# Make windows

@left_window = Window_EquipLeft.new(battler)

@right_window = Window_EquipRight.new(battler)

@item_window1 = Window_EquipItem.new(battler, 0)

@item_window2 = Window_EquipItem.new(battler, 1)

@item_window3 = Window_EquipItem.new(battler, 2)

@item_window4 = Window_EquipItem.new(battler, 3)

@item_window5 = Window_EquipItem.new(battler, 4)

# Set new Z-Depth of windows

@left_window.z += 700

@right_window.z += 700

@item_window1.z += 700

@item_window2.z += 700

@item_window3.z += 700

@item_window4.z += 700

@item_window5.z += 700

# Associate help window

@right_window.help_window = @help_window

@item_window1.help_window = @help_window

@item_window2.help_window = @help_window

@item_window3.help_window = @help_window

@item_window4.help_window = @help_window

@item_window5.help_window = @help_window

@now_right_window = -1

@right_window.index = 0

equip_item_window_select

# Disable actor command window

@actor_command_window.active = false

@actor_command_window.visible = false

end

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

# * End Equipment Selection

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

def end_equip_select

# Reset z-depth of windows

@left_window.z -= 700

@right_window.z -= 700

@item_window1.z -= 700

@item_window2.z -= 700

@item_window3.z -= 700

@item_window4.z -= 700

@item_window5.z -= 700

# Return the help window's opacity

@help_window.back_opacity = @help_trans

# Dispose of windows

@left_window.dispose

@right_window.dispose

@item_window1.dispose

@item_window2.dispose

@item_window3.dispose

@item_window4.dispose

@item_window5.dispose

@right_window= nil

@item_window1= nil

@item_window2= nil

@item_window3= nil

@item_window4= nil

@item_window5= nil

# Hide help window

@help_window.visible = false

# Enable actor command window

@actor_command_window.active = true

@actor_command_window.visible = true

# Return Battlestatus Window

@status_window.visible = true

end

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

# * Refresh Equipment Selection

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

def equip_item_window_select

# Allow for RTAB system

if $r_detected

battler = @active_actor

else

battler = @active_battler

end

# Set item window to visible

@item_window1.visible = (@right_window.index == 0)

@item_window2.visible = (@right_window.index == 1)

@item_window3.visible = (@right_window.index == 2)

@item_window4.visible = (@right_window.index == 3)

@item_window5.visible = (@right_window.index == 4)

# Set current item window to @item_window

case @right_window.index

when 0

@equip_item_window = @item_window1

when 1

@equip_item_window = @item_window2

when 2

@equip_item_window = @item_window3

when 3

@equip_item_window = @item_window4

when 4

@equip_item_window = @item_window5

end

end

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

# * Action Wait Decision

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

def anime_wait_return

if $r_detected

if (@action_battlers.empty? or @anime_wait == false) and

not $game_system.battle_interpreter.running?

# If enemy arrow is enabled

if @enemy_arrow != nil

return [@active - 2, 0].min == 0

# If actor arrow is enabled

elsif @actor_arrow != nil

return [@active - 2, 0].min == 0

# If skill window is enabled

elsif @skill_window != nil

return [@active - 3, 0].min == 0

# If item window is enabled

elsif @item_window != nil

return [@active - 3, 0].min == 0

# If equipment window is enabled

# -- I used the same setting that pauses the actor command window -- smile.png

elsif @right_window != nil

return [@active - 1, 0].min == 0

# If actor command window is enabled

elsif @actor_command_window.active

return [@active - 1, 0].min == 0

else

return true

end

else

return false

end

end

end

end

 

 

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

# ** Spriteset_Battle

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

# This class brings together battle screen sprites. It's used within

# the Scene_Battle class.

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

 

class Spriteset_Battle

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

# * Object Initialization

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

alias equ_init initialize

def initialize

equ_init

# Determine if RTAB system in use

if @real_zoom != nil

$r_detected = true

end

end

end

 

 

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

# --- XRXS.Command Window Add-On Module ---

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

module XRXS_Window_Command

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

# * Add Command

# command : command text string being added

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

def add_command(command)

#

# Creates an empty @disabled array when first called.

#

@disabled = [] if @disabled.nil?

if @commands.size != @disabled.size

for i in 0...@commands.size

@disabled = false

end

end

#

# Add Command

#

@commands.push(command)

@disabled.push(false)

@item_max = @commands.size

# Position the command window

if $command_y_pos == nil

self.y -= 32

else

self.y = $command_y_pos

end

# Set the command window height

if $command_height == nil

self.height += 32

else

self.height = $command_height

end

self.contents.dispose

self.contents = nil

self.contents = Bitmap.new(self.width - 32, @item_max * 32)

refresh

for i in 0...@commands.size

if @disabled

disable_item(i)

end

end

end

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

# * Disable Item

# index : item number

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

def disable_item(index)

@disabled = [] if @disabled.nil?

@disabled[index] = true

draw_item(index, disabled_color)

end

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

# * Enable Item

# index : item number

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

def enable_item(index)

@disabled = [] if @disabled.nil?

@disabled[index] = false

draw_item(index, normal_color)

end

end

class Window_Command < Window_Selectable

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

# ** Include

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

include XRXS_Window_Command

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

# * Disable Item

# index : item number

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

def disable_item(index)

super

end

end

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

# --- Edited Copy of Include for SoulRage script ---

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

class Window_Command_Enhanced < Window_Selectable

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

# ** Include

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

include XRXS_Window_Command

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

# * Disable Item

# index : item number

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

def disable_item(index)

super

end

end

 

Edited by Rajaat99

Share this post


Link to post
Share on other sites

Wow. Great find Rajaat :) I like the idea of changing equipment in battle. I've seen that in a few games and have thought about using it in games I create. I'll definitely try this out sometime :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...