楼主: 黑夜守望者

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

[复制链接]
梦石
0
星屑
39236
在线时间
11155 小时
注册时间
2009-3-15
回帖
4768
发表于 2021-12-13 23:45:41 | 显示全部楼层
本帖最后由 soulsaga 于 2021-12-16 15:44 编辑

[pre lang="ruby"]class Game_Temp
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_accessor :连击FLAG
  def 连击FLAG;return @连击FLAG||=false;end
  end

module RPG
  class Skill
    attr_accessor :连击
    attr_accessor :desc
    attr_accessor :几率
    def 连击;return @连击||=0;end
    def description
     description = @description.split(/@/)[0]
     return description != nil ? description : ''
   end
   def desc
     desc = @description.split(/@/)[1]
     return desc != nil ? desc.to_i : 0
   end
   def 几率
     desc = @description.split(/@/)[2]
     return desc != nil ? desc.to_i : 0
     end
   end
end

#==============================================================================
# ■ Scene_Battle (分割定义 4)
#------------------------------------------------------------------------------
#  处理战斗画面的类。
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  #--------------------------------------------------------------------------
  alias update_phase4_step5_20211213 update_phase4_step5
  def update_phase4_step5
    update_phase4_step5_20211213
    敌全灭=true
    for enemy in $game_troop.enemies
    敌全灭=false if enemy.exist?
    end
    if @active_battler.current_action.skill_id != 0 and !敌全灭
    skill=$data_skills[@active_battler.current_action.skill_id].dup
    @连击||=skill.desc
    # 移至步骤 2
    if @连击 > 0 and skill.几率 > rand(100)
    @phase4_step = 2
    $game_temp.连击FLAG=true
  end
    @连击-=1
    end
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面 (主回合步骤 6 : 刷新)
  #--------------------------------------------------------------------------
  alias update_phase4_step6_20211213 update_phase4_step6
  def update_phase4_step6
    update_phase4_step6_20211213
    skill=$data_skills[@active_battler.current_action.skill_id].dup if @active_battler.current_action.skill_id != 0
    @连击=nil
  end
  #--------------------------------------------------------------------------
  # ● 生成特技行动结果
  #--------------------------------------------------------------------------
  def make_skill_action_result
    # 获取特技
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # 如果不是强制行动
    unless @active_battler.current_action.forcing
      # 因为 SP 耗尽而无法使用的情况下
      unless @active_battler.skill_can_use?(@skill.id)
        # 清除强制行动对像的战斗者
        $game_temp.forcing_battler = nil
        # 移至步骤 1
        @phase4_step = 1
        return
      end
    end
    # 消耗 SP
    if $game_temp.连击FLAG
      $game_temp.连击FLAG=false
      else
    @active_battler.sp -= @skill.sp_cost
    end
    # 刷新状态窗口
    @status_window.refresh
    # 在帮助窗口显示特技名
    @help_window.set_text(@skill.name, 1)
    # 设置动画 ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # 设置公共事件 ID
    @common_event_id = @skill.common_event_id
    # 设置对像侧战斗者
    set_target_battlers(@skill.scope)
    # 应用特技效果
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
end

class Game_Battler
  #--------------------------------------------------------------------------
  # ● 可以使用特技的判定
  #     skill_id : 特技 ID
  #--------------------------------------------------------------------------
  def skill_can_use?(skill_id)
    return true if $game_temp.连击FLAG
    # SP 不足的情况下不能使用
    if $data_skills[skill_id].sp_cost > self.sp
      return false
    end
    # 战斗不能的情况下不能使用
    if dead?
      return false
    end
    # 沉默状态的情况下、物理特技以外的特技不能使用
    if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
      return false
    end
    # 获取可以使用的时机
    occasion = $data_skills[skill_id].occasion
    # 战斗中的情况下
    if $game_temp.in_battle
      # [平时] 或者是 [战斗中] 可以使用
      return (occasion == 0 or occasion == 1)
    # 不是战斗中的情况下
    else
      # [平时] 或者是 [菜单中] 可以使用
      return (occasion == 0 or occasion == 2)
    end
  end
  end[/pre]

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

使用道具 举报

梦石
0
星屑
846
在线时间
85 小时
注册时间
2005-11-21
回帖
62
 楼主| 发表于 2021-12-14 12:51:20 | 显示全部楼层
soulsaga 发表于 2021-12-13 23:45
class Game_Temp
  #--------------------------------------------------------------------------
  # ● ...

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

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部