ГлавнаяФорумRPG MakerСкрипты/ПлагиныRPG Maker VX ACEУлучшающие или добавляющее новое скрипты[VXA] Временное хранение всего инвентаря (сундук)
Войти на сайт
×
ТЕМА: [VXA] Временное хранение всего инвентаря (сундук)
[VXA] Временное хранение всего инвентаря (сундук) 5 года 8 мес. назад #110884
|
Написал такой простой скрипт по идее akito66. Наверное похожие скрипты уже есть, если кто-то знает другие варианты получше — поделитесь ссылками.
У скрипт три опции:
(1 Я носитель языка, что хочу, то и несу) Мне лень добавлять другие функции, но скрипт рабочий и может кому-то пригодиться. Очень простой, функционал минимален — дёшево и сердито. Он в общественном достоянии согласно CC0, то есть его можно использовать в любых играх без каких-либо ограничений, меня указывать не надо (но буду благодарен, если укажете, может мне на Светлой рубинчик дадут? ) Вот код скрипта: # This code is placed into public domain according to the
# CC0 public domain dedication. You can use it in any way you like without
# any requirements.
# Этот код в общественном достоянии согласно CC0. Его можно использовать,
# как вам угодно, без каких-либо условий.
# Чтобы положить вещи в сундук, используйте такой скрипт:
# dmy_into_chest
# Если сундуков в игре несколько, добавьте код сундука:
# dmy_into_chest 1
# Код сундука может быть числом или словом в кавычках. Если код не указан,
# используется код 'default'.
# Чтобы достать вещи из сундука, используйте такой скрипт:
# dmy_from_chest
# Если сундуков в игре несколько, тоже добавьте код:
# dmy_from_chest 1
# Чтобы проверить, лежит ли что-то в сундуке, используйте команду
# Ветвление условий со скриптовым условием, в скриптовом условии запишите
# такой скрипт:
# dmy_chest_has_items?
# Если сундуков в игре несколько, добавьте код сундука:
# dmy_chest_has_items? 1
class Game_Party < Game_Unit
alias dmy_chests_initialize initialize
def initialize
dmy_chests_initialize
dmy_init_chests
end
def dmy_init_chests
@dmy_chests = {}
end
def dmy_items_into_chest(in_chest, in_inv)
return unless in_inv
in_inv.each do |key, value|
in_chest[key] = 0 unless in_chest.has_key?(key)
in_chest[key] += value
end
end
def dmy_into_chest(chest_id = 'default')
if @dmy_chests.has_key?(chest_id)
chest = @dmy_chests[chest_id]
dmy_items_into_chest(chest[:items], @items)
dmy_items_into_chest(chest[:weapons], @weapons)
dmy_items_into_chest(chest[:armors], @armors)
else
@dmy_chests[chest_id] = {
:items => @items,
:weapons => @weapons,
:armors => @armors
}
end
init_all_items
end
def dmy_items_from_container(in_chest, in_inv)
return unless in_chest
in_chest.each do |key, value|
in_inv[key] = 0 unless in_inv.has_key?(key)
in_inv[key] += value
end
end
def dmy_from_chest(chest_id = 'default')
return unless @dmy_chests.has_key?(chest_id)
chest = @dmy_chests[chest_id]
dmy_items_from_container(chest[:items], @items)
dmy_items_from_container(chest[:weapons], @weapons)
dmy_items_from_container(chest[:armors], @armors)
@dmy_chests.delete(chest_id)
end
def dmy_chest_has_items?(chest_id = 'default')
return false unless @dmy_chests.has_key?(chest_id)
chest = @dmy_chests[chest_id]
return (chest[:items].size + chest[:weapons].size + chest[:armors].size) > 0
end
end
def dmy_from_chest(chest_id = 'default')
$game_party.dmy_from_chest(chest_id)
end
def dmy_into_chest(chest_id = 'default')
$game_party.dmy_into_chest(chest_id)
end
def dmy_chest_has_items?(chest_id = 'default')
$game_party.dmy_chest_has_items?(chest_id)
end Пример использования: |
Последнее редактирование: 5 года 8 мес. назад от Dmy.
Администратор запретил публиковать записи гостям.
|
[VXA] Временное хранение всего инвентаря (сундук) 5 года 8 мес. назад #110886
|
Так первый найденный мной несовместимый скрипт FP Inventory Plus он отвечает за придание всем вещам веса:
=begin
#==============================================================================
** FP Inventory Plus
Author: Tsukihime
Date: Jul 10, 2012
------------------------------------------------------------------------------
** Change log
Jul 10
-fixed logic error where == wasn't returning false if no branches return
Jul 9
-restructured Game_Weapon, Game_Armor, and Game_Item to include a new
BaseItem module
-overwrote == logic to distinguish between RPG objects and custom objects.
Jun 26
-added proper item losing
May 30
-fixed issue where item type check wasn't checked properly
eg: default weapon check assumes class == RPG::Weapon
May 29
-added counting options: count-by-item, count-by-stack
May 27
-added options to enable/disable item/weight limits
-added item limit window
May 26
-added the imported boolean
May 24
-Initialized RPG classes
May 22
-Added "clear inventory" method to clear everything out
-Clears out equips as well
May 15, 2012
- fixed some bugs
May 14, 2012
- Initial release
------------------------------------------------------------------------------
This script extends the default inventory system and all item-handling
throughout the engine. All items will be fetched from the inventory, and
instances of the specific item is stored and retrieved.
You can specify the stack sizes for each item as well as their weights.
You can specify item limits and weight limits for each item.
All equips are treated independently.
This script will act as the basis for all future item-related scripts.
To specify an item/equip stack size, tag it with
<¤чейка: n>
where n is an integer >= 1
To specify the weight of an item/equip, tag it with
<вес: n>
where n is a real number
To specify the the limit for an item/equip, tag it with
<лимит: n>
where n is an integer >= 0
<лимит: х> #макс.кол-во для предмета
<вес: х> #вес предмета
<ячейка: х> #кол-во вещей одной позиции до перехода на другую
#==============================================================================
=end
$imported = {} if $imported.nil?
$imported["FP_InventoryPlus"] = true
#==============================================================================
# ** Configuration
#==============================================================================
module Feature_Plus
module Inventory_System
Use_Item_Limit = false
Use_Weight_Limit = true
# Item counting method. If "Count_Items" is true, then
# Count_Stacks is not used
Count_By_Stack = false # treat each stack as a single item
Count_By_Item = true # count every item individually
# ячейка по-умолчанию
Default_Item_Stack = 999
Default_Equip_Stack = 998
# ћасса по-умолчанию
Default_KeyItem_Weight = 0
Default_Item_Weight = 1.0
Default_Equip_Weight = 0.25
Weight_Unit = "кг."
# [current weight] / [max weight] [weight unit]
Weight_Display = "%s/%s %s"
# [item_count] / [item_limit]
Item_Display = "Вещей: %s/%s"
# Inventory limit defaults
Inventory_Limit = 250 #макс.кол-во всех вещей
#для разных рас разный максимальный переносимый вес
Weight_Limit=150
#======
#regex
Item_Limit = /<лимит:?\s*(\d+)/i #макс.кол-во дл¤ предмета
Item_Weight = /<вес:?\s*(.*)>/i #вес предмета
Stack_Size = /<ячейка:?\s*(\d+)>/i #кол-во вещей одной позиции до перехода на другую
end
end
#========================================================================
# ** Rest of the script
#==============================================================================
module RPG
class Item < UsableItem
include Feature_Plus::Inventory_System
def item_weight
return @item_weight unless @item_weight.nil?
res = Item_Weight.match(self.note)
return @item_weight = res ? res[1].to_f : (key_item? ? Default_KeyItem_Weight : Default_Item_Weight)
end
def item_stack
return @item_stack unless @item_stack.nil?
res = Stack_Size.match(self.note)
return @item_stack = res ? res[1].to_i : Default_Item_Stack
end
def item_limit
return @item_limit unless @item_limit.nil?
res = Item_Limit.match(self.note)
return @item_limit = res ? res[1].to_i : Inventory_Limit
end
end
class EquipItem < BaseItem
include Feature_Plus::Inventory_System
def item_weight
return @item_weight unless @item_weight.nil?
res = Item_Weight.match(self.note)
return @item_weight = res ? res[1].to_f : Default_Equip_Weight
end
def item_stack
return @item_stack unless @item_stack.nil?
res = Stack_Size.match(self.note)
return @item_stack = res ? res[1].to_i : Default_Equip_Stack
end
def item_limit
return @item_limit unless @item_limit.nil?
res = Item_Limit.match(self.note)
return @item_limit = res ? res[1].to_i : Inventory_Limit
end
end
end
# this module is included by Game_Item, Game_Weapon, and Game_Armor
module BaseItem
attr_reader :index # index of item in the inventory slot
attr_reader :count # number of items in this stack
attr_reader :class #
attr_reader :item_stack # max items per stack
attr_reader :item_weight # weight per instance of item
attr_reader :item_limit # max number of items allowed to carry
attr_reader :id # database ID used to reference the type of item
def initialize(item, index)
super()
init_base_attributes(item)
@count = 0
@index = index
@id = item.id
@item_stack = item.item_stack
@item_weight = item.item_weight
@item_limit = item.item_limit
setup(item, index) if needs_setup?(item)
end
def setup(item, index)
end
def init_base_attributes(item)
item.instance_variables.each do |attr|
self.instance_variable_set(attr, item.instance_variable_get(attr))
end
end
def amount_can_add?
@item_stack - @count
end
def add_amount(amt)
@count = [@count + amt, @item_stack].min
end
def lose_amount(amt)
lost = [amt, @count].min
@count = [@count - amt, 0].max
return lost
end
def full?
@count >= @item_stack
end
def can_add?
return false if full?
return true
end
def inspect
"<%s>" % @name
end
end
# This module is included in Game_Weapon and Game_Armor. It contains common
# methods shared by all equip items
module EquipItem
def setup(item, index)
# call anything from BaseItem
super
end
end
#==============================================================================
# ** Game_Item
#------------------------------------------------------------------------------
# This is an extension of RPG::Item. All of the methods defined in
# RPG::Item are inherited. When an item is created, it is wrapped by
# this Game_Item and all of the attributes are cloned
#==============================================================================
class Game_Item < RPG::Item
include BaseItem
def setup(item, index)
@class = Game_Item
end
def needs_setup?(item)
item.class == RPG::Item
end
def ==(item)
if item.class == RPG::Item
return $data_items[@id] == item
elsif item.is_a?(Game_Item)
return self.equal?(item)
end
return false
end
end
#==============================================================================
# ** Game_Weapon
#------------------------------------------------------------------------------
# This is an extension of RPG::Weapon. All of the methods defined in
# RPG::Weapon are inherited. When an item is created, it is wrapped by
# this Game_Weapon and all of the attributes are cloned
#==============================================================================
class Game_Weapon < RPG::Weapon
include BaseItem
include EquipItem
alias :th_inventory_setup :setup
def setup(item, index)
@class = Game_Weapon
@params = item.params.clone #we must clone this
@name = item.name
th_inventory_setup(item, index)
end
def needs_setup?(item)
item.class == RPG::Weapon
end
def ==(item)
if item.class == RPG::Weapon
return $data_weapons[@id] == item
elsif item.is_a?(Game_Weapon)
return equal?(item)
end
return false
end
end
#==============================================================================
# ** Game_Armor
#------------------------------------------------------------------------------
# This is an extension of RPG::Armor. All of the methods defined in
# RPG::Armor are inherited. When an item is created, it is wrapped by
# this Game_Armor and all of the attributes are cloned
#==============================================================================
class Game_Armor < RPG::Armor
include BaseItem
include EquipItem
def setup(item, index)
@class = Game_Armor
@params = item.params.clone #we must clone this
@name = item.name
end
def needs_setup?(item)
item.class == RPG::Armor
end
def ==(item)
if item.class == RPG::Armor
return $data_armors[@id] == item
elsif item.is_a?(RPG::Armor)
return self.equal?(item)
end
return false
end
end
#==============================================================================
# ** Game_Inventory
#------------------------------------------------------------------------------
# This is an inventory object. It represents a generic inventory, containing
# a set of items including common items, weapons, armors, and key items.
#
# All inventory related methods are defined and any access to the inventory
# should use the provided methods
#==============================================================================
class Game_Inventory
include Feature_Plus::Inventory_System
attr_reader :weight
attr_reader :item_count
def initialize
@id = 0
@name = ""
@weight = 0
@item_count = 0
@items = {}
@weapons = {}
@armors = {}
@discards = {}
@inventory_limit = Inventory_Limit
end
def max_items
@inventory_limit
end
def max_weight
if [4, 5].include?($game_variables[1]) then
cw = 200
@weight_limit=cw
$game_variables[4]=cw
$game_variables[3]=@weight
return cw
else
cw = 170
@weight_limit=cw
$game_variables[4]=cw
$game_variables[3]=@weight
return cw
end
end
def weight_exceeded?(item)
return false unless Feature_Plus::Inventory_System::Use_Weight_Limit
@weight + item.item_weight > @weight_limit
end
def items_exceeded?
return false unless Feature_Plus::Inventory_System::Use_Item_Limit
@item_count >= @inventory_limit
end
def limit_reached?(item)
items_exceeded? || weight_exceeded?(item)
end
def can_add_amount?(item)
if item.item_weight > 0
return [[max_items - @item_count, (max_weight - @weight) / item.item_weight].min, 0].max
end
return [max_items - @item_count, 0].max
end
def get_item_type(item)
return @items if item.is_a?(RPG::Item)
return @weapons if item.is_a?(RPG::Weapon)
return @armors if item.is_a?(RPG::Armor)
return nil
end
def is_system_item?(item)
return [RPG::Weapon, RPG::Armor, RPG::Item].include?(item.class)
end
def item_number(item)
container = get_item_type(item)
return 0 unless container && container[item.id]
return container[item.id].count unless item.instance_variable_defined?(:@index)
return container[item.id][item.index].nil? ? 0 : container[item.id][item.index].count
end
def has_item?(item, include_equip=false)
item_number(item) > 0
end
def gain_item(item, amount)
container = get_item_type(item)
return unless container
valid_amount = [can_add_amount?(item), amount].min
discard_amount = amount - valid_amount
unless limit_reached?(item)
container[item.id] = Game_InventorySlot.new(item) unless container[item.id]
amount_avail = [container[item.id].can_add_amount?(item), valid_amount].min
container[item.id].gain_item(item, amount_avail)
update_inventory(container, item, amount_avail)
end
update_discards(item, discard_amount)
end
def lose_item(item, amount)
container = get_item_type(item)
return unless container
return unless container[item.id]
lost = container[item.id].lose_item(item, amount)
update_inventory(container, item, -lost)
end
def update_inventory(container, item, added)
#~ if Count_By_Item
@weight += item.item_weight * added
@item_count += added
#~ elsif Count_By_Stack
#~ mod = container[item.id].stacks.size
#~ @weight += added < 0 ? -mod*item.item_weight : mod*item.item_weight
#~ @item_count += added < 0 ? -mod : mod
#~ end
end
def update_discards(item, remains)
return unless remains > 0
p "Discarded %d %s" %[remains, item.name]
end
def clear_inventory(include_equips=false)
$game_party.all_members.each {|actor| actor.clear_equips} if include_equips
@weapons.clear
@armors.clear
@items.clear
@item_count = 0
@weight = 0
end
#--------------------------------------------------------------------------
# * Accessor methods. Returns the same things that Game_Party used
# to return
#--------------------------------------------------------------------------
#~
def get_weapon(item_id)
slot = @weapons[item_id]
return unless slot
return slot.stacks[0]
end
def get_armor(item_id)
slot = @armors[item_id]
return unless slot
return slot.stacks[0]
end
def items
@items.keys.sort.collect {|id| @items[id].stacks}.flatten
end
def weapons
@weapons.keys.sort.collect {|id| @weapons[id].stacks}.flatten
end
def armors
@armors.keys.sort.collect {|id| @armors[id].stacks}.flatten
end
def equip_items
weapons.concat(armors)
end
def discards
@discards
end
def all_items
items.concat(weapons).concat(armors)
end
end
#==============================================================================
# ** Game_InventorySlot
#------------------------------------------------------------------------------
# This is an inventory slot object. It provides information about this slot
# such as the number of items and total weight. It stores an instance of
# my custom game item in an array
#==============================================================================
class Game_InventorySlot
include Feature_Plus::Inventory_System
attr_reader :item_stack
attr_reader :count
attr_reader :weight
def initialize(item)
@id = item.id
@item = item
@stacks = [] # individual instances of this item
@item_weight = item.item_weight
@count = 0 # number of items across all stacks
@weight = 0 # weight of items across all stacks
@item_stack = item.item_stack # number of items per stack
@item_limit = item.item_limit
end
def [](index)
return unless @stacks[index]
@stacks[index]
end
def max_items
@item_limit
end
def max_weight
Weight_Limit
end
def stack_size
@item_stack
end
#--------------------------------------------------------------------------
# * Return all non-nil stacks
#--------------------------------------------------------------------------
def stacks
@stacks.select {|stack| !stack.nil?}
end
def slot_exceeded?
@count >= max_items
end
def weight_exceeded?(item)
return false unless Feature_Plus::Inventory_System::Use_Weight_Limit
@weight >= max_weight
end
def can_add?(item)
return false if slot_exceeded? || weight_exceeded?(item)
return true
end
def can_add_amount?(item)
if item.item_weight > 0
return [[max_items - @count, (max_weight - @weight) / item.item_weight].min, 0].max
end
return [max_items - @count, 0].max
end
# gets the first available stack to add item to
def get_stack(item)
(0 .. @stacks.size ).find { |k| @stacks[k].nil? || @stacks[k].can_add?}
end
# gets the first non-nil stack
def first_stack
(0 .. @stacks.size ).find { |k| @stacks[k]}
end
def make_item(item, i)
@stacks[i] = Game_Item.new(item, i) if item.is_a?(RPG::Item)
@stacks[i] = Game_Weapon.new(item, i) if item.is_a?(RPG::Weapon)
@stacks[i] = Game_Armor.new(item, i) if item.is_a?(RPG::Armor)
end
def gain_item(item, amount)
return unless can_add?(item)
total = amount
while amount > 0
i = get_stack(item)
make_item(item, i) if @stacks[i].nil?
stack = @stacks[i]
amt = stack.amount_can_add?
@stacks[i].add_amount([amount, amount - amt, 0].max)
amount -= amt
end
update_slot(item, total)
end
def delete_stack(index)
@stacks.delete_at(index)
@stacks.insert(index, nil)
end
def lose_item(item, amount)
total_lost = 0
while @count > 0 && amount > 0
i = item.index rescue first_stack
if i
i = first_stack if @stacks[i].count == 0
stack = @stacks[i]
lost_amount = stack.lose_amount(amount)
delete_stack(i) if @stacks[i].count == 0
update_slot(item, -lost_amount)
total_lost += lost_amount
amount -= lost_amount
end
end
return total_lost
end
def update_slot(item, amount)
@count += amount
@weight += item.item_weight * amount
end
end
class Game_Actor < Game_Battler
alias fp_inventory_actor_initialize initialize
def initialize(actor_id)
fp_inventory_actor_initialize(actor_id)
@last_skill = Game_CustItem.new
end
def clear_equips
@equips = Array.new(equip_slots.size) { Game_CustItem.new }
end
#need to set up initial equips properly
def init_equips(equips)
@equips = Array.new(equip_slots.size) { Game_CustItem.new }
equips.each_with_index do |item_id, i|
etype_id = index_to_etype_id(i)
slot_id = empty_slot(etype_id)
if item_id > 0
@equips[slot_id].object = get_initial_equip(etype_id == 0, item_id) if slot_id
else
@equips[slot_id].object = nil if slot_id
end
end
refresh
end
def get_initial_equip(is_weapon, item_id)
if is_weapon
return Game_Weapon.new($data_weapons[item_id], 0)
else
return Game_Armor.new($data_armors[item_id], 0)
end
end
def xequips
@equips.collect {|item| item.object }
end
def armors
@equips.select {|item| item.is_armor? }.collect {|item| item.object }
end
def change_equip(slot_id, item)
return unless trade_item_with_party(item, equips[slot_id])
return if item && equip_slots[slot_id] != item.etype_id
@equips[slot_id].object = item
refresh
end
# event command "change equipment"
def change_equip_by_id(slot_id, item_id)
if equip_slots[slot_id] == 0
item = $game_party.get_weapon(item_id)
return unless item
change_equip(slot_id, item)
else
index = $game_party.get_armor(item_id)
return unless item
change_equip(slot_id, Game_Armor.new($data_armors[item_id], index))
end
end
end
#==============================================================================
# ** Game_party
#------------------------------------------------------------------------------
# All inventory access methods are re-written to allow the Inventory object
# to properly handle those requests
#==============================================================================
class Game_Party < Game_Unit
attr_reader :inventory
alias tsuki_inventory_party_initialize initialize
def initialize
tsuki_inventory_party_initialize
@inventory = Game_Inventory.new
@last_item = Game_CustItem.new
end
def clear_inventory(include_equip=false)
@inventory.clear_inventory(include_equip)
end
def weight
@inventory.weight
end
def items
@inventory.items
end
def weapons
@inventory.weapons
end
def armors
@inventory.armors
end
def equip_items
@inventory.equip_items
end
def all_items
@inventory.all_items
end
def item_number(item)
@inventory.item_number(item)
end
def has_item?(item, include_equip=false)
@inventory.has_item?(item)
end
def gain_item(item, amount, include_equip = false)
if amount < 0
lose_item(item, -amount, include_equip)
else
@inventory.gain_item(item, amount)
end
end
def lose_item(item, amount, include_equip = false)
@inventory.lose_item(item, amount)
end
def max_item_number(item)
99
end
def max_weight
@inventory.max_weight
end
def item_count
@inventory.item_count
end
def max_items
@inventory.max_items
end
def item_max?(item)
item_number(item) >= max_item_number(item)
end
def get_weapon(item_id)
@inventory.get_weapon(item_id)
end
def get_armor(item_id)
@inventory.get_armor(item_id)
end
end
#==============================================================================
# ** Game_CustItem
#------------------------------------------------------------------------------
# This is a variation of Game_BaseItem that stores the actual instance of
# the object rather than storing references to the database
#==============================================================================
class Game_CustItem < Game_BaseItem
def initialize
super
@object = nil
end
def is_skill?; @object.is_a?(RPG::Skill); end
def is_item?; @object.is_a?(RPG::Item); end
def is_weapon?; @object.is_a?(RPG::Weapon); end
def is_armor?; @object.is_a?(RPG::Armor); end
def object
return nil unless @object
return @object
end
def object=(item)
@class = item.class
@item_id = item.id if item
@object = item
end
def set_equip(is_weapon, item_id)
@class = is_weapon ? RPG::Weapon : RPG::Armor
@item_id = item_id
@object = is_weapon ? $data_weapons[item_id] : $data_armors[item_id]
end
end
class Game_Action
alias fp_initialize_clear_action clear
def clear
fp_initialize_clear_action
@item = Game_CustItem.new
end
def set_item(item)
@item.object = item
self
end
end
#==============================================================================
# ** Scenes
#==============================================================================
class Scene_Battle < Scene_Base
def on_item_ok
@item = @item_window.item
BattleManager.actor.input.set_item(@item)
if [email protected]_selection?
@item_window.hide
next_command
elsif @item.for_opponent?
select_enemy_selection
else
select_actor_selection
end
$game_party.last_item.object = @item
end
end
class Scene_Menu < Scene_MenuBase
alias fp_inventory_menu_start start
def start
fp_inventory_menu_start
create_limit_windows
end
def create_limit_windows
y = 48
if Feature_Plus::Inventory_System::Use_Weight_Limit
@weight_window = Window_Weight.new(0, Graphics.height - y - @gold_window.height)
y += 48
end
if Feature_Plus::Inventory_System::Use_Item_Limit
@item_limit_window = Window_ItemLimit.new(0, Graphics.height - y - @gold_window.height)
end
end
end
class Scene_Item < Scene_ItemBase
alias fp_inventory_item_start start
def start
fp_inventory_item_start
create_limit_windows
end
def create_limit_windows
x = 160
if Feature_Plus::Inventory_System::Use_Weight_Limit
@weight_window = Window_Weight.new(Graphics.width - x, 0)
@weight_window.z = 200
@actor_window.z = 300
x += 160
end
if Feature_Plus::Inventory_System::Use_Item_Limit
@item_limit_window = Window_ItemLimit.new(Graphics.width - x, 0)
@item_limit_window.z = 200
x += 160
end
end
alias fp_inventory_use_item use_item
def use_item
fp_inventory_use_item
@weight_window.refresh if Feature_Plus::Inventory_System::Use_Weight_Limit
@item_limit_window.refresh if Feature_Plus::Inventory_System::Use_Item_Limit
end
end
class Window_ItemLimit < Window_Base
include Feature_Plus::Inventory_System
def initialize(x, y)
super(x, y, window_width, fitting_height(1))
refresh
end
def window_width
160
end
def refresh
contents.clear
draw_weight_value(4, 0)
end
def draw_weight_value(x, y)
text = sprintf(Item_Display, item_count, item_limit)
change_color(normal_color)
draw_text(x, y, self.contents.width - 4, line_height, text, 1)
end
def item_limit
$game_party.max_items
end
#--------------------------------------------------------------------------
# * Get inventory weight
#--------------------------------------------------------------------------
def item_count
$game_party.item_count
end
#--------------------------------------------------------------------------
# * Open Window
#--------------------------------------------------------------------------
def open
refresh
super
end
end
class Window_Weight < Window_Base
include Feature_Plus::Inventory_System
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, fitting_height(1))
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_weight_value(4, 0, contents.width - 8)
end
def draw_weight_value(x, y, width)
text = sprintf(Weight_Display, weight, max_weight, weight_unit)
change_color(normal_color)
draw_text(x, y, width, line_height, text, 2)
end
def weight_unit
Weight_Unit
end
def max_weight
$game_party.max_weight
end
#--------------------------------------------------------------------------
# * Get inventory weight
#--------------------------------------------------------------------------
def weight
$game_party.weight
end
#--------------------------------------------------------------------------
# * Open Window
#--------------------------------------------------------------------------
def open
refresh
super
end
end
class Game_Interpreter
def can_add_amount?(item)
return false if item.nil?
item = $data_items[item] unless item.is_a?(RPG::BaseItem)
return $game_party.inventory.can_add_amount?(item)
end
def armor(i)
return $data_armors[i]
end
def weapon(i)
return $data_weapons[i]
end
def item(i)
return @data_items[i]
end
end |
Последнее редактирование: 5 года 8 мес. назад от akito66.
Администратор запретил публиковать записи гостям.
|
[VXA] Временное хранение всего инвентаря (сундук) 5 года 8 мес. назад #110914
|
Дмай нашел тематический скрипт на положить броню, оружие в сундук:
#===============================================================================
# Разработан на основе скрипта $D13x - Bank Account
#===============================================================================
# Описание
#-------------------------------------------------------------------------------
# Создает механизм сохранения предметов на будущее
#===============================================================================
# Инструкция
#-------------------------------------------------------------------------------
# 1.Скопировать скрипт перед Main
# 2.Создать Событие с вызовом скрипта SceneManager.call(Scene_Chest_Item)
#===============================================================================
# Команды для события
#-------------------------------------------------------------------------------
# $chest_item.gain_cash(amount) //Добавляет денег в сундук
# $chest_item.lose_cash(amount) //Отнимает деньги из сундука
# $chest_item.add_to_items(id, amount) //Добавляет вещь в сундук
# $chest_item.add_to_weapons(id, amount) //Добавляет оружие в сундук
# $chest_item.add_to_armors(id, amount) //Добавляет броню в сундук
# SceneManager.call(Scene_Chest_Item) //Вызов GUI скрипта
#===============================================================================
module Game_Storage
#===============================================================================
#-----------------------------------------------------------------------------
# Начальная сумма денег в сундуке
#-----------------------------------------------------------------------------
Initial_CASH = 2000
#-----------------------------------------------------------------------------
# Какие вещи будут с начала игры в сундуке
# Формат = [ [ID вещи, кол-во], [ID вещи, кол-во] ]
#-----------------------------------------------------------------------------
Initial_Items = [ [1, 1], [2, 2] ]
#-----------------------------------------------------------------------------
# Какое оружие будут с начала игры в сундуке
# Формат = [ [ID оружия, кол-во], [ID оружия, кол-во] ]
#-----------------------------------------------------------------------------
Initial_Weapons = [ [1, 1] ]
#-----------------------------------------------------------------------------
# Какая броня будут с начала игры в сундуке
# Формат = [ [ID брони, кол-во], [ID брони, кол-во] ]
#-----------------------------------------------------------------------------
Initial_Armors = [ [1, 1] ]
end
#===============================================================================
module PC_Scene
#===============================================================================
Money_Vocab = "Деньги"
Money_Prefix = "%s G"
Money_Icon = 361
Money_Icon_x = 0
Money_Text_x = 25
#-----------------------------------------------------------------------------
Value_Prefix = "x%s"
#-----------------------------------------------------------------------------
Items_Vocab = "Вещи"
Weapons_Vocab = "Оружие"
Armors_Vocab = "Броня"
#-----------------------------------------------------------------------------
Current_Money_Vocab = "В рюкзаке :"
Chest_Item_Money_Vocab = "В сундуке :"
#-----------------------------------------------------------------------------
Deposit_Vocab = "Положить"
Deposit_Info = "Положить деньги, вещи или экипировку в сундук."
Deposit_Cash = "Положить деньги в сундук."
Deposit_Items = "Положить вещи в сундук."
Deposit_Weapons = "Положить оружие в сундук."
Deposit_Armors = "Положить броню в сундук."
#-----------------------------------------------------------------------------
Withdraw_Vocab = "Забрать"
Withdraw_Info = "Забрать деньги, вещи или экипировку из сундука."
Withdraw_Cash = "Забрать деньги из сундука."
Withdraw_Items = "Забрать вещи из сундука."
Withdraw_Weapons = "Забрать оружие из сундука."
Withdraw_Armors = "Забрать броню из сундука."
end
#===============================================================================
module DataManager
#===============================================================================
#-----------------------------------------------------------------------------
class << self ;
alias :cgo_chest_item_account :create_game_objects
alias :msc_chest_item_account :make_save_contents
alias :esc_chest_item_account :extract_save_contents
end
#-----------------------------------------------------------------------------
def self.create_game_objects
cgo_chest_item_account
$chest_item = Chest_Item_Account.new
end
#-----------------------------------------------------------------------------
def self.make_save_contents
contents = msc_chest_item_account
contents[:chest_item] = $chest_item
contents
end
#-----------------------------------------------------------------------------
def self.extract_save_contents(contents)
esc_chest_item_account(contents)
$chest_item = contents[:chest_item].nil? ? Chest_Item_Account.new : contents[:chest_item]
end
end
#===============================================================================
class Chest_Item_Account
#===============================================================================
#-----------------------------------------------------------------------------
include Game_Storage
#-----------------------------------------------------------------------------
attr_reader :cash
attr_reader :items
attr_reader :weapons
attr_reader :armors
#-----------------------------------------------------------------------------
def initialize
init_pis
get_initial_stored_items
get_initial_stored_weapons
get_initial_stored_armors
end
#-----------------------------------------------------------------------------
def init_pis
@cash = Initial_CASH
@items = []
@weapons = []
@armors = []
end
#-----------------------------------------------------------------------------
def get_initial_stored_items
for info in Game_Storage::Initial_Items
next if info[0] == nil || info[0] <= 0
add_to_items(info[0], info[1])
end
end
#-----------------------------------------------------------------------------
def get_initial_stored_weapons
for info in Game_Storage::Initial_Weapons
next if info[0] == nil || info[0] <= 0
add_to_weapons(info[0], info[1])
end
end
#-----------------------------------------------------------------------------
def get_initial_stored_armors
for info in Game_Storage::Initial_Armors
next if info[0] == nil || info[0] <= 0
add_to_armors(info[0], info[1])
end
end
#-----------------------------------------------------------------------------
def add_to_items(item_id, amount)
return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
@items.push([ $data_items[item_id] , amount ])
end
#-----------------------------------------------------------------------------
def add_to_weapons(item_id, amount)
return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
weapon = [$data_weapons[item_id], amount]
@weapons.push(weapon)
end
#-----------------------------------------------------------------------------
def add_to_armors(item_id, amount)
return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
armor = [$data_armors[item_id],amount]
@armors.push(armor)
end
#-----------------------------------------------------------------------------
def gain_cash(amount)
@cash += amount
end
#-----------------------------------------------------------------------------
def lose_cash(amount)
@cash -= amount
@cash = 0 if @cash < 0
end
end
#===============================================================================
class Window_Player_PC_Number < Window_ShopNumber
#===============================================================================
#-----------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_height)
end
#-----------------------------------------------------------------------------
def window_width
return Graphics.width / 2
end
#-----------------------------------------------------------------------------
def window_height
return line_height + 24
end
#-----------------------------------------------------------------------------
def refresh
contents.clear
draw_the_item
draw_number
end
#-----------------------------------------------------------------------------
def draw_number
change_color(normal_color)
if @item
change_color(normal_color, true)
end
tx = sprintf(PC_Scene::Value_Prefix, @number)
draw_text(0,0,window_width-(standard_padding*2), line_height, tx, 2)
end
#-----------------------------------------------------------------------------
def draw_the_item
change_color(normal_color)
x = PC_Scene::Money_Text_x
ix = PC_Scene::Money_Icon_x
y = item_y
w = window_width
if @item == $data_items[0]
draw_icon(PC_Scene::Money_Icon, ix, y, true)
draw_text(x, y, w, line_height, PC_Scene::Money_Vocab)
else
draw_icon(@item.icon_index, ix, y, true)
change_color(normal_color, true)
draw_text(x, y, w, line_height, @item.name)
end
end
#----------------------------------------------------------------------------
def item_y
return 0
end
#-----------------------------------------------------------------------------
def figures
return 4
end
#-----------------------------------------------------------------------------
def update_number
super
end
#-----------------------------------------------------------------------------
def update_cursor
cursor_rect.set(0, 0, 0, 0)
end
#-----------------------------------------------------------------------------
def change_number(amount)
@number = [[@number + amount, @max].min, 0].max
end
#-----------------------------------------------------------------------------
def set(item, max, price, currency_unit = nil)
@item = item
@max = max
@price = price
@currency_unit = currency_unit if currency_unit
@number = @item == $data_items[0] ? 0 : 1
refresh
end
end
#===============================================================================
class Window_Chest_Item_Help < Window_Base
#===============================================================================
def initialize(line_number = 2)
super(0, 0, Graphics.width/4*3, fitting_height(line_number))
@item = nil
end
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
def set_item(item)
return if @item == item
@item = item
refresh
set_text(item ? item.description : "")
end
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
#--------------------------------------------------------------------------
def reset_font_settings
change_color(normal_color)
self.contents.font.name = ["VL Gothic","Serif","Arial"]
self.contents.font.size = 15
self.contents.font.bold = true
end
end
#===============================================================================
class Window_PC_GOLD < Window_Gold
#===============================================================================
#-----------------------------------------------------------------------------
def window_width
return ((Graphics.width / 4 * 2))
end
#-----------------------------------------------------------------------------
def refresh
contents.clear
draw_gold
end
#-----------------------------------------------------------------------------
def draw_gold
x = 0 ; y = 0
change_color(normal_color)
draw_text(x, y, window_width, line_height, PC_Scene::Current_Money_Vocab)
draw_text(x, y, window_width-24, line_height, unit, 2)
end
#-----------------------------------------------------------------------------
def unit
sprintf(PC_Scene::Money_Prefix, value)
end
end
#==============================================================================
class Window_PC_GOLD_InChest_Item < Window_PC_GOLD
#==============================================================================
#-----------------------------------------------------------------------------
def draw_gold
x = 0 ; y = 0
change_color(normal_color)
draw_text(x, y, window_width, line_height, PC_Scene::Chest_Item_Money_Vocab)
draw_text(x, y, window_width-24, line_height, unit, 2)
end
#-----------------------------------------------------------------------------
def value
$chest_item.cash
end
end
#===============================================================================
class Window_Player_PC_Command < Window_Command
#===============================================================================
#-----------------------------------------------------------------------------
def initialize(x, y)
super(x, y)
draw_items_info
type
end
#-----------------------------------------------------------------------------
def change_type(type = :items)
@type = type
end
#-----------------------------------------------------------------------------
def type
@type
end
#-----------------------------------------------------------------------------
def window_width
return Graphics.width - (Graphics.width / 4 * 2)
end
#-----------------------------------------------------------------------------
def window_height
return Graphics.height - fitting_height(6)
end
#-----------------------------------------------------------------------------
def make_command_list
case @type
when :items
for item in $chest_item.items
add_item_command(item)
end
when :weapons
for item in $chest_item.weapons
add_item_command(item)
end
when :armors
for item in $chest_item.armors
add_item_command(item)
end
end
end
#-----------------------------------------------------------------------------
def add_item_command(item)
add_command("" , :avail_item, true)
end
#-----------------------------------------------------------------------------
def draw_items_info
x = 0 ; y = 0
case @type
when :items
for item in $chest_item.items
y = draw_infoo(x, y, item)
end
when :weapons
for item in $chest_item.weapons
y = draw_infoo(x, y, item)
end
when :armors
for item in $chest_item.armors
y = draw_infoo(x, y, item)
end
end
end
#-----------------------------------------------------------------------------
def draw_infoo(x, y, item)
draw_icon(item[0].icon_index, x, y, true)
change_color(normal_color)
draw_text(x+25, y, window_width-50, line_height, item[0].name, 0)
draw_text(x, y, window_width-25, line_height, "x#{item[1]} ", 2)
return y + line_height
end
#-----------------------------------------------------------------------------
def refresh
super
draw_items_info
end
end
#==============================================================================
class Window_Player_PC_Bag_Command < Window_Player_PC_Command
#==============================================================================
#-----------------------------------------------------------------------------
def make_command_list
case @type
when :items
for item in $game_party.items
add_item_command(item)
end
when :weapons
for item in $game_party.weapons
add_item_command(item)
end
when :armors
for item in $game_party.armors
add_item_command(item)
end
end
end
#-----------------------------------------------------------------------------
def add_item_command(item)
add_command("" , :avail_item, true)
end
#-----------------------------------------------------------------------------
def draw_items_info
x = 0
y = 0
case @type
when :items
for item in $game_party.items
y = draw_infoo(x, y, item)
end
when :weapons
for item in $game_party.weapons
y = draw_infoo(x, y, item)
end
when :armors
for item in $game_party.armors
y = draw_infoo(x, y, item)
end
end
end
#-----------------------------------------------------------------------------
def draw_infoo(x, y, item)
draw_icon(item.icon_index, x, y, true)
change_color(normal_color)
draw_text(x+25, y, window_width-50, line_height, item.name, 0)
item_count = $game_party.item_number(item)
draw_text(x, y, window_width-25, line_height, "x#{item_count} ", 2)
return y + line_height
end
end
#===============================================================================
class Window_Player_PC_Action_Command < Window_Command
#===============================================================================
#-----------------------------------------------------------------------------
def window_width
return Graphics.width/4
end
#-----------------------------------------------------------------------------
def make_command_list
add_command(PC_Scene::Deposit_Vocab, :deposit)
add_command(PC_Scene::Withdraw_Vocab, :withdraw)
end
end
#==============================================================================
class Window_Player_PC_Action_Command_2 < Window_HorzCommand
#==============================================================================
#-----------------------------------------------------------------------------
def window_width
return Graphics.width
end
#-----------------------------------------------------------------------------
def make_command_list
add_command(PC_Scene::Money_Vocab, :cash)
add_command(PC_Scene::Items_Vocab, :items)
add_command(PC_Scene::Weapons_Vocab, :weapons)
add_command(PC_Scene::Armors_Vocab, :armors)
end
#-----------------------------------------------------------------------------
def col_max
return 4
end
end
#===============================================================================
class Scene_Chest_Item < Scene_MenuBase
#===============================================================================
#-----------------------------------------------------------------------------
def start
super
create_help_window
create_action_commands
create_action_commands_2
create_main_commands
create_player_bag_commands
create_number_window
create_gold_window
create_chest_item_gold_window
end
#-----------------------------------------------------------------------------
def create_help_window
@help_window = Window_Chest_Item_Help.new
@help_window.viewport = @viewport
@help_window.x = Graphics.width / 4
end
#-----------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_PC_GOLD.new
@gold_window.x = 0
@gold_window.y = @action_com_wind_2.y + @action_com_wind_2.height
end
#-----------------------------------------------------------------------------
def create_chest_item_gold_window
@chest_item_gold_window = Window_PC_GOLD_InChest_Item.new
@chest_item_gold_window.x = ((Graphics.width / 4 * 2))
@chest_item_gold_window.y = @action_com_wind_2.y + @action_com_wind_2.height
end
#-----------------------------------------------------------------------------
def create_action_commands
wx = @help_window.x
wy = @help_window.height
@action_com_wind = Window_Player_PC_Action_Command.new(0, 0)
@action_com_wind.set_handler(:deposit, method(:command_trigger_nxt_choice))
@action_com_wind.set_handler(:withdraw, method(:command_trigger_nxt_choice))
@action_com_wind.set_handler(:cancel, method(:return_scene))
@my_current_symbol = :deposit
end
#-----------------------------------------------------------------------------
def create_action_commands_2
y = @help_window.height
@action_com_wind_2 = Window_Player_PC_Action_Command_2.new(0, y)
@action_com_wind_2.set_handler(:cash, method(:command_trigger_cash))
@action_com_wind_2.set_handler(:items, method(:command_trigger_items))
@action_com_wind_2.set_handler(:weapons, method(:command_trigger_weapons))
@action_com_wind_2.set_handler(:armors, method(:command_trigger_armors))
@action_com_wind_2.set_handler(:cancel, method(:command_back_to_firstchoice))
@action_com_wind_2.deactivate
@action_com_wind_2.select(-1)
end
#-----------------------------------------------------------------------------
def create_main_commands
wx = Graphics.width / 2
wy = @action_com_wind_2.y + (@action_com_wind_2.height * 2)
@main_com_wind = Window_Player_PC_Command.new(wx, wy)
@main_com_wind.set_handler(:avail_item, method(:command_items))
@main_com_wind.set_handler(:cancel, method(:command_back_to_2nd_choice))
@main_com_wind.deactivate
@main_com_wind.select(-1)
end
#-----------------------------------------------------------------------------
def create_player_bag_commands
wx = 0
wy = @action_com_wind_2.y + (@action_com_wind_2.height * 2)
@bag_com_wind = Window_Player_PC_Bag_Command.new(wx, wy)
@bag_com_wind.set_handler(:avail_item, method(:command_items))
@bag_com_wind.set_handler(:cancel, method(:command_back_to_2nd_choice))
@bag_com_wind.deactivate
@bag_com_wind.select(-1)
end
#-----------------------------------------------------------------------------
def create_number_window
wx = Graphics.width / 4
wy = @action_com_wind.y + @action_com_wind.height
@number_window = Window_Player_PC_Number.new(wx, wy)
@number_window.viewport = @viewport
@number_window.set_handler(:ok, method(:confirm_numbers))
@number_window.set_handler(:cancel, method(:cancel_numbers))
@number_window.hide
end
#-----------------------------------------------------------------------------
def command_trigger_nxt_choice
@action_com_wind_2.activate
@action_com_wind_2.select(0)
end
#-----------------------------------------------------------------------------
def command_trigger_cash
item = $data_items[0]
case @action_com_wind.current_symbol
when :deposit ; max = $game_party.gold
price = $game_party.gold == 0 ? 0 : 1
when :withdraw ; max = $chest_item.cash
price = $chest_item.cash == 0 ? 0 : 1
end
@action_com_wind_2.deactivate
@number_window.set(item, max, price)
@number_window.open
@number_window.activate
@number_window.show
end
#-----------------------------------------------------------------------------
def command_trigger_items
@action_com_wind_2.deactivate
case @action_com_wind.current_symbol
when :deposit
@bag_com_wind.activate
@bag_com_wind.select(0)
when :withdraw
@main_com_wind.activate
@main_com_wind.select(0)
end
end
#-----------------------------------------------------------------------------
def command_trigger_weapons
@action_com_wind_2.deactivate
case @action_com_wind.current_symbol
when :deposit
@bag_com_wind.activate
@bag_com_wind.select(0)
when :withdraw
@main_com_wind.activate
@main_com_wind.select(0)
end
end
#-----------------------------------------------------------------------------
def command_trigger_armors
@action_com_wind_2.deactivate
case @action_com_wind.current_symbol
when :deposit
@bag_com_wind.activate
@bag_com_wind.select(0)
when :withdraw
@main_com_wind.activate
@main_com_wind.select(0)
end
end
#-----------------------------------------------------------------------------
def command_back_to_firstchoice
@action_com_wind_2.deactivate
@action_com_wind_2.select(-1)
@action_com_wind.activate
end
#-----------------------------------------------------------------------------
def command_back_to_2nd_choice
@main_com_wind.deactivate
@main_com_wind.select(-1)
@bag_com_wind.deactivate
@bag_com_wind.select(-1)
@action_com_wind_2.activate
end
#-----------------------------------------------------------------------------
def command_items
case @action_com_wind_2.current_symbol
when:items
case @action_com_wind.current_symbol
when :deposit
item = $data_items[$game_party.items[@bag_com_wind.index].id]
max = $game_party.item_number(item)
when :withdraw
item = $chest_item.items[@main_com_wind.index][0]
max = $chest_item.items[@main_com_wind.index][1]
end
when :weapons
case @action_com_wind.current_symbol
when :deposit
item = $data_weapons[$game_party.weapons[@bag_com_wind.index].id]
max = $game_party.item_number(item)
when :withdraw
item = $chest_item.weapons[@main_com_wind.index][0]
max = $chest_item.weapons[@main_com_wind.index][1]
end
when :armors
case @action_com_wind.current_symbol
when :deposit
item = $data_armors[$game_party.armors[@bag_com_wind.index].id]
max = $game_party.item_number(item)
when :withdraw
item = $chest_item.armors[@main_com_wind.index][0]
max = $chest_item.armors[@main_com_wind.index][1]
end
end
price = 1
@number_window.set(item, max, price)
@number_window.activate
@number_window.show
end
#-----------------------------------------------------------------------------
def confirm_numbers
case @action_com_wind.current_symbol
when :deposit
case @action_com_wind_2.current_symbol
when :cash
deposit_cash(@number_window.number)
@action_com_wind_2.activate
when :items
deposit_items(@number_window.number)
@bag_com_wind.activate
when :weapons
deposit_weapons(@number_window.number)
@bag_com_wind.activate
when :armors
deposit_armors(@number_window.number)
@bag_com_wind.activate
end
when :withdraw
case @action_com_wind_2.current_symbol
when :cash
withdraw_cash(@number_window.number)
@action_com_wind_2.activate
when :items
withdraw_items(@number_window.number)
@main_com_wind.activate
when :weapons
withdraw_weapons(@number_window.number)
@main_com_wind.activate
when :armors
withdraw_armors(@number_window.number)
@main_com_wind.activate
end
end
@number_window.deactivate
@number_window.hide
end
#-----------------------------------------------------------------------------
def cancel_numbers
case @action_com_wind.current_symbol
when :deposit
case @action_com_wind_2.current_symbol
when :cash
@action_com_wind_2.activate
when :items, :weapons, :armors
@bag_com_wind.activate
end
when :withdraw
case @action_com_wind_2.current_symbol
when :cash
@action_com_wind_2.activate
when :items, :weapons, :armors
@main_com_wind.activate
end
end
@number_window.deactivate
@number_window.hide
end
#-----------------------------------------------------------------------------
def deposit_cash(amount)
$game_party.lose_gold(amount)
$chest_item.gain_cash(amount)
@gold_window.refresh
@chest_item_gold_window.refresh
end
#-----------------------------------------------------------------------------
def withdraw_cash(amount)
$game_party.gain_gold(amount)
$chest_item.lose_cash(amount)
@gold_window.refresh
@chest_item_gold_window.refresh
end
#-----------------------------------------------------------------------------
def deposit_items(amount)
inv_item = $game_party.items[@bag_com_wind.index].id
$game_party.lose_item($data_items[inv_item], amount)
already_had_item = false
$chest_item.items.each {|item|
item[1] += amount if item[0].id == inv_item
already_had_item = true if item[0].id == inv_item ; }
$chest_item.add_to_items(inv_item, amount) if !already_had_item
@bag_com_wind.refresh
@main_com_wind.refresh
@bag_com_wind.activate
end
#-----------------------------------------------------------------------------
def withdraw_items(amount)
gsi = $chest_item.items[@main_com_wind.index]
gsi[1] -= amount
$game_party.gain_item(gsi[0], amount)
if gsi[1] < 1
$chest_item.items.delete_at(@main_com_wind.index)
@main_com_wind.index = 0
end
@main_com_wind.refresh
@bag_com_wind.refresh
@main_com_wind.activate
end
#-----------------------------------------------------------------------------
def deposit_weapons(amount)
inv_item = $game_party.weapons[@bag_com_wind.index].id
$game_party.lose_item($data_weapons[inv_item], amount)
already_had_item = false
$chest_item.weapons.each {|item|
item[1] += amount if item[0].id == inv_item
already_had_item = true if item[0].id == inv_item ; }
$chest_item.add_to_weapons(inv_item, amount) if !already_had_item
@bag_com_wind.refresh
@main_com_wind.refresh
@bag_com_wind.activate
end
#-----------------------------------------------------------------------------
def withdraw_weapons(amount)
gsi = $chest_item.weapons[@main_com_wind.index]
gsi[1] -= amount
$game_party.gain_item(gsi[0], amount)
if gsi[1] < 1
$chest_item.weapons.delete_at(@main_com_wind.index)
@main_com_wind.index = 0
end
@main_com_wind.refresh
@bag_com_wind.refresh
@main_com_wind.activate
end
#-----------------------------------------------------------------------------
def deposit_armors(amount)
inv_item = $game_party.armors[@bag_com_wind.index].id
$game_party.lose_item($data_armors[inv_item], amount)
already_had_item = false
$chest_item.items.each {|item|
item[1] += amount if item[0].id == inv_item
already_had_item = true if item[0].id == inv_item ; }
$chest_item.add_to_armors(inv_item, amount) if !already_had_item
@bag_com_wind.refresh
@main_com_wind.refresh
@bag_com_wind.activate
end
#-----------------------------------------------------------------------------
def withdraw_armors(amount)
gsi = $chest_item.armors[@main_com_wind.index]
gsi[1] -= amount
$game_party.gain_item(gsi[0], amount)
if gsi[1] < 1
$chest_item.armors.delete_at(@main_com_wind.index)
@main_com_wind.index = 0
end
@main_com_wind.refresh
@bag_com_wind.refresh
@main_com_wind.activate
end
#-----------------------------------------------------------------------------
def update
super
update_help_text
update_wind_type
end
#-----------------------------------------------------------------------------
def update_help_text
if @action_com_wind.active
update_text_one
elsif @action_com_wind_2.active
update_text_two
elsif @main_com_wind.active
update_text_three
end
end
#-----------------------------------------------------------------------------
def update_text_one
text = @action_com_wind.current_symbol == :deposit ?
PC_Scene::Deposit_Info : PC_Scene::Withdraw_Info
@help_window.set_text(text)
end
#-----------------------------------------------------------------------------
def update_text_two
case @action_com_wind_2.current_symbol
when :cash ;
text = @action_com_wind.current_symbol == :deposit ?
PC_Scene::Deposit_Cash : PC_Scene::Withdraw_Cash
when :items ; text = PC_Scene::Withdraw_Info
text = @action_com_wind.current_symbol == :deposit ?
PC_Scene::Deposit_Items : PC_Scene::Withdraw_Items
when :weapons ; text = PC_Scene::Withdraw_Info
text = @action_com_wind.current_symbol == :deposit ?
PC_Scene::Deposit_Weapons : PC_Scene::Withdraw_Weapons
when :armors ; text = PC_Scene::Withdraw_Info
text = @action_com_wind.current_symbol == :deposit ?
PC_Scene::Deposit_Armors : PC_Scene::Withdraw_Armors
end
@help_window.set_text(text)
end
#-----------------------------------------------------------------------------
def update_text_three
case @action_com_wind_2.current_symbol
#when :cash ;
when :items ; text = PC_Scene::Withdraw_Info
text = $chest_item.items[@main_com_wind.index] == nil ?
"" : $chest_item.items[@main_com_wind.index][0]
when :weapons ; text = PC_Scene::Withdraw_Info
text = $chest_item.weapons[@main_com_wind.index] == nil ?
"" : $chest_item.weapons[@main_com_wind.index][0]
when :armors ; text = PC_Scene::Withdraw_Info
text = $chest_item.armors[@main_com_wind.index] == nil ?
"" : $chest_item.armors[@main_com_wind.index][0]
end
return if text = ""
@help_window.set_item(text)
end
#-----------------------------------------------------------------------------
def update_wind_type
if @main_com_wind.type != @action_com_wind_2.current_symbol
@main_com_wind.change_type(@action_com_wind_2.current_symbol)
@main_com_wind.refresh
end
if @bag_com_wind.type != @action_com_wind_2.current_symbol
@bag_com_wind.change_type(@action_com_wind_2.current_symbol)
@bag_com_wind.refresh
end
end
end |
Администратор запретил публиковать записи гостям.
За этот пост поблагодарили: Dmy
|
[VXA] Временное хранение всего инвентаря (сундук) 3 года 10 мес. назад #121566
|
akito66 пишет:
Так первый найденный мной несовместимый скрипт FP Inventory Plus он отвечает за придание всем вещам веса Вот очень простой аналог моего скрипта для FP Inventory Plus (по сути FP Inventory Plus меняет так много, что от моего скрипта ничего не осталось). Код некрасивый, но работает.class Game_Inventory
attr_accessor :testing_discards
attr_accessor :discards_found
def transfer_all_to(second_inventory)
second_inventory.accept_all_from(self)
clear_inventory
end
def accept_all_from(other_inventory)
accept_all_of_type($data_items, other_inventory.items)
accept_all_of_type($data_weapons, other_inventory.weapons)
accept_all_of_type($data_armors, other_inventory.armors)
end
def accept_all_of_type(data_array, items)
items.each do |item|
gain_item(data_array[item.id], item.count)
if testing_discards && discards_found then
break
end
end
end
def can_accept_all_from?(other_inventory)
temp_clone = self.clone
temp_clone.discards_found = false
temp_clone.clone_internal_objects
temp_clone.testing_discards = true
temp_clone.accept_all_from(other_inventory)
return !temp_clone.discards_found
end
def clone_internal_objects
@items = @items.clone
@weapons = @weapons.clone
@armors = @armors.clone
@discards = @discards.clone
end
alias :grbfpichest_update_discards :update_discards
def update_discards(item, remains)
if testing_discards then
return unless remains > 0
@discards_found = true
else
grbfpichest_update_discards(item, remains)
end
end
end
class Game_Chest < Game_Inventory
def initialize
super
@weight_limit = Float::INFINITY
@inventory_limit = Float::INFINITY
end
def max_weight
@weight_limit = Float::INFINITY
@weight_limit
end
end
class Game_Chests
attr_reader :chests
def initialize
@chests = {}
end
def [](chest_id)
@chests[chest_id] = Game_Chest.new unless @chests[chest_id]
return @chests[chest_id]
end
def []=(chest_id, chest)
@chests[chest_id] = chest
end
def empty_chest?(chest_id = :default)
@chests[chest_id] ? @chests[chest_id].all_items.size == 0 : true
end
def all_into_chest(chest_id = :default)
chest = self[chest_id]
$game_party.inventory.transfer_all_to(chest)
end
def all_from_chest(chest_id = :default)
chest = self[chest_id]
chest.transfer_all_to($game_party.inventory)
end
end
class << DataManager
alias :grbfpichest_create_game_objects :create_game_objects
def create_game_objects
grbfpichest_create_game_objects
$game_chests = Game_Chests.new
end
alias :grbfpichest_make_save_contents :make_save_contents
def make_save_contents
contents = grbfpichest_make_save_contents
contents[:chests] = $game_chests
contents
end
alias :grbfpichests_extract_save_contents :extract_save_contents
def extract_save_contents(contents)
grbfpichests_extract_save_contents(contents)
$game_chests = contents[:chests] or Game_Chests.new
end
end
def dmy_into_chest(chest_id = :default)
$game_chests.all_into_chest(chest_id)
end
def dmy_from_chest(chest_id = :default)
$game_chests.all_from_chest(chest_id)
end
def dmy_chest_has_items?(chest_id = :default)
!$game_chests.empty_chest?(chest_id)
end
def dmy_chest_can_be_taken?(chest_id = :default)
$game_party.inventory.can_accept_all_from?($game_chests[chest_id])
end
После команд можно указывать код сундука (через пробел). Если его не указать, используется код :default |
Администратор запретил публиковать записи гостям.
За этот пост поблагодарили: Cabbit
|
Модераторы: NeKotZima
Время создания страницы: 0.466 секунд