查看: 1356|回复: 2

[已经解决] 帮忙看看这个合成脚本如何使用

[复制链接]

梦石
0
星屑
782
在线时间
3431 小时
注册时间
2011-6-10
回帖
6325
发表于 2013-10-28 08:54:59 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 铃仙·优昙华院·因幡 于 2013-10-28 10:00 编辑

写是写了使用方法,但是实验了几次完全用不来……帮忙看看是如何 调出窗口,设置素材的

[pre lang="ruby" line="1"]
#******************************************************************************
#
#    * アイテム合成
#
#  --------------------------------------------------------------------------
#    バージョン :  2.0.1
#     対    応  :  RPGツクールVX : RGSS2
#     制 作 者  :  CACAO
#     配 布 元  :  http://cacaosoft.web.fc2.com/
#  --------------------------------------------------------------------------
#   == 概    要 ==
#
#    : アイテムの合成機能を追加します。
#
#  --------------------------------------------------------------------------
#   == 使用方法 ==
#
#    ★ 合成画面を表示する (簡易)
#     イベントコマンド「ラベル」に <アイテム合成> と記入し、
#     イベントコマンド「ショップの処理」でアイテムを設定する。
#
#    ★ 合成画面を表示する (分割)
#     イベントコマンド「ラベル」に <合成準備> と記入し、
#     イベントコマンド「ショップの処理」で、アイテムを設定し、
#     イベントコマンド「ラベル」に <合成開始> と記入し合成画面を開く。
#     イベントコマンド「ラベル」に <合成中止> と記入すれば、準備が中止される。
#    ※ アイテムの設定は、複数に分けても構わない。
#
#    ★ 合成素材の設定
#     アイテムのメモ欄に @CONFLATE[種類ID:個数] と記入してください。
#      種類 .. I:アイテム, W:武器, A:防具
#      ID .. データベース上でのアイテムの番号
#      個数 .. 左辺のアイテムの必要な数
#     [...] には、, で区切ることで複数の設定ができます。
#     最初の要素に数値のみの設定を行うと、合成に必要な費用を設定できます。
#     費用の設定を省略した場合、価格に CUT_RATE をかけた値が使用されます。
#    例) @CONFLATE[100, I1:3, I13:1, A17:1]
#    ※ @CONFLATE は、複数に分けて設定することも可能です。
#
#
#******************************************************************************


#==============================================================================
# ◆ 設定項目
#==============================================================================
module CAO
module Conflate
  #--------------------------------------------------------------------------
  # ◇ 値引率
  #--------------------------------------------------------------------------
  CUT_RATE = 0.3
  
  #--------------------------------------------------------------------------
  # ◇ ショップステータスを表示する
  #--------------------------------------------------------------------------
  USE_SHOP_STATUS = true
  
  #--------------------------------------------------------------------------
  # ◇ 背景画像
  #--------------------------------------------------------------------------
  #     ファイル名を設定します。使用しない場合は nil としてください。
  #--------------------------------------------------------------------------
  FILE_SCENEBACK  = nil#"BackConflate"
  FILE_STATUSBACK = "成品"
  
  #--------------------------------------------------------------------------
  # ◇ 用語設定
  #--------------------------------------------------------------------------
  VOCAB = {}    # <= 変更しないでください。
  VOCAB[:gold]     = ""
  VOCAB[:material] = ""
  VOCAB[:have]     = "                                                                件"
  VOCAB[:have_u]   = ""
  VOCAB[:cost]     = ""
end
end


#/////////////////////////////////////////////////////////////////////////////#
#                                                                             #
#                下記のスクリプトを変更する必要はありません。                 #
#                                                                             #
#/////////////////////////////////////////////////////////////////////////////#


module CAO::Conflate
  REGEXP_GOLD = /^@CONFLATE\[(\d+)(?:,|\])/i
  REGEXP_KEYS = /^@CONFLATE\[(.+?)\]/i
  REGEXP_GOODS = /([IWA])(\d+):(\d+)/i
end

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # ● 合成費用の取得
  #--------------------------------------------------------------------------
  def conflate_price
    return self.note.gsub(" ", "")[CAO::Conflate::REGEXP_GOLD, 1]
  end
  #--------------------------------------------------------------------------
  # ● 合成に必要なアイテムの取得
  #--------------------------------------------------------------------------
  def conflate_items
    self.note.gsub(" ", "").scan(CAO::Conflate::REGEXP_KEYS).flatten.
    join(",").scan(CAO::Conflate::REGEXP_GOODS).map do |key|
      case key.first.upcase
      when "I"; [$data_items[key[1].to_i], key[2].to_i]
      when "W"; [$data_weapons[key[1].to_i], key[2].to_i]
      when "A"; [$data_armors[key[1].to_i], key[2].to_i]
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 合成に必要なアイテムが揃っているか判定
  #--------------------------------------------------------------------------
  def enough_material?
    return self.conflate_items.all? {|o,n| n <= $game_party.item_number(o) }
  end
  #--------------------------------------------------------------------------
  # ● 合成可能か判定
  #--------------------------------------------------------------------------
  def can_make?
    return false if $game_party.gold < self.conflate_price
    return false unless $game_party.item_number(self) < 99
    return false unless self.enough_material?
    return true
  end
end

class RPG::Item
  #--------------------------------------------------------------------------
  # ○ 合成費用の取得
  #--------------------------------------------------------------------------
  def conflate_price
    return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  end
end
class RPG::Weapon
  #--------------------------------------------------------------------------
  # ○ 合成費用の取得
  #--------------------------------------------------------------------------
  def conflate_price
    return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  end
end
class RPG::Armor
  #--------------------------------------------------------------------------
  # ○ 合成費用の取得
  #--------------------------------------------------------------------------
  def conflate_price
    return Integer(super || self.price * CAO::Conflate::CUT_RATE)
  end
end

class Game_Temp
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :conflate_setting         # 合成 準備中フラグ
  attr_accessor :conflate_immediate       # 合成 即時実行フラグ
  attr_accessor :conflate_goods           # 合成 商品リスト
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias _cao_conflate_initialize initialize
  def initialize
    _cao_conflate_initialize
    @conflate_goods = []      # 合成アイテムID
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ ラベル
  #--------------------------------------------------------------------------
  alias _cao_conflate_command_118 command_118
  def command_118
    case @params[0]
    when /^<物品合成>/
      $game_temp.conflate_goods = []
      $game_temp.conflate_setting = true
      $game_temp.conflate_immediate = true
    when /^<合成准备>/
      $game_temp.conflate_goods = []
      $game_temp.conflate_setting = true
      $game_temp.conflate_immediate = false
    when /^<合成开始>/
      $game_temp.next_scene = "conflate"
      $game_temp.conflate_setting = false
      $game_temp.conflate_immediate = false
    when /^<合成完毕>/
      $game_temp.conflate_goods = []
      $game_temp.conflate_setting = false
      $game_temp.conflate_immediate = false
    end
    _cao_conflate_command_118
  end
  #--------------------------------------------------------------------------
  # ○ ショップの処理
  #--------------------------------------------------------------------------
  alias _cao_conflate_command_302 command_302
  def command_302
    if $game_temp.conflate_setting
      items = [$data_items, $data_weapons, $data_armors]
      while [302, 605].include?(@list[@index].code)
        kind = @list[@index].parameters[0]
        id = @list[@index].parameters[1]
        $game_temp.conflate_goods.push(items[kind][id]) if items[kind][id]
        @Index += 1
      end
      if $game_temp.conflate_immediate
        $game_temp.next_scene = "conflate"
        $game_temp.conflate_setting = false
        $game_temp.conflate_immediate = false
      end
      return false
    end
    _cao_conflate_command_302
  end
end

class Scene_Map
  #--------------------------------------------------------------------------
  # ○ 画面切り替えの実行
  #--------------------------------------------------------------------------
  alias _cao_conflate_update_scene_change update_scene_change
  def update_scene_change
    return if $game_player.moving?    # プレイヤーの移動中?
    if $game_temp.next_scene == "conflate"
      $game_temp.next_scene = nil
      $scene = Scene_Conflate.new
    else
      _cao_conflate_update_scene_change
    end
  end
end

class Window_Conflate < Window_Selectable
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x : ウィンドウの X 座標
  #     y : ウィンドウの Y 座標
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x+0, y+140, 240,360+105)
    self.index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # ● アイテムの取得
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    $game_temp.conflate_goods.each {|item| @data.push(item) }
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    draw_item_name(item, rect.x, rect.y, item.can_make?)
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

class Window_ConflateGold < Window_Base
  include CAO::Conflate
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x : ウィンドウの X 座標
  #     y : ウィンドウの Y 座標
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x+0, y+112+12+105, 304, 56)
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:gold])
    draw_currency_value($game_party.gold, 0, 0, self.width - 32)
  end
end

class Window_ConflateStatus < Window_Base
  include CAO::Conflate
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x : ウィンドウの X 座標
  #     y : ウィンドウの Y 座標
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x+0, y+120, 304, 224)
    @item = nil
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    return if @item == nil
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, self.contents.width, WLH, VOCAB[:material])
    @item.conflate_items.each_with_index do |(item,num), i|
      y = i * WLH + WLH
      draw_item_name(item, 8, y, num <= $game_party.item_number(item))
      self.contents.draw_text(8, y, self.contents.width-52, WLH, num, 2)
      text = sprintf("(%02d)", $game_party.item_number(item))
      self.contents.draw_text(8, y, self.contents.width-8, WLH, text, 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● アイテムの設定
  #     item : 新しいアイテム
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end

class Window_ConflateInfo < Window_Base
  include CAO::Conflate
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x : ウィンドウの X 座標
  #     y : ウィンドウの Y 座標
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x+0, y+112, 304, 80)
    @item = nil
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    return if @item == nil
    width = self.contents.width
    self.contents.font.color = system_color
    self.contents.draw_text(0, 0, width, WLH, VOCAB[:have])
    self.contents.draw_text(0, 0, width, WLH, VOCAB[:have_u], 2)
    self.contents.draw_text(0, WLH, width, WLH, VOCAB[:cost])
    self.contents.draw_text(0, WLH, width, WLH, Vocab::gold, 2)
    self.contents.font.color = normal_color
    width -= contents.text_size(Vocab::gold).width + 2
    self.contents.draw_text(0, 0, width, WLH, $game_party.item_number(@item), 2)
    self.contents.draw_text(0, WLH, width, WLH, @item.conflate_price, 2)
  end
  #--------------------------------------------------------------------------
  # ● アイテムの設定
  #     item : 新しいアイテム
  #--------------------------------------------------------------------------
  def item=(item)
    if @item != item
      @item = item
      refresh
    end
  end
end

class Scene_Conflate < Scene_Base
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    @viewport = Viewport.new(8,-56, 800, 700)
    @viewport.z = 100
    create_menu_background
    @help_window = Window_Help4.new
    @gold_window = Window_ConflateGold.new(240, 304)
    @gold_window.viewport = @viewport
    @conflate_window = Window_Conflate.new(0, 0)
    @conflate_window.viewport = @viewport
    @conflate_window.help_window = @help_window
    @info_window = Window_ConflateInfo.new(240, 0)
    @info_window.viewport = @viewport
    @material_window = Window_ConflateStatus.new(240, 80)
    @material_window.viewport = @viewport
    create_status_window
   
    if CAO::Conflate::FILE_SCENEBACK || CAO::Conflate::FILE_STATUSBACK
      @help_window.opacity = 0
      @gold_window.opacity = 0
      @conflate_window.opacity = 0
      @info_window.opacity = 0
      @material_window.opacity = 0
      @status_window.opacity = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @viewport.dispose
    @help_window.dispose
    @gold_window.dispose
    @conflate_window.dispose
    @info_window.dispose
    @material_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● メニュー画面系の背景作成
  #--------------------------------------------------------------------------
  def create_menu_background
    if CAO::Conflate::FILE_SCENEBACK
      @menuback_sprite = Sprite.new
      @menuback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_SCENEBACK)
    else
      super
    end
    if CAO::Conflate::FILE_STATUSBACK
      @statusback_sprite = Sprite.new(@viewport)
      @statusback_sprite.bitmap = Cache.system(CAO::Conflate::FILE_STATUSBACK)
    end
    update_menu_background
  end
  #--------------------------------------------------------------------------
  # ● メニュー画面系の背景解放
  #--------------------------------------------------------------------------
  def dispose_menu_background
    super
    @statusback_sprite.dispose if CAO::Conflate::FILE_STATUSBACK
  end
  #--------------------------------------------------------------------------
  # ● ショップステータスウィンドウの生成
  #--------------------------------------------------------------------------
  def create_status_window
    @status_window = Window_ShopStatus.new(544, 0)
    @status_window.x = 544
    @status_window.y = 120
    @status_window.height = 360+105
    @status_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 元の画面へ戻る
  #--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @viewport.update
    @help_window.update
    @gold_window.update
    @conflate_window.update
    @info_window.update
    @material_window.update
    @status_window.update
   
    @info_window.item = @conflate_window.item
    @material_window.item = @conflate_window.item
    @status_window.item = @conflate_window.item
   
    update_conflate_input
#    update_status_input
   
    if @open_status
      @viewport.ox += 16
      if @viewport.ox > @status_window.width
        @viewport.ox = @status_window.width
        @open_status = false
      end
    elsif @close_status
      @viewport.ox -= 16
      if @viewport.ox < 0
        @viewport.ox = 0
        @close_status = false
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 合成アイテムの入力更新
  #--------------------------------------------------------------------------
  def update_conflate_input
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      if @conflate_window.item.can_make?
        Sound.play_shop
        $game_party.lose_gold(@conflate_window.item.conflate_price)
        for item,n in @conflate_window.item.conflate_items
          $game_party.lose_item(item, n)
        end
        $game_party.gain_item(@conflate_window.item, 1)
        @gold_window.refresh
        @conflate_window.refresh
        @info_window.refresh
        @material_window.refresh
        @status_window.refresh
      else
        Sound.play_buzzer
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● ショップステータスの入力更新
  #--------------------------------------------------------------------------
#  def update_status_input
#   return unless CAO::Conflate::USE_SHOP_STATUS
  #  if Input.trigger?(Input::LEFT)
   #   @open_status = false
    #  @close_status = true
    #elsif Input.trigger?(Input::RIGHT)
     # @open_status = true
      #@close_status = false
    #end
  #end
end[/pre]

点评

↓哪里多了!哪里多了!→_→  发表于 2013-10-28 09:47
用这么多的外来脚本,你不怕游戏崩溃?  发表于 2013-10-28 09:20
长名公主玩家群:372588926 攻略娱乐应有尽有
了解更多新RM游戏,游戏制作请加入RPGmaker支援群:113622890

永无止境的旅程<

梦石
0
星屑
537
在线时间
1554 小时
注册时间
2012-6-19
回帖
1162

开拓者贵宾

发表于 2013-10-28 12:31:11 | 显示全部楼层
应该是 $scene = Scene_Conflate.new

评分

参与人数 1星屑 +80 收起 理由
Luciffer + 80 塞糖

查看全部评分

[url=https://rpg.blue/thread-389697-1-1.html]https://rpg.blue/https://rpg.blue/data/attachment/forum/201602/26/220128cfbxxs47xth4xkz4.jpg[/url]
&lt;font size=&quot;5&quot;&gt;[color=Green][url=https://rpg.blue/forum.php?mod=viewthread&amp;tid=396208&amp;extra=page%3D1][color=DeepSkyBlue]全新配套ACT系统,每周末一大更新,尽请期待。[/color][/url][/color]
回复

使用道具 举报

狂気の月兔

梦石
0
星屑
421
在线时间
1245 小时
注册时间
2009-4-7
回帖
866

贵宾

发表于 2013-10-28 16:56:49 | 显示全部楼层
在需要合成的物品道具防具的备注里面写上

  1. @CONFLATE[100, W1:2, I13:1, A17:1]
复制代码
这里面的 100 表示合成费用为 100金币.
W1:2  表示 武器里 ID 为1 的物品在合成的时候需要 2 把. 同理的还有 I 表示物品, A 表示防具

评分

参与人数 1星屑 +100 收起 理由
Luciffer + 100 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部