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

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 黑夜守望者
打印 上一主题 下一主题

[讨论] 脚本小白学脚本@简单技能连击效果

[复制链接]

Lv5.捕梦者

梦石
0
星屑
33143
在线时间
10485 小时
注册时间
2009-3-15
帖子
4756
11
发表于 2021-12-13 23:45:41 | 只看该作者
本帖最后由 soulsaga 于 2021-12-16 15:44 编辑

RUBY 代码复制
  1. class Game_Temp
  2.   #--------------------------------------------------------------------------
  3.   # ● 定义实例变量
  4.   #--------------------------------------------------------------------------
  5.   attr_accessor :连击FLAG
  6.   def 连击FLAG;return @连击FLAG||=false;end
  7.   end
  8.  
  9. module RPG
  10.   class Skill
  11.     attr_accessor :连击
  12.     attr_accessor :desc
  13.     attr_accessor :几率
  14.     def 连击;return @连击||=0;end
  15.     def description
  16.      description = @description.split(/@/)[0]
  17.      return description != nil ? description : ''
  18.    end
  19.    def desc
  20.      desc = @description.split(/@/)[1]
  21.      return desc != nil ? desc.to_i : 0
  22.    end
  23.    def 几率
  24.      desc = @description.split(/@/)[2]
  25.      return desc != nil ? desc.to_i : 0
  26.      end
  27.    end
  28. end
  29.  
  30. #==============================================================================
  31. # ■ Scene_Battle (分割定义 4)
  32. #------------------------------------------------------------------------------
  33. #  处理战斗画面的类。
  34. #==============================================================================
  35.  
  36. class Scene_Battle
  37. #--------------------------------------------------------------------------
  38.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  39.   #--------------------------------------------------------------------------
  40.   alias update_phase4_step5_20211213 update_phase4_step5
  41.   def update_phase4_step5
  42.     update_phase4_step5_20211213
  43.     敌全灭=true
  44.     for enemy in $game_troop.enemies
  45.     敌全灭=false if enemy.exist?
  46.     end
  47.     if @active_battler.current_action.skill_id != 0 and !敌全灭
  48.     skill=$data_skills[@active_battler.current_action.skill_id].dup
  49.     @连击||=skill.desc
  50.     # 移至步骤 2
  51.     if @连击 > 0 and skill.几率 > rand(100)
  52.     @phase4_step = 2
  53.     $game_temp.连击FLAG=true
  54.   end
  55.     @连击-=1
  56.     end
  57.   end
  58.   #--------------------------------------------------------------------------
  59.   # ● 刷新画面 (主回合步骤 6 : 刷新)
  60.   #--------------------------------------------------------------------------
  61.   alias update_phase4_step6_20211213 update_phase4_step6
  62.   def update_phase4_step6
  63.     update_phase4_step6_20211213
  64.     skill=$data_skills[@active_battler.current_action.skill_id].dup if @active_battler.current_action.skill_id != 0
  65.     @连击=nil
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 生成特技行动结果
  69.   #--------------------------------------------------------------------------
  70.   def make_skill_action_result
  71.     # 获取特技
  72.     @skill = $data_skills[@active_battler.current_action.skill_id]
  73.     # 如果不是强制行动
  74.     unless @active_battler.current_action.forcing
  75.       # 因为 SP 耗尽而无法使用的情况下
  76.       unless @active_battler.skill_can_use?(@skill.id)
  77.         # 清除强制行动对像的战斗者
  78.         $game_temp.forcing_battler = nil
  79.         # 移至步骤 1
  80.         @phase4_step = 1
  81.         return
  82.       end
  83.     end
  84.     # 消耗 SP
  85.     if $game_temp.连击FLAG
  86.       $game_temp.连击FLAG=false
  87.       else
  88.     @active_battler.sp -= @skill.sp_cost
  89.     end
  90.     # 刷新状态窗口
  91.     @status_window.refresh
  92.     # 在帮助窗口显示特技名
  93.     @help_window.set_text(@skill.name, 1)
  94.     # 设置动画 ID
  95.     @animation1_id = @skill.animation1_id
  96.     @animation2_id = @skill.animation2_id
  97.     # 设置公共事件 ID
  98.     @common_event_id = @skill.common_event_id
  99.     # 设置对像侧战斗者
  100.     set_target_battlers(@skill.scope)
  101.     # 应用特技效果
  102.     for target in @target_battlers
  103.       target.skill_effect(@active_battler, @skill)
  104.     end
  105.   end
  106. end
  107.  
  108. class Game_Battler
  109.   #--------------------------------------------------------------------------
  110.   # ● 可以使用特技的判定
  111.   #     skill_id : 特技 ID
  112.   #--------------------------------------------------------------------------
  113.   def skill_can_use?(skill_id)
  114.     return true if $game_temp.连击FLAG
  115.     # SP 不足的情况下不能使用
  116.     if $data_skills[skill_id].sp_cost > self.sp
  117.       return false
  118.     end
  119.     # 战斗不能的情况下不能使用
  120.     if dead?
  121.       return false
  122.     end
  123.     # 沉默状态的情况下、物理特技以外的特技不能使用
  124.     if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
  125.       return false
  126.     end
  127.     # 获取可以使用的时机
  128.     occasion = $data_skills[skill_id].occasion
  129.     # 战斗中的情况下
  130.     if $game_temp.in_battle
  131.       # [平时] 或者是 [战斗中] 可以使用
  132.       return (occasion == 0 or occasion == 1)
  133.     # 不是战斗中的情况下
  134.     else
  135.       # [平时] 或者是 [菜单中] 可以使用
  136.       return (occasion == 0 or occasion == 2)
  137.     end
  138.   end
  139.   end


用法 要连击的技能描术后面加上@2@50
2是指会连2次
50是指50%几率触发连击
已加无MP消耗
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
841
在线时间
85 小时
注册时间
2005-11-21
帖子
85
12
 楼主| 发表于 2021-12-14 12:51:20 | 只看该作者
soulsaga 发表于 2021-12-13 23:45
class Game_Temp
  #--------------------------------------------------------------------------
  # ● ...

大佬V5,感谢赐教!
本人自开仙境传说RO怀旧1.0服务器,QQ群552321558,人不多,娱乐用。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 20:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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