查看: 2093|回复: 0

[已经过期] 断未魔怎么实现

[复制链接]
梦石
0
星屑
146
在线时间
17 小时
注册时间
2022-3-12
回帖
4
发表于 2022-10-29 00:04:26 | 显示全部楼层 |阅读模式

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

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

×
这里有一个代码,但是没法实现,整合出问题了
[pre lang="ruby"]=begin
      RGSS3

      ★ 断末魔 ★

      戦闘不能になる直前に指定のスキルを発動するエネミーを作れます。
      
      ● 仕様 ●==========================================================
      断末魔を発動したエネミーは、
      自身を断末魔スキルの効果対象にすることはできません。
      ====================================================================
      
      ● 使い方 ●========================================================
      エネミーのメモ欄に「断末魔:n」と記述してください。
      nには断末魔として発動させるスキルIDを指定してください。
      ====================================================================
      
      ver1.00

      Last Update : 2015/05/13
      5/13 : RGSS2にあったものを移植
      
      ろかん   http://kaisou-ryouiki.sakura.ne.jp/
=end

$rsi ||= {}
$rsi["断末魔"] = true

class RPG::Enemy < RPG::BaseItem
  def death_throes_id
    unless @death_throes_id
      @death_throes_id = 0
      self.note.each_line{|line|
        if line =~ /断末魔:(\d+)/i
          @death_throes_id = $1.to_i
          break
        end
      }
    end
    @death_throes_id
  end
end

class << BattleManager
  #--------------------------------------------------------------------------
  # ● ターン終了
  #--------------------------------------------------------------------------
  alias death_throes_turn_end turn_end
  def turn_end
    death_throes_turn_end if @phase
  end
end

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 断末魔をあげるバトラーであるか
  #--------------------------------------------------------------------------
  def death_throes?
    false
  end
end

class Game_Action
  #--------------------------------------------------------------------------
  # ● 断末魔のターゲットの配列作成
  #--------------------------------------------------------------------------
  def make_targets_with_death_throes
    if item.for_opponent?
      targets_for_opponents
    elsif item.for_friend?
      targets_for_friends_with_death_throes
    else
      []
    end
  end
  #--------------------------------------------------------------------------
  # ● 味方に対するターゲット
  #--------------------------------------------------------------------------
  def targets_for_friends_with_death_throes
    if item.for_user?
      []
    elsif item.for_dead_friend?
      if item.for_one?
        [friends_unit.smooth_dead_target(@target_index)]
      else
        friends_unit.dead_members
      end
    elsif item.for_friend?
      result = friends_unit.alive_members
      result.delete(@subject)
      if item.for_one?
        result.empty? ? [] : [result.sample]
      else
        result
      end
    end
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :gave_death_throes
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias death_throes_initialize initialize
  def initialize(index, enemy_id)
    death_throes_initialize(index, enemy_id)
    @gave_death_throes = false # 既に断末魔をあげたかの判断に利用
  end
  #--------------------------------------------------------------------------
  # ● 断末魔をあげるバトラーであるか
  #--------------------------------------------------------------------------
  def death_throes?
    @result.added_states.include?(death_state_id) && !death_throes_id.zero? && !@gave_death_throes
  end
  #--------------------------------------------------------------------------
  # ● 断末魔で発動するスキルID
  #--------------------------------------------------------------------------
  def death_throes_id
    enemy.death_throes_id
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能から復活
  #--------------------------------------------------------------------------
  def revive
    super
    @gave_death_throes = false
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能判定
  #--------------------------------------------------------------------------
  def dead?
    (!death_throes_id.zero? && !@gave_death_throes) ? false : super
  end
  #--------------------------------------------------------------------------
  # ● 生存判定
  #--------------------------------------------------------------------------
  def alive?
    (!death_throes_id.zero? && !@gave_death_throes) ? true : super
  end
  #--------------------------------------------------------------------------
  # ● 断末魔行動の作成
  #--------------------------------------------------------------------------
  def make_death_throes_actions
    clear_actions
    action = Game_Action.new(self, true)
    action.set_skill(death_throes_id)
    @actions.push(action)
  end
end

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 断末魔用メソッドの設定
  #--------------------------------------------------------------------------
  def method_death_throes=(method)
    @method_death_throes = method
  end
  #--------------------------------------------------------------------------
  # ● 影響を受けたステータスの表示
  #--------------------------------------------------------------------------
  alias death_throes_display_affected_status display_affected_status
  def display_affected_status(target, item)
    if target.death_throes?
      wait_and_clear
      last_added_states = target.result.added_states.dup
      @method_death_throes.call(target)
      target.result.added_states = last_added_states
      death_throes_display_affected_status(target, item)
      wait_and_clear
      BattleManager.judge_win_loss
    else
      death_throes_display_affected_status(target, item)
    end
  end
end

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● ログウィンドウの作成
  #--------------------------------------------------------------------------
  alias death_throes_create_log_window create_log_window
  def create_log_window
    death_throes_create_log_window
    @log_window.method_death_throes = method(:process_death_throes)
  end
  #--------------------------------------------------------------------------
  # ● 断末魔の処理
  #--------------------------------------------------------------------------
  def process_death_throes(user)
    last_subject = @subject
    @subject = user
    @subject.make_death_throes_actions
    targets = @subject.current_action.make_targets_with_death_throes.compact
    unless targets.empty?
      if @subject.current_action
        @status_window.open
        use_death_throes(targets)
        @subject.remove_current_action
        process_action_end
      end
    end
    @subject.gave_death_throes = true
    @subject = last_subject
    update_for_wait
  end
  #--------------------------------------------------------------------------
  # ● 断末魔の使用
  #--------------------------------------------------------------------------
  def use_death_throes(targets)
    @subject.sprite_effect_type = :whiten
    item = @subject.current_action.item
    @log_window.display_use_item(@subject, item)
    @subject.use_item(item)
    refresh_status
    show_animation(targets, item.animation_id)
    targets.each {|target| item.repeats.times { invoke_item(target, item) } }
    @log_window.wait_and_clear
  end
end[/pre]

工程地址:
断未魔测试
链接:https://pan.baidu.com/s/1NOpFHwy1U14SIPwC9Uk47A?pwd=q7bc
提取码:q7bc
--来自百度网盘超级会员V3的分享

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

本版积分规则

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

在本版发帖返回顶部