Project1
标题:
请问有VA的合成系统吗?
[打印本页]
作者:
lanxuanbaby
时间:
2015-7-6 11:14
标题:
请问有VA的合成系统吗?
有看到VX的和XP的,就是没看到VA的,请问有吗?0v0
求一个~~~~(ΦωΦ)
作者:
VIPArcher
时间:
2015-7-6 11:27
https://rpg.blue/home.php?mod=sp ... o=blog&id=12220
作者:
黄濑凉太
时间:
2015-7-6 11:36
①:
#==============================================================================
# ■ RGSS3 アイテム合成 ver 1.02
#------------------------------------------------------------------------------
# 配布元:
# 白の魔 http://izumiwhite.web.fc2.com/
#
# 利用規約:
# RPGツクールVX Aceの正規の登録者のみご利用になれます。
# 利用報告・著作権表示とかは必要ありません。
# 改造もご自由にどうぞ。
# 何か問題が発生しても責任は持ちません。
#==============================================================================
#--------------------------------------------------------------------------
# ★ 初期設定。
# 合成レシピ等の設定
#--------------------------------------------------------------------------
module WD_itemsynthesis_ini
Cost_view = true #費用(G)の表示(合成の費用が全て0Gの場合はfalseを推奨)
Category_i = false #カテゴリウィンドウに「アイテム」の項目を表示
Category_w = true #カテゴリウィンドウに「武器」の項目を表示
Category_a = false #カテゴリウィンドウに「防具」の項目を表示
Category_k = false #カテゴリウィンドウに「大事なもの」の項目を表示
I_recipe = [] #この行は削除しないこと
W_recipe = [] #この行は削除しないこと
A_recipe = [] #この行は削除しないこと
#以下、合成レシピ。
#例: I_recipe[3] = [100, ["I",1,1], ["W",2,1], ["A",2,2], ["A",3,1]]
#と記載した場合、ID3のアイテムの合成必要は、100G。
#必要な素材は、ID1のアイテム1個、ID2の武器1個、ID2の防具2個、ID3の防具1個
#となる。
#アイテムの合成レシピ
I_recipe[3] = [10, ["I",1,2]]
#I_recipe[3] = [100, ["I",1,1], ["I",2,1]]
#I_recipe[17] = [500, ["I",1,10]]
#武器の合成レシピ
W_recipe[3] = [150, ["I",2,1], ["W",2,1]]
W_recipe[6] = [150, ["I",2,1], ["W",5,1]]
#W_recipe[6] = [600, ["W",3,1], ["I",17,0]]
#防具の合成レシピ
A_recipe[2] = [40, ["A",1,2]]
#A_recipe[5] = [400, ["A",2,1], ["W",2,2], ["I",17,0]]
end
#==============================================================================
# ■ WD_itemsynthesis
#------------------------------------------------------------------------------
# アイテム合成用の共通メソッドです。
#==============================================================================
module WD_itemsynthesis
def i_recipe_switch_on(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
$game_system.i_rcp_sw[id] = true
end
def i_recipe_switch_off(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
$game_system.i_rcp_sw[id] = false
end
def i_recipe_switch_on?(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
return $game_system.i_rcp_sw[id]
end
def i_recipe_all_switch_on
for i in 1..$data_items.size
i_recipe_switch_on(i)
end
end
def i_recipe_all_switch_off
for i in 1..$data_items.size
i_recipe_switch_off(i)
end
end
def w_recipe_switch_on(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
$game_system.w_rcp_sw[id] = true
end
def w_recipe_switch_off(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
$game_system.w_rcp_sw[id] = false
end
def w_recipe_switch_on?(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
return $game_system.w_rcp_sw[id]
end
def w_recipe_all_switch_on
for i in 1..$data_weapons.size
w_recipe_switch_on(i)
end
end
def w_recipe_all_switch_off
for i in 1..$data_weapons.size
w_recipe_switch_off(i)
end
end
def a_recipe_switch_on(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
$game_system.a_rcp_sw[id] = true
end
def a_recipe_switch_off(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
$game_system.a_rcp_sw[id] = false
end
def a_recipe_switch_on?(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
return $game_system.a_rcp_sw[id]
end
def a_recipe_all_switch_on
for i in 1..$data_armors.size
a_recipe_switch_on(i)
end
end
def a_recipe_all_switch_off
for i in 1..$data_armors.size
a_recipe_switch_off(i)
end
end
def recipe_all_switch_on
i_recipe_all_switch_on
w_recipe_all_switch_on
a_recipe_all_switch_on
end
def recipe_all_switch_off
i_recipe_all_switch_off
w_recipe_all_switch_off
a_recipe_all_switch_off
end
end
class Game_Interpreter
include WD_itemsynthesis
end
class Game_System
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :i_rcp_sw
attr_accessor :w_rcp_sw
attr_accessor :a_rcp_sw
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias wd_orig_initialize004 initialize
def initialize
wd_orig_initialize004
@i_rcp_sw = []
@w_rcp_sw = []
@a_rcp_sw = []
end
end
#==============================================================================
# ■ Scene_ItemSynthesis
#------------------------------------------------------------------------------
# 合成画面の処理を行うクラスです。
#==============================================================================
class Scene_ItemSynthesis < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_dummy_window
create_number_window
create_status_window
create_material_window
create_list_window
create_category_window
create_gold_window
create_change_window
end
def create_background
@background_sprite = Spriteset_Map.new
end
#--------------------------------------------------------------------------
# ● ゴールドウィンドウの作成
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = @help_window.height
@gold_window.hide
end
#--------------------------------------------------------------------------
# ● 切り替え表示ウィンドウの作成
#--------------------------------------------------------------------------
def create_change_window
wx = 0
wy = @gold_window.y
ww = Graphics.width - @gold_window.width
wh = @gold_window.height
@change_window = Window_ItemSynthesisChange.new(wx, wy, ww, wh)
@change_window.viewport = @viewport
@change_window.hide
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウの作成
#--------------------------------------------------------------------------
def create_dummy_window
wy = @help_window.y + @help_window.height + 48
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● 個数入力ウィンドウの作成
#--------------------------------------------------------------------------
def create_number_window
wy = @dummy_window.y
wh = @dummy_window.height
@number_window = Window_ItemSynthesisNumber.new(0, wy, wh)
@number_window.viewport = @viewport
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@status_window = Window_ShopStatus.new(wx, wy, ww, wh)
@status_window.viewport = @viewport
@status_window.hide
end
#--------------------------------------------------------------------------
# ● 素材ウィンドウの作成
#--------------------------------------------------------------------------
def create_material_window
wx = @number_window.width
wy = @dummy_window.y
ww = Graphics.width - wx
wh = @dummy_window.height
@material_window = Window_ItemSynthesisMaterial.new(wx, wy, ww, wh)
@material_window.viewport = @viewport
@material_window.hide
@number_window.material_window = @material_window
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウの作成
#--------------------------------------------------------------------------
def create_list_window
wy = @dummy_window.y
wh = @dummy_window.height
@list_window = Window_ItemSynthesisList.new(0, wy, wh)
@list_window.viewport = @viewport
@list_window.help_window = @help_window
@list_window.status_window = @status_window
@list_window.material_window = @material_window
@list_window.hide
@list_window.set_handler(:ok, method(:on_list_ok))
@list_window.set_handler(:cancel, method(:on_list_cancel))
@list_window.set_handler(:change_window, method(:on_change_window))
end
#--------------------------------------------------------------------------
# ● カテゴリウィンドウの作成
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_ItemSynthesisCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.y = @help_window.height
@category_window.activate
@category_window.item_window = @list_window
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 合成アイテムリストウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate_list_window
@list_window.money = money
@list_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[決定]
#--------------------------------------------------------------------------
def on_list_ok
@item = @list_window.item
@list_window.hide
@number_window.set(@item, max_buy, buying_price, currency_unit)
@number_window.show.activate
end
#--------------------------------------------------------------------------
# ● 合成[キャンセル]
#--------------------------------------------------------------------------
def on_list_cancel
@category_window.activate
@category_window.show
@dummy_window.show
@list_window.hide
@status_window.hide
@status_window.item = nil
@material_window.hide
@material_window.set(nil, nil)
@gold_window.hide
@change_window.hide
@help_window.clear
end
#--------------------------------------------------------------------------
# ● 表示切替
#--------------------------------------------------------------------------
def on_change_window
if @status_window.visible
@status_window.hide
@material_window.show
else
@status_window.show
@material_window.hide
end
end
#--------------------------------------------------------------------------
# ● カテゴリ[決定]
#--------------------------------------------------------------------------
def on_category_ok
activate_list_window
@gold_window.show
@change_window.show
@material_window.show
@category_window.hide
@list_window.select(0)
end
#--------------------------------------------------------------------------
# ● 個数入力[決定]
#--------------------------------------------------------------------------
def on_number_ok
Sound.play_shop
do_syntetic(@number_window.number)
end_number_input
@gold_window.refresh
end
#--------------------------------------------------------------------------
# ● 個数入力[キャンセル]
#--------------------------------------------------------------------------
def on_number_cancel
Sound.play_cancel
end_number_input
end
#--------------------------------------------------------------------------
# ● 合成の実行
#--------------------------------------------------------------------------
def do_syntetic(number)
$game_party.lose_gold(number * buying_price)
$game_party.gain_item(@item, number)
@recipe = @list_window.recipe(@item)
for i in
[email protected]
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
$game_party.lose_item(item, num*number)
end
end
#--------------------------------------------------------------------------
# ● 個数入力の終了
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_list_window
end
#--------------------------------------------------------------------------
# ● 最大購入可能個数の取得
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
@recipe = @list_window.recipe(@item)
for i in
[email protected]
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if num > 0
max_buf = $game_party.item_number(item)/num
else
max_buf = 999
end
max = [max, max_buf].min
end
buying_price == 0 ? max : [max, money / buying_price].min
end
#--------------------------------------------------------------------------
# ● 所持金の取得
#--------------------------------------------------------------------------
def money
@gold_window.value
end
#--------------------------------------------------------------------------
# ● 通貨単位の取得
#--------------------------------------------------------------------------
def currency_unit
@gold_window.currency_unit
end
#--------------------------------------------------------------------------
# ● 合成費用の取得
#--------------------------------------------------------------------------
def buying_price
@list_window.price(@item)
end
end
#==============================================================================
# ■ Window_ItemSynthesisList
#------------------------------------------------------------------------------
# 合成画面で、合成可能なアイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_ItemSynthesisList < Window_Selectable
include WD_itemsynthesis
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :status_window # ステータスウィンドウ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@shop_goods = []
@shop_recipes = []
for i in 1..WD_itemsynthesis_ini::I_recipe.size
recipe = WD_itemsynthesis_ini::I_recipe[i]
if recipe
good = [0, i, recipe[0]]
if i_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
for i in 1..WD_itemsynthesis_ini::W_recipe.size
recipe = WD_itemsynthesis_ini::W_recipe[i]
if recipe
good = [1, i, recipe[0]]
if w_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
for i in 1..WD_itemsynthesis_ini::A_recipe.size
recipe = WD_itemsynthesis_ini::A_recipe[i]
if recipe
good = [2, i, recipe[0]]
if a_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
@money = 0
refresh
select(0)
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 304
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
@data[index]
end
#--------------------------------------------------------------------------
# ● 所持金の設定
#--------------------------------------------------------------------------
def money=(money)
@money = money
refresh
end
#--------------------------------------------------------------------------
# ● 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● 合成費用を取得
#--------------------------------------------------------------------------
def price(item)
@price[item]
end
#--------------------------------------------------------------------------
# ● 合成可否を取得
#--------------------------------------------------------------------------
def enable?(item)
@makable[item]
end
#--------------------------------------------------------------------------
# ● レシピを取得
#--------------------------------------------------------------------------
def recipe(item)
@recipe[item]
end
#--------------------------------------------------------------------------
# ● アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def have_mat?(recipe)
flag = true
if @money >= recipe[0]
for i in 1...recipe.size
kind = recipe[i][0]
id = recipe[i][1]
num = recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if $game_party.item_number(item) < [num, 1].max
flag = false
end
end
else
flag = false
end
return flag
end
#--------------------------------------------------------------------------
# ● カテゴリの設定
#--------------------------------------------------------------------------
def category=(category)
return if @category == category
@category = category
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● アイテムをリストに含めるかどうか
#--------------------------------------------------------------------------
def include?(item)
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item?
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
when :key_item
item.is_a?(RPG::Item) && item.key_item?
else
false
end
end
#--------------------------------------------------------------------------
# ● アイテムリストの作成
#--------------------------------------------------------------------------
def make_item_list
@data = []
@price = {}
@makable = {}
@recipe = {}
for i in 0...@shop_goods.size
goods = @shop_goods[i]
recipe = @shop_recipes[i]
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
if include?(item)
@data.push(item)
@price[item] = goods[2]
@makable[item] = have_mat?(recipe)
@recipe[item] = recipe
end
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_text(rect, price(item), 2) if WD_itemsynthesis_ini::Cost_view
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの設定
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
end
#--------------------------------------------------------------------------
# ● 素材ウィンドウの設定
#--------------------------------------------------------------------------
def material_window=(material_window)
@material_window = material_window
call_update_help
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item) if @help_window
@status_window.item = item if @status_window
@material_window.set(item, recipe(item)) if @material_window
end
#--------------------------------------------------------------------------
# ● ←→ ボタン(表示切替)が押されたときの処理
#--------------------------------------------------------------------------
def process_change_window
Sound.play_cursor
Input.update
call_handler(:change_window)
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング処理
#--------------------------------------------------------------------------
def process_handling
super
if active
return process_change_window if handle?(:change_window) && Input.trigger?(:X)
return process_change_window if handle?(:change_window) && Input.trigger?(:Y)
end
end
end
#==============================================================================
# ■ Window_ItemSynthesisMaterial
#------------------------------------------------------------------------------
# 合成画面で、合成に必要な素材を表示するウィンドウです。
#==============================================================================
class Window_ItemSynthesisMaterial < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_possession(4, 0)
draw_material_info(0, line_height * 2)
end
#--------------------------------------------------------------------------
# ● アイテムの設定
#--------------------------------------------------------------------------
def set(item, recipe)
@item = item
@recipe = recipe
@make_number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 作成個数の設定
#--------------------------------------------------------------------------
def set_num(make_number)
@make_number = make_number
refresh
end
#--------------------------------------------------------------------------
# ● 所持数の描画
#--------------------------------------------------------------------------
def draw_possession(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(system_color)
draw_text(rect, Vocab::Possession)
change_color(normal_color)
draw_text(rect, $game_party.item_number(@item), 2)
end
#--------------------------------------------------------------------------
# ● 素材情報の描画
#--------------------------------------------------------------------------
def draw_material_info(x, y)
rect = Rect.new(x, y, contents.width, line_height)
change_color(system_color)
contents.font.size = 18
draw_text(rect, "需要材料", 0)
if @recipe
for i in
[email protected]
kind = @recipe[i][0]
id = @recipe[i][1]
num = @recipe[i][2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
rect = Rect.new(x, y + line_height*i, contents.width, line_height)
enabled = true
enabled = false if [num*@make_number, 1].max > $game_party.item_number(item)
draw_item_name(item, rect.x, rect.y, enabled)
change_color(normal_color, enabled)
if num > 0
draw_text(rect, "#{num*@make_number}/#{$game_party.item_number(item)}", 2)
end
end
end
change_color(normal_color)
contents.font.size = 24
end
end
#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
# 合成画面で、合成するアイテムの個数を入力するウィンドウです。
#==============================================================================
class Window_ItemSynthesisNumber < Window_ShopNumber
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_item_name(@item, 0, item_y)
draw_number
draw_total_price if WD_itemsynthesis_ini::Cost_view
end
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def material_window=(material_window)
@material_window = material_window
call_update_help
end
#--------------------------------------------------------------------------
# ● 作成個数の変更
#--------------------------------------------------------------------------
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
call_update_help #追加
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def call_update_help
@material_window.set_num(@number) if @material_window
end
end
#==============================================================================
# ■ Window_ItemSynthesisCategory
#------------------------------------------------------------------------------
# 合成画面で、通常アイテムや装備品の分類を選択するウィンドウです。
#==============================================================================
class Window_ItemSynthesisCategory < Window_ItemCategory
#--------------------------------------------------------------------------
# ● 桁数の取得
#--------------------------------------------------------------------------
def col_max
i = 0
i += 1 if WD_itemsynthesis_ini::Category_i
i += 1 if WD_itemsynthesis_ini::Category_w
i += 1 if WD_itemsynthesis_ini::Category_a
i += 1 if WD_itemsynthesis_ini::Category_k
return i
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::item, :item) if WD_itemsynthesis_ini::Category_i
add_command("强化", :weapon) if WD_itemsynthesis_ini::Category_w
add_command(Vocab::armor, :armor) if WD_itemsynthesis_ini::Category_a
add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
end
end
#==============================================================================
# ■ Window_ItemSynthesisNumber
#------------------------------------------------------------------------------
# 合成画面で、切替を表示するウィンドウです。
#==============================================================================
class Window_ItemSynthesisChange < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
text = "X:返回列表"
draw_text(0, 0, contents_width, line_height, text, 1)
end
end
复制代码
②:
#encoding:utf-8
#==============================================================================
#BY:asd11000
#每添加一个制造的类型,最上面的类别菜单就会多一项。
#
#添加类型的方法是:
#$game_party.add_cook_type(类别名称,类别介绍, 类别状态-默认false)
#
#举例:
#$game_party.add_cook_type("制药","调配药品", true)
#
#添加配方的方法:
#$game_party.add_cookbook(配方名称, 配方介绍, 配方类别名称,材料的二维数组,产出物的二维数组,配方状态默认为true)
#
#举例:
#$game_party.add_cookbook("初级补血药水", "制作初级补血药水", "制药",[[18,2],[3,4],[2,5]],[[1,1],[44,5]],true)
#
#调用窗口的方法:SceneManager.call(Scene_Cook)
#==============================================================================
#==============================================================================
# ■ Cookbook_Type
#------------------------------------------------------------------------------
# 食谱类型类。
#==============================================================================
class Cookbook_Type
attr_reader :index
attr_reader :name
attr_reader :description
attr_reader :enabled
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(index, name, description, enabled = false)
@Index = index
@name = name
@description = description
@enabled = enabled
end
def enable(en)
@enabled = en
end
end
#==============================================================================
# ■ Cookbook
#------------------------------------------------------------------------------
# 食谱类。本类在 Game_Task 类的内部使用。
# 食谱属性:食谱序号,食谱名称,食谱类型,食谱介绍,原料,成品
#==============================================================================
class Cookbook
attr_reader :index
attr_reader :name
attr_reader :description
attr_reader :type
attr_reader :input
attr_reader :output
attr_reader :enabled
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(index, name, description, type, input, output, enabled = true)
@Index = index
@name = name
@description = description
@type = type
@input = input
@output = output
@enabled = enabled
end
def enable(en)
@enabled = en
end
#--------------------------------------------------------------------------
# ● 查询列表中的物品
#--------------------------------------------------------------------------
def in_list?(item, list)
list.each do |arr|
return true if arr[0] == item.id
end
return false
end
#--------------------------------------------------------------------------
# ● 查询是否是材料列表中的物品
#--------------------------------------------------------------------------
def resource?(item)
in_list?(item, @input)
end
#--------------------------------------------------------------------------
# ● 查询是否是产出列表中的物品
#--------------------------------------------------------------------------
def output?(item)
in_list?(item, @output)
end
#--------------------------------------------------------------------------
# ● 查询材料需求量
#--------------------------------------------------------------------------
def amount(item, i)
if i == 0
@input.each do |arr|
return arr[1] if arr[0] == item.id
end
else
@output.each do |arr|
return arr[1] if arr[0] == item.id
end
end
return 0
end
#--------------------------------------------------------------------------
# ● 查询材料是否足够
#--------------------------------------------------------------------------
def enough?
input.each do |arr|
return false if $data_items[arr[0]] && arr[1] > $game_party.item_number($data_items[arr[0]])
end
return true
end
#--------------------------------------------------------------------------
# ● 查询某件材料是否足够
#--------------------------------------------------------------------------
def item_enough?(item)
input.each do |arr|
return false if arr[0] == item.id && arr[1] > $game_party.item_number(item)
end
return true
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
alias old_old_init initialize
def initialize
old_old_init
@cook_types = []
@cookbooks = []
end
#--------------------------------------------------------------------------
# ● 添加新的食谱类型
#--------------------------------------------------------------------------
def add_cook_type(n, d, en)
@cook_types.push(Cookbook_Type.new(@cook_types.size, n, d, en)) if !have_cook_type?(n)
end
#--------------------------------------------------------------------------
# ● 添加新的食谱
#--------------------------------------------------------------------------
def add_cookbook(n, d, type, input, output, en)
if !have_cookbook?(n) && have_cook_type?(type)
@cookbooks.push(Cookbook.new(@cookbooks.size, n, d, type, input, output, en))
end
end
#--------------------------------------------------------------------------
# ● 判断名称为n的食谱类型是否存在
#--------------------------------------------------------------------------
def have_cook_type?(n)
@cook_types.each do |x|
return true if x.name == n
end
return false
end
#--------------------------------------------------------------------------
# ● 判断名称为n的食谱是否存在
#--------------------------------------------------------------------------
def have_cookbook?(n)
@cookbooks.each do |x|
return true if x.name == n
end
return false
end
#--------------------------------------------------------------------------
# ● 返回食谱类型列表
#--------------------------------------------------------------------------
def cook_types
return @cook_types
end
#--------------------------------------------------------------------------
# ● 返回食谱列表
#--------------------------------------------------------------------------
def cookbooks(type = nil)
return @cookbooks if type == nil
arr = []
@cookbooks.each do |x|
arr.push(x) if x.type == type
end
return arr
end
#--------------------------------------------------------------------------
# ● 更改序号为i的食谱类型的使用状态
#--------------------------------------------------------------------------
def set_cook_type(i, en)
@cook_types[i].enable(en)
end
#--------------------------------------------------------------------------
# ● 更改序号为i的食谱的使用状态
#--------------------------------------------------------------------------
def set_cookbook(i, en)
@cookbooks[i].enable(en)
end
#--------------------------------------------------------------------------
# ● 返回食谱类型数目
#--------------------------------------------------------------------------
def cook_types_size
return @cook_types.size
end
#--------------------------------------------------------------------------
# ● 查询名称为n的食谱类型的描述
#--------------------------------------------------------------------------
def cook_type_description(n)
@cook_types.each do |x|
return x.description if x.name == n
end
return ""
end
end
#==============================================================================
# ■ Scene_Cook
#------------------------------------------------------------------------------
# 烹饪画面
#==============================================================================
class Scene_Cook < Scene_ItemBase
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_category_window
create_cookbook_window
create_description_window
create_needs_window
end
#--------------------------------------------------------------------------
# ● 生成分类窗口
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_CookCategory.new
@category_window.viewport = @viewport
@category_window.y = 0
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 生成食谱窗口
#--------------------------------------------------------------------------
def create_cookbook_window
wy = @category_window.height
wh = Graphics.height - wy
@item_window = Window_CookList.new(0, wy, Graphics.width*0.5 , wh)
@item_window.viewport = @viewport
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@category_window.item_window = @item_window
end
#--------------------------------------------------------------------------
# ● 生成描述窗口
#--------------------------------------------------------------------------
def create_description_window
wy = @category_window.height
@help_window = Window_Description.new(Graphics.width*0.5, wy)
@help_window.viewport = @viewport
@item_window.help_window = @help_window
@category_window.help_window = @help_window
end
#--------------------------------------------------------------------------
# ● 生成材料窗口
#--------------------------------------------------------------------------
def create_needs_window
wy = @category_window.height + @help_window.height
wh = Graphics.height - wy
@needs_window = Window_NeedsList.new(Graphics.width*0.5, wy, Graphics.width*0.5 , wh)
#@item_window.viewport = @viewport
@item_window.needs_window = @needs_window
end
#--------------------------------------------------------------------------
# ● 分类“确定”
#--------------------------------------------------------------------------
def on_category_ok
@item_window.activate
@item_window.select_last
end
#--------------------------------------------------------------------------
# ● 食谱“确定”
#--------------------------------------------------------------------------
def on_item_ok
#$game_party.last_item.object = item
cook
end
#--------------------------------------------------------------------------
# ● 食谱“取消”
#--------------------------------------------------------------------------
def on_item_cancel
@item_window.unselect
@category_window.activate
end
#--------------------------------------------------------------------------
# ● 烹饪
#--------------------------------------------------------------------------
def cook
if item.enough?
play_se_for_item
use_item
@needs_window.refresh
@item_window.refresh
activate_item_window
end
end
#--------------------------------------------------------------------------
# ● 播放制作声效
#--------------------------------------------------------------------------
def play_se_for_item
Sound.play_recovery
end
#--------------------------------------------------------------------------
# ● 使用食谱
#--------------------------------------------------------------------------
def use_item
#super
#@item_window.redraw_current_item
$data_items.each do |it|
if it && !it.name.empty?
$game_party.gain_item(it,-item.amount(it,0)) if item.resource?(it)
$game_party.gain_item(it,item.amount(it,1)) if item.output?(it)
end
end
end
end
#==============================================================================
# ■ Window_CookCategory
#------------------------------------------------------------------------------
# 烹饪画面中,显示食谱类型的窗口。
#==============================================================================
class Window_CookCategory < Window_HorzCommand
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :item_window
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0)
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
Graphics.width
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return $game_party.cook_types_size
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
#@item_window.category = current_symbol if @item_window
@item_window.category = current_data[:name] if @item_window
end
#--------------------------------------------------------------------------
# ● 生成食谱类型列表
#--------------------------------------------------------------------------
def make_command_list
$game_party.cook_types.each do |t|
add_command(t.name, t.index, t.enabled)
end
end
#--------------------------------------------------------------------------
# ● 设置食谱列表窗口
#--------------------------------------------------------------------------
def item_window=(item_window)
@item_window = item_window
update
end
#--------------------------------------------------------------------------
# ● 更新帮助内容
#--------------------------------------------------------------------------
def update_help
@help_window.set_text($game_party.cook_type_description(current_data[:name]))
end
end
#==============================================================================
# ■ Window_CookList
#------------------------------------------------------------------------------
# 任务画面中,显示已获得任务的窗口。
#==============================================================================
class Window_CookList < Window_Selectable
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :needs_window
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@data = []
@category = $game_party.cook_types_size > 0 ? $game_party.cook_types[0].name : nil
refresh
end
#--------------------------------------------------------------------------
# ● 设置分类
#--------------------------------------------------------------------------
def category=(category)
return if @category == category
@category = category
refresh
self.oy = 0
end
#--------------------------------------------------------------------------
# ● 设置材料窗口
#--------------------------------------------------------------------------
def needs_window=(needs_window)
@needs_window = needs_window
update
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# ● 获取项目数
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● 获取食谱
#--------------------------------------------------------------------------
def item
@data && index >= 0 ? @data[index] : nil
end
#--------------------------------------------------------------------------
# ● 获取选择食谱的有效状态
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● 查询此食谱是否可用
#--------------------------------------------------------------------------
def enable?(item)
item.enabled && item.enough?
end
#--------------------------------------------------------------------------
# ● 生成食谱列表
#--------------------------------------------------------------------------
def make_item_list
@data = $game_party.cookbooks(@category)
end
#--------------------------------------------------------------------------
# ● 返回上一个选择的位置
#--------------------------------------------------------------------------
def select_last
select(0)
end
#--------------------------------------------------------------------------
# ● 绘制项目
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y, enable?(item))
end
end
#--------------------------------------------------------------------------
# ● 绘制名称
# enabled : 有效的标志。false 的时候使用半透明效果绘制
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true, width = 300)
return unless item
text = item.name
text += "[材料不足]" if !item.enough?
change_color(normal_color, enabled)
draw_text(x, y, width, line_height, text)
end
#--------------------------------------------------------------------------
# ● 更新帮助内容
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item)
end
#--------------------------------------------------------------------------
# ● 更新食谱清单
#--------------------------------------------------------------------------
def update_needslist
@needs_window.set_item(item)
end
#--------------------------------------------------------------------------
# ● 调用帮助窗口的更新方法
#--------------------------------------------------------------------------
def call_update_help
update_help if @help_window
update_needslist if @needs_window
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
end
#==============================================================================
# ■ Window_Description
#------------------------------------------------------------------------------
# 显示食谱的说明的窗口
#==============================================================================
class Window_Description < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, Graphics.width*0.5, fitting_height(4))
end
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 设置食谱的介绍
#--------------------------------------------------------------------------
def set_item(item)
set_text(item ? item.description : "")
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(4, 0, @text)
end
end
#==============================================================================
# ■ Window_NeedsList
#------------------------------------------------------------------------------
# 烹饪画面中,显示食谱所需材料的窗口。
#==============================================================================
class Window_NeedsList < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@category = :item
@cookbook = nil
@data = []
refresh
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return 1
end
#--------------------------------------------------------------------------
# ● 获取项目数
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
@data && index >= 0 ? @data[index] : nil
end
#--------------------------------------------------------------------------
# ● 查询列表中是否含有此物品
#--------------------------------------------------------------------------
def include?(item)
item.is_a?(RPG::Item) && !item.key_item?
end
#--------------------------------------------------------------------------
# ● 获取选择食谱的有效状态
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● 查询此食谱是否可用
#--------------------------------------------------------------------------
def enable?(item)
$game_party.usable?(item) && @cookbook.item_enough?(item)
end
#--------------------------------------------------------------------------
# ● 生成物品列表
#--------------------------------------------------------------------------
def make_item_list
@data = []
return if @cookbook== nil
tmp1 = []
tmp2 = []
$data_items.each do |item|
tmp1.push([item, 0]) if item && !item.name.empty? && @cookbook.resource?(item)
tmp2.push([item, 1]) if item && !item.name.empty? && @cookbook.output?(item)
end
if tmp1.size > 0 && tmp2.size > 0
@data.push(["需要材料:",0])
@data += tmp1
@data.push(["可以获得:",1])
@data += tmp2
end
end
#--------------------------------------------------------------------------
# ● 返回上一个选择的位置
#--------------------------------------------------------------------------
def select_last
select(0)
end
#--------------------------------------------------------------------------
# ● 绘制项目
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
if item[0].is_a?(RPG::Item)
draw_item_name(item, rect.x, rect.y, enable?(item[0]))
draw_item_number(rect, item[0])
else
draw_input_output(item, rect.x, rect.y)
end
end
end
#--------------------------------------------------------------------------
# ● 绘制物品名称
# enabled : 有效的标志。false 的时候使用半透明效果绘制
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true, width = 172)
return unless item
text = item[0].name + "*" + String(@cookbook.amount(item[0], item[1]))
draw_icon(item[0].icon_index, x, y, enabled)
change_color(normal_color, enable?(item[0]))
draw_text(x + 24, y, width, line_height, text)
end
#--------------------------------------------------------------------------
# ● 绘制输入和产出
#--------------------------------------------------------------------------
def draw_input_output(item, x, y, enabled = false, width = 172)
return unless item
if item[1] == 0
text = "[需要]"
else
text = "[可以获得]"
end
change_color(normal_color, @cookbook.enough?)
draw_text(x , y, width, line_height, text)
end
#--------------------------------------------------------------------------
# ● 绘制物品个数
#--------------------------------------------------------------------------
def draw_item_number(rect, item)
draw_text(rect, sprintf("现有%2d", $game_party.item_number(item)), 2)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● 设置食谱的材料
#--------------------------------------------------------------------------
def set_item(item)
@cookbook = item
refresh
end
end
复制代码
作者:
lanxuanbaby
时间:
2015-7-6 11:48
VIPArcher 发表于 2015-7-6 11:27
https://rpg.blue/home.php?mod=space&uid=291206&do=blog&id=12220
呃,有点看不太懂呢。
左上角的是自己拥有的物品吗?
那么右上角是什么呢
还有左下角和右下角是什么?0v0
作者:
kymcz79608
时间:
2015-10-13 00:54
為什麼用了之後圖片的CG圖跑不出來
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1