Advertisement
Dekita

bank

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