- Сообщений: 201
- Спасибо получено: 198
Правила раздела:
1 Задавайте конкретные вопросы. Для болтовни есть свободный раздел.
2 По возможности давайте конкретные ответы.
3 Один вопрос=одна тема. Если хотите задать ещё вопрос, то начинайте новую тему.
4 Название темы должно составлять сам вопрос, и быть максимально конкретным. Рекомендуется начинать тему словами "Как", "Что", "Почему". А первый пост повторяет вопрос и даёт расширенные сведения.
5 Рекомендуется указывать версию мейкера (2000, 2003, RMXP, RMVX, ACE, IGM, и.т.д.. Это важно, и всё равно ведь спросят.
6 Темы "Пара вопросов", "Помогите", и подобные им - самый лёгкий путь к бану.
7 Поиск находится вверху справа.
А. Названия подразделов этого раздела уточняются. Советы принимаются.
1 Задавайте конкретные вопросы. Для болтовни есть свободный раздел.
2 По возможности давайте конкретные ответы.
3 Один вопрос=одна тема. Если хотите задать ещё вопрос, то начинайте новую тему.
4 Название темы должно составлять сам вопрос, и быть максимально конкретным. Рекомендуется начинать тему словами "Как", "Что", "Почему". А первый пост повторяет вопрос и даёт расширенные сведения.
5 Рекомендуется указывать версию мейкера (2000, 2003, RMXP, RMVX, ACE, IGM, и.т.д.. Это важно, и всё равно ведь спросят.
6 Темы "Пара вопросов", "Помогите", и подобные им - самый лёгкий путь к бану.
7 Поиск находится вверху справа.
А. Названия подразделов этого раздела уточняются. Советы принимаются.
[VX] Очищение инвентаря
Скрыть
Больше
15 года 3 мес. назад #39405
от idavollr
Her Third Eye is drawing me closer
idavollr создал тему: [VX] Очищение инвентаря
Столкнулся с проблемой. В определенный момент игры управление должно передаться совсем другому персонажу. Как это сделать-понятно. Но проблема в том, что инвентарь остается тем же самым-те зелья, которые у меня были, остаются. Получается как-то нелогично.
Как можно полностью очистить инвентарь в игре?
Заранее спасибо)))
Как можно полностью очистить инвентарь в игре?
Заранее спасибо)))
Her Third Eye is drawing me closer
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
15 года 3 мес. назад - 15 года 3 мес. назад #39406
от Avatosius
Avatosius ответил в теме Re: [VX] Очищение инвентаря
Ох, где-то я видел такой скрипт.
Сейчас поищу, он на форуме
Увы, нашёл лишь на ХР.
rpg-maker.info/forum/85-uluchshayushhie-...ave-your-items#36056
Но он маленький и с комментариями, при знании синтаксиса Руби 2 можно с лёгкостью переписать... я надеюсь.
Сейчас поищу, он на форуме
Увы, нашёл лишь на ХР.
rpg-maker.info/forum/85-uluchshayushhie-...ave-your-items#36056
Но он маленький и с комментариями, при знании синтаксиса Руби 2 можно с лёгкостью переписать... я надеюсь.
Последнее редактирование: 15 года 3 мес. назад пользователем Avatosius.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
- SaretOdin-Sol
-
- Не в сети
- Давно я тут
-
- Жизнь - не игра...Хотя кого это колышет?
Скрыть
Больше
- Сообщений: 475
- Спасибо получено: 77
15 года 3 мес. назад #39444
от SaretOdin-Sol
SaretOdin-Sol ответил в теме Re: [VX] Очищение инвентаря
Юзай этот скрипт.
ВНИМАНИЕ: Спойлер!
Code:
#==============================================================================
# ** Game_Party implementation
#------------------------------------------------------------------------------
# aliased methods : initialize
# $game_party.backup_items - Makes a copy of all currently held items and saves it to be restored later.
# $game_party.clear_items - Removes all items from the player's inventory. Don't worry, you made a copy first, right?
#
# Next, when you want to give the items back to the player, use another "Script" event command (inside a treasure chest or something) and use this single line:
# CODE
# $game_party.restore_items
#==============================================================================
class Game_Party
alias :biged_old_init :initialize
def initialize
biged_old_init
@temp_items = {} # temp items hash
@temp_weapons = {} # temp weapons hash
@temp_armors = {} # temp armors hash
@temp_gold = nil # temp gold variable
end
#--------------------------------------------------------------------------
# * if the player has picked up some items since their's were wiped
# and backed up, we need to combine the totals of any common items
#--------------------------------------------------------------------------
def merge_like_key_values(dest, src)
return if dest == {}
for key in dest.keys
src[key] += dest[key] if src.has_key?(key)
end
end
#--------------------------------------------------------------------------
# * Make a copy of the current inventory
#--------------------------------------------------------------------------
def backup_items
@temp_items = Marshal::load(Marshal::dump(@items))
@temp_weapons = Marshal::load(Marshal::dump(@weapons))
@temp_armors = Marshal::load(Marshal::dump(@armors))
end
#--------------------------------------------------------------------------
# * Clear the current inventory
#--------------------------------------------------------------------------
def clear_items
@items.clear
@weapons.clear
@armors.clear
end
#--------------------------------------------------------------------------
# * Restore the backed up inventory if a backup exists
#--------------------------------------------------------------------------
def restore_items
unless @temp_items == {}
merge_like_key_values(@items, @temp_items)
@items = @items.merge(@temp_items)
end
unless @temp_weapons == {}
merge_like_key_values(@weapons, @temp_weapons)
@weapons = @weapons.merge(@temp_weapons)
end
unless @temp_armors == {}
merge_like_key_values(@armors, @temp_armors)
@armors = @armors.merge(@temp_armors)
end
@temp_items = @temp_weapons = @temp_armors = {}
end
#--------------------------------------------------------------------------
# * Backup All mparty member's equipment
#--------------------------------------------------------------------------
def backup_all_equips
for i in @actors
$game_actors[i].backup_equips
end
end
#--------------------------------------------------------------------------
# * unequip all party member
# THE EQUIPMENT WILL BE LOST FOREVER
# IF YOU DO NOT FIRST MAKE A BACKUP!
#--------------------------------------------------------------------------
def unequip_all
for i in @actors
$game_actors[i].clear_equips
end
end
#--------------------------------------------------------------------------
# * Backup All mparty member's equipment
#--------------------------------------------------------------------------
def restore_all_equips
for i in @actors
$game_actors[i].restore_equips
end
end
#--------------------------------------------------------------------------
# * Make a copy of the current gold total
#--------------------------------------------------------------------------
def backup_gold
@temp_gold = @gold
end
#--------------------------------------------------------------------------
# * Clear the current gold total
#--------------------------------------------------------------------------
def clear_gold
@gold = 0
end
#--------------------------------------------------------------------------
# * Restore the saved gold total if one exists
#--------------------------------------------------------------------------
def restore_gold
unless @temp_gold == nil
@gold += @temp_gold
@temp_gold = nil
end
end
end
#==============================================================================
# ** Game_Actor implementation
#------------------------------------------------------------------------------
# aliased methods : initialize
#==============================================================================
class Game_Actor < Game_Battler
alias :biged_old_init :initialize
def initialize(actor_id)
biged_old_init(actor_id)
@temp_weapons = [] #temporary store for weapons
@temp_armors = [] #temporary store for armor
end
#--------------------------------------------------------------------------
# * Make a copy of the currently equiped items
#--------------------------------------------------------------------------
def backup_equips
@temp_weapons = weapons
@temp_armors = armors
end
#--------------------------------------------------------------------------
# * Restore back up equipment if it exists
#--------------------------------------------------------------------------
def restore_equips
#un-equip the current equipment and place it in the inventory
unless @temp_weapons == [] && @temp_armors == [] #no backup made
for i in 0...5 do
change_equip(i, nil)
end
end
#-------------------------------------------------------------#
#we check each one individually here because if any slot #
#is set to nil, a default value is used (not nil). This #
#default value does actually correspond to an item, and we #
#don't want that, so we check. #
#-------------------------------------------------------------#
#the incrementor is there because the armor array size will be#
#different depending on whether the player is using 2 swords #
#-------------------------------------------------------------#
@weapon_id = @temp_weapons[0].id if @temp_weapons[0] != nil
if two_swords_style
@armor1_id = @temp_weapons[1].id if @temp_weapons[1] != nil
i = 0
else
@armor1_id = @temp_armors[0].id if @temp_armors[0] != nil
i = 1
end
@armor2_id = @temp_armors[i].id if @temp_armors[i] != nil
@armor3_id = @temp_armors[i+1].id if @temp_armors[i+1] != nil
@armor4_id = @temp_armors[i+2].id if @temp_armors[i+2] != nil
@temp_weapons = @temp_armors = []
end
#--------------------------------------------------------------------------
# * Clear the currently equipped item set.
# THIS DOES NOT PLACE THE ITEMS IN INVENTORY!
# THEY WILL BE GONE FOREVER UNLESS YOU MAKE A BACKUP FIRST!
#--------------------------------------------------------------------------
def clear_equips
@weapon_id = 0
@armor1_id = 0
@armor2_id = 0
@armor3_id = 0
@armor4_id = 0
end
end
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Скрыть
Больше
- Сообщений: 201
- Спасибо получено: 198
15 года 3 мес. назад #39445
от idavollr
И вновь ты меня выручаешь)
Her Third Eye is drawing me closer
idavollr ответил в теме Re: [VX] Очищение инвентаря
Спасибо большое))SaretOdin-Sol пишет: Юзай этот скрипт.
ВНИМАНИЕ: Спойлер!Code:#============================================================================== # ** Game_Party implementation #------------------------------------------------------------------------------ # aliased methods : initialize # $game_party.backup_items - Makes a copy of all currently held items and saves it to be restored later. # $game_party.clear_items - Removes all items from the player's inventory. Don't worry, you made a copy first, right? # # Next, when you want to give the items back to the player, use another "Script" event command (inside a treasure chest or something) and use this single line: # CODE # $game_party.restore_items #============================================================================== class Game_Party alias :biged_old_init :initialize def initialize biged_old_init @temp_items = {} # temp items hash @temp_weapons = {} # temp weapons hash @temp_armors = {} # temp armors hash @temp_gold = nil # temp gold variable end #-------------------------------------------------------------------------- # * if the player has picked up some items since their's were wiped # and backed up, we need to combine the totals of any common items #-------------------------------------------------------------------------- def merge_like_key_values(dest, src) return if dest == {} for key in dest.keys src[key] += dest[key] if src.has_key?(key) end end #-------------------------------------------------------------------------- # * Make a copy of the current inventory #-------------------------------------------------------------------------- def backup_items @temp_items = Marshal::load(Marshal::dump(@items)) @temp_weapons = Marshal::load(Marshal::dump(@weapons)) @temp_armors = Marshal::load(Marshal::dump(@armors)) end #-------------------------------------------------------------------------- # * Clear the current inventory #-------------------------------------------------------------------------- def clear_items @items.clear @weapons.clear @armors.clear end #-------------------------------------------------------------------------- # * Restore the backed up inventory if a backup exists #-------------------------------------------------------------------------- def restore_items unless @temp_items == {} merge_like_key_values(@items, @temp_items) @items = @items.merge(@temp_items) end unless @temp_weapons == {} merge_like_key_values(@weapons, @temp_weapons) @weapons = @weapons.merge(@temp_weapons) end unless @temp_armors == {} merge_like_key_values(@armors, @temp_armors) @armors = @armors.merge(@temp_armors) end @temp_items = @temp_weapons = @temp_armors = {} end #-------------------------------------------------------------------------- # * Backup All mparty member's equipment #-------------------------------------------------------------------------- def backup_all_equips for i in @actors $game_actors[i].backup_equips end end #-------------------------------------------------------------------------- # * unequip all party member # THE EQUIPMENT WILL BE LOST FOREVER # IF YOU DO NOT FIRST MAKE A BACKUP! #-------------------------------------------------------------------------- def unequip_all for i in @actors $game_actors[i].clear_equips end end #-------------------------------------------------------------------------- # * Backup All mparty member's equipment #-------------------------------------------------------------------------- def restore_all_equips for i in @actors $game_actors[i].restore_equips end end #-------------------------------------------------------------------------- # * Make a copy of the current gold total #-------------------------------------------------------------------------- def backup_gold @temp_gold = @gold end #-------------------------------------------------------------------------- # * Clear the current gold total #-------------------------------------------------------------------------- def clear_gold @gold = 0 end #-------------------------------------------------------------------------- # * Restore the saved gold total if one exists #-------------------------------------------------------------------------- def restore_gold unless @temp_gold == nil @gold += @temp_gold @temp_gold = nil end end end #============================================================================== # ** Game_Actor implementation #------------------------------------------------------------------------------ # aliased methods : initialize #============================================================================== class Game_Actor < Game_Battler alias :biged_old_init :initialize def initialize(actor_id) biged_old_init(actor_id) @temp_weapons = [] #temporary store for weapons @temp_armors = [] #temporary store for armor end #-------------------------------------------------------------------------- # * Make a copy of the currently equiped items #-------------------------------------------------------------------------- def backup_equips @temp_weapons = weapons @temp_armors = armors end #-------------------------------------------------------------------------- # * Restore back up equipment if it exists #-------------------------------------------------------------------------- def restore_equips #un-equip the current equipment and place it in the inventory unless @temp_weapons == [] && @temp_armors == [] #no backup made for i in 0...5 do change_equip(i, nil) end end #-------------------------------------------------------------# #we check each one individually here because if any slot # #is set to nil, a default value is used (not nil). This # #default value does actually correspond to an item, and we # #don't want that, so we check. # #-------------------------------------------------------------# #the incrementor is there because the armor array size will be# #different depending on whether the player is using 2 swords # #-------------------------------------------------------------# @weapon_id = @temp_weapons[0].id if @temp_weapons[0] != nil if two_swords_style @armor1_id = @temp_weapons[1].id if @temp_weapons[1] != nil i = 0 else @armor1_id = @temp_armors[0].id if @temp_armors[0] != nil i = 1 end @armor2_id = @temp_armors[i].id if @temp_armors[i] != nil @armor3_id = @temp_armors[i+1].id if @temp_armors[i+1] != nil @armor4_id = @temp_armors[i+2].id if @temp_armors[i+2] != nil @temp_weapons = @temp_armors = [] end #-------------------------------------------------------------------------- # * Clear the currently equipped item set. # THIS DOES NOT PLACE THE ITEMS IN INVENTORY! # THEY WILL BE GONE FOREVER UNLESS YOU MAKE A BACKUP FIRST! #-------------------------------------------------------------------------- def clear_equips @weapon_id = 0 @armor1_id = 0 @armor2_id = 0 @armor3_id = 0 @armor4_id = 0 end end
И вновь ты меня выручаешь)
Her Third Eye is drawing me closer
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Время создания страницы: 0.098 секунд
