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

Project1

 找回密码
 注册会员
搜索
查看: 1380|回复: 0

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
146
在线时间
17 小时
注册时间
2022-3-12
帖子
13
发表于 2022-10-29 00:04:26 | 显示全部楼层 |阅读模式

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

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

x
这里有一个代码,但是没法实现,整合出问题了
RUBY 代码复制
  1. =begin
  2.       RGSS3
  3.  
  4.       ★ 断末魔 ★
  5.  
  6.       戦闘不能になる直前に指定のスキルを発動するエネミーを作れます。
  7.       
  8.       ● 仕様 ●==========================================================
  9.       断末魔を発動したエネミーは、
  10.       自身を断末魔スキルの効果対象にすることはできません。
  11.       ====================================================================
  12.       
  13.       ● 使い方 ●========================================================
  14.       エネミーのメモ欄に「断末魔:n」と記述してください。
  15.       nには断末魔として発動させるスキルIDを指定してください。
  16.       ====================================================================
  17.       
  18.       ver1.00
  19.  
  20.       Last Update : 2015/05/13
  21.       5/13 : RGSS2にあったものを移植
  22.       
  23.       ろかん   http://kaisou-ryouiki.sakura.ne.jp/
  24. =end
  25.  
  26. $rsi ||= {}
  27. $rsi["断末魔"] = true
  28.  
  29. class RPG::Enemy < RPG::BaseItem
  30.   def death_throes_id
  31.     unless @death_throes_id
  32.       @death_throes_id = 0
  33.       self.note.each_line{|line|
  34.         if line =~ /断末魔:(\d+)/i
  35.           @death_throes_id = $1.to_i
  36.           break
  37.         end
  38.       }
  39.     end
  40.     @death_throes_id
  41.   end
  42. end
  43.  
  44. class << BattleManager
  45.   #--------------------------------------------------------------------------
  46.   # ● ターン終了
  47.   #--------------------------------------------------------------------------
  48.   alias death_throes_turn_end turn_end
  49.   def turn_end
  50.     death_throes_turn_end if @phase
  51.   end
  52. end
  53.  
  54. class Game_Battler < Game_BattlerBase
  55.   #--------------------------------------------------------------------------
  56.   # ● 断末魔をあげるバトラーであるか
  57.   #--------------------------------------------------------------------------
  58.   def death_throes?
  59.     false
  60.   end
  61. end
  62.  
  63. class Game_Action
  64.   #--------------------------------------------------------------------------
  65.   # ● 断末魔のターゲットの配列作成
  66.   #--------------------------------------------------------------------------
  67.   def make_targets_with_death_throes
  68.     if item.for_opponent?
  69.       targets_for_opponents
  70.     elsif item.for_friend?
  71.       targets_for_friends_with_death_throes
  72.     else
  73.       []
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 味方に対するターゲット
  78.   #--------------------------------------------------------------------------
  79.   def targets_for_friends_with_death_throes
  80.     if item.for_user?
  81.       []
  82.     elsif item.for_dead_friend?
  83.       if item.for_one?
  84.         [friends_unit.smooth_dead_target(@target_index)]
  85.       else
  86.         friends_unit.dead_members
  87.       end
  88.     elsif item.for_friend?
  89.       result = friends_unit.alive_members
  90.       result.delete(@subject)
  91.       if item.for_one?
  92.         result.empty? ? [] : [result.sample]
  93.       else
  94.         result
  95.       end
  96.     end
  97.   end
  98. end
  99.  
  100. class Game_Enemy < Game_Battler
  101.   #--------------------------------------------------------------------------
  102.   # ● 公開インスタンス変数
  103.   #--------------------------------------------------------------------------
  104.   attr_accessor :gave_death_throes
  105.   #--------------------------------------------------------------------------
  106.   # ● オブジェクト初期化
  107.   #--------------------------------------------------------------------------
  108.   alias death_throes_initialize initialize
  109.   def initialize(index, enemy_id)
  110.     death_throes_initialize(index, enemy_id)
  111.     @gave_death_throes = false # 既に断末魔をあげたかの判断に利用
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 断末魔をあげるバトラーであるか
  115.   #--------------------------------------------------------------------------
  116.   def death_throes?
  117.     @result.added_states.include?(death_state_id) && !death_throes_id.zero? && !@gave_death_throes
  118.   end
  119.   #--------------------------------------------------------------------------
  120.   # ● 断末魔で発動するスキルID
  121.   #--------------------------------------------------------------------------
  122.   def death_throes_id
  123.     enemy.death_throes_id
  124.   end
  125.   #--------------------------------------------------------------------------
  126.   # ● 戦闘不能から復活
  127.   #--------------------------------------------------------------------------
  128.   def revive
  129.     super
  130.     @gave_death_throes = false
  131.   end
  132.   #--------------------------------------------------------------------------
  133.   # ● 戦闘不能判定
  134.   #--------------------------------------------------------------------------
  135.   def dead?
  136.     (!death_throes_id.zero? && !@gave_death_throes) ? false : super
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # ● 生存判定
  140.   #--------------------------------------------------------------------------
  141.   def alive?
  142.     (!death_throes_id.zero? && !@gave_death_throes) ? true : super
  143.   end
  144.   #--------------------------------------------------------------------------
  145.   # ● 断末魔行動の作成
  146.   #--------------------------------------------------------------------------
  147.   def make_death_throes_actions
  148.     clear_actions
  149.     action = Game_Action.new(self, true)
  150.     action.set_skill(death_throes_id)
  151.     @actions.push(action)
  152.   end
  153. end
  154.  
  155. class Window_BattleLog < Window_Selectable
  156.   #--------------------------------------------------------------------------
  157.   # ● 断末魔用メソッドの設定
  158.   #--------------------------------------------------------------------------
  159.   def method_death_throes=(method)
  160.     @method_death_throes = method
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 影響を受けたステータスの表示
  164.   #--------------------------------------------------------------------------
  165.   alias death_throes_display_affected_status display_affected_status
  166.   def display_affected_status(target, item)
  167.     if target.death_throes?
  168.       wait_and_clear
  169.       last_added_states = target.result.added_states.dup
  170.       @method_death_throes.call(target)
  171.       target.result.added_states = last_added_states
  172.       death_throes_display_affected_status(target, item)
  173.       wait_and_clear
  174.       BattleManager.judge_win_loss
  175.     else
  176.       death_throes_display_affected_status(target, item)
  177.     end
  178.   end
  179. end
  180.  
  181. class Scene_Battle < Scene_Base
  182.   #--------------------------------------------------------------------------
  183.   # ● ログウィンドウの作成
  184.   #--------------------------------------------------------------------------
  185.   alias death_throes_create_log_window create_log_window
  186.   def create_log_window
  187.     death_throes_create_log_window
  188.     @log_window.method_death_throes = method(:process_death_throes)
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 断末魔の処理
  192.   #--------------------------------------------------------------------------
  193.   def process_death_throes(user)
  194.     last_subject = @subject
  195.     @subject = user
  196.     @subject.make_death_throes_actions
  197.     targets = @subject.current_action.make_targets_with_death_throes.compact
  198.     unless targets.empty?
  199.       if @subject.current_action
  200.         @status_window.open
  201.         use_death_throes(targets)
  202.         @subject.remove_current_action
  203.         process_action_end
  204.       end
  205.     end
  206.     @subject.gave_death_throes = true
  207.     @subject = last_subject
  208.     update_for_wait
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ● 断末魔の使用
  212.   #--------------------------------------------------------------------------
  213.   def use_death_throes(targets)
  214.     @subject.sprite_effect_type = :whiten
  215.     item = @subject.current_action.item
  216.     @log_window.display_use_item(@subject, item)
  217.     @subject.use_item(item)
  218.     refresh_status
  219.     show_animation(targets, item.animation_id)
  220.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  221.     @log_window.wait_and_clear
  222.   end
  223. end


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

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

本版积分规则

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

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

GMT+8, 2024-3-29 12:42

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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