def self.gainequip(id,params = nil)
$game_party.gain_item(Equipplus.getnewequip($data_weapons[id],params),1,true)
end
end
if $商店随机 == true
class Scene_Shop < Scene_MenuBase
def do_buy(number)
$game_party.lose_gold(number * buying_price)
if @item.is_a?(RPG::EquipItem)
x = number
loop do
break if x <= 0
x -= 1
$game_party.gain_item(Equipplus.getnewequip(@item), 1)
end
else
$game_party.gain_item(@item, number)
end
end
end
end
if $战斗随机 == true
module BattleManager
def self.gain_drop_items
# 遍历战斗中掉落物品列表
$game_troop.make_drop_items.each do |item|
# 判断物品是否为装备物品
# 如果是装备物品,调用获取具有随机属性的新装备的方法
# 如果不是装备物品,直接使用原始物品
item.is_a?(RPG::EquipItem) ? xitem = Equipplus.getnewequip(item) : xitem = item
# 将物品添加到角色的物品列表中,并显示获得物品的消息
$game_party.gain_item(xitem, 1)
$game_message.add(sprintf(Vocab::ObtainItem, xitem.name))
end
# 等待消息的显示完成
wait_for_message
end
end
end
##-------------------------
##---------------------------------------
class RPG::EquipItem < RPG::BaseItem
alias old initialize
def initialize
old
@paramsplus #前缀
end
attr_accessor :paramsplus
end
[/pre]
下面是合成代码[pre lang="ruby" file="合成"]#==============================================================================
# ■ RGSS3 物品合成 ver 1.04
#------------------------------------------------------------------------------
# 配布元:
# 白の魔 http://izumiwhite.web.fc2.com/
#
# 利用規約:
# RPGツクールVX Aceの正規の登録者のみご利用になれます。
# 利用報告?著作権表示とかは必要ありません。
# 改造もご自由にどうぞ。
# 何か問題が発生しても責任は持ちません。
#==============================================================================
=begin
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
@recipe = @list_window.recipe(@item)
for i in [email protected]
kind = @recipe[0]
id = @recipe[1]
num = @recipe[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[0]
id = @recipe[1]
num = @recipe[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
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
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
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
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[0]
id = recipe[1]
num = recipe[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
recipe = @shop_recipes
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) && $game_party.item_number(item) < $game_party.max_item_number(item)
@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
#--------------------------------------------------------------------------
# ● Z ボタン(表示切替)が押されたときの処理
#--------------------------------------------------------------------------
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?(:Z)
# return process_change_window if handle?(:change_window) && Input.trigger?(:Z)
end
end
end
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("普通物品", :item) if WD_itemsynthesis_ini::Category_i
add_command("人类装备", :weapon) if WD_itemsynthesis_ini::Category_w
add_command("战车装备", :armor) if WD_itemsynthesis_ini::Category_a
add_command("特殊物品", :key_item) if WD_itemsynthesis_ini::Category_k
end
end