设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1984|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
582
在线时间
917 小时
注册时间
2013-3-13
帖子
557
跳转到指定楼层
1
发表于 2015-7-22 13:15:24 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

本脚本可以自动释放已设定好的技能,优先释放第一个技能,
如果第一个技能无法释放,则会释放第二个技能,以此类推。
非战斗状态点击一下技能即选定,再点击一下即取消,选定的技能会根据优先顺序显示在技能窗口中。
脚本只支持设定攻击技能,其他技能请自行设定。未设定技能时,默认为普通攻击。

以下是脚本,具体使用方法见范例。
RUBY 代码复制
  1. #作者 crow2006   66RPG
  2. #-------------------------------------------------------------------------------
  3. #使用说明
  4. =begin
  5. 本脚本可以自动释放已设定好的技能,优先释放第一个技能,
  6. 如果第一个技能无法释放,则会释放第二个技能,以此类推。
  7. 非战斗状态点击一下技能即选定,再点击一下即取消,
  8. 选定的技能会根据优先顺序显示在技能窗口中。
  9. 脚本只支持设定攻击技能,其他技能请自行设定。
  10. 未设定技能时,默认为普通攻击。
  11. =end
  12. #-------------------------------------------------------------------------------
  13. module ZD
  14.          #第一步:设定存储角色选定技能的变量
  15. JN = 10  #假设有5个角色,那么变量11-变量15不要作其他用途。
  16.          #class Window_Skill < Window_Selectable中的@column_max请根据窗口自行设定,我这里是3.
  17.          #第二步:设定开启/关闭全员自动战斗的开关
  18. KG = 10  #范例中开关号是10。
  19. end
  20. #==============================================================================
  21. # ** Game_Actor
  22. #------------------------------------------------------------------------------
  23. class Game_Actor < Game_Battler
  24.   def auto_battle
  25.     return $game_switches[ZD::KG] #全员自动战斗开关
  26.   end
  27. end  
  28. #==============================================================================
  29. # ** Window_Skill
  30. #------------------------------------------------------------------------------
  31. class Window_Skill < Window_Selectable
  32.   def initialize(x, y, width, height, actor)
  33.     super(x, y, width, height)
  34.     @actor = actor
  35.     @column_max = 3 #请根据窗口自行设定。
  36.     self.index = 0
  37.     refresh
  38.   end
  39. end  
  40. #==============================================================================
  41. # ■ Window_SkillStatus
  42. #------------------------------------------------------------------------------
  43. class Window_SkillStatus < Window_Base
  44.   def initialize(x, y, actor)
  45.     super(x, y, 544, WLH + 32 + 40)
  46.     @actor = actor
  47.     refresh
  48.   end
  49.   def refresh
  50.     self.contents.clear
  51.     draw_actor_name(@actor, 4, 0)
  52.     draw_actor_level(@actor, 140, 0)
  53.     draw_actor_hp(@actor, 240, 0)
  54.     draw_actor_mp(@actor, 392, 0)
  55.     if $game_variables[ZD::JN + @actor.id][0] != nil
  56.       draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][0]], 0, 35, true)
  57.     end  
  58.     if $game_variables[ZD::JN + @actor.id][1] != nil
  59.       draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][1]], 180, 35, true)
  60.     end  
  61.     if $game_variables[ZD::JN + @actor.id][2] != nil
  62.       draw_item_name($data_skills[$game_variables[ZD::JN + @actor.id][2]], 360, 35, true)
  63.     end  
  64.   end
  65. end
  66. #==============================================================================
  67. # ■ Scene_Skill
  68. #------------------------------------------------------------------------------
  69. class Scene_Skill < Scene_Base  
  70.   def start
  71.     super
  72.     create_menu_background
  73.     @actor = $game_party.members[@actor_index]
  74.     $game_variables[ZD::JN + @actor.id] = [] if $game_variables[ZD::JN + @actor.id] == 0
  75.     @viewport = Viewport.new(0, 0, 544, 416)
  76.     @name_window = Window_Base.new(0, 0, 544, 56)
  77.     @name_window.contents.draw_text(4, 0, 544, 24, Vocab::skill, 0)   
  78.     @help_window = Window_Help.new
  79.     @help_window.viewport = @viewport
  80.     @status_window = Window_SkillStatus.new(0, 56, @actor)
  81.     @status_window.viewport = @viewport
  82.     @skill_window = Window_Skill.new(0, 112+40, 544, 304-40, @actor)
  83.     @skill_window.viewport = @viewport
  84.     @skill_window.help_window = @help_window
  85.     @target_window = Window_MenuStatus.new(0, 0)
  86.     hide_target_window
  87.   end  
  88.   #--------------------------------------------------------------------------
  89.   # ● 更新技能选择
  90.   #--------------------------------------------------------------------------
  91.   def update_skill_selection
  92.     if Input.trigger?(Input::B)
  93.       Sound.play_cancel
  94.       return_scene
  95.     elsif Input.trigger?(Input::R)
  96.       Sound.play_cursor
  97.       next_actor
  98.     elsif Input.trigger?(Input::L)
  99.       Sound.play_cursor
  100.       prev_actor
  101.     elsif Input.trigger?(Input::C)
  102.       @skill = @skill_window.skill
  103.       if @skill != nil
  104.         @actor.last_skill_id = @skill.id  
  105.         if not $game_variables[ZD::JN + @actor.id].include?(@skill.id) and @skill.for_opponent? and $game_variables[ZD::JN + @actor.id].size <= 3
  106.           $game_variables[ZD::JN + @actor.id] += [@skill.id]
  107.           @status_window.refresh
  108.         elsif $game_variables[ZD::JN + @actor.id].include?(@skill.id)
  109.           $game_variables[ZD::JN + @actor.id] -= [@skill.id]
  110.           @status_window.refresh
  111.         end
  112.       end
  113.       if @actor.skill_can_use?(@skill)
  114.         Sound.play_decision
  115.         determine_skill
  116.       else
  117.         Sound.play_buzzer
  118.       end
  119.     end
  120.   end
  121. end
  122. #==============================================================================
  123. # ■ Scene_Battle
  124. #------------------------------------------------------------------------------
  125. class Scene_Battle < Scene_Base
  126.   def next_actor
  127.     loop do
  128.       if @actor_index == $game_party.members.size-1
  129.         start_main
  130.         return
  131.       end
  132.       @status_window.index = @actor_index += 1
  133.       @active_battler = $game_party.members[@actor_index]
  134.       if @active_battler.auto_battle
  135.        @active_battler.action.set_attack
  136.        @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][2]] if $game_variables[ZD::JN + @active_battler.id][2] != nil
  137.        @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)        
  138.        @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][1]] if $game_variables[ZD::JN + @active_battler.id][1] != nil
  139.        @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)
  140.        @skill = $data_skills[$game_variables[ZD::JN + @active_battler.id][0]] if $game_variables[ZD::JN + @active_battler.id][0] != nil
  141.        @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)  
  142.        start_target_enemy_selection
  143.        @active_battler.action.target_index = @target_enemy_window.enemy.index #如果使用敌人状态脚本,此处可能有冲突。请注意。
  144.        end_target_enemy_selection
  145.         next
  146.       end   
  147.       break if @active_battler.inputable?
  148.     end
  149.     start_actor_command_selection
  150.   end
  151. end
     

自动释放技能.zip

370.18 KB, 下载次数: 102

Lv2.观梦者

梦石
0
星屑
582
在线时间
917 小时
注册时间
2013-3-13
帖子
557
2
 楼主| 发表于 2015-7-23 11:35:38 | 只看该作者
我对很多写法不在行,请高手对脚本做优化。非常感谢。
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-25 11:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表