设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2868|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
帖子
53
跳转到指定楼层
1
 楼主| 发表于 2013-2-3 23:12:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

RUBY 代码复制
  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.  
  116.   TAX                    = "Tax"   # Word which stands before percent tax IF the percent tax > 100
  117.   DISCOUNT              = "价格"   # Word which stands before percent tax IF the percent tax < 100
  118.   TAX_DIRECT      = "Tax (A)"     # Word which stands before direct tax IF the direct tax > 0
  119.   DISCOUNT_DIRECT = "Discount (A)" # Word which stands before direct tax IF the direct tax < 0
  120.   TAX_INFORMATION = true  # True = show information about taxes in shops, false = well... the opposite
  121.   TAX_X            = 4    # x position of the information of the taxes. Usually, text has an x-value of 4
  122.   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
  123.  
  124. end
  125.  
  126. module EME
  127.   module REGEXP
  128.         module ITEM
  129.  
  130.           # Only edit things past here if you know what you're doing
  131.           KEY_ITEM_TAG = /<tax[\s_]?key[\s_]?item>/i # <tax key item>
  132.           ITEM_TAX_PER = /<tax[\s_]?[ ]*([\+\-]\d+)([%%])>/i # <tax +/-x%>
  133.           ITEM_TAX_DIR = /<tax[\s_]?[ ]*([\+\-]\d+)>/i  # <tax +/-x>
  134.           ITEM_SELLTAX_PER = /<selltax[\s_]?[ ]*([\+\-]\d+)([%%])>/i # <selltax +/-x%>
  135.           ITEM_SELLTAX_DIR = /<selltax[\s_]?[ ]*([\+\-]\d+)>/i  # <selltax +/-x>
  136.  
  137.         end
  138.   end
  139. end
  140.  
  141. #============================================================================
  142. #
  143. # Game_System
  144. # Defines all needed variables for taxes.
  145. #============================================================================
  146.  
  147. class Game_System::Tax
  148.   attr_accessor :percent
  149.   attr_accessor :perbon
  150.   attr_accessor :direct
  151.   attr_accessor :dirbon
  152.  
  153.   def initialize
  154.         @percent = 100
  155.         @perbon  = 0
  156.         @direct  = 0
  157.         @dirbon  = 0
  158.   end
  159.  
  160. end
  161.  
  162. class Game_System::SellTax
  163.   attr_accessor :percent
  164.   attr_accessor :perbon
  165.   attr_accessor :direct
  166.   attr_accessor :dirbon
  167.  
  168.   def initialize
  169.         @percent = 100
  170.         @perbon  = 0
  171.         @direct  = 0
  172.         @dirbon  = 0
  173.   end
  174.  
  175. end
  176.  
  177. class Game_System
  178.   attr_reader :tax
  179.   attr_reader :selltax
  180.  
  181.   alias eme_tax_initialize initialize
  182.   def initialize
  183.         eme_tax_initialize
  184.         @tax = Tax.new
  185.         @selltax = SellTax.new
  186.   end
  187.  
  188. end
  189.  
  190. #============================================================================
  191. #
  192. # Window_ShopBuy
  193. # Handles effects of taxes and <tax key item>.
  194. #============================================================================
  195.  
  196. class Window_ShopBuy
  197.  
  198.   def price(item)
  199.         @price[item]
  200.         notetag_check(item)
  201.         if @key_item
  202.           @new_price = @price[item]
  203.         elsif $game_system.tax.percent != 100 or $game_system.tax.direct != 0
  204.           @new_price = @price[item] * $game_system.tax.percent / 100 + $game_system.tax.direct
  205.         else
  206.           @new_price = @price[item]
  207.         end
  208.   end
  209.  
  210.   def notetag_check(item)
  211.         @key_item = false
  212.         item.note.split(/[\r\n]+/).each { |line|
  213.         case line
  214.           when EME::REGEXP::ITEM::KEY_ITEM_TAG
  215.                 @key_item = true
  216.           end
  217.         }
  218.   end
  219.  
  220. end
  221.  
  222. class Scene_Shop
  223.  
  224.   def selling_price
  225.         the_selling_price = @item.price / 2
  226.         notetag_check(@item)
  227.         unless @key_item = true
  228.           if $game_system.selltax.percent != 100
  229.                 the_selling_price *= $game_system.selltax.percent / 100
  230.           end
  231.           if $game_system.selltax.direct != 0
  232.                 the_selling_price += $game_system.selltax.direct
  233.           end
  234.         end
  235.         return the_selling_price
  236.   end
  237.  
  238.   def notetag_check(item)
  239.         @key_item = false
  240.         item.note.split(/[\r\n]+/).each { |line|
  241.         case line
  242.           when EME::REGEXP::ITEM::KEY_ITEM_TAG
  243.                 @key_item = true
  244.           end
  245.         }
  246.   end
  247.  
  248. end
  249.  
  250. #============================================================================
  251. #
  252. # Game_Party
  253. # Handles items which alter taxes.
  254. #============================================================================
  255.  
  256. class Game_Party
  257.  
  258.   alias eme_tax_gain_item gain_item
  259.   def gain_item(item, amount, include_equip = false)
  260.         eme_tax_gain_item(item, amount, include_equip = false)
  261.         if amount > 0 and item != nil
  262.           item.note.split(/[\r\n]+/).each { |line|
  263.           case line
  264.                 when EME::REGEXP::ITEM::ITEM_TAX_PER
  265.                   $game_system.tax.percent += $1.to_i * amount
  266.                   $game_system.tax.perbon += $1.to_i * amount
  267.                 when EME::REGEXP::ITEM::ITEM_TAX_DIR
  268.                   $game_system.tax.direct += $1.to_i * amount
  269.                   $game_system.tax.dirbon += $1.to_i * amount
  270.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  271.                   $game_system.selltax.percent += $1.to_i * amount
  272.                   $game_system.selltax.perbon += $1.to_i * amount
  273.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  274.                   $game_system.selltax.percent += $1.to_i * amount
  275.                   $game_system.selltax.perbon += $1.to_i * amount
  276.                 end
  277.           }
  278.         elsif item != nil
  279.           item.note.split(/[\r\n]+/).each { |line|
  280.           case line
  281.                 when EME::REGEXP::ITEM::ITEM_TAX_PER
  282.                   $game_system.tax.percent -= $1.to_i * amount
  283.                   $game_system.tax.perbon -= $1.to_i * amount
  284.                 when EME::REGEXP::ITEM::ITEM_TAX_DIR
  285.                   $game_system.tax.direct -= $1.to_i * amount
  286.                   $game_system.tax.dirbon -= $1.to_i * amount
  287.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  288.                   $game_system.selltax.percent -= $1.to_i * amount
  289.                   $game_system.selltax.perbon -= $1.to_i * amount
  290.                 when EME::REGEXP::ITEM::ITEM_SELLTAX_PER
  291.                   $game_system.selltax.percent -= $1.to_i * amount
  292.                   $game_system.selltax.perbon -= $1.to_i * amount
  293.                 end
  294.           }
  295.         end
  296.   end
  297.  
  298. end
  299.  
  300. #============================================================================
  301. #
  302. # Window_ShopStatus
  303. # Handles information of taxes shown in shops.
  304. #============================================================================
  305. class Window_ShopStatus < Window_Base
  306.  
  307.   alias eme_tax_refresh refresh
  308.   def refresh
  309.         eme_tax_refresh
  310.         if TAX_INFORMATION
  311.           draw_taxes(TAX_X, TAX_Y)
  312.         end
  313.   end
  314.  
  315.   def draw_taxes(x, y)
  316.         if $game_system.tax.percent != 100
  317.           rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  318.           change_color(system_color)
  319.           if $game_system.tax.percent > 100
  320.                 draw_text(rect, TAX + ":")
  321.           else
  322.                 draw_text(rect, DISCOUNT + ":")
  323.           end
  324.           change_color(normal_color)
  325.           draw_text(rect, $game_system.tax.percent.to_s + "%", 2)
  326.         end
  327.         if $game_system.tax.direct != 0
  328.           rect = Rect.new(x, y + 24, contents.width - 4 - x, line_height)
  329.           change_color(system_color)
  330.           if $game_system.tax.direct > 0
  331.                 draw_text(rect, TAX_DIRECT + ":")
  332.           else
  333.                 draw_text(rect, DISCOUNT_DIRECT + ":")
  334.           end
  335.           change_color(normal_color)
  336.           draw_text(rect, $game_system.tax.direct.to_s, 2)
  337.         end
  338.   end
  339.  
  340. end

Lv1.梦旅人

梦石
0
星屑
50
在线时间
60 小时
注册时间
2013-1-21
帖子
53
2
 楼主| 发表于 2013-2-5 14:04:32 | 只看该作者
????????????求使用经验
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-1 18:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表