查看: 1919|回复: 3

[已经解决] 能帮忙看一看我什么这段脚本报误吗?

[复制链接]
梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

发表于 2015-5-24 21:31:30 | 显示全部楼层 |阅读模式

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

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

×
使用了tamura 的 自爆スキル 脚本 和 ろかん的 断末魔 脚本
自爆スキル脚本[pre lang="ruby"]=begin
RPGツクールVXACE
自爆スキル 作成サポートスクリプト

2012年12月28日
tamuraさんは遊び足りない
http://tamurarpgvx.blog137.fc2.com/

【使い方】
スクリプトエディタを開き、左のリストを下にスクロール。
(ここに追加)の下で右クリック・挿入。
空白のファイルが新しく出来るので、
右の広い空白の部分にこのファイルを貼り付けます。



【使用方法】
① まず、このスクリプトを導入します。
どこでもOKのハズですが、なるべくならScene_Battleのすぐ下に。


② 使用していないコモンイベントを選び、
イベントコマンド「スクリプト」を使って

SceneManager.scene.ret_subject.add_state(1)
SceneManager.scene.subject_update

と記述します。
このコモンイベントには、スキルを使用した人を戦闘不能にする という効果があります。


③ 自爆スキルを、データベースのスキルに作ります。
使用効果の欄に、
「その他」タブ コモンイベント ②で作成したコモンイベントを指定します。



【更新履歴】

=end


class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 行動主体者
  #--------------------------------------------------------------------------
  def ret_subject
    return @subject
  end
  #--------------------------------------------------------------------------
  # ● 行動主体者 死亡ならばコラプス
  #--------------------------------------------------------------------------
  def subject_update
    @log_window.display_added_states(@subject)
  end
end[/pre]


插入脚本以后,一旦打败带有临死技能的敌人就会报误:
QQ截图20150524212559.png

断末魔脚本[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]

用头画头像,用脚写脚本
梦石
0
星屑
166
在线时间
454 小时
注册时间
2015-2-25
回帖
358
发表于 2015-5-26 11:37:44 | 显示全部楼层
看報錯內容,當前場景是地圖而不是戰鬥所以出錯了..

看不懂日文

SceneManager.scene.ret_subject.add_state(1)
SceneManager.scene.subject_update

是讓你加在哪的?

点评

那你是什麼情況下報錯的?  发表于 2015-5-27 00:41
找到了,它写着要在技能上连接到公共事件上。不过我并没有在战斗以外的时候调用那个公共事件啊……  发表于 2015-5-27 00:38
會不會是你加了,然後在戰鬥外使用該技能了  发表于 2015-5-27 00:37
額 不過你應該加了吧 加了才會報錯吧? 目測是讓你加在技能觸發的公共事件中...?  发表于 2015-5-27 00:36
那个我也不知道是哪里加的了……  发表于 2015-5-26 22:31
回复

使用道具 举报

梦石
10
星屑
39550
在线时间
1919 小时
注册时间
2010-11-14
回帖
3214

R考场第七期纪念奖

 楼主| 发表于 2015-5-27 00:57:28 | 显示全部楼层
  @howhow1314
我设定了一个用完就会死的技能,
技能栏的公共事件那里导向了一个写着
SceneManager.scene.ret_subject.add_state(1)
SceneManager.scene.subject_update
那两句脚本的公共事件。
然而战斗中敌人一使用这个技能,在战斗结束以后刚回到地图就报误。
用头画头像,用脚写脚本
回复

使用道具 举报

梦石
0
星屑
166
在线时间
454 小时
注册时间
2015-2-25
回帖
358
发表于 2015-5-27 01:17:46 | 显示全部楼层
本帖最后由 howhow1314 于 2015-5-27 01:26 编辑

發現問題了,跟臨死技無關的...只要該技能擊殺了最後一個敵人,技能觸發的公共事件就會在戰鬥結束後才執行...

最簡單的方法是不用公共事件,不過這樣執行順序會不一樣...

main前插入

[pre lang="ruby"]def bao
  SceneManager.scene.ret_subject.add_state(1)
  SceneManager.scene.subject_update
end[/pre]

在技能的算式前加上bao;

比如[pre lang="ruby"]bao;a.atk[/pre]

也可以直接在算式前加SceneManager.scene.ret_subject.add_state(1);SceneManager.scene.subject_update;

不過算式欄長度有限




呃,不過這樣的話怎麼不直接a.add_state(1)....用公共事件是不是有什麼原因呢?

如果要用公共事件的話..在事件加上判斷場景...滿簡單的不過我現在懶得寫-  -而且這樣會變成自爆的角色在戰鬥結束後才死亡..不會怪怪的麼

加在算式的話則角色先死亡,再造成傷害....老實說我有點搞不懂這腳本的用意- -||

点评

谢谢!用了你说的方法以后不会报误了~  发表于 2015-5-27 22:50
我试过了……直接用a.add_state(1)的话敌人会死但是图像不消失……  发表于 2015-5-27 22:46

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
taroxd + 1 认可答案
KB.Driver + 10 一次最多只能给这么多呢=w=

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部