Код:
#==============================================================================
# ** Scene_Spoils
#------------------------------------------------------------------------------
# This class controls the scene that allows the player to access chests
#==============================================================================
class Scene_Spoils < Scene_Base
include Overlord_Dave::DRIACS::Settings
#--------------------------------------------------------------------------
# * Object Initialisation
# source : The scene from which the spoils scene was opened
# head : The name displayed above the chest
# chest_id : The id of the chest opened (from the $chests hash)
#--------------------------------------------------------------------------
def initialize(source, head = nil, chest_id = nil)
@source = source
@chest_id = chest_id
@max_size = chest_id.nil? ? 0 : $chests[chest_id].max_size
@spoils_head = case @source # 1: from map, 2: from menu, 3: from battle
when 1,2: USE_CONTAINER_NAME && !head.nil? && head != '' ? head : WIN_CONT_HEAD
when 3: head # the head is determined in Game_System.init_battle_spoils
end
end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_menu_background
case SPOILS_INFO_POS
when 0
info_y = 0
titles_y = 56
items_y = 112
when 1
info_y = 360
titles_y = 0
items_y = 56
end
@info_window = Window_Help.new
@info_window.y = info_y
@spoils_title = Window_Help.new
@spoils_title.y = titles_y
@spoils_title.width = 544/2.0
@spoils_title.create_contents
@inv_title = Window_Help.new
@inv_title.y = titles_y
@inv_title.x = 544/2.0
@inv_title.width = 544/2.0
@inv_title.create_contents
@spoils_window = Window_Spoils.new(0, items_y, 544/2.0, 304)
@spoils_window.chest = $game_temp.temp_chest
@inv_window = Window_Item.new(544/2.0, items_y, 544/2.0, 304, true)
@inv_window.column_max = 1
@inv_window.refresh
@inv_window.update
@inv_window.index = 0
# make the spoils window active unless it is empty
if $game_temp.temp_chest.all_items == [-1]
@spoils_window.active = false
@inv_window.active = true
else
@spoils_window.active = true
@spoils_window.index = 0
@inv_window.active = false
end
update
end
#--------------------------------------------------------------------------
# * Makes the message window appear
# type : the message window to display (1-5)
# obj : and object that can be passed to the method if necessary
# (such as for type 5)
#--------------------------------------------------------------------------
def show_message(type, obj = nil)
@message_window = case type
when 1: Window_Info.new(LEAVE_ND_MSG, 1) # from inv_window
when 2: Window_Info.new(INV_FULL, 1) # exiting with an over-size inventory
when 3: Window_Info.new(SPOILS_FULL, 2) # exiting with an over-size chest
when 4: Window_Info.new(NO_LEAVE_MSG, 1) # if a chest is not accessable
when 5: Window_List.new(WARN_FORCED_MSG, 2, obj) # forced items window
# gold found message (must check whether chest has items to find value
# of return_to)
when 6: Window_Info.new(sprintf(GOLD_FOUND, obj), $game_temp.temp_chest.all_items == [-1] ? 1 : 2)
end
# play the shop sound for the gold message window
Sound.play_shop if type == 6 && GOLD_MSG_SOUND
@message_window.visible = true
@spoils_window.active = false
@inv_window.active = false
end
#--------------------------------------------------------------------------
# * Makes the message window disappear
#--------------------------------------------------------------------------
def hide_message_window
case @message_window.return_to
when 1 # return to inv_window
@inv_window.active = true
@spoils_window.active = false
when 2 # return to spoils_window
@inv_window.active = false
@spoils_window.active = true
end
@message_window.dispose
@message_window = nil
end
#--------------------------------------------------------------------------
# * Makes the exit confirmation window appear
# type : the message window to display (1-4)
#--------------------------------------------------------------------------
def show_exit_window(type)
if @inv_window.active
return_to = 1
elsif @spoils_window.active
return_to = 2
end
message = case type
when 0 :CONF_MSG_0
when 1 :CONF_MSG_1
when 2 :CONF_MSG_2
when 3 :E_MSG_SPOILS
end
@inv_window.active = false
@spoils_window.active = false
if type == 3 # over-encumbered message
@exit_window = Window_Option.new(message, E_OPT1_SPOILS, E_OPT2_SPOILS, 4)
else
@exit_window = Window_Option.new(message, CONF_OPT1, CONF_OPT2)
end
@exit_window.visible = true
@exit_window.active = true
@exit_window.index = 0
@exit_window.return_to = return_to
end
#--------------------------------------------------------------------------
# * Makes the exit confirmation window disappear
#--------------------------------------------------------------------------
def hide_exit_window
case @exit_window.return_to
when 1 # inv window
@inv_window.active = true
when 2 # spoils
@spoils_window.active = true
end
@exit_window.dispose
@exit_window = nil
end
#--------------------------------------------------------------------------
# * Makes the option window appear when an item is selected from the inventory
# source : which window it was called from (kept for possible future
# features)
#--------------------------------------------------------------------------
def show_drop_choice_window(source)
case source
when 1 # inv_window
@drop_choice_window = Window_Option.new('', USE_ITEM_OPT1B, USE_ITEM_OPT2, 2)
@drop_choice_window.draw_window(@item)
end
@drop_choice_window.visible = true
@drop_choice_window.active = true
@drop_choice_window.index = 0
@spoils_window.active = false
@inv_window.active = false
end
#--------------------------------------------------------------------------
# * Makes the option window when an item is selected from the inventory
# disappear
#--------------------------------------------------------------------------
def hide_drop_choice_window
case @drop_choice_window.type
when 2 # from inv_window
@inv_window.active = true
when 3 # from spoils window
@spoils_window.active = true
end
@drop_choice_window.dispose
@drop_choice_window = nil
end
#--------------------------------------------------------------------------
# * Makes the number select window appear
# type : which message is shown above the number (1-3)
#--------------------------------------------------------------------------
def show_num_window(type)
message = case type
when 1 :LEAVE_SPOILS_MSG
when 2 :TAKE_SPOILS_MSG
when 3 :DROP_SPOILS_MSG
end
@num_window = Window_NumSelect.new(message, type)
@num_window.num_max = case type
when 1 :$game_party.item_number(@item)
when 2 :$game_temp.temp_chest.item_number(@item, @dropped)
when 3 :$game_party.item_number(@item)
end
hide_drop_choice_window if !@drop_choice_window.nil?
@spoils_window.active = false
@inv_window.active = false
end
#--------------------------------------------------------------------------
# * Makes the number select window disappear
#--------------------------------------------------------------------------
def hide_num_window
case @num_window.type
when 1
@inv_window.active = true
when 2
@spoils_window.active = true
when 3
@inv_window.active = true
end
@num_window.dispose
@num_window = nil
end
#--------------------------------------------------------------------------
# * Determines which windows to show after an action is selected from the drop
# choice window.
# type : which action has been selected (1-3)
#--------------------------------------------------------------------------
def det_move_item(type)
case type
when 1 # from inv_window
case SHOW_MOVE_ITEM
when 0 # never
Sound.play_decision
leave_item(1)
when 1 # if more than one in stack
if $game_party.item_number(@item) > 1
Sound.play_decision
show_num_window(1)
else
Sound.play_decision
leave_item(1)
end
when 2 # always
Sound.play_decision
show_num_window(1)
end
when 2 # from spoils_window
if @spoils_window.index == 0 # take all selected
Sound.play_decision
take_all
return
end
case SHOW_MOVE_ITEM
when 0 # never
Sound.play_decision
take_item(1)
when 1 # if more than one in stack
if $game_temp.temp_chest.item_number(@item, @dropped) > 1
Sound.play_decision
show_num_window(2)
else
Sound.play_decision
take_item(1)
end
when 2 # always
Sound.play_decision
show_num_window(2)
end
when 3 # dropping an item
case SHOW_MOVE_ITEM
when 0 # never
Sound.play_drop
drop_item(1)
when 1 # if more than one in stack
if $game_party.item_number(@item) > 1
Sound.play_decision
show_num_window(3)
else
Sound.play_drop
drop_item(1)
end
when 2 # always
Sound.play_decision
show_num_window(3)
end
end
end
#--------------------------------------------------------------------------
# * Moves a number of the currently selected item to the chest
# n : the number of items to move
#--------------------------------------------------------------------------
def leave_item(n)
# these must be determineed before the inventory and chest is modified
item_lost = true if n >= $game_party.item_number(@item)
reset_chest = $game_temp.temp_chest.empty? ? true : false
# modifying chest and inventory...
$game_party.lose_item(@item, n)
$game_temp.temp_chest.gain_item(@item, n)
@spoils_window.index = 0 if reset_chest
@inv_window.index -= 1 unless @inv_window.index == 0 || item_lost == false
@inv_window.refresh
@spoils_window.refresh
hide_drop_choice_window if !@drop_choice_window.nil?
end
#--------------------------------------------------------------------------
# * Moves a number of the currently selected item to the inventory
# n : the number of items to move
#--------------------------------------------------------------------------
def take_item(n)
# these must be determineed before the inventory and chest is modified
if n >= $game_temp.temp_chest.item_number(@item, @dropped)
item_lost = true
item_index = @spoils_window.index
end
# modifying chest and inventory...
$game_party.gain_item(@item, n)
$game_temp.temp_chest.lose_item(@item, n, @dropped)
if item_lost
@spoils_window.item_max -= 1
@spoils_window.index = item_index - 1 if item_index > (@spoils_window.item_max-1)
end
# make inventory window active if the chest is empty
if $game_temp.temp_chest.empty?
@spoils_window.active = false
@spoils_window.index = -1
@inv_window.active = true
end
@inv_window.refresh
@spoils_window.refresh
end
#--------------------------------------------------------------------------
# * Drops a number of the currently selected item
# n : the number of items to drop
#--------------------------------------------------------------------------
def drop_item(n)
# these must be determineed before the inventory and chest is modified
item_lost = true if n >= $game_party.item_number(@item)
reset_chest = $game_temp.temp_chest.empty? ? true : false
# modifying chest and inventory...
$game_party.lose_item(@item, n)
$game_temp.temp_chest.gain_item(@item, n, true)
@spoils_window.index = 0 if reset_chest
@inv_window.index -= 1 unless @inv_window.index == 0 || item_lost == false
@inv_window.refresh
@spoils_window.refresh
hide_drop_choice_window if !@drop_choice_window.nil?
end
#--------------------------------------------------------------------------
# * Takes all of the items from the chest an puts them in the player's
# inventory.
#--------------------------------------------------------------------------
def take_all
items = $game_temp.temp_chest.all_item_objects + $game_temp.temp_chest.all_dropped_objects
index = 0
for i in items
index += 1 # variable is required to use item_dropped? method
dropped = @spoils_window.item_dropped?(index)
$game_party.gain_item(i, $game_temp.temp_chest.item_number(i, dropped))
end
$game_temp.temp_chest.all_items = [-1]
$game_temp.temp_chest.all_dropped = [-1]
@inv_window.refresh
@spoils_window.refresh
@spoils_window.active = false
@spoils_window.index = -1
@inv_window.active = true
end
#--------------------------------------------------------------------------
# * Determines which action to take when a number is chosen from the number
# select window.
#--------------------------------------------------------------------------
def move_num_items
case @num_window.type
when -1
Print 'ERROR: @num_window\'s source has not been set!'
when 1
Sound.play_decision
leave_item(@num_window.number)
when 2
Sound.play_decision
take_item(@num_window.number)
when 3
Sound.play_drop
drop_item(@num_window.number)
end
end
#--------------------------------------------------------------------------
# * Determines whether it is possible for the player to exit
# If it is possible, then confirm_exit is called.
#--------------------------------------------------------------------------
def check_exit
f_item_names = [] # any items with the 'force' tag
for i in $game_temp.temp_chest.all_item_objects
f_item_names.push(i.name) if i.force_take?
end
if f_item_names != []
Sound.play_buzzer
show_message(5, f_item_names)
return true
end
if !ENCUMBER
if $game_party.total_inv_size <= $max_inv_size && $game_temp.temp_chest.total_size <= $game_temp.temp_chest.max_size
Sound.play_cancel
return confirm_exit
elsif $game_party.total_inv_size > $max_inv_size
Sound.play_buzzer
show_message(2)
return true
elsif $game_temp.temp_chest.total_size > $game_temp.temp_chest.max_size
if $game_temp.temp_chest.unlimited?
Sound.play_cancel
return confirm_exit
end
if !$game_temp.temp_chest.accessable?
Sound.play_cancel
return confirm_exit
end
Sound.play_buzzer
show_message(3)
return true
end
else
Sound.play_cancel
return confirm_exit
end
end
#--------------------------------------------------------------------------
# * Determines whether to show an exit window to player, and if so which one
#--------------------------------------------------------------------------
def confirm_exit
# these override the value of CONFIRMATION
if !CONF_EMPTY_CHEST && $game_temp.temp_chest.total_size == 0
Sound.play_cancel
do_exit
return true
elsif CONF_MODE_ZERO && $game_temp.temp_chest.mode == 0 && $game_temp.temp_chest.total_size != 0
show_exit_window(0)
else # if neither evaluate to true, check CONFIRMATION
case CONFIRMATION
when 0 # always
show_exit_window($game_temp.temp_chest.mode)
when 1 # never
Sound.play_cancel
do_exit
return true
when 2 # only if there are 'dropped' items
if $game_temp.temp_chest.all_dropped != [-1]
show_exit_window($game_temp.temp_chest.mode)
else
Sound.play_cancel
do_exit
return true
end
end
end
end
#--------------------------------------------------------------------------
# * Exits the scene, and makes modifications to the $chests hash as
# necessary
# exit : variable necessary if the player is exiting whilst
# over_encumbered. Since 2 exit windows are called, this is
# used to make sure the first checks the size of the inventory.
#--------------------------------------------------------------------------
def do_exit(exit = false)
unless exit
# this is because if ENCUMBER is true then two exit windows are called one
# after the other.
if $game_party.total_inv_size > $max_inv_size && ENCUMBER && INFORM_E_SPOILS
show_exit_window(3)
return
end
end
# empty chest if it is mode zero
if $game_temp.temp_chest.mode == 0
$game_temp.temp_chest.all_items = [-1]
$game_temp.temp_chest.active = false
end
# empty dropped items
$game_temp.temp_chest.all_dropped = [-1]
$game_temp.temp_chest.opened = true
if $game_temp.temp_chest.is_a?(Chest) && !@chest_id.nil?
# transfer temp_chets back to $chests hash
# This does not occur if the chest is B_Spoils object.
$chests[@chest_id] = $game_temp.temp_chest.deep_clone
end
$game_temp.temp_chest = nil
$scene = case @source
when 1: Scene_Map.new # from map
when 2: Scene_Menu.new # from menu
when 3: Scene_Map.new # from battle
end
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
@spoils_window.dispose
@spoils_title.dispose
@inv_window.dispose
@inv_title.dispose
@info_window.dispose
@drop_choice_window.dispose unless @drop_choice_window.nil?
@message_window.dispose unless @message_window.nil?
@exit_window.dispose unless @exit_window.nil?
@num_window.dispose unless @num_window.nil?
end
#--------------------------------------------------------------------------
# * Updates all the window objects
#--------------------------------------------------------------------------
def update_windows
@spoils_window.update
@spoils_title.update
@inv_window.update
@inv_title.update
@info_window.update
@drop_choice_window.update unless @drop_choice_window.nil?
@message_window.update unless @message_window.nil?
@exit_window.update unless @exit_window.nil?
@num_window.update unless @num_window.nil?
end
#--------------------------------------------------------------------------
# * Main frame update method
# Checks for input, and calls the appropriate sub-update method depending on
# which windows are open.
#--------------------------------------------------------------------------
def update
super
# for gold message delay...
@gold_counter = 0 if @gold_counter.nil?
if @inv_window.active || @spoils_window.active
if Input.trigger?(Input::B)
return if check_exit
elsif Input.trigger?(Input::LEFT)
move_left
elsif Input.trigger?(Input::RIGHT)
move_right
end
# checks for gold in chest
if $game_temp.temp_chest.gold != 0 && @gold_counter == GOLD_MSG_DEL
show_message(6, $game_temp.temp_chest.gold)
$game_party.gain_gold($game_temp.temp_chest.gold)
$game_temp.temp_chest.gold = 0
end
end
# window-dependant updates
if @inv_window.active # Inventory window
@item = @inv_window.item
@dropped = false
update_inv_item_selection if Input.trigger?(Input::C)
elsif @spoils_window.active # Spoils window
@item = @spoils_window.item
@dropped = @spoils_window.item_dropped?(@spoils_window.index)
det_move_item(2) if Input.trigger?(Input::C)
elsif !@message_window.nil? # Message window
if Input.trigger?(Input::C) or Input.trigger?(Input::B)
Sound.play_cancel
hide_message_window
end
elsif !@drop_choice_window.nil? # 'drop choice' window
update_drop_choice_window
elsif !@exit_window.nil? # exit confirmation window
return if update_exit_window
elsif !@num_window.nil? # number select window (drop, take or leave)
@num_window.update_num_selection
if Input.trigger?(Input::C)
Sound.play_decision
move_num_items
hide_num_window
elsif Input.trigger?(Input::B)
Sound.play_cancel
hide_num_window
end
end
# redefine @item and @dropped before update_infos is called
if @inv_window.active # Inventory window
@item = @inv_window.item
@dropped = false
elsif @spoils_window.active # Spoils window
@item = @spoils_window.item
@dropped = @spoils_window.item_dropped?(@spoils_window.index)
end
update_infos
update_windows
# for gold message delay...
@gold_counter += 1 unless @gold_counter >= GOLD_MSG_DEL
end
#--------------------------------------------------------------------------
# * Update exit window option selection
#--------------------------------------------------------------------------
def update_exit_window
if Input.trigger?(Input::B)
Sound.play_cancel
hide_exit_window
return false
elsif Input.trigger?(Input::C)
if @exit_window.index == 0
Sound.play_decision
exit = (@exit_window.type == 4)
hide_exit_window
# if it is the 2nd exit_window, then don't check encumberment
do_exit(exit)
return true
elsif @exit_window.index == 1
Sound.play_cancel
hide_exit_window
return false
end
end
end
#--------------------------------------------------------------------------
# * Update drop choice window option selection
#--------------------------------------------------------------------------
def update_drop_choice_window
if Input.trigger?(Input::B)
Sound.play_cancel
hide_drop_choice_window
elsif Input.trigger?(Input::C)
case @drop_choice_window.index
when 0 # leave item
unless $game_temp.temp_chest.accessable?
Sound.play_buzzer
unless NO_LEAVE_MSG == -1
hide_drop_choice_window
show_message(4)
end
return
end
det_move_item(1)
when 1 # drop item
det_move_item(3)
end
end
end
#--------------------------------------------------------------------------
# * Update inventory selection
#--------------------------------------------------------------------------
def update_inv_item_selection
if @item.nil?
Sound.play_buzzer
return
end
if @item.no_drop?
Sound.play_buzzer
show_message(1)
return
end
if ALLOW_SPOILS_DROP
Sound.play_decision
show_drop_choice_window(1)
else
unless $game_temp.temp_chest.accessable?
Sound.play_buzzer
show_message(4) unless NO_LEAVE_MSG == -1
return
end
det_move_item(1)
end
end
#--------------------------------------------------------------------------
# * Moves the cursor to the chest (if it isn't empty)
#--------------------------------------------------------------------------
def move_left
if $game_temp.temp_chest.empty?
Sound.play_buzzer
return
end
# don't play the sound if the player is already on the spoils window
Sound.play_cursor unless @spoils_window.active
@spoils_window.active = true
@inv_window.active = false
end
#--------------------------------------------------------------------------
# * Moves the cursor to the player's inventory (even if empty)
#--------------------------------------------------------------------------
def move_right
# don't play the sound if the player is already on the inventory window
Sound.play_cursor unless @inv_window.active
@spoils_window.active = false
@inv_window.active = true
end
#--------------------------------------------------------------------------
# Updates the information in the help windows
#--------------------------------------------------------------------------
def update_infos
# drawing the item's size and stack size
if !@item.nil? && @item != -1
str = ''
str += 'Item '+ITEM_SIZE_NAME+': %.1f'+SIZE_UNITS
str += ' (%.1f'+SIZE_UNITS+' in stack)'
if @inv_window.active
text = sprintf(str, @item.get_size.to_f / 10.0,
$game_party.item_number(@item)*@item.get_size.to_f / 10.0)
elsif @spoils_window.active
text = sprintf(str, @item.get_size,
$game_temp.temp_chest.item_number(@item, @dropped)*@item.get_size)
end
elsif @item == -1 # 'Take all' option selected
value = ($game_temp.temp_chest.total_size.to_f / 10.0).to_s
text = 'Total '+ITEM_SIZE_NAME+' of contents: '+value+SIZE_UNITS
else # if no item is selected (this should never occur)
text = NO_ITEM_TERM
end
@info_window.set_text(text, 0)
# creating Color object from the value in the settings module
over_size_colour = E_TEXT_COLOUR
over_size_colour = over_size_colour == -1 ? @info_window.normal_color : @info_window.text_color(over_size_colour) if !over_size_colour.is_a?(Color)
# inventory title
str = ''
str += WIN_ITEMS_HEAD == -1 ? Vocab.item : WIN_ITEMS_HEAD
str += ' (%.1f/%.1f'+SIZE_UNITS+')'
text = sprintf(str,
$game_party.total_inv_size.to_f / 10.0,
$max_inv_size.to_f / 10.0)
if $game_party.total_inv_size > $max_inv_size
@inv_title.set_text(text, 1, over_size_colour)
else
@inv_title.set_text(text, 1)
end
# spoils title
if @max_size != -1
str = ''
str += @spoils_head
str += ' (%.1f/%.1f'+SIZE_UNITS+')' if $game_temp.temp_chest.accessable? && !$game_temp.temp_chest.unlimited?
text = sprintf(str,
$game_temp.temp_chest.total_size.to_f / 10.0,
@max_size.to_f / 10.0)
else
text = @spoils_head
end
if $game_temp.temp_chest.total_size > $game_temp.temp_chest.max_size && $game_temp.temp_chest.accessable? && !$game_temp.temp_chest.unlimited?
@spoils_title.set_text(text, 1, over_size_colour)
else
@spoils_title.set_text(text, 1)
end
end
end
#==============================================================================
# ** Window_Spoils
#------------------------------------------------------------------------------
# The window on the left of Scene_Spoils. Has a similar interface to
# Window_Item, but operates on the different data structure of the DRIAC system.
#==============================================================================
class Window_Spoils < Window_Selectable
include Overlord_Dave::DRIACS::Data
#--------------------------------------------------------------------------
# * Object Initialisation
# x : The x-position of the window
# y : The y-position of the window
# width : The width of the window
# height : The height of the window
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 1
@chest = CHESTS['null_chest'].deep_clone
refresh
end
#--------------------------------------------------------------------------
# * Sets the new chest object of the window
# This will not function if the new object is not a Chest or B_Spoils
# value : new chest
#--------------------------------------------------------------------------
def chest=(value)
return if !value.is_a?(Chest) && !value.is_a?(B_Spoils)
@chest = value
refresh
end
#--------------------------------------------------------------------------
# * Determines whether an item at a certain index is a 'dropped' item
# index : the index of the window to check
#--------------------------------------------------------------------------
def item_dropped?(index)
start_index = 1
# finds where the list of dropped items begins
unless @chest.all_items == [-1]
for i in @chest.all_items
start_index += i.size unless i == [-1]
end
end
return (index >= start_index)
end
#--------------------------------------------------------------------------
# * Gets the item at the current window index
#--------------------------------------------------------------------------
def item
return -1 if @index == 0 # 'take all' option highlighted
range_min = 1
range_max = range_min
offset = 1
# The purpose of the 'offset' variable is so that index of the window can
# constantly increased, whilst the index used in each item array will always
# be between zero and the size of the array. It is increased by the size of
# the previous array after each check, and subtracted from the window index
# when accessing each array.
# checking weapons
unless @chest.all_items == [-1]
unless @chest.weapons == [-1]
size = @chest.weapons.size
range_max += size
# index will therefore only go up to the ammount of weapons present
if range_min <= @index && @index < range_max
return $data_weapons[@chest.weapons[@index-offset][0]]
end
# If nothing is found, then increase the minimum and offset and try the
# next item type
offset += size
range_min += size
end
# same for armours
unless @chest.armours == [-1]
size = @chest.armours.size
range_max += size
if range_min <= @index && @index < range_max
return $data_armors[@chest.armours[@index-offset][0]]
end
offset += size
range_min += size
end
# then items
unless @chest.items == [-1]
size = @chest.items.size
range_max += size
if range_min <= @index && @index < range_max
return $data_items[@chest.items[@index-offset][0]]
end
offset += size
range_min += size
end
end
# then again for dropped items, armours and weapons
unless @chest.all_dropped == [-1]
unless @chest.d_weapons == [-1]
size = @chest.d_weapons.size
range_max += size
if range_min <= @index && @index < range_max
return $data_weapons[@chest.d_weapons[@index-offset][0]]
end
offset += size
range_min += size
end
unless @chest.d_armours == [-1]
size = @chest.d_armours.size
range_max += size
if range_min <= @index && @index < range_max
return $data_armors[@chest.d_armours[@index-offset][0]]
end
offset += size
range_min += size
end
unless @chest.d_items == [-1]
size = @chest.d_items.size
range_max += size
if range_min <= @index && @index < range_max
return $data_items[@chest.d_items[@index-offset][0]]
end
end
end
end
#--------------------------------------------------------------------------
# * Redraws the window
#--------------------------------------------------------------------------
def refresh
create_contents
if @chest.empty?
self.contents.draw_text(0, 0, self.contents.width, WLH, SPOILS_EMPTY, 1)
return
end
i = 0
offset = 0
# this offset works in a similar way to the one in the 'item' method
# first draw 'take all' option
rect = item_rect(i)
self.contents.clear_rect(rect)
self.contents.draw_text(rect, TAKE_ALL_SPOILS, 1)
i += 1
offset += 1
# non dropped items first
unless @chest.all_items == [-1]
# drawing weapons first
unless @chest.weapons == [-1]
while i - offset < @chest.weapons.size
draw_item(i, 2, offset)
i += 1
end
offset += @chest.weapons.size
end
# then armours
unless @chest.armours == [-1]
while i - offset < @chest.armours.size
draw_item(i, 1, offset)
i += 1
end
offset += @chest.armours.size
end
# then items
unless @chest.items == [-1]
while i - offset < @chest.items.size
draw_item(i, 0, offset)
i += 1
end
offset += @chest.items.size
end
end
# then dropped weapons, armours then items
unless @chest.all_dropped == [-1]
unless @chest.d_weapons == [-1]
while i - offset < @chest.d_weapons.size
draw_item(i, 5, offset)
i += 1
end
offset += @chest.d_weapons.size
end
unless @chest.d_armours == [-1]
while i - offset < @chest.d_armours.size
draw_item(i, 4, offset)
i += 1
end
offset += @chest.d_armours.size
end
unless @chest.d_items == [-1]
while i - offset < @chest.d_items.size
draw_item(i, 3, offset)
i += 1
end
end
end
@item_max = i
end
#--------------------------------------------------------------------------
# * Draws an entry in the window
# index : the index to draw ar
# type : what type of item to draw (ie. weapon, armour etc...) (0-5)
# offset : the offset variable carried over from refresh. It is needed
# to draw a one index whilst accessing the item arrays at
# another.
#--------------------------------------------------------------------------
def draw_item(index, type, offset)
rect = item_rect(index)
self.contents.clear_rect(rect)
array = case type
when 0: @chest.items[index - offset].compact # items
when 1: @chest.armours[index - offset].compact # armours
when 2: @chest.weapons[index - offset].compact # weapons
when 3: @chest.d_items[index - offset].compact # dropped items
when 4: @chest.d_armours[index - offset].compact # dropped armours
when 5: @chest.d_weapons[index - offset].compact # dropped weapons
end
if !array.nil?
id = array[0]
number = array[1].nil? ? 1 : array[1]
item = case type
when 0,3: $data_items[id] # items
when 1,4: $data_armors[id] # armours
when 2,5: $data_weapons[id] # weapons
end
if MOD_FC_SPOILS && USE_SPOILS_COLOURS
if item.force_take?
colour = F_COLOUR
else
colour = NF_COLOUR
end
# if colour isn't a Color object, check if it's -1 or not.
colour = colour == -1 ? normal_color : text_color(colour) if !colour.is_a?(Color)
else colour = nil end
rect.width -= 4
if type > 2 # dropped items
old_item_name = item.name
# adding the customisable preffix and suffix to the item name
item.name = DROPPED_PRE+item.name+DROPPED_SUF
draw_item_name(item, rect.x, rect.y, !FADE_DROPPED)
item.name = old_item_name
else
draw_item_name(item, rect.x, rect.y, true, colour)
end
self.contents.draw_text(rect, sprintf(':%2d', number), 2)
end
end
end
#==============================================================================
# ** Window_Info
#------------------------------------------------------------------------------
# A simple window that displays a message (and stores a variable in return_to)
#==============================================================================
class Window_Info < Window_Base
attr_reader :return_to # where the window should exit to
#--------------------------------------------------------------------------
# * Object Initialisation
# message : the message to show
# return_to : the value of return_to
#--------------------------------------------------------------------------
def initialize(message, return_to)
super(0, 0, DIA_WIDTH, 50)
@message = message
@para = str_paragraph(@message, self.contents.width)
self.height = WLH*(@para.size+1)+5
self.x = (544 - self.width)/2.0
self.y = (416 - self.height)/2.0
self.back_opacity = 255
create_contents
draw_paragraph(0, -WLH*(@para.size-1)/2.0, self.contents.width, self.contents.height, @para, 1)
@return_to = return_to
end
end
#==============================================================================
# ** Window_List
#------------------------------------------------------------------------------
# Like Window_Info, but with a list of strings added after the message
#==============================================================================
class Window_List < Window_Base
attr_accessor :return_to # where the window should exit to
#--------------------------------------------------------------------------
# * Object Initialisation
# message : the message to show
# return_to : the value of return_to
# list : list of strings to add onto the end of the message
#--------------------------------------------------------------------------
def initialize(message, return_to, list)
super(0, 0, DIA_WIDTH, 50)
@message = message
@para = str_paragraph(@message, self.contents.width)
return if list.nil?
list.each {|i| @para.push(i) if i.is_a?(String)}
self.height = WLH*(@para.size+1)
self.x = (544 - self.width)/2.0
self.y = (416 - self.height)/2.0
self.back_opacity = 255
create_contents
draw_paragraph(0, -WLH*(@para.size-1)/2.0, self.contents.width, self.contents.height, @para, 1)
@return_to = return_to
end
end
#==============================================================================
# ** Window_Option
#------------------------------------------------------------------------------
# A custom window that displays a message and two options below it.
#==============================================================================
class Window_Option < Window_Selectable
attr_reader :type # the type of window
attr_accessor :return_to # where the window should exit to
#--------------------------------------------------------------------------
# * Object Initialisation
# message : the message to show
# opt1 : the first (top) option of the window
# opt2 : the second (bottom) option of the window
# type : the type of the window
#--------------------------------------------------------------------------
def initialize(message, opt1, opt2, type = 0)
@message = message
@opt1 = opt1
@opt2 = opt2
@para = str_paragraph(@message, DIA_WIDTH-32)
h = WLH*(@para.size+3)+16
super((544 - DIA_WIDTH)/2.0, (416 - h)/2.0, DIA_WIDTH, h)
@item_max = 2
@column_max = 1
@type = type
self.back_opacity = 255
draw_window
end
#--------------------------------------------------------------------------
# * Draws the window
# obj : and optional object to pass this method, which depending on the
# value of type will fade certain options
#--------------------------------------------------------------------------
def draw_window(obj = nil)
return if @type == -1 # don't draw window for some reason decided by user
self.contents = Bitmap.new(self.width-32, self.height-32)
self.contents.font.color.alpha = 255
opacity1 = 255
opacity2 = 255
# draw message
draw_paragraph(0, -WLH*(@para.size/2.0+1), self.contents.width, self.contents.height, @para)
# whether to fade certain options (depending on obj's properties)
unless obj.nil?
case @type
when 1 # from Scene_Item
opacity1 = $game_party.item_can_use?(obj) ? 255 : 128
opacity2 = obj.no_drop? ? 128 : 255
when 2 # from inv_window of Scene_Spoils
opacity1 = $game_temp.temp_chest.accessable? ? 255 : 128
opacity2 = obj.no_drop? ? 128 : 255
when 3 # from Scene_Shop
opacity1 = obj.price == 0 ? 128 : 255
opacity2 = obj.no_drop? ? 128 : 255
when 4 # reserved for over-encumbered window
# do nothing
end
end
self.contents.font.color.alpha = opacity1
self.contents.draw_text(0, WLH*@para.size, self.contents.width, WLH, @opt1, 1)
self.contents.font.color.alpha = opacity2
self.contents.draw_text(0, WLH*(@para.size+1), self.contents.width, WLH, @opt2, 1)
end
#--------------------------------------------------------------------------
# * The rectangle of each option
# index : the index to find the rectangle of
#--------------------------------------------------------------------------
def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = WLH
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = (index / @column_max + @para.size) * WLH
return rect
end
end
#==============================================================================
# ** Window_NumSelect
#------------------------------------------------------------------------------
# A custom number select window, that instead of selecting digits just changes
# by one each time, and also displays a message.
#==============================================================================
class Window_NumSelect < Window_Base
attr_reader :number # the currently selected number of the window
attr_accessor :type # the type of the window
#--------------------------------------------------------------------------
# * Object Initialisation
# message : the message to show
# type : the type of the window
#--------------------------------------------------------------------------
def initialize(message, type = -1)
@num_max = 1
@number = 1
@message = message
@type = type
super(0, 0, DIA_WIDTH, 50)
@para = str_paragraph(@message, self.contents.width)
draw_window
end
#--------------------------------------------------------------------------
# * Sets a new maximum number for the window
# value : the new maximum to set
#--------------------------------------------------------------------------
def num_max=(value)
@num_max = value
@number = 1
end
#--------------------------------------------------------------------------
# * Draws the window
#--------------------------------------------------------------------------
def draw_window
self.height = WLH*(@para.size+2)+16
self.x = (544 - self.width)/2.0
self.y = (416 - self.height)/2.0
create_contents
draw_paragraph(0, -WLH/2.0, self.contents.width, self.contents.height, @para)
self.contents.draw_text(0, WLH*@para.size, self.contents.width, WLH, @number.to_s)
end
#--------------------------------------------------------------------------
# * Updates the value of number, listening for keyboard input from the player
#--------------------------------------------------------------------------
def update_num_selection
if Input.trigger?(Input::UP)
Sound.play_cursor
@number = (@number + 1) > @num_max ? 1 : @number + 1
draw_window
elsif Input.trigger?(Input::DOWN)
Sound.play_cursor
@number = (@number - 1) < 1 ? @num_max : @number - 1
draw_window
end
end
end
#==============================================================================
# ** Window_InvInfo
#------------------------------------------------------------------------------
# This is a window common to Scene_Item and Scene_Shop, that displays info about
# the selected item on one side and the entire inventory on the other.
#==============================================================================
class Window_InvInfo < Window_Help
#--------------------------------------------------------------------------
# * Object Initialisation
# y : the y-position of the window on the screen
#--------------------------------------------------------------------------
def initialize(y)
super()
self.y = y
create_contents
end
#--------------------------------------------------------------------------
# * Draws the window
# item : the item to display information about
# n : the number of this item
# num_select : whether the currently active window is the number select
# window from Scene_Shop
#--------------------------------------------------------------------------
def refresh_window(item = nil, n = -1, num_select = false)
self.contents.clear
self.contents.font.color = normal_color
# drawing left hand side
if item == nil
text = NO_ITEM_TERM
elsif num_select # from number_select window in Scene_Shop
str = 'Total selected: %.1f'+SIZE_UNITS
text = sprintf(str, item.get_size*n.to_f / 10.0)
else
if n != -1
str = 'Item: %.1f'+SIZE_UNITS+' (%.1f'+SIZE_UNITS+' in stack)'
text = sprintf(str, item.get_size.to_f / 10.0, n*item.get_size.to_f / 10.0)
else
str = 'Item '+ITEM_SIZE_NAME+': %.1f'+SIZE_UNITS
text = sprintf(str, item.get_size.to_f / 10.0)
end
end
self.contents.draw_text(4, 0, self.width - 40, WLH, text)
# drawing right-hand side
term = INV_FULL_NAME == -1 ? Vocab.item : INV_FULL_NAME
str = term+': %.1f/%.1f'+SIZE_UNITS
text = sprintf(str, $game_party.total_inv_size.to_f / 10.0, $max_inv_size.to_f / 10.0)
if $game_party.total_inv_size > $max_inv_size
colour = E_TEXT_COLOUR
# if E_TEXT_COLOUR isn't a colour object, check if it's -1 or not.
colour = colour == -1 ? normal_color : text_color(colour) if !colour.is_a?(Color)
self.contents.font.color = colour
end
self.contents.draw_text((self.width - 40)/2.0, 0, (self.width - 40)/2.0, WLH, text, 2)
end
end
# ==============================================================================
# ==============================================================================
# ========================== SCENE_ITEM MODIFICATIONS ==========================
# ==============================================================================
# ==============================================================================
# Classes modified: Window_Item, Scene_Item
# Scene_Shop modifications are later in the script.
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#------------------------------------------------------------------------------
# Methods overriden: draw_item
# Methods aliased: intialize, update_help, enable?
# New methods: spoils_scene?, @stats_window accessor
#==============================================================================
class Window_Item < Window_Selectable
attr_writer :stats_window # accessor to new window
# ----------------------------------------------------------------------------
# Window_Item.initialize
# ----------------------------------------------------------------------------
# Added arguments:
# spoils_scene : determines whether the window is in the spoils scene or
# not
# Added functionality:
# intialises @spoils_scene variable
# ----------------------------------------------------------------------------
alias ye_olde_window_item_initialize_DRIACS initialize
def initialize(x, y, width, height, spoils_scene = false)
ye_olde_window_item_initialize_DRIACS(x, y, width, height)
@spoils_scene = spoils_scene
end
# added getter method
def spoils_scene?; return @spoils_scene end
# ----------------------------------------------------------------------------
# ALIASED Window_Item.update_help
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# refreshes the new 'stats_window' that this class now contains.
# ----------------------------------------------------------------------------
alias ye_olde_window_item_update_help_DRIACS update_help
def update_help
ye_olde_window_item_update_help_DRIACS
# standard update help for Scene_Item
n = $game_party.item_number(self.item)
@stats_window.refresh_window(self.item, n) unless @stats_window.nil?
end
# ----------------------------------------------------------------------------
# ALIASED Window_Item.enable?
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Determines whether an item should be enabled based on new settings in
# the settings module
# ----------------------------------------------------------------------------
alias ye_olde_window_item_enable_DRIACS enable?
def enable?(item)
# these determine all the fade options from the settings module
if !spoils_scene?
return ye_olde_window_item_enable_DRIACS(item) if !MOD_FADE_COLOUR || $game_temp.in_battle
if GREEDY_FADE
return false if !$game_party.item_can_use?(item) && item.no_drop?
return true
end
return $game_party.item_can_use?(item) if FADE_NU_ITEMS
return false if FADE_ND_ITEMS && item.no_drop?
else
# if it is in Scene_Spoils then different settings are used.
return ye_olde_window_item_enable_DRIACS(item) if !MOD_FC_SPOILS
c = $game_temp.temp_chest
if GREEDY_FADE_SPOILS
return false if !c.accessable? && item.no_drop?
return true
end
return false if FADE_ND_ITEMS_SPOILS && item.no_drop?
return accessable? if FADE_NL_ITEMS_SPOILS
end
return true
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Window_Item.draw_item
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Changes the colour of the item text depending on settings in the
# settings module.
# ----------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if !item.nil?
number = $game_party.item_number(item)
enabled = enable?(item)
# added colour options
if MOD_FADE_COLOUR
if !spoils_scene? && USE_COLOURS
if $game_party.item_can_use?(item)
colour = item.no_drop? ? U_ND_COLOUR : U_D_COLOUR
else
colour = item.no_drop? ? NU_ND_COLOUR : NU_D_COLOUR
end
colour = colour == -1 ? normal_color : text_color(colour) if !colour.is_a?(Color)
end
elsif MOD_FC_SPOILS
if spoils_scene? && USE_SPOILS_COLOURS
if item.no_drop?
colour = ND_COLOUR
else
colour = $game_temp.temp_chest.accessable ? M_D_COLOUR : NM_D_COLOUR
end
# usual colour logic...
colour = colour == -1 ? normal_color : text_color(colour) if !colour.is_a?(Color)
end
else colour = nil end
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enabled, colour)
self.contents.draw_text(rect, sprintf(':%2d', number), 2)
end
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen processing.
#------------------------------------------------------------------------------
# Methods overriden: update, update_item_selection
# Methods aliased: start, show_target_window, terminate
# New methods: hide_option_window, show_option_window, show_drop_window,
# hide_drop_window, update_num_drop, update_option_selection,
# drop_item
#==============================================================================
class Scene_Item < Scene_Base
include Overlord_Dave::DRIACS::Settings
# ----------------------------------------------------------------------------
# ALIASED Scene_Item.start
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# repositioning all windows
# creating new 'stats_window', 'option_window' and 'drop_window'
# ----------------------------------------------------------------------------
alias ye_olde_scene_title_start_DRIACS start
def start
ye_olde_scene_title_start_DRIACS
case ITEM_INFO_POS
when 0
h_window_y = 56
s_window_y = 0
i_window_y = Window_Base::WLH+88
when 1
h_window_y = 0
s_window_y = 56
i_window_y = Window_Base::WLH+88
when 2
h_window_y = 0
s_window_y = 360
i_window_y = 56
end
@stats_window = Window_InvInfo.new(s_window_y)
@stats_window.viewport = @viewport
@help_window.y = h_window_y
@option_window = Window_Option.new('', USE_ITEM_OPT1, USE_ITEM_OPT2, 1)
hide_option_window
@drop_window = Window_NumSelect.new(DROP_ITEM_MSG)
hide_drop_window
# recreate item window lower
@item_window = Window_Item.new(0, i_window_y, 544, 328-Window_Base::WLH)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.stats_window = @stats_window
@item_window.active = false
hide_target_window
end
# ----------------------------------------------------------------------------
# ALIASED Scene_Item.show_target_window
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# makes the new 'option_window' also inactive and invisible
# ----------------------------------------------------------------------------
alias ye_olde_show_target_window_DRIACS show_target_window
def show_target_window(right)
@option_window.visible = false
@option_window.active = false
ye_olde_show_target_window_DRIACS(right)
end
#--------------------------------------------------------------------------
# * Hides the option window
#--------------------------------------------------------------------------
def hide_option_window
@option_window.index = -1
@option_window.visible = false
@option_window.active = false
@item_window.active = true
end
#--------------------------------------------------------------------------
# * Shows the option window
#--------------------------------------------------------------------------
def show_option_window
@option_window.index = 0
@option_window.active = true
@option_window.visible = true
@option_window.draw_window(@item)
@item_window.active = false
@target_window.visible = false
@target_window.active = false
end
#--------------------------------------------------------------------------
# * Hides the drop window
#--------------------------------------------------------------------------
def hide_drop_window
@drop_window.visible = false
@item_window.active = true
end
#--------------------------------------------------------------------------
# * Shows the drop window
# num_max : the maximum number for the drop window
#--------------------------------------------------------------------------
def show_drop_window(num_max)
@option_window.active = false
@option_window.visible = false
@drop_window.visible = true
@drop_window.num_max = num_max
@drop_window.draw_window
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Scene_Item.update
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# called the new windows' 'update' method
# added the new windows scene update methods to the if-else statement
# ----------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_window.update
@target_window.update
@stats_window.update
@option_window.update
if @item_window.active
update_item_selection
elsif @option_window.active
update_option_selection
elsif @drop_window.visible
update_num_drop
elsif @target_window.active
update_target_selection
end
end
#--------------------------------------------------------------------------
# * OVERRIDDEN Scene_Item.update_target_selection
#--------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Hides target window when all of an item has been used up.
# ----------------------------------------------------------------------------
def update_target_selection
if Input.trigger?(Input::B)
Sound.play_cancel
if $game_party.item_number(@item) == 0 # If item is used up
@item_window.refresh # Recreate the window contents
end
hide_target_window
elsif Input.trigger?(Input::C)
if not $game_party.item_can_use?(@item)
Sound.play_buzzer
else
determine_target
# check the item wasn't used up
if $game_party.item_number(@item) == 0
hide_target_window
@item_window.index -= 1 unless @item_window.index == 0
@item_window.refresh
end
end
end
end
#--------------------------------------------------------------------------
# * Updates the player's action when the num drop window is active
#--------------------------------------------------------------------------
def update_num_drop
@drop_window.update_num_selection
if Input.trigger?(Input::B)
Sound.play_cancel
hide_drop_window
elsif Input.trigger?(Input::C)
drop_item(@drop_window.number)
hide_drop_window
end
end
# ----------------------------------------------------------------------------
# * Determines the action to be taken when the player chooses an option from
# the option window.
# ----------------------------------------------------------------------------
def update_option_selection
if Input.trigger?(Input::B)
Sound.play_cancel
hide_option_window
elsif Input.trigger?(Input::C)
case @option_window.index
when 0 # use item
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
# check the player hasn't used up all of the item
if $game_party.item_number(@item) == 0
hide_option_window
@item_window.index -= 1 unless @item_window.index == 0
@item_window.refresh
end
else
Sound.play_buzzer
end
when 1 # drop item
if @item.no_drop?
Sound.play_buzzer
else
case SHOW_DROP_ITEM
when 0 # never
drop_item(1)
hide_option_window
when 1 # more than 1 item in stack
if $game_party.item_number(@item) > 1
Sound.play_decision
show_drop_window($game_party.item_number(@item))
else
drop_item(1)
hide_option_window
end
when 2 # always
Sound.play_decision
show_drop_window($game_party.item_number(@item))
end
end
end
end
end
# ----------------------------------------------------------------------------
# * Drop the selected item
# num : number of the item to drop
# ----------------------------------------------------------------------------
def drop_item(num)
Sound.play_drop
item_lost = false
if num >= $game_party.item_number(@item)
item_lost = true
end
$game_party.lose_item(@item, num)
@item_window.index -= 1 unless item_lost == false || @item_window.index == 0
@item_window.refresh
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Scene_Item.update_item_selection
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Prevents the player leaving if they are over-encumbered
# If an item is selected opens the option window.
# ----------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
if $game_party.total_inv_size > $max_inv_size && !ENCUMBER
# prevent player exiting if they are over-encumbered
Sound.play_buzzer
return
end
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
return if @item.nil?
$game_party.last_item_id = @item.id
Sound.play_decision
show_option_window
end
end
# ----------------------------------------------------------------------------
# ALIASED Scene_Item.terminate
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# terminates new windows
# ----------------------------------------------------------------------------
alias ye_olde_scene_item_terminate_DRIACS terminate
def terminate
ye_olde_scene_item_terminate_DRIACS
@stats_window.dispose
@option_window.dispose
@drop_window.dispose
end
end
# ==============================================================================
# ==============================================================================
# ========================== SCENE_SHOP MODIFICATIONS ==========================
# ==============================================================================
# ==============================================================================
# Classes modified: Window_ShopStatus, Window_ShopBuy, Window_ShopSell,
# Scene_Shop
#==============================================================================
# ** Window_ShopStatus
#------------------------------------------------------------------------------
# This window displays number of items in possession and the actor's equipment
# on the shop screen.
#------------------------------------------------------------------------------
# Methods overriden: refresh
# Methods aliased: [none]
# New methods: [none]
#==============================================================================
class Window_ShopStatus < Window_Base
# ----------------------------------------------------------------------------
# OVERRIDDEN Window_ShopStatus.refresh
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# see comment
# ----------------------------------------------------------------------------
def refresh
self.contents.clear
if !@item.nil?
number = $game_party.item_number(@item)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 200, WLH, number, 2)
for actor in $game_party.members
x = 4
y = WLH * (1 + actor.index * 2) # changed from '2 +' to '1 +' in order
# to shorten status window
draw_actor_parameter_change(actor, x, y)
end
end
end
end
#==============================================================================
# ** Window_ShopBuy
#------------------------------------------------------------------------------
# This window displays buyable goods on the shop screen.
#------------------------------------------------------------------------------
# Methods overriden: draw_item
# Methods aliased: update_help
# New methods: [none]
#==============================================================================
class Window_ShopBuy < Window_Selectable
attr_accessor :stats_window # accessor to new window
# ----------------------------------------------------------------------------
# ALIASED Window_ShopBuy.update_help
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# refreshes new 'stats_window'
# ----------------------------------------------------------------------------
alias ye_olde_window_shopbuy_update_help_DRIACS update_help
def update_help
ye_olde_window_shopbuy_update_help_DRIACS
# similar to Window_Item.update_help, but not including the number of items
@stats_window.refresh_window(self.item) unless @stats_window.nil?
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Window_ShopBuy.draw_item
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# modifies the colour of the item text depending on values in the settings
# module
# ----------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
number = $game_party.item_number(item)
enabled = (item.price <= $game_party.gold and number < 99)
rect = item_rect(index)
self.contents.clear_rect(rect)
# added colour options
if MOD_FADE_COLOUR
unless !USE_COLOURS
if $game_party.item_can_use?(item)
colour = U_ND_COLOUR if item.no_drop?
colour = U_D_COLOUR if !item.no_drop?
else
colour = NU_ND_COLOUR if item.no_drop?
colour = NU_D_COLOUR if !item.no_drop?
end
end
colour = colour == -1 ? normal_color : text_color(colour) if !colour.is_a?(Color)
else colour = nil end
draw_item_name(item, rect.x, rect.y, enabled, colour)
rect.width -= 4
self.contents.draw_text(rect, item.price, 2)
end
end
#==============================================================================
# ** Window_ShopSell
#------------------------------------------------------------------------------
# This window displays items in possession for selling on the shop screen.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: enable?
# New methods: [none]
#==============================================================================
class Window_ShopSell < Window_Item
# ----------------------------------------------------------------------------
# ALIASED Window_ShopSell.enable?
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Determines whether an item should be enabled based on new settings in
# the settings module
# ----------------------------------------------------------------------------
alias ye_olde_window_shopsell_enable_DRIACS enable?
def enable?(item)
# fade options as defined in settings module
return ye_olde_window_shopsell_enable_DRIACS(item) if !MOD_FADE_COLOUR
if GREEDY_FADE_SHOP
return false if (item.price <= 0) && item.no_drop?
return true
end
return (item.price > 0) if FADE_NS_ITEMS_SHOP
return false if FADE_ND_ITEMS_SHOP && item.no_drop? && ALLOW_SHOP_DROP
return true
end
end
#==============================================================================
# ** Scene_Shop
#------------------------------------------------------------------------------
# This class performs shop screen processing.
#------------------------------------------------------------------------------
# Methods overriden: update, update_buy_selection, update_sell_selection
# Methods aliased: start, decide_number_input, terminate
# New methods: show_message, hide_message_window, show_option_window,
# hide_option_window, show_drop_window, hide_drop_window,
# drop_item, update_option_window, update_drop_window
#==============================================================================
class Scene_Shop < Scene_Base
include Overlord_Dave::DRIACS::Settings
# ----------------------------------------------------------------------------
# ALIASED Scene_Shop.start
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Repositions existing windows
# creates new 'info window'
# ----------------------------------------------------------------------------
alias ye_olde_scene_shop_start_DRIACS start
def start
ye_olde_scene_shop_start_DRIACS
# default values
command_y = 56
help_y = 0
main_y = 112
info_y = -1
case SHOP_INFO_POS
when 0 # very top
command_y = 112
help_y = 56
main_y = 168
info_y = 0
when 1 # just below description
command_y = 112
help_y = 0
main_y = 168
info_y = 56
when 2 # just below command window
command_y = 56
help_y = 0
main_y = 168
info_y = 112
when 3 # very bottom
command_y = 56
help_y = 0
main_y = 112
info_y = 360
end
main_h = 248
# new info window
@info_window = Window_InvInfo.new(info_y)
@info_window.refresh_window
# repositioning/resizing windows
@command_window.y = command_y
@gold_window.y = command_y
@help_window.y = help_y
@dummy_window.y = main_y
@dummy_window.height = main_h
@dummy_window.create_contents
@buy_window.y = main_y
@buy_window.height = main_h
@buy_window.create_contents
@buy_window.stats_window = @info_window
@sell_window.y = main_y
@sell_window.height = main_h
@sell_window.stats_window = @info_window
@number_window.y = main_y
@number_window.height = main_h
@number_window.create_contents
@status_window.y = main_y
@status_window.height = main_h
@status_window.create_contents
end
#--------------------------------------------------------------------------
# * Makes the message window appear
# type : the message window to display (1-2)
#--------------------------------------------------------------------------
def show_message(type)
@message_window = case type
when 1: Window_Info.new(SHOP_SPACE_MSG,1) # not enough space for item (from buy_window)
when 2: Window_Info.new(E_MSG_SHOP, 1) # the player has become over-encumbered
end
@message_window.visible = true
@buy_window.active = false
@sell_window.active = false
end
#--------------------------------------------------------------------------
# * Makes the message window disappear
#--------------------------------------------------------------------------
def hide_message_window
return if @message_window.nil?
case @message_window.return_to
when 1 # to the buy window
@buy_window.active = true
when 2 # the sell window
@sell_window.active = true
end
@message_window.dispose
@message_window = nil
end
#--------------------------------------------------------------------------
# * Makes the option window appear (to sell or drop)
#--------------------------------------------------------------------------
def show_option_window
@option_window = Window_Option.new('', SELL_ITEM_OPT1, SELL_ITEM_OPT2, 3)
@option_window.draw_window(@item)
@option_window.visible = true
@option_window.index = 0
@option_window.active = true
@sell_window.active = false
end
#--------------------------------------------------------------------------
# * Makes the option window disappear
#--------------------------------------------------------------------------
def hide_option_window
@option_window.dispose
@option_window = nil
@sell_window.active = true
end
#--------------------------------------------------------------------------
# * Makes the drop window appear, to choose how many items to drop
#--------------------------------------------------------------------------
def show_drop_window(num_max)
@option_window.dispose
@option_window = nil
@drop_window = Window_NumSelect.new(DROP_ITEM_MSG)
@drop_window.num_max = num_max
@drop_window.draw_window
end
#--------------------------------------------------------------------------
# * Makes the drop window disappear
#--------------------------------------------------------------------------
def hide_drop_window
@drop_window.dispose
@drop_window = nil
@sell_window.active = true
end
#--------------------------------------------------------------------------
# * Drops a number of the selected item
# num : the number of this item to drop
#--------------------------------------------------------------------------
def drop_item(num)
Sound.play_drop
# must be determineed before inventory is modified
item_lost = num >= $game_party.item_number(@item) ? true : false
# modifying inventory...
$game_party.lose_item(@item, num)
@sell_window.index -= 1 unless !item_lost || @sell_window.index == 0
@sell_window.refresh
end
# ----------------------------------------------------------------------------
# ALIASED Scene_Shop.decide_number_input
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# If the player has become encumbered, show a message for it
# ----------------------------------------------------------------------------
alias ye_olde_scene_shop_decide_number_input_DRIACS decide_number_input
def decide_number_input
ye_olde_scene_shop_decide_number_input_DRIACS
return if !ENCUMBER
show_message(2) if $game_party.total_inv_size > $max_inv_size && INFORM_E_SHOP
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Scene_Shop.update
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# calls the new windows' 'update' method
# adds the new window's selction update methods to the if-else satement
# ----------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
@info_window.update
@message_window.update unless @message_window.nil?
@option_window.update unless @option_window.nil?
@drop_window.update unless @drop_window.nil?
if @command_window.active
@info_window.refresh_window
update_command_selection
elsif @buy_window.active
update_buy_selection
elsif @sell_window.active
update_sell_selection
elsif @number_window.active
update_number_input
@info_window.refresh_window(@item, @number_window.number, true)
elsif !@message_window.nil?
if Input.trigger?(Input::C) || Input.trigger?(Input::B)
Sound.play_cancel
hide_message_window
end
elsif !@option_window.nil?
update_option_window
elsif !@drop_window.nil?
update_drop_window
end
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Scene_Shop.update_buy_selection
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Prevents the number window appearing if one item would encumber the
# player
# Sets the maximum of the number window depending on how many items the
# player can fit in their inventory
# ----------------------------------------------------------------------------
def update_buy_selection
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text('')
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
number = $game_party.item_number(@item)
if @item.nil? or @item.price > $game_party.gold or number == 99
Sound.play_buzzer
elsif ($game_party.total_inv_size + @item.get_size) > $max_inv_size && !ENCUMBER
# if one of the item will make the player over-encumbered, don't buy
Sound.play_buzzer
show_message(1) unless SHOP_SPACE_MSG == -1
else
Sound.play_decision
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
size_max = 100
# retrict by item size (unless ENCUMBER is true)
unless ENCUMBER
size_max = @item.get_size == 0 ? 99 : ($max_inv_size-$game_party.total_inv_size) / @item.get_size
end
max = [max, 99 - number].min
max = [max, size_max].min
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
# ----------------------------------------------------------------------------
# OVERRIDDEN Scene_Shop.update_sell_selection
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functions:
# prevents the player selling an item if it cannot be dropped
# shows the option window if ALLOW_SHOP_DROP is true
# ----------------------------------------------------------------------------
def update_sell_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
@help_window.set_text('')
elsif Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
if @item.nil? or @item.price == 0 || @item.no_drop?
Sound.play_buzzer
else
Sound.play_decision
if ALLOW_SHOP_DROP
show_option_window
else
max = $game_party.item_number(@item)
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
end
end
#--------------------------------------------------------------------------
# * Updates option window selection
#--------------------------------------------------------------------------
def update_option_window
if Input.trigger?(Input::B)
Sound.play_cancel
hide_option_window
elsif Input.trigger?(Input::C)
case @option_window.index
when 0 # sell selected
if @item.price == 0
Sound.play_buzzer
return
end
hide_option_window
max = $game_party.item_number(@item)
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
when 1 # drop selected
if @item.no_drop?
Sound.play_buzzer
return
end
if @item.no_drop?
Sound.play_buzzer
else
case SHOW_DROP_ITEM
when 0 # never
drop_item(1)
hide_option_window
when 1 # more than 1 item in stack
if $game_party.item_number(@item) > 1
Sound.play_decision
show_drop_window($game_party.item_number(@item))
else
drop_item(1)
hide_option_window
end
when 2 # always
Sound.play_decision
show_drop_window($game_party.item_number(@item))
end
end
end
end
end
#--------------------------------------------------------------------------
# * Updates drop window number selection
#--------------------------------------------------------------------------
def update_drop_window
@drop_window.update_num_selection
if Input.trigger?(Input::B)
Sound.play_cancel
hide_drop_window
elsif Input.trigger?(Input::C)
drop_item(@drop_window.number)
hide_drop_window
end
end
# ----------------------------------------------------------------------------
# ALIASED Scene_Shop.terminate
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functions:
# disposes the new windows
# ----------------------------------------------------------------------------
alias ye_olde_scene_shop_terminate_DRIACS terminate
def terminate
ye_olde_scene_shop_terminate_DRIACS
@info_window.dispose
@message_window.dispose unless @message_window.nil?
@option_window.dispose unless @option_window.nil?
end
end
#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
# The RGSS2 class that contains basic item data
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: get_size, force_take?, no_drop?
#==============================================================================
module RPG
class BaseItem
#--------------------------------------------------------------------------
# * gets the size of the item from the Note section in the database
#--------------------------------------------------------------------------
def get_size
return 0 if !(@note =~ /<size=\d+>/)
s = $&.gsub(/[<>]/, '').split(/=/)[1].to_i
return (s < 1 ? 0 : s)
end
#--------------------------------------------------------------------------
# * Finds whether the item has the <forced> tag
#--------------------------------------------------------------------------
def force_take?
return @note =~ /<force>/
end
#--------------------------------------------------------------------------
# * Finds whether the item has the <no_drop> tag
#--------------------------------------------------------------------------
def no_drop?
return @note =~ /<no_drop>/
end
end
end
#==============================================================================
# ** Sound
#------------------------------------------------------------------------------
# The RGSS2 module that controls in-game sounds
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: play_drop
#==============================================================================
module Sound
#--------------------------------------------------------------------------
# * The sound to play when an item is dropped
#--------------------------------------------------------------------------
def self.play_drop
self.play_equip
end
end
#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs the title screen processing.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: create_game_objects
# New methods: [none]
#==============================================================================
class Scene_Title < Scene_Base
include Overlord_Dave::DRIACS::Settings
# ----------------------------------------------------------------------------
# ALIASED Scene_Title.create_game_objects
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# creates $max_inv_size and the $chests hash
# ----------------------------------------------------------------------------
alias ye_olde_create_objects_DRIACS create_game_objects
def create_game_objects
ye_olde_create_objects_DRIACS
# the max size of the inventory
$max_inv_size = INT_MAX_SIZE
# the game's chest objects
$chests = {}
end
end
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: write_save_data, read_save_data
# New methods: [none]
#==============================================================================
class Scene_File < Scene_Base
# ----------------------------------------------------------------------------
# ALIASED Scene_File.write_save_data
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# saves the values of $max_inv_size and $chests
# ----------------------------------------------------------------------------
alias ye_olde_write_data_DRIACS write_save_data
def write_save_data(file)
ye_olde_write_data_DRIACS(file)
Marshal.dump($max_inv_size, file)
Marshal.dump($chests, file)
end
# ----------------------------------------------------------------------------
# ALIASED Scene_File.write_save_data
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# loads the values of $max_inv_size and $chests
# ----------------------------------------------------------------------------
alias ye_olde_read_data_DRIACS read_save_data
def read_save_data(file)
ye_olde_read_data_DRIACS(file)
$max_inv_size = Marshal.load(file)
$chests = Marshal.load(file)
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: clear_chest, reset_chest, update_chests, disable_encumber,
# enable_encumber, use_enc?, init_battle_spoils, add_to_chest,
# check_item, remote_open_chest
#==============================================================================
class Game_System
include Overlord_Dave::DRIACS::Data
#--------------------------------------------------------------------------
# * Completely empties a chest in the $chests hash
# chest_id : the unique id of the chest to empty
#--------------------------------------------------------------------------
def clear_chest(chest_id)
if !$chests[chest_id].nil?
$chests[chest_id].all_items = [-1]
end
end
#--------------------------------------------------------------------------
# * Resets a chest to one from the CHESTS hash. The chest must have been
# opened before hand.
# chest_id : the unique id of the chest to reset
# chest_name : the id of the chest from CHESTS to reset it to
#--------------------------------------------------------------------------
def reset_chest(chest_id, chest_name)
if !$chests[chest_id].nil? && !CHESTS[chest_name].nil?
$chests[chest_id] = CHESTS[chest_name].deep_clone
end
end
#--------------------------------------------------------------------------
# * Empties mode 1 chests in the selected maps
# maps : and array of any non-zero length of map ids
#--------------------------------------------------------------------------
def update_chests(maps)
for i in 0...maps.size
# replace all instances of -1 with the current map id
maps[i] = $game_map.map_id if maps[i] == -1
end
for c in $chests
chest = c[1]
chest.all_items = [-1] if maps.include?(chest.map_id) && chest.mode == 1
end
end
#--------------------------------------------------------------------------
# * Enables movement reduction from encumberment
#--------------------------------------------------------------------------
def disable_encumber; @enc = false end
#--------------------------------------------------------------------------
# * Disables movement reduction from encumberment
#--------------------------------------------------------------------------
def enable_encumber; @enc = true end
#--------------------------------------------------------------------------
# * Finds whether encumberment has been disabled or not
#--------------------------------------------------------------------------
def use_enc?
return true if @enc.nil?
return @enc
end
#--------------------------------------------------------------------------
# * Starts Scene_Spoils after a battle
# spoil_objects : this can be a single id or array of ids that
# correspond to the object in the SPOILS hash to open
#--------------------------------------------------------------------------
def init_battle_spoils(spoil_objects)
if spoil_objects.is_a?(Array)
# choose one randomly
n = rand(spoil_objects.size)
spoil_id = spoil_objects[n]
# for error message
old_objects = spoil_objects.to_s
# if it isn't found, keep choosing until one is...
unless SPOILS.include(spoil_id)
until SPOILS.include(spoil_id)
# ... deleting the not-found one each time
spoil_objects.delete_at(n)
spoil_objects.compact
if spoil_object.size == 0
print 'ERROR: no matches in the SPOILS hash for these ids: \n'+old_objects
break
end
n = rand(spoil_objects.size)
spoil_id = spoil_objects[n]
end
end
else
spoil_id = spoil_objects
if !SPOILS.include?(spoil_id)
print 'ERROR: no spoils exists in the SPOILS hash with id: '+spoil_id
return
end
end
$game_temp.temp_chest = SPOILS[spoil_id].deep_clone
$game_temp.temp_chest.add_from_item_table
$scene = Scene_Spoils.new(3, $game_temp.temp_chest.name)
end
#--------------------------------------------------------------------------
# * Initialises a chest without the player opening it.
# chest_id : the unique id of the chest to create
# chest_base : the id of the chest from CHESTS to create it from
# map_id : the map_id to assigne the chest (-1 indicates current
# map
#--------------------------------------------------------------------------
def remote_open_chest(chest_id, chest_base, map_id)
if !CHESTS[chest_base].nil? && $chests[chest_id].nil?
$chests[chest_id] = CHESTS[chest_base].deep_clone
$chests[chest_id].add_from_item_table
$chests[chest_id].map_id = map_id == -1 ? $game_map.map_id : map_id
end
end
#--------------------------------------------------------------------------
# * Adds one or more of a single item/wepon/armour/gold to a chest
# chest_id: the id of the unique chest to add the item to
# item_code: the item code of the item to add in the same format as when
# creating base chests (ie. n*m or gn).
#--------------------------------------------------------------------------
def add_to_chest(chest_id, item_code)
chest = $chests[chest_id]
return if chest.nil?
$chests[chest_id].add_items_from_code(item_code)
end
#--------------------------------------------------------------------------
# * Checks how many of an item are in a chest; will return zero if none exist
# chest_id: the id of the unique chest to add the item to
# item_code: the item code of the item to check for, in the same format
# as when creating base chests, but without the number of
# items (ie. tm), or, for gold, g. ONLY A SINGLE ITEM CAN BE
# CHECKED FOR.
#--------------------------------------------------------------------------
def check_item(chest_id, item_code)
chest = $chests[chest_id]
return -1 if chest.nil?
# check first for gold
return chest.gold if item_code == 'g'
# get item info
info = Chest.get_info_from_code(item_code)
# read info
item_type = info[0]
n = info[1]
item_id = info[2]
# get the correct array
array = case item_type
when 0: chest.items # item
when 1: chest.armours # armour
when 2: chest.weapons # weapon
end
# cycle through each item, and then if it exists get the number
array.each {|i| (n = i[1].nil? ? 1 : i[1]) if i[0] == item_id}
return n
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: initialize
# New methods: temp_chest accessor
#==============================================================================
class Game_Temp
attr_accessor :temp_chest
# ----------------------------------------------------------------------------
# ALIASED Game_Temp.initialize
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# creates an initial value for the @temp_chest variable
# ----------------------------------------------------------------------------
alias ye_olde_game_temp_initialise_DRIACS initialize
def initialize
ye_olde_game_temp_initialise_DRIACS
@temp_chest = Overlord_Dave::DRIACS::Data::CHESTS['null_chest']
end
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles the party. It includes information on amount of gold
# and items. The instance of this class is referenced by $game_party.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: check_inv_size, total_inv_size, open_chest
#==============================================================================
class Game_Party < Game_Unit
include Overlord_Dave::DRIACS::Data
include Overlord_Dave::DRIACS::Settings
#--------------------------------------------------------------------------
# * Check whether the inventory is oversize, and if so runs the event set in
# the settings module
#--------------------------------------------------------------------------
def check_inv_size
return if self.total_inv_size <= $max_inv_size || ENCUMBER
if OVER_SIZE_EVENT == -1
$scene = Scene_Item.new
else
$game_temp.common_event_id = OVER_SIZE_EVENT
end
end
#--------------------------------------------------------------------------
# * Gets the total size of the inventory by summing the size of each item
#--------------------------------------------------------------------------
def total_inv_size(count_equipped = false)
total = 0
# get all item sizes
items.each {|i| total += i.get_size*item_number(i)}
if COUNT_EQUIPPED || count_equipped
for m in members
# if an items size has not been defined it will count as having size 0
m.equips.each {|i| total += i.get_size unless i.nil?}
end
end
return total
end
#--------------------------------------------------------------------------
# * Opens the spoils scene on the chosen chest
# This cannot be called from within battle
# chest_id : the id of the chest to open from the $chests hash. If this
# id does not exist, it will create a new entry
# chest_base : the name of the base chest from the CHESTS hash that the
# chest will be based on if it has not yet been opened.
#--------------------------------------------------------------------------
def open_chest(chest_id, chest_base)
if $scene === Scene_Battle
print 'ERROR: cannot call \'open_chest\' from within a battle'
return
end
if CHESTS.include?(chest_base)
# if this chest has not already been initialised, do so
if !$chests.include?(chest_id)
$chests[chest_id] = CHESTS[chest_base].deep_clone
$chests[chest_id].opened = true
$chests[chest_id].map_id = $game_map.map_id
end
if $chests[chest_id].active == true
$chests[chest_id].add_from_item_table
$game_temp.temp_chest = $chests[chest_id].deep_clone
source = case $scene
when Scene_Map: 1
when Scene_Menu: 2
when Scene_Battle: 3
# note this method should cannot be called from within a battle
end
$scene = Scene_Spoils.new(source, $chests[chest_id].name, chest_id)
end
else
print 'ERROR: no chest exists in the CHESTS hash with id: '+chest_name
end
end
end
#==============================================================================
# ** Game_Player
#------------------------------------------------------------------------------
# - RGSS2 description is incorrect (and refers to Game_Map) -
#------------------------------------------------------------------------------
# Methods overriden: update_move (inherited from Game_Character)
# Methods aliased: [none]
# New methods: [none]
#==============================================================================
class Game_Player
include Overlord_Dave::DRIACS::Settings
# ----------------------------------------------------------------------------
# OVERRIDDEN Game_Player.update_move
# ----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# modified the move speed if the player is encumbered, and disables dash
# if neccessary
# ----------------------------------------------------------------------------
def update_move
# the new speed to move
enc_speed = @move_speed
unless !ENCUMBER
# whether encumberment has temporarily been disabled...
unless !$game_system.use_enc?
if $game_party.total_inv_size > $max_inv_size
enc_speed = case E_TYPE
when 0: E_VALUE if @move_speed == 4 # change default move speed
when 1: [@move_speed - E_VALUE, 1].max # reduce all move speeds
end
end
end
end
distance = 2 ** enc_speed
# adding dash disabling
unless !ENCUMBER && !DISABLE_DASH
distance *= 2 if dash? && $game_system.use_enc?
end
# everything else is the same...
@real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
@real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
@real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
@real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
update_bush_depth unless moving?
if @walk_anime
@anime_count += 1.5
elsif @step_anime
@anime_count += 1
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a superclass of all windows in the game.
#------------------------------------------------------------------------------
# Methods overriden: draw_item_name
# Methods aliased: [none]
# New methods: [none]
#==============================================================================
class Window_Base < Window
include Overlord_Dave::DRIACS::Settings
# ----------------------------------------------------------------------------
# OVERRIDDEN Window_Base.draw_item_name
# ----------------------------------------------------------------------------
# Added arguments: colour
# Added functionality:
# changes the colour of the item name depending on the value of colour
# ----------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true, colour = nil)
if !item.nil?
draw_icon(item.icon_index, x, y, enabled)
# added colour setting
self.contents.font.color = colour.nil? ? normal_color : colour
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, item.name)
end
end
end
#==============================================================================
# ** Window_Selectable
#------------------------------------------------------------------------------
# This window contains cursor movement and scroll functions.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: column_max accessor, item_max accessor
#==============================================================================
class Window_Selectable < Window_Base
attr_accessor :column_max
attr_accessor :item_max
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: map_id accessor
#==============================================================================
class Game_Map
attr_reader :map_id
end
#==============================================================================
# ** Window_Help
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status.
#------------------------------------------------------------------------------
# Methods overriden: set_text
# Methods aliased: [none]
# New methods:[none]
#==============================================================================
class Window_Help < Window_Base
# ----------------------------------------------------------------------------
# OVERRIDDEN Window_Help.set_text
# ----------------------------------------------------------------------------
# Added arguments: text_colour
# Added functionality:
# changes the colour of the text depending on the value of text_colour
# ----------------------------------------------------------------------------
def set_text(text, align = 0, text_colour = self.normal_color)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = text_colour
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#------------------------------------------------------------------------------
# Methods overriden: battle_end, display_drop_items
# Methods aliased: start
# New methods: [none]
#==============================================================================
class Scene_Battle
include Overlord_Dave::DRIACS::Settings
#--------------------------------------------------------------------------
# * ALIASED Start Processing
#----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Creates @call_spoils variable
#--------------------------------------------------------------------------
alias ye_olde_scene_battle_start_DRIACS start
def start
ye_olde_scene_battle_start_DRIACS
@call_spoils = false
end
#--------------------------------------------------------------------------
# * OVERRIDDEN End Battle
#----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Initiaites the spoils scene if items were dropped
#--------------------------------------------------------------------------
def battle_end(result)
if result == 2 and not $game_troop.can_lose
call_gameover
else
$game_party.clear_actions
$game_party.remove_states_battle
$game_troop.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
# the following line has been overridden
$scene = @call_spoils ? Scene_Spoils.new(3, $game_temp.temp_chest.name) : Scene_Map.new
@message_window.clear
Graphics.fadeout(30)
end
$game_temp.in_battle = false
end
#--------------------------------------------------------------------------
# * OVERRIDDEN Display Gained Drop Items
#----------------------------------------------------------------------------
# Added arguments: [none]
# Added functionality:
# Adds items to a new spoils object for collection, and doesn't add
# straight to inventory
#--------------------------------------------------------------------------
def display_drop_items
return if !RAN_BAT_SPOILS
drop_items = $game_troop.make_drop_items
# create the spoils chest
name = USE_TROOP_NAME ? $game_troop.troop.name : -1
$game_temp.temp_chest = B_Spoils.new(name, '')
for item in drop_items
# items are not gained at this point
# instead a new spoils objects is created
$game_temp.temp_chest.gain_item(item, 1)
end
@call_spoils = true if !$game_temp.temp_chest.empty?
wait_for_message
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#------------------------------------------------------------------------------
# Methods overriden: [none]
# Methods aliased: [none]
# New methods: open_chest, reset_chest, init_battle_spoils, update_chests,
# disable_encumber, enable_encumber, check_inv_size,
# clear_chest, add_to_chest, check_item, inventory_size
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Checks whether a chest has been opened or initialised
# chest_id : id of the chest in the $chests array to be checked
#--------------------------------------------------------------------------
def chest_opened?(chest_id)
return false if $chests[chest_id].nil?
return $chests[chest_id].opened?
end
# --------------------------------------------------------------------------
# These link directly to the appropriate methods of other classes; their
# purpose is so that the user does not have to unclude "$some_class." in front
# of the commands
# --------------------------------------------------------------------------
def open_chest(id, base)
$game_party.open_chest(id, base)
end
def remote_open_chest(chest_id, chest_base, map_id)
$game_system.remote_open_chest(chest_id, chest_base, map_id)
end
def reset_chest(id, base)
$game_system.reset_chest(id, base)
end
def init_battle_spoils(spoils)
$game_system.init_battle_spoils(spoils)
end
def update_chests(maps)
$game_system.update_chests(maps)
end
def disable_encumber
$game_system.disable_encumber
end
def enable_encumber
$game_system.enable_encumber
end
def check_inv_size
$game_party.check_inv_size
end
def clear_chest(id)
$game_system.clear_chest(id)
end
def add_to_chest(chest_id, item_code)
$game_system.add_to_chest(chest_id, item_code)
end
def check_item(chest_id, item_code)
$game_system.check_item(chest_id, item_code)
end
def inventory_size(equipped = false)
return $game_party.total_inv_size(equipped)
end
end
#-------------------------------------------------------------------------------
#----------- ATP(Advanced Text Paragrapher) V1.0 by Samo, The thief ------------
#-------------------------------------------------------------------------------
# Modfied by Overlord_Dave 26/5/2009
# - the 'str_paragraph' method can now be called statically
# - the 'draw_paragraph' method has been unmodified
# new/modified lines are indicated by a MODIFIED or ADDED tag
class Window_Base < Window
def str_paragraph(str_old, width)
temp_str = ''
str = '' + str_old
words = []
size = 0
str_size = 0
temp_bitmap = Bitmap.new(10, 10) # ADDED
while ((c = str.slice!(/./m)) != nil)
temp_str += c
str_size += 1
if c == ' '
words.push(temp_str)
temp_str = ''
end
if str.size == 0
words.push(temp_str)
temp_str = ''
end
end
lines = []
for i in 0...words.size
word = words[i]
if word == '^ '
lines.push(temp_str)
temp_str = ''
next
end
temp_str += word
size = temp_bitmap.text_size(temp_str).width # MODIFIED
if size > width - temp_bitmap.text_size(' ').width # MODIFED
for i in 1..word.size
temp_str = temp_str.chop
end
lines.push(temp_str)
temp_str = ''
temp_str += word
end
end
words = words.compact
if temp_str != ''
lines.push(temp_str)
end
temp_bitmap.dispose # ADDED
return lines
end
def draw_paragraph(x,y,width,height,lines,align = 0)
for i in 0...lines.size
self.contents.draw_text(x, y + i * self.contents.font.size + 1, width, height, lines[i], align)
end
end
end
Социальные закладки