查看: 4214|回复: 1

[RMVX发布] 设定技能自动释放(自动战斗用)

[复制链接]
梦石
0
星屑
632
在线时间
921 小时
注册时间
2013-3-13
回帖
503
发表于 2015-7-22 13:15:24 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 crow2006 于 2015-7-22 13:31 编辑

本脚本可以自动释放已设定好的技能,优先释放第一个技能,
如果第一个技能无法释放,则会释放第二个技能,以此类推。
非战斗状态点击一下技能即选定,再点击一下即取消,选定的技能会根据优先顺序显示在技能窗口中。
脚本只支持设定攻击技能,其他技能请自行设定。未设定技能时,默认为普通攻击。
QQ图片20150722131127.png
以下是脚本,具体使用方法见范例。
[pre lang="ruby"]#作者 crow2006   66RPG
#-------------------------------------------------------------------------------
#使用说明
=begin
本脚本可以自动释放已设定好的技能,优先释放第一个技能,
如果第一个技能无法释放,则会释放第二个技能,以此类推。
非战斗状态点击一下技能即选定,再点击一下即取消,
选定的技能会根据优先顺序显示在技能窗口中。
脚本只支持设定攻击技能,其他技能请自行设定。
未设定技能时,默认为普通攻击。
=end
#-------------------------------------------------------------------------------
module ZD
         #第一步:设定存储角色选定技能的变量
JN = 10  #假设有5个角色,那么变量11-变量15不要作其他用途。
         #class Window_Skill < Window_Selectable中的@column_max请根据窗口自行设定,我这里是3.
         #第二步:设定开启/关闭全员自动战斗的开关
KG = 10  #范例中开关号是10。
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
class Game_Actor < Game_Battler
  def auto_battle
    return $game_switches[ZD::KG] #全员自动战斗开关
  end
end  
#==============================================================================
# ** Window_Skill
#------------------------------------------------------------------------------
class Window_Skill < Window_Selectable
  def initialize(x, y, width, height, actor)
    super(x, y, width, height)
    @actor = actor
    @column_max = 3 #请根据窗口自行设定。
    self.index = 0
    refresh
  end
end  
#==============================================================================
# ■ Window_SkillStatus
#------------------------------------------------------------------------------
class Window_SkillStatus < Window_Base
  def initialize(x, y, actor)
    super(x, y, 544, WLH + 32 + 40)
    @actor = actor
    refresh
  end
  def refresh
    self.contents.clear
    draw_actor_name(@actor, 4, 0)
    draw_actor_level(@actor, 140, 0)
    draw_actor_hp(@actor, 240, 0)
    draw_actor_mp(@actor, 392, 0)
    if $game_variables[ZD::JN + @actor.id][0] != nil
      draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][0]], 0, 35, true)
    end  
    if $game_variables[ZD::JN + @actor.id][1] != nil
      draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][1]], 180, 35, true)
    end  
    if $game_variables[ZD::JN + @actor.id][2] != nil
      draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][2]], 360, 35, true)
    end  
  end
end
#==============================================================================
# ■ Scene_Skill
#------------------------------------------------------------------------------
class Scene_Skill < Scene_Base  
  def start
    super
    create_menu_background
    @actor = $game_party.members[@actor_index]
    $game_variables[ZD::JN + @actor.id] = [] if $game_variables[ZD::JN + @actor.id] == 0
    @viewport = Viewport.new(0, 0, 544, 416)
    @name_window = Window_Base.new(0, 0, 544, 56)
    @name_window.contents.draw_text(4, 0, 544, 24, Vocab::skill, 0)   
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @status_window = Window_SkillStatus.new(0, 56, @actor)
    @status_window.viewport = @viewport
    @skill_window = Window_Skill.new(0, 112+40, 544, 304-40, @actor)
    @skill_window.viewport = @viewport
    @skill_window.help_window = @help_window
    @target_window = Window_MenuStatus.new(0, 0)
    hide_target_window
  end  
  #--------------------------------------------------------------------------
  # ● 更新技能选择
  #--------------------------------------------------------------------------
  def update_skill_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::R)
      Sound.play_cursor
      next_actor
    elsif Input.trigger?(Input::L)
      Sound.play_cursor
      prev_actor
    elsif Input.trigger?(Input::C)
      @skill = @skill_window.skill
      if @skill != nil
        @actor.last_skill_id = @skill.id  
        if not $game_variables[ZD::JN + @actor.id].include?(@skill.id) and @skill.for_opponent? and $game_variables[ZD::JN + @actor.id].size <= 3
          $game_variables[ZD::JN + @actor.id] += [@skill.id]
          @status_window.refresh
        elsif $game_variables[ZD::JN + @actor.id].include?(@skill.id)
          $game_variables[ZD::JN + @actor.id] -= [@skill.id]
          @status_window.refresh
        end
      end
      if @actor.skill_can_use?(@skill)
        Sound.play_decision
        determine_skill
      else
        Sound.play_buzzer
      end
    end
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
class Scene_Battle < Scene_Base
  def next_actor
    loop do
      if @actor_index == $game_party.members.size-1
        start_main
        return
      end
      @status_window.index = @actor_index += 1
      @active_battler = $game_party.members[@actor_index]
      if @active_battler.auto_battle
       @active_battler.action.set_attack
       @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][2]] if $game_variables[ZD::JN + @active_battler.id][2] != nil
       @active_battler.action.set_skill($game_variables[ZD::JN + @active_battler.id][2]) if $game_variables[ZD::JN + @active_battler.id][2] != nil and @active_battler.skill_can_use?(@skill)        
       @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][1]] if $game_variables[ZD::JN + @active_battler.id][1] != nil
       @active_battler.action.set_skill($game_variables[ZD::JN + @active_battler.id][1]) if $game_variables[ZD::JN + @active_battler.id][1] != nil and @active_battler.skill_can_use?(@skill)
       @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][0]] if $game_variables[ZD::JN + @active_battler.id][0] != nil
       @active_battler.action.set_skill($game_variables[ZD::JN + @active_battler.id][0]) if $game_variables[ZD::JN + @active_battler.id][0] != nil and @active_battler.skill_can_use?(@skill)  
       start_target_enemy_selection
       @active_battler.action.target_index = @target_enemy_window.enemy.index #如果使用敌人状态脚本,此处可能有冲突。请注意。
       end_target_enemy_selection
        next
      end   
      break if @active_battler.inputable?
    end
    start_actor_command_selection
  end
end  
[/pre]     

自动释放技能.zip

370.18 KB, 下载次数: 102

梦石
0
星屑
632
在线时间
921 小时
注册时间
2013-3-13
回帖
503
 楼主| 发表于 2015-7-23 11:35:38 | 显示全部楼层
我对很多写法不在行,请高手对脚本做优化。非常感谢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部