pigu_6

Galv| Item/Bank Storage

Nov 24th, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.48 KB | None | 0 0
  1.  
  2. #------------------------------------------------------------------------------#
  3. # Galv's Item/Bank Storage
  4. #------------------------------------------------------------------------------#
  5. # For: RPGMAKER VX ACE
  6. # Version 1.7
  7. #------------------------------------------------------------------------------#
  8. # 2012-10-24 - Version 1.7 - Added multiple storages controlled with variable.
  9. # - Changed name to Item/Bank Storage
  10. # - changed alias naming for compatibility
  11. # 2012-10-19 - Version 1.6 - Bug fixes
  12. # 2012-10-19 - Version 1.5 - Fixed a max gold and withdrawing issue.
  13. # - Added deposit all and withdraw all gold buttons.
  14. # - party gold and item limits can now be set or use
  15. # - the limit from a limit breaking script. (in theory)
  16. # 2012-10-18 - Version 1.4 - Other small fixes
  17. # 2012-10-18 - Version 1.3 - Added banking SE
  18. # 2012-10-18 - Version 1.2 - Added gold storage and more script calls
  19. # 2012-10-17 - Version 1.1 - Added script calls to control stored items.
  20. # 2012-10-16 - Version 1.0 - Released
  21. #------------------------------------------------------------------------------#
  22. # An item storage script. Allows the player to store as many items as he/she
  23. # requires in bank-like storage that can be accessed from anywhere.
  24. #
  25. # This script differs to my "Multiple Storage containers" script in that you
  26. # can have "banks" that store items and gold and can be accessed from anywhere.
  27. # It was designed to be used for one bank, but now has option to have more if
  28. # required.
  29. #
  30. # My "Multiple Storage Containers" script stores only items within certain
  31. # events that can only be accessed by activating the particular event. This was
  32. # designed for location specific containers like chests, barrels, etc.
  33. #
  34. # Here are some script calls that might be useful:
  35. #------------------------------------------------------------------------------#
  36. #
  37. # open_storage # Opens the item storage scene
  38. #
  39. # store_add(type, id, amount) # creates an item in storage
  40. # store_rem(type, id, amount) # destroys an item in storage
  41. # store_count(type, id) # returns amount of an item in storage
  42. #
  43. # bank_add(amount) # adds amount of gold to bank
  44. # bank_rem(amount) # removes amount of gold from bank
  45. # bank_count # returns amount of gold in bank
  46. #
  47. #------------------------------------------------------------------------------#
  48. # EXPLAINATION:
  49. # type this can be "weapon", "armor" or "item"
  50. # id the ID of the item/armor/weapon
  51. # amount the number of the item/armor/weapon/gold you want to remove
  52. #
  53. # EXAMPLE OF USE:
  54. # store_add("weapon", 5, 20)
  55. # store_rem("item", 18, 99)
  56. # store_count("armor", 1)
  57. # bank_add(100)
  58. #------------------------------------------------------------------------------#
  59. # More setup options further down.
  60. #------------------------------------------------------------------------------#
  61.  
  62. $imported = {} if $imported.nil?
  63. $imported["Item_Storage"] = true
  64.  
  65. module Storage
  66.  
  67. #------------------------------------------------------------------------------#
  68. # SCRIPT SETUP OPTIONS
  69. #------------------------------------------------------------------------------#
  70.  
  71. # BOX VARIABLE
  72. BOX_VAR = 0 # This is the variable ID to use to determine which box you are
  73. # adding/removing items from. Set the variable to a box number
  74. # right before any add/remove or opening storage script calls
  75. # to tell them which box they will affect.
  76. # Set to 0 if you only want 1 box storage in your game. You
  77. # then don't have to change a variable before each script call.
  78.  
  79.  
  80. # COMMAND LIST VOCAB
  81. BANK = "Bank"
  82. STORE = "Store Item"
  83. REMOVE = "Remove Item"
  84. CANCEL = "Cancel"
  85.  
  86. # OTHER VOCAB
  87. IN_STORAGE = "In Storage"
  88. IN_INVENTORY = "In Inventory"
  89.  
  90. GOLD_INVENTORY = "Party:"
  91. GOLD_BANKED = "Banked:"
  92. BANK_HELP = "Hold DOWN to deposit. Hold UP to withdraw." + "\n" +
  93. "Press R to deposit all. Press L to withdraw all."
  94.  
  95.  
  96. # OTHER OPTIONS
  97. SE = ["Equip2", 90, 100] # Sound effect when storing/removing an item
  98. SE_BANK = ["Shop", 50, 150] # Repeating sound effect when banking gold
  99. # ["SE Name", volume, pitch]
  100.  
  101. STORE_PRICELESS = true # Items worth 0 can be stored? true or false
  102. STORE_KEY = true # Key items can be stored? true or false
  103.  
  104.  
  105. # PARTY LIMITS
  106. # NOTE: These limits set to 0 will use the default limits. In theory this will
  107. # be compatible with a limit breaker script by leaving them at 0. Or you can
  108. # set the party limits below to whatever you like.
  109.  
  110. MAX_GOLD = 0 # Max gold your PARTY can carry.
  111. # This will overwrite the default limit.
  112. # 0 means do not use this.
  113.  
  114. MAX_ITEMS = 0 # Max items your PARTY can carry.
  115. # This will overwrite the default limit.
  116. # 0 means do not use this.
  117.  
  118.  
  119. #------------------------------------------------------------------------------#
  120. # SCRIPT SETUP OPTIONS
  121. #------------------------------------------------------------------------------#
  122.  
  123. end
  124.  
  125.  
  126. class Scene_ItemBank < Scene_MenuBase
  127. def start
  128. super
  129. check_storage_exists
  130. create_help_window
  131. create_command_window
  132. create_dummy_window
  133. create_bank_window
  134. create_number_window
  135. create_status_window
  136. create_category_window
  137. create_take_window
  138. create_give_window
  139.  
  140. end
  141.  
  142. def check_storage_exists
  143. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].nil?
  144. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]] = {}
  145. end
  146. end
  147.  
  148.  
  149. #--------------------------------------------------------------------------
  150. # Create Windows
  151. #--------------------------------------------------------------------------
  152. def create_command_window
  153. @command_window = Window_BankCommand.new(Graphics.width)
  154. @command_window.viewport = @viewport
  155. @command_window.y = @help_window.height
  156. @command_window.set_handler(:bank, method(:command_bank))
  157. @command_window.set_handler(:give, method(:command_give))
  158. @command_window.set_handler(:take, method(:command_take))
  159. @command_window.set_handler(:cancel, method(:return_scene))
  160. end
  161. def create_dummy_window
  162. wy = @command_window.y + @command_window.height
  163. wh = Graphics.height - wy
  164. @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  165. @dummy_window.viewport = @viewport
  166. end
  167. def create_bank_window
  168. @bank_window = Window_Bank.new
  169. @bank_window.viewport = @viewport
  170. @bank_window.x = 0
  171. @bank_window.y = @help_window.height + @command_window.height
  172. @bank_window.hide
  173. @bank_window.set_handler(:ok, method(:on_bank_cancel))
  174. @bank_window.set_handler(:cancel, method(:on_bank_cancel))
  175.  
  176. end
  177.  
  178. def create_number_window
  179. wy = @dummy_window.y
  180. wh = @dummy_window.height
  181. @number_window = Window_BankNumber.new(0, wy, wh)
  182. @number_window.viewport = @viewport
  183. @number_window.hide
  184. @number_window.set_handler(:ok, method(:on_number_ok))
  185. @number_window.set_handler(:cancel, method(:on_number_cancel))
  186. end
  187. def create_status_window
  188. wx = @number_window.width
  189. wy = @dummy_window.y
  190. ww = Graphics.width - wx
  191. wh = @dummy_window.height
  192. @status_window = Window_BankItems.new(wx, wy, ww, wh)
  193. @status_window.viewport = @viewport
  194. @status_window.hide
  195. end
  196. def create_category_window
  197. @category_window = Window_ItemCategory.new
  198. @category_window.viewport = @viewport
  199. @category_window.help_window = @help_window
  200. @category_window.y = @dummy_window.y
  201. @category_window.hide.deactivate
  202. @category_window.set_handler(:ok, method(:on_category_ok))
  203. @category_window.set_handler(:cancel, method(:on_category_cancel))
  204. end
  205. def create_give_window
  206. wy = @category_window.y + @category_window.height
  207. wh = Graphics.height - wy
  208. @give_window = Window_BankGive.new(0, wy, Graphics.width, wh)
  209. @give_window.viewport = @viewport
  210. @give_window.help_window = @help_window
  211. @give_window.hide
  212. @give_window.set_handler(:ok, method(:on_give_ok))
  213. @give_window.set_handler(:cancel, method(:on_give_cancel))
  214. @category_window.item_window = @give_window
  215. end
  216. def create_take_window
  217. wy = @command_window.y + @command_window.height
  218. wh = Graphics.height - wy
  219. @take_window = Window_BankTake.new(0, wy, Graphics.width, wh)
  220. @take_window.viewport = @viewport
  221. @take_window.help_window = @help_window
  222. @take_window.hide
  223. @take_window.set_handler(:ok, method(:on_take_ok))
  224. @take_window.set_handler(:cancel, method(:on_take_cancel))
  225. @category_window.item_window = @take_window
  226. end
  227.  
  228. #--------------------------------------------------------------------------
  229. # * Activate Windows
  230. #--------------------------------------------------------------------------
  231. def activate_give_window
  232. @category_window.show
  233. @give_window.refresh
  234. @give_window.show.activate
  235. @status_window.hide
  236. end
  237. def activate_take_window
  238. @take_window.select(0)
  239. @take_window.refresh
  240. @take_window.show.activate
  241. @status_window.hide
  242. end
  243. def activate_bank_window
  244. @bank_window.refresh
  245. @bank_window.show.activate
  246. @help_window.set_text(Storage::BANK_HELP)
  247. end
  248.  
  249.  
  250. #--------------------------------------------------------------------------
  251. # HANDLER METHODS
  252. #--------------------------------------------------------------------------
  253. def on_category_ok
  254. activate_give_window
  255. @give_window.select(0)
  256. end
  257. def on_category_cancel
  258. @command_window.activate
  259. @dummy_window.show
  260. @category_window.hide
  261. @give_window.hide
  262. end
  263. def command_give
  264. @dummy_window.hide
  265. @category_window.show.activate
  266. @give_window.show
  267. @give_window.unselect
  268. @give_window.refresh
  269. end
  270. def on_give_ok
  271. @item = @give_window.item
  272. if @item.nil?
  273. RPG::SE.stop
  274. Sound.play_buzzer
  275. @give_window.activate
  276. @give_window.refresh
  277. return
  278. else
  279. @status_window.item = @item
  280. @category_window.hide
  281. @give_window.hide
  282. @number_window.set(@item, max_give)
  283. @number_window.show.activate
  284. @status_window.show
  285. end
  286. end
  287. def on_give_cancel
  288. @give_window.unselect
  289. @category_window.activate
  290. @status_window.item = nil
  291. @help_window.clear
  292. end
  293. def command_take
  294. @dummy_window.hide
  295. activate_take_window
  296. @take_window.show
  297. @take_window.refresh
  298. end
  299. def command_bank
  300. #@dummy_window.hide
  301. activate_bank_window
  302. @bank_window.show
  303. @bank_window.refresh
  304. end
  305. def on_bank_cancel
  306. @command_window.activate
  307. @dummy_window.show
  308. @category_window.hide
  309. @bank_window.hide
  310. @help_window.clear
  311. end
  312. def on_take_ok
  313. @item = @take_window.item
  314. if @item.nil? || $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].empty? || $game_party.item_number(@item) == $game_party.max_item_number(@item)
  315. RPG::SE.stop
  316. Sound.play_buzzer
  317. @take_window.activate
  318. @take_window.refresh
  319. return
  320. elsif
  321. @item = @take_window.item
  322. @status_window.item = @item
  323. @take_window.hide
  324. @number_window.set(@item, max_take)
  325. @number_window.show.activate
  326. @status_window.show
  327. end
  328. end
  329. def on_take_cancel
  330. @take_window.unselect
  331. @command_window.activate
  332. @dummy_window.show
  333. @take_window.hide
  334. @status_window.item = nil
  335. @help_window.clear
  336. end
  337. def on_number_ok
  338. RPG::SE.new(Storage::SE[0], Storage::SE[1], Storage::SE[2]).play
  339. case @command_window.current_symbol
  340. when :take
  341. do_take(@number_window.number)
  342. when :give
  343. do_give(@number_window.number)
  344. end
  345. end_number_input
  346. @status_window.refresh
  347. end
  348. def on_number_cancel
  349. Sound.play_cancel
  350. end_number_input
  351. end
  352. def end_number_input
  353. @number_window.hide
  354. case @command_window.current_symbol
  355. when :take
  356. activate_take_window
  357. when :give
  358. activate_give_window
  359. end
  360. end
  361.  
  362. #--------------------------------------------------------------------------
  363. # * Giving and taking methods
  364. #--------------------------------------------------------------------------
  365. def max_take
  366. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] > $game_party.max_item_number(@item) - $game_party.item_number(@item)
  367. $game_party.max_item_number(@item) - $game_party.item_number(@item)
  368. else
  369. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item]
  370. end
  371. end
  372. def max_give
  373. $game_party.item_number(@item)
  374. end
  375. def do_give(number)
  376. $game_party.lose_item(@item, number)
  377. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item].nil?
  378. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] = number
  379. else
  380. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] += number
  381. end
  382. end
  383. def do_take(number)
  384. return if @item.nil?
  385. $game_party.gain_item(@item, number)
  386. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] -= number
  387. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].delete(@item) if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] <= 0
  388. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].empty?
  389. @take_window.activate
  390. end
  391. end
  392.  
  393. end # Scene_ItemBank < Scene_MenuBase
  394.  
  395.  
  396. #------------------------------------------------------------------------------#
  397. # Window Stored Items
  398. #------------------------------------------------------------------------------#
  399.  
  400. class Window_StoreList_Bank < Window_Selectable
  401. def initialize(x, y, width, height)
  402. super
  403. @category = :none
  404. @data = []
  405. end
  406. def category=(category)
  407. return if @category == category
  408. @category = category
  409. refresh
  410. self.oy = 0
  411. end
  412. def col_max
  413. return 2
  414. end
  415. def item_max
  416. @data ? @data.size : 1
  417. end
  418. def item
  419. @data && index >= 0 ? @data[index] : nil
  420. end
  421. def current_item_enabled?
  422. enable?(@data[index])
  423. end
  424. def include?(item)
  425. case @category
  426. when :item
  427. item.is_a?(RPG::Item) && !item.key_item?
  428. when :weapon
  429. item.is_a?(RPG::Weapon)
  430. when :armor
  431. item.is_a?(RPG::Armor)
  432. when :key_item
  433. item.is_a?(RPG::Item) && item.key_item?
  434. else
  435. false
  436. end
  437. end
  438. def enable?(item)
  439. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].has_key?(item)
  440. end
  441. def make_item_list
  442. @data = $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].keys {|item| include?(item) }
  443. @data.push(nil) if include?(nil)
  444. end
  445. def select_last
  446. select(@data.index($game_party.last_item.object) || 0)
  447. end
  448. def draw_item(index)
  449. item = @data[index]
  450. if item
  451. rect = item_rect(index)
  452. rect.width -= 4
  453. draw_item_name(item, rect.x, rect.y, enable?(item))
  454. draw_item_number(rect, item)
  455. end
  456. end
  457. def draw_item_number(rect, item)
  458. draw_text(rect, sprintf(":%2d", $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][item]), 2)
  459. end
  460. def update_help
  461. @help_window.set_item(item)
  462. end
  463. def refresh
  464. make_item_list
  465. create_contents
  466. draw_all_items
  467. end
  468. end # Window_StoreList_Bank < Window_Selectable
  469.  
  470.  
  471. #------------------------------------------------------------------------------#
  472. # Window Stored Item amount
  473. #------------------------------------------------------------------------------#
  474.  
  475. class Window_BankNumber < Window_Selectable
  476. attr_reader :number
  477. def initialize(x, y, height)
  478. super(x, y, window_width, height)
  479. @item = nil
  480. @max = 1
  481. @number = 1
  482. end
  483. def window_width
  484. return 304
  485. end
  486. def set(item, max)
  487. @item = item
  488. @max = max
  489. @number = 1
  490. refresh
  491. end
  492. def refresh
  493. contents.clear
  494. draw_item_name(@item, 0, item_y)
  495. draw_number
  496. end
  497. def draw_number
  498. change_color(normal_color)
  499. draw_text(cursor_x - 28, item_y, 22, line_height, "×")
  500. draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  501. end
  502. def item_y
  503. contents_height / 2 - line_height * 3 / 2
  504. end
  505. def cursor_width
  506. figures * 10 + 12
  507. end
  508. def cursor_x
  509. contents_width - cursor_width - 4
  510. end
  511. def figures
  512. return 2
  513. end
  514. def update
  515. super
  516. if active
  517. last_number = @number
  518. update_number
  519. if @number != last_number
  520. Sound.play_cursor
  521. refresh
  522. end
  523. end
  524. end
  525. def update_number
  526. change_number(1) if Input.repeat?(:RIGHT)
  527. change_number(-1) if Input.repeat?(:LEFT)
  528. change_number(10) if Input.repeat?(:UP)
  529. change_number(-10) if Input.repeat?(:DOWN)
  530. end
  531. def change_number(amount)
  532. @number = [[@number + amount, @max].min, 1].max
  533. end
  534. def update_cursor
  535. cursor_rect.set(cursor_x, item_y, cursor_width, line_height)
  536. end
  537.  
  538. end # Window_BankNumber < Window_Selectable
  539.  
  540.  
  541. #------------------------------------------------------------------------------#
  542. # Window Store Item Status
  543. #------------------------------------------------------------------------------#
  544.  
  545. class Window_BankItems < Window_Base
  546. def initialize(x, y, width, height)
  547. super(x, y, width, height)
  548. @item = nil
  549. @page_index = 0
  550. refresh
  551. end
  552. def refresh
  553. contents.clear
  554. draw_possession(4, 0)
  555. draw_stored(4, line_height)
  556. draw_equip_info(4, line_height * 2) if @item.is_a?(RPG::EquipItem)
  557. end
  558. def item=(item)
  559. @item = item
  560. refresh
  561. end
  562. def draw_possession(x, y)
  563. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  564. change_color(system_color)
  565. draw_text(rect, Storage::IN_INVENTORY)
  566. change_color(normal_color)
  567. draw_text(rect, $game_party.item_number(@item), 2)
  568. end
  569. def draw_stored(x, y)
  570. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  571. change_color(system_color)
  572. draw_text(rect, Storage::IN_STORAGE)
  573. change_color(normal_color)
  574. stored_amount = $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item]
  575. stored_amount = 0 if stored_amount.nil?
  576. draw_text(rect, stored_amount, 2)
  577. end
  578. def draw_equip_info(x, y)
  579. status_members.each_with_index do |actor, i|
  580. draw_actor_equip_info(x, y + line_height * (i * 2.4), actor)
  581. end
  582. end
  583. def status_members
  584. $game_party.members[@page_index * page_size, page_size]
  585. end
  586. def page_size
  587. return 4
  588. end
  589. def page_max
  590. ($game_party.members.size + page_size - 1) / page_size
  591. end
  592. def draw_actor_equip_info(x, y, actor)
  593. enabled = actor.equippable?(@item)
  594. change_color(normal_color, enabled)
  595. draw_text(x, y, 112, line_height, actor.name)
  596. item1 = current_equipped_item(actor, @item.etype_id)
  597. draw_actor_param_change(x, y, actor, item1) if enabled
  598. draw_item_name(item1, x, y + line_height, enabled)
  599. end
  600. def draw_actor_param_change(x, y, actor, item1)
  601. rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  602. change = @item.params[param_id] - (item1 ? item1.params[param_id] : 0)
  603. change_color(param_change_color(change))
  604. draw_text(rect, sprintf("%+d", change), 2)
  605. end
  606. def param_id
  607. @item.is_a?(RPG::Weapon) ? 2 : 3
  608. end
  609. def current_equipped_item(actor, etype_id)
  610. list = []
  611. actor.equip_slots.each_with_index do |slot_etype_id, i|
  612. list.push(actor.equips[i]) if slot_etype_id == etype_id
  613. end
  614. list.min_by {|item| item ? item.params[param_id] : 0 }
  615. end
  616. def update
  617. super
  618. update_page
  619. end
  620. def update_page
  621. if visible && Input.trigger?(:A) && page_max > 1
  622. @page_index = (@page_index + 1) % page_max
  623. refresh
  624. end
  625. end
  626.  
  627. end # Window_BankItems < Window_Base
  628.  
  629.  
  630. #------------------------------------------------------------------------------#
  631. # Window Give Item
  632. #------------------------------------------------------------------------------#
  633.  
  634. class Window_BankGive < Window_ItemList
  635. def initialize(x, y, width, height)
  636. super(x, y, width, height)
  637. end
  638. def current_item_enabled?
  639. enable?(@data[index])
  640. end
  641. def enable?(item)
  642. if item.is_a?(RPG::Item)
  643. return false if item.key_item? && !Storage::STORE_KEY
  644. end
  645. if Storage::STORE_PRICELESS
  646. true
  647. else
  648. item && item.price > 0
  649. end
  650. end
  651. end
  652.  
  653.  
  654. #------------------------------------------------------------------------------#
  655. # Window Take Item
  656. #------------------------------------------------------------------------------#
  657.  
  658. class Window_BankTake < Window_StoreList_Bank
  659. def initialize(x, y, width, height)
  660. super(x, y, width, height)
  661. end
  662. def current_item_enabled?
  663. enable?(@data[index])
  664. end
  665. def enable?(item)
  666. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][item] != 0 && $game_party.item_number(item) < $game_party.max_item_number(@item)
  667. end
  668. end
  669.  
  670.  
  671. #------------------------------------------------------------------------------#
  672. # Window Command
  673. #------------------------------------------------------------------------------#
  674.  
  675. class Window_BankCommand < Window_HorzCommand
  676. def initialize(window_width)
  677. @window_width = window_width
  678. super(0, 0)
  679. end
  680. def window_width
  681. @window_width
  682. end
  683. def col_max
  684. return 4
  685. end
  686. def make_command_list
  687. add_command(Storage::BANK, :bank)
  688. add_command(Storage::STORE, :give)
  689. add_command(Storage::REMOVE, :take)
  690. add_command(Storage::CANCEL, :cancel)
  691. end
  692. end
  693.  
  694.  
  695. #------------------------------------------------------------------------------#
  696. # Window Bank
  697. #------------------------------------------------------------------------------#
  698.  
  699. class Window_Bank < Window_Selectable
  700. def initialize
  701. super(0, 0, window_width, fitting_height(2))
  702. refresh
  703. @deposit_rate = 1
  704. @withdraw_rate = 1
  705. end
  706. def window_width
  707. return Graphics.width / 2
  708. end
  709. alias galv_bank_update update
  710. def update
  711. galv_bank_update
  712. gold_transfer if self.active
  713. end
  714. def gold_transfer
  715. if Input.repeat?(:DOWN) && $game_party.gold > 0 || Input.repeat?(:UP) && $game_party.gold_stored > 0 && $game_party.gold < $game_party.max_gold
  716. RPG::SE.new(Storage::SE_BANK[0], Storage::SE_BANK[1], Storage::SE_BANK[2]).play
  717. end
  718. if Input.press?(:DOWN)
  719. before = $game_party.gold
  720. $game_party.lose_gold(@deposit_rate)
  721. after = $game_party.gold
  722. $game_party.gold_stored += before - after
  723. @deposit_rate += 1
  724. refresh
  725. end
  726. if Input.trigger?(:R) && !Input.press?(:DOWN) && !Input.press?(:UP)
  727. return if $game_party.gold == 0
  728. before = $game_party.gold
  729. $game_party.lose_gold($game_party.gold)
  730. after = $game_party.gold
  731. $game_party.gold_stored += before - after
  732. refresh
  733. RPG::SE.new(Storage::SE_BANK[0], Storage::SE_BANK[1], Storage::SE_BANK[2]).play
  734. end
  735. if !Input.press?(:DOWN)
  736. @deposit_rate = 1
  737. end
  738. if Input.press?(:UP)
  739. return if $game_party.gold == $game_party.max_gold
  740. @withdraw_rate = $game_party.gold_stored if @withdraw_rate >= $game_party.gold_stored
  741. if @withdraw_rate + $game_party.gold > $game_party.max_gold
  742. @withdraw_rate = $game_party.max_gold - $game_party.gold
  743. end
  744. before = $game_party.gold_stored
  745. $game_party.gold_stored -= @withdraw_rate
  746. after = $game_party.gold_stored
  747. $game_party.gain_gold(before - after)
  748. if $game_party.gold_stored == 0
  749. return refresh
  750. end
  751. @withdraw_rate += 1
  752. refresh
  753. end
  754.  
  755. if Input.trigger?(:L) && !Input.press?(:DOWN) && !Input.press?(:UP)
  756. take_all_gold = $game_party.gold_stored
  757. return if $game_party.gold == $game_party.max_gold || $game_party.gold_stored == 0
  758. if take_all_gold + $game_party.gold > $game_party.max_gold
  759. take_all_gold = $game_party.max_gold - $game_party.gold
  760. end
  761. before = $game_party.gold_stored
  762. $game_party.gold_stored -= take_all_gold
  763. after = $game_party.gold_stored
  764. $game_party.gain_gold(before - after)
  765. refresh
  766. RPG::SE.new(Storage::SE_BANK[0], Storage::SE_BANK[1], Storage::SE_BANK[2]).play
  767. end
  768. if !Input.press?(:UP)
  769. @withdraw_rate = 1
  770. end
  771. end
  772. def refresh
  773. contents.clear
  774. draw_gold_location(Storage::GOLD_INVENTORY, 0, 0, 250)
  775. draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
  776. draw_gold_location(Storage::GOLD_BANKED, 0, line_height * 1, 250)
  777. draw_currency_value(value_stored, currency_unit, 4, line_height * 1, contents.width - 8)
  778. end
  779. def draw_gold_location(vocab, x, y, width)
  780. change_color(system_color)
  781. draw_text(x, y, width, line_height, vocab)
  782. end
  783. def value
  784. $game_party.gold
  785. end
  786. def value_stored
  787. $game_party.gold_stored
  788. end
  789. def currency_unit
  790. Vocab::currency_unit
  791. end
  792. def open
  793. refresh
  794. super
  795. end
  796. end
  797.  
  798.  
  799. #------------------------------------------------------------------------------#
  800. # Game Party Additions
  801. #------------------------------------------------------------------------------#
  802.  
  803.  
  804. class Game_Party < Game_Unit
  805. attr_accessor :multi_storage
  806. attr_accessor :gold_stored
  807.  
  808. alias galv_bank_init_all_items init_all_items
  809. def init_all_items
  810. galv_bank_init_all_items
  811. @storage = {}
  812. @stored_items = {}
  813. @stored_weapons = {}
  814. @stored_armors = {}
  815. @gold_stored = 0
  816. end
  817.  
  818. def multi_storage
  819. @storage
  820. end
  821. def storage
  822. @stored_items
  823. @stored_weapons
  824. @stored_armors
  825. end
  826. def gold_stored
  827. @gold_stored
  828. end
  829.  
  830. alias galv_bank_max_gold max_gold
  831. def max_gold
  832. return Storage::MAX_GOLD if Storage::MAX_GOLD > 0
  833. galv_bank_max_gold
  834. end
  835.  
  836. alias galv_bank_max_item_number max_item_number
  837. def max_item_number(item)
  838. return Storage::MAX_ITEMS if Storage::MAX_ITEMS > 0
  839. return 99 if item.nil?
  840. galv_bank_max_item_number(item)
  841. end
  842.  
  843. end # Game_Party < Game_Unit
  844.  
  845.  
  846. class Game_Interpreter
  847. def store_add(type, id, amount)
  848. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].nil?
  849. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]] = {}
  850. end
  851. case type
  852. when "weapon"
  853. @item = $data_weapons[id]
  854. when "item"
  855. @item = $data_items[id]
  856. when "armor"
  857. @item = $data_armors[id]
  858. end
  859. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item].nil?
  860. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] = amount
  861. else
  862. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] += amount
  863. end
  864. end
  865. def store_rem(type, id, amount)
  866. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].nil?
  867. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]] = {}
  868. end
  869. case type
  870. when "weapon"
  871. @item = $data_weapons[id]
  872. when "item"
  873. @item = $data_items[id]
  874. when "armor"
  875. @item = $data_armors[id]
  876. end
  877. return if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item].nil?
  878. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] <= amount
  879. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].delete(@item)
  880. else
  881. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item] -= amount
  882. end
  883. end
  884. def store_count(type, id)
  885. if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]].nil?
  886. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]] = {}
  887. end
  888. case type
  889. when "weapon"
  890. @item = $data_weapons[id]
  891. when "item"
  892. @item = $data_items[id]
  893. when "armor"
  894. @item = $data_armors[id]
  895. end
  896. return 0 if $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item].nil?
  897. $game_party.multi_storage[$game_variables[Storage::BOX_VAR]][@item]
  898. end
  899. def bank_add(amount)
  900. $game_party.gold_stored += amount
  901. end
  902. def bank_rem(amount)
  903. $game_party.gold_stored -= amount
  904. $game_party.gold_stored = 0 if $game_party.gold_stored < 0
  905. end
  906. def bank_count
  907. $game_party.gold_stored
  908. end
  909. def open_storage
  910. SceneManager.call(Scene_ItemBank)
  911. end
  912. end
Add Comment
Please, Sign In to add comment