Advertisement
TroyZ

TroyZ - Theo Specific Sell Price

Sep 28th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.38 KB | None | 0 0
  1. # ==============================================================================
  2. # ▼▼▼▼▼▼                TroyZ - Theo Specific Sell Price                  ▼▼▼▼▼▼
  3. # ==============================================================================
  4. # Script by : Theo Allen
  5. # Edited by : Agung Prasetyo(TroyZ)
  6. # Contact me by : - Email agung.endisnear.xyz@gmail.com
  7. #                 - Forum RPGMakerID, username TroyZ
  8. #                 - Handphone 085756289121
  9. # Engine : VXAce
  10. # Level : Easy
  11. # Version : 1.0
  12. # ------------------------------------------------------------------------------
  13. # Change Logs :
  14. # 8 August 2013 : Version 1.0 released
  15. # 29 September 2014 : Version 1.0 edited by TroyZ released
  16. # ------------------------------------------------------------------------------
  17. # How this work :
  18. # Just adding another function to make the sell price appear as percentage.
  19. # Furthermore the rest of script instructions are in the old header of the
  20. # script's itself.
  21. # ------------------------------------------------------------------------------
  22. # How to use :
  23. # Place it between material and main. To use percentage sell price, use this
  24. # notetag :
  25. #
  26. # <sell price mul: x%>
  27. #
  28. # For example :
  29. #
  30. # <sell price mul: 75%>
  31. # Means that this item has selling price at 75% of it's buying price. The
  32. # percentage selling price has higher priority than fixed selling price.
  33. # ------------------------------------------------------------------------------
  34. # Compatibility issues :
  35. # None yet. If you found some, let me or Theo know, and bug fixes will come out
  36. # soon.
  37. # ------------------------------------------------------------------------------
  38. # Who to credit :
  39. # - Allah swt. : For the chance of living that he has given to me.
  40. # - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim.
  41. #                        I'm proud to be your follower. :)
  42. # - Theo Allen : It's his script, credit him.
  43. # - Agung Prasetyo(TroyZ) : Whatever, but if you pleased, just credit me, hehehe.
  44. # ------------------------------------------------------------------------------
  45. # License :
  46. # - Free Game : Follow Theo's credit rules.
  47. # - Commercial Game : Same as free game's license.
  48. # ------------------------------------------------------------------------------
  49.  
  50. # =============================================================================
  51. # TheoAllen - Specific Sell Price
  52. # Version : 1.0
  53. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  54. # (This script documentation is written in informal indonesian language)
  55. # =============================================================================
  56. ($imported ||= {})[:Theo_SellPrice] = true
  57. # =============================================================================
  58. # CHANGE LOGS:
  59. # -----------------------------------------------------------------------------
  60. # 2013.08.11 - Finished script
  61. # =============================================================================
  62. =begin
  63.  
  64.   Perkenalan :
  65.   Script ini berfungsi untuk spesifikasi harga item
  66.  
  67.   Cara penggunaan :
  68.   Pasang dibawah material namun diatas main
  69.   Gunakan tag <sell price: n> pada note armor, weapon, dan item. Dimana n
  70.   adalah harga jual barang tersebut.
  71.  
  72.   Terms of Use :
  73.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  74.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  75.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  76.  
  77. =end
  78. # =============================================================================
  79. # Tidak ada konfigurasi
  80. # =============================================================================
  81. class << DataManager
  82.  
  83.   alias theo_sell_price_load_db load_database
  84.   def load_database
  85.     theo_sell_price_load_db
  86.     load_price_database
  87.   end
  88.  
  89.   def load_price_database
  90.     ($data_armors + $data_weapons + $data_items).compact.each do |item|
  91.       item.load_price
  92.     end
  93.   end
  94.  
  95. end
  96.  
  97. class RPG::Item < RPG::UsableItem
  98.   attr_accessor :sell_price
  99.   attr_accessor :sell_price_mult
  100.  
  101.   def load_price
  102.     @sell_price = 0
  103.     @sell_price_mult = 0
  104.     self.note.split(/[\r\n]+/).each do |line|
  105.       case line
  106.       when /<(?:SELL_PRICE|sell price): [ ]*(\d+)>/i
  107.         @sell_price = $1.to_i
  108.       when /<(?:SELL_PRICE_MUL|sell price mul): [ ]*(\d+)%>/i
  109.         @sell_price_mult = $1.to_i * 0.01
  110.       end
  111.     end
  112.   end
  113.  
  114.   def specify_sell_price_multiplier?
  115.     @sell_price_mult > 0
  116.   end
  117.  
  118.   def specify_sell_price?
  119.     @sell_price > 0
  120.   end
  121.  
  122. end
  123.  
  124. class RPG::EquipItem < RPG::BaseItem
  125.   attr_accessor :sell_price
  126.   attr_accessor :sell_price_mult
  127.  
  128.   def load_price
  129.     @sell_price = 0
  130.     @sell_price_mult = 0
  131.     self.note.split(/[\r\n]+/).each do |line|
  132.       case line
  133.       when /<(?:SELL_PRICE|sell price): [ ]*(\d+)>/i
  134.         @sell_price = $1.to_i
  135.       when /<(?:SELL_PRICE_MUL|sell price mul): [ ]*(\d+)%>/i
  136.         @sell_price_mult = $1.to_i * 0.01
  137.       end
  138.     end
  139.   end
  140.  
  141.   def specify_sell_price_multiplier?
  142.     @sell_price_mult > 0
  143.   end
  144.  
  145.   def specify_sell_price?
  146.     @sell_price > 0
  147.   end
  148.  
  149. end
  150.  
  151. class Scene_Shop < Scene_MenuBase
  152.   alias theo_ori_sell_price selling_price
  153.   def selling_price
  154.     return (@item.price * @item.sell_price_mult).to_i if @item.specify_sell_price_multiplier?
  155.     return @item.sell_price if @item.specify_sell_price?
  156.     return theo_ori_sell_price
  157.   end
  158. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement