#----------------------------------------------------------------------------
# SRW風「気力」カスタム by 貪藻矢射妥←
#----------------------------------------------------------------------------
# 原作: ◆ SRW風「気力」 - KGC_SRWSpirit ◆
# ◇ Last update : 2008/01/10 ◇
# 原作者: TOMY様
# HP: Kamesoft
# アドレス: http://ytomy.sakura.ne.jp/
#
# ≪消費SP改造[SPCostAlter]≫より下
#
# 改造内容:
# ・原作通り、戦闘中のみ気力が上下するように変更
# ・原作通り(?)、エネミー撃破時にパーティー全員の気力が上がるように変更
# ・最近のスパロボにある『気力限界突破』、『気力覚醒』に対応
# ・装備による初期気力増減を追加
# ・被ダメージ時、攻撃回避時に気力増加(オプション)
#
# メモ
# ・強気、弱気などで攻撃を喰らった際に気力が上下する・・・のは未対応
# ・claimh様などの撃破数カウンタによって初期気力を増加する・・・のは未対応
#
#============================================================================
# 変更点
#
# 2012:01:21
# ・装備による初期気力増減に対応
# ・攻撃がミスの場合でも気力が増加するバグを修正
#
# 2013:06:01
# ・近年のスパロボにある気力覚醒を追加
# ・気力限界突破での上限値を255から200に引き下げ
#
# 2016:03:01
# ・武器による命中精度対応
# ・被ダメージ時、攻撃回避時に気力増加機能追加
#
# 2024:05:01
# ・固定文字列対応
#
# 2024:06:01
# ・スクリプト中で使用されてる文字列の定義化追加
# ★ カスタマイズ項目 - Customize ★
#==============================================================================
module KGC
# ◆気力基準値(初期値)
SRWS_SPIRIT_STD = 100
# ◆気力最大値
SRWS_SPIRIT_MAX = 150
# ◆気力限界突破値
SRWS_SPIRIT_MAX_LB = 200
# ◆気力覚醒値
SRWS_SPIRIT_MAX_DISL = 255
# ◆気力最小値
SRWS_SPIRIT_MIN = 50
# ◆通常攻撃影響度
# 高いほどダメージ増減幅が大きくなる。
# 気力が基準値より高いほどダメージ増加、低いほど減少。
# 負数を指定すると効果が逆転。
SRWS_ATTACK_INF = 100
# ◆防御影響度
SRWS_GUARD_INF = -75
# ◆回復影響度
SRWS_RECOVER_INF = -100
# ◆命中率影響度
SRWS_HIT_INF = -20
# ◆通常攻撃時変動値
SRWS_ATTACK_FLUC = 1
# ◆ダメージ時変動値
SRWS_DAMAGE_FLUC = 1
# ◆回復時変動値
SRWS_RECOVER_FLUC = -1
# ◆撃破時変動値
SRWS_DEFEAT_FLUC = 5
# ◆回避時変動値
SRWS_EVAL_FLUC = 1
# ◆気力限界突破ステートID
SEWS_SPIRIT_LB_STATE = 296
# ◆気力覚醒ステートID
SEWS_SPIRIT_DISL_STATE = 297
# ◆被ダメージ時気力増加ステートID
SEWS_SPIRIT_DMG_UP_STATE = 298
# ◆回避時気力増加ステートID
SEWS_SPIRIT_EVA_UP_STATE = 299
# ◆「気力」の名称
SRWS_SPIRIT_NAME = "気力"
# ◆初期気力増加用ステート名称
SRWS_INI_SP_NAME = "初期気力"
# ◆気力増減属性名称
SRWS_SP_UP_DW_NAME = "気力増減"
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["SRWSpirit"] = true
if $game_special_elements == nil
$game_special_elements = {}
$data_system = load_data(FIX_PATH::PATH_DATA_SYSM)
end
# 気力条件スキル属性
$game_special_elements["skill_spirit"] =
/(?:(?:必要気力)|(?:NeedSpirit))(\d+)((?:以下)|(?:Below))?/
# スキル使用時気力増加属性
$game_special_elements["skill_spirit_fluc"] =
/(?:(?:気力増加)|(?:SpiritFluc))([-])?(\d+)/
# 気力増減属性
$game_special_elements["spirit_id"] =
$data_system.elements.index(KGC::SRWS_SP_UP_DW_NAME)
if $game_special_elements["spirit_id"] == nil
$game_special_elements["spirit_id"] =
$data_system.elements.index("SpiritFluctuate")
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
# アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
# の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● セットアップ
# actor_id : アクター ID
#--------------------------------------------------------------------------
alias ki_pow_setup setup
def setup(actor_id)
@spirit_plus = 0
ki_pow_setup(actor_id)
end
def base_spirit
n = KGC::SRWS_SPIRIT_STD
return n + spirit_plus
#return spirit_plus
end
def spirit_plus
ini_plus = 0
for id in @states
if $data_states[id].name =~ /^#{KGC::SRWS_INI_SP_NAME}([0-9]+)/
ini_plus += $1.to_i
end
end
return ini_plus
end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
# エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
# 内部で使用されます。
#==============================================================================
class Game_Enemy < Game_Battler
def base_spirit
return KGC::SRWS_SPIRIT_STD
end
end
#==============================================================================
# ■ Game_Battler (分割定義 1)
#==============================================================================
class Game_Battler
attr_accessor :first_flg
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KGC_SRWSpirit initialize
def initialize
initialize_KGC_SRWSpirit
@spirit = KGC::SRWS_SPIRIT_STD
@spirit_plus = 0
@first_flg = false
end
#--------------------------------------------------------------------------
# ● 命中率の取得
#--------------------------------------------------------------------------
alias hit_KGC_SRWSpirit hit
def hit
nt = KGC::SRWS_SPIRIT_STD
rt = KGC::SRWS_SPIRIT_STD * 100
n = hit_KGC_SRWSpirit
n += (100 + n * KGC::SRWS_HIT_INF * (@spirit.to_f - nt) / rt) / 100
return Integer(n)
end
def get_spirit_limit_break(n)
if @states.include?(KGC::SEWS_SPIRIT_DISL_STATE)
n = [[n, KGC::SRWS_SPIRIT_MIN].max, KGC::SRWS_SPIRIT_MAX_DISL].min
elsif @states.include?(KGC::SEWS_SPIRIT_LB_STATE)
n = [[n, KGC::SRWS_SPIRIT_MIN].max, KGC::SRWS_SPIRIT_MAX_LB].min
else
n = [[n, KGC::SRWS_SPIRIT_MIN].max, KGC::SRWS_SPIRIT_MAX].min
end
return n
end
#--------------------------------------------------------------------------
# ● 気力取得
#--------------------------------------------------------------------------
def spirit
@spirit = KGC::SRWS_SPIRIT_STD if @spirit == nil
# フラグ初期化
@first_flg = false if @first_flg == nil
# 一番最初のみ、初期気力増減分を追加する
if !@first_flg
n = get_spirit_limit_break(base_spirit + @spirit_plus)
if n > @spirit
@spirit = n
$first_flg = true
end
end
return @spirit
end
#--------------------------------------------------------------------------
# ● 気力変更
#--------------------------------------------------------------------------
def spirit=(n)
@spirit = KGC::SRWS_SPIRIT_STD if @spirit == nil
@spirit = get_spirit_limit_break(n)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Battler (分割定義 3)
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# ● 気力によるダメージ値調整
#--------------------------------------------------------------------------
def adjust_damage_spirit(user, value)
nt = KGC::SRWS_SPIRIT_STD
rt = KGC::SRWS_SPIRIT_STD * 100
n = value * KGC::SRWS_ATTACK_INF * (user.spirit - nt) / rt
value += n
n = value * KGC::SRWS_GUARD_INF * (self.spirit - nt) / rt
value += n
return value
end
#--------------------------------------------------------------------------
# ● 気力による回復量調整
#--------------------------------------------------------------------------
def adjust_recover_spirit(user, value)
nt = KGC::SRWS_SPIRIT_STD
rt = KGC::SRWS_SPIRIT_STD * 100
n = value * KGC::SRWS_RECOVER_INF * (self.spirit - nt) / rt
value += n
return value
end
#--------------------------------------------------------------------------
# ● 通常攻撃の効果適用
#--------------------------------------------------------------------------
alias attack_effect_KGC_SRWSpirit attack_effect
def attack_effect(attacker)
last_hp = self.hp
# 攻撃者の気力変動
#attacker.spirit += KGC::SRWS_ATTACK_FLUC
result = attack_effect_KGC_SRWSpirit(attacker)
# ダメージを受けた場合
if result && self.damage.is_a?(Numeric) && self.damage > 0
# 被攻撃者の気力変動
if @states.include?(KGC::SEWS_SPIRIT_DMG_UP_STATE)
self.spirit += KGC::SRWS_DAMAGE_FLUC
end
# ダメージ値調整
self.damage = adjust_damage_spirit(attacker, self.damage)
self.hp = last_hp - self.damage
end
# 回避時
if result && self.damage == Vocab::MISS_WORD &&
@states.include?(KGC::SEWS_SPIRIT_EVA_UP_STATE)
self.spirit += KGC::SRWS_EVAL_FLUC
end
# 撃破時
if self.is_a?(Game_Enemy)
if self.dead?
attacker.spirit += KGC::SRWS_DEFEAT_FLUC
for index in 0...$game_party.actors.size
$game_party.smooth_target_actor(index).spirit += KGC::SRWS_ATTACK_FLUC
end
elsif self.damage.is_a?(Numeric) && self.damage > 0
attacker.spirit += KGC::SRWS_ATTACK_FLUC
end
end
return result
end
#--------------------------------------------------------------------------
# ● スキルの効果適用
#--------------------------------------------------------------------------
alias skill_effect_KGC_SRWSpirit skill_effect
def skill_effect(user, skill)
# 使用者の気力変動
skill.element_set.compact.each { |element|
if $game_special_elements["skill_spirit_fluc"] =~
$data_system.elements[element]
i = $2.to_i
user.spirit += ($1 == Vocab::MINUS_WORD ? -i : i)
end
}
# 無敵判定
if $imported["Invincible"] && self.invincible?(skill)
self.damage = Vocab::MISS_WORD
self.critical = false
return false
end
# 気力増減属性を持っていない場合
unless skill.element_set.include?($game_special_elements["spirit_id"])
last_hp = self.hp
result = skill_effect_KGC_SRWSpirit(user, skill)
# 気力増減属性を持っておらず、かつ割合ダメージではない、
# かつ消費SP比例ダメージではない場合
if result && !skill.element_set.include?($game_special_elements["spirit_id"]) &&
(!$imported["RateDamage"] || KGC::check_damage_rate(skill) == nil) &&
(!$imported["SPCostAlter"] || !skill.consume_sp_rate?)
# 被ダメージ時
if self.damage.is_a?(Numeric)
# ダメージが正
if self.damage > 0
# 気力変動
if @states.include?(KGC::SEWS_SPIRIT_DMG_UP_STATE)
self.spirit += KGC::SRWS_DAMAGE_FLUC
end
# ダメージ値調整
self.damage = adjust_damage_spirit(user, self.damage)
# ダメージが負
elsif self.damage < 0
# 気力変動
self.spirit += KGC::SRWS_RECOVER_FLUC
# 回復量調整
self.damage = adjust_recover_spirit(user, self.damage)
end
# HP減少処理
self.hp = last_hp - self.damage
# 撃破時
if self.is_a?(Game_Enemy) && self.dead?
user.spirit += KGC::SRWS_DEFEAT_FLUC
for index in 0...$game_party.actors.size
$game_party.smooth_target_actor(index).spirit += KGC::SRWS_ATTACK_FLUC
end
else
user.spirit += KGC::SRWS_ATTACK_FLUC
end
# 回避時
elsif self.damage == Vocab::MISS_WORD &&
@states.include?(KGC::SEWS_SPIRIT_EVA_UP_STATE)
self.spirit += KGC::SRWS_EVAL_FLUC
end
end
return result
end
# クリティカルフラグをクリア
self.critical = false
# スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
# またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
if ((skill.scope == 3 || skill.scope == 4) && self.hp == 0) ||
((skill.scope == 5 || skill.scope == 6) && self.hp >= 1)
# メソッド終了
return false
end
# 有効フラグをクリア
@effective = false
# コモンイベント ID が有効の場合は有効フラグをセット
@effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
if $OuterFlgs["Weapon_HitRate"]
base_hitrate = get_hitrate_base(user)
else
base_hitrate = 100
end
hit_result = (rand(base_hitrate) < hit)
# 不確実なスキルの場合は有効フラグをセット
@effective |= hit < 100
# 命中の場合
if hit_result == true
# ステート変化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# "威力" 分気力を増減
self.damage = -skill.power
self.spirit += skill.power
# 戻る
return true
end
return false
end
#--------------------------------------------------------------------------
# ● アイテムの効果適用
#--------------------------------------------------------------------------
alias item_effect_KGC_SRWSpirit item_effect
def item_effect(item)
# 気力増減属性を持っていない場合
unless item.element_set.include?($game_special_elements["spirit_id"])
result = item_effect_KGC_SRWSpirit(item)
# ダメージが存在する場合
if result && self.damage.is_a?(Numeric)
# ダメージが正
if self.damage > 0
self.spirit += KGC::SRWS_DAMAGE_FLUC
# ダメージが負
elsif self.damage < 0
self.spirit += KGC::SRWS_RECOVER_FLUC
end
end
return result
end
# 無敵判定
if $imported["Invincible"] && self.invincible?(item)
self.damage = Vocab::MISS_WORD
self.critical = false
return false
end
# クリティカルフラグをクリア
self.critical = false
# アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、
# またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
if ((item.scope == 3 || item.scope == 4) && self.hp == 0) ||
((item.scope == 5 || item.scope == 6) && self.hp >= 1)
# メソッド終了
return false
end
# 有効フラグをクリア
@effective = false
# コモンイベント ID が有効の場合は有効フラグをセット
@effective |= item.common_event_id > 0
# 命中判定
if $OuterFlgs["Weapon_HitRate"]
base_hitrate = get_hitrate_base(self, false)
else
base_hitrate = 100
end
hit_result = (rand(base_hitrate) < item.hit)
# 不確実なスキルの場合は有効フラグをセット
@effective |= item.hit < 100
# 命中の場合
if hit_result == true
# "HP回復量" 分気力を増減
self.damage = -item.recover_hp
self.spirit -= self.damage
# 戻る
return true
end
return false
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Actor
#==============================================================================
KGC_Game_Actor_first = "SRWSpirit" unless defined?(KGC_Game_Actor)
module KGC_Game_Actor
#--------------------------------------------------------------------------
# ● スキルの使用可能判定
#--------------------------------------------------------------------------
if defined?(skill_can_use?) && !@_skill_can_use_srwspirit
alias skill_can_use_KGC_SRWSpirit skill_can_use?
else
@_skill_can_use_srwspirit = true
end
def skill_can_use?(skill_id)
result = true
# 気力条件確認
$data_skills[skill_id].element_set.compact.each { |element|
if $game_special_elements["skill_spirit"] =~ $data_system.elements[element]
if $2 == "以下"
# 気力が指定値を超えている場合は使用不可
result = false if self.spirit > $1.to_i
else
# 気力が足りない場合は使用不可
result = false if self.spirit < $1.to_i
end
end
}
if defined?(skill_can_use_KGC_SRWSpirit)
return result & skill_can_use_KGC_SRWSpirit(skill_id)
else
return result & super
end
end
module_function :skill_can_use?
public :skill_can_use?
end
class Game_Actor
include KGC_Game_Actor
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# ● パーティメンバーの気力をリセット
#--------------------------------------------------------------------------
def reset_spirit
self.actors.each { |actor|
actor.spirit = KGC::SRWS_SPIRIT_STD
}
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Status
#==============================================================================
class Window_Status < Window_Base
include RUBY_SYS
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
alias refresh_KGC_SRWSpirit refresh
def refresh
refresh_KGC_SRWSpirit
draw_actor_spirit(@actor, 320, 112)
end
end
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 気力描画
#--------------------------------------------------------------------------
def draw_actor_spirit(actor, x, y)
if $scene.is_a?(Scene_Battle)
x_plus = 40
else
x_plus = 80
end
font_name = self.contents.font.name
self.contents.font.name = DRAWFONT
draw_shadow_text([x, y, 80, 32], KGC::SRWS_SPIRIT_NAME, system_color)
self.contents.font.name = DRAWFONT2
draw_shadow_text([x + x_plus, y, 84, 32], actor.spirit.to_s, normal_color, 2)
self.contents.font.name = font_name
end
end
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 24, 120)
draw_actor_sp(actor, actor_x, 48, 120)
draw_actor_spirit(actor, actor_x, 64)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 84, 120, 32, Vocab::LV_UP_WORD)
else
draw_actor_state(actor, actor_x, 84)
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Battle (分割定義 1)
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● バトル終了
# result : 結果 (0:勝利 1:逃走 2:敗北)
#--------------------------------------------------------------------------
alias battle_end_KGC_SRWSpirit battle_end
def battle_end(result)
=begin
unless @battle_spirit_added
# 結果で分岐
case result
when 0 # 勝利
$game_party.actors.each { |actor|
actor.spirit += KGC::SRWS_VICTORY_FLUC
}
when 1 # 逃走
$game_party.actors.each { |actor|
actor.spirit += KGC::SRWS_ESCAPE_FLUC
}
end
@battle_spirit_added = true
end
=end
# 気力を初期値に戻す
$game_party.actors.each { |actor|
actor.spirit = KGC::SRWS_SPIRIT_STD
actor.first_flg = nil
}
battle_end_KGC_SRWSpirit(result)
end
end
|