Modules
- Kód: Vybrat vše
#==============================================================================
# ** Multi-Elot Equipment VX
#------------------------------------------------------------------------------
# Section 1: Modules
#==============================================================================
module MS_MOD
#==============================================================================
# *** C O N F I G U R A T I O N S E C T I O N *** #
#==============================================================================
ARMOR_KINDS = [0, 1, 2, 3, 4, 5, 6, 7, 8]
EXTRA_SLOT_NAMES = ["rukavice", "Boty", "Amulet", "Prsten", "Spirit"]
CURSED_WEAPONS = []
CURSED_ARMOR = [30]
CURSED_COLOR = 30
SWITCH_EQUIP_WEAPONS = []
SWITCH_EQUIP_ARMORS = [ [28,30] ]
end
#==============================================================================
# ** TAG CONSTANT
#------------------------------------------------------------------------------
# Constant value(s) used to gain data from the 'note' section.
#==============================================================================
# Used for 'note-tagged' Multi-Slot Equipment
SLOT_KIND = /(?:SLOT_KIND|Multi-Slot:)\s*(.+)/i
#==============================================================================
# ** RPG
#------------------------------------------------------------------------------
# A module containing RPGVX Data Structures.
#==============================================================================
module RPG
#============================================================================
# ** Armor
#----------------------------------------------------------------------------
# Data class for armor.
#============================================================================
class Armor < RPG::BaseItem
#------------------------------------------------------------------------
# * Alias Listings
#------------------------------------------------------------------------
alias ms_module_kind kind
#------------------------------------------------------------------------
# * Set New Item Types
#------------------------------------------------------------------------
def set_new_item_types
@__type = -1
self.note.split(/[\r\n]+/).each { |line|
if line =~ SLOT_KIND
line_index = MS_MOD::EXTRA_SLOT_NAMES.index($1)
next if line_index == nil
@__type = line_index + 4
end }
end
#------------------------------------------------------------------------
# * Set Advanced 'Slot' Type
#------------------------------------------------------------------------
def type
set_new_item_types if @__type == nil
return (@__type == -1 ? ms_module_kind : @__type)
end
end
end
Actors
- Kód: Vybrat vše
#==============================================================================
# ** Multi-Slot Equipment VX
#------------------------------------------------------------------------------
# Section 2: Actors
#==============================================================================
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It's used within the Game_Actors class
# ($game_actors) and referenced by the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias ms_actor_setup setup
alias ms_actor_armors armors
alias ms_actor_change_equip change_equip
alias ms_actor_discard_equip discard_equip
alias ms_actor_class_id class_id=
alias ms_two_swords_style two_swords_style
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_writer :equip_type # equipment type
attr_accessor :armor_array # addtl armor array
attr_accessor :weapon_slot_names # Optional weapon slot names
attr_accessor :armor_slot_names # Optional armor slot names
attr_accessor :extra_slot_names # Optional extra slot names
attr_accessor :extra_two_swords_style # Optional two sword style changer
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@extra_armor_id = []
# Perform the original call
ms_actor_setup(actor_id)
# Restore extra slot equipment
equipment_restore
end
#--------------------------------------------------------------------------
# * Get Armor Object Array
#--------------------------------------------------------------------------
def armors
# Obtain the original call's result
result = ms_actor_armors
# Sort through additional armors
extra_armor_slot.times { |i|
armor_id = extra_armor_id[i]
result << (armor_id == nil ? nil : $data_armors[armor_id]) }
return result
end
#--------------------------------------------------------------------------
# * Reset all slot data to default one
#--------------------------------------------------------------------------
def reset_all_slots
self.armor_slots = MS_MOD::ARMOR_KINDS
self.armor_slot_names = []
self.weapon_slot_names = []
self.extra_slot_names = []
self.extra_two_swords_style = nil
end
#--------------------------------------------------------------------------
# * Change Armor Slots
# array : Array for armor slots
#--------------------------------------------------------------------------
def armor_slots=(array)
return if actor == nil
@equip_type = array
equip_type
end
#--------------------------------------------------------------------------
# * Change Weapon Slot Names
# array : Array for weapon slot names
#--------------------------------------------------------------------------
def weapon_slot_names=(array)
@weapon_slot_names = nil
return if actor == nil
@weapon_slot_names = array
end
#--------------------------------------------------------------------------
# * Change Armor Slot Names
# array : Array for armor slot names
#--------------------------------------------------------------------------
def armor_slot_names=(array)
@armor_slot_names = nil
return if actor == nil
@armor_slot_names = array
end
#--------------------------------------------------------------------------
# * Change Extra Armor Slot Names
# array : Array for extra slot names
#--------------------------------------------------------------------------
def extra_slot_names=(array)
@extra_slot_names = nil
return if actor == nil
@extra_slot_names = array
end
#--------------------------------------------------------------------------
# * Change Two Swords Style
# flag : true/false flag
#--------------------------------------------------------------------------
def two_swords_style=(flag)
return if actor == nil
@extra_two_swords_style = flag
end
#--------------------------------------------------------------------------
# * Get [Dual Wield] Option
#--------------------------------------------------------------------------
def two_swords_style
ms_return = ms_two_swords_style
ms_return = @extra_two_swords_style if @extra_two_swords_style != nil
return ms_return
end
#--------------------------------------------------------------------------
# * Change Equipment (designate object)
# equip_type : Equip region (0..4)
# item : Weapon or armor (nil is used to unequip)
# test : Test flag (for battle test or temporary equipment)
#--------------------------------------------------------------------------
def change_equip(equip_type, item, test = false)
# Prevent use if game party not formed (party changer fix)
return if item == nil && $game_party == nil
# Perform the original call
ms_actor_change_equip(equip_type, item, test)
# If an additional slot
if extra_armor_slot > 0
item_id = item == nil ? 0 : item.id
case equip_type
when 5..armor_slot
@extra_armor_id = [] if @extra_armor_id == nil
@extra_armor_id[equip_type - 5] = item_id
end
end
end
#--------------------------------------------------------------------------
# * Discard Equipment
# item : Weapon or armor to be discarded.
# Used when the "Include Equipment" option is enabled.
#--------------------------------------------------------------------------
def discard_equip(item)
# Store original armor IDs
last_armors = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
# Perform the original call
ms_actor_discard_equip(item)
# Store current armor IDs
curr_armors = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
return unless item.is_a?(RPG::Armor)
return if last_armors != curr_armors
# Sort through and remove armor
extra_armor_slot.times { |i|
if extra_armor_id[i] == item.id
@extra_armor_id[i] = 0
break
end }
end
#--------------------------------------------------------------------------
# * Switch Items. Switches equipment to fool a player.
# item : item (Weapon or Armor
#--------------------------------------------------------------------------
def switch_items(item)
id = item.id
if item.is_a?(RPG::Weapon)
for i in 0...MS_MOD::SWITCH_EQUIP_WEAPONS.size
if MS_MOD::SWITCH_EQUIP_WEAPONS[i][0] == id
id = MS_MOD::SWITCH_EQUIP_WEAPONS[i][1]
end
end
end
if item.is_a?(RPG::Armor)
for i in 0...MS_MOD::SWITCH_EQUIP_ARMORS.size
if MS_MOD::SWITCH_EQUIP_ARMORS[i][0] == id
id = MS_MOD::SWITCH_EQUIP_ARMORS[i][1]
end
end
end
# Return the id value
return id
end
#--------------------------------------------------------------------------
# * Change Class ID
# class_id : New class ID
#--------------------------------------------------------------------------
def class_id=(class_id)
# Perform the original call
ms_actor_class_id(class_id)
return if extra_armor_slot == 0 # Only if no additional slots
# Sort through slots
for i in 5..armor_slot
change_equip(i, nil) unless equippable?(equips[i])
end
end
#--------------------------------------------------------------------------
# * Equipment Type
#--------------------------------------------------------------------------
def equip_type
if @equip_type.is_a?(Array)
return @equip_type
else
return MS_MOD::ARMOR_KINDS
end
end
#--------------------------------------------------------------------------
# * Return number of slots
#--------------------------------------------------------------------------
def armor_slot
return equip_type.size
end
#--------------------------------------------------------------------------
# * Return @extra_armor_slot
#--------------------------------------------------------------------------
def extra_armor_slot
return [armor_slot - 4, 0].max
end
#--------------------------------------------------------------------------
# # Return armor slot ID
#--------------------------------------------------------------------------
def extra_armor_id
@extra_armor_id = [] if @extra_armor_id == nil
return @extra_armor_id
end
#--------------------------------------------------------------------------
# * Restore equipment
#--------------------------------------------------------------------------
def equipment_restore
return if @__last_equip_type == equip_type
# Store previous values
last_equips = equips
last_hp = self.hp
last_mp = self.mp
# Change all equipment
last_equips.each_index { |i| change_equip(i, nil) }
last_equips.compact.each { |item| equip_legal_slot(item) }
self.hp = last_hp
self.mp = last_mp
@__last_equip_type = equip_type.clone
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# * Order Items
# item : Weapon or Armor
#--------------------------------------------------------------------------
def equip_legal_slot(item)
if item.is_a?(RPG::Weapon)
if @weapon_id == 0
# Weapon #1
change_equip(0, item)
elsif two_swords_style && @armor1_id == 0
# Weapon #2 (Two-Sword style)
change_equip(1, item)
end
elsif item.is_a?(RPG::Armor)
if !two_swords_style && item.type == equip_type[0] && @armor1_id == 0
# Shield
change_equip(1, item)
else
# Set Equipment Order
list = [-1, @armor2_id, @armor3_id, @armor4_id]
list += extra_armor_id
# Compress the Equipment List
equip_type.each_with_index { |type, i|
if type == item.type && list[i] == 0
change_equip(i + 1, item)
break
end }
end
end
end
#--------------------------------------------------------------------------
# * Return Equipment ID
# equip_type : Equip region (0 or higher)
#--------------------------------------------------------------------------
def return_equip_id(equip_type)
returned = 0
case equip_type
when 0 # Weapon
returned = @weapon_id
when 1 # Shield
returned = @armor1_id
when 2 # Head
returned = @armor2_id
when 3 # Body
returned = @armor3_id
when 4 # Accessory
returned = @armor4_id
when 5..armor_slot
returned = @extra_armor_id[equip_type - 5]
end
return returned
end
end
Windows
- Kód: Vybrat vše
#==============================================================================
# ** Multi-Slot Equipment VX
#------------------------------------------------------------------------------
# Section 3: Windows
#==============================================================================
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a superclass of all windows in the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Get Cursed Color
#--------------------------------------------------------------------------
def cursed_color
if MS_MOD::CURSED_COLOR.is_a?(Array)
return Color.new( MS_MOD::CURSED_COLOR[0],
MS_MOD::CURSED_COLOR[1],
MS_MOD::CURSED_COLOR[2])
else
return text_color(MS_MOD::CURSED_COLOR)
end
end
end
#==============================================================================
# ** Window_Equip
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================
class Window_Equip < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = @actor.equips.clone
@item_max = [@data.size, @actor.armor_slot + 1].min
create_contents
# Weapon_Names
ms_weapon = Vocab::weapon
ms_weapon1 = Vocab::weapon1
ms_weapon2 = Vocab::weapon2
# Substitute Names
unless @actor.weapon_slot_names == nil
ms_weapon = @actor.weapon_slot_names[0] if @actor.weapon_slot_names[0] != nil
ms_weapon1 = @actor.weapon_slot_names[0] if @actor.weapon_slot_names[0] != nil
ms_weapon2 = @actor.weapon_slot_names[1] if @actor.weapon_slot_names[1] != nil
end
# Basic weapon-slot handlings
self.contents.font.color = system_color
if @actor.two_swords_style
self.contents.draw_text(4, WLH * 0, 92, WLH, ms_weapon1)
self.contents.draw_text(4, WLH * 1, 92, WLH, ms_weapon2)
else
self.contents.draw_text(4, WLH * 0, 92, WLH, ms_weapon)
name = armor_slot_name(@actor.equip_type[0])
self.contents.draw_text(4, WLH * 1, 92, WLH, name)
end
for i in 1...@actor.armor_slot
name = armor_slot_name(@actor.equip_type[i])
self.contents.draw_text(4, WLH * (i + 1), 92, WLH, name)
end
# Draw Additional armor slots
rect = Rect.new(92, 0, self.width - 128, WLH)
@item_max.times { |i| rect.y = WLH * i
draw_item_name(@data[i], rect.x, rect.y) }
end
#--------------------------------------------------------------------------
# * Draw Item Name
# item : Item (skill, weapon, armor are also possible)
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# enabled : Enabled flag. When false, draw semi-transparently.
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
if item.is_a?(RPG::Weapon) && MS_MOD::CURSED_WEAPONS.include?(item.id)
self.contents.font.color = cursed_color
end
if item.is_a?(RPG::Armor) && MS_MOD::CURSED_ARMOR.include?(item.id)
self.contents.font.color = cursed_color
end
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, item.name)
end
end
#--------------------------------------------------------------------------
# * Armor Slot Names
# type : armor type
#--------------------------------------------------------------------------
def armor_slot_name(type)
case type
when 0..3
ms_armor = eval("Vocab.armor#{type + 1}")
unless @actor.armor_slot_names == nil
ms_armor = @actor.armor_slot_names[type] if @actor.armor_slot_names[type] != nil
end
else
ms_armor = MS_MOD::EXTRA_SLOT_NAMES[type - 4]
unless @actor.extra_slot_names == nil
ms_armor = @actor.extra_slot_names[type-4] if @actor.extra_slot_names[type-4] != nil
end
end
return ms_armor
end
end
#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
# This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================
class Window_EquipItem < Window_Item
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@item_enabled = []
super
@data.each { |item| @item_enabled << enable?(item) }
end
#--------------------------------------------------------------------------
# * Secondary Refresh
# equip_type : Equip region (0..4)
#--------------------------------------------------------------------------
def second_refresh(equip_type)
# Modifying the equipment region temporarily
last_equip_type = @equip_type
@equip_type = equip_type
@data.each_with_index { |item, i|
# Redraw when the item changes
if enable?(item) != @item_enabled[i]
draw_item(i)
@item_enabled[i] = enable?(item)
end
}
# Reset the equipment region
@equip_type = last_equip_type
end
#--------------------------------------------------------------------------
# * Whether to include item in list
# item : item
#--------------------------------------------------------------------------
def include?(item)
return true if item == nil
if @equip_type == 0
return false unless item.is_a?(RPG::Weapon)
else
return false unless item.is_a?(RPG::Armor)
return false unless item.type == @equip_type - 1
end
return @actor.equippable?(item)
end
#--------------------------------------------------------------------------
# * Whether to display item in enabled state
# item : item
#--------------------------------------------------------------------------
def enable?(item)
return false unless @actor.equippable?(item)
return true
end
end
#==============================================================================
# ** Window_Status
#------------------------------------------------------------------------------
# This window displays full status specs on the status screen.
#==============================================================================
class Window_Status < Window_Base
#--------------------------------------------------------------------------
# * Draw Equipment
# x : Draw spot X coordinate
# y : Draw spot Y coordinate
#--------------------------------------------------------------------------
def draw_equipments(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, WLH, Vocab::equip)
item_number = [@actor.equips.size, @actor.armor_slot + 1].min
item_number.times { |i|
draw_item_name(@actor.equips[i], x + 16, y + WLH * (i + 1)) }
end
end
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# * Draw Actor's Current Equipment and Parameters
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
#--------------------------------------------------------------------------
def draw_actor_parameter_change(actor, x, y)
return if @item.is_a?(RPG::Item)
enabled = actor.equippable?(@item)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x, y, 200, WLH, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = weaker_weapon(actor)
elsif actor.two_swords_style and @item.type == 0
item1 = nil
else
index = actor.equip_type.index(@item.type)
item1 = (index != nil ? actor.equips[1 + index] : nil)
end
if enabled
if @item.is_a?(RPG::Weapon)
atk1 = item1 == nil ? 0 : item1.atk
atk2 = @item == nil ? 0 : @item.atk
change = atk2 - atk1
else
def1 = item1 == nil ? 0 : item1.def
def2 = @item == nil ? 0 : @item.def
change = def2 - def1
end
self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
end
draw_item_name(item1, x, y + WLH, enabled)
end
end
Other
- Kód: Vybrat vše
#==============================================================================
# ** Multi-Slot Equipment VX
#------------------------------------------------------------------------------
# Section 4: Other
#==============================================================================
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs the equipment screen processing.
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias ms_scene_initialize initialize
alias ms_scene_create_item_windows create_item_windows
alias ms_scene_update_item_selection update_item_selection
alias ms_scene_update_equip_selection update_equip_selection
#--------------------------------------------------------------------------
# * Constants
#--------------------------------------------------------------------------
EQUIP_TYPE_MAX = MS_MOD::EXTRA_SLOT_NAMES.size + 5
#--------------------------------------------------------------------------
# * Object Initialization
# actor_index : actor index
# equip_index : equipment index
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
ms_scene_initialize(actor_index, equip_index)
actor = $game_party.members[actor_index]
@equip_index = [@equip_index, actor.armor_slot].min
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
def create_item_windows
# Perform the original call
ms_scene_create_item_windows
type = equip_type(@equip_index)
EQUIP_TYPE_MAX.times { |i| @item_windows[i].visible = (type == i) }
end
#--------------------------------------------------------------------------
# * Update Item Window
#--------------------------------------------------------------------------
def update_item_windows
type = equip_type(@equip_window.index)
for i in 0...EQUIP_TYPE_MAX
@item_windows[i].visible = (type == i)
@item_windows[i].update
end
@item_window = @item_windows[type]
@item_window.second_refresh(@equip_window.index)
end
#--------------------------------------------------------------------------
# * Get the Equipment Type
# index : Index
#--------------------------------------------------------------------------
def equip_type(index)
if index == 0
return 0
else
return @actor.equip_type[index - 1] + 1
end
end
#--------------------------------------------------------------------------
# * Update Status Window
#--------------------------------------------------------------------------
def update_status_window
if @equip_window.active
@status_window.set_new_parameters(nil, nil, nil, nil)
elsif @item_window.active
temp_actor = Marshal.load(Marshal.dump(@actor))
temp_actor.change_equip(@equip_window.index, @item_window.item, true)
new_atk = temp_actor.atk
new_def = temp_actor.def
new_spi = temp_actor.spi
new_agi = temp_actor.agi
@status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
end
@status_window.update
end
#--------------------------------------------------------------------------
# * Update Equip Region Selection
#--------------------------------------------------------------------------
def update_equip_selection
if Input.trigger?(Input::C)
# Regular gear
w = @actor.weapon_id
a1 = @actor.armor1_id
a2 = @actor.armor2_id
a3 = @actor.armor3_id
a4 = @actor.armor4_id
# Additional slots
slotarray = []
for i in 0...EQUIP_TYPE_MAX - 5
slotarray[i] = @actor.extra_armor_id[i]
end
# If already fixed
if @actor.fix_equipment
Sound.play_buzzer
return
end
# Go through generic gear
if @equip_window.index == 0 && MS_MOD::CURSED_WEAPONS.include?(w)
Sound.play_buzzer
return
elsif @equip_window.index == 1
if @actor.two_swords_style && MS_MOD::CURSED_WEAPONS.include?(a1)
Sound.play_buzzer
return
elsif !@actor.two_swords_style && MS_MOD::CURSED_ARMOR.include?(a1)
Sound.play_buzzer
return
end
elsif @equip_window.index == 2 && MS_MOD::CURSED_ARMOR.include?(a2)
Sound.play_buzzer
return
elsif @equip_window.index == 3 && MS_MOD::CURSED_ARMOR.include?(a3)
Sound.play_buzzer
return
elsif @equip_window.index == 4 && MS_MOD::CURSED_ARMOR.include?(a4)
Sound.play_buzzer
return
end
# Go through extra slots
for i in 0...EQUIP_TYPE_MAX-5
if @equip_window.index == 5 + i && MS_MOD::CURSED_ARMOR.include?(slotarray[i])
Sound.play_buzzer
return
end
end
end
# Perform the original call
ms_scene_update_equip_selection
end
#--------------------------------------------------------------------------
# * Update Item Selection
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::C)
# Return if invalid selection
index = @equip_window.index
current_item = @item_window.item
unless current_item == nil || @actor.equippable?(current_item)
Sound.play_buzzer
return
end
unless current_item == nil
switched = @actor.switch_items(current_item)
end
end
# Perform the original call
ms_scene_update_item_selection
if Input.trigger?(Input::C)
unless switched == nil
if current_item.is_a?(RPG::Weapon)
gained_item = $data_weapons[switched]
else
gained_item = $data_armors[switched]
end
$game_party.gain_item(gained_item, 1, true)
@actor.change_equip_by_id(@equip_window.index, switched)
@equip_window.refresh
$game_party.lose_item(current_item, 1, true)
end
end
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias ms_scene_read_save_data read_save_data
#--------------------------------------------------------------------------
# * Restore Equipment
#--------------------------------------------------------------------------
def equipment_restore
(1...$data_actors.size).each { |i| actor = $game_actors[i]
actor.equipment_restore }
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
# Perform the original call
ms_scene_read_save_data(file)
# Restore extra slot equipment
equipment_restore
# Reset Graphics
Graphics.frame_reset
end
end