Project1

标题: 请问《妖精的珍宝》 中的 按键特技施展系统 怎么实现? [打印本页]

作者: dadongliang    时间: 2010-8-13 10:50
提示: 作者被禁止或删除 内容自动屏蔽
作者: liqunsz    时间: 2010-8-13 11:03
  1. #==============================================================================
  2. #   组合键连续特技系统 By 绿发的Eclair
  3. #==============================================================================
  4. #   仿传说系列的效果,在使用一个特技中按照一定的顺序摁键可以再使用一个特技。
  5. #   使用方法:在下面的自定义部分里设定特技对应的组合键和连接上的特技。
  6. #   为了避免玩家二周目或者提前知道的情况下一开始就是用强力连续技能的事情发生,
  7. #   特别做了判断,只有$chain这个数组包括的技能才会被连出来。
  8. #   事件脚本中使用 add_chain(可以连出来的特技ID) 可以给这个数组添加新特技。
  9. #   就好像“学会新的”一样。
  10. #==============================================================================
  11. $chain = [ ]#可以使用的连续技
  12. module RPG
  13. class Skill
  14.   def chain
  15.   ############################################################自定义部分
  16.   case id
  17.    when 57                #有连续效果技能的ID,57就是"十字斩"
  18.     chain = ["A","A","A"] #连续技能的摁键,一定要写成数组,用英文半角逗号来隔开
  19.     chain_id = 81         #连接技能的ID,81就是"千裂斩"
  20.   when 81                 #使用技能为千裂斩
  21.     chain = ["上","上","下" ,"下","左","右","左","右","B","A"] #输入魂斗罗的作弊码 :)
  22.     chain_id = 82         #连接技能,"灵魂裂隙"                                   
  23.   when 82                 #使用技能为灵魂裂隙
  24.     chain = ["上","下","左","右"] #输入键顺序为"上下左右"
  25.     chain_id = 82         #连接技能还是"灵魂裂隙"
  26.   #在这里按照上面的格式添加  
  27.   #when n  
  28.   #chain = ["第一个摁键","第二个摁键","第三个摁键"]
  29.   #chain_id = 连接技能的ID
  30.   
  31.   
  32.   ############################################################
  33.   else
  34.     chain = []
  35.     chain_id = 0
  36.   end
  37.    return [chain,chain_id]
  38.   end
  39. end
  40. end
  41. class Interpreter
  42.   def add_chain(id)
  43.     $chain.push(id)
  44.   end
  45. end
  46. class Scene_Battle
  47.   alias update_phase4_step1_2 :update_phase4_step1
  48.   def update_phase4_step1
  49.     @result = [] if @result == nil
  50.     update_phase4_step1_2
  51.   end
  52.   alias update_e :update
  53.   def update
  54.     if (@phase4_step == 3 or @phase4_step == 4 or @phase4_step == 5) && @active_battler.current_action.kind == 1
  55.       @use = @active_battler.current_action.kind == 1 && $data_skills[@active_battler.current_action.skill_id].chain != [[],0] && $chain.include?($data_skills[@active_battler.current_action.skill_id].chain[1])
  56.     if @use == true and $data_skills[@active_battler.current_action.skill_id].chain != [[],0]
  57.        @use = $data_skills[$data_skills[@active_battler.current_action.skill_id].chain[1]].sp_cost <= @active_battler.sp
  58.     end
  59.     if @use == true
  60.    if Input.trigger?(Input::A)
  61.      @result.push("A")
  62.    end
  63.    if Input.trigger?(Input::B)
  64.      @result.push("B")
  65.    end
  66.    if Input.trigger?(Input::C)
  67.      @result.push("C")
  68.    end
  69.    if Input.trigger?(Input::X)
  70.      @result.push("X")
  71.    end
  72.    if Input.trigger?(Input::Y)
  73.      @result.push("Y")
  74.    end
  75.    if Input.trigger?(Input::Z)
  76.      @result.push("Z")
  77.    end
  78.    if Input.trigger?(Input::L)
  79.      @result.push("L")
  80.    end
  81.    if Input.trigger?(Input::R)
  82.      @result.push("R")
  83.    end
  84.    if Input.trigger?(Input::UP)
  85.      @result.push("上")
  86.    end
  87.    if Input.trigger?(Input::DOWN)
  88.      @result.push("下")
  89.    end
  90.    if Input.trigger?(Input::LEFT)
  91.      @result.push("左")
  92.    end
  93.    if Input.trigger?(Input::RIGHT)
  94.      @result.push("右")
  95.    end
  96.    end
  97. end
  98.   if @phase == 4 and @phase4_step > 5 and @active_battler.current_action.kind == 1 and @use == true
  99.   if @result == $data_skills[@active_battler.current_action.skill_id].chain[0]
  100.     @active_battler.current_action.kind = 1
  101.     a = $data_skills[@active_battler.current_action.skill_id].chain[1]
  102.     @active_battler.current_action.skill_id = a
  103.     @action_battlers.unshift(@active_battler)
  104.     update_phase4_step1
  105.   end
  106. end
  107. update_e
  108. end
  109.   #--------------------------------------------------------------------------
  110.   # ● 生成特技行动结果
  111.   #--------------------------------------------------------------------------
  112.   def make_skill_action_result
  113.     # 获取特技
  114.     @skill = $data_skills[@active_battler.current_action.skill_id]
  115.     # 如果不是强制行动
  116.     unless @active_battler.current_action.forcing || @result != nil && [] #Eclair
  117.       # 因为 SP 耗尽而无法使用的情况下
  118.       unless @active_battler.skill_can_use?(@skill.id)
  119.         # 清除强制行动对像的战斗者
  120.         $game_temp.forcing_battler = nil
  121.         # 移至步骤 1
  122.         @phase4_step = 1
  123.         return
  124.       end
  125.     end
  126.     @result = [] #Eclair
  127.     # 消耗 SP
  128.     @active_battler.sp -= @skill.sp_cost
  129.     # 刷新状态窗口
  130.     @status_window.refresh
  131.     # 在帮助窗口显示特技名
  132.     @help_window.set_text(@skill.name, 1)
  133.     # 设置动画 ID
  134.     @animation1_id = @skill.animation1_id
  135.     @animation2_id = @skill.animation2_id
  136.     # 设置公共事件 ID
  137.     @common_event_id = @skill.common_event_id
  138.     # 设置对像侧战斗者
  139.     set_target_battlers(@skill.scope)
  140.     # 应用特技效果
  141.     for target in @target_battlers
  142.       target.skill_effect(@active_battler, @skill)
  143.     end
  144.   end
  145. end
  146. #==============================================================================
  147. #   组合键连续特技系统 By 绿发的Eclair
  148. #==============================================================================
复制代码

作者: dadongliang    时间: 2010-8-13 11:16
提示: 作者被禁止或删除 内容自动屏蔽
作者: liqunsz    时间: 2010-8-13 12:24
需要范例工程么?
传说-摁键连技.rar (188.58 KB, 下载次数: 63)
作者: dadongliang    时间: 2010-8-13 22:08
提示: 作者被禁止或删除 内容自动屏蔽
作者: dadongliang    时间: 2010-8-13 22:31
提示: 作者被禁止或删除 内容自动屏蔽
作者: dbshy    时间: 2010-8-13 22:46
回复 dadongliang 的帖子

站上有教程 搜索禾西 解读默认战斗系统 很详细

不过我的建议是自己搞懂 战斗系统就在于精妙的刷新
注意看update那4个阶段 如果不懂可以来提问区问

   
作者: dadongliang    时间: 2010-8-14 12:02
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1