ページ 1 / 1
【解決済み】(Ace) 特定の敵がMP0の際、戦闘不能
Posted: 2016年8月31日(水) 06:29
by nira
FF6の魔法生物のような、特定の敵のMPが0になった際に戦闘不能になるシステムを作りたいと思っています。
イベントのステート付加でも作れますが、MPダメージを与えた瞬間に処理したいので、こちらに投稿させて頂きました。
モジュールでワードを設定するような形にしていただけると助かります。
お手数をおかけいたしますが、宜しくお願い致します。
Re: (Ace) 特定の敵がMP0の際、戦闘不能
Posted: 2016年8月31日(水) 16:35
by ONOZUKA
敵キャラのメモ欄に<MP戦闘不能>(変更可能)と書かれていれば、
その敵キャラのみMP0でHP0か死亡ステートということですね。
私の実力ではモジュール化までは無理でしたので後続の回答者向けにメモを残します。
バトルシーンにおける定義
トループ中の敵のメモ欄にキーワードが存在するか?
キーワードが存在する敵のトループ中のIDを取得
MPが0であれば全てにHPを0もしくは死亡ステートを付与する。
下のスクリプトは戦闘のスクリプト挿入なおかつ個数ごとに設定が必要です。
あくまで参考用ではありますので、実際に使用することは想定していません。
コード: 全て選択
troop_enemy = $game_variables[]
dead_state_id = $game_variables[]
if $game_troop.members[troop_enemy].mp == then
iterate_enemy_index(troop_enemy) do |enemy|
already_dead = enemy.dead?
anemy.add_state(dead_state_id)
if enemy.dead?
enemy.perform_collapse_effect
end
end
end
Re: (Ace) 特定の敵がMP0の際、戦闘不能
Posted: 2016年9月02日(金) 14:09
by nira
返事が遅くなりました。申し訳ございません。
モジュールではなくても、変数で管理するやり方でも大丈夫です。
Game_Battlerクラス148行目の
コード: 全て選択
#--------------------------------------------------------------------------
# ● 戦闘不能になる
#--------------------------------------------------------------------------
def die
@hp = 0 || @mp = 0
clear_states
clear_buffs
end
#--------------------------------------------------------------------------
# ● 戦闘不能から復活
#--------------------------------------------------------------------------
def revive
@hp = 1 if @hp == 0 || @mp = 1 if @mp == 0
end
Game_BattlerBaseクラス501行目の
コード: 全て選択
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
state_resist_set.each {|state_id| erase_state(state_id) }
@hp = [[@hp, mhp].min, 0].max
@mp = [[@mp, mmp].min, 0].max
@hp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
@mp == 0 ? add_state(death_state_id) : remove_state(death_state_id)
end
@mpを指定番号のエネミーのmpにしたいのですが、自分の知識ではよく分かりません・・・・・・
Re: (Ace) 特定の敵がMP0の際、戦闘不能
Posted: 2016年9月03日(土) 21:37
by faida
適当ですがこんなんでどうでしょう。
コード: 全て選択
# MP戦闘不能を持つキャラはMPがちょうど0になる場合スキルを使用できない
BATTLER_NOUSEMP_DEATH = true
class RPG::BaseItem
def mp0_death
return @mp0_death if !@mp0_death.nil?
@mp0_death = (note =~ /<MP戦闘不能>/ ? true : false)
end
end
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
alias mp0_death_refresh refresh
def refresh
mp0_death_refresh
check_mp0_death
end
def check_mp0_death
if mp0_death?
(@hp == 0 || @mp == 0) ? add_state(death_state_id) :
remove_state(death_state_id)
end
end
def mp0_death?
feature_objects.any?{|a|a.mp0_death}
end
end
if BATTLER_NOUSEMP_DEATH
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● スキル使用コストの支払い可能判定
#--------------------------------------------------------------------------
alias mp0_death_skill_cost_payable? skill_cost_payable?
def skill_cost_payable?(skill)
return false if !mp0_death_skill_cost_payable?(skill)
!mp0_death? || mp > skill_mp_cost(skill)
end
end
else
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
mp0_death_refresh
return if SceneManager.scene.instance_variable_get(:@subject) == self
check_mp0_death
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 戦闘行動終了時の処理
#--------------------------------------------------------------------------
alias mp0_death_process_action_end process_action_end
def process_action_end
@subject.check_mp0_death
@log_window.display_changed_states(@subject)
mp0_death_process_action_end
end
end
end
※2018/2/28
こちらのトピックで出た不具合を修正
Re: 【解決済み】(Ace) 特定の敵がMP0の際、戦闘不能
Posted: 2016年9月04日(日) 10:53
by nira
>faidaさんへ
このスクリプトで、まさに理想としているシステムを作る事が出来ました!
RPG::BaseItemで用語を定義するのですね・・・勉強になります。
クレジットを記載し、スクリプトを利用させていただきますね。
お二方のご協力に対して心よりお礼申し上げます。