Advertisement
Dekita

bank 1.2

Mar 11th, 2013
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.44 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.2
  3. ★ Perfect BANK™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8. This script simply creates a "bank" scene, you can deposit / withdraw
  9. items, weapons, armors and cash.
  10. You can also set the bank to already have items ect at the start of the game.
  11.  
  12. ================================================================================
  13. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  14. ================================================================================
  15. 1. You must give credit to "Dekita"
  16. 2. You are NOT allowed to repost this script.(or modified versions)
  17. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  18. 4. You are NOT allowed to use this script for Commercial games.
  19. 5. ENJOY!
  20.  
  21. "FINE PRINT"
  22. By using this script you hereby agree to the above terms and conditions,
  23. if any violation of the above terms occurs "legal action" may be taken.
  24. Not understanding the above terms and conditions does NOT mean that
  25. they do not apply to you.
  26. If you wish to discuss the terms and conditions in further detail you can
  27. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  28.  
  29. ================================================================================
  30. History:
  31. =========
  32. D /M /Y
  33. 1o/o3/2o13 - Added x position option for money icon and text,
  34. o6/o3/2o13 - Fixed bug (equip vanish when deposit),
  35. - Added sprintf txt options for value and gold prefix,
  36. 22/o1/2o13 - Re-wired Player PC (pokemon script), into a full bank,
  37.  
  38. ================================================================================
  39. Credit and Thanks to :
  40. =======================
  41.  
  42. ================================================================================
  43. Known Bugs:
  44. ============
  45. N/A
  46.  
  47. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  48. If a new bug is found please contact me at
  49. http://dekitarpg.wordpress.com/
  50.  
  51. ================================================================================
  52. INSTRUCTIONS:
  53. ==============
  54. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  55.  
  56. ================================================================================
  57. Script Calls :
  58. ==========
  59. $game_storage.gain_cash(amount)
  60. $game_storage.add_to_items(id, amount)
  61. $game_storage.add_to_weapons(id, amount)
  62. $game_storage.add_to_armors(id, amount)
  63.  
  64. The above script calls *should* be fairly obvious, replace id with the id of
  65. the item (found in the database). replace amount with the amount you want.
  66.  
  67. =end #=========================================================================#
  68. module Game_Storage
  69.  
  70. Initial_CASH = 2000
  71.  
  72. # Format = [ [item id, amount], [item id, amount] ]
  73. Initial_Items = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]
  74.  
  75. # Format = Same As Above.
  76. Initial_Weapons = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]
  77.  
  78. # Format = Same As Above.
  79. Initial_Armors = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]
  80.  
  81. end ; module PC_Scene # DO NOT DELETE THIS LINE !!
  82.  
  83. Money_Vocab = "Money"
  84. Money_Prefix = "£ %s" # (shows as £ value)
  85. Money_Icon = 361
  86. # X position for money icon and text.
  87. Money_Icon_x = 0 # 60
  88. Money_Text_x = 25 # 0
  89.  
  90. Value_Prefix = "×%s" # (for showing selected item amounts)
  91.  
  92. Items_Vocab = "Items"
  93. Weapons_Vocab = "Weapons"
  94. Armors_Vocab = "Armors"
  95.  
  96. Current_Money_Vocab = "In Pocket :"
  97. Banked_Money_Vocab = "In Bank :"
  98.  
  99. Deposit_Vocab = "Deposit"
  100. Deposit_Info = "Deposit Money, Items or Equipment into your account."
  101. Deposit_Cash = "Deposit Money into your account."
  102. Deposit_Items = "Deposit Items into your account."
  103. Deposit_Weapons = "Deposit Weapons into your account."
  104. Deposit_Armors = "Deposit Armors into your account."
  105.  
  106. Withdraw_Vocab = "Withdraw"
  107. Withdraw_Info = "Withdraw Money, Items or Equipment from your account."
  108. Withdraw_Cash = "Withdraw Money from your account."
  109. Withdraw_Items = "Withdraw Items from your account."
  110. Withdraw_Weapons = "Withdraw Weapons into your account."
  111. Withdraw_Armors = "Withdraw Armors into your account."
  112.  
  113. # If you hold this key, while on the NUMBER screen, it will increase / decrease
  114. # the selection amount faster.
  115. Key = :SHIFT
  116.  
  117. end #####################
  118. # CUSTOMISATION END #
  119. #####################
  120. #===============================================================================#
  121. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  122. # #
  123. # http://dekitarpg.wordpress.com/ #
  124. # #
  125. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  126. #===============================================================================#
  127. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  128. # YES?\.\. #
  129. # OMG, REALLY? \| #
  130. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  131. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  132. #################################################################################
  133. # PC Scene Script 1 :~ Player PC Scene # http://dekitarpg.wordpress.com/ #
  134. #################################################################################
  135.  
  136. $imported = {} if $imported.nil?
  137. $imported[:Dekita_BANK] = true
  138.  
  139. #===============================================================================#
  140. class Window_Player_PC_Number < Window_ShopNumber #
  141. #===============================================================================#
  142.  
  143. def initialize(x, y)
  144. super(x, y, window_height)
  145. end
  146.  
  147. def window_width
  148. return Graphics.width / 2
  149. end
  150.  
  151. def window_height
  152. return line_height + 24
  153. end
  154.  
  155. def refresh
  156. contents.clear
  157. draw_the_item
  158. draw_number
  159. end
  160.  
  161. def draw_number
  162. change_color(normal_color)
  163. tx = sprintf(PC_Scene::Value_Prefix, @number)
  164. draw_text(0,0,window_width-(standard_padding*2), line_height, tx, 2)
  165. end
  166.  
  167. def draw_the_item
  168. if @item == $data_items[0]
  169. draw_icon(PC_Scene::Money_Icon, PC_Scene::Money_Icon_x, item_y, true)
  170. draw_text(PC_Scene::Money_Text_x, item_y, window_width, line_height, PC_Scene::Money_Vocab)
  171. else
  172. draw_item_name(@item, 0, item_y)
  173. end
  174. end
  175.  
  176. def item_y
  177. return 0
  178. end
  179.  
  180. def figures
  181. return 4
  182. end
  183.  
  184. def update_number
  185. if Input.press?(PC_Scene::Key)
  186. change_number(100) if Input.repeat?(:UP)
  187. change_number(-100) if Input.repeat?(:DOWN)
  188. change_number(10) if Input.repeat?(:RIGHT)
  189. change_number(-10) if Input.repeat?(:LEFT)
  190. else
  191. super
  192. end
  193. end
  194.  
  195. def update_cursor
  196. cursor_rect.set(0, 0, 0, 0)
  197. end
  198.  
  199. def change_number(amount)
  200. @number = [[@number + amount, @max].min, 0].max
  201. end
  202.  
  203. def set(item, max, price, currency_unit = nil)
  204. @item = item
  205. @max = max
  206. @price = price
  207. @currency_unit = currency_unit if currency_unit
  208. @number = @item == $data_items[0] ? 0 : 1
  209. refresh
  210. end
  211.  
  212. end
  213.  
  214. #==============================================================================
  215. class Window_PC_GOLD < Window_Gold
  216. #==============================================================================
  217.  
  218. def window_width
  219. return ((Graphics.width / 4 * 2))
  220. end
  221.  
  222. def refresh
  223. contents.clear
  224. draw_gold
  225. end
  226.  
  227. def draw_gold
  228. x = 0 ; y = 0
  229. change_color(normal_color)
  230. draw_text(x, y, window_width, line_height, PC_Scene::Current_Money_Vocab)
  231. # draw_text(x, y, window_width-24, line_height, unit + value.to_s, 2)
  232. draw_text(x, y, window_width-24, line_height, unit, 2)
  233. end
  234.  
  235. def unit
  236. sprintf(PC_Scene::Money_Prefix, value)
  237. # PC_Scene::Money_Prefix
  238. end
  239.  
  240. end
  241. #==============================================================================
  242. class Window_PC_GOLD_InBank < Window_PC_GOLD
  243. #==============================================================================
  244.  
  245. def draw_gold
  246. x = 0 ; y = 0
  247. change_color(normal_color)
  248. draw_text(x, y, window_width, line_height, PC_Scene::Banked_Money_Vocab)
  249. # draw_text(x, y, window_width-24, line_height, unit + value.to_s, 2)
  250. draw_text(x, y, window_width-24, line_height, unit, 2)
  251. end
  252.  
  253. def value
  254. $game_storage.cash
  255. end
  256.  
  257. end
  258.  
  259. #==============================================================================
  260. class Window_Player_PC_Command < Window_Command
  261. #==============================================================================
  262.  
  263. def initialize(x, y)
  264. super(x, y)
  265. draw_items_info
  266. type
  267. end
  268.  
  269. def change_type(type = :items)
  270. @type = type
  271. end
  272.  
  273. def type
  274. @type
  275. end
  276.  
  277. def window_width
  278. return Graphics.width - (Graphics.width / 4 * 2)
  279. end
  280.  
  281. def window_height
  282. return Graphics.height - fitting_height(6)
  283. end
  284.  
  285. def make_command_list
  286. case @type
  287. when :items
  288. for item in $game_storage.items
  289. add_item_command(item)
  290. end
  291. when :weapons
  292. for item in $game_storage.weapons
  293. add_item_command(item)
  294. end
  295. when :armors
  296. for item in $game_storage.armors
  297. add_item_command(item)
  298. end
  299. end
  300. end
  301.  
  302. def add_item_command(item)
  303. add_command("" , :avail_item, true)
  304. end
  305.  
  306. def draw_items_info
  307. x = 0 ; y = 0
  308. case @type
  309. when :items
  310. for item in $game_storage.items
  311. y = draw_infoo(x, y, item)
  312. end
  313. when :weapons
  314. for item in $game_storage.weapons
  315. y = draw_infoo(x, y, item)
  316. end
  317. when :armors
  318. for item in $game_storage.armors
  319. y = draw_infoo(x, y, item)
  320. end
  321. end
  322. end
  323.  
  324. def draw_infoo(x, y, item)
  325. draw_icon(item[0].icon_index, x, y, true)
  326. draw_text(x+25, y, window_width-50, line_height, item[0].name, 0)
  327. draw_text(x, y, window_width-25, line_height, "×#{item[1]} ", 2)
  328. return y + line_height
  329. end
  330.  
  331. def refresh
  332. super
  333. draw_items_info
  334. end
  335.  
  336. end
  337.  
  338. #==============================================================================
  339. class Window_Player_PC_Bag_Command < Window_Player_PC_Command
  340. #==============================================================================
  341.  
  342. def make_command_list
  343. case @type
  344. when :items
  345. for item in $game_party.items
  346. add_item_command(item)
  347. end
  348. when :weapons
  349. for item in $game_party.weapons
  350. add_item_command(item)
  351. end
  352. when :armors
  353. for item in $game_party.armors
  354. add_item_command(item)
  355. end
  356. end
  357. end
  358.  
  359. def add_item_command(item)
  360. add_command("" , :avail_item, true)
  361. end
  362.  
  363. def draw_items_info
  364. x = 0
  365. y = 0
  366. case @type
  367. when :items
  368. for item in $game_party.items
  369. y = draw_infoo(x, y, item)
  370. end
  371. when :weapons
  372. for item in $game_party.weapons
  373. y = draw_infoo(x, y, item)
  374. end
  375. when :armors
  376. for item in $game_party.armors
  377. y = draw_infoo(x, y, item)
  378. end
  379. end
  380. end
  381.  
  382. def draw_infoo(x, y, item)
  383. item_count = $game_party.item_number(item)
  384. draw_icon(item.icon_index, x, y, true)
  385. draw_text(x+25, y, window_width-50, line_height, item.name, 0)
  386. draw_text(x, y, window_width-25, line_height, "×#{item_count} ", 2)
  387. return y + line_height
  388. end
  389.  
  390. end
  391.  
  392. #==============================================================================
  393. class Window_Player_PC_Action_Command < Window_HorzCommand
  394. #==============================================================================
  395.  
  396. def window_width
  397. return Graphics.width
  398. end
  399.  
  400. def make_command_list
  401. add_command(PC_Scene::Deposit_Vocab, :deposit)
  402. add_command(PC_Scene::Withdraw_Vocab, :withdraw)
  403. end
  404.  
  405. def col_max
  406. return 2
  407. end
  408.  
  409. end
  410.  
  411. #==============================================================================
  412. class Window_Player_PC_Action_Command_2 < Window_Player_PC_Action_Command
  413. #==============================================================================
  414.  
  415. def make_command_list
  416. add_command(PC_Scene::Money_Vocab, :cash)
  417. add_command(PC_Scene::Items_Vocab, :items)
  418. add_command(PC_Scene::Weapons_Vocab, :weapons)
  419. add_command(PC_Scene::Armors_Vocab, :armors)
  420. end
  421.  
  422. def col_max
  423. return 4
  424. end
  425.  
  426. end
  427.  
  428. #==============================================================================
  429. class Scene_BANK < Scene_Base
  430. #==============================================================================
  431.  
  432. def start
  433. super
  434. create_help_window
  435. create_action_commands
  436. create_action_commands_2
  437. create_main_commands
  438. create_player_bag_commands
  439. create_number_window
  440. create_gold_window
  441. create_bankgold_window
  442. end
  443.  
  444. def create_help_window
  445. @help_window = Window_Help.new
  446. @help_window.viewport = @viewport
  447. end
  448.  
  449. def create_gold_window
  450. @gold_window = Window_PC_GOLD.new
  451. @gold_window.x = 0
  452. @gold_window.y = @action_com_wind.y + @action_com_wind.height
  453. end
  454.  
  455. def create_bankgold_window
  456. @bankgold_window = Window_PC_GOLD_InBank.new
  457. @bankgold_window.x = ((Graphics.width / 4 * 2))
  458. @bankgold_window.y = @action_com_wind.y + @action_com_wind.height
  459. end
  460.  
  461. def create_action_commands
  462. wx = 0
  463. wy = @help_window.height
  464. @action_com_wind = Window_Player_PC_Action_Command.new(wx, wy)
  465. @action_com_wind.set_handler(:deposit, method(:command_trigger_nxt_choice))
  466. @action_com_wind.set_handler(:withdraw, method(:command_trigger_nxt_choice))
  467. @action_com_wind.set_handler(:cancel, method(:return_scene))
  468. @my_current_symbol = :deposit
  469. end
  470.  
  471. def create_action_commands_2
  472. wx = 0
  473. wy = @help_window.height
  474. @action_com_wind_2 = Window_Player_PC_Action_Command_2.new(wx, wy)
  475. @action_com_wind_2.set_handler(:cash, method(:command_trigger_cash))
  476. @action_com_wind_2.set_handler(:items, method(:command_trigger_items))
  477. @action_com_wind_2.set_handler(:weapons, method(:command_trigger_weapons))
  478. @action_com_wind_2.set_handler(:armors, method(:command_trigger_armors))
  479. @action_com_wind_2.set_handler(:cancel, method(:command_back_to_firstchoice))
  480. @action_com_wind_2.deactivate
  481. @action_com_wind_2.select(-1)
  482. @action_com_wind_2.hide
  483. end
  484.  
  485. def create_main_commands
  486. wx = Graphics.width / 2
  487. wy = @action_com_wind.y + (@action_com_wind.height * 2)
  488. @main_com_wind = Window_Player_PC_Command.new(wx, wy)
  489. @main_com_wind.set_handler(:avail_item, method(:command_items))
  490. @main_com_wind.set_handler(:cancel, method(:command_back_to_2nd_choice))
  491. @main_com_wind.deactivate
  492. @main_com_wind.select(-1)
  493. end
  494.  
  495. def create_player_bag_commands
  496. wx = 0
  497. wy = @action_com_wind.y + (@action_com_wind.height * 2)
  498. @bag_com_wind = Window_Player_PC_Bag_Command.new(wx, wy)
  499. @bag_com_wind.set_handler(:avail_item, method(:command_items))
  500. @bag_com_wind.set_handler(:cancel, method(:command_back_to_2nd_choice))
  501. @bag_com_wind.deactivate
  502. @bag_com_wind.select(-1)
  503. end
  504.  
  505. def create_number_window
  506. wx = Graphics.width / 4
  507. wy = @action_com_wind.y + @action_com_wind.height
  508. @number_window = Window_Player_PC_Number.new(wx, wy)
  509. @number_window.viewport = @viewport
  510. @number_window.set_handler(:ok, method(:confirm_numbers))
  511. @number_window.set_handler(:cancel, method(:cancel_numbers))
  512. @number_window.hide
  513. end
  514.  
  515. def command_trigger_nxt_choice
  516. @action_com_wind.hide
  517. @action_com_wind_2.show
  518. @action_com_wind_2.activate
  519. @action_com_wind_2.select(0)
  520. end
  521.  
  522. def command_trigger_cash
  523. item = $data_items[0]
  524. case @action_com_wind.current_symbol
  525. when :deposit ; max = $game_party.gold
  526. price = $game_party.gold == 0 ? 0 : 1
  527. when :withdraw ; max = $game_storage.cash
  528. price = $game_storage.cash == 0 ? 0 : 1
  529. end
  530. @action_com_wind_2.deactivate
  531. @number_window.set(item, max, price)
  532. @number_window.open
  533. @number_window.activate
  534. @number_window.show
  535. end
  536.  
  537. def command_trigger_items
  538. @action_com_wind_2.deactivate
  539. case @action_com_wind.current_symbol
  540. when :deposit
  541. @bag_com_wind.activate
  542. @bag_com_wind.select(0)
  543. when :withdraw
  544. @main_com_wind.activate
  545. @main_com_wind.select(0)
  546. end
  547. end
  548.  
  549. def command_trigger_weapons
  550. @action_com_wind_2.deactivate
  551. case @action_com_wind.current_symbol
  552. when :deposit
  553. @bag_com_wind.activate
  554. @bag_com_wind.select(0)
  555. when :withdraw
  556. @main_com_wind.activate
  557. @main_com_wind.select(0)
  558. end
  559. end
  560.  
  561. def command_trigger_armors
  562. @action_com_wind_2.deactivate
  563. case @action_com_wind.current_symbol
  564. when :deposit
  565. @bag_com_wind.activate
  566. @bag_com_wind.select(0)
  567. when :withdraw
  568. @main_com_wind.activate
  569. @main_com_wind.select(0)
  570. end
  571. end
  572.  
  573. def command_back_to_firstchoice
  574. @action_com_wind_2.deactivate
  575. @action_com_wind_2.select(-1)
  576. @action_com_wind_2.hide
  577. @action_com_wind.show
  578. @action_com_wind.activate
  579. end
  580.  
  581. def command_back_to_2nd_choice
  582. @main_com_wind.deactivate
  583. @main_com_wind.select(-1)
  584. @bag_com_wind.deactivate
  585. @bag_com_wind.select(-1)
  586. @action_com_wind_2.activate
  587. end
  588.  
  589. def command_items
  590. case @action_com_wind_2.current_symbol
  591. when:items
  592. case @action_com_wind.current_symbol
  593. when :deposit
  594. item = $data_items[$game_party.items[@bag_com_wind.index].id]
  595. max = $game_party.item_number(item)
  596. when :withdraw
  597. item = $game_storage.items[@main_com_wind.index][0]
  598. max = $game_storage.items[@main_com_wind.index][1]
  599. end
  600. when :weapons
  601. case @action_com_wind.current_symbol
  602. when :deposit
  603. item = $data_weapons[$game_party.weapons[@bag_com_wind.index].id]
  604. max = $game_party.item_number(item)
  605. when :withdraw
  606. item = $game_storage.weapons[@main_com_wind.index][0]
  607. max = $game_storage.weapons[@main_com_wind.index][1]
  608. end
  609. when :armors
  610. case @action_com_wind.current_symbol
  611. when :deposit
  612. item = $data_armors[$game_party.armors[@bag_com_wind.index].id]
  613. max = $game_party.item_number(item)
  614. when :withdraw
  615. item = $game_storage.armors[@main_com_wind.index][0]
  616. max = $game_storage.armors[@main_com_wind.index][1]
  617. end
  618. end
  619. price = 1
  620. @number_window.set(item, max, price)
  621. @number_window.activate
  622. @number_window.show
  623. end
  624.  
  625. def confirm_numbers
  626. case @action_com_wind.current_symbol
  627. when :deposit
  628. case @action_com_wind_2.current_symbol
  629. when :cash
  630. deposit_cash(@number_window.number)
  631. @action_com_wind_2.activate
  632. when :items
  633. deposit_items(@number_window.number)
  634. @bag_com_wind.activate
  635. when :weapons
  636. deposit_weapons(@number_window.number)
  637. @bag_com_wind.activate
  638. when :armors
  639. deposit_armors(@number_window.number)
  640. @bag_com_wind.activate
  641. end
  642. when :withdraw
  643. case @action_com_wind_2.current_symbol
  644. when :cash
  645. withdraw_cash(@number_window.number)
  646. @action_com_wind_2.activate
  647. when :items
  648. withdraw_items(@number_window.number)
  649. @main_com_wind.activate
  650. when :weapons
  651. withdraw_weapons(@number_window.number)
  652. @main_com_wind.activate
  653. when :armors
  654. withdraw_armors(@number_window.number)
  655. @main_com_wind.activate
  656. end
  657. end
  658. @number_window.deactivate
  659. @number_window.hide
  660. end
  661.  
  662. def cancel_numbers
  663. case @action_com_wind.current_symbol
  664. when :deposit
  665. case @action_com_wind_2.current_symbol
  666. when :cash
  667. @action_com_wind_2.activate
  668. when :items, :weapons, :armors
  669. @bag_com_wind.activate
  670. end
  671. when :withdraw
  672. case @action_com_wind_2.current_symbol
  673. when :cash
  674. @action_com_wind_2.activate
  675. when :items, :weapons, :armors
  676. @main_com_wind.activate
  677. end
  678. end
  679. @number_window.deactivate
  680. @number_window.hide
  681. end
  682.  
  683. def deposit_cash(amount)
  684. $game_party.lose_gold(amount)
  685. $game_storage.gain_cash(amount)
  686. @gold_window.refresh
  687. @bankgold_window.refresh
  688. end
  689.  
  690. def withdraw_cash(amount)
  691. $game_party.gain_gold(amount)
  692. $game_storage.lose_cash(amount)
  693. @gold_window.refresh
  694. @bankgold_window.refresh
  695. end
  696.  
  697. def deposit_items(amount)
  698. inv_item = $game_party.items[@bag_com_wind.index].id
  699. $game_party.lose_item($data_items[inv_item], amount)
  700. already_had_item = false
  701. $game_storage.items.each {|item|
  702. item[1] += amount if item[0].id == inv_item
  703. already_had_item = true if item[0].id == inv_item ; }
  704. $game_storage.add_to_items(inv_item, amount) if !already_had_item
  705. @bag_com_wind.refresh
  706. @main_com_wind.refresh
  707. @bag_com_wind.activate
  708. end
  709.  
  710. def withdraw_items(amount)
  711. gsi = $game_storage.items[@main_com_wind.index]
  712. gsi[1] -= amount
  713. $game_party.gain_item(gsi[0], amount)
  714. if gsi[1] < 1
  715. $game_storage.items.delete_at(@main_com_wind.index)
  716. @main_com_wind.index = 0
  717. end
  718. @main_com_wind.refresh
  719. @bag_com_wind.refresh
  720. @main_com_wind.activate
  721. end
  722.  
  723. def deposit_weapons(amount)
  724. inv_item = $game_party.weapons[@bag_com_wind.index].id
  725. $game_party.lose_item($data_weapons[inv_item], amount)
  726. already_had_item = false
  727. $game_storage.weapons.each {|item|
  728. item[1] += amount if item[0].id == inv_item
  729. already_had_item = true if item[0].id == inv_item ; }
  730. $game_storage.add_to_weapons(inv_item, amount) if !already_had_item
  731. @bag_com_wind.refresh
  732. @main_com_wind.refresh
  733. @bag_com_wind.activate
  734. end
  735.  
  736. def withdraw_weapons(amount)
  737. gsi = $game_storage.weapons[@main_com_wind.index]
  738. gsi[1] -= amount
  739. $game_party.gain_item(gsi[0], amount)
  740. if gsi[1] < 1
  741. $game_storage.weapons.delete_at(@main_com_wind.index)
  742. @main_com_wind.index = 0
  743. end
  744. @main_com_wind.refresh
  745. @bag_com_wind.refresh
  746. @main_com_wind.activate
  747. end
  748.  
  749. def deposit_armors(amount)
  750. inv_item = $game_party.armors[@bag_com_wind.index].id
  751. $game_party.lose_item($data_armors[inv_item], amount)
  752. already_had_item = false
  753. $game_storage.items.each {|item|
  754. item[1] += amount if item[0].id == inv_item
  755. already_had_item = true if item[0].id == inv_item ; }
  756. $game_storage.add_to_armors(inv_item, amount) if !already_had_item
  757. @bag_com_wind.refresh
  758. @main_com_wind.refresh
  759. @bag_com_wind.activate
  760. end
  761.  
  762. def withdraw_armors(amount)
  763. gsi = $game_storage.armors[@main_com_wind.index]
  764. gsi[1] -= amount
  765. $game_party.gain_item(gsi[0], amount)
  766. if gsi[1] < 1
  767. $game_storage.armors.delete_at(@main_com_wind.index)
  768. @main_com_wind.index = 0
  769. end
  770. @main_com_wind.refresh
  771. @bag_com_wind.refresh
  772. @main_com_wind.activate
  773. end
  774.  
  775. def update
  776. super
  777. update_help_text
  778. update_wind_type
  779. end
  780.  
  781. def update_help_text
  782. if @action_com_wind.active
  783. update_text_one
  784. elsif @action_com_wind_2.active
  785. update_text_two
  786. elsif @main_com_wind.active
  787. update_text_three
  788. end
  789. end
  790.  
  791. def update_text_one
  792. text = @action_com_wind.current_symbol == :deposit ?
  793. PC_Scene::Deposit_Info : PC_Scene::Withdraw_Info
  794. @help_window.set_text(text)
  795. end
  796.  
  797. def update_text_two
  798. case @action_com_wind_2.current_symbol
  799. when :cash ;
  800. text = @action_com_wind.current_symbol == :deposit ?
  801. PC_Scene::Deposit_Cash : PC_Scene::Withdraw_Cash
  802. when :items ; text = PC_Scene::Withdraw_Info
  803. text = @action_com_wind.current_symbol == :deposit ?
  804. PC_Scene::Deposit_Items : PC_Scene::Withdraw_Items
  805. when :weapons ; text = PC_Scene::Withdraw_Info
  806. text = @action_com_wind.current_symbol == :deposit ?
  807. PC_Scene::Deposit_Weapons : PC_Scene::Withdraw_Weapons
  808. when :armors ; text = PC_Scene::Withdraw_Info
  809. text = @action_com_wind.current_symbol == :deposit ?
  810. PC_Scene::Deposit_Armors : PC_Scene::Withdraw_Armors
  811. end
  812. @help_window.set_text(text)
  813. end
  814.  
  815. def update_text_three
  816. case @action_com_wind_2.current_symbol
  817. # when :cash ;
  818. when :items ; text = PC_Scene::Withdraw_Info
  819. text = $game_storage.items[@main_com_wind.index] == nil ?
  820. "" : $game_storage.items[@main_com_wind.index][0]
  821. when :weapons ; text = PC_Scene::Withdraw_Info
  822. text = $game_storage.weapons[@main_com_wind.index] == nil ?
  823. "" : $game_storage.weapons[@main_com_wind.index][0]
  824. when :armors ; text = PC_Scene::Withdraw_Info
  825. text = $game_storage.armors[@main_com_wind.index] == nil ?
  826. "" : $game_storage.armors[@main_com_wind.index][0]
  827. end
  828. return if text = ""
  829. @help_window.set_item(text)
  830. end
  831.  
  832.  
  833. def update_wind_type
  834. if @main_com_wind.type != @action_com_wind_2.current_symbol
  835. @main_com_wind.change_type(@action_com_wind_2.current_symbol)
  836. @main_com_wind.refresh
  837. end
  838. if @bag_com_wind.type != @action_com_wind_2.current_symbol
  839. @bag_com_wind.change_type(@action_com_wind_2.current_symbol)
  840. @bag_com_wind.refresh
  841. end
  842. end
  843.  
  844. end
  845. #===============================================================================#
  846. # PC Scene Script 1(Player PC Scene) END #
  847. #===============================================================================#
  848. # http://dekitarpg.wordpress.com/ #
  849. #===============================================================================#
  850. module DataManager
  851. #===============================================================================#
  852.  
  853. class << self ;
  854. alias :cgo_game_storage :create_game_objects
  855. alias :msc_game_storage :make_save_contents
  856. alias :esc_game_storage :extract_save_contents
  857. end
  858.  
  859. def self.create_game_objects
  860. cgo_game_storage
  861. $game_storage = PC_Storage.new
  862. end
  863.  
  864. def self.make_save_contents
  865. contents = msc_game_storage
  866. contents[:game_storage] = $game_storage
  867. contents
  868. end
  869.  
  870. def self.extract_save_contents(contents)
  871. esc_game_storage(contents)
  872. $game_storage = contents[:game_storage]
  873. end
  874.  
  875. end
  876.  
  877. #==============================================================================
  878. class PC_Storage
  879. #==============================================================================
  880.  
  881. attr_reader :cash
  882. attr_reader :items
  883. attr_reader :weapons
  884. attr_reader :armors
  885.  
  886. def initialize
  887. setup
  888. end
  889.  
  890. def setup
  891. @cash = get_initial_stored_cash
  892. @items = get_initial_stored_items
  893. @weapons = get_initial_stored_weapons
  894. @armors = get_initial_stored_armors
  895. end
  896.  
  897. def get_initial_stored_cash
  898. Game_Storage::Initial_CASH
  899. end
  900.  
  901. def get_initial_stored_items
  902. items = []
  903. for item_info in Game_Storage::Initial_Items
  904. next if item_info[0] == nil || item_info[0] <= 0
  905. items.push([ $data_items[item_info[0]] , item_info[1] ])
  906. end
  907. items
  908. end
  909.  
  910. def get_initial_stored_weapons
  911. items = []
  912. for item_info in Game_Storage::Initial_Weapons
  913. next if item_info[0] == nil || item_info[0] <= 0
  914. items.push([ $data_weapons[item_info[0]] , item_info[1] ])
  915. end
  916. items
  917. end
  918.  
  919. def get_initial_stored_armors
  920. items = []
  921. for item_info in Game_Storage::Initial_Armors
  922. next if item_info[0] == nil || item_info[0] <= 0
  923. items.push([ $data_armors[item_info[0]] , item_info[1] ])
  924. end
  925. items
  926. end
  927.  
  928. def add_to_items(item_id, amount)
  929. return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
  930. @items.push([$data_items[item_id], amount])
  931. end
  932.  
  933. def add_to_weapons(item_id, amount)
  934. return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
  935. @weapons.push([$data_weapons[item_id], amount])
  936. end
  937.  
  938. def add_to_armors(item_id, amount)
  939. return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
  940. @armors.push([$data_armors[item_id], amount])
  941. end
  942.  
  943. def gain_cash(amount)
  944. @cash += amount
  945. end
  946.  
  947. def lose_cash(amount)
  948. @cash -= amount
  949. @cash = 0 if @cash < 0
  950. end
  951.  
  952. end
  953.  
  954. #===============================================================================#
  955. # - SCRIPT END - #
  956. #===============================================================================#
  957. # http://dekitarpg.wordpress.com/ #
  958. #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement