king-exit/Scripts/_.57.rb
2024-08-31 14:17:23 -05:00

221 lines
No EOL
7.9 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ RGSS3 パーティ能力詳細設定 Ver1.02 by 星潟
#------------------------------------------------------------------------------
# 「半減する」・「二倍にする」・「無効にする」等と
# 大雑把なパーティ能力の効果を詳細に設定できるようなシステムを追加します。
# 特徴を有する項目(アクター・職業・装備品・ステート等)の
# メモ欄に特定の書式で書き込む事で設定を行います。
#
# 例
# <エンカウント率増減:-25>
# エンカウント率を25減少させます。
#
# <先制攻撃率増減:10>
# 先制攻撃率を10増加させます。
#
# <獲得金額率増減:50>
# 獲得金額率を50増加させます。
#
# <ドロップ率増減:70>
# アイテムドロップ率を70増加させます。
#------------------------------------------------------------------------------
# Ver1.01 キャッシュ化による軽量化。
# 効果を加算にするか乗算にするかを選択できるように変更。
#------------------------------------------------------------------------------
# Ver1.02 戦闘に参加していないパーティメンバーのパーティ能力を
# 得られるようにする機能を追加。
# Ver1.01の加算/乗算の計算が異常だった不具合を修正。
#==============================================================================
module DETAIL_PTA
#このスクリプトによるパーティ能力の効果を加算にするか乗算にするかを設定します。
#0で乗算、1で加算とします。
#プレイヤーに効果を明確に実感させたい場合は1をお勧めします。
TYPE = 1
#戦闘に参加していないメンバーのパーティ能力も得られるようにするかどうかを設定します。
#trueで有効、falseで無効にします。
UNBM = true
#エンカウント率増減効果設定の為のキーワードを設定します。(変更不要)
WORD1 = "エンカウント率増減"
#先制攻撃率増減効果設定の為のキーワードを設定します。(変更不要)
WORD2 = "先制攻撃率増減"
#獲得金額率増減効果設定の為のキーワードを設定します。(変更不要)
WORD3 = "獲得金額率増減"
#ドロップ率増減効果設定の為のキーワードを設定します。(変更不要)
WORD4 = "ドロップ率増減"
end
class Game_BattlerBase
#--------------------------------------------------------------------------
# パーティ能力詳細データ(個人)
#--------------------------------------------------------------------------
def extra_pta(n)
#0に各特徴のパーティ能力詳細値を加算した値を返す。
feature_objects.inject(0) {|r, f| r += f.extra_pta[n]}
end
end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# パーティ能力詳細データ(パーティ)
#--------------------------------------------------------------------------
def extra_pta(n)
#100に各アクターの先制攻撃率を加算した値を作成。
array = DETAIL_PTA::UNBM ? all_members : battle_members
data = array.inject(DETAIL_PTA::TYPE == 0 ? 100 : 0) {|r, actor| r += actor.extra_pta(n)}
#0でない場合は100.0で除算。
data /= 100.0 if data != 0
#0より小さい場合は0とする。
data = 0 if data < 0
#値を返す。
data
end
#--------------------------------------------------------------------------
# パーティ能力の所持判定
#--------------------------------------------------------------------------
alias party_ability_un_battle_members party_ability
def party_ability(ability_id)
#戦闘参加メンバーのみパーティ能力の判定を行う場合は本来の処理を行い
#そうでない場合は全メンバーで判定する。
return party_ability_un_battle_members(ability_id) if !DETAIL_PTA::UNBM
all_members.any? {|actor| actor.party_ability(ability_id) }
end
#--------------------------------------------------------------------------
# 先制攻撃の確率計算
#--------------------------------------------------------------------------
alias rate_preemptive_enh_st rate_preemptive
def rate_preemptive(troop_agi)
#本来の処理にパーティ能力詳細のデータを乗算する。
case DETAIL_PTA::TYPE
when 0;rate_preemptive_enh_st(troop_agi) * $game_party.extra_pta(1)
when 1;rate_preemptive_enh_st(troop_agi) + $game_party.extra_pta(1)
end
end
end
class Game_Player < Game_Character
#--------------------------------------------------------------------------
# エンカウント進行値の取得
#--------------------------------------------------------------------------
alias encounter_progress_value_enh_st encounter_progress_value
def encounter_progress_value
#本来の処理にパーティ能力詳細のデータを乗算する。
case DETAIL_PTA::TYPE
when 0;encounter_progress_value_enh_st * $game_party.extra_pta(0)
when 1;encounter_progress_value_enh_st + $game_party.extra_pta(0)
end
end
end
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# お金の合計計算
#--------------------------------------------------------------------------
alias gold_total_enh_st gold_total
def gold_total
#そのままでは小数点以下が生じる為、整数にする。
gold_total_enh_st.to_i
end
#--------------------------------------------------------------------------
# お金の倍率を取得
#--------------------------------------------------------------------------
alias gold_rate_enh_st gold_rate
def gold_rate
#本来の処理にパーティ能力詳細のデータを乗算する。
case DETAIL_PTA::TYPE
when 0;gold_rate_enh_st * $game_party.extra_pta(2)
when 1;gold_rate_enh_st + $game_party.extra_pta(2)
end
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ドロップアイテム取得率の倍率を取得
#--------------------------------------------------------------------------
alias drop_item_rate_enh_st drop_item_rate
def drop_item_rate
#本来の処理にパーティ能力詳細のデータを乗算する。
case DETAIL_PTA::TYPE
when 0;drop_item_rate_enh_st * $game_party.extra_pta(3)
when 1;drop_item_rate_enh_st + $game_party.extra_pta(3)
end
end
end
class RPG::BaseItem
#--------------------------------------------------------------------------
# パーティ能力詳細データ
#--------------------------------------------------------------------------
def extra_pta
#キャッシュが存在する場合はキャッシュを返す。
return @extra_pta if @extra_pta != nil
#0が4つ入った配列を作成。
@extra_pta = [0] * 4
#各行からデータを取得。
self.note.each_line {|l|
#データ別に判別ワードを取得。
4.times {|i|
case i
when 0;word = DETAIL_PTA::WORD1#エンカウント率増減
when 1;word = DETAIL_PTA::WORD2#先制攻撃率増減
when 2;word = DETAIL_PTA::WORD3#獲得金額率増減
when 3;word = DETAIL_PTA::WORD4#ドロップ率増減
end
#判別を用いてデータを取得。
memo = l.scan(/<#{word}[:](\S+)>/).flatten
#データを取得出来た場合、配列の然るべき箇所に、そのデータを加算。
@extra_pta[i] += memo[0].to_i if memo != nil && !memo.empty?}}
#データを返す。
@extra_pta
end
end