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

Project1

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

[已经解决] 怎样将合成脚本加入菜单里

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
跳转到指定楼层
1
发表于 2011-11-27 01:10:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

在论坛上下的合成脚本,需要开启X号开关后在打开商店才能打开打开合成菜单,在菜单里加选项后,想要链接到1个公共事件
求解
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ 物品合成 - KGC_ComposeItem ◆ VX ◆
  3. #_/    ◇ Last update : 2008/01/25 ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/                     可制作合成物品。
  6. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  7. #==============================================================================
  8. # ★ 定做項目 - Customize ★
  9. #==============================================================================

  10. module KGC
  11. module ComposeItem
  12.   # ◆ 将合成画面调用的开关号码
  13.   #  把这个开关设定为 ON 的话,可代替通常的店铺并使用合成功能。
  14.   COMPOSE_CALL_SWITCH = 13

  15.   # ◆ 合成物素材设定,通常格式:
  16.   #  ?费用,"物品类型:ID,个数",... ?
  17.   #  【 费用 】合成物品所需的费用
  18.   #  【 物品种类 】合成素材的种类  (I..物品  W..武器  A..防具)
  19.   #  【  ID  】合成素材的ID (↑要与以上相对应)
  20.   #  【 个数 】合成物品所需素材的数目
  21.   #  "物品种类:ID,個数" 。多个的时候也可以这样设定。
  22.   #  可省略数目。写成 "物品类型:ID" 。如果没写的话,将用默认设定个数为1。
  23.   #  如果把个数设定为0的话,持有1个以上时也可以合成,但是合成成功的话,将
  24.   #不会扣除所设定的物品。
  25.   #  按一下设定的排列,添加的顺序与物品?武器?防具的ID相对应。
  26.   RECIPE_ITEM   = []  # 物品
  27.   RECIPE_WEAPON = []  # 武器
  28.   RECIPE_ARMOR  = []  # 防具
  29.   # 从这里开始,自定义合成公式(找不到好的词)。
  30.   #  <例如>
  31.   #  物品ID为8的合成公式
  32.   #  物品ID 2, 4, 7 各消耗1个,免费合成。
  33.   RECIPE_ITEM[8] = [0, "I:2", "I:4", "I:7"]
  34.   #  武器ID:16 的合成公式
  35.   #  武器ID:10 消耗1个、物品ID:16 消耗 2 个,合成费用800 G。
  36.   RECIPE_WEAPON[16] = [800, "W:10", "I:16,2"]
  37.   RECIPE_WEAPON[1] = [0,"I:1,2"]

  38.   # ◆ 合成指令名
  39.   #  可替代普通商店的购买指令。
  40.   #  ※ 想要修改指令名字的话,可在下面的[Vocab]后做修改。
  41.   VOCAB_COMPOSE_ITEM = "合成"
  42.   # ◆ 合成物品的信息转换按键
  43.   #  「所需材料 <=转换=> 角色能力值変化(为装备品时)」信息变换按键。
  44.   #  不使用的时候,请设定成 nil。
  45.   SWITCH_INFO_BUTTON = Input::X

  46.   # ◆ 必要设定
  47.   #  当合成的材料为较多数时,请设定成 true。(其实就是合成素材的行距与字的大小)
  48.   COMPACT_MATERIAL_LIST = true
  49.   # ◆ 不显示命令窗口。
  50.   #  这与XP是相似的。
  51.   HIDE_COMMAND_WINDOW   = true
  52.   # ◆ 不显示所持金钱数
  53.   HIDE_GOLD_WINDOW      = false
  54.   # ◆ 当合成费用是0时, 不显示费用。
  55.   HIDE_ZERO_COST        = true

  56.   # ◆ 不表示费用与素材不足的合成列表。
  57.   #  之前合成过的物品的显名表示。
  58.   HIDE_SHORTAGE_RECIPE     = true
  59.   # ◆ 没有合成的物品隐藏物品名字, true为隐藏。
  60.   MASK_UNKNOWN_RECIPE_NAME = false
  61.   # ◆ 没有合成过的物品在列表上的表示方法
  62.   #  以下设定隐藏名,当物品名字为多个时,按以下设定扩展名字。
  63.   UNKNOWN_NAME_MASK        = "?"
  64.   # ◆ 没有合成过的物品,隐藏帮助信息。
  65.   HIDE_UNKNOWN_RECIPE_HELP = true
  66.   # ◆ 没有合成过在物品在列表上的帮助 信息。
  67.   UNKNOWN_RECIPE_HELP      = "制造列表"
  68. end
  69. end

  70. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  71. $imported = {} if $imported == nil
  72. $imported["ComposeItem"] = true

  73. module KGC::ComposeItem
  74.   # 定义正则表达式
  75.   module Regexp
  76.     # 合成列表
  77.     RECIPE = /([IWA])[ ]*:[ ]*(\d+)([ ]*,[ ]*\d+)?/i
  78.   end
  79. end

  80. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  81. #==============================================================================
  82. # ■ Vocab
  83. #==============================================================================

  84. module Vocab
  85.   # 合成画面
  86.   ComposeItem = KGC::ComposeItem::VOCAB_COMPOSE_ITEM
  87. end

  88. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  89. #==============================================================================
  90. # ■ RPG::BaseItem
  91. #==============================================================================

  92. class RPG::BaseItem
  93.   #--------------------------------------------------------------------------
  94.   # ○ 变量
  95.   #--------------------------------------------------------------------------
  96.   @@__masked_name =
  97.     KGC::ComposeItem::UNKNOWN_NAME_MASK  # 隐藏名
  98.   @@__expand_masked_name = false         # 隐藏名的扩展表示

  99.   if @@__masked_name != nil
  100.     @@__expand_masked_name = (@@__masked_name.scan(/./).size == 1)
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ○ 物品合成费用
  104.   #--------------------------------------------------------------------------
  105.   def create_compose_item_cache
  106.     @__compose_cost = 0
  107.     @__compose_materials = []

  108.     # 合成列表取得
  109.     recipe = nil
  110.     case self
  111.     when RPG::Item    # 物品
  112.       recipe = KGC::ComposeItem::RECIPE_ITEM[self.id]
  113.     when RPG::Weapon  # 武器
  114.       recipe = KGC::ComposeItem::RECIPE_WEAPON[self.id]
  115.     when RPG::Armor   # 防具
  116.       recipe = KGC::ComposeItem::RECIPE_ARMOR[self.id]
  117.     end
  118.     return if recipe == nil
  119.     recipe = recipe.dup

  120.     @__compose_cost = recipe.shift
  121.     # 合成材料名单
  122.     recipe.each { |r|
  123.       if r =~ KGC::ComposeItem::Regexp::RECIPE
  124.         material = Game_ComposeMaterial.new
  125.         material.kind = $1.upcase                    # 取得材料的种类
  126.         material.id = $2.to_i                        # 取得材料的ID
  127.         if $3 != nil
  128.           material.number = [$3[/\d+/].to_i, 0].max  # 取得必要合成个数
  129.         end
  130.         @__compose_materials << material
  131.       end
  132.     }
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ○ 隐藏名
  136.   #--------------------------------------------------------------------------
  137.   def masked_name
  138.     if KGC::ComposeItem::MASK_UNKNOWN_RECIPE_NAME
  139.       if @@__expand_masked_name
  140.         # 隐藏名的扩展表示
  141.         return @@__masked_name * self.name.scan(/./).size
  142.       else
  143.         return @@__masked_name
  144.       end
  145.     else
  146.       return self.name
  147.     end
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ○ 合成费用
  151.   #--------------------------------------------------------------------------
  152.   def compose_cost
  153.     create_compose_item_cache if @__compose_cost == nil
  154.     return @__compose_cost
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ○ 合成用材料名单
  158.   #--------------------------------------------------------------------------
  159.   def compose_materials
  160.     create_compose_item_cache if @__compose_materials == nil
  161.     return @__compose_materials
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ○ 合成列表
  165.   #--------------------------------------------------------------------------
  166.   def is_compose?
  167.     return !compose_materials.empty?
  168.   end
  169. end

  170. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  171. #==============================================================================
  172. # ■ Game_Party
  173. #==============================================================================

  174. class Game_Party < Game_Unit
  175.   #--------------------------------------------------------------------------
  176.   # ○ 合成済みフラグをクリア
  177.   #--------------------------------------------------------------------------
  178.   def clear_composed_flag
  179.     @item_composed = {}
  180.     @weapon_composed = {}
  181.     @armor_composed = {}
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ○ アイテムの合成済みフラグを設定
  185.   #     item : アイテム
  186.   #     flag : true..合成済み  false..未合成
  187.   #--------------------------------------------------------------------------
  188.   def set_item_composed(item, flag = true)
  189.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外
  190.     return false unless item.is_compose?           # 合成アイテム以外

  191.     # 合成済みフラグを格納するハッシュを作成
  192.     clear_composed_flag if @item_composed == nil

  193.     # 合成済みフラグをセット
  194.     case item
  195.     when RPG::Item    # アイテム
  196.       @item_composed[item.id] = flag
  197.     when RPG::Weapon  # 武器
  198.       @weapon_composed[item.id] = flag
  199.     when RPG::Armor   # 防具
  200.       @armor_composed[item.id] = flag
  201.     end
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ○ アイテムの合成済み判定
  205.   #     item : アイテム
  206.   #--------------------------------------------------------------------------
  207.   def item_composed?(item)
  208.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外
  209.     return false unless item.is_compose?           # 合成アイテム以外

  210.     # 合成済みフラグを格納するハッシュを作成
  211.     clear_composed_flag if @item_composed == nil

  212.     # 合成済み判定
  213.     case item
  214.     when RPG::Item    # アイテム
  215.       return @item_composed[item.id]
  216.     when RPG::Weapon  # 武器
  217.       return @weapon_composed[item.id]
  218.     when RPG::Armor   # 防具
  219.       return @armor_composed[item.id]
  220.     end
  221.     return false
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # ○ アイテムの合成可能判定
  225.   #     item : アイテム
  226.   #--------------------------------------------------------------------------
  227.   def item_can_compose?(item)
  228.     return false unless item.is_a?(RPG::BaseItem)  # アイテム以外は不可
  229.     return false unless item.is_compose?           # 合成アイテム以外は不可

  230.     return false if gold < item.compose_cost       # 資金不足なら不可

  231.     item.compose_materials.each { |material|
  232.       num = item_number(material.item)
  233.       # 素材不足なら不可
  234.       return false if num < material.number || num == 0
  235.     }
  236.     return true
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ○ アイテムの合成可能数を取得
  240.   #     item : アイテム
  241.   #--------------------------------------------------------------------------
  242.   def number_of_composable(item)
  243.     return 0 unless item.is_a?(RPG::BaseItem)  # アイテム以外
  244.     return 0 unless item.is_compose?           # 合成アイテム以外

  245.     number = ($imported["LimitBreak"] ? item.number_limit : 99)
  246.     if item.compose_cost > 0
  247.       number = [number, gold / item.compose_cost].min
  248.     end
  249.     # 素材数判定
  250.     item.compose_materials.each { |material|
  251.       next if material.number == 0  # 必要数 0 は無視
  252.       n = item_number(material.item) / material.number
  253.       number = [number, n].min
  254.     }
  255.     return number
  256.   end
  257. end

  258. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  259. #==============================================================================
  260. # □ Game_ComposeMaterial
  261. #------------------------------------------------------------------------------
  262. #   合成素材の情報を格納するクラスです。
  263. #==============================================================================

  264. class Game_ComposeMaterial
  265.   #--------------------------------------------------------------------------
  266.   # ○ 公開インスタンス変数
  267.   #--------------------------------------------------------------------------
  268.   attr_accessor :kind                     # アイテムの種類 (/[IWA]/)
  269.   attr_accessor :id                       # アイテムの ID
  270.   attr_accessor :number                   # 必要数
  271.   #--------------------------------------------------------------------------
  272.   # ○ オブジェクト初期化
  273.   #--------------------------------------------------------------------------
  274.   def initialize
  275.     @kind = "I"
  276.     @id = 0
  277.     @number = 1
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # ○ アイテム取得
  281.   #--------------------------------------------------------------------------
  282.   def item
  283.     case @kind
  284.     when "I"  # アイテム
  285.       return $data_items[@id]
  286.     when "W"  # 武器
  287.       return $data_weapons[@id]
  288.     when "A"  # 防具
  289.       return $data_armors[@id]
  290.     else
  291.       return nil
  292.     end
  293.   end
  294. end

  295. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  296. #==============================================================================
  297. # ■ Window_Base
  298. #==============================================================================

  299. class Window_Base < Window
  300.   #--------------------------------------------------------------------------
  301.   # ○ 合成アイテム名の描画
  302.   #     item    : アイテム (スキル、武器、防具でも可)
  303.   #     x       : 描画先 X 座標
  304.   #     y       : 描画先 Y 座標
  305.   #     enabled : 有効フラグ。false のとき半透明で描画
  306.   #--------------------------------------------------------------------------
  307.   def draw_compose_item_name(item, x, y, enabled = true)
  308.     return if item == nil

  309.     draw_icon(item.icon_index, x, y, enabled)
  310.     self.contents.font.color = normal_color
  311.     self.contents.font.color.alpha = enabled ? 255 : 128
  312.     self.contents.draw_text(x + 24, y, 172, WLH,
  313.       $game_party.item_composed?(item) ? item.name : item.masked_name)
  314.   end
  315. end
  316.   
  317. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  318. #==============================================================================
  319. # □ Window_ComposeNumber
  320. #------------------------------------------------------------------------------
  321. #   合成画面で、合成するアイテムの個数を入力するウィンドウです。
  322. #==============================================================================

  323. class Window_ComposeNumber < Window_ShopNumber
  324.   #--------------------------------------------------------------------------
  325.   # ● リフレッシュ
  326.   #--------------------------------------------------------------------------
  327.   def refresh
  328.     y = 96
  329.     self.contents.clear
  330.     draw_compose_item_name(@item, 0, y)
  331.     self.contents.font.color = normal_color
  332.     self.contents.draw_text(212, y, 20, WLH, "×")
  333.     self.contents.draw_text(248, y, 20, WLH, @number, 2)
  334.     self.cursor_rect.set(244, y, 28, WLH)
  335.     if !KGC::ComposeItem::HIDE_ZERO_COST || @price > 0
  336.       draw_currency_value(@price * @number, 4, y + WLH * 2, 264)
  337.     end
  338.   end
  339. end

  340. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  341. #==============================================================================
  342. # □ Window_ComposeItem
  343. #------------------------------------------------------------------------------
  344. #   合成画面で、合成できる商品の一覧を表示するウィンドウです。
  345. #==============================================================================

  346. class Window_ComposeItem < Window_ShopBuy
  347.   #--------------------------------------------------------------------------
  348.   # ● リフレッシュ
  349.   #--------------------------------------------------------------------------
  350.   def refresh
  351.     @data = []
  352.     for goods_item in @shop_goods
  353.       case goods_item[0]
  354.       when 0
  355.         item = $data_items[goods_item[1]]
  356.       when 1
  357.         item = $data_weapons[goods_item[1]]
  358.       when 2
  359.         item = $data_armors[goods_item[1]]
  360.       end
  361.       # 合成アイテムのみ追加
  362.       @data.push(item) if include?(item)
  363.     end
  364.     @item_max = @data.size
  365.     create_contents
  366.     for i in 0...@item_max
  367.       draw_item(i)
  368.     end
  369.   end
  370.   #--------------------------------------------------------------------------
  371.   # ○ アイテムをリストに含めるかどうか
  372.   #     item : アイテム
  373.   #--------------------------------------------------------------------------
  374.   def include?(item)
  375.     return false if item == nil                # アイテムが nil なら含めない
  376.     return false unless item.is_compose?       # 合成アイテムでなければ含めない
  377.     if KGC::ComposeItem::HIDE_SHORTAGE_RECIPE  # 費用?素材不足を隠す場合
  378.       if !$game_party.item_composed?(item) && !enable?(item)
  379.         return false  # 未合成かつ合成不可なら含めない
  380.       end
  381.     end

  382.     return true
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ○ アイテムを許可状態で表示するかどうか
  386.   #     item : アイテム
  387.   #--------------------------------------------------------------------------
  388.   def enable?(item)
  389.     return $game_party.item_can_compose?(item)
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 項目の描画
  393.   #     index : 項目番号
  394.   #--------------------------------------------------------------------------
  395.   def draw_item(index)
  396.     item = @data[index]
  397.     number = $game_party.item_number(item)
  398.     limit = ($imported["LimitBreak"] ? item.number_limit : 99)
  399.     rect = item_rect(index)
  400.     self.contents.clear_rect(rect)
  401.     draw_compose_item_name(item, rect.x, rect.y, enable?(item))
  402.     # 費用を描画
  403.     if !KGC::ComposeItem::HIDE_ZERO_COST || item.compose_cost > 0
  404.       rect.width -= 4
  405.       self.contents.draw_text(rect, item.compose_cost, 2)
  406.     end
  407.   end

  408.   if KGC::ComposeItem::HIDE_UNKNOWN_RECIPE_HELP
  409.   #--------------------------------------------------------------------------
  410.   # ● ヘルプテキスト更新
  411.   #--------------------------------------------------------------------------
  412.   def update_help
  413.     item = (index >= 0 ? @data[index] : nil)
  414.     if item == nil || $game_party.item_composed?(item)
  415.       # アイテムが nil か、合成済みなら [Window_ShopBuy] に任せる
  416.       super
  417.     else
  418.       @help_window.set_text(KGC::ComposeItem::UNKNOWN_RECIPE_HELP)
  419.     end
  420.   end
  421.   end
  422. end

  423. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  424. #==============================================================================
  425. # □ Window_ComposeStatus
  426. #------------------------------------------------------------------------------
  427. #  合成画面で、素材の所持数や必要数を表示するウィンドウです。
  428. #==============================================================================

  429. class Window_ComposeStatus < Window_ShopStatus
  430.   #--------------------------------------------------------------------------
  431.   # ○ 表示モード
  432.   #--------------------------------------------------------------------------
  433.   MODE_MATERIAL = 0  # 素材リスト
  434.   MODE_STATUS   = 1  # パーティのステータス
  435.   #--------------------------------------------------------------------------
  436.   # ● オブジェクト初期化
  437.   #     x : ウィンドウの X 座標
  438.   #     y : ウィンドウの Y 座標
  439.   #--------------------------------------------------------------------------
  440.   def initialize(x, y)
  441.     @mode = MODE_MATERIAL
  442.     super(x, y)
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ○ モード変更
  446.   #--------------------------------------------------------------------------
  447.   def change_mode
  448.     case @mode
  449.     when MODE_MATERIAL
  450.       @mode = MODE_STATUS
  451.     when MODE_STATUS
  452.       @mode = MODE_MATERIAL
  453.     end
  454.     self.oy = 0
  455.     refresh
  456.   end
  457.   #--------------------------------------------------------------------------
  458.   # ● ウィンドウ内容の作成
  459.   #--------------------------------------------------------------------------
  460.   def create_contents
  461.     if @mode == MODE_STATUS
  462.       super
  463.       return
  464.     end

  465.     self.contents.dispose
  466.     ch = height - 32
  467.     if @item != nil
  468.       mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  469.       ch = [ch, WLH * (mag + @item.compose_materials.size * mag)].max
  470.     end
  471.     self.contents = Bitmap.new(width - 32, ch)
  472.   end
  473.   #--------------------------------------------------------------------------
  474.   # ● リフレッシュ
  475.   #--------------------------------------------------------------------------
  476.   def refresh
  477.     create_contents
  478.     self.contents.font.size = Font.default_size
  479.     case @mode
  480.     when MODE_MATERIAL
  481.       draw_material_list
  482.     when MODE_STATUS
  483.       super
  484.     end
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ○ 素材リストを描画
  488.   #--------------------------------------------------------------------------
  489.   def draw_material_list
  490.     return if @item == nil
  491.     number = $game_party.item_number(@item)
  492.     self.contents.font.color = system_color
  493.     self.contents.draw_text(4, 0, 200, WLH, Vocab::Possession)
  494.     self.contents.font.color = normal_color
  495.     self.contents.draw_text(4, 0, 200, WLH, number, 2)
  496.     self.contents.font.size = 16 if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  497.     mag = (KGC::ComposeItem::COMPACT_MATERIAL_LIST ? 1 : 2)
  498.     @item.compose_materials.each_with_index { |material, i|
  499.       y = WLH * (mag + i * mag)
  500.       draw_material_info(0, y, material)
  501.     }
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   # ○ 素材情報を描画
  505.   #--------------------------------------------------------------------------
  506.   def draw_material_info(x, y, material)
  507.     m_item = material.item
  508.     return if m_item == nil
  509.     number = $game_party.item_number(m_item)
  510.     enabled = (number > 0 && number >= material.number)
  511.     draw_item_name(m_item, x, y, enabled)
  512.     if KGC::ComposeItem::COMPACT_MATERIAL_LIST
  513.       m_number = (material.number == 0 ? "-" : sprintf("%d", material.number))
  514.       self.contents.draw_text(x, y, width - 32, WLH,
  515.         sprintf("%s/%d", m_number, number), 2)
  516.     else
  517.       m_number = (material.number == 0 ? "-" : sprintf("%2d", material.number))
  518.       self.contents.draw_text(x, y + WLH, width - 32, WLH,
  519.         sprintf("%2s/%2d", m_number, number), 2)
  520.     end
  521.   end
  522. end

  523. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  524. #==============================================================================
  525. # ■ Scene_Map
  526. #==============================================================================

  527. class Scene_Map < Scene_Base
  528.   #--------------------------------------------------------------------------
  529.   # ● ショップ画面への切り替え
  530.   #--------------------------------------------------------------------------
  531.   alias call_shop_KGC_ComposeItem call_shop
  532.   def call_shop
  533.     # 合成画面を呼び出した場合
  534.     if $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH]
  535.       # 合成画面に移行
  536.       $game_temp.next_scene = nil
  537.       $game_switches[KGC::ComposeItem::COMPOSE_CALL_SWITCH] = false
  538.       $scene = Scene_ComposeItem.new
  539.     else
  540.       call_shop_KGC_ComposeItem
  541.     end
  542.   end
  543. end

  544. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  545. #==============================================================================
  546. # □ Scene_ComposeItem
  547. #------------------------------------------------------------------------------
  548. #  合成画面の処理を行うクラスです。
  549. #==============================================================================

  550. class Scene_ComposeItem < Scene_Shop
  551.   #--------------------------------------------------------------------------
  552.   # ● 開始処理
  553.   #--------------------------------------------------------------------------
  554.   def start
  555.     super
  556.     # コマンドウィンドウ非表示
  557.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  558.       @command_window.visible = false
  559.       @gold_window.y = Graphics.height - @gold_window.height
  560.       @gold_window.z = @status_window.z + 100
  561.       @gold_window.visible = !KGC::ComposeItem::HIDE_GOLD_WINDOW

  562.       @dummy_window.y = @command_window.y
  563.       @dummy_window.height += @command_window.height
  564.     end

  565.     # [Scene_Shop] 再利用のため、合成リストに @buy_window を使用
  566.     @buy_window.dispose
  567.     @buy_window = Window_ComposeItem.new(0, @dummy_window.y)
  568.     @buy_window.height = @dummy_window.height
  569.     @buy_window.active = false
  570.     @buy_window.visible = false
  571.     @buy_window.help_window = @help_window

  572.     # その他のウィンドウを再構成
  573.     @number_window.dispose
  574.     @number_window = Window_ComposeNumber.new(0, @buy_window.y)
  575.     @number_window.height = @buy_window.height
  576.     @number_window.create_contents
  577.     @number_window.active = false
  578.     @number_window.visible = false

  579.     @status_window.dispose
  580.     @status_window = Window_ComposeStatus.new(@buy_window.width, @buy_window.y)
  581.     @status_window.height = @buy_window.height
  582.     @status_window.create_contents
  583.     @status_window.visible = false

  584.     # コマンドウィンドウ非表示の場合、合成ウィンドウに切り替え
  585.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW
  586.       @command_window.active = false
  587.       @dummy_window.visible = false
  588.       @buy_window.active = true
  589.       @buy_window.visible = true
  590.       @buy_window.update_help
  591.       @status_window.visible = true
  592.       @status_window.item = @buy_window.item
  593.     end
  594.   end
  595.   #--------------------------------------------------------------------------
  596.   # ● コマンドウィンドウの作成
  597.   #--------------------------------------------------------------------------
  598.   def create_command_window
  599.     s1 = Vocab::ComposeItem
  600.     s2 = Vocab::ShopSell
  601.     s3 = Vocab::ShopCancel
  602.     @command_window = Window_Command.new(384, [s1, s2, s3], 3)
  603.     @command_window.y = 56
  604.     if $game_temp.shop_purchase_only
  605.       @command_window.draw_item(1, false)
  606.     end
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● フレーム更新
  610.   #--------------------------------------------------------------------------
  611.   def update
  612.     super
  613.     if KGC::ComposeItem::SWITCH_INFO_BUTTON != nil &&
  614.         Input.trigger?(KGC::ComposeItem::SWITCH_INFO_BUTTON)
  615.       Sound.play_cursor
  616.       @status_window.change_mode
  617.     end
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 購入アイテム選択の更新
  621.   #--------------------------------------------------------------------------
  622.   def update_buy_selection
  623.     # コマンドウィンドウ非表示で B ボタンが押された場合
  624.     if KGC::ComposeItem::HIDE_COMMAND_WINDOW && Input.trigger?(Input::B)
  625.       Sound.play_cancel
  626.       $scene = Scene_Map.new
  627.       return
  628.     end

  629.     @status_window.item = @buy_window.item
  630.     if Input.trigger?(Input::C)
  631.       @item = @buy_window.item
  632.       # アイテムが無効なら選択不可
  633.       if @item == nil
  634.         Sound.play_buzzer
  635.         return
  636.       end

  637.       # 合成不可能 or 限界数まで所持している場合は選択不可
  638.       number = $game_party.item_number(@item)
  639.       limit = ($imported["LimitBreak"] ? @item.number_limit : 99)
  640.       if !$game_party.item_can_compose?(@item) || number == limit
  641.         Sound.play_buzzer
  642.         return
  643.       end

  644.       # 個数入力に切り替え
  645.       Sound.play_decision
  646.       max = $game_party.number_of_composable(@item)
  647.       max = [max, limit - number].min
  648.       @buy_window.active = false
  649.       @buy_window.visible = false
  650.       @number_window.set(@item, max, @item.compose_cost)
  651.       @number_window.active = true
  652.       @number_window.visible = true
  653.       return
  654.     end

  655.     super
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 個数入力の決定
  659.   #--------------------------------------------------------------------------
  660.   def decide_number_input
  661.     if @command_window.index != 0  # 「合成する」以外
  662.       super
  663.       return
  664.     end

  665.     Sound.play_shop
  666.     @number_window.active = false
  667.     @number_window.visible = false
  668.     # 合成処理
  669.     operation_compose
  670.     @gold_window.refresh
  671.     @buy_window.refresh
  672.     @status_window.refresh
  673.     @buy_window.active = true
  674.     @buy_window.visible = true
  675.   end
  676.   #--------------------------------------------------------------------------
  677.   # ○ 合成の処理
  678.   #--------------------------------------------------------------------------
  679.   def operation_compose
  680.     $game_party.lose_gold(@number_window.number * @item.compose_cost)
  681.     $game_party.gain_item(@item, @number_window.number)
  682.     # 素材を減らす
  683.     @item.compose_materials.each { |material|
  684.       $game_party.lose_item(material.item,
  685.         material.number * @number_window.number)
  686.     }
  687.     # 合成済みにする
  688.     $game_party.set_item_composed(@item)
  689.   end
  690. end
