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

Project1

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

[已经过期] 找一个能够设定出售价格的脚本

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2084
在线时间
664 小时
注册时间
2014-2-15
帖子
81
跳转到指定楼层
1
发表于 2017-12-24 12:51:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 资深萝莉控 于 2017-12-24 19:01 编辑

影月千秋的脚本我看过了,我需要的是在每个商店那边设定的出售价格都不同的,也就是说,不是他那样只能调整所有的出售比例,而是每一个卖品在每一个商店有各自的卖价,这个比例不是一定的。就像Hime的shop manager 里面设定那样,不过她的脚本和我的真实商店会冲突。所以希望找一个类似的价格宏展。
  1. #
  2. # 要使用的店主可以在整个购物过程中更改图形
  3. # 让他们笑或其他任何你的想象力认为的。
  4. # 它还增加了在此过程中为店主的谈话显示文本。
  5. #
  6. # 该脚本不包括图形供您使用。你需要创建
  7. #
  8. # 该脚本还可以跟踪的股票在不同的商店,即使你卖
  9. # 项目到店,这将增加该项目,以它的购买清单
  10. #
  11. #------------------------------------------------------------------------------#
  12. #  INSTRUCTIONS:
  13. #------------------------------------------------------------------------------#
  14. #  把在材料与上述主要脚本
  15. #  图片进去 /Graphics/Pictures/ 文件夹中。
  16. #
  17. #------------------------------------------------------------------------------#
  18. #  脚本调用来改变图像
  19. #------------------------------------------------------------------------------#
  20. #
  21. # $game_system.shopkeeper = "ImageName"         # 变化店主图像
  22. #
  23. # $game_system.shopback = "ImageName"           # 更改背景图片
  24. #
  25. # $game_system.shop_windowskin = "ImageName"    # Change windowskin for shop
  26. #                                               # /Graphics/System/ folder
  27. #
  28. #------------------------------------------------------------------------------#
  29. #  高级脚本调用改变店主的谈话(x是设置的行)
  30. #------------------------------------------------------------------------------#
  31. #
  32. # $game_system.shop_talk[x] = "New shopkeeper saying here"
  33. #
  34. #------------------------------------------------------------------------------#
  35. # 我说这是先进的,是因为它是在微小的脚本callbox使用
  36. # 您可能需要使用额外的代码。下面的例子:
  37. #
  38. #     $game_system.shop_talk[0] = "This will " +
  39. #     "change the text for the initial welcome
  40. #     message."
  41. #
  42. # 下面reasSee在店主TALK每个报价将被编号用在这里.
  43. #------------------------------------------------------------------------------#

  44. #------------------------------------------------------------------------------#
  45. #  脚本调用控制SHOP STOCK
  46. #------------------------------------------------------------------------------#
  47. #
  48. # shop(shop_id)    # Use this script call to set the next shop processing event
  49. #                  # to be a certain shop number. If you do not use this script
  50. #                  # call before a shop event, the shop will not use stock.
  51. #
  52. # add_stock(shop_id,type,item_id,amount)     # Add a number of items to the shop
  53. #                                            # number you specify.
  54. #
  55. # rem_stock(shop_id,type,item_id,amount)     # Remove a number of items from the
  56. #                                            # shop number you specify.
  57. #
  58. # bulk_fill(shop_id,type,amount,[id,id,id])  # Add items to a shop in bulk.
  59. #
  60. #
  61. #   # If you do NOT add an item as stock (using the above script call) to a shop
  62. #   # that includes that item in the shop processing event - that item will be
  63. #   # unlimited.
  64. #
  65. #------------------------------------------------------------------------------#
  66. # 上述脚本调用说明
  67. #------------------------------------------------------------------------------#
  68. # shop_id
  69. # This is a number you choose to use for a certain shop. You can use this
  70. # number for any shop anywhere and it will keep track of what items are sold
  71. # and bought from it. You can have as many different shop id's as you likd.
  72. #
  73. # type
  74. # 0 = an item     1 = a weapon     2 = an armor
  75. #
  76. # item_id   or   id
  77. # The id of the item/weapon/armor in your database.
  78. #
  79. # amount
  80. # How many of the item you wish to add or remove from the chosen shop id.
  81. #
  82. #------------------------------------------------------------------------------#
  83. #  EXAMPLES
  84. #------------------------------------------------------------------------------#
  85. #
  86. #  add_stock(2,0,1,20)     # 将新增项目120至店数2
  87. #  add_stock(6,1,10,2)     # Will add 2 of weapon 10 to shop number 6
  88. #  rem_stock(6,1,10,2)     # Will remove 2 of weapon 10 from shop number 6
  89. #
  90. #  bulk_fill(1,0,20,[1,2,3,4,5,6])  # Will add 20 of each item inside square
  91. #                                   # brackets to shop number 1
  92. #
  93. #  bulk_fill(3,2,1,[12,22,13])      # Will add 1 of each armor inside square
  94. #                                   # brackets to shop number 3
  95. #
  96. #  shop(3)                 # The next shop processing will use shop number 3
  97. #
  98. #------------------------------------------------------------------------------#

  99. #------------------------------------------------------------------------------#
  100. #  NOTETAG for CLASS
  101. #------------------------------------------------------------------------------#
  102. #
  103. #  <primary_params: x,y>   # 武器和装甲paramater一类将使用
  104. #                          # 比较,如果该武器(x)或铠(y)为更好
  105. #                          # 对于演员的装备或不.
  106. #
  107. #  不包括本notetag的类将使用默认的2,3(ATK和DEF)
  108. #
  109. #  参数ID是:
  110. #
  111. #  0 - MaxHP         1 - MaxMP         2 - ATK           3 - DEF
  112. #  4 - MAT           5 - MDF           6 - AGI           7 - LUK
  113. #
  114. #------------------------------------------------------------------------------#

  115. ($imported ||= {})["Galvs_Shopkeepers"] = true
  116. module Galv_Shopkeeper

  117. #------------------------------------------------------------------------------#
  118. #  SCRIPT SETTINGS
  119. #------------------------------------------------------------------------------#
  120.   #-------------------#
  121.   # SHOPKEEPER IMAGES #
  122.   #-------------------#
  123.   
  124.   SHOPKEEPER_IMAGE = "shopkeeper"
  125.   
  126.   # Shopkeeper will change to an image using the current shopkeeper file name
  127.   # with the below extentions added (eg. Graphics/Pictures/shopkeeper_happy.png)
  128.   
  129.   GREET = "_happy"         # image extension greeting when you enter shop
  130.   FAREWELL = "_happy"      # image extension when you leave the shop
  131.   
  132.   BUY = "_happy"           # image extension when you buy an item
  133.   SELL = "_happy"          # image extension when you sell an item
  134.   
  135.   DONT_BUY = "_annoyed"    # image extension when you don't buy something
  136.   DONT_SELL = "_annoyed"   # image extension when you don't sell something
  137.   
  138.   CANT_BUY = "_annoyed"    # image extension when you can't afford something
  139.   CANT_SELL = "_annoyed"   # image extension when you can't sell an item
  140.   MAX_ITEMS = "_annoyed"   # image extension when you can't hold more of an item
  141.   SOLD_OUT = "_happy"      # image extension when can't buy sold out item
  142.   
  143.   SHOW_DETAILS = "_happy"  # image extension when show details window is open
  144.   NO_DETAILS = "_annoyed"  # image extension when no item when 'd' pressed


  145.   #-------------------#
  146.   # BACKGROUND IMAGE  #
  147.   #-------------------#
  148.   
  149.   SHOP_BACKGROUND = "shop_background"   # background image behind shopkeeper
  150.   BACKGROUND_SCROLL_X = 0               # speed background scroll horizontally
  151.   BACKGROUND_SCROLL_Y = 0               # speed background scroll vertically

  152.   WINDOWSKIN = "Window"            # windowskin used by shop

  153.   #-----------------#
  154.   # SHOPKEEPER TALK #
  155.   #-----------------#
  156.   
  157.   # These are defaults. You can change them using script calls during game.
  158.   
  159.   TALK = [ # don't touch
  160.   
  161.     "欢迎!商品都是很棒的哦!",     # 0: when entering a shop
  162.     "谢谢你的购买!!!",     # 1: when purchase an item
  163.     "你的物品也是不错的!.",      # 2: when sell an item
  164.     "你需要再看看其他商品么?",       # 3: when in root menu after shopping
  165.     "只是看看商品么?",       # 4: when in root menu but didn't buy
  166.     "你这是浪费我的时间还是什么?", # 5: when in root menu but didn't sell
  167.     "对不起呢,你的金币不够的样子呢!",     # 6: when try to buy too pricey item
  168.     "我不能买这个...",              # 7: when try to sell something you cant
  169.     "你已经不能携带更多的这个商品了!",# 8: when try to buy when items maxed
  170.     "谢谢, 欢迎下次再来购物!", # 9: when leaving a shop
  171.     "这个无法查看详细信息的说!",  # 10: when pressing 'd' on no item.
  172.     "那些我们已经卖完了!",    # 11: when item is sold out
  173.    
  174.   ] # don't touch
  175.   
  176.   
  177.   #---------------#
  178.   # OTHER OPTIONS #
  179.   #---------------#
  180.   
  181.   ITEM_COUNT_TEXT = "所持金币"    # Text that appears before item amount
  182.   HOW_MANY_TEXT = "数量?"         # Text for when determining how many
  183.   STOCK_TEXT = "库存"             # Text to display how many items in stock
  184.                                       # only displays if a limit is set.
  185.   NO_STOCK = "已经卖完"               # Displayed if limit of 0 is reached
  186.   STOCK_COLOR = 6                     # 色股份文本。

  187.   
  188.   FRAME_TIME = 75        # time that above text and images stay active before
  189.                          # returning to default image and no talk.
  190.                          # (60 = 1 second)
  191.   
  192.   SALE_VAR = 1           # variable that controls sale price as a % of item's
  193.                          # price. Default is 50, use control variables to change
  194.                          # this during the game. Make this 0 to not use this
  195.                          # feature.

  196.   DETAILS_KEY = :Z       # :Z is "D". Press "D" in the shop to show the item
  197.                          # selected's details.

  198.   D_IMAGE = "shop_detail" # The image used to show what key to press for details
  199.                           # This image goes in /Graphics/System/

  200.   SE1 = ["Book2", 85, 100]  # Sound effect played when opening details
  201.   SE2 = ["Blow1", 85, 150]  # Sound effect played when closing details
  202.   
  203.   ACTORS_SHOWN = 4       # Number of actors shown in the equip status window
  204.   ACTORS_X = 15          # x position of first actor in the equip status window
  205.   ACTORS_SPACE = 70      # space between each actor in equip status window

  206.   # Settings to fit 6 actors here nicely are:
  207.   # ACTORS_SHOWN = 6, ACTORS_X = 5, ACTORS_SPACE = 50


  208.   #---------------#
  209.   # EQUIP COMPARE #
  210.   #---------------#


  211.   SHOW_COMPARE_IMAGE = true   # if true: shop will display only an image behind
  212.                               # the characters shown when viewing equipment

  213.   SHOW_PARAM_CHANGE = true    # shows by how much the primary parameter changes
  214.   
  215.   SHOW_PARAM_NAME = true      # shows which paramater it is changing

  216.   IMAGE_OVER = false     # false: images are under the characters
  217.                          # true: images are on top of them.


  218.   # Below images are taken from /Graphics/System/

  219.   E_INCREASE = "shop_up"    # Image displayed when equip is better
  220.   E_DECREASE = "shop_down"  # Image displayed when equip is worse
  221.   E_SAME = ""      # Image displayed when euqip is same

  222. #------------------------------------------------------------------------------#
  223. #  END SCRIPT SETTINGS
  224. #------------------------------------------------------------------------------#
  225. end


  226. module Shop_Stock
  227.   def check_stock(item)
  228.     if item.is_a?(RPG::Item); itype = 0
  229.     elsif item.is_a?(RPG::Weapon); itype = 1
  230.     else; itype = 2; end
  231.     return -1 if item.nil?
  232.     return -1 if $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]].nil?
  233.     if $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]] >= 0
  234.       return $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]]
  235.     else
  236.       return -1
  237.     end
  238.   end
  239. end


  240. class Game_Interpreter
  241.   def shop(shop_id)
  242.     $game_system.shop_selected = shop_id
  243.   end
  244.   
  245.   def add_stock(shop_id,type,item_id,amount)
  246.     # type 0 = item, 1 = weapon, 2 = armor
  247.     $game_system.shop_stock[shop_id] ||= {}
  248.     $game_system.shop_stock[shop_id][[type,item_id]] ||= 0
  249.     $game_system.shop_stock[shop_id][[type,item_id]] += amount
  250.   end
  251.   
  252.   def rem_stock(shop_id,type,item_id,amount)
  253.     # type 0 = item, 1 = weapon, 2 = armor
  254.     return if $game_system.shop_stock[shop_id].nil?
  255.     return if $game_system.shop_stock[shop_id][[type,item_id]].nil?
  256.     $game_system.shop_stock[shop_id][[type,item_id]] -= amount
  257.     if $game_system.shop_stock[shop_id][[type,item_id]] < 0
  258.       $game_system.shop_stock[shop_id][[type,item_id]] = 0
  259.     end
  260.   end
  261.   
  262.   def reset_shop_settings
  263.     $game_system.shopkeeper = Galv_Shopkeeper::SHOPKEEPER_IMAGE
  264.     $game_system.shopback = Galv_Shopkeeper::SHOP_BACKGROUND
  265.     $game_system.shop_windowskin = Galv_Shopkeeper::WINDOWSKIN
  266.     $game_system.shop_talk = Array.new(Galv_Shopkeeper::TALK)
  267.   end
  268.   
  269.   def bulk_fill(*args)
  270.     array = [*args]
  271.     shop_id = array[0]
  272.     type = array[1]
  273.     amount = array[2]
  274.     ids = array[3]
  275.    
  276.     $game_system.shop_stock[shop_id] ||= {}
  277.     ids.each do |i|
  278.       $game_system.shop_stock[shop_id][[type,i]] ||= 0
  279.       $game_system.shop_stock[shop_id][[type,i]] += amount
  280.     end
  281.   end
  282. end # Game_Interpreter


  283. class Game_System
  284.   attr_accessor :shop_selected
  285.   attr_accessor :shop_stock
  286.   attr_accessor :shopback
  287.   attr_accessor :shopkeeper
  288.   attr_accessor :shop_talk
  289.   attr_accessor :shop_spose
  290.   attr_accessor :shop_windowskin
  291.   
  292.   alias galv_shopkeeper_system_initialize initialize
  293.   def initialize
  294.     galv_shopkeeper_system_initialize
  295.     @shopback = Galv_Shopkeeper::SHOP_BACKGROUND
  296.     @shopkeeper = Galv_Shopkeeper::SHOPKEEPER_IMAGE
  297.     @shop_talk = Array.new(Galv_Shopkeeper::TALK)
  298.     @shop_windowskin = Galv_Shopkeeper::WINDOWSKIN
  299.     @shop_spose = nil
  300.     @shop_selected = 0
  301.     @shop_stock = {0=>{}}
  302.   end
  303.   
  304. end # Game_System


  305. class Scene_Shop < Scene_MenuBase
  306.   
  307.   alias galv_shopkeeper_scene_shop_prepare prepare
  308.   def prepare(goods, purchase_only)
  309.     galv_shopkeeper_scene_shop_prepare(goods, purchase_only)
  310.     return if $game_system.shop_stock[$game_system.shop_selected].nil?
  311.     stock_change

  312.   end
  313.   
  314.   def stock_change
  315.     temp_list = $game_system.shop_stock[$game_system.shop_selected].keys
  316.     @goods.each do |i|
  317.       if temp_list.include?([i[0],i[1]])
  318.         temp_list.delete([i[0],i[1]])
  319.       end
  320.     end
  321.     temp_list.each do |i|
  322.       if $game_system.shop_stock[$game_system.shop_selected][[i[0],i[1]]] != 0
  323.         @goods << [i[0],i[1],0,0]
  324.       end
  325.     end
  326.   end
  327.   
  328.   alias galv_shopkeeper_scene_shop_start start
  329.   def start
  330.     galv_shopkeeper_scene_shop_start
  331.     @shoptime = 0
  332.     @has_shopped = false
  333.     create_talk_window
  334.     create_desc_window
  335.     create_shop_background
  336.     create_shopkeeper
  337.     create_images
  338.     @leave_shop = false
  339.     @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::GREET) rescue Cache.picture($game_system.shopkeeper)
  340.     @shoptime = Galv_Shopkeeper::FRAME_TIME
  341.   end
  342.   
  343.   def create_desc_window
  344.     b = @buy_window
  345.     @desc_window = Window_ItemDesc.new(b.x, b.y, b.width, b.height)
  346.     @desc_window.viewport = @viewport
  347.     @desc_window.hide
  348.   end
  349.   
  350.   def create_talk_window
  351.     @talk_window = Window_Help.new
  352.     @talk_window.viewport = @viewport
  353.     @talk_window.set_text($game_system.shop_talk[0])
  354.     @help_window.hide
  355.   end
  356.   
  357.   def create_itemcount_window
  358.     wy = @dummy_window.y
  359.     ww = Graphics.width - 304
  360.     wh = @gold_window.height
  361.     @itemcount_window = Window_ItemCount.new(0, wy, ww, wh)
  362.     @itemcount_window.viewport = @viewport
  363.     @itemcount_window.hide
  364.   end
  365.   
  366.   # OVERWRITE
  367.   def create_dummy_window
  368.     wy = @command_window.y + @command_window.height
  369.     wh = Graphics.height - wy - @gold_window.height * 2
  370.     @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
  371.     @dummy_window.viewport = @viewport
  372.   end
  373.   
  374.   # OVERWRITE
  375.   def create_buy_window
  376.     wy = @dummy_window.y
  377.     wh = @dummy_window.height
  378.     @buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
  379.     @buy_window.viewport = @viewport
  380.     @buy_window.help_window = @help_window
  381.     @buy_window.status_window = @status_window
  382.     @buy_window.count_window = @itemcount_window
  383.     @buy_window.desc_window = @desc_window
  384.     @buy_window.hide
  385.     @buy_window.set_handler(:ok,     method(:on_buy_ok))
  386.     @buy_window.set_handler(:cancel, method(:on_buy_cancel))
  387.     @buy_window.x = Graphics.width - @buy_window.width
  388.   end
  389.   
  390.   # OVERWRITE
  391.   def create_sell_window
  392.     wy = @category_window.y + @category_window.height
  393.     wh = Graphics.height - wy
  394.     @sell_window = Window_ShopSell.new(0, wy, @buy_window.width, wh)
  395.     @sell_window.viewport = @viewport
  396.     @sell_window.help_window = @help_window
  397.     @sell_window.status_window = @itemcount_window
  398.     @sell_window.hide
  399.     @sell_window.set_handler(:ok,     method(:on_sell_ok))
  400.     @sell_window.set_handler(:cancel, method(:on_sell_cancel))
  401.     @category_window.item_window = @sell_window
  402.     @sell_window.x = Graphics.width - @buy_window.width
  403.   end
  404.   
  405.   alias galv_shopkeeper_create_number_window create_number_window
  406.   def create_number_window
  407.     galv_shopkeeper_create_number_window
  408.     @number_window.x = Graphics.width - @number_window.width
  409.   end
  410.   
  411.   # OVERWRITE
  412.   def create_status_window
  413.     wx = @number_window.x
  414.     wy = @dummy_window.y + @dummy_window.height
  415.     ww = @number_window.width
  416.     wh = Graphics.height - @dummy_window.height - @dummy_window.y
  417.     @status_window = Window_ShopStatus.new(wx, wy, ww, wh)
  418.     @status_window.viewport = @viewport
  419.     @status_window.hide
  420.     create_itemcount_window
  421.   end
  422.   
  423.   alias galv_shopkeeper_create_dummy_window create_dummy_window
  424.   def create_dummy_window
  425.     galv_shopkeeper_create_dummy_window
  426.     @dummy_window.hide
  427.   end
  428.   
  429.   def create_shopkeeper
  430.     @keeper = Sprite.new
  431.     @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  432.     @keeper.y = Graphics.height - @keeper.bitmap.height
  433.   end
  434.   
  435.   def create_images
  436.     @dkey = Sprite.new
  437.     @dkey.opacity = 0
  438.     @dkey.bitmap = Cache.system(Galv_Shopkeeper::D_IMAGE) rescue Cache.system("")
  439.     @dkey.y = Graphics.height - @dkey.bitmap.height
  440.   end
  441.   
  442.   def create_shop_background
  443.     @shopback = Plane.new
  444.     @shopback.bitmap = Cache.picture($game_system.shopback)
  445.   end
  446.   
  447.   alias galv_shopkeer_sell_on_category_ok on_category_ok
  448.   def on_category_ok
  449.     galv_shopkeer_sell_on_category_ok
  450.     @dkey.opacity = 255
  451.   end
  452.   
  453.   # OVERWRITE
  454.   def on_category_cancel
  455.     @command_window.activate
  456.     @category_window.hide
  457.     @sell_window.hide
  458.     if @has_shopped == true
  459.       @talk_window.set_text($game_system.shop_talk[3])
  460.       @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  461.     else
  462.       @talk_window.set_text($game_system.shop_talk[5])
  463.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::DONT_SELL)
  464.     end
  465.     show_talk
  466.     @has_shopped = false
  467.   end
  468.   
  469.   # OVERWRITE
  470.   def on_buy_cancel
  471.     @command_window.activate
  472.     @buy_window.hide
  473.     @itemcount_window.hide
  474.     @status_window.hide
  475.     @status_window.item = nil
  476.     @itemcount_window.item = nil
  477.     @help_window.clear
  478.     if @has_shopped == true
  479.       @talk_window.set_text($game_system.shop_talk[3])
  480.       @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  481.     else
  482.       @talk_window.set_text($game_system.shop_talk[4])
  483.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::DONT_BUY)
  484.     end
  485.     show_talk
  486.     @has_shopped = false
  487.     @dkey.opacity = 0
  488.   end

  489.   # OVERWRITE
  490.   def on_sell_cancel
  491.     @sell_window.unselect
  492.     @category_window.activate
  493.     @status_window.item = nil
  494.     @itemcount_window.item = nil
  495.     @itemcount_window.hide
  496.     @help_window.clear
  497.     @dkey.opacity = 0
  498.   end
  499.   
  500.   alias galv_shopkeeper_command_buy command_buy
  501.   def command_buy
  502.     galv_shopkeeper_command_buy
  503.     @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  504.     @itemcount_window.show
  505.     hide_talk
  506.     @dkey.opacity = 255
  507.     @desc_window.y = @buy_window.y
  508.     @desc_window.height = @buy_window.height
  509.   end
  510.   
  511.   alias galv_shopkeeper_command_sell command_sell
  512.   def command_sell
  513.     galv_shopkeeper_command_sell
  514.     @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  515.     hide_talk
  516.     @desc_window.y = @sell_window.y
  517.     @desc_window.height = @sell_window.height
  518.   end
  519.   
  520.   alias galv_shopkeeper_do_buy do_buy
  521.   def do_buy(number)
  522.     @has_shopped = true
  523.     galv_shopkeeper_do_buy(number)
  524.     remove_stock(@item,number)
  525.     @talk_window.set_text($game_system.shop_talk[1])
  526.     show_talk
  527.     @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::BUY) rescue Cache.picture($game_system.shopkeeper)
  528.     @shoptime = Galv_Shopkeeper::FRAME_TIME
  529.   end
  530.   
  531.   def remove_stock(item,number)
  532.     return if $game_system.shop_stock[$game_system.shop_selected].nil? ||
  533.     $game_system.shop_selected == 0
  534.     if item.is_a?(RPG::Item); itype = 0
  535.     elsif item.is_a?(RPG::Weapon); itype = 1
  536.     else; itype = 2; end
  537.     return if $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]].nil?
  538.     $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]] -= number
  539.   end

  540.   alias galv_shopkeeper_do_sell do_sell
  541.   def do_sell(number)
  542.     @has_shopped = true
  543.     galv_shopkeeper_do_sell(number)
  544.     add_stock(@item,number)
  545.     stock_change
  546.     @talk_window.set_text($game_system.shop_talk[2])
  547.     show_talk
  548.     @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::SELL) rescue Cache.picture($game_system.shopkeeper)
  549.     @shoptime = Galv_Shopkeeper::FRAME_TIME
  550.   end
  551.   
  552.   def add_stock(item,number)
  553.     return if $game_system.shop_selected == 0
  554.     if item.is_a?(RPG::Item); itype = 0
  555.     elsif item.is_a?(RPG::Weapon); itype = 1
  556.     else; itype = 2; end
  557.     @goods.each do |i|
  558.       if i[0] == itype && i[1] == item.id && $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]].nil?
  559.         return
  560.       end
  561.     end
  562.     $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]] ||= 0
  563.     $game_system.shop_stock[$game_system.shop_selected][[itype,item.id]] += number
  564.   end
  565.   

  566.   # OVERWRITE
  567.   def on_number_ok
  568.     Sound.play_shop
  569.     case @command_window.current_symbol
  570.     when :buy
  571.       do_buy(@number_window.number)
  572.     when :sell
  573.       do_sell(@number_window.number)
  574.       @itemcount_window.hide
  575.     end
  576.     end_number_input
  577.     @gold_window.refresh
  578.     @status_window.refresh
  579.     @itemcount_window.refresh
  580.     @dkey.opacity = 255
  581.   end
  582.   
  583.   alias galv_shopkeeper_on_number_cancel on_number_cancel
  584.   def on_number_cancel
  585.     galv_shopkeeper_on_number_cancel
  586.     case @command_window.current_symbol
  587.     when :sell
  588.       @itemcount_window.hide
  589.     end
  590.     @dkey.opacity = 255
  591.   end

  592.   alias galv_shopkeeper_on_sell_ok on_sell_ok
  593.   def on_sell_ok
  594.     @number_window.trans = :sell
  595.     galv_shopkeeper_on_sell_ok
  596.     @itemcount_window.show
  597.     @dkey.opacity = 0
  598.   end
  599.   
  600.   alias galv_shopkeeper_on_buy_ok on_buy_ok
  601.   def on_buy_ok
  602.     @number_window.trans = :buy
  603.     galv_shopkeeper_on_buy_ok
  604.     @dkey.opacity = 0
  605.   end
  606.   
  607.   
  608.   def end_shopanim
  609.     SceneManager.return if @leave_shop == true
  610.     @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  611.     hide_talk unless @command_window.active
  612.   end
  613.   
  614.   def show_talk
  615.     @talk_window.show
  616.     @help_window.hide
  617.   end
  618.   
  619.   def hide_talk
  620.     @talk_window.hide
  621.     @help_window.show
  622.   end

  623.   def update
  624.     super
  625.     @shoptime -= 1
  626.     end_shopanim if @shoptime == 0
  627.     if @shoptime.odd?
  628.       @shopback.ox += Galv_Shopkeeper::BACKGROUND_SCROLL_X
  629.       @shopback.oy += Galv_Shopkeeper::BACKGROUND_SCROLL_Y
  630.     end
  631.     check_button
  632.     other_poses if $game_system.shop_spose != nil
  633.   end
  634.   
  635.   def check_button
  636.     if @desc_window.visible
  637.       if Input.trigger?(Galv_Shopkeeper::DETAILS_KEY) || Input.trigger?(:B)
  638.         case @command_window.current_symbol
  639.         when :buy
  640.           @buy_window.show.activate
  641.         when :sell
  642.           @sell_window.show.activate
  643.         end
  644.         RPG::SE.new(Galv_Shopkeeper::SE2[0], Galv_Shopkeeper::SE2[1], Galv_Shopkeeper::SE2[2]).play
  645.         @desc_window.hide
  646.         @keeper.bitmap = Cache.picture($game_system.shopkeeper)
  647.       end
  648.     elsif @buy_window.active || @sell_window.active
  649.       if Input.trigger?(Galv_Shopkeeper::DETAILS_KEY)
  650.         case @command_window.current_symbol
  651.         when :buy
  652.           return if @buy_window.item.nil?
  653.           @buy_window.hide.deactivate
  654.           @desc_window.refresh(@buy_window.item,0)
  655.         when :sell
  656.           if @sell_window.item.nil?
  657.             $game_system.shop_spose = 3
  658.             return other_poses
  659.           end
  660.           @sell_window.hide.deactivate
  661.           @desc_window.refresh(@sell_window.item,1)
  662.         end
  663.         @shoptime = 0
  664.         RPG::SE.new(Galv_Shopkeeper::SE1[0], Galv_Shopkeeper::SE1[1], Galv_Shopkeeper::SE1[2]).play
  665.         @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::SHOW_DETAILS) rescue Cache.picture($game_system.shopkeeper)
  666.         hide_talk
  667.         @desc_window.show
  668.       end
  669.     end
  670.   end
  671.   
  672.   def other_poses
  673.     case $game_system.shop_spose
  674.     when 0
  675.       @talk_window.set_text($game_system.shop_talk[6])
  676.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::CANT_BUY) rescue Cache.picture($game_system.shopkeeper)
  677.     when 1
  678.       @talk_window.set_text($game_system.shop_talk[7])
  679.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::CANT_SELL) rescue Cache.picture($game_system.shopkeeper)
  680.     when 2
  681.       @talk_window.set_text($game_system.shop_talk[8])
  682.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::MAX_ITEMS) rescue Cache.picture($game_system.shopkeeper)
  683.     when 3
  684.       @talk_window.set_text($game_system.shop_talk[10])
  685.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::NO_DETAILS) rescue Cache.picture($game_system.shopkeeper)
  686.     when 4
  687.       @talk_window.set_text($game_system.shop_talk[11])
  688.       @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::SOLD_OUT) rescue Cache.picture($game_system.shopkeeper)
  689.     end
  690.     show_talk
  691.     @shoptime = Galv_Shopkeeper::FRAME_TIME
  692.     $game_system.shop_spose = nil
  693.   end
  694.   
  695.   def return_scene
  696.     @talk_window.set_text($game_system.shop_talk[9])
  697.     @keeper.bitmap = Cache.picture($game_system.shopkeeper + Galv_Shopkeeper::FAREWELL) rescue Cache.picture($game_system.shopkeeper)
  698.     show_talk
  699.     @shoptime = Galv_Shopkeeper::FRAME_TIME
  700.     @leave_shop = true
  701.     $game_system.shop_selected = 0
  702.   end
  703.   
  704.   def terminate
  705.     super
  706.     @keeper.dispose
  707.     @keeper.bitmap.dispose
  708.     @shopback.dispose
  709.     @dkey.bitmap.dispose
  710.     @dkey.dispose
  711.   end
  712.   
  713.   # OVERWRITE
  714.   def selling_price
  715.     if $game_variables[Galv_Shopkeeper::SALE_VAR] > 0
  716.       ((@item.price * 0.01) * $game_variables[Galv_Shopkeeper::SALE_VAR]).round
  717.     else
  718.       @item.price / 2
  719.     end
  720.   end
  721.   
  722. end # Scene_Shop < Scene_MenuBase


  723. class Scene_Title < Scene_Base
  724.   alias galv_shopkeeper_command_new_game command_new_game
  725.   def command_new_game
  726.     galv_shopkeeper_command_new_game
  727.     $game_variables[Galv_Shopkeeper::SALE_VAR] = 50 if $game_variables[Galv_Shopkeeper::SALE_VAR] > 0
  728.   end
  729. end # Scene_Title < Scene_Base


  730. class Window_ItemCount < Window_Base
  731.   def initialize(x, y, width, height)
  732.     super(x, y, width, height)
  733.     @item = nil
  734.     refresh
  735.   end

  736.   def refresh
  737.     contents.clear
  738.     draw_possession(4, 0)
  739.   end

  740.   def item=(item)
  741.     @item = item
  742.     refresh
  743.   end

  744.   def draw_possession(x, y)
  745.     rect = Rect.new(x, y, contents.width - 4 - x, line_height)
  746.     change_color(system_color)
  747.     draw_text(rect, Galv_Shopkeeper::ITEM_COUNT_TEXT)
  748.     change_color(normal_color)
  749.     draw_text(rect, $game_party.item_number(@item), 2)
  750.   end
  751. end # Window_ItemCount < Window_Base


  752. class Window_ShopNumber < Window_Selectable
  753.   attr_accessor :trans

  754.   alias galv_shopkeeper_number_initialize initialize
  755.   def initialize(x, y, height)
  756.     galv_shopkeeper_number_initialize(x, y, height)
  757.     @trans = :buy
  758.     draw_how_many
  759.     draw_stock
  760.   end
  761.   
  762.   alias galv_shopkeeper_number_refresh refresh
  763.   def refresh
  764.     galv_shopkeeper_number_refresh
  765.     draw_how_many
  766.     draw_stock
  767.   end
  768.   
  769.   def draw_how_many
  770.     change_color(system_color)
  771.     draw_text(4, 4, contents.width, line_height, Galv_Shopkeeper::HOW_MANY_TEXT)
  772.     change_color(normal_color)
  773.   end
  774.   
  775.   def draw_stock
  776.     return if $game_system.shop_stock[$game_system.shop_selected].nil?
  777.     @stock = check_stock(@item)
  778.    
  779.     if @stock > 0
  780.       text = @stock.to_s + " " + Galv_Shopkeeper::STOCK_TEXT
  781.     elsif @stock == 0
  782.       text = Galv_Shopkeeper::NO_STOCK
  783.     elsif @stock < 0
  784.       text = ""
  785.     end
  786.     change_color(text_color(Galv_Shopkeeper::STOCK_COLOR))
  787.     draw_text(4, 4, contents.width, line_height, text + " ",2) if @trans != :sell
  788.     change_color(normal_color)
  789.   end
  790.   
  791.   def change_number(amount)
  792.     if @stock > 0; stock = @stock
  793.     else stock = @max
  794.     end
  795.     if @trans == :buy
  796.       @number = [[@number + amount, @max, stock].min, 1].max
  797.     elsif @trans == :sell
  798.       @number = [[@number + amount, @max].min, 1].max
  799.     end
  800.   end
  801.   
  802.   include Shop_Stock
  803.   
  804. end # Window_ShopNumber < Window_Selectable


  805. class Window_ShopStatus < Window_Base

  806.   alias galv_shopkeeper_window_status_initialize initialize
  807.   def initialize(x, y, width, height)
  808.     @walk = 0
  809.     @step = 0  # 0 is left, 1 is right
  810.     @animtime = 0
  811.     @e_images = {}
  812.     galv_shopkeeper_window_status_initialize(x, y, width, height)
  813.   end
  814.   
  815.   # OVERWRITE
  816.   def refresh
  817.     contents.clear
  818.     draw_equip_info(Galv_Shopkeeper::ACTORS_X + 5, 40) if @item.is_a?(RPG::EquipItem)
  819.   end
  820.   
  821.   def update
  822.     super
  823.     @animtime += 1
  824.     if @animtime == 10
  825.       case @walk
  826.       when 1; @walk -= 1
  827.       when -1; @walk += 1
  828.       when 0
  829.         if @step == 1
  830.           @walk = -1
  831.           @step = 0
  832.         else
  833.           @walk = 1
  834.           @step = 1
  835.         end
  836.       end
  837.       refresh
  838.       @animtime = 0
  839.     end
  840.   end

  841.   # OVERWRITE
  842.   def draw_equip_info(x, y)
  843.     status_members.each_with_index do |actor, i|
  844.       draw_actor_equip_info(x + (i * Galv_Shopkeeper::ACTORS_SPACE), y, actor)
  845.     end
  846.   end

  847.   # OVERWRITE
  848.   def page_size
  849.     return Galv_Shopkeeper::ACTORS_SHOWN
  850.   end

  851.   # OVERWRITE
  852.   def draw_actor_equip_info(x, y, actor)
  853.     enabled = actor.equippable?(@item)
  854.     change_color(normal_color, enabled)
  855.     item1 = current_equipped_item(actor, @item.etype_id)
  856.     if Galv_Shopkeeper::IMAGE_OVER
  857.       draw_character(actor.character_name, actor.character_index, x + 10, y + 11, enabled)
  858.       draw_actor_param_change(x - 10, y + 10, actor, item1) if enabled
  859.     else
  860.       draw_actor_param_change(x - 10, y + 10, actor, item1) if enabled
  861.       draw_character(actor.character_name, actor.character_index, x + 10, y + 11, enabled)
  862.     end
  863.     if Galv_Shopkeeper::SHOW_PARAM_NAME
  864.       draw_text(x - 8, y - 40, 40, line_height, Vocab::param(@p_id),1) if enabled
  865.     end
  866.   end

  867.   def draw_character(character_name, character_index, x, y,enabled)
  868.     return unless character_name
  869.     bitmap = Cache.character(character_name)
  870.     sign = character_name[/^[\!\$]./]
  871.     if sign && sign.include?('$')
  872.       cw = bitmap.width / 3
  873.       ch = bitmap.height / 4
  874.     else
  875.       cw = bitmap.width / 12
  876.       ch = bitmap.height / 8
  877.     end
  878.     n = character_index
  879.     step = 0
  880.     step = @walk if enabled
  881.     src_rect = Rect.new((n%4*3+1+step)*cw, (n/4*4)*ch, cw, ch)
  882.     contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  883.   end

  884.   # OVERWRITE
  885.   def draw_actor_param_change(x, y, actor, item1)
  886.     @p_id = pid(actor.class_id)
  887.     rect = Rect.new(x, y - 2, 40, line_height)
  888.     change = @item.params[@p_id] - (item1 ? item1.params[@p_id] : 0)
  889.     change_color(param_change_color(change))
  890.     draw_e_image(rect.x,rect.y,actor.id,change) if Galv_Shopkeeper::SHOW_COMPARE_IMAGE
  891.     contents.font.size = 20
  892.     draw_text(rect, sprintf("%+d", change), 1) if Galv_Shopkeeper::SHOW_PARAM_CHANGE
  893.     contents.font.size = 20
  894.   end
  895.   
  896.   def pid(cid)
  897.     primary_param = $data_classes[cid].primary_params
  898.     @item.is_a?(RPG::Weapon) ? type = primary_param[0] : primary_param[1]
  899.   end
  900.   
  901.   def draw_e_image(x,y,actor_id,change)
  902.     if change > 0
  903.       bitmap = Cache.system(Galv_Shopkeeper::E_INCREASE)
  904.     elsif change < 0
  905.       bitmap = Cache.system(Galv_Shopkeeper::E_DECREASE)
  906.     else
  907.       bitmap = Cache.system(Galv_Shopkeeper::E_SAME)
  908.     end
  909.     src_rect = Rect.new(0, 0, 100, 100)
  910.     contents.blt(x, 0, bitmap, src_rect)
  911.   end
  912.   
  913.   
  914.   
  915.   
  916. end # Window_ShopStatus < Window_Base


  917. class Window_ShopBuy < Window_Selectable
  918.   
  919.   # OVERWRITE
  920.   def initialize(x, y, height, shop_goods)
  921.     super(x, y, window_width, height)
  922.     @shop_goods = shop_goods
  923.     @money = 0
  924.     @max_items_reached = false
  925.     refresh
  926.     select(0)
  927.   end
  928.   
  929.   def count_window=(count_window)
  930.     @count_window = count_window
  931.   end
  932.   
  933.   def desc_window=(desc_window)
  934.     @desc_window = desc_window
  935.   end

  936.   # OVERWRITE
  937.   def update_help
  938.     @help_window.set_item(item) if @help_window
  939.     @status_window.item = item if @status_window
  940.     @count_window.item = item if @count_window
  941.     @desc_window.item = item if @desc_window
  942.   end
  943.   
  944.   # OVERWRITE
  945.   def current_item_enabled?
  946.     if $game_party.item_max?(item)
  947.       @max_items_reached = true
  948.     else
  949.       @max_items_reached = false
  950.     end
  951.     if check_stock(item) == 0
  952.       @item_sold_out = true
  953.     else
  954.       @item_sold_out = false
  955.     end
  956.     enable?(@data[index])
  957.   end
  958.   
  959.   def enable?(item)
  960.     item && price(item) <= @money && !$game_party.item_max?(item) &&
  961.     check_stock(item) != 0
  962.   end
  963.   
  964.   # OVERWRITE
  965.   def draw_item(index)
  966.     item = @data[index]
  967.     stock = check_stock(item)
  968.     rect = item_rect(index)
  969.     draw_item_name(item, rect.x, rect.y, enable?(item))
  970.     rect.width -= 4
  971.     if stock == 0
  972.       draw_text(rect, Galv_Shopkeeper::NO_STOCK, 2)
  973.     else
  974.       draw_text(rect, price(item), 2)
  975.     end
  976.   end
  977.   
  978.   def process_ok
  979.     if current_item_enabled?
  980.       Sound.play_ok
  981.       Input.update
  982.       deactivate
  983.       call_ok_handler
  984.     else
  985.       if @item_sold_out == true
  986.         $game_system.shop_spose = 4
  987.       elsif @max_items_reached == false
  988.         $game_system.shop_spose = 0
  989.       else
  990.         $game_system.shop_spose = 2
  991.       end
  992.       Sound.play_buzzer
  993.     end
  994.   end
  995.   
  996.   include Shop_Stock
  997.   
  998. end # class Window_ShopBuy < Window_Selectable


  999. class Window_ShopSell < Window_ItemList
  1000.   def col_max
  1001.     return 1
  1002.   end
  1003.   
  1004.   def process_ok
  1005.     if current_item_enabled?
  1006.       Sound.play_ok
  1007.       Input.update
  1008.       deactivate
  1009.       call_ok_handler
  1010.     else
  1011.       $game_system.shop_spose = 1
  1012.       Sound.play_buzzer
  1013.     end
  1014.   end
  1015.   
  1016.   def status_window=(status_window)
  1017.     @status_window = status_window
  1018.   end

  1019.   def update_help
  1020.     @help_window.set_item(item) if @help_window
  1021.     @status_window.item = item if @status_window
  1022.   end
  1023. end # Window_ShopSell < Window_ItemList


  1024. class Window_ItemDesc < Window_Base
  1025.   def initialize(x, y, width, height)
  1026.     super(x, y, width, height)
  1027.     @item = nil
  1028.     @shop_type = 0
  1029.   end
  1030.   
  1031.   def refresh(item,type)
  1032.     @item = item
  1033.     contents.clear
  1034.     return if item.nil?
  1035.     @shop_type = type
  1036.     draw_item_name(@item, 0, 0)
  1037.     draw_currency_value(get_price, Vocab::currency_unit, 0, 0, contents.width)
  1038.     equip_stats if @item.is_a?(RPG::EquipItem)
  1039.     item_stats if @item.is_a?(RPG::Item)
  1040.   end
  1041.   
  1042.   def get_price
  1043.     if @shop_type == 0
  1044.       return @item.price
  1045.     else
  1046.       if $game_variables[Galv_Shopkeeper::SALE_VAR] > 0
  1047.         return ((@item.price * 0.01) * $game_variables[Galv_Shopkeeper::SALE_VAR]).round
  1048.       else
  1049.         return @item.price / 2
  1050.       end
  1051.     end
  1052.   end

  1053.   def stat_col
  1054.     contents.width / 2
  1055.   end
  1056.   
  1057.   def equip_stats
  1058.     y_offset = -15
  1059.     draw_equip_stats(0, line_height * 2 + y_offset, 0)           # HP
  1060.     draw_equip_stats(stat_col, line_height * 2 + y_offset, 1)    # MP
  1061.     draw_equip_stats(0, line_height * 3 + y_offset, 2)           # ATK
  1062.     draw_equip_stats(stat_col, line_height * 3 + y_offset, 3)    # DEF
  1063.     draw_equip_stats(0, line_height * 4 + y_offset, 4)           # MAT
  1064.     draw_equip_stats(stat_col, line_height * 4 + y_offset, 5)    # MDF
  1065.     draw_equip_stats(0, line_height * 5 + y_offset, 6)           # AGI
  1066.     draw_equip_stats(stat_col, line_height * 5 + y_offset, 7)    # LUK
  1067.     draw_icons(100, line_height * 6 , width = 96)                # States
  1068.   end
  1069.   
  1070.   def item=(item)
  1071.     @item = item
  1072.     refresh
  1073.   end
  1074.   
  1075.   def draw_equip_stats(x, y, param_id)
  1076.     draw_param_name(x + 4, y, param_id)
  1077.     draw_param(x + 94, y, param_id)
  1078.   end
  1079.   
  1080.   def draw_icons(x, y, width = 96)
  1081.     icons = []  # atk
  1082.     icons2 = [] # resistances
  1083.     @item.features.each do |f|
  1084.       if f.code == 32
  1085.         icons << $data_states[f.data_id].icon_index
  1086.       elsif f.code == 14
  1087.         icons2 << $data_states[f.data_id].icon_index
  1088.       end
  1089.     end
  1090.     if icons != []
  1091.       change_color(system_color)
  1092.       draw_text(0, line_height * 6, 120, line_height, "Inflicts")
  1093.       change_color(normal_color)
  1094.       icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
  1095.     elsif icons2 != []
  1096.       change_color(system_color)
  1097.       draw_text(0, line_height * 6, 120, line_height, "Resists")
  1098.       change_color(normal_color)
  1099.       icons2.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
  1100.     end
  1101.   end

  1102.   def draw_param_name(x, y, param_id)
  1103.     change_color(system_color)
  1104.     draw_text(x, y, 80, line_height, Vocab::param(param_id))
  1105.   end
  1106.   
  1107.   def draw_param(x, y, param_id)
  1108.     if @item.params[param_id] > 0
  1109.       change_color(power_up_color)
  1110.     elsif @item.params[param_id] < 0
  1111.       change_color(power_down_color)
  1112.     else
  1113.       change_color(normal_color)
  1114.     end
  1115.     draw_text(x, y, 32, line_height, @item.params[param_id].to_s, 2)
  1116.    
  1117.   end

  1118.   def item_stats
  1119.     x = 0
  1120.     y = 0
  1121.     line = 1
  1122.     y_offset = 15
  1123.     width = contents.width
  1124.     rem_states = []
  1125.     add_states = []
  1126.     add_buffs = []
  1127.     rem_buffs = []
  1128.    
  1129.     if @item.damage.type != 0
  1130.       change_color(system_color)
  1131.       case @item.damage.type
  1132.       when 1; vocab = Vocab::hp_a + " Damage"
  1133.       when 2; vocab = Vocab::mp_a + " Damage"
  1134.       when 3; vocab = Vocab::hp_a + " Restore"
  1135.       when 4; vocab = Vocab::mp_a + " Restore"
  1136.       when 5; vocab = Vocab::hp_a + " Drain"
  1137.       when 6; vocab = Vocab::mp_a + " Drain"
  1138.       end
  1139.       draw_text(0, line_height * line + y_offset, width, line_height, vocab, 0)
  1140.       change_color(normal_color)
  1141.       draw_text(0, line_height * line + y_offset, width, line_height, @item.damage.formula.to_s, 2)
  1142.       line += 1
  1143.     end
  1144.    
  1145.     @item.effects.each do |e|
  1146.       next if line == 6
  1147.       change_color(system_color)
  1148.       case e.code
  1149.       when 11; vocab = Vocab::hp_a; vocab2 = Vocab::hp
  1150.       when 12; vocab = Vocab::mp_a; vocab2 = Vocab::mp
  1151.       when 13; vocab = Vocab::tp_a; vocab2 = Vocab::tp
  1152.       end
  1153.       
  1154.       case e.code
  1155.       when 11, 12
  1156.         draw_text(0, line_height * line + y_offset, width, line_height, vocab + " (" + vocab2 + ")", 0)
  1157.         v1 = (e.value1 * 100).to_i
  1158.         v2 = e.value2.to_i
  1159.         if e.value1 == 0
  1160.           check_color(v2)
  1161.           draw_text(0, line_height * line + y_offset, width, line_height, v2.to_s, 2)
  1162.         elsif e.value2 == 0
  1163.           check_color(v1)
  1164.           draw_text(0, line_height * line + y_offset, width, line_height, v1.to_s + "%", 2)
  1165.         else
  1166.           check_color(v1)
  1167.           draw_text(0, line_height * line + y_offset, width, line_height, v2.to_s + " + " + v1.to_s + "%", 2)
  1168.         end
  1169.         line += 1
  1170.       when 13
  1171.         draw_text(0, line_height * line + y_offset, width, line_height, vocab + " (" + vocab2 + ")", 0)
  1172.         check_color(e.value1)
  1173.         draw_text(0, line_height * line + y_offset, width, line_height, e.value1.to_i.to_s + "%", 2)
  1174.         line += 1
  1175.       when 21
  1176.         #add state
  1177.         add_states << e.data_id unless e.data_id == 0
  1178.       when 22
  1179.         #remove state
  1180.         rem_states << e.data_id unless e.data_id == 0
  1181.       when 31, 32
  1182.         #add buff/debuffs
  1183.         add_buffs << (64 + e.data_id) if e.code == 31
  1184.         add_buffs << (64 + e.data_id + 16) if e.code == 32
  1185.       when 33, 34
  1186.         rem_buffs << (64 + e.data_id) if e.code == 33
  1187.         rem_buffs << (64 + e.data_id + 16) if e.code == 34
  1188.       when 42
  1189.         #grow stat
  1190.         change_color(system_color)
  1191.         name = $data_system.terms.params[e.data_id] + " Increase"
  1192.         draw_text(0, line_height * line + y_offset, width, line_height, name, 0)
  1193.         change_color(normal_color)
  1194.         draw_text(0, line_height * line + y_offset, width, line_height, e.value1.to_i.to_s, 2)
  1195.         line += 1
  1196.       when 43
  1197.         #learn skill
  1198.         change_color(system_color)
  1199.         skill = $data_skills[e.data_id].name
  1200.         draw_text(0, line_height * line + y_offset, width, line_height, "Learn", 0)
  1201.         change_color(normal_color)
  1202.         draw_text(0, line_height * line + y_offset, width, line_height, skill, 2)
  1203.         line += 1
  1204.       end
  1205.     end
  1206.    
  1207.     if add_states != [] && line < 6 || add_buffs != [] && line < 6
  1208.       x = 90
  1209.       icons = []
  1210.       add_states.each do |s|
  1211.         icons << $data_states[s].icon_index
  1212.       end
  1213.       add_buffs.each do |b|
  1214.         icons << b
  1215.       end
  1216.       change_color(system_color)
  1217.       draw_text(0, line_height * line + y_offset, width, line_height, "Applies")
  1218.       change_color(normal_color)
  1219.       icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, line_height * line + y_offset) }
  1220.       line += 1
  1221.     end
  1222.    
  1223.     if rem_states != [] && line < 6 || rem_buffs != [] && line < 6
  1224.       x = 90
  1225.       icons2 = []
  1226.       rem_states.each do |s|
  1227.         icons2 << $data_states[s].icon_index
  1228.       end
  1229.       rem_buffs.each do |b|
  1230.         icons2 << b
  1231.       end
  1232.       change_color(system_color)
  1233.       draw_text(0, line_height * line + y_offset, width, line_height, "Removes")
  1234.       change_color(normal_color)
  1235.       icons2.each_with_index {|n, i| draw_icon(n, x + 24 * i, line_height * line + y_offset) }
  1236.       line += 1
  1237.     end
  1238.   end
  1239.   
  1240.   def check_color(amount)
  1241.     if amount < 0
  1242.       change_color(power_down_color)
  1243.     else
  1244.       change_color(normal_color)
  1245.     end
  1246.   end
  1247. end # Window_ItemDesc < Window_Base


  1248. class Window_Base < Window
  1249.   alias galv_shopkeeper_windowbase_initialize initialize
  1250.   def initialize(x, y, width, height)
  1251.     galv_shopkeeper_windowbase_initialize(x, y, width, height)
  1252.     if SceneManager.scene_is?(Scene_Shop)
  1253.       self.windowskin = Cache.system($game_system.shop_windowskin)
  1254.     end
  1255.   end
  1256. end # Window_Base < Window


  1257. class RPG::Class
  1258.   def primary_params
  1259.     if @primary_params.nil?
  1260.       if @note =~ /<primary_params:[ ](.*),(.*)>/i
  1261.         @primary_params = [$1.to_i,$2.to_i]
  1262.       else
  1263.         @primary_params = [2,3]
  1264.       end
  1265.     end
  1266.     @primary_params
  1267.   end
  1268. end # RPG::Class


  1269. #------------------------------------------------------------------------------#
  1270. #  COMPATABILITY PATCH FOR YANFLY'S EQUIP DYNAMIC STATS SCRIPT
  1271. #------------------------------------------------------------------------------#
  1272. #  If you don't use this script from Yanfly, you can remove this.              #
  1273. #------------------------------------------------------------------------------#

  1274. if $imported["YEA-EquipDynamicStats"]
  1275.   class Window_ShopStatus < Window_Base
  1276.     def draw_actor_param_change(x, y, actor, item1)
  1277.       rect = Rect.new(x, y, 40, line_height)
  1278.       change = actor_param_change_value(actor, item1)
  1279.       change_color(param_change_color(change))
  1280.       text = change.group
  1281.       text = "+" + text if change >= 0
  1282.       draw_text(rect, sprintf("%+d", change), 1)
  1283.     end
  1284.   end # Window_ShopStatus

  1285.   class Window_ItemDesc < Window_Base
  1286.     def draw_equip_stats(x, y, param_id)
  1287.       draw_param_name(x + 4, y, param_id)
  1288.       draw_param(x + 30, y, param_id)
  1289.     end
  1290.    
  1291.     def draw_param(x, y, param_id)
  1292.       a = @item.params[param_id] + $game_variables[@item.var_params[param_id]]
  1293.       b = @item.per_params[param_id]
  1294.       if a > 0 || b > 0; change_color(power_up_color)
  1295.       elsif a < 0 || b < 0; change_color(power_down_color)
  1296.       else; change_color(normal_color); end
  1297.       a != 0 && b != 0 ? plus = "+" : plus = ""
  1298.       if b != 0; perc = "%"; b = (b *= 100).to_i.to_s; else; perc = ""; b = ""; end
  1299.       if b == "" && a == 0; a = 0; elsif b != "" && a == 0; a = ""; end
  1300.       draw_text(x, y, 100, line_height, a.to_s + plus + b.to_s + perc, 2)
  1301.     end
  1302.   end # Window_ItemDesc < Window_Base
  1303. end
