查看: 3202|回复: 1

[已经过期] 这令商品价格浮动的脚本,真的不懂用

[复制链接]
梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
发表于 2013-2-3 23:12:56 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 Mic_洛洛 于 2013-2-25 00:03 编辑

这个令商品价格浮动的脚本,真的不懂用,不懂填写哪里, 直接执行会出错,

  1. #============================================================================
  2. # Shop Taxes V1.6 (VXA version)
  3. # By Emerald
  4. #----------------------------------------------------------------------------
  5. # Originally made by Falcon for RMXP
  6. # Edited by Emerald to fit the RMVX and now also RMVX Ace
  7. # You're free to use the script for any game, as long as you give credits
  8. #----------------------------------------------------------------------------
  9. # Version History
  10. # 0.5 -> Script ported to RMVX Ace with minor edits to avoid errors
  11. # 1.0 -> Further edits due to problems with percentage taxes
  12. #               Added possibility to easily configure x/y position of tax information
  13. #               and a value to configure if it will even be shown at all.
  14. # 1.5 -> Again, further edits due to slight problems. But aside from that,
  15. #               you can use <tax key item> again. Also added possibility to create
  16. #               items which alter taxes. DRASTICALLY changed Instructions, be sure to
  17. #               read it thoroughly.
  18. # 1.6 -> Added Sell taxes and item Sell Tax changes.
  19. #----------------------------------------------------------------------------
  20. # With this script, you can almost fully control prices for VX Ace. You can
  21. # normally set prices and prices unique per shop, and this script adds the
  22. # possibility to make taxes. With these taxes, you can easily change prices of
  23. # all items in a shop, either higher or lower.
  24. #
  25. # Instructions:
  26. #
  27. # Just as always, put this script between ▼ Materials and ▼ Main. If the
  28. # information about the taxes is not shown correctly in shops, you can change
  29. # it below.
  30. #
  31. #
  32. # In order to add taxes, use the call script method within an event. Use
  33. # the following codes codes:
  34. #
  35. # $game_system.tax.percent = x
  36. # Where x > 100 results in a tax with x% the normal price
  37. # Where x < 100 results in a discount with x% the normal price
  38. #
  39. # $game_systeme.tax.direct = y
  40. # Where y > 0 results in a tax which adds y to every price
  41. # Where y < 0 results in a discount which subtracts y to every price
  42. #
  43. # WARNING
  44. # For n = the price of an item,
  45. # If n - y equals 0, the item becomes free
  46. # If n - y < 0, the item becomes free AND you GET money (why doesn't that happen
  47. # in real life)
  48. # If x = a negative value then you'll GET money (x% the normal price)
  49. #
  50. # ALWAYS!!, unless you're SURE the player can't have any items which alter taxes,
  51. # add $game_system.tax.perbon to percentage taxes and $game_system.tax.dirbon to
  52. # direct taxes. Else, the changes of the items ARE NOT APLIED!!
  53. # END WARNING
  54. #
  55. # $game_system.selltax.percent = x
  56. # $game_system.selltax.direct = y
  57. # $game_system.selltax.perbon = x
  58. # $game_system.selltax.dirbon = y
  59. #
  60. # Exact same story as above, only these are hidden and for items being sold.
  61. #
  62. #
  63. # <tax key item>
  64. # Use the above tag if you don't want that the price of that item can be changed
  65. # by taxes. Useful for items which the player may not buy/sell.
  66. #
  67. #
  68. # <tax +/-x>
  69. # Use the above tag to make items which will alter direct taxes. Use + to make
  70. # it higher, - to make it lower. Enter a value for x.
  71. #
  72. # <tax +/-x%>
  73. # Use the above tag to make items whcih will alter percentage taxes. Use + to
  74. # make it higher, - to make it lower. WARNING!! The value you enter for x will
  75. # be ADDED or SUBSTRACTED of the current tax.percent!!
  76. # Examples:
  77. # $game_system.tax.percent = 150 & an item with <tax +20%> will result in a tax
  78. # of 170%.
  79. #
  80. # $game_system.tax.percent = 100 (/no value set) & an item with <tax -42%> will
  81. # result in a tax of 58%.
  82. #
  83. # NOTE that if the player gets any items with these tags, the amount he/she has
  84. # of the item determines how many times the taxes will be altered! Two of the
  85. # same items in Example 1 will result in a tax of 190% instead of 170%.
  86. # Also, if the player gets any items with these tags, the changes to taxes will
  87. # be stored in $game_system.tax.perbon and $game_system.tax.dirbon for
  88. # percentage and direct taxes respectively. Always add these variable to
  89. # $game_system.tax.percent and $game_system.tax.direct respectively if changes
  90. # to these two are made. Don't change perbon and dirbon as they only handle the
  91. # changes made by items.
  92. #
  93. # <selltax +/-x>
  94. # Exact same effect as <tax...> but this one changes the prices of sold items.
  95. #
  96. # <selltax +/-x%>
  97. # Same story as above.
  98. #
  99. # Use $game_system.selltax.perbon and $game_system.selltax.perbon for the above
  100. # two tags.
  101. #----------------------------------------------------------------------------
  102. # Credits to:
  103. # Falcon for the original script
  104. # Blizard for the idea that triggered version 2.0 (Falcon's Credits)
  105. # You, because you ate a cookie in your life =D (I hope... If not, I'll send
  106. # Bennett to make you eat a cookie with his manliness...)
  107. #----------------------------------------------------------------------------
  108. # This script should be compatible with all shop systems. If not, alert me.
  109. #============================================================================
  110. #
  111. # CONFIGURATIONS
  112. #
  113. #============================================================================
  114. class Window_ShopStatus < Window_Base

  115.   TAX                    = "Tax"   # Word which stands before percent tax IF the percent tax > 100
  116.   DISCOUNT              = "价格"   # Word which stands before percent tax IF the percent tax < 100
  117.   TAX_DIRECT      = "Tax (A)"     # Word which stands before direct tax IF the direct tax > 0
  118.   DISCOUNT_DIRECT = "Discount (A)" # Word which stands before direct tax IF the direct tax < 0
  119.   TAX_INFORMATION = true  # True = show information about taxes in shops, false = well... the opposite
  120.   TAX_X            = 4    # x position of the information of the taxes. Usually, text has an x-value of 4
  121.   TAX_Y            = 216  # y position of the information. Default = 216. Not that text starts on y = 0 and every line has a height of y = 24

  122. end

  123. module EME
  124.   module REGEXP
  125.         module ITEM

  126.           # Only edit things past here if you know what you're doing
  127.           KEY_ITEM_TAG = /<tax[\s_]?key[\s_]?item>/i # <tax key item>
  128.           ITEM_TAX_PER = /<tax[\s_]?[ ]*([\+\-]\d+)([%%])>/i # <tax +/-x%>
  129.           ITEM_TAX_DIR = /<tax[\s_]?[ ]*([\+\-]\d+)>/i  # <tax +/-x>
  130.           ITEM_SELLTAX_PER = /<selltax[\s_]?[ ]*([\+\-]\d+)([%%])>/i # <selltax +/-x%>
  131.           ITEM_SELLTAX_DIR = /<selltax[\s_]?[ ]*([\+\-]\d+)>/i  # <selltax +/-x>

  132.         end
  133.   end
  134. end

  135. #============================================================================
  136. #
  137. # Game_System
  138. # Defines all needed variables for taxes.
  139. #============================================================================

  140. class Game_System::Tax
  141.   attr_accessor :percent
  142.   attr_accessor :perbon
  143.   attr_accessor :direct
  144.   attr_accessor :dirbon

  145.   def initialize
  146.         @percent = 100
  147.         @perbon  = 0
  148.         @direct  = 0
  149.         @dirbon  = 0
  150.   end

  151. end

  152. class Game_System::SellTax
  153.   attr_accessor :percent
  154.   attr_accessor :perbon
  155.   attr_accessor :direct
  156.   attr_accessor :dirbon

  157.   def initialize
  158.         @percent = 100
  159.         @perbon  = 0
  160.         @direct  = 0
  161.         @dirbon  = 0
  162.   end

  163. end

  164. class Game_System
  165.   attr_reader :tax
  166.   attr_reader :selltax

  167.   alias eme_tax_initialize initialize
  168.   def initialize
  169.         eme_tax_initialize
  170.         @tax = Tax.new
  171.         @selltax = SellTax.new
  172.   end

  173. end

  174. #============================================================================
  175. #
  176. # Window_ShopBuy
  177. # Handles effects of taxes and <tax key item>.
  178. #============================================================================

  179. class Window_ShopBuy

  180.   def price(item)
  181.         @price[item]
  182.         notetag_check(item)
  183.         if @key_item
  184.           @new_price = @price[item]
  185.         elsif $game_system.tax.percent != 100 or $game_system.tax.direct != 0
  186.           @new_price = @price[item] * $game_system.tax.percent / 100 + $game_system.tax.direct
  187.         else
  188.           @new_price = @price[item]
  189.         end
  190.   end

  191.   def notetag_check(item)
  192.         @key_item = false
  193.         item.note.split(/[\r\n]+/).each { |line|
  194.         case line
  195.           when EME::REGEXP::ITEM::KEY_ITEM_TAG
  196.                 @key_item = true
  197.           end
  198.         }
  199.   end

  200. end

  201. class Scene_Shop

  202.   def selling_price
  203.         the_selling_price = @item.price / 2
  204.         notetag_check(@item)
  205.         unless @key_item = true
  206.           if $game_system.selltax.percent != 100
  207.                 the_selling_price *= $game_system.selltax.percent / 100
  208.           end
  209.           if $game_system.selltax.direct != 0
  210.                 the_selling_price += $game_system.selltax.direct
  211.           end
  212.         end
  213.         return the_selling_price
  214.   end

  215.   def notetag_check(item)
  216.         @key_item = false
  217.         item.note.split(/[\r\n]+/).each { |line|
  218.         case line
  219.           when EME::REGEXP::ITEM::KEY_ITEM_TAG
  220.                 @key_item = true
  221.           end
  222.         }
  223.   end

  224. end

  225. #============================================================================
  226. #
  227. # Game_Party
  228. # Handles items which alter taxes.
  229. #============================================================================

  230. class Game_Party

  231.   alias eme_tax_gain_item gain_item
  232.   def gain_item(item, amount, include_equip = false)
  233.         eme_tax_gain_item(item, amount, include_equip = false)
  234.         if amount > 0 and item != nil
  235.           item.note.split(/[\r\n]+/).each { |line|
  236.           case line
  237.                 when EME::REGEXP::ITEM::ITEM_TAX_PER
  238.                   $game_system.tax.percent += $1.to_i * amount
  239.                   $game_system.tax.perbon += $1.to_i * amount
  240.                 when EME::REGEXP::ITEM::ITEM_TAX_DIR
  241.                   $game_system.tax.direct += $1.to_i * amount
  242.                   $game_system.tax.dirbon += $1.to_i * amount
  243.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  244.                   $game_system.selltax.percent += $1.to_i * amount
  245.                   $game_system.selltax.perbon += $1.to_i * amount
  246.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  247.                   $game_system.selltax.percent += $1.to_i * amount
  248.                   $game_system.selltax.perbon += $1.to_i * amount
  249.                 end
  250.           }
  251.         elsif item != nil
  252.           item.note.split(/[\r\n]+/).each { |line|
  253.           case line
  254.                 when EME::REGEXP::ITEM::ITEM_TAX_PER
  255.                   $game_system.tax.percent -= $1.to_i * amount
  256.                   $game_system.tax.perbon -= $1.to_i * amount
  257.                 when EME::REGEXP::ITEM::ITEM_TAX_DIR
  258.                   $game_system.tax.direct -= $1.to_i * amount
  259.                   $game_system.tax.dirbon -= $1.to_i * amount
  260.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  261.                   $game_system.selltax.percent -= $1.to_i * amount
  262.                   $game_system.selltax.perbon -= $1.to_i * amount
  263.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  264.                   $game_system.selltax.percent -= $1.to_i * amount
  265.                   $game_system.selltax.perbon -= $1.to_i * amount
  266.                 end
  267.           }
  268.         end
  269.   end

  270. end

  271. #============================================================================
  272. #
  273. # Window_ShopStatus
  274. # Handles information of taxes shown in shops.
  275. #============================================================================
  276. class Window_ShopStatus < Window_Base

  277.   alias eme_tax_refresh refresh
  278.   def refresh
  279.         eme_tax_refresh
  280.         if TAX_INFORMATION
  281.           draw_taxes(TAX_X, TAX_Y)
  282.         end
  283.   end

  284.   def draw_taxes(x, y)
  285.         if $game_system.tax.percent != 100
  286.           rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  287.           change_color(system_color)
  288.           if $game_system.tax.percent > 100
  289.                 draw_text(rect, TAX + ":")
  290.           else
  291.                 draw_text(rect, DISCOUNT + ":")
  292.           end
  293.           change_color(normal_color)
  294.           draw_text(rect, $game_system.tax.percent.to_s + "%", 2)
  295.         end
  296.         if $game_system.tax.direct != 0
  297.           rect = Rect.new(x, y + 24, contents.width - 4 - x, line_height)
  298.           change_color(system_color)
  299.           if $game_system.tax.direct > 0
  300.                 draw_text(rect, TAX_DIRECT + ":")
  301.           else
  302.                 draw_text(rect, DISCOUNT_DIRECT + ":")
  303.           end
  304.           change_color(normal_color)
  305.           draw_text(rect, $game_system.tax.direct.to_s, 2)
  306.         end
  307.   end

  308. end
复制代码
梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
回帖
45
 楼主| 发表于 2013-2-5 14:04:32 | 显示全部楼层
????????????求使用经验
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部