复制代码
roguelike求生RPG研发中....

Lv1.梦旅人

星君

梦石
0
星屑
83
在线时间
2980 小时
注册时间
2011-10-9
帖子
2317

贵宾短篇七萝莉正太组冠军

2
发表于 2011-11-27 02:59:56 | 只看该作者
本帖最后由 皮卡星 于 2011-11-27 03:01 编辑

不需要哦~~亲~~
直接把xxx开关false不就行了~~
不过这个合成脚本要怎样……可合成的道具全打开么= =||
这脚本本来就是这样的说……事件调用……菜单调用就有点那啥了……
说实话比起是“合成”更像“总换”脚本= =
正题:
如果要执行公共事件可以用以下语句:
$game_temp.common_event_id = 1
$scene = Scene_Map.new
注意:1是公共事件ID

回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1428
在线时间
1705 小时
注册时间
2011-8-17
帖子
818
3
 楼主| 发表于 2011-11-27 14:08:54 | 只看该作者
皮卡星 发表于 2011-11-27 02:59
不需要哦~~亲~~
直接把xxx开关false不就行了~~
不过这个合成脚本要怎样……可合成的道具全打开么= =||

表示我是要写在Scene_Menu里,用$game_temp.common_event_id = 1打不开啊...

点评

先调用$scene = Scene_Map.new  发表于 2011-11-27 14:36
roguelike求生RPG研发中....
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
87
在线时间
0 小时
注册时间
2013-2-7
帖子
2
4
发表于 2013-2-7 03:08:13 手机端发表。 | 只看该作者
好长的一个帖子... 先马克等会再看    不知道能跟XAS兼容不...我也很想要的说
来自: Android客户端

评分

参与人数 1星屑 -20 收起 理由
Luciffer -20 挖坟

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-6-11 23:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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