复制代码
  1. =begin
  2. #===============================================================================
  3. Title: Shop Manager
  4. Author: Hime
  5. Date: Aug 4, 2014
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. 2.3 Aug 4, 2014
  9.    - added shop ID's
  10. 2.2 Apr 9, 2014
  11.    - fixed bug where calling a common event causes all shops to call wrong shop
  12. 2.1 Apr 1, 2014
  13.    - fixed bug where game crashes after loading from an event save
  14. 2.0 Mar 12, 2014
  15.    - added support for custom sell prices for each shop
  16. 1.9 Dec 2, 2013
  17.    - fixed bug where shop common event ID was not cleared out properly
  18. 1.81 Nov 21, 2013
  19.    - game shops are initialized on game load if necessary
  20. 1.8 Nov 20, 2013
  21.    - Game_ShopGood formulas are evaluated in the context of the interpreter
  22. 1.7 Oct 24, 2013
  23.    - added `add_shop_good` script call to add shop goods programmatically
  24.    - added "price formulas" to specify a good's price using a formula
  25. 1.6 Oct 15, 2013
  26.    - removed page refreshing. It doesn't work.
  27. 1.5 Mar 29, 2013
  28.    - added simple shop refreshing on page change. Will need a better solution
  29.      since this does not track the state of a shop on a different page
  30. 1.4 Mar 13, 2013
  31.    - fixed bug where common event shops were not handled appropriately when
  32.      called through effects
  33. 1.3 Mar 1, 2013
  34.    - Game_ShopGood now determines whether it should be included or enabled
  35.    - Two shop options implemented: hidden, disabled
  36. 1.2 Feb 25
  37.    - fixed issue where common event shops were not handled correctly
  38.    - exposed Shop Good variables as readers
  39. 1.1
  40.    - ShopManager handles shop scene changing depending on the type of shop
  41.    - added handling for different "types" of shops
  42.    - all goods in a shop can be accessed via shop.shop_goods
  43.    - reference to shop added to shop scene
  44.    - added support for adding and removing goods from a shop
  45. 1.0 Feb 22, 2013
  46.    - Initial Release
  47. --------------------------------------------------------------------------------   
  48. ** Terms of Use
  49. * Free to use in non-commercial projects
  50. * Contact me for commercial use
  51. * No real support. The script is provided as-is
  52. * Will do bug fixes, but no compatibility patches
  53. * Features may be requested but no guarantees, especially if it is non-trivial
  54. * Credits to Hime Works in your project
  55. * Preserve this header
  56. --------------------------------------------------------------------------------
  57. ** Description

  58. This script enhances the game shop, providing useful options that allow you
  59. to customize each shop good individually.

  60. This script provides functionality for remembering a shop’s “state”. Each
  61. shop is uniquely identified by a shop ID, and if you visit the same shop
  62. repeatedly, you should see the same settings.

  63. For example, if a shop holds 10 potions, and you bought 5, then you can
  64. expect that the next time you visit the shop, it will only have 5 potions
  65. remaining.

  66. Of course, you will need extra plugins to have that kind of functionality.

  67. In summary:
  68.    -more control over your shops
  69.    -simple API for developers to write shop-related scripts

  70. --------------------------------------------------------------------------------
  71. ** Usage

  72. This script provides a number of built-in shop options for you to customize your shop goods for each shop.

  73. Each shop option requires you to pass in a “good ID”, which is basically the order that the items appear in your “shop processing” list. The shop good at the top of the list has a good ID of 1, the next has a good ID of 2, and so on.

  74. All shop options must be set before the shop processing command.

  75. The following variables are available for all formulas:

  76.    v - game variables
  77.    s - game switches
  78.    p - game party

  79. -- Hiding Goods --

  80. You can prevent a shop good from appear in the shop list by using a
  81. “hide formula”. To set a hide formula for a particular good, use the
  82. script call

  83.     hide_good(good_id, hide_formula)

  84. -- Disabling Goods --

  85. Disabling a shop good means the player can’t buy it, but it will still appear
  86. on the list. The default windows simply change the color of the good to
  87. indicate that it can’t be selected. You can disable a shop good using a
  88. “disable formula”, and can be set using the script call

  89.     disable_good(good_id, hide_formula)

  90. -- Price Formulas --

  91. Each shop good can have a custom price by defining a “price formula”. The
  92. price is evaluated when the player visits the shop, so it is dynamically
  93. generated based on the current game state.

  94. To set a price formula, use the script call

  95.     price_good(good_id, price_formula)
  96.    
  97. -- Selling price formulas --

  98. You can specify the selling price of all items for a particular shop.
  99. To set the selling price, use the script call

  100.     sell_price(item_string, price_formula)
  101.    
  102. The item string uses the following format:

  103.     i2 - item ID 2
  104.     w4 - weapon ID 4
  105.     a12 - armor ID 12
  106.    
  107. If the sell price is not specified, then it is assumed to be half the
  108. buy price.

  109. --------------------------------------------------------------------------------
  110. ** Developers

  111. Here are some specifications that I have written.

  112. Have a look through each class to see what is available for use.
  113. If you have any suggestions that will improve the base script (ie: this),
  114. I will consider adding them.

  115. -- Shop Manager --

  116. This module serves are the interface for all shop-related queries. It handles
  117. how shops are stored for you so that it is easy to properly obtain a reference
  118. to a shop.

  119. You should use the Shop Manager whenever possible.

  120. -- Game Shop --

  121. This script treats a shop as a concrete object. A shop is created the first
  122. time it is accessed, and will be stored with the game for the remainder of
  123. the game.

  124. A very basic shop is provided, which manages what items are available for sale.
  125. All shops are stored in a global Game_Shops hash in $game_shops

  126. -- Shop Type --

  127. On top of the basic Game_Shop class, you can define your own shops and
  128. associate them with custom scenes specific to those shops.

  129. The Shop Manager only requires you to be consistent with your shop name.
  130. For example, if your shop type is "CraftShop", then you must define a

  131.    Game_CraftShop  - the shop object that the shop will be instantiated with
  132.    Scene_CraftShop - the scene that will be called when visiting a CraftShop
  133.    
  134. Users will set a @shop_type attribute in Game_Interpreter to determine
  135. what type of shop should be created

  136. -- Managing shops --

  137. This script assumes shops are only called through events or common events.
  138. Troop events are not supported.

  139. A shop is identified by a map ID and an event ID.
  140. Shops that are called via common events will have a map ID of 0.

  141. In order to determine whether a normal event or a common event called the
  142. shop, the "depth" of the interpreter is used.

  143.     When depth = 0, then it is a normal event
  144.     When depth > 0, then it is a common event
  145.    
  146. The shop processing should be handled appropriately depending on the depth

  147. This script assumes that an event is triggered through "normal" interaction;
  148. that is, you can only interact with events within a map. Any events that should
  149. be treated as the same event should be done as a common event call.

  150. --- Shop Goods ---

  151. Rather than storing all goods as a simple array of values, this script
  152. provides a Game_ShopGood class. You can use this to store any additional
  153. information that you want.

  154. All shop related scenes and windows MUST provide support for handling shop
  155. goods. While backwards compatibility is provided for the default scripts,
  156. additional methods have been defined to allow you to retrieve the currently
  157. selected shop good.

  158. --- Shop Options ---

  159. Since there isn't actually a way to setup individual shop goods, external
  160. approaches must be used. There is not much specification here yet, so it
  161. is up to you how you wish to populate your ShopGood objects. I have provided
  162. a "setup_goods" method in Game_Interpreter that you can alias.

  163. --------------------------------------------------------------------------------
  164. ** Compatibility

  165. This script changes the following from the default scripts

  166.    DataManager
  167.      aliased  - create_game_objects   
  168.      aliased  - make_save_contents
  169.      aliased  - extract_save_contents
  170.    Game_Interpreter
  171.      replaced - command_302
  172.    Window_ShopBuy
  173.      replaced - prepare
  174.    Scene_Shop
  175.      replaced - make_item_list
  176. #===============================================================================
  177. =end
  178. $imported = {} if $imported.nil?
  179. $imported["TH_ShopManager"] = 2.4
  180. #===============================================================================
  181. # ** Rest of the Script
  182. #===============================================================================
  183. #-------------------------------------------------------------------------------
  184. # Main shop manager that acts as the interface between shops and other objects
  185. # The main role of the ShopManager is to essentially manage any shop objects
  186. # that exist in the game. In particular, it provides all of the methods for
  187. # creating, retrieving, and deleting shops.
  188. #-------------------------------------------------------------------------------
  189. module ShopManager
  190.   
  191.   #-----------------------------------------------------------------------------
  192.   # Return a reference to a specific shop
  193.   #-----------------------------------------------------------------------------
  194.   def self.get_shop(shop_id)
  195.     return $game_shops[shop_id]
  196.   end
  197.   
  198.   #-----------------------------------------------------------------------------
  199.   # Indicate that a shop needs to be refreshed
  200.   #-----------------------------------------------------------------------------
  201.   def self.refresh_shop(shop_id)
  202.     shop = get_shop(shop_id)
  203.     shop.need_refresh = true if shop
  204.   end
  205.   
  206.   #-----------------------------------------------------------------------------
  207.   # Setup shop if first time visiting
  208.   #-----------------------------------------------------------------------------
  209.   def self.setup_shop(shop_id, goods, purchase_only, shop_type)
  210.     shop = get_shop(shop_id)
  211.     return shop if shop && !shop.need_refresh
  212.     shop = shop_class(shop_type).new(goods, purchase_only)
  213.     $game_shops[shop_id] = shop
  214.     return shop
  215.   end
  216.   
  217.   #-----------------------------------------------------------------------------
  218.   # Return the appropriate shop class given the shop type
  219.   #-----------------------------------------------------------------------------
  220.   def self.shop_class(shop_type)
  221.     shop_type = "Game_" + shop_type.to_s
  222.     return Object.const_get(shop_type.to_sym)
  223.   end
  224.   
  225.   #-----------------------------------------------------------------------------
  226.   # Return the scene associated with this shop.
  227.   # TO DO
  228.   #-----------------------------------------------------------------------------
  229.   def self.shop_scene(shop)
  230.     shop_scene = "Scene_" + shop.class.name.gsub("Game_", "")
  231.     return Object.const_get(shop_scene.to_sym)
  232.   end
  233.   
  234.   #-----------------------------------------------------------------------------
  235.   # Invokes SceneManager.call on the appropriate scene
  236.   #-----------------------------------------------------------------------------
  237.   def self.call_scene(shop)
  238.     SceneManager.call(shop_scene(shop))
  239.     SceneManager.scene.prepare(shop)
  240.   end
  241.   
  242.   #-----------------------------------------------------------------------------
  243.   # Invokes SceneManager.goto on the appropriate scene
  244.   #-----------------------------------------------------------------------------
  245.   def self.goto_scene(shop)
  246.     SceneManager.goto(shop_scene(shop))
  247.     SceneManager.scene.prepare(shop)
  248.   end
  249.   
  250.   #-----------------------------------------------------------------------------
  251.   # Returns a good ID, given a shop and an item. If the item is already in
  252.   # the shop, it will return that good's ID. Otherwise, it will return a new ID
  253.   #-----------------------------------------------------------------------------
  254.   def self.get_good_id(shop, item)
  255.     good = shop.shop_goods.detect {|good| good.item == item}
  256.     return good.nil? ? shop.shop_goods.size + 1 : good.id
  257.   end
  258.   
  259.   #-----------------------------------------------------------------------------
  260.   # Returns a good, given a shop and an item. If the shop already has that good
  261.   # just return it. Otherwise, make a new good. If the price is negative, then
  262.   # the price is the default price. Otherwise, it is the specified price.
  263.   #-----------------------------------------------------------------------------
  264.   def self.get_good(shop, item, price=-1)
  265.     good = shop.shop_goods.detect {|good| good.item == item}
  266.     return good if good
  267.     good_id = shop.shop_goods.size + 1
  268.     type = item_type(item)
  269.     if price < 0
  270.       price_type = price = 0
  271.     else
  272.       price_type = 1
  273.     end
  274.     return Game_ShopGood.new(good_id, type, item.id, price_type, price)
  275.   end
  276.   
  277.   #-----------------------------------------------------------------------------
  278.   # Returns the type of an item.
  279.   #-----------------------------------------------------------------------------
  280.   def self.item_type(item)
  281.     return 0 if item.is_a?(RPG::Item)
  282.     return 1 if item.is_a?(RPG::Weapon)
  283.     return 2 if item.is_a?(RPG::Armor)
  284.     return -1
  285.   end
  286. end

  287. #-------------------------------------------------------------------------------
  288. # Shops are stored in a global variable `$game_shops`. This is dumped and
  289. # loaded appropriately.
  290. #-------------------------------------------------------------------------------
  291. module DataManager
  292.   
  293.   class << self
  294.     alias :th_shop_manager_create_game_objects :create_game_objects
  295.     alias :th_shop_manager_make_save_contents :make_save_contents
  296.     alias :th_shop_manager_extract_save_contents :extract_save_contents
  297.   end
  298.   
  299.   def self.create_game_objects
  300.     th_shop_manager_create_game_objects
  301.     $game_shops = Game_Shops.new
  302.   end
  303.   
  304.   def self.make_save_contents
  305.     contents = th_shop_manager_make_save_contents
  306.     contents[:shops] = $game_shops
  307.     contents
  308.   end
  309.   
  310.   #-----------------------------------------------------------------------------
  311.   # Load shop data
  312.   #-----------------------------------------------------------------------------
  313.   def self.extract_save_contents(contents)
  314.     th_shop_manager_extract_save_contents(contents)
  315.     $game_shops = contents[:shops] || Game_Shops.new
  316.   end
  317. end

  318. class Game_Temp
  319.   
  320.   # even if we're not actually calling a shop, it shouldn't affect anything
  321.   # because we are always setting this at each common event call by an event
  322.   attr_accessor :shop_common_event_id
  323.   
  324.   alias :th_shop_manager_reserve_common_event :reserve_common_event
  325.   def reserve_common_event(common_event_id)
  326.     th_shop_manager_reserve_common_event(common_event_id)
  327.     @shop_common_event_id = common_event_id
  328.   end
  329.   
  330.   alias :th_shop_manager_clear_common_event :clear_common_event
  331.   def clear_common_event
  332.     th_shop_manager_clear_common_event
  333.     clear_shop_event_id
  334.   end
  335.   
  336.   def clear_shop_event_id
  337.     @shop_common_event_id = nil
  338.   end
  339. end

  340. class Game_Interpreter
  341.   
  342.   alias :th_shop_manager_initialize :initialize
  343.   def initialize(*args)
  344.     @shop_common_event_id = $game_temp.shop_common_event_id if $game_temp
  345.     th_shop_manager_initialize(*args)
  346.   end
  347.   
  348.   alias :th_shop_manager_clear :clear
  349.   def clear
  350.     th_shop_manager_clear
  351.     clear_shop_options
  352.     @custom_goods = {}
  353.     @shop_type = nil
  354.     @shop_id = nil
  355.   end
  356.   
  357.   def shop_options
  358.     return @shop_options if @shop_options
  359.     clear_shop_options
  360.     return @shop_options
  361.   end
  362.   
  363.   def custom_goods
  364.     @custom_goods ||= {}
  365.   end
  366.   
  367.   #-----------------------------------------------------------------------------
  368.   # New.
  369.   #-----------------------------------------------------------------------------
  370.   def clear_shop_options
  371.     @shop_options = {}
  372.     @shop_options[:hidden] = {}
  373.     @shop_options[:disabled] = {}
  374.     @shop_options[:price] = {}
  375.     @shop_options[:sell_price] = {}
  376.   end
  377.   
  378.   #-----------------------------------------------------------------------------
  379.   # New. We are in a common event only if the shop common event ID is set.
  380.   #-----------------------------------------------------------------------------
  381.   def shop_map_id
  382.     @shop_common_event_id ? 0 : @map_id
  383.   end
  384.   
  385.   def shop_event_id
  386.     @shop_common_event_id ? @shop_common_event_id : @event_id
  387.   end
  388.   
  389.   #-----------------------------------------------------------------------------
  390.   # Set the shop's common event ID so that the child interpreter can pick it
  391.   # up. Then clear it out
  392.   #-----------------------------------------------------------------------------
  393.   alias :th_shop_manager_command_117 :command_117
  394.   def command_117
  395.     $game_temp.shop_common_event_id = @params[0]
  396.     th_shop_manager_command_117
  397.     $game_temp.clear_shop_event_id
  398.   end
  399.   
  400.   #-----------------------------------------------------------------------------
  401.   # Replaced. A shop is setup only once, and is retrieved whenever it is
  402.   # called in the future. This assumes the shop is invoked through "normal"
  403.   # event interactions.
  404.   #-----------------------------------------------------------------------------
  405.   def command_302
  406.     return if $game_party.in_battle
  407.     shop_type = @shop_type || :Shop
  408.    
  409.     # load goods
  410.     goods = load_all_goods
  411.    
  412.     shop_id = @shop_id || [shop_map_id, shop_event_id]
  413.    
  414.     # Setup shop if needed
  415.     shop = ShopManager.setup_shop(shop_id, goods, @params[4], shop_type)
  416.     setup_shop(shop)
  417.    
  418.     # prepare the shop with a reference to the actual shop
  419.     ShopManager.call_scene(shop)
  420.     Fiber.yield
  421.   end
  422.   
  423.   def load_all_goods
  424.     good_id = 1
  425.     goods = []

  426.     # setup goods
  427.     good = make_good(@params[0..-1], good_id) # last param is for the shop
  428.     goods.push(good)
  429.     good_id +=1
  430.    
  431.     while next_event_code == 605
  432.       @index += 1
  433.       good = make_good(@list[@index].parameters, good_id)
  434.       goods.push(good)
  435.       good_id +=1
  436.     end

  437.     goods.concat(load_custom_goods)
  438.     return goods
  439.   end
  440.   
  441.   #-----------------------------------------------------------------------------
  442.   # Goods that should be added to the shop, but are not added through the
  443.   # shop editor (eg: script calls)
  444.   #-----------------------------------------------------------------------------
  445.   def load_custom_goods
  446.     goods = []
  447.     custom_goods.each do |id, goods_array|
  448.       good = make_good(goods_array, id)
  449.       goods.push(good)
  450.     end
  451.     return goods
  452.   end
  453.   
  454.   #-----------------------------------------------------------------------------
  455.   # New. This is where the goods are setup.
  456.   #-----------------------------------------------------------------------------
  457.   def make_good(goods_array, good_id)
  458.     item_type, item_id, price_type, price = goods_array
  459.     good = Game_ShopGood.new(good_id, item_type, item_id, price_type, price)
  460.    
  461.     # additional setup
  462.     setup_good(good, good_id)
  463.     return good
  464.   end
  465.   
  466.   #-----------------------------------------------------------------------------
  467.   # New. Adds a shop good to the list of goods. Note that you must check
  468.   # that ID of the shop good is unique. I will not generate an ID automatically
  469.   # because otherwise you'd have no way of applying shop options to it
  470.   #-----------------------------------------------------------------------------
  471.   def add_shop_good(good_id, item_type, item_id, price=nil)
  472.     if item_type == :item
  473.       item_type = 0
  474.     elsif item_type == :weapon
  475.       item_type = 1
  476.     elsif item_type == :armor
  477.       item_type = 2
  478.     end
  479.     price_type = price ? 1 : 0
  480.     custom_goods[good_id] = [item_type, item_id, price_type, price]
  481.   end
  482.   
  483.   def get_shop(id)
  484.     @shop_id = id
  485.   end
  486.   
  487.   def setup_shop(shop)
  488.     setup_sell_prices(shop)
  489.   end
  490.   
  491.   def setup_sell_prices(shop)
  492.     shop_options[:sell_price].each do |item_str, formula|
  493.       type, id = item_str[0].downcase, item_str[1..-1].to_i
  494.       case type
  495.       when "i"
  496.         item = $data_items[id]
  497.       when "w"
  498.         item = $data_weapons[id]
  499.       when "a"
  500.         item = $data_armors[id]
  501.       end
  502.       shop.set_sell_price(item, formula)
  503.     end
  504.   end
  505.   
  506.   #-----------------------------------------------------------------------------
  507.   # New. You can do more things with your good here
  508.   #-----------------------------------------------------------------------------
  509.   def setup_good(good, good_id)
  510.     setup_hidden_option(good, good_id)
  511.     setup_disabled_option(good, good_id)
  512.     setup_price_option(good, good_id)
  513.   end
  514.   
  515.   #-----------------------------------------------------------------------------
  516.   # New. Shop options
  517.   #-----------------------------------------------------------------------------
  518.   def price_good(good_id, price_formula)
  519.     shop_options[:price][good_id] = price_formula
  520.   end
  521.   
  522.   def hide_good(good_id, condition)
  523.     shop_options[:hidden][good_id] = condition
  524.   end
  525.   
  526.   def disable_good(good_id, condition)
  527.     shop_options[:disabled][good_id] = condition
  528.   end
  529.   
  530.   def sell_price(item_str, price_formula)
  531.     shop_options[:sell_price][item_str] = price_formula
  532.   end
  533.   
  534.   #-----------------------------------------------------------------------------
  535.   # New. Apply shop option to the goods
  536.   #-----------------------------------------------------------------------------  
  537.   def setup_hidden_option(good, good_id)
  538.     return unless shop_options[:hidden][good_id]
  539.     good.hidden_condition = shop_options[:hidden][good_id]
  540.   end
  541.   
  542.   def setup_disabled_option(good, good_id)
  543.     return unless shop_options[:disabled][good_id]
  544.     good.disable_condition = shop_options[:disabled][good_id]
  545.   end
  546.   
  547.   def setup_price_option(good, good_id)
  548.     return unless shop_options[:price][good_id]
  549.     good.price_formula = shop_options[:price][good_id].to_s
  550.   end
  551.   
  552.   def eval_shop_condition(formula, v=$game_variables, s=$game_switches, p=$game_party, t=$game_troop)
  553.     eval(formula)
  554.   end
  555. end

  556. #-------------------------------------------------------------------------------
  557. # A shop good.
  558. # This is a wrapper around a raw item (RPG::Item, RPG::Weapon, etc).
  559. #-------------------------------------------------------------------------------

  560. class Game_ShopGood
  561.   
  562.   attr_reader :id         # ID of this good
  563.   attr_reader :item_type
  564.   attr_reader :item_id
  565.   attr_reader :price_type
  566.   attr_accessor :hidden_condition
  567.   attr_accessor :disable_condition
  568.   attr_accessor :price_formula
  569.   
  570.   @@interpreter = Game_Interpreter.new
  571.   
  572.   def initialize(id, item_type, item_id, price_type, price)
  573.     @id = id
  574.     @item_type = item_type
  575.     @item_id = item_id
  576.     @price_type = price_type
  577.     @price = price
  578.     @hidden_condition = ""
  579.     @disable_condition = ""
  580.     @price_formula = ""
  581.   end
  582.   
  583.   #-----------------------------------------------------------------------------
  584.   # Determines whether the shop item should be included
  585.   #-----------------------------------------------------------------------------
  586.   def include?
  587.     return false if eval_shop_condition(@hidden_condition)
  588.     return true
  589.   end
  590.   
  591.   #-----------------------------------------------------------------------------
  592.   # Determines whether the shop item is enabled
  593.   #-----------------------------------------------------------------------------
  594.   def enable?
  595.     return false if eval_shop_condition(@disable_condition)
  596.     return true
  597.   end
  598.   
  599.   #-----------------------------------------------------------------------------
  600.   # Returns the appropriate object based on the item type. This implementation
  601.   # is limited because it assumes you are pulling objects from the database.
  602.   # Currently designed for compatibility with default implementation
  603.   #-----------------------------------------------------------------------------
  604.   def item
  605.     return $data_items[@item_id] if @item_type == 0
  606.     return $data_weapons[@item_id] if @item_type == 1
  607.     return $data_armors[@item_id] if @item_type == 2
  608.   end
  609.   
  610.   #-----------------------------------------------------------------------------
  611.   # Returns the price of the shop good.
  612.   #-----------------------------------------------------------------------------
  613.   def price
  614.     return eval_shop_condition(@price_formula) unless @price_formula.empty?
  615.     return item.price if @price_type == 0
  616.     return @price
  617.   end
  618.   
  619.   #-----------------------------------------------------------------------------
  620.   # Any shop formula that needs to be evaluated goes through here
  621.   #-----------------------------------------------------------------------------
  622.   def eval_shop_condition(formula)
  623.     @@interpreter.eval_shop_condition(formula)
  624.   end
  625. end

  626. #-------------------------------------------------------------------------------
  627. # A shop object. Stores information about the shop such as its inventory
  628. # and other shop-related data
  629. #-------------------------------------------------------------------------------
  630. class Game_Shop
  631.   attr_reader   :purchase_only
  632.   attr_reader   :shop_goods      # all goods that this shop has.
  633.   attr_accessor :need_refresh  # shop needs to be refreshed
  634.   attr_accessor :sell_prices
  635.   
  636.   @@interpreter = Game_Interpreter.new
  637.   
  638.   def initialize(goods, purchase_only=false)
  639.     @shop_goods = goods
  640.     @purchase_only = purchase_only
  641.     @need_refresh = false
  642.     setup_sell_prices
  643.   end
  644.   
  645.   def setup_sell_prices
  646.     @items = {}
  647.     @weapons = {}
  648.     @armors = {}
  649.   end
  650.   
  651.   #-----------------------------------------------------------------------------
  652.   # Returns true if the goods should be included
  653.   #-----------------------------------------------------------------------------
  654.   def include?(index)
  655.     true
  656.   end
  657.   
  658.   #-----------------------------------------------------------------------------
  659.   # Return a set of goods for sale
  660.   #-----------------------------------------------------------------------------
  661.   def goods
  662.     @shop_goods
  663.   end
  664.   
  665.   #-----------------------------------------------------------------------------
  666.   # Add a new good to the shop
  667.   #-----------------------------------------------------------------------------
  668.   def add_good(good)
  669.     @shop_goods.push(good) unless @shop_goods.include?(good)
  670.   end
  671.   
  672.   #-----------------------------------------------------------------------------
  673.   # Remove the specified good from the shop
  674.   #-----------------------------------------------------------------------------
  675.   def remove_good(good_id)
  676.     @shop_goods.delete_at(good_id - 1)
  677.   end
  678.   
  679.   def item_container(item)
  680.     return @weapons if item.is_a?(RPG::Weapon)
  681.     return @armors if item.is_a?(RPG::Armor)
  682.     return @items if item.is_a?(RPG::Item)
  683.   end
  684.   
  685.   def set_sell_price(item, price_formula)
  686.     container = item_container(item)
  687.     container[item.id] = price_formula
  688.   end
  689.   
  690.   def sell_price(item)
  691.     container = item_container(item)
  692.     if container.include?(item.id)
  693.       return @@interpreter.eval_shop_condition(container[item.id])
  694.     else
  695.       return 0
  696.     end
  697.   end
  698. end

  699. #-------------------------------------------------------------------------------
  700. # A wrapper containing all shops in the game.
  701. #-------------------------------------------------------------------------------
  702. class Game_Shops
  703.   
  704.   #-----------------------------------------------------------------------------
  705.   # Initializes a hash of game shops. Each key is a map ID, pointing to another
  706.   # hash whose keys are event ID's and values are Game_Shop objects.
  707.   #-----------------------------------------------------------------------------
  708.   def initialize
  709.     @data = {}
  710.   end
  711.   
  712.   def [](id)
  713.     @data[id]
  714.   end
  715.   
  716.   def []=(id, shop)
  717.     @data[id] = shop
  718.   end
  719. end

  720. #-------------------------------------------------------------------------------
  721. # The shop scene now works with the Shop and ShopGood objects
  722. #-------------------------------------------------------------------------------
  723. class Scene_Shop < Scene_MenuBase
  724.   #--------------------------------------------------------------------------
  725.   # Replaced. The scene now takes a Game_Shop object
  726.   #--------------------------------------------------------------------------
  727.   def prepare(shop)
  728.     @shop = shop
  729.     @goods = shop.goods
  730.     @purchase_only = shop.purchase_only
  731.   end
  732.   
  733.   alias :th_shop_manager_on_buy_ok :on_buy_ok
  734.   def on_buy_ok
  735.     @selected_good = @buy_window.current_good
  736.     th_shop_manager_on_buy_ok
  737.   end
  738.   
  739.   #-----------------------------------------------------------------------------
  740.   #
  741.   #-----------------------------------------------------------------------------
  742.   alias :th_shop_manager_selling_price :selling_price
  743.   def selling_price
  744.     price = @shop.sell_price(@sell_window.item)
  745.     if price != 0
  746.       return price
  747.     else
  748.       return th_shop_manager_selling_price
  749.     end
  750.   end
  751. end

  752. #-------------------------------------------------------------------------------
  753. # @shop_goods is now an array of Game_ShopGoods
  754. #-------------------------------------------------------------------------------
  755. class Window_ShopBuy < Window_Selectable
  756.    
  757.   #--------------------------------------------------------------------------
  758.   # New. Returns true if the good should be included in the shop inventory
  759.   #--------------------------------------------------------------------------
  760.   def include?(shopGood)
  761.     shopGood.include?
  762.   end
  763.   
  764.   alias :th_shop_manager_enable? :enable?
  765.   def enable?(item)
  766.     return false unless @goods[item].enable?
  767.     th_shop_manager_enable?(item)
  768.   end
  769.   
  770.   #--------------------------------------------------------------------------
  771.   # New. Get the currently selected good
  772.   #--------------------------------------------------------------------------
  773.   def current_good
  774.     @goods[item]
  775.   end
  776.   
  777.   #-----------------------------------------------------------------------------
  778.   # Replaced. ShopGood takes care of most information. The data still contains
  779.   # a list of RPG items for now since I don't want to change them to goods yet
  780.   # A separate list of goods for sale is used for 1-1 correspondence
  781.   #-----------------------------------------------------------------------------
  782.   def make_item_list
  783.     @data = []
  784.     @goods = {}
  785.     @price = {}
  786.     @shop_goods.each do |shopGood|
  787.       next unless include?(shopGood)
  788.       item = shopGood.item
  789.       @data.push(item)
  790.       @goods[item] = shopGood
  791.       @price[item] = shopGood.price
  792.     end
  793.   end
  794. end
复制代码

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

2
发表于 2017-12-24 13:59:23 | 只看该作者
  1. class Scene_Shop < Scene_MenuBase

  2.   #--------------------------------------------------------------------------
  3.   # ● 获取卖出价格
  4.   #--------------------------------------------------------------------------
  5.   def selling_price
  6.     @item.price / 2
  7.   end
  8. end
复制代码

@item.price / 2是按物品買入價格的一半設定出售價格
把這裡改成其他的就可以了

点评

具体就是比如在某地x,a商品稀少所以a的出手价格为2倍,b商品比较多,出售价格为0.25,而到了地点y,商品a比较多,出手价格为0.5,b比较少,出售1.5  发表于 2017-12-24 14:10
不是这个,我的意思是每个商店里面卖的商品的价格都不一样。因为我做的是类似与跑商那样的  发表于 2017-12-24 14:03
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
发表于 2017-12-24 14:46:18 | 只看该作者
買入價格是
  1.   #--------------------------------------------------------------------------
  2.   # ● 获取买入价格
  3.   #--------------------------------------------------------------------------
  4.   def buying_price
  5.     @buy_window.price(@item)
  6.   end
复制代码

你自己又不貼你自己用的腳本,那我就只能按默認的發給你

点评

我用的商店已发,就是galvs的shop  发表于 2017-12-24 17:33
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

4
发表于 2017-12-24 17:50:05 | 只看该作者
  1. # OVERWRITE
  2.   def selling_price
  3.     if $game_variables[Galv_Shopkeeper::SALE_VAR] > 0
  4.       ((@item.price * 0.01) * $game_variables[Galv_Shopkeeper::SALE_VAR]).round
  5.     else
  6.       @item.price / 2
  7.     end
  8.   end
复制代码

這裡是其中一個,搜索這個腳本裏所有的price和Galv_Shopkeeper::SALE_VAR
然後你自己看著改
@item.id可以獲取物品在數據庫中的編號,腳本編輯器裏有判斷@item是物品還是武器還是防具的用法

点评

是的,怎么做?  发表于 2017-12-24 20:06
你想隨時隨地改價格?那就用一個變量數組去指定  发表于 2017-12-24 19:55
大佬,不会改,原脚本没有设计事件调用的方法,不太会改。我想要做到像刚刚发的hime的脚本那样可以用事件调用。  发表于 2017-12-24 19:03
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-17 12:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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