| 赞 | 61 |
| VIP | |
| 好人卡 | |
| 积分 | 86 |
| 经验 | |
| 最后登录 | 2026-10-2 |
| 在线时间 | 3858 小时 |
漾夕☽星化残月☾
- 梦石
- 0
- 星屑
- 8611
- 在线时间
- 3858 小时
- 注册时间
- 2015-5-12
- 回帖
- 2022

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
](;´Д`)找到了一个比较完美的锻造屋系统的脚本、
但是把它移植后会直接闪退、我也找不到关键函数、求大大帮忙看一下闪退的关键语句、以及有没有什么解决方法、、、
画面/合成屋
=begin
=合成屋 by Foo
==更新履歴
Date Version Author Comment
=end
#==============================================================================
# ■ NWConst::Synthesize
#==============================================================================
module NWConst::Synthesize
CONFIRM_TEXT = "%sを精製します。本当によろしいですか?"
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 合成屋の呼び出し
#--------------------------------------------------------------------------
def call_synthesize(shop_id)
SceneManager.call(Scene_Synthesize)
SceneManager.scene.prepare(shop_id)
Fiber.yield
end
end
#==============================================================================
# ■ Window_SynthesizeCommand
#==============================================================================
class Window_SynthesizeCommand < Window_HorzCommand
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0)
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
480
end
#--------------------------------------------------------------------------
# ● 桁数の取得
#--------------------------------------------------------------------------
def col_max
return 2
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command("合成する", :synthesize)
add_command("やめる", :cancel)
end
end
#==============================================================================
# ■ Window_SynthesizeStatus
#==============================================================================
class Window_SynthesizeStatus < Window_Base
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(304, 120, window_width, 360)
@item = nil
@befores = nil
@page_index = 0
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 336
end
#--------------------------------------------------------------------------
# ● アイテムのセット
#--------------------------------------------------------------------------
def set_item(after_item, befores)
@item = after_item
@befores = befores
@page_index = 0
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
contents.clear
return if @item.nil?
draw_possession(4, 0)
return if @item.is_a?(RPG::Item)
draw_button(0, contents.height - (line_height * 2))
method_name = draw_methods[@page_index][:name]
index = draw_methods[@page_index][:index]
send(method_name, 0, 28, index)
end
#--------------------------------------------------------------------------
# ● 描画命令メソッド配列の取得
#--------------------------------------------------------------------------
def draw_methods
methods = []
methods.push({:name => :draw_before_items, :index => 0})
param_page_max.times{|i| methods.push({:name => :draw_params, :index => i})}
enchant_page_max.times{|i| methods.push({:name => :draw_enchants, :index => i})}
return methods
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_button(x, y)
rect = Rect.new(x, y, contents.width, line_height)
change_color(system_color)
if 1 < page_max
draw_text(rect, Help.shop_equip_change)
draw_text(rect, "#{@page_index + 1}/#{page_max}", 2)
end
rect.y += line_height
draw_text(rect, Help.shop_param_compare)
end
#--------------------------------------------------------------------------
# ● 必要素材の描画
#--------------------------------------------------------------------------
def draw_before_items(x, y, dummy)
rect = Rect.new(x, y, contents.width, line_height)
change_color(system_color)
draw_text(rect, "必要素材")
rect.y += line_height + 2
change_color(normal_color)
@befores.each{|before|
case before[:kind]
when :I; item = $data_items[before[:id]]
when :W; item = $data_weapons[before[:id]]
when :A; item = $data_armors[before[:id]]
end
party_num = $game_party.item_number(item)
need_num = before[:num]
draw_item_name(item, rect.x, rect.y, need_num <= party_num)
draw_text(rect, "#{need_num}/#{party_num}", 2)
rect.y += line_height
}
end
#--------------------------------------------------------------------------
# ● 基礎性能の描画
#--------------------------------------------------------------------------
def draw_params(x, y, index)
rect = Rect.new(x, y, contents.width, line_height)
param_names = @item.param_names[index * NWConst::Shop::STATUS_MAX, NWConst::Shop::STATUS_MAX]
change_color(system_color)
draw_text(rect, "基礎性能")
rect.y += line_height + 2
change_color(normal_color)
param_names.each{|name|
draw_text(rect, name)
rect.y += line_height
}
end
#--------------------------------------------------------------------------
# ● 特殊効果の描画
#--------------------------------------------------------------------------
def draw_enchants(x, y, index)
rect = Rect.new(x, y, contents.width, line_height)
enchant_names = @item.enchant_names[index * NWConst::Shop::STATUS_MAX, NWConst::Shop::STATUS_MAX]
change_color(system_color)
draw_text(rect, "特殊効果")
rect.y += line_height + 2
change_color(normal_color)
enchant_names.each{|name|
draw_text(rect, name)
rect.y += line_height
}
end
#--------------------------------------------------------------------------
# ● 基礎性能最大ページ数の取得
#--------------------------------------------------------------------------
def param_page_max
return (@item.param_names.size - 1) / NWConst::Shop::STATUS_MAX + 1
end
#--------------------------------------------------------------------------
# ● 特殊効果最大ページ数の取得
#--------------------------------------------------------------------------
def enchant_page_max
return (@item.enchant_names.size - 1) / NWConst::Shop::STATUS_MAX + 1
end
#--------------------------------------------------------------------------
# ● 最大ページ数の取得
#--------------------------------------------------------------------------
def page_max
return 1 + param_page_max + enchant_page_max
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
update_page
end
#--------------------------------------------------------------------------
# ● ページの更新
#--------------------------------------------------------------------------
def update_page
if visible && @item.is_a?(RPG::EquipItem) && page_max > 1
if Input.trigger?(:RIGHT)
@page_index = (@page_index + 1) % page_max
refresh
elsif Input.trigger?(:LEFT)
@page_index = ((@page_index - 1) + page_max) % page_max
refresh
end
end
end
end
#==============================================================================
# ■ Window_SynthesizeLineUp
#==============================================================================
class Window_SynthesizeLineUp < Window_Selectable
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :status_window # ステータスウィンドウ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(shop_id)
super(0, 120, window_width, 360)
@shop_id = shop_id
@Money = 0
refresh
select(0)
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 304
end
#--------------------------------------------------------------------------
# ● ウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate
@compare_window.hide.activate if @compare_window
super
end
#--------------------------------------------------------------------------
# ● ウィンドウの非アクティブ化
#--------------------------------------------------------------------------
def deactivate
@compare_window.hide.deactivate if @compare_window
super
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
@data[index]
end
#--------------------------------------------------------------------------
# ● 商品の値段を取得
#--------------------------------------------------------------------------
def price(item)
@price[item]
end
#--------------------------------------------------------------------------
# ● 材料品の取得
#--------------------------------------------------------------------------
def befores(item)
@befores[item]
end
#--------------------------------------------------------------------------
# ● 所持金の設定
#--------------------------------------------------------------------------
def money=(money)
@money = money
refresh
end
#--------------------------------------------------------------------------
# ● 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def enable?(item)
item && price(item) <= @money && need_before_item?(item) && !$game_party.item_max?(item)
end
#--------------------------------------------------------------------------
# ● 合成材料を持っているか?
#--------------------------------------------------------------------------
def need_before_item?(after_item)
befores(after_item).all?{|before|
case before[:kind]
when :I; before_item = $data_items[before[:id]]
when :W; before_item = $data_weapons[before[:id]]
when :A; before_item = $data_armors[before[:id]]
end
if before_item && (before[:num] <= $game_party.item_number(before_item))
true
else
false
end
}
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● アイテムリストの作成
#--------------------------------------------------------------------------
def make_item_list
@data = []
@price = {}
@befores = {}
NWConst::Synthesize::Shops[@shop_id].collect{ |recipe_id|
NWConst::Synthesize::Recipes[recipe_id]
}.each{|recipe|
case recipe[:after][:kind]
when :I; after_item = $data_items[recipe[:after][:id]]
when :W; after_item = $data_weapons[recipe[:after][:id]]
when :A; after_item = $data_armors[recipe[:after][:id]]
end
if after_item
@data.push(after_item)
@price[after_item] = recipe[:price]
@befores[after_item] = recipe[:befores]
end
}
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
name_width = rect.width - text_size(price(item)).width - 24
draw_item_name(item, rect.x, rect.y, enable?(item), name_width)
rect.width -= 4
draw_text(rect, price(item), 2)
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの設定
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
end
#--------------------------------------------------------------------------
# ● 性能差比較ウィンドウの設定
#--------------------------------------------------------------------------
def compare_window=(compare_window)
@compare_window = compare_window
call_update_help
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item) if @help_window
@status_window.set_item(item, befores(item)) if @status_window
@compare_window.item = item if @compare_window
end
end
#==============================================================================
# ■ Scene_Synthesize
#==============================================================================
class Scene_Synthesize < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 準備
#--------------------------------------------------------------------------
def prepare(shop_id)
@shop_id = shop_id
end
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_gold_window
create_command_window
create_dummy_window
create_status_window
create_compare_window
create_lineup_window
create_popup_confirm_window
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
end
#--------------------------------------------------------------------------
# ● コマンドウィンドウの作成
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_SynthesizeCommand.new
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.set_handler(:synthesize, method(:command_synthesize))
@command_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● コマンド:合成
#--------------------------------------------------------------------------
def command_synthesize
@lineup_window.money = money
@dummy_window.hide
@lineup_window.show
@status_window.show
@lineup_window.activate
end
#--------------------------------------------------------------------------
# ● ダミーウィンドウの作成
#--------------------------------------------------------------------------
def create_dummy_window
wy = @command_window.y + @command_window.height
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの作成
#--------------------------------------------------------------------------
def create_status_window
@status_window = Window_SynthesizeStatus.new
@status_window.viewport = @viewport
@status_window.hide
end
#--------------------------------------------------------------------------
# ● 性能差比較ウィンドウの作成
#--------------------------------------------------------------------------
def create_compare_window
@compare_window = Window_ShopCompare.new
@compare_window.viewport = @viewport
end
#--------------------------------------------------------------------------
# ● ラインナップウィンドウの作成
#--------------------------------------------------------------------------
def create_lineup_window
@lineup_window = Window_SynthesizeLineUp.new(@shop_id)
@lineup_window.viewport = @viewport
@lineup_window.hide
@lineup_window.set_handler(:ok, method(:synthesize_ok))
@lineup_window.set_handler(:cancel, method(:synthesize_cancel))
@lineup_window.help_window = @help_window
@lineup_window.status_window = @status_window
@lineup_window.compare_window = @compare_window
end
#--------------------------------------------------------------------------
# ● 合成:決定
#--------------------------------------------------------------------------
def synthesize_ok
@popup_confirm_window.refresh
@popup_confirm_window.show.activate
@popup_confirm_window.set_name(@lineup_window.item.name)
@popup_confirm_window.select(0)
end
#--------------------------------------------------------------------------
# ● 合成:キャンセル
#--------------------------------------------------------------------------
def synthesize_cancel
@lineup_window.hide
@status_window.hide
@dummy_window.show
@help_window.clear
@command_window.activate
end
#--------------------------------------------------------------------------
# ● 確認ポップアップウィンドウの作成
#--------------------------------------------------------------------------
def create_popup_confirm_window
@popup_confirm_window = Window_PopupConfirm.new
@popup_confirm_window.set_title(NWConst::Synthesize::CONFIRM_TEXT)
@popup_confirm_window.viewport = @viewport
@popup_confirm_window.hide
@popup_confirm_window.set_handler(:ok, method(:confirm_ok))
@popup_confirm_window.set_handler(:cancel, method(:confirm_cancel))
end
#--------------------------------------------------------------------------
# ● 確認:決定
#--------------------------------------------------------------------------
def confirm_ok
after_item = @lineup_window.item
price = @lineup_window.price(after_item)
befores = @lineup_window.befores(after_item)
$game_party.lose_gold(price)
befores.each{|before|
case before[:kind]
when :W; before_item = $data_weapons[before[:id]]
when :A; before_item = $data_armors[before[:id]]
when :I; before_item = $data_items[before[:id]]
end
$game_party.lose_item(before_item, before[:num])
}
$game_party.gain_item(after_item, 1)
Sound.play_shop
@gold_window.refresh
@lineup_window.money = money
@lineup_window.refresh
@popup_confirm_window.hide
@lineup_window.activate
end
#--------------------------------------------------------------------------
# ● 確認:キャンセル
#--------------------------------------------------------------------------
def confirm_cancel
@popup_confirm_window.hide
@lineup_window.activate
end
#--------------------------------------------------------------------------
# ● 所持金の取得
#--------------------------------------------------------------------------
def money
@gold_window.value
end
end
Synthesize# -*- encoding: utf-8 -*-
=begin
= 合成屋の設定
呼び出し方法は「スクリプト」から
call_synthesize(店ID)
です
=end
#==============================================================================
# ■ NWConst::Synthesize
#==============================================================================
module NWConst::Synthesize
# レシピ一覧
Recipes = {
# レシピID
1 => {
:price => 17,
:after => {:kind => :W, :id => 658},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 657, :num => 1},
{:kind => :I, :id => 322, :num => 1},
],
},
3 => {
:price => 12,
:after => {:kind => :W, :id => 2},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 1, :num => 1},
{:kind => :I, :id => 163, :num => 1},
],
},
4 => {
:price => 12,
:after => {:kind => :W, :id => 48},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 46, :num => 1},
{:kind => :I, :id => 161, :num => 1},
],
},
5 => {
:price => 15,
:after => {:kind => :W, :id => 144},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 143, :num => 1},
{:kind => :I, :id => 163, :num => 1},
],
},
6 => {
:price => 18,
:after => {:kind => :W, :id => 291},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 290, :num => 1},
{:kind => :I, :id => 164, :num => 1},
],
},
7 => {
:price => 15,
:after => {:kind => :W, :id => 401},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 400, :num => 1},
{:kind => :I, :id => 161, :num => 1},
],
},
8 => {
:price => 18,
:after => {:kind => :W, :id => 510},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 509, :num => 1},
{:kind => :I, :id => 162, :num => 1},
],
},
9 => {
:price => 18,
:after => {:kind => :W, :id => 590},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 589, :num => 1},
{:kind => :I, :id => 162, :num => 1},
],
},
10 => {
:price => 20,
:after => {:kind => :W, :id => 659},
:befores => [
# 種類, ID, 必要個数
{:kind => :W, :id => 658, :num => 1},
{:kind => :I, :id => 160, :num => 1},
],
},
11 => {
:price => 14,
:after => {:kind => :A, :id => 281},
:befores => [
# 種類, ID, 必要個数
{:kind => :A, :id => 280, :num => 1},
{:kind => :I, :id => 161, :num => 1},
],
},
}
# 店一覧
Shops = {
# 店ID => [レシピID, レシピID, レシピID...]
1 => [1],
2 => [4,1],
3 => [3,4,5,6,7,8,9,10,11],
}
end
|
|