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

Project1

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

[已经解决] 求VX物品合成脚本

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

跳转到指定楼层
1
发表于 2017-2-25 17:17:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  如题...

Lv1.梦旅人

梦石
0
星屑
60
在线时间
52 小时
注册时间
2017-1-12
帖子
192
2
发表于 2017-2-25 17:56:28 | 只看该作者
请善用搜索 - -
RUBY 代码复制
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 物品合成 - KGC_ComposeItem ◆ VX ◆
  3. #_/    ◇ Last update : 2008/01/25 ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/                     可制作合成物品。
  6. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  7.  
  8. #==============================================================================
  9. # ★ 定做項目 - Customize ★
  10. #==============================================================================
  11.  
  12. module KGC
  13. module ComposeItem
  14.   # ◆ 将合成画面调用的开关号码
  15.   #  把这个开关设定为 ON 的话,可代替通常的店铺并使用合成功能。
  16.   COMPOSE_CALL_SWITCH = 13
  17.  
  18.   # ◆ 合成物素材设定,通常格式:
  19.   #  ?费用,"物品类型:ID,个数",... ?
  20.   #  【 费用 】合成物品所需的费用
  21.   #  【 物品种类 】合成素材的种类  (I..物品  W..武器  A..防具)
  22.   #  【  ID  】合成素材的ID (↑要与以上相对应)
  23.   #  【 个数 】合成物品所需素材的数目
  24.   #  "物品种类:ID,個数" 。多个的时候也可以这样设定。
  25.   #  可省略数目。写成 "物品类型:ID" 。如果没写的话,将用默认设定个数为1。
  26.   #  如果把个数设定为0的话,持有1个以上时也可以合成,但是合成成功的话,将
  27.   #不会扣除所设定的物品。
  28.   #  按一下设定的排列,添加的顺序与物品?武器?防具的ID相对应。
  29.   RECIPE_ITEM   = []  # 物品
  30.   RECIPE_WEAPON = []  # 武器
  31.   RECIPE_ARMOR  = []  # 防具
  32.   # 从这里开始,自定义合成公式(找不到好的词)。
  33.   #  <例如>
  34.   #  物品ID为8的合成公式
  35.   #  物品ID 2, 4, 7 各消耗1个,免费合成。
  36.   RECIPE_ITEM[8] = [0, "I:2", "I:4", "I:7"]
  37.   #  武器ID:16 的合成公式
  38.   #  武器ID:10 消耗1个、物品ID:16 消耗 2 个,合成费用800 G。
  39.   RECIPE_WEAPON[16] = [800, "W:10", "I:16,2"]
  40.   RECIPE_WEAPON[1] = [0,"I:1,2"]
  41.  
  42.   # ◆ 合成指令名
  43.   #  可替代普通商店的购买指令。
  44.   #  ※ 想要修改指令名字的话,可在下面的[Vocab]后做修改。
  45.   VOCAB_COMPOSE_ITEM = "合成"
  46.   # ◆ 合成物品的信息转换按键
  47.   #  「所需材料 <=转换=> 角色能力值変化(为装备品时)」信息变换按键。
  48.   #  不使用的时候,请设定成 nil。
  49.   SWITCH_INFO_BUTTON = Input::X
  50.  
  51.   # ◆ 必要设定
  52.   #  当合成的材料为较多数时,请设定成 true。(其实就是合成素材的行距与字的大小)
  53.   COMPACT_MATERIAL_LIST = true
  54.   # ◆ 不显示命令窗口。
  55.   #  这与XP是相似的。
  56.   HIDE_COMMAND_WINDOW   = true
  57.   # ◆ 不显示所持金钱数
  58.   HIDE_GOLD_WINDOW      = false
  59.   # ◆ 当合成费用是0时, 不显示费用。
  60.   HIDE_ZERO_COST        = true
  61.  
  62.   # ◆ 不表示费用与素材不足的合成列表。
  63.   #  之前合成过的物品的显名表示。
  64.   HIDE_SHORTAGE_RECIPE     = false
  65.   # ◆ 没有合成的物品隐藏物品名字, true为隐藏。
  66.   MASK_UNKNOWN_RECIPE_NAME = true
  67.   # ◆ 没有合成过的物品在列表上的表示方法
  68.   #  以下设定隐藏名,当物品名字为多个时,按以下设定扩展名字。
  69.   UNKNOWN_NAME_MASK        = "?"
  70.   # ◆ 没有合成过的物品,隐藏帮助信息。
  71.   HIDE_UNKNOWN_RECIPE_HELP = true
  72.   # ◆ 没有合成过在物品在列表上的帮助 信息。
  73.   UNKNOWN_RECIPE_HELP      = "合成列表"
  74. end
  75. end
  76.  
  77. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  78.  
  79. $imported = {} if $imported == nil
  80. $imported["ComposeItem"] = true
  81.  
  82. module KGC::ComposeItem
  83.   # 定义正则表达式
  84.   module Regexp
  85.     # 合成列表
  86.     RECIPE = /([IWA])[ ]*:[ ]*(\d+)([ ]*,[ ]*\d+)?/i
  87.   end
  88. end
  89.  
  90. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  91.  
  92. #==============================================================================
  93. # ■ Vocab
  94. #==============================================================================
  95.  
  96. module Vocab
  97.   # 合成画面
  98.   ComposeItem = KGC::ComposeItem::VOCAB_COMPOSE_ITEM
  99. end
  100.  
  101. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  102.  
  103. #==============================================================================
  104. # ■ RPG::BaseItem
  105. #==============================================================================
  106.  
  107. class RPG::BaseItem
  108.   #--------------------------------------------------------------------------
  109.   # ○ 变量
  110.   #--------------------------------------------------------------------------
  111.   @@__masked_name =
  112.     KGC::ComposeItem::UNKNOWN_NAME_MASK  # 隐藏名
  113.   @@__expand_masked_name = false         # 隐藏名的扩展表示
  114.  
  115.   if @@__masked_name != nil
  116.     @@__expand_masked_name = (@@__masked_name.scan(/./).size == 1)
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ○ 物品合成费用
  120.   #--------------------------------------------------------------------------
  121.   def create_compose_item_cache
  122.     @__compose_cost = 0
  123.     @__compose_materials = []
  124.  
  125.     # 合成列表取得
  126.     recipe = nil
  127.     case self
  128.     when RPG::Item    # 物品
  129.       recipe = KGC::ComposeItem::RECIPE_ITEM[self.id]
  130.     when RPG::Weapon  # 武器
  131.       recipe = KGC::ComposeItem::RECIPE_WEAPON[self.id]
  132.     when RPG::Armor   # 防具
  133.       recipe = KGC::ComposeItem::RECIPE_ARMOR[self.id]
  134.     end
  135.     return if recipe == nil
  136.     recipe = recipe.dup
  137.  
  138.     @__compose_cost = recipe.shift
  139.     # 合成材料名单
  140.     recipe.each { |r|
  141.       if r =~ KGC::ComposeItem::Regexp::RECIPE
  142.         material = Game_ComposeMaterial.new
  143.         material.kind = $1.upcase                    # 取得材料的种类
  144.         material.id = $2.to_i                        # 取得材料的ID
  145.         if $3 != nil
  146.           material.number = [$3[/\d+/].to_i, 0].max  # 取得必要合成个数
  147.         end
  148.         @__compose_materials << material
  149.       end
  150.     }
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ○ 隐藏名
  154.   #--------------------------------------------------------------------------
  155.   def masked_name
  156.     if KGC::ComposeItem::MASK_UNKNOWN_RECIPE_NAME
  157.       if @@__expand_masked_name
  158.         # 隐藏名的扩展表示
  159.         return @@__masked_name * self.name.scan(/./).size
  160.       else
  161.         return @@__masked_name
  162.       end
  163.     else
  164.       return self.name
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # ○ 合成费用
  169.   #--------------------------------------------------------------------------
  170.   def compose_cost
  171.     create_compose_item_cache if @__compose_cost == nil
  172.     return @__compose_cost
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ○ 合成用材料名单
  176.   #--------------------------------------------------------------------------
  177.   def compose_materials
  178.     create_compose_item_cache if @__compose_materials == nil
  179.     return @__compose_materials
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # ○ 合成列表
  183.   #--------------------------------------------------------------------------
  184.   def is_compose?
  185.     return !compose_materials.empty?
  186.   end
  187. end
  188.  
  189. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  190.  
  191. #==============================================================================
  192. # ■ Game_Party
  193. #==============================================================================
  194.  
  195. class Game_Party < Game_Unit
  196.   #--------------------------------------------------------------------------
  197.   # ○ 合成済みフラグをクリア
  198.   #--------------------------------------------------------------------------
  199.   def clear_composed_flag
  200.     @item_composed = {}
  201.     @weapon_composed = {}
  202.     @armor_composed = {}
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ○ アイテムの合成済みフラグを設定
  206.   #     item : アイテム
  207.   #     flag : true..合成済み  false..未合成
  208.   #--------------------------------------------------------------------------
  209.   def set_item_composed(item, flag = true)
  210.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外
  211.     return false unless item.is_compose?           # 合成アイテム以外
  212.  
  213.     # 合成済みフラグを格納するハッシュを作成
  214.     clear_composed_flag if @item_composed == nil
  215.  
  216.     # 合成済みフラグをセット
  217.     case item
  218.     when RPG::Item    # アイテム
  219.       @item_composed[item.id] = flag
  220.     when RPG::Weapon  # 武器
  221.       @weapon_composed[item.id] = flag
  222.     when RPG::Armor   # 防具
  223.       @armor_composed[item.id] = flag
  224.     end
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ○ アイテムの合成済み判定
  228.   #     item : アイテム
  229.   #--------------------------------------------------------------------------
  230.   def item_composed?(item)
  231.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外
  232.     return false unless item.is_compose?           # 合成アイテム以外
  233.  
  234.     # 合成済みフラグを格納するハッシュを作成
  235.     clear_composed_flag if @item_composed == nil
  236.  
  237.     # 合成済み判定
  238.     case item
  239.     when RPG::Item    # アイテム
  240.       return @item_composed[item.id]
  241.     when RPG::Weapon  # 武器
  242.       return @weapon_composed[item.id]
  243.     when RPG::Armor   # 防具
  244.       return @armor_composed[item.id]
  245.     end
  246.     return false
  247.   end
  248.   #--------------------------------------------------------------------------
  249.   # ○ アイテムの合成可能判定
  250.   #     item : アイテム
  251.   #--------------------------------------------------------------------------
  252.   def item_can_compose?(item)
  253.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外は不可
  254.     return false unless item.is_compose?           # 合成アイテム以外は不可
  255.  
  256.     return false if gold < item.compose_cost       # 資金不足なら不可
  257.  
  258.     item.compose_materials.each { |material|
  259.       num = item_number(material.item)
  260.       # 素材不足なら不可
  261.       return false if num < material.number || num == 0
  262.     }
  263.     return true
  264.   end
  265.   #--------------------------------------------------------------------------
  266.   # ○ アイテムの合成可能数を取得
  267.   #     item : アイテム
  268.   #--------------------------------------------------------------------------
  269.   def number_of_composable(item)
  270.     return 0 unless item.is_a?(RPG::BaseItem)  # アイテム以外
  271.     return 0 unless item.is_compose?           # 合成アイテム以外
  272.  
  273.     number = ($imported["LimitBreak"] ? item.number_limit : 99)
  274.     if item.compose_cost > 0
  275.       number = [number, gold / item.compose_cost].min
  276.     end
  277.     # 素材数判定
  278.     item.compose_materials.each { |material|
  279.       next if material.number == 0  # 必要数 0 は無視
  280.       n = item_number(material.item) / material.number
  281.       number = [number, n].min
  282.     }
  283.     return number
  284.   end
  285. end
  286.  
  287. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  288.  
  289. #==============================================================================
  290. # □ Game_ComposeMaterial
  291. #------------------------------------------------------------------------------
  292. #   合成素材の情報を格納するクラスです。
  293. #==============================================================================
  294.  
  295. class Game_ComposeMaterial
  296.   #--------------------------------------------------------------------------
  297.   # ○ 公開インスタンス変数
  298.   #--------------------------------------------------------------------------
  299.   attr_accessor :kind                     # アイテムの種類 (/[IWA]/)
  300.   attr_accessor :id                       # アイテムの ID
  301.   attr_accessor :number                   # 必要数
  302.   #--------------------------------------------------------------------------
  303.   # ○ オブジェクト初期化
  304.   #--------------------------------------------------------------------------
  305.   def initialize
  306.     @kind = "I"
  307.     @id = 0
  308.     @number = 1
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ○ アイテム取得
  312.   #--------------------------------------------------------------------------
  313.   def item
  314.     case @kind
  315.     when "I"  # アイテム
  316.       return $data_items[@id]
  317.     when "W"  # 武器
  318.       return $data_weapons[@id]
  319.     when "A"  # 防具
  320.       return $data_armors[@id]
  321.     else
  322.       return nil
  323.     end
  324.   end
  325. end
  326.  
  327. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  328.  
  329. #==============================================================================
  330. # ■ Window_Base
  331. #==============================================================================
  332.  
  333. class Window_Base < Window
  334.   #--------------------------------------------------------------------------
  335.   # ○ 合成アイテム名の描画
  336.   #     item    : アイテム (スキル、武器、防具でも可)
  337.   #     x       : 描画先 X 座標
  338.   #     y       : 描画先 Y 座標
  339.   #     enabled : 有効フラグ。false のとき半透明で描画
  340.   #--------------------------------------------------------------------------
  341.   def draw_compose_item_name(item, x, y, enabled = true)
  342.     return if item == nil
  343.  
  344.     draw_icon(item.icon_index, x, y, enabled)
  345.     self.contents.font.color = normal_color
  346.     self.contents.font.color.alpha = enabled ? 255 : 128
  347.     self.contents.draw_text(x + 24, y, 172, WLH,
  348.       $game_party.item_composed?(item) ? item.name : item.masked_name)
  349.   end
  350. end
  351.  
  352. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  353.  
  354. #==============================================================================
  355. # □ Window_ComposeNumber
  356. #------------------------------------------------------------------------------
  357. #   合成画面で、合成するアイテムの個数を入力するウィンドウです。
  358. #==============================================================================
  359.  
  360. class Window_ComposeNumber < Window_ShopNumber
  361.   #--------------------------------------------------------------------------
  362.   # ● リフレッシュ
  363.   #--------------------------------------------------------------------------
  364.   def refresh
  365.     y = 96
  366.     self.contents.clear
  367.     draw_compose_item_name(@item, 0, y)
  368.     self.contents.font.color = normal_color
  369.     self.contents.draw_text(212, y, 20, WLH, "×")
  370.     self.contents.draw_text(248, y, 20, WLH, @number, 2)
  371.     self.cursor_rect.set(244, y, 28, WLH)
  372.     if !KGC::ComposeItem::HIDE_ZERO_COST || @price > 0
  373.       draw_currency_value(@price * @number, 4, y + WLH * 2, 264)
  374.     end
  375.   end
  376. end
  377.  
  378. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  379.  
  380. #==============================================================================
  381. # □ Window_ComposeItem
  382. #------------------------------------------------------------------------------
  383. #   合成画面で、合成できる商品の一覧を表示するウィンドウです。
  384. #==============================================================================
  385.  
  386. class Window_ComposeItem < Window_ShopBuy
  387.   #--------------------------------------------------------------------------
  388.   # ● リフレッシュ
  389.   #--------------------------------------------------------------------------
  390.   def refresh
  391.     @data = []
  392.     for goods_item in @shop_goods
  393.       case goods_item[0]
  394.       when 0
  395.         item = $data_items[goods_item[1]]
  396.       when 1
  397.         item = $data_weapons[goods_item[1]]
  398.       when 2
  399.         item = $data_armors[goods_item[1]]
  400.       end
  401.       # 合成アイテムのみ追加
  402.       @data.push(item) if include?(item)
  403.     end
  404.     @item_max = @data.size
  405.     create_contents
  406.     for i in 0...@item_max
  407.       draw_item(i)
  408.     end
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # ○ アイテムをリストに含めるかどうか
  412.   #     item : アイテム
  413.   #--------------------------------------------------------------------------
  414.   def include?(item)
  415.     return false if item == nil                # アイテムが nil なら含めない
  416.     return false unless item.is_compose?       # 合成アイテムでなければ含めない
  417.     if KGC::ComposeItem::HIDE_SHORTAGE_RECIPE  # 費用?素材不足を隠す場合
  418.       if !$game_party.item_composed?(item) && !enable?(item)
  419.         return false  # 未合成かつ合成不可なら含めない
  420.       end
  421.     end
  422.  
  423.     return true
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ○ アイテムを許可状態で表示するかどうか
  427.   #     item : アイテム
  428.   #--------------------------------------------------------------------------
  429.   def enable?(item)
  430.     return $game_party.item_can_compose?(item)
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # ● 項目の描画
  434.   #     index : 項目番号
  435.   #--------------------------------------------------------------------------
  436.   def draw_item(index)
  437.     item = @data[index]
  438.     number = $game_party.item_number(item)
  439.     limit = ($imported["LimitBreak"] ? item.number_limit : 99)
  440.     rect = item_rect(index)
  441.     self.contents.clear_rect(rect)
  442.     draw_compose_item_name(item, rect.x, rect.y, enable?(item))
  443.     # 費用を描画
  444.     if !KGC::ComposeItem::HIDE_ZERO_COST || item.compose_cost > 0
  445.       rect.width -= 4
  446.       self.contents.draw_text(rect, item.compose_cost, 2)
  447.     end
  448.   end
  449.  
  450.   if KGC::ComposeItem::HIDE_UNKNOWN_RECIPE_HELP
  451.   #--------------------------------------------------------------------------
  452.   # ● ヘルプテキスト更新
  453.   #--------------------------------------------------------------------------
  454.   def update_help
  455.     item = (index >= 0 ? @data[index] : nil)
  456.     if item == nil || $game_party.item_composed?(item)
  457.       # アイテムが nil か、合成済みなら [Window_ShopBuy] に任せる
  458.       super
  459.     else
  460.       @help_window.set_text(KGC::ComposeItem::UNKNOWN_RECIPE_HELP)
  461.     end
  462.   end
  463.   end
  464. end
  465.  
  466. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  467.  
  468. #==============================================================================
  469. # □ Window_ComposeStatus
  470. #------------------------------------------------------------------------------
  471. #  合成画面で、素材の所持数や必要数を表示するウィンドウです。
  472. #==============================================================================
  473.  
  474. class Window_ComposeStatus < Window_ShopStatus
  475.   #--------------------------------------------------------------------------
  476.   # ○ 表示モード
  477.   #--------------------------------------------------------------------------
  478.   MODE_MATERIAL = 0  # 素材リスト
  479.   MODE_STATUS   = 1  # パーティのステータス
  480.   #--------------------------------------------------------------------------
  481.   # ● オブジェクト初期化
  482.   #     x : ウィンドウの X 座標
  483.   #     y : ウィンドウの Y 座標
  484.   #--------------------------------------------------------------------------
  485.   def initialize(x, y)
  486.     @mode = MODE_MATERIAL
  487.     super(x, y)
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ○ モード変更
  491.   #--------------------------------------------------------------------------
  492.   def change_mode
  493.     case @mode
  494.     when MODE_MATERIAL
  495.       @mode = MODE_STATUS
  496.     when MODE_STATUS
  497.       @mode = MODE_MATERIAL
  498.     end
  499.     self.oy = 0
  500.     refresh
  501.   end
  502.   #--------------------------------------------------------------------------
  503.   # ● ウィンドウ内容の作成
  504.   #--------------------------------------------------------------------------
  505.   def create_contents
  506.     if @mode == MODE_STATUS
  507.       super
  508.       return
  509.     end
  510.  
  511.     self.contents.dispose
  512.     ch = height - 32
  513.     if @item != nil
  514.       mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  515.       ch = [ch, WLH * (mag + @item.compose_materials.size * mag)].max
  516.     end
  517.     self.contents = Bitmap.new(width - 32, ch)
  518.   end
  519.   #--------------------------------------------------------------------------
  520.   # ● リフレッシュ
  521.   #--------------------------------------------------------------------------
  522.   def refresh
  523.     create_contents
  524.     self.contents.font.size = Font.default_size
  525.     case @mode
  526.     when MODE_MATERIAL
  527.       draw_material_list
  528.     when MODE_STATUS
  529.       super
  530.     end
  531.   end
  532.   #--------------------------------------------------------------------------
  533.   # ○ 素材リストを描画
  534.   #--------------------------------------------------------------------------
  535.   def draw_material_list
  536.     return if @item == nil
  537.     number = $game_party.item_number(@item)
  538.     self.contents.font.color = system_color
  539.     self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
  540.     self.contents.font.color = normal_color
  541.     self.contents.draw_text(4, 0, 200, WLH, number, 2)
  542.     self.contents.font.size = 16 if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  543.     mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  544.     @item.compose_materials.each_with_index { |material, i|
  545.       y = WLH * (mag + i * mag)
  546.       draw_material_info(0, y, material)
  547.     }
  548.   end
  549.   #--------------------------------------------------------------------------
  550.   # ○ 素材情報を描画
  551.   #--------------------------------------------------------------------------
  552.   def draw_material_info(x, y, material)
  553.     m_item = material.item
  554.     return if m_item == nil
  555.     number = $game_party.item_number(m_item)
  556.     enabled = (number > 0 && number >= material.number)
  557.     draw_item_name(m_item, x, y, enabled)
  558.     if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  559.       m_number = (material.number == 0 ? "-" : sprintf("%d", material.number))
  560.       self.contents.draw_text(x, y, width - 32, WLH,
  561.         sprintf("%s/%d", m_number, number), 2)
  562.     else
  563.       m_number = (material.number == 0 ? "-" : sprintf("%2d", material.number))
  564.       self.contents.draw_text(x, y + WLH, width - 32, WLH,
  565.         sprintf("%2s/%2d", m_number, number), 2)
  566.     end
  567.   end
  568. end
  569.  
  570. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  571.  
  572. #==============================================================================
  573. # ■ Scene_Map
  574. #==============================================================================
  575.  
  576. class Scene_Map < Scene_Base
  577.   #--------------------------------------------------------------------------
  578.   # ● ショップ画面への切り替え
  579.   #--------------------------------------------------------------------------
  580.   alias call_shop_KGC_ComposeItem call_shop
  581.   def call_shop
  582.     # 合成画面を呼び出した場合
  583.     if $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH]
  584.       # 合成画面に移行
  585.       $game_temp.next_scene = nil
  586.       $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH] = false
  587.       $scene = Scene_ComposeItem.new
  588.     else
  589.       call_shop_KGC_ComposeItem
  590.     end
  591.   end
  592. end
  593.  
  594. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
  595.  
  596. #==============================================================================
  597. # □ Scene_ComposeItem
  598. #------------------------------------------------------------------------------
  599. #  合成画面の処理を行うクラスです。
  600. #==============================================================================
  601.  
  602. class Scene_ComposeItem < Scene_Shop
  603.   #--------------------------------------------------------------------------
  604.   # ● 開始処理
  605.   #--------------------------------------------------------------------------
  606.   def start
  607.     super
  608.     # コマンドウィンドウ非表示
  609.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  610.       @command_window.visible = false
  611.       @gold_window.y = Graphics.height - @gold_window.height
  612.       @gold_window.z = @status_window.z + 100
  613.       @gold_window.visible = !KGC::ComposeItem::HIDE_GOLD_WINDOW
  614.  
  615.       @dummy_window.y = @command_window.y
  616.       @dummy_window.height += @command_window.height
  617.     end
  618.  
  619.     # [Scene_Shop] 再利用のため、合成リストに @buy_window を使用
  620.     @buy_window.dispose
  621.     @buy_window = Window_ComposeItem.new(0, @dummy_window.y)
  622.     @buy_window.height = @dummy_window.height
  623.     @buy_window.active = false
  624.     @buy_window.visible = false
  625.     @buy_window.help_window = @help_window
  626.  
  627.     # その他のウィンドウを再構成
  628.     @number_window.dispose
  629.     @number_window = Window_ComposeNumber.new(0, @buy_window.y)
  630.     @number_window.height = @buy_window.height
  631.     @number_window.create_contents
  632.     @number_window.active = false
  633.     @number_window.visible = false
  634.  
  635.     @status_window.dispose
  636.     @status_window = Window_ComposeStatus.new(@buy_window.width, @buy_window.y)
  637.     @status_window.height = @buy_window.height
  638.     @status_window.create_contents
  639.     @status_window.visible = false
  640.  
  641.     # コマンドウィンドウ非表示の場合、合成ウィンドウに切り替え
  642.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  643.       @command_window.active = false
  644.       @dummy_window.visible = false
  645.       @buy_window.active = true
  646.       @buy_window.visible = true
  647.       @buy_window.update_help
  648.       @status_window.visible = true
  649.       @status_window.item = @buy_window.item
  650.     end
  651.   end
  652.   #--------------------------------------------------------------------------
  653.   # ● コマンドウィンドウの作成
  654.   #--------------------------------------------------------------------------
  655.   def create_command_window
  656.     s1 = Vocab::ComposeItem
  657.     s2 = Vocab::ShopSell
  658.     s3 = Vocab::ShopCancel
  659.     @command_window = Window_Command.new(384, [s1, s2, s3], 3)
  660.     @command_window.y = 56
  661.     if $game_temp.shop_purchase_only
  662.       @command_window.draw_item(1, false)
  663.     end
  664.   end
  665.   #--------------------------------------------------------------------------
  666.   # ● フレーム更新
  667.   #--------------------------------------------------------------------------
  668.   def update
  669.     super
  670.     if KGC::ComposeItem::SWITCH_INFO_BUTTON != nil &&
  671.         Input.trigger?(KGC::ComposeItem::SWITCH_INFO_BUTTON)
  672.       Sound.play_cursor
  673.       @status_window.change_mode
  674.     end
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ● 購入アイテム選択の更新
  678.   #--------------------------------------------------------------------------
  679.   def update_buy_selection
  680.     # コマンドウィンドウ非表示で B ボタンが押された場合
  681.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW && Input.trigger?(Input::B)
  682.       Sound.play_cancel
  683.       $scene = Scene_Map.new
  684.       return
  685.     end
  686.  
  687.     @status_window.item = @buy_window.item
  688.     if Input.trigger?(Input::C)
  689.       @item = @buy_window.item
  690.       # アイテムが無効なら選択不可
  691.       if @item == nil
  692.         Sound.play_buzzer
  693.         return
  694.       end
  695.  
  696.       # 合成不可能 or 限界数まで所持している場合は選択不可
  697.       number = $game_party.item_number(@item)
  698.       limit = ($imported["LimitBreak"] ? @item.number_limit : 99)
  699.       if !$game_party.item_can_compose?(@item) || number == limit
  700.         Sound.play_buzzer
  701.         return
  702.       end
  703.  
  704.       # 個数入力に切り替え
  705.       Sound.play_decision
  706.       max = $game_party.number_of_composable(@item)
  707.       max = [max, limit - number].min
  708.       @buy_window.active = false
  709.       @buy_window.visible = false
  710.       @number_window.set(@item, max, @item.compose_cost)
  711.       @number_window.active = true
  712.       @number_window.visible = true
  713.       return
  714.     end
  715.  
  716.     super
  717.   end
  718.   #--------------------------------------------------------------------------
  719.   # ● 個数入力の決定
  720.   #--------------------------------------------------------------------------
  721.   def decide_number_input
  722.     if @command_window.index != 0  # 「合成する」以外
  723.       super
  724.       return
  725.     end
  726.  
  727.     Sound.play_shop
  728.     @number_window.active = false
  729.     @number_window.visible = false
  730.     # 合成処理
  731.     operation_compose
  732.     @gold_window.refresh
  733.     @buy_window.refresh
  734.     @status_window.refresh
  735.     @buy_window.active = true
  736.     @buy_window.visible = true
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ○ 合成の処理
  740.   #--------------------------------------------------------------------------
  741.   def operation_compose
  742.     $game_party.lose_gold(@number_window.number * @item.compose_cost)
  743.     $game_party.gain_item(@item, @number_window.number)
  744.     # 素材を減らす
  745.     @item.compose_materials.each { |material|
  746.       $game_party.lose_item(material.item,
  747.         material.number * @number_window.number)
  748.     }
  749.     # 合成済みにする
  750.     $game_party.set_item_composed(@item)
  751.   end
  752. end

评分

参与人数 1梦石 +1 收起 理由
正太君 + 1 认可答案

查看全部评分

别问我是谁! 我只是一个不为人知的小白而已..
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

3
 楼主| 发表于 2017-3-4 15:51:09 | 只看该作者
额   这个脚本是代替商店吗
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

4
 楼主| 发表于 2017-3-4 15:52:27 | 只看该作者
怎么通过事件呼出
我是想用物品合成的脚本做一个炼金术类的技能
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

5
 楼主| 发表于 2017-3-5 12:11:11 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

额   这个脚本是代替商店吗
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

6
 楼主| 发表于 2017-3-5 12:11:35 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

怎么通过事件呼出
我是想用物品合成的脚本做一个炼金术类的技能

点评

备注里不是写着使用方法吗...  发表于 2017-3-5 13:07
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

7
 楼主| 发表于 2017-3-11 17:06:44 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

我看不懂啊...到底怎么呼出合成界面啊,好人帮帮我吧>_<
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

8
 楼主| 发表于 2017-3-18 15:09:57 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

O(∩_∩)O谢谢!我突然明白怎么用了,先把脚本里说的那个号码的开关打开,再用商店处理指定要合成的物品,就可以打开合成界面了~
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

9
 楼主| 发表于 2017-3-18 15:10:33 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

十分感谢!
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1235
在线时间
254 小时
注册时间
2017-2-18
帖子
99

开拓者

10
 楼主| 发表于 2017-3-18 15:11:01 | 只看该作者
axicc 发表于 2017-2-25 17:56
请善用搜索 - -
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/   ...

十分感谢!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-29 20:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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