Project1
标题:
另外制作一个新状态栏,而且只能用道具查看,but...请问我...
[打印本页]
作者:
bgltnup
时间:
2018-5-11 17:44
标题:
另外制作一个新状态栏,而且只能用道具查看,but...请问我...
我的游戏只有一个主角,所以没有伙伴问题,
我想另外多制作一个新状态栏,而且只能用道具才能查看,
我先做了一个道具,道具编号是999,
然后写一个新的角本[Scene_Status2],当使用道具后,
去打开新的视窗[Window_Status2],
结束后会到地图画面。
但是...新的状态栏不会显示
请问我脚本哪里写错了....???
#==============================================================================
# ■ Scene_Status2
#------------------------------------------------------------------------------
# Status2画面
#==============================================================================
class Scene_Status2 < Scene_ItemBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias xxx001_start start
def start
xxx001_start
@status2_window = Window_Status2.new
end
#--------------------------------------------------------------------------
# ● 對應道具items[999]
#--------------------------------------------------------------------------
alias xxx001_determine_item determine_item
def determine_item
if determine_item = $data_items[999]
show_sub_window(@status2_window)
else
xxx001_determine_item
end
end
end
#==============================================================================
# ■ Window_Status2
#------------------------------------------------------------------------------
#密状态栏
#==============================================================================
class Window_Status2 < Window_Base
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
@actor = $game_party.members.first
refresh
activate
end
#--------------------------------------------------------------------------
# ● 幅
#--------------------------------------------------------------------------
def window_width
Graphics.width - 160
end
#--------------------------------------------------------------------------
# ● 高
#--------------------------------------------------------------------------
def window_height
Graphics.height - 123
end
#--------------------------------------------------------------------------
# ● 1區塊
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1 (line_height * 0)
end
#--------------------------------------------------------------------------
# ● 1區塊內容
#--------------------------------------------------------------------------
def draw_block1(y)
draw_eexp_info(0, y)
end
# ● 內容描画
#--------------------------------------------------------------------------
def draw_eexp_info(x, y)
s1 = @actor.max_level? ? "-------" : @actor.exp
s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
s_next = sprintf(Vocab::ExpNext, Vocab::level)
change_color(system_color)
draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
draw_text(x, y + line_height * 1, 180, line_height, s_next)
change_color(normal_color)
draw_text(x, y + line_height * 0, 280, line_height, s1, 2)
draw_text(x, y + line_height * 1, 280, line_height, s2, 2)
end
#--------------------------------------------------------------------------
# ●返回地圖
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Map.new
end
end
作者:
阵颜
时间:
2018-5-12 10:51
#--------------------------------------------------------------------------
# ● 對應道具items[999]
#--------------------------------------------------------------------------
alias xxx001_determine_item determine_item
def determine_item
if determine_item = $data_items[999]
上面这里也许应该改成 if @item.id = 999
我没试过,随便说的。
作者:
文雅夕露
时间:
2018-5-12 12:01
首先楼主您这个脚本是在RGSS2运行还是RGSS3运行的?
RGSS2默认并没有Scene_ItemBase这个场景。
RGSS3默认并不会有$scene = Scene_Map.new这个实例方法。
看脚本的样子还是RGSS3的结构。
附上正确的脚本给您参考一下。
#encoding:utf-8
#==============================================================================
# ■ Scene_ItemBase
#------------------------------------------------------------------------------
# 物品画面和技能画面的共同父类
#==============================================================================
class Scene_ItemBase
#--------------------------------------------------------------------------
# ● 使用物品
#--------------------------------------------------------------------------
alias up_use_item use_item
def use_item
p 1
if $data_items[21]
use_status_item
else
up_use_item
end
end
#--------------------------------------------------------------------------
# ● 设定
#--------------------------------------------------------------------------
def use_status_item
SceneManager.call(Scene_Status2)
end
end
#==============================================================================
# ■ Scene_Status2
#------------------------------------------------------------------------------
# Status2画面
#==============================================================================
class Scene_Status2 < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias xxx001_start start
def start
xxx001_start
@status2_window = Window_Status2.new(0,0)
@status2_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ●返回地圖
#--------------------------------------------------------------------------
def return_scene
SceneManager.call(Scene_Map)
end
end
#==============================================================================
# ■ Window_Status2
#------------------------------------------------------------------------------
#==============================================================================
class Window_Status2 < Window_Selectable
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
@actor = $game_party.leader
refresh
activate
end
#--------------------------------------------------------------------------
# ● 幅
#--------------------------------------------------------------------------
def window_width
Graphics.width - 160
end
#--------------------------------------------------------------------------
# ● 高
#--------------------------------------------------------------------------
def window_height
Graphics.height - 123
end
#--------------------------------------------------------------------------
# ● 1區塊
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_block1 (line_height * 0)
end
#--------------------------------------------------------------------------
# ● 1區塊內容
#--------------------------------------------------------------------------
def draw_block1(y)
draw_eexp_info(0, y)
end
# ● 內容描画
#--------------------------------------------------------------------------
def draw_eexp_info(x, y)
s1 = @actor.max_level? ? "-------" : @actor.exp
s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
s_next = sprintf(Vocab::ExpNext, Vocab::level)
change_color(system_color)
draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
draw_text(x, y + line_height * 1, 180, line_height, s_next)
change_color(normal_color)
draw_text(x, y + line_height * 0, 280, line_height, s1, 2)
draw_text(x, y + line_height * 1, 280, line_height, s2, 2)
end
end
复制代码
作者:
bgltnup
时间:
2018-5-12 12:54
感恩~文雅夕露 ,我脚本是RGSS3,
状态栏成功用道具打开了,但是bug出现了
我編號999的道具是設定成[貴重物品],
结果全部在[贵重物品栏]里的道具都会打开这个状态栏....
请问我哪理改错了......
[Scene_Status2][Window_Status2]
是依你贴的改,
但[Scene_ItemBase]我是把它加到原有的底下....↓
#==============================================================================
# ■ Scene_ItemBase
#==============================================================================
class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 開始
#--------------------------------------------------------------------------
def start
super
create_actor_window
end
#--------------------------------------------------------------------------
# ● 创建演员窗口
#--------------------------------------------------------------------------
def create_actor_window
@actor_window = Window_MenuActor.new
@actor_window.set_handler(:ok, method(:on_actor_ok))
@actor_window.set_handler(:cancel, method(:on_actor_cancel))
end
#--------------------------------------------------------------------------
# ● 检索当前选择的项目
#--------------------------------------------------------------------------
def item
@item_window.item
end
#--------------------------------------------------------------------------
# ● 获取物品的用户
#--------------------------------------------------------------------------
def user
$game_party.movable_members.max_by {|member| member.pha }
end
#--------------------------------------------------------------------------
# ● 确定光标是否在左栏中
#--------------------------------------------------------------------------
def cursor_left?
@item_window.index % 2 == 0
end
#--------------------------------------------------------------------------
# ● 显示子窗口
#--------------------------------------------------------------------------
def show_sub_window(window)
width_remain = Graphics.width - window.width
window.x = cursor_left? ? width_remain : 0
@viewport.rect.x = @viewport.ox = cursor_left? ? 0 : window.width
@viewport.rect.width = width_remain
window.show.activate
end
#--------------------------------------------------------------------------
# ● 隐藏子窗口
#--------------------------------------------------------------------------
def hide_sub_window(window)
@viewport.rect.x = @viewport.ox = 0
@viewport.rect.width = Graphics.width
window.hide.deactivate
activate_item_window
end
#--------------------------------------------------------------------------
# ● 演员[决定]
#--------------------------------------------------------------------------
def on_actor_ok
if item_usable?
use_item
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● 演员[取消]
#--------------------------------------------------------------------------
def on_actor_cancel
hide_sub_window(@actor_window)
end
#--------------------------------------------------------------------------
# ● 项目确定
#--------------------------------------------------------------------------
def determine_item
if item.for_friend?
show_sub_window(@actor_window)
@actor_window.select_for_item(item)
else
use_item
activate_item_window
end
end
#--------------------------------------------------------------------------
# ● 激活项目窗口
#--------------------------------------------------------------------------
def activate_item_window
@item_window.refresh
@item_window.activate
end
#--------------------------------------------------------------------------
# ● 获取演员将该项目用作数组
#--------------------------------------------------------------------------
def item_target_actors
if !item.for_friend?
[]
elsif item.for_all?
$game_party.members
else
[$game_party.members[@actor_window.index]]
end
end
#--------------------------------------------------------------------------
# ● 项目的可用性确定
#--------------------------------------------------------------------------
def item_usable?
user.usable?(item) && item_effects_valid?
end
#--------------------------------------------------------------------------
# ● 确定项目效果是否有效
#--------------------------------------------------------------------------
def item_effects_valid?
item_target_actors.any? do |target|
target.item_test(user, item)
end
end
#--------------------------------------------------------------------------
# ● 为演员使用项目
#--------------------------------------------------------------------------
def use_item_to_actors
item_target_actors.each do |target|
item.repeats.times { target.item_apply(user, item) }
end
end
#--------------------------------------------------------------------------
# ● 使用项目
#--------------------------------------------------------------------------
def use_item
play_se_for_item
user.use_item(item)
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
end
#--------------------------------------------------------------------------
# ● 使用物品items[999]
#--------------------------------------------------------------------------
alias up_use_item use_item
def use_item
p 1
if $data_items[999]
use_status_item
else
up_use_item
end
end
#--------------------------------------------------------------------------
# ● items[999]设定
#--------------------------------------------------------------------------
def use_status_item
SceneManager.call(Scene_Status2)
end
#--------------------------------------------------------------------------
# ● 常见的事件预约判断
# 如果事件呼叫保留,它将转换到地图屏幕。
#--------------------------------------------------------------------------
def check_common_event
SceneManager.goto(Scene_Map) if $game_temp.common_event_reserved?
end
end
作者:
文雅夕露
时间:
2018-5-12 13:48
#==============================================================================
# ■ Scene_ItemBase
#------------------------------------------------------------------------------
# 物品画面和技能画面的共同父类
#==============================================================================
class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 使用物品
#--------------------------------------------------------------------------
alias up_use_item use_item
def use_item
up_use_item
use_status_item if item.note.include?("<状态>")
end
#--------------------------------------------------------------------------
# ● 设定
#--------------------------------------------------------------------------
def use_status_item
SceneManager.call(Scene_Status2)
end
end
复制代码
换一种判断方法吧,就是打开状态菜单的道具备注里填入<状态>即可。
作者:
bgltnup
时间:
2018-5-12 15:39
感谢~文雅夕露,问题成功解决! !
所以前一个判断方法比较是适合用在一般道具...
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1