Project1
标题: 【脚本问题】自己修改的脚本求大佬帮忙看下 [打印本页]
作者: Zter 时间: 2017-10-20 19:16
标题: 【脚本问题】自己修改的脚本求大佬帮忙看下
本帖最后由 Zter 于 2017-10-20 19:25 编辑
我暂时只会把技能列表改成这样
(暂时不要帮助窗口),但是这样显得不美观,我想把技能名和花费TP的描绘都统一向下微移一些,但是我只会调技能名的位置,不会调技能花费的位置,所以求助大佬,还有我也想把技能列表调成战斗开始时就显得的那种,也就是说要完全屏蔽Window_PartyCommand和Window_ActorCommand两窗口,技能窗口从战斗开始一直显示到战斗结束才消失,每回合只存在有效无效的转换,求助大佬怎么改脚本,
附上脚本修改后的Scene_Battle和新加的Window_BattleSkillEx脚本class Window_BattleSkillEx < Window_Selectable
def initialize
super(0,Graphics.height-fitting_height(3),Graphics.width,fitting_height(3))
@actor = nil
@stype_id = 0
@data = []
end
def col_max
return 4
end
def row_max
return 1
end
def spacing
return 8
end
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = fitting_height(2)
rect.x = index % col_max * item_width
rect.y = index / col_max * item_height
rect
end
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
self.oy = 0
end
def stype_id=(stype_id)
return if @stype_id == stype_id
@stype_id = stype_id
refresh
self.oy = 0
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 include?(item)
item && item.stype_id == @stype_id
end
def enable?(item)
@actor && @actor.usable?(item)
end
def make_item_list
@data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
end
def select_last
select(@data.index(@actor.last_skill.object) || 0)
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
draw_item_name(skill, rect.x, rect.y, 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, @actor.skill_tp_cost(skill), 2)
elsif @actor.skill_mp_cost(skill) > 0
change_color(mp_cost_color, enable?(skill))
draw_text(rect, @actor.skill_mp_cost(skill), 2)
end
end
def refresh
make_item_list
create_contents
draw_all_items
end
end
class Window_BattleSkillEx < Window_Selectable
def initialize
super(0,Graphics.height-fitting_height(3),Graphics.width,fitting_height(3))
@actor = nil
@stype_id = 0
@data = []
end
def col_max
return 4
end
def row_max
return 1
end
def spacing
return 8
end
def item_rect(index)
rect = Rect.new
rect.width = item_width
rect.height = fitting_height(2)
rect.x = index % col_max * item_width
rect.y = index / col_max * item_height
rect
end
def actor=(actor)
return if @actor == actor
@actor = actor
refresh
self.oy = 0
end
def stype_id=(stype_id)
return if @stype_id == stype_id
@stype_id = stype_id
refresh
self.oy = 0
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 include?(item)
item && item.stype_id == @stype_id
end
def enable?(item)
@actor && @actor.usable?(item)
end
def make_item_list
@data = @actor ? @actor.skills.select {|skill| include?(skill) } : []
end
def select_last
select(@data.index(@actor.last_skill.object) || 0)
end
def draw_item(index)
skill = @data[index]
if skill
rect = item_rect(index)
draw_item_name(skill, rect.x, rect.y, 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, @actor.skill_tp_cost(skill), 2)
elsif @actor.skill_mp_cost(skill) > 0
change_color(mp_cost_color, enable?(skill))
draw_text(rect, @actor.skill_mp_cost(skill), 2)
end
end
def refresh
make_item_list
create_contents
draw_all_items
end
end
- #encoding:utf-8
- #==============================================================================
- # ■ Scene_Battle
- #------------------------------------------------------------------------------
- # 战斗画面
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_spriteset
- create_all_windows
- BattleManager.method_wait_for_message = method(:wait_for_message)
- end
- #--------------------------------------------------------------------------
- # ● 开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- battle_start
- end
- #--------------------------------------------------------------------------
- # ● 结束前处理
- #--------------------------------------------------------------------------
- def pre_terminate
- super
- Graphics.fadeout(30) if SceneManager.scene_is?(Scene_Map)
- Graphics.fadeout(60) if SceneManager.scene_is?(Scene_Title)
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_spriteset
- @info_viewport.dispose
- RPG::ME.stop
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if BattleManager.in_turn?
- process_event
- process_action
- end
- BattleManager.judge_win_loss
- end
- #--------------------------------------------------------------------------
- # ● 更新画面(基础)
- #--------------------------------------------------------------------------
- def update_basic
- super
- $game_timer.update
- $game_troop.update
- @spriteset.update
- update_info_viewport
- update_message_open
- end
- #--------------------------------------------------------------------------
- # ● 更新画面(等待用)
- #--------------------------------------------------------------------------
- def update_for_wait
- update_basic
- end
- #--------------------------------------------------------------------------
- # ● 等待
- #--------------------------------------------------------------------------
- def wait(duration)
- duration.times {|i| update_for_wait if i < duration / 2 || !show_fast? }
- end
- #--------------------------------------------------------------------------
- # ● 快进判定
- #--------------------------------------------------------------------------
- def show_fast?
- Input.press?(:A) || Input.press?(:C)
- end
- #--------------------------------------------------------------------------
- # ● 等待(快进无效)
- #--------------------------------------------------------------------------
- def abs_wait(duration)
- duration.times {|i| update_for_wait }
- end
- #--------------------------------------------------------------------------
- # ● 短时间等待(快进无效)
- #--------------------------------------------------------------------------
- def abs_wait_short
- abs_wait(15)
- end
- #--------------------------------------------------------------------------
- # ● 等待信息显示的结束
- #--------------------------------------------------------------------------
- def wait_for_message
- @message_window.update
- update_for_wait while $game_message.visible
- end
- #--------------------------------------------------------------------------
- # ● 等待动画显示的结束
- #--------------------------------------------------------------------------
- def wait_for_animation
- update_for_wait
- update_for_wait while @spriteset.animation?
- end
- #--------------------------------------------------------------------------
- # ● 等待效果执行的结束
- #--------------------------------------------------------------------------
- def wait_for_effect
- update_for_wait
- update_for_wait while @spriteset.effect?
- end
- #--------------------------------------------------------------------------
- # ● 更新信息显示的显示端口
- #--------------------------------------------------------------------------
- def update_info_viewport
- move_info_viewport(64) if BattleManager.in_turn?
- end
- #--------------------------------------------------------------------------
- # ● 移动信息显示的显示端口
- #--------------------------------------------------------------------------
- def move_info_viewport(ox)
- current_ox = @info_viewport.ox
- @info_viewport.ox = [ox, current_ox + 16].min if current_ox < ox
- @info_viewport.ox = [ox, current_ox - 16].max if current_ox > ox
- end
- #--------------------------------------------------------------------------
- # ● 信息窗口打开时的更新
- # 在状态窗口关闭完成前,信息窗口的打开度设置为 0 。
- #--------------------------------------------------------------------------
- def update_message_open
- if $game_message.busy? && !@status_window.close?
- @message_window.openness = 0
- @status_window.close
- @party_command_window.close
- @actor_command_window.close
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成精灵组
- #--------------------------------------------------------------------------
- def create_spriteset
- @spriteset = Spriteset_Battle.new
- end
- #--------------------------------------------------------------------------
- # ● 释放精灵组
- #--------------------------------------------------------------------------
- def dispose_spriteset
- @spriteset.dispose
- end
- #--------------------------------------------------------------------------
- # ● 生成所有窗口
- #--------------------------------------------------------------------------
- def create_all_windows
- create_message_window
- create_scroll_text_window
- create_log_window
- create_status_window
- create_info_viewport
- create_help_window
- create_skill_window
- create_actor_window
- create_enemy_window
- end
- #--------------------------------------------------------------------------
- # ● 生成信息窗口
- #--------------------------------------------------------------------------
- def create_message_window
- @message_window = Window_Message.new
- end
- #--------------------------------------------------------------------------
- # ● 生成滚动文字窗口
- #--------------------------------------------------------------------------
- def create_scroll_text_window
- @scroll_text_window = Window_ScrollText.new
- end
- #--------------------------------------------------------------------------
- # ● 生成日志记录窗口
- #--------------------------------------------------------------------------
- def create_log_window
- @log_window = Window_BattleLog.new
- @log_window.method_wait = method(:wait)
- @log_window.method_wait_for_effect = method(:wait_for_effect)
- end
- #--------------------------------------------------------------------------
- # ● 生成状态窗口
- #--------------------------------------------------------------------------
- def create_status_window
- @status_window = Window_BattleStatus.new
- @status_window.x = 128
- end
- #--------------------------------------------------------------------------
- # ● 生成信息显示的显示端口
- #--------------------------------------------------------------------------
- def create_info_viewport
- @info_viewport = Viewport.new
- @info_viewport.rect.y = Graphics.height - @status_window.height
- @info_viewport.rect.height = @status_window.height
- @info_viewport.z = 100
- @info_viewport.ox = 64
- @status_window.viewport = @info_viewport
- end
- #--------------------------------------------------------------------------
- # ● 生成帮助窗口
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new
- @help_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 生成技能窗口
- #--------------------------------------------------------------------------
- def create_skill_window
- @skill_window = Window_BattleSkillEx.new
- @skill_window.set_handler(:ok, method(:on_skill_ok))
- @skill_window.set_handler(:cancel, method(:on_skill_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 生成角色窗口
- #--------------------------------------------------------------------------
- def create_actor_window
- @actor_window = Window_BattleActor.new(@info_viewport)
- @actor_window.set_handler(:ok, method(:on_actor_ok))
- @actor_window.set_handler(:cancel, method(:on_actor_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 生成敌人窗口
- #--------------------------------------------------------------------------
- def create_enemy_window
- @enemy_window = Window_BattleEnemy.new(@info_viewport)
- @enemy_window.set_handler(:ok, method(:on_enemy_ok))
- @enemy_window.set_handler(:cancel, method(:on_enemy_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 更新状态窗口的信息
- #--------------------------------------------------------------------------
- def refresh_status
- @status_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 进行下一个指令输入
- #--------------------------------------------------------------------------
- def next_command
- if BattleManager.next_command
- @skill_window.activate
- else
- turn_start
- end
- end
- #--------------------------------------------------------------------------
- # ● 返回上一个指令输入
- #--------------------------------------------------------------------------
- def prior_command
- if BattleManager.prior_command
- start_skill_selection
- else
- start_skill_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 开始队伍指令的选择
- #--------------------------------------------------------------------------
- def start_party_command_selection
- unless scene_changing?
- refresh_status
- @status_window.unselect
- @status_window.open
- if BattleManager.input_start
- @actor_command_window.close
- @party_command_window.setup
- else
- @party_command_window.deactivate
- turn_start
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 开始角色指令的选择
- #--------------------------------------------------------------------------
- def start_actor_command_selection
- @status_window.select(BattleManager.actor.index)
- @party_command_window.close
- @actor_command_window.setup(BattleManager.actor)
- end
- #--------------------------------------------------------------------------
- # ● 开始技能指令的选择
- #--------------------------------------------------------------------------
- def start_skill_selection
- @skill_window.actor = BattleManager.actor
- @skill_window.refresh
- @skill_window.show.activate
- end
- #--------------------------------------------------------------------------
- # ● 指令“技能”
- #--------------------------------------------------------------------------
- def command_skill
- @skill_window.actor = BattleManager.actor
- @skill_window.stype_id = @actor_command_window.current_ext
- @skill_window.refresh
- @skill_window.show.activate
- end
- #--------------------------------------------------------------------------
- # ● 开始选择队友
- #--------------------------------------------------------------------------
- def select_actor_selection
- @actor_window.refresh
- @actor_window.show.activate
- end
- #--------------------------------------------------------------------------
- # ● 角色“确定”
- #--------------------------------------------------------------------------
- def on_actor_ok
- BattleManager.actor.input.target_index = @actor_window.index
- @actor_window.hide
- @skill_window.deactivate
- next_command
- end
- #--------------------------------------------------------------------------
- # ● 角色“取消”
- #--------------------------------------------------------------------------
- def on_actor_cancel
- @actor_window.hide
- @skill_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 开始选择敌人
- #--------------------------------------------------------------------------
- def select_enemy_selection
- @enemy_window.refresh
- @enemy_window.show.activate
- end
- #--------------------------------------------------------------------------
- # ● 敌人“确定”
- #--------------------------------------------------------------------------
- def on_enemy_ok
- BattleManager.actor.input.target_index = @enemy_window.enemy.index
- @enemy_window.hide
- @skill_window.deactivate
- next_command
- end
- #--------------------------------------------------------------------------
- # ● 敌人“取消”
- #--------------------------------------------------------------------------
- def on_enemy_cancel
- @enemy_window.hide
- @skill_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 技能“确定”
- #--------------------------------------------------------------------------
- def on_skill_ok
- @skill = @skill_window.item
- BattleManager.actor.input.set_skill(@skill.id)
- BattleManager.actor.last_skill.object = @skill
- if [email protected]_selection?
- @skill_window.deactivate
- next_command
- elsif @skill.for_opponent?
- select_enemy_selection
- else
- select_actor_selection
- end
- end
- #--------------------------------------------------------------------------
- # ● 技能“取消”
- #--------------------------------------------------------------------------
- def on_skill_cancel
- @skill_window.deactivate
- end
- #--------------------------------------------------------------------------
- # ● 战斗开始
- #--------------------------------------------------------------------------
- def battle_start
- BattleManager.battle_start
- process_event
- @skill_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 回合开始
- #--------------------------------------------------------------------------
- def turn_start
- @skill_window.deactivate
- @status_window.unselect
- @subject = nil
- BattleManager.turn_start
- @log_window.wait
- @log_window.clear
- end
- #--------------------------------------------------------------------------
- # ● 回合结束
- #--------------------------------------------------------------------------
- def turn_end
- all_battle_members.each do |battler|
- battler.on_turn_end
- refresh_status
- @log_window.display_auto_affected_status(battler)
- @log_window.wait_and_clear
- end
- BattleManager.turn_end
- process_event
- @skill_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 获取敌我双方的全部参战角色
- #--------------------------------------------------------------------------
- def all_battle_members
- $game_party.members + $game_troop.members
- end
- #--------------------------------------------------------------------------
- # ● 处理事件
- #--------------------------------------------------------------------------
- def process_event
- while !scene_changing?
- $game_troop.interpreter.update
- $game_troop.setup_battle_event
- wait_for_message
- wait_for_effect if $game_troop.all_dead?
- process_forced_action
- BattleManager.judge_win_loss
- break unless $game_troop.interpreter.running?
- update_for_wait
- end
- end
- #--------------------------------------------------------------------------
- # ● 处理强制战斗行动
- #--------------------------------------------------------------------------
- def process_forced_action
- if BattleManager.action_forced?
- last_subject = @subject
- @subject = BattleManager.action_forced_battler
- BattleManager.clear_action_force
- process_action
- @subject = last_subject
- end
- end
- #--------------------------------------------------------------------------
- # ● 处理战斗行动
- #--------------------------------------------------------------------------
- def process_action
- return if scene_changing?
- if !@subject || [email protected]_action
- @subject = BattleManager.next_subject
- end
- return turn_end unless @subject
- if @subject.current_action
- @subject.current_action.prepare
- if @subject.current_action.valid?
- @status_window.open
- execute_action
- end
- @subject.remove_current_action
- end
- process_action_end unless @subject.current_action
- end
- #--------------------------------------------------------------------------
- # ● 战斗行动结束时的处理
- #--------------------------------------------------------------------------
- def process_action_end
- @subject.on_action_end
- refresh_status
- @log_window.display_auto_affected_status(@subject)
- @log_window.wait_and_clear
- @log_window.display_current_state(@subject)
- @log_window.wait_and_clear
- BattleManager.judge_win_loss
- end
- #--------------------------------------------------------------------------
- # ● 执行战斗行动
- #--------------------------------------------------------------------------
- def execute_action
- @subject.sprite_effect_type = :whiten
- use_item
- @log_window.wait_and_clear
- end
- #--------------------------------------------------------------------------
- # ● 使用技能/物品
- #--------------------------------------------------------------------------
- def use_item
- item = @subject.current_action.item
- @log_window.display_use_item(@subject, item)
- @subject.use_item(item)
- refresh_status
- targets = @subject.current_action.make_targets.compact
- show_animation(targets, item.animation_id)
- targets.each {|target| item.repeats.times { invoke_item(target, item) } }
- end
- #--------------------------------------------------------------------------
- # ● 发动技能/物品
- #--------------------------------------------------------------------------
- def invoke_item(target, item)
- if rand < target.item_cnt(@subject, item)
- invoke_counter_attack(target, item)
- elsif rand < target.item_mrf(@subject, item)
- invoke_magic_reflection(target, item)
- else
- apply_item_effects(apply_substitute(target, item), item)
- end
- @subject.last_target_index = target.index
- end
- #--------------------------------------------------------------------------
- # ● 应用技能/物品效果
- #--------------------------------------------------------------------------
- def apply_item_effects(target, item)
- target.item_apply(@subject, item)
- refresh_status
- @log_window.display_action_results(target, item)
- end
- #--------------------------------------------------------------------------
- # ● 发动反击
- #--------------------------------------------------------------------------
- def invoke_counter_attack(target, item)
- @log_window.display_counter(target, item)
- attack_skill = $data_skills[target.attack_skill_id]
- @subject.item_apply(target, attack_skill)
- refresh_status
- @log_window.display_action_results(@subject, attack_skill)
- end
- #--------------------------------------------------------------------------
- # ● 发动反射魔法攻击
- #--------------------------------------------------------------------------
- def invoke_magic_reflection(target, item)
- @log_window.display_reflection(target, item)
- apply_item_effects(@subject, item)
- end
- #--------------------------------------------------------------------------
- # ● 应用保护弱者
- #--------------------------------------------------------------------------
- def apply_substitute(target, item)
- if check_substitute(target, item)
- substitute = target.friends_unit.substitute_battler
- if substitute && target != substitute
- @log_window.display_substitute(substitute, target)
- return substitute
- end
- end
- target
- end
- #--------------------------------------------------------------------------
- # ● 检查是否能使用保护弱者
- #--------------------------------------------------------------------------
- def check_substitute(target, item)
- target.hp < target.mhp / 4 && (!item || !item.certain?)
- end
- #--------------------------------------------------------------------------
- # ● 显示动画
- # targets : 目标的数组
- # animation_id : 动画 ID(-1: 与普通攻击一样)
- #--------------------------------------------------------------------------
- def show_animation(targets, animation_id)
- if animation_id < 0
- show_attack_animation(targets)
- else
- show_normal_animation(targets, animation_id)
- end
- @log_window.wait
- wait_for_animation
- end
- #--------------------------------------------------------------------------
- # ● 显示攻击动画
- # targets : 目标的数组
- # 是角色的时候考虑双持武器的效果(反转动画显示左手武器)。
- # 是敌人的时候,在那一瞬间,播放“敌人普通攻击”的声效。
- #--------------------------------------------------------------------------
- def show_attack_animation(targets)
- if @subject.actor?
- show_normal_animation(targets, @subject.atk_animation_id1, false)
- show_normal_animation(targets, @subject.atk_animation_id2, true)
- else
- Sound.play_enemy_attack
- abs_wait_short
- end
- end
- #--------------------------------------------------------------------------
- # ● 显示普通动画
- # targets : 目标的数组
- # animation_id : 动画ID
- # mirror : 左右反转
- #--------------------------------------------------------------------------
- def show_normal_animation(targets, animation_id, mirror = false)
- animation = $data_animations[animation_id]
- if animation
- targets.each do |target|
- target.animation_id = animation_id
- target.animation_mirror = mirror
- abs_wait_short unless animation.to_screen?
- end
- abs_wait_short if animation.to_screen?
- end
- end
- end
复制代码
如果Scene_Battle不改的话加上Window_BattleSkillEx技能窗口还可用,内容也能照常显示,如果Scene_Battle改了的话加上Window_BattleSkillEx,技能窗口就不能显示内容了,也就不好用了,大佬求教咋改,感激万分!(顺便本人也是刚学会些简单的脚本,很多东西都只能暴力修改,不懂逻辑。。
作者: 魔法丶小肉包 时间: 2017-10-20 22:06
首先呢,完全可以不用重写一个,直接修改原来的更方便,而且一般来说原本的这个类也就在战斗中这一块地方使用,所以应该不会影响别的地方
那么,经过修改
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
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |