Advertisement
WCouillard

RGSS3: Alternate Currency v2.00 [RMVXA]

Jan 24th, 2013
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.00 KB | None | 0 0
  1. # ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
  2. # ║ Alternate Currency                                   │ v2.00 │ (03/25/14) ║
  3. # ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
  4. # ║ Author  : William Couillard                                               ║
  5. # ║ E-Mail  : cooliebk18@yahoo.com                                            ║
  6. # ╠═══════════════════════════════════════════════════════════════════════════╣
  7. # ║ ABOUT                                                                     ║
  8. # ╠═══════════════════════════════════════════════════════════════════════════╣
  9. # ║ This script allows the user to change shops to use an alternate currency  ║
  10. # ║ which is stored in a variable. The new currency can be turned on or off   ║
  11. # ║ at any time.                                                              ║
  12. # ╠═══════════════════════════════════════════════════════════════════════════╣
  13. # ║ CHANGE LOG                                                                ║
  14. # ╠═════════════════════════════════════════════════════════════════╤═════════╣
  15. # ║ ■ March 25, 2014   : Removed depencency on YEA Shop Options.    │ (v2.00) ║
  16. # ║ ■ January 24, 2012 : Initial release.                           │ (v1.00) ║
  17. # ╠═════════════════════════════════════════════════════════════════╧═════════╣
  18. # ║ OVERWRITTEN METHODS                                                       ║
  19. # ╠═══════════════════════════════════════════════════════════════════════════╣
  20. # ║   This script overwrites a few methods in various default scripts.        ║
  21. # ╟───────────────────────────────────────────────────────────────────────────╢
  22. # ║ ■ class Window_ShopNumber < Window_Selectable                             ║
  23. # ║    ► def draw_total_price                                                 ║
  24. # ╟───────────────────────────────────────────────────────────────────────────╢
  25. # ║ ■ class Window_Gold < Window_Base                                         ║
  26. # ║    ► def refresh                                                          ║
  27. # ║    ► def value                                                            ║
  28. # ║    ► def currency_unit                                                    ║
  29. # ╟───────────────────────────────────────────────────────────────────────────╢
  30. # ║ ■ class Scene_Shop < Scene_MenuBase                                       ║
  31. # ║    ► def do_buy                                                           ║
  32. # ║    ► def do_sell                                                          ║
  33. # ╠═══════════════════════════════════════════════════════════════════════════╣
  34. # ║ NEW METHODS                                                               ║
  35. # ╠═══════════════════════════════════════════════════════════════════════════╣
  36. # ║   There are several new methods introduced in this script.                ║
  37. # ╟───────────────────────────────────────────────────────────────────────────╢
  38. # ║ ■ class Game_Party < Game_Unit                                            ║
  39. # ║    ► def gain_bp                                                          ║
  40. # ║    ► def lose_bp                                                          ║
  41. # ║    ► def max_bp                                                           ║
  42. # ╟───────────────────────────────────────────────────────────────────────────╢
  43. # ║ ■ class Window_ShopNumber < Window_Selectable                             ║
  44. # ║    ► def current_currency_value                                           ║
  45. # ╠═══════════════════════════════════════════════════════════════════════════╣
  46. # ║ INSTRUCTIONS                                                              ║
  47. # ╠═══════════════════════════════════════════════════════════════════════════╣
  48. # ║ Paste this script below Materials and above Main.                         ║
  49. # ╠═══════════════════════════════════════════════════════════════════════════╣
  50. # ║ IMPORT SETTING                                                            ║
  51. # ╚═══════════════════════════════════════════════════════════════════════════╝
  52. $imported = {} if $imported.nil?              # Do not edit
  53. $imported[:wc_alternate_currency] = true      # Do not edit
  54. # ╔═══════════════════════════════════════════════════════════════════════════╗
  55. # ║ CUSTOMIZATION MODULE                                                      ║
  56. # ╚═══════════════════════════════════════════════════════════════════════════╝
  57. module COOLIE
  58.   module ALT_CURRENCY
  59.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  60.     # - New Currency Settings -
  61.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  62.     # Changes settings for the new currency used in shops.
  63.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  64.     CURRENCY_SWITCH   = 1              # Currency Change Switch ID
  65.                                        # ^ When this switch is ON, shops use
  66.                                        # alternate currency.
  67.     CURRENCY_VARIABLE = 1              # Currency Variable ID
  68.                                        # ^ Variable that stores the currency
  69.                                        # value.
  70.     CURRENCY_NAME     = "BP"           # Currency Name
  71.                                        # ^ The name of the alternate currency.
  72.     MAX_ALT_CURRENCY  = 9999999        # Maximum Alternate Currency Amount
  73.                                        # ^ The maximum amount of alternate
  74.                                        # currency that can be held at once.
  75.   end
  76. end
  77. #==============================================================================
  78. # ■ Game_Party
  79. #==============================================================================
  80. class Game_Party < Game_Unit
  81.   #--------------------------------------------------------------------------
  82.   # * new method: gain_bp
  83.   #--------------------------------------------------------------------------
  84.   def gain_bp(amount)
  85.     $game_variables[COOLIE::ALT_CURRENCY::CURRENCY_VARIABLE] = [[$game_variables[COOLIE::ALT_CURRENCY::CURRENCY_VARIABLE] + amount, 0].max, max_bp].min
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # * new method: lose_bp
  89.   #--------------------------------------------------------------------------
  90.   def lose_bp(amount)
  91.     gain_bp(-amount)
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * new method: def max_bp
  95.   #--------------------------------------------------------------------------
  96.   def max_bp
  97.     return COOLIE::ALT_CURRENCY::MAX_ALT_CURRENCY
  98.   end
  99. end
  100.  
  101. #==============================================================================
  102. # ■ Window_ShopNumber
  103. #==============================================================================
  104. class Window_ShopNumber < Window_Selectable
  105.  
  106.   #--------------------------------------------------------------------------
  107.   # * Draw Total Price
  108.   #--------------------------------------------------------------------------
  109.   def draw_total_price
  110.     if $imported["YEA-ShopOptions"]
  111.       dw = contents_width - 8
  112.       dy = price_y
  113.       # Draw total currency
  114.       draw_currency_value(current_currency_value, @currency_unit, 4, dy, dw)
  115.       dy += line_height
  116.       draw_horz_line(dy)
  117.       # Draw total cost
  118.       value = @price * @number
  119.       value *= -1 if buy?
  120.       draw_currency_value(value, @currency_unit, 4, dy, dw)
  121.       dy += line_height
  122.       # Draw remaining currency
  123.       value = current_currency_value + value
  124.       if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  125.         value = [[value, 0].max, $game_party.max_bp].min
  126.       else
  127.         value = [[value, 0].max, $game_party.max_gold].min
  128.       end
  129.       draw_currency_value(value, @currency_unit, 4, dy, dw)
  130.     else
  131.       width = contents_width - 8
  132.       draw_currency_value(@price * @number, @currency_unit, 4, price_y, width)
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * new method: current_currency_value
  137.   #--------------------------------------------------------------------------
  138.   def current_currency_value
  139.     if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  140.       return $game_variables[COOLIE::ALT_CURRENCY::CURRENCY_VARIABLE]
  141.     else
  142.       return $game_party.gold
  143.     end
  144.   end
  145. end # Game_Party
  146.  
  147. #==============================================================================
  148. # ■ Window_Gold
  149. #==============================================================================
  150. class Window_Gold < Window_Base
  151.   #--------------------------------------------------------------------------
  152.   # * overwrite method: refresh
  153.   #--------------------------------------------------------------------------
  154.   def refresh
  155.     contents.clear
  156.     draw_currency_value(value, currency_unit, 4, 0, contents.width - 8)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * overwrite method: value
  160.   #--------------------------------------------------------------------------
  161.   def value
  162.     if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  163.       $game_variables[COOLIE::ALT_CURRENCY::CURRENCY_VARIABLE]
  164.     else
  165.       $game_party.gold
  166.     end
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * overwrite method: currency_unit
  170.   #--------------------------------------------------------------------------
  171.   def currency_unit
  172.     if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  173.       COOLIE::ALT_CURRENCY::CURRENCY_NAME
  174.     else
  175.       Vocab::currency_unit
  176.     end
  177.   end
  178.    
  179. end # Window_Gold
  180.  
  181. #==============================================================================
  182. # ■ Scene_Shop
  183. #==============================================================================
  184. class Scene_Shop < Scene_MenuBase
  185.   #--------------------------------------------------------------------------
  186.   # * overwrite method: do_buy
  187.   #--------------------------------------------------------------------------
  188.   def do_buy(number)
  189.     if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  190.      $game_party.lose_bp(number * buying_price)
  191.     else
  192.      $game_party.lose_gold(number * buying_price)
  193.     end
  194.      $game_party.gain_item(@item, number)
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # * overwrite method: do_sell
  198.   #--------------------------------------------------------------------------
  199.   def do_sell(number)
  200.     if $game_switches[COOLIE::ALT_CURRENCY::CURRENCY_SWITCH]
  201.       $game_party.gain_bp(number * selling_price)
  202.     else
  203.       $game_party.gain_gold(number * selling_price)
  204.     end
  205.     $game_party.lose_item(@item, number)
  206.   end
  207. end # Scene_Shop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement