#==============================================================================
# Crystal Engine - Equipment Weight
#------------------------------------------------------------------------------
# Current Version: 1.00
#==============================================================================
$imported ||= {}
$imported["CE-EquipmentWeight"] = true
=begin
This script allows you to set up a weight system for your equipment. This system
sets all equipable items to have a weight. When an actor's equipment is too
heavy the play cannot exit out of the equip scene (or cycle to another actor).
-------------------------------------------------------------------------------
Notetags:
Actor Notes
Class Notes
<weight limit: x> # Sets the class's weight limit to x (actor limit take priority)
Skill Notes
<change weight limit: +x> # Add x to the target's weight limit
<change weight limit: -x> # Subtract x to the target's weight limit
Item Notes
<change weight limit: +x> # Add x to the target's weight limit
<change weight limit: -x> # Subtract x to the target's weight limit
<weight: x> # Sets the weight of the item to x (only if using CE - Item Accessories)
Weapon Notes
<weight: x> # Sets the weight of the weapon to x
Armor Notes
<weight: x> # Sets the weight of the armor to x
-------------------------------------------------------------------------------
Script Calls:
change_weight_limit(actor_id, amount) # Modify the specified actor's weight limit
# by the amount specified
=end
module CRYSTAL
module EQUIP
#--------------------------------------------------------------------------
# * Default Weight Limit for Actors
#--------------------------------------------------------------------------
DEFAULT_WEIGHT_LIMIT = 20
#--------------------------------------------------------------------------
# * Default Weight for Equipment
#--------------------------------------------------------------------------
DEFAULT_WEIGHT = 5
end
end
#==============================================================================
# Editing beyond this point may cause stone, zombie, mist frenzy, and/or toad,
# so edit at your own risk.
#==============================================================================
#==============================================================================
# ** RPG::Actor
#------------------------------------------------------------------------------
# The data class for actors.
#==============================================================================
class RPG::Actor < RPG::BaseItem
#--------------------------------------------------------------------------
# * Weight Limit
#--------------------------------------------------------------------------
def weight_limit
@note =~ /<WEIGHT LIMIT: (\d+)>/i ? $1.to_i : nil
end
end
#==============================================================================
# ** RPG::Class
#------------------------------------------------------------------------------
# The data class for classes.
#==============================================================================
class RPG::Class < RPG::BaseItem
#--------------------------------------------------------------------------
# * Weight Limit
#--------------------------------------------------------------------------
def weight_limit
@note =~ /<WEIGHT LIMIT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT_LIMIT
end
end
#==============================================================================
# ** RPG::UsableItem
#------------------------------------------------------------------------------
# A superclass of weapons and armor.
#==============================================================================
class RPG::UsableItem < RPG::BaseItem
#--------------------------------------------------------------------------
# * Weight
#--------------------------------------------------------------------------
def weight_mod
@note =~ /<CHANGE WEIGHT LIMIT: ([\+\-]\d+)>/i ? $1.to_i : 0
end
end
#==============================================================================
# ** RPG::Item
#------------------------------------------------------------------------------
# A superclass of weapons and armor.
#==============================================================================
class RPG::Item < RPG::UsableItem
#--------------------------------------------------------------------------
# * Weight
#--------------------------------------------------------------------------
def weight
@note =~ /<WEIGHT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT
end
end
#==============================================================================
# ** RPG::EquipItem
#------------------------------------------------------------------------------
# A superclass of weapons and armor.
#==============================================================================
class RPG::EquipItem < RPG::BaseItem
#--------------------------------------------------------------------------
# * Weight
#--------------------------------------------------------------------------
def weight
@note =~ /<WEIGHT: (\d+)>/i ? $1.to_i : CRYSTAL::EQUIP::DEFAULT_WEIGHT
end
end
#==============================================================================
# ** SceneManager
#------------------------------------------------------------------------------
# This module manages scene transitions. For example, it can handle
# hierarchical structures such as calling the item screen from the main menu
# or returning from the item screen to the main menu.
#==============================================================================
module SceneManager
#--------------------------------------------------------------------------
# * Force Recall
#--------------------------------------------------------------------------
def self.force_recall(scene_class)
[url=home.php?mod=space&uid=420706]@Scene[/url] = scene_class
end
end # SceneManager
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# A battler class with methods for sprites and actions added. This class
# is used as a super class of the Game_Actor class and Game_Enemy class.
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# * Test Skill/Item Application
# Used to determine, for example, if a character is already fully healed
# and so cannot recover anymore.
#--------------------------------------------------------------------------
alias item_test_ce_equipment_weight item_test
def item_test(user, item)
return true if actor? && item.weight_mod != 0
return item_test_ce_equipment_weight(user, item)
end
#--------------------------------------------------------------------------
# * Apply Effect of Skill/Item
#--------------------------------------------------------------------------
alias item_apply_ce_equipment_weight item_apply
def item_apply(user, item)
item_apply_ce_equipment_weight(user, item)
return if enemy?
@weight_mod += item.weight_mod
if available_weight < 0
if $game_party.in_battle
Graphics.freeze
SceneManager.scene.info_viewport.visible = false
SceneManager.scene.log_window.visible = false
hide_extra_gauges if $imported["YEA-BattleEngine"]
SceneManager.snapshot_for_background
$game_party.menu_actor = self
old_scene = SceneManager.scene
SceneManager.call(Scene_Equip)
SceneManager.scene.main
SceneManager.force_recall(old_scene)
show_extra_gauges if $imported["YEA-BattleEngine"]
SceneManager.scene.info_viewport.visible = true
SceneManager.scene.log_window.visible = true
SceneManager.scene.status_window.refresh
SceneManager.scene.perform_transition
else
SceneManager.scene.instance_variables.each do |varname|
ivar = SceneManager.scene.instance_variable_get(varname)
ivar.visible = false if ivar.is_a?(Window)
end
$game_party.menu_actor = self
old_scene = SceneManager.scene
SceneManager.call(Scene_Equip)
SceneManager.scene.main
SceneManager.force_recall(old_scene)
SceneManager.scene.instance_variables.each do |varname|
ivar = SceneManager.scene.instance_variable_get(varname)
ivar.visible = true if ivar.is_a?(Window)
end
SceneManager.scene.perform_transition
end
end
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :weight_mod # Equipment Weight Modifier
#--------------------------------------------------------------------------
# * Setup
#--------------------------------------------------------------------------
alias setup_ce_equipment_weight setup
def setup(actor_id)
@weight_mod = 0
setup_ce_equipment_weight(actor_id)
end
#--------------------------------------------------------------------------
# * Base Weight Limit
#--------------------------------------------------------------------------
def base_weight_limit
actor.weight_limit ? actor.weight_limit : self.class.weight_limit
end
#--------------------------------------------------------------------------
# * Max Weight Limit
#--------------------------------------------------------------------------
def max_weight_limit
base_weight_limit + @weight_mod
end
#--------------------------------------------------------------------------
# * Combined Weight of All Equipment
#--------------------------------------------------------------------------
def equipment_weight
equips.compact.inject(0) {|r, item| r += item.weight }
end
#--------------------------------------------------------------------------
# * Weight Availible for Equipment
#--------------------------------------------------------------------------
def available_weight
max_weight_limit - equipment_weight
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Change Weight Limit for Actor
#--------------------------------------------------------------------------
def change_weight_limit(actor_id, amount)
$game_actors[actor_id].weight_mod += amount
if $game_actors[actor_id].available_weight < 0
if $game_party.in_battle
Graphics.freeze
SceneManager.scene.info_viewport.visible = false
SceneManager.scene.log_window.visible = false
hide_extra_gauges if $imported["YEA-BattleEngine"]
SceneManager.snapshot_for_background
$game_party.menu_actor = $game_actors[actor_id]
old_scene = SceneManager.scene
SceneManager.call(Scene_Equip)
SceneManager.scene.main
SceneManager.force_recall(old_scene)
show_extra_gauges if $imported["YEA-BattleEngine"]
SceneManager.scene.info_viewport.visible = true
SceneManager.scene.log_window.visible = true
SceneManager.scene.status_window.refresh
SceneManager.scene.perform_transition
else
$game_party.menu_actor = self
old_scene = SceneManager.scene
SceneManager.call(Scene_Equip)
SceneManager.scene.main
SceneManager.force_recall(old_scene)
SceneManager.scene.perform_transition
end
end
end
end
#==============================================================================
# ** Window_EquipCommand
#------------------------------------------------------------------------------
# This window is for selecting commands (change equipment/ultimate equipment
# etc.) on the skill screen.
#==============================================================================
class Window_EquipCommand < Window_HorzCommand
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actor # The Actor Displayed
#--------------------------------------------------------------------------
# * Get Activation State of Cancel Processing
#--------------------------------------------------------------------------
def can_cancel?
return false if @actor && @actor.available_weight < 0
return true
end
#--------------------------------------------------------------------------
# * Processing When Cancel Button Is Pressed
#--------------------------------------------------------------------------
alias process_cancel_ce_equipment_weight process_cancel
def process_cancel
if can_cancel?
process_cancel_ce_equipment_weight
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Processing When L Button (Page Up) Is Pressed
#--------------------------------------------------------------------------
alias process_pageup_ce_equipment_weight process_pageup
def process_pageup
if can_cancel?
process_pageup_ce_equipment_weight
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# * Processing When R Button (Page Down) Is Pressed
#--------------------------------------------------------------------------
alias process_pagedown_ce_equipment_weight process_pagedown
def process_pagedown
if can_cancel?
process_pagedown_ce_equipment_weight
else
Sound.play_buzzer
end
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs the equipment screen processing.
#==============================================================================
class Scene_Equip < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
alias create_command_window_ce_equipment_weight create_command_window
def create_command_window
create_command_window_ce_equipment_weight
@command_window.actor = @actor
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :info_viewport
attr_accessor :status_window
attr_accessor :log_window
end
if $imported["YEA-AceEquipEngine"]
#==============================================================================
# ** Window_EquipSlot
#------------------------------------------------------------------------------
# This window displays items the actor is currently equipped with on the
# equipment screen.
#==============================================================================
class Window_EquipSlot < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :weight_window # Status window
#--------------------------------------------------------------------------
# * Set Status Window
#--------------------------------------------------------------------------
def weight_window=(weight_window)
@weight_window = weight_window
call_update_help
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
alias update_help_ce_equipment_weight update_help
def update_help
update_help_ce_equipment_weight
@weight_window.set_temp_actor(nil) if @weight_window
end
end
#==============================================================================
# ** Window_EquipItem
#------------------------------------------------------------------------------
# This window displays choices when opting to change equipment on the
# equipment screen.
#==============================================================================
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :weight_window # Status window
#--------------------------------------------------------------------------
# * Set Status Window
#--------------------------------------------------------------------------
def weight_window=(weight_window)
@weight_window = weight_window
call_update_help
end
#--------------------------------------------------------------------------
# * Update Help Text
#--------------------------------------------------------------------------
alias update_help_ce_equipment_weight update_help
def update_help
update_help_ce_equipment_weight
if @actor && @weight_window
temp_actor = Marshal.load(Marshal.dump(@actor))
temp_actor.force_change_equip(@slot_id, item)
@weight_window.set_temp_actor(temp_actor)
end
end
end
#==============================================================================
# ** Window_EquipWeight
#------------------------------------------------------------------------------
# This window displays the weight changes for an actor in the equipscreen
#==============================================================================
class Window_EquipWeight < Window_Base
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :actor # The Actor Displayed
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(width, actor)
super(416, 0, width, fitting_height(1))
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_weight
end
#--------------------------------------------------------------------------
# * Set Actor
#--------------------------------------------------------------------------
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# * Set Temporary Actor After Equipment Change
#--------------------------------------------------------------------------
def set_temp_actor(temp_actor)
return if @temp_actor == temp_actor
@temp_actor = temp_actor
refresh
end
#--------------------------------------------------------------------------
# * Draw Weight
#--------------------------------------------------------------------------
def draw_weight
draw_text(0, 0, 112, line_height, "Weight")
change_color(normal_color)
pos = 0
draw_text(112, 0, text_size("(").width + 5, line_height, "(")
pos += text_size("(").width
if @temp_actor
change_color(param_change_color(@temp_actor.available_weight - actor.available_weight))
n = @temp_actor.available_weight.to_s
draw_text(112 + pos, 0, text_size(n).width + 5, line_height, n)
pos += text_size(n).width
else
change_color(param_change_color(0 - 1)) if actor.available_weight < 0
n = actor.available_weight.to_s
draw_text(112 + pos, 0, text_size(n).width + 5, line_height, n)
pos += text_size(n).width
end
change_color(normal_color)
max = "/#{actor.max_weight_limit})"
draw_text(112 + pos, 0, width, line_height, max)
end
end
#==============================================================================
# ** Scene_Equip
#------------------------------------------------------------------------------
# This class performs the equipment screen processing.
#==============================================================================
class Scene_Equip < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Slot Window
#--------------------------------------------------------------------------
alias create_slot_window_ce_equipment_weight create_slot_window
def create_slot_window
create_slot_window_ce_equipment_weight
@weight_window = Window_EquipWeight.new(@slot_window.width, @actor)
@slot_window.height -= @weight_window.height
@slot_window.refresh
@weight_window.y = @slot_window.y + @slot_window.height
@slot_window.weight_window = @weight_window
end
#--------------------------------------------------------------------------
# * Create Item Window
#--------------------------------------------------------------------------
alias create_item_window_ce_equipment_weight create_item_window
def create_item_window
create_item_window_ce_equipment_weight
@item_window.weight_window = @weight_window
end
#--------------------------------------------------------------------------
# * [Ultimate Equipment] Command
#--------------------------------------------------------------------------
alias command_optimize_ce_equipment_weight command_optimize
def command_optimize
command_optimize_ce_equipment_weight
@weight_window.refresh
end
#--------------------------------------------------------------------------
# * [Remove All] Command
#--------------------------------------------------------------------------
alias command_clear_ce_equipment_weight command_clear
def command_clear
command_clear_ce_equipment_weight
@weight_window.refresh
end
end
else
#==============================================================================
# ** Window_EquipStatus
#------------------------------------------------------------------------------
# This window displays actor parameter changes on the equipment screen.
#==============================================================================
class Window_EquipStatus < Window_Base
#--------------------------------------------------------------------------
# * Draw Name
#--------------------------------------------------------------------------
alias draw_actor_name_ce_equipment_weight draw_actor_name
def draw_actor_name(actor, x, y, width = 112)
draw_actor_name_ce_equipment_weight(actor, x, y)
change_color(normal_color)
pos = 0
draw_text(x + width, y, text_size("(").width + 5, line_height, "(")
pos += text_size("(").width
if @temp_actor
change_color(param_change_color(@temp_actor.available_weight - actor.available_weight))
n = @temp_actor.available_weight.to_s
draw_text(x + width + pos, y, text_size(n).width + 5, line_height, n)
pos += text_size(n).width
else
change_color(param_change_color(0 - 1)) if actor.available_weight < 0
n = actor.available_weight.to_s
draw_text(x + width + pos, y, text_size(n).width + 5, line_height, n)
pos += text_size(n).width
end
change_color(normal_color)
max = "/#{actor.max_weight_limit})"
draw_text(x + width + pos, y, width, line_height, max)
end
end
end
#==============================================================================
#
# ▼ End of File
#
#==============================================================================