bgillisp

4 tiered currency system

Sep 29th, 2014
22
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Script Four Tiered Currency Script, version 0.1
  2. # Author: Bgillisp
  3. # Released: 9/29/2014
  4.  
  5. # This script sets it up so that there are 4 currencies in the game
  6. # The currencies are currently Brozne, Copper, Silver, and Gold
  7. # with 100 Bronze = 1 Copper, 100 Copper = 1 Silver,
  8. # and 100 Silver = 1 Gold
  9.  
  10. # This script auto-adjusts the display for the parties gold and
  11. # shops to show all values in the new currency. Whenever the party
  12. # has 100 of a currency, it auto-converts to the new currency. So
  13. # if you find 150 Bronze in a battle, the script will convert it
  14. # to 1 Copper, 50 Bronze in the display
  15.  
  16. # To use, set all enemy drops and all item prices to their value
  17. # in bronze. For instance, if you want an item to cost 4 Silver,
  18. # set the price to 400 in the database. The script will do the rest.
  19.  
  20. # Requires an adjust limits script if you want to have items
  21. # cost more than 999999 Bronze (99 Silver, 99 Copper, and 99 Bronze)
  22.  
  23. # Early beta version, more features coming.
  24.  
  25. # Pending features:
  26. # -Change the display after battles to show the new currency.
  27. # Currently, it will show the award in the currency set under the
  28. # system tab. Set the currenty to Bronze in the game for now,
  29. # and it will be functional, but more work is needed on this.
  30.  
  31. # -Fix it so that an adjust limits script is not required.
  32.  
  33. #----------------------------------------------------------------------------
  34. # Editable region
  35.  
  36. #None, hardcoded for early testing. Will fix in another release.
  37.  
  38. #End of Editable Region
  39. #--------------------------------------------------------------------------
  40.  
  41.  
  42. #Do not edit anything below here unless you know what you are doing.
  43. #Failure to ahead to this warning may result in unpredictable behavior in
  44. #your game. Consider yourself warned
  45. #__________________________________________________________________________
  46.  
  47.  
  48. class Game_Party < Game_Unit
  49.  
  50. #Overwrite method, max_gold
  51. #Keep max gold at 999,999,999,999.
  52. def max_gold
  53. return 999999999999
  54. end
  55.  
  56. end
  57.  
  58. class Window_Base < Window
  59.  
  60. #Overwrite method, draw currency value
  61. def draw_currency_value(value, unit, x, y, width)
  62. cx = text_size(unit).width
  63. change_color(normal_color)
  64. store = value
  65. tier1 = store % 100
  66. tier2 = (store / 100).to_i % 100
  67. tier3 = (store / 10000).to_i % 100
  68. tier4 = (store / 1000000).to_i
  69. text = sprintf("%2dG %2dS %2dC %2dB", tier4, tier3, tier2, tier1)
  70. draw_text(x, y, width, line_height, text, 2)
  71. end
  72.  
  73. end
  74.  
  75. class Window_ShopBuy < Window_Selectable
  76.  
  77. #Overwrite method, draw_item
  78. def draw_item(index)
  79. item = @data[index]
  80. rect = item_rect(index)
  81. draw_item_name(item, rect.x, rect.y, enable?(item))
  82. rect.width -= 4
  83. store = price(item)
  84. tier1 = store % 100
  85. tier2 = (store / 100).to_i % 100
  86. tier3 = (store / 10000).to_i % 100
  87. tier4 = (store / 1000000).to_i
  88.  
  89. text = ""
  90. if(tier4 != 0)
  91. text = sprintf("%2dG", tier4)
  92. end
  93.  
  94. if(tier3 != 0)
  95. text += sprintf("% 2dS", tier3)
  96. end
  97.  
  98. if(tier2 != 0)
  99. text += sprintf("% 2dC", tier2)
  100. end
  101.  
  102. if(tier1 != 0)
  103. text += sprintf("% 2dB", tier1)
  104. end
  105.  
  106. #Default if the item is free.
  107. if(text == "")
  108. text = "0B"
  109. end
  110.  
  111. #Display the new text for currency
  112. draw_text(rect, text, 2)
  113. #draw_text(rect, price(item), 2)
  114. end
  115.  
  116. end
RAW Paste Data