首先呢,完全可以不用重写一个,直接修改原来的更方便,而且一般来说原本的这个类也就在战斗中这一块地方使用,所以应该不会影响别的地方
那么,经过修改
class Window_BattleSkill < Window_SkillList def initialize super(0, Graphics.height-fitting_height(3), Graphics.width, fitting_height(3)) self.visible = false end def show select_last super end def hide super end def col_max return 4 end def spacing return 0 end def item_height line_height*3 end def draw_item(index) skill = @data[index] if skill rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y+24, enable?(skill)) draw_skill_cost(rect, skill) end end def draw_skill_cost(rect, skill) if @actor.skill_tp_cost(skill) > 0 change_color(tp_cost_color, enable?(skill)) draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_tp_cost(skill), 2) elsif @actor.skill_mp_cost(skill) > 0 change_color(mp_cost_color, enable?(skill)) draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_mp_cost(skill), 2) end end end
class Window_BattleSkill < Window_SkillList
def initialize
super(0, Graphics.height-fitting_height(3), Graphics.width, fitting_height(3))
self.visible = false
end
def show
select_last
super
end
def hide
super
end
def col_max
return 4
end
def spacing
return 0
end
def item_height
line_height*3
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x, rect.y+24, enable?(skill))
draw_skill_cost(rect, skill)
end
end
def draw_skill_cost(rect, skill)
if @actor.skill_tp_cost(skill) > 0
change_color(tp_cost_color, enable?(skill))
draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_tp_cost(skill), 2)
elsif @actor.skill_mp_cost(skill) > 0
change_color(mp_cost_color, enable?(skill))
draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_mp_cost(skill), 2)
end
end
end
就只需要30多行代码了,是不是省事多了呢~
顺便说一下第一个问题,技能名坐标你会了,那就不多说了,消耗坐标的话其实draw_text这个方法可以把第一个参数rect拆开来写成4个参数(x,y,width,height),通过调整这四个参数来实现坐标的具体修改
具体的可以参考上面的代码自己试着调整一下参数看看变化就ok了
别忘了改这里
class Scene_Battle < Scene_Base def create_skill_window @skill_window = Window_BattleSkill.new @skill_window.set_handler(:ok, method(:on_skill_ok)) @skill_window.set_handler(:cancel, method(:on_skill_cancel)) end end
class Scene_Battle < Scene_Base
def create_skill_window
@skill_window = Window_BattleSkill.new
@skill_window.set_handler(:ok, method(:on_skill_ok))
@skill_window.set_handler(:cancel, method(:on_skill_cancel))
end
end
那么,第二个问题呢,也不用考虑的太复杂了
只需要一个简单的思路:战斗开始——>选择技能
那么展开来继续思考:战斗开始——>直接进入角色技能选择界面
继续:战斗开始——>跳过队伍指令——>跳过角色指令——>直接进入角色技能选择界面
大致的思路有了,那么想一想怎么实现比较方便,2个思路
1.干脆取消创建窗口
2.创建了窗口但隐藏掉(反正玩家看不见就行了)
那么,首先是第一步
去掉队伍指令窗口,在这里就选择干脆取消创建窗口吧
def create_all_windows create_message_window create_scroll_text_window create_log_window create_status_window create_info_viewport create_actor_command_window create_help_window create_skill_window create_item_window create_actor_window create_enemy_window end
def create_all_windows
create_message_window
create_scroll_text_window
create_log_window
create_status_window
create_info_viewport
create_actor_command_window
create_help_window
create_skill_window
create_item_window
create_actor_window
create_enemy_window
end
去掉创建队伍指令窗口的那行脚本
直接这样去掉肯定一堆出错吧?没关系,一点点调试就行了
直接进去战斗测试,你会发现各种报错
没关系,这些报错都是写原本调用了队伍指令窗口的地方报错(因为现在不创建了)
把这些东西该改的改一改该注释的注释掉就行了
def update_info_viewport move_info_viewport(64) if BattleManager.in_turn? end def update_message_open if $game_message.busy? && !@status_window.close? @message_window.openness = 0 @status_window.close @actor_command_window.close end end def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open if BattleManager.input_start command_fight else turn_start end end end def start_actor_command_selection @status_window.select(BattleManager.actor.index) @actor_command_window.setup(BattleManager.actor) end def turn_start @actor_command_window.close @status_window.unselect @subject = nil BattleManager.turn_start @log_window.wait @log_window.clear end
def update_info_viewport
move_info_viewport(64) if BattleManager.in_turn?
end
def update_message_open
if $game_message.busy? && !@status_window.close?
@message_window.openness = 0
@status_window.close
@actor_command_window.close
end
end
def start_party_command_selection
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start
command_fight
else
turn_start
end
end
end
def start_actor_command_selection
@status_window.select(BattleManager.actor.index)
@actor_command_window.setup(BattleManager.actor)
end
def turn_start
@actor_command_window.close
@status_window.unselect
@subject = nil
BattleManager.turn_start
@log_window.wait
@log_window.clear
end
嗯,然后呢,队伍指令窗口就这么没了,进入战斗测试后会发现直接开始角色命令的选择了。
那么,第一步完成
第二步,想办法直接进入技能选择界面
def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open if BattleManager.input_start command_fight else turn_start end end end
def start_party_command_selection
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start
command_fight
else
turn_start
end
end
end
这个方法是刚刚上面改的,在战斗开始后就直接进入战斗命令了(相当于默认选择了"战斗")
那么选择战斗是进入角色指令界面,那如果默认选择"技能"呢?
于是改一改
def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open if BattleManager.input_start if BattleManager.next_command start_actor_command_selection command_skill else turn_start end else turn_start end end end
def start_party_command_selection
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start
if BattleManager.next_command
start_actor_command_selection
command_skill
else
turn_start
end
else
turn_start
end
end
end
这样一来,就默认选择了技能
测试一下,发现虽然打开了技能界面,但角色指令窗口还是在,于是还要改一下
def start_actor_command_selection @status_window.select(BattleManager.actor.index) end
def start_actor_command_selection
@status_window.select(BattleManager.actor.index)
end
这样的话呢,角色指令窗口就没了
但是新的问题又来了,窗口出现但没技能
于是改一改command_skill的@skill_window.stype_id的值,这里改成1代表第一种类型的技能(因为数据库里可以设置很多种类的技能,这里改成默认显示1也就是"特技",当然可以进一步的修改来显示所有已学会的技能)
def command_skill @skill_window.actor = BattleManager.actor @skill_window.stype_id = 1 @skill_window.refresh @skill_window.show.activate end
def command_skill
@skill_window.actor = BattleManager.actor
@skill_window.stype_id = 1
@skill_window.refresh
@skill_window.show.activate
end
然后测试,发现可以选择了,但是,你会发现2个问题
1.如果技能都消耗不足无法使用怎么继续
2.如果这回合不想使用技能怎么跳过进入下一个角色的选择
那么,想一想,确定来选择,那么取消呢,取消还没修改
默认的取消是返回角色指令选择界面,那么我们现在不需要,所以要修改
def on_skill_cancel @skill_window.hide next_command end
def on_skill_cancel
@skill_window.hide
next_command
end
取消后直接进入下一个选择就ok了,这样一下子就解决了2个问题和原本按取消时候的bug
到这里,就算基本完成了
包括第一个问题总的合起来就是:
class Scene_Battle < Scene_Base def create_skill_window @skill_window = Window_BattleSkill.new @skill_window.set_handler(:ok, method(:on_skill_ok)) @skill_window.set_handler(:cancel, method(:on_skill_cancel)) end end class Window_BattleSkill < Window_SkillList def initialize super(0, Graphics.height-fitting_height(3), Graphics.width, fitting_height(3)) self.visible = false end def show select_last super end def hide super end def col_max return 4 end def spacing return 0 end def item_height line_height*3 end def draw_item(index) skill = @data[index] if skill rect = item_rect(index) rect.width -= 4 draw_item_name(skill, rect.x, rect.y+24, enable?(skill)) draw_skill_cost(rect, skill) end end def draw_skill_cost(rect, skill) if @actor.skill_tp_cost(skill) > 0 change_color(tp_cost_color, enable?(skill)) draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_tp_cost(skill), 2) elsif @actor.skill_mp_cost(skill) > 0 change_color(mp_cost_color, enable?(skill)) draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_mp_cost(skill), 2) end end end class Scene_Battle < Scene_Base def update_info_viewport move_info_viewport(64) if BattleManager.in_turn? end def update_message_open if $game_message.busy? && !@status_window.close? @message_window.openness = 0 @status_window.close @actor_command_window.close end end def create_all_windows create_message_window create_scroll_text_window create_log_window create_status_window create_info_viewport create_actor_command_window create_help_window create_skill_window create_item_window create_actor_window create_enemy_window end def start_party_command_selection unless scene_changing? refresh_status @status_window.unselect @status_window.open if BattleManager.input_start if BattleManager.next_command start_actor_command_selection command_skill else turn_start end else turn_start end end end def start_actor_command_selection @status_window.select(BattleManager.actor.index) end def turn_start @actor_command_window.close @status_window.unselect @subject = nil BattleManager.turn_start @log_window.wait @log_window.clear end def command_skill @skill_window.actor = BattleManager.actor @skill_window.stype_id = 1 @skill_window.refresh @skill_window.show.activate end def next_command if BattleManager.next_command start_actor_command_selection command_skill else turn_start end end def on_skill_cancel @skill_window.hide next_command end end
class Scene_Battle < Scene_Base
def create_skill_window
@skill_window = Window_BattleSkill.new
@skill_window.set_handler(:ok, method(:on_skill_ok))
@skill_window.set_handler(:cancel, method(:on_skill_cancel))
end
end
class Window_BattleSkill < Window_SkillList
def initialize
super(0, Graphics.height-fitting_height(3), Graphics.width, fitting_height(3))
self.visible = false
end
def show
select_last
super
end
def hide
super
end
def col_max
return 4
end
def spacing
return 0
end
def item_height
line_height*3
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
rect.width -= 4
draw_item_name(skill, rect.x, rect.y+24, enable?(skill))
draw_skill_cost(rect, skill)
end
end
def draw_skill_cost(rect, skill)
if @actor.skill_tp_cost(skill) > 0
change_color(tp_cost_color, enable?(skill))
draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_tp_cost(skill), 2)
elsif @actor.skill_mp_cost(skill) > 0
change_color(mp_cost_color, enable?(skill))
draw_text(rect.x,rect.y,rect.width,rect.height + 24, @actor.skill_mp_cost(skill), 2)
end
end
end
class Scene_Battle < Scene_Base
def update_info_viewport
move_info_viewport(64) if BattleManager.in_turn?
end
def update_message_open
if $game_message.busy? && !@status_window.close?
@message_window.openness = 0
@status_window.close
@actor_command_window.close
end
end
def create_all_windows
create_message_window
create_scroll_text_window
create_log_window
create_status_window
create_info_viewport
create_actor_command_window
create_help_window
create_skill_window
create_item_window
create_actor_window
create_enemy_window
end
def start_party_command_selection
unless scene_changing?
refresh_status
@status_window.unselect
@status_window.open
if BattleManager.input_start
if BattleManager.next_command
start_actor_command_selection
command_skill
else
turn_start
end
else
turn_start
end
end
end
def start_actor_command_selection
@status_window.select(BattleManager.actor.index)
end
def turn_start
@actor_command_window.close
@status_window.unselect
@subject = nil
BattleManager.turn_start
@log_window.wait
@log_window.clear
end
def command_skill
@skill_window.actor = BattleManager.actor
@skill_window.stype_id = 1
@skill_window.refresh
@skill_window.show.activate
end
def next_command
if BattleManager.next_command
start_actor_command_selection
command_skill
else
turn_start
end
end
def on_skill_cancel
@skill_window.hide
next_command
end
end
|