バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ のクラスは Game_Battler クラスのスーパークラスとして使用されます。
- A
- B
- C
- D
- E
- F
- G
- H
- I
- L
- M
- N
- O
- P
- R
- S
- T
- U
- X
FEATURE_ELEMENT_RATE | = | 11 |
定数(特徴) |
||
FEATURE_DEBUFF_RATE | = | 12 |
FEATURE_STATE_RATE | = | 13 |
FEATURE_STATE_RESIST | = | 14 |
FEATURE_PARAM | = | 21 |
FEATURE_XPARAM | = | 22 |
FEATURE_SPARAM | = | 23 |
FEATURE_ATK_ELEMENT | = | 31 |
FEATURE_ATK_STATE | = | 32 |
FEATURE_ATK_SPEED | = | 33 |
FEATURE_ATK_TIMES | = | 34 |
FEATURE_STYPE_ADD | = | 41 |
FEATURE_STYPE_SEAL | = | 42 |
FEATURE_SKILL_ADD | = | 43 |
FEATURE_SKILL_SEAL | = | 44 |
FEATURE_EQUIP_WTYPE | = | 51 |
FEATURE_EQUIP_ATYPE | = | 52 |
FEATURE_EQUIP_FIX | = | 53 |
FEATURE_EQUIP_SEAL | = | 54 |
FEATURE_SLOT_TYPE | = | 55 |
FEATURE_ACTION_PLUS | = | 61 |
FEATURE_SPECIAL_FLAG | = | 62 |
FEATURE_COLLAPSE_TYPE | = | 63 |
FEATURE_PARTY_ABILITY | = | 64 |
FLAG_ID_AUTO_BATTLE | = | 0 |
定数(特殊フラグ) |
||
FLAG_ID_GUARD | = | 1 |
FLAG_ID_SUBSTITUTE | = | 2 |
FLAG_ID_PRESERVE_TP | = | 3 |
ICON_BUFF_START | = | 64 |
定数(能力強化/弱体アイコンの開始番号) |
||
ICON_DEBUFF_START | = | 80 |
[R] | hp | 公開インスタンス変数 |
[R] | mp | |
[R] | tp |
オブジェクト初期化
Source: show
# File Game_BattlerBase.rb, line 92 def initialize @hp = @mp = @tp = 0 @hidden = false clear_param_plus clear_states clear_buffs end
行動回数追加確率の配列を取得
Source: show
# File Game_BattlerBase.rb, line 460 def action_plus_set features(FEATURE_ACTION_PLUS).collect {|ft| ft.value } end
アクターか否かの判定
Source: show
# File Game_BattlerBase.rb, line 684 def actor? return false end
能力値の加算
Source: show
# File Game_BattlerBase.rb, line 516 def add_param(param_id, value) @param_plus[param_id] += value refresh end
追加スキルタイプの取得
Source: show
# File Game_BattlerBase.rb, line 390 def added_skill_types features_set(FEATURE_STYPE_ADD) end
追加スキルの取得
Source: show
# File Game_BattlerBase.rb, line 404 def added_skills features_set(FEATURE_SKILL_ADD) end
生存判定
Source: show
# File Game_BattlerBase.rb, line 642 def alive? exist? && !death_state? end
全ての特徴オブジェクトの配列取得
Source: show
# File Game_BattlerBase.rb, line 203 def all_features feature_objects.inject([]) {|r, obj| r + obj.features } end
攻撃時属性の取得
Source: show
# File Game_BattlerBase.rb, line 355 def atk_elements features_set(FEATURE_ATK_ELEMENT) end
攻撃速度補正の取得
Source: show
# File Game_BattlerBase.rb, line 376 def atk_speed features_sum_all(FEATURE_ATK_SPEED) end
攻撃時ステートの取得
Source: show
# File Game_BattlerBase.rb, line 362 def atk_states features_set(FEATURE_ATK_STATE) end
攻撃時ステートの発動率取得
Source: show
# File Game_BattlerBase.rb, line 369 def atk_states_rate(state_id) features_sum(FEATURE_ATK_STATE, state_id) end
攻撃追加回数の取得
Source: show
# File Game_BattlerBase.rb, line 383 def atk_times_add [features_sum_all(FEATURE_ATK_TIMES), 0].max end
通常攻撃のスキル ID を取得
Source: show
# File Game_BattlerBase.rb, line 808 def attack_skill_id return 1 end
通常攻撃の使用可能判定
Source: show
# File Game_BattlerBase.rb, line 822 def attack_usable? usable?($data_skills[attack_skill_id]) end
自動戦闘の判定
Source: show
# File Game_BattlerBase.rb, line 488 def auto_battle? special_flag(FLAG_ID_AUTO_BATTLE) end
強化/弱体に対応するアイコン番号を取得
Source: show
# File Game_BattlerBase.rb, line 183 def buff_icon_index(buff_level, param_id) if buff_level > 0 return ICON_BUFF_START + (buff_level - 1) * 8 + param_id elsif buff_level < 0 return ICON_DEBUFF_START + (-buff_level - 1) * 8 + param_id else return 0 end end
現在の強化/弱体をアイコン番号の配列で取得
Source: show
# File Game_BattlerBase.rb, line 173 def buff_icons icons = [] @buffs.each_with_index {|lv, i| icons.push(buff_icon_index(lv, i)) } icons.delete(0) icons end
HP の増減(イベント用)
value : 増減値 enable_death : 戦闘不能を許可
Source: show
# File Game_BattlerBase.rb, line 542 def change_hp(value, enable_death) if !enable_death && @hp + value <= 0 self.hp = 1 else self.hp += value end end
能力強化情報をクリア
Source: show
# File Game_BattlerBase.rb, line 128 def clear_buffs @buffs = Array.new(8) { 0 } @buff_turns = {} end
能力値に加算する値をクリア
Source: show
# File Game_BattlerBase.rb, line 103 def clear_param_plus @param_plus = [0] * 8 end
ステート情報をクリア
Source: show
# File Game_BattlerBase.rb, line 110 def clear_states @states = [] @state_turns = {} @state_steps = {} end
消滅エフェクトの取得
Source: show
# File Game_BattlerBase.rb, line 474 def collapse_type features_set(FEATURE_COLLAPSE_TYPE).max || 0 end
混乱状態判定
Source: show
# File Game_BattlerBase.rb, line 670 def confusion? exist? && restriction >= 1 && restriction <= 3 end
混乱レベル取得
Source: show
# File Game_BattlerBase.rb, line 677 def confusion_level confusion? ? restriction : 0 end
戦闘不能判定
Source: show
# File Game_BattlerBase.rb, line 635 def dead? exist? && death_state? end
戦闘不能ステートの検査
Source: show
# File Game_BattlerBase.rb, line 143 def death_state? state?(death_state_id) end
戦闘不能のステート ID を取得
Source: show
# File Game_BattlerBase.rb, line 150 def death_state_id return 1 end
弱体有効度の取得
Source: show
# File Game_BattlerBase.rb, line 327 def debuff_rate(param_id) features_pi(FEATURE_DEBUFF_RATE, param_id) end
二刀流の判定
Source: show
# File Game_BattlerBase.rb, line 453 def dual_wield? slot_type == 1 end
属性有効度の取得
Source: show
# File Game_BattlerBase.rb, line 320 def element_rate(element_id) features_pi(FEATURE_ELEMENT_RATE, element_id) end
敵キャラか否かの判定
Source: show
# File Game_BattlerBase.rb, line 691 def enemy? return false end
防具装備可能の判定
Source: show
# File Game_BattlerBase.rb, line 425 def equip_atype_ok?(atype_id) features_set(FEATURE_EQUIP_ATYPE).include?(atype_id) end
装備固定の判定
Source: show
# File Game_BattlerBase.rb, line 432 def equip_type_fixed?(etype_id) features_set(FEATURE_EQUIP_FIX).include?(etype_id) end
装備封印の判定
Source: show
# File Game_BattlerBase.rb, line 439 def equip_type_sealed?(etype_id) features_set(FEATURE_EQUIP_SEAL).include?(etype_id) end
武器装備可能の判定
Source: show
# File Game_BattlerBase.rb, line 418 def equip_wtype_ok?(wtype_id) features_set(FEATURE_EQUIP_WTYPE).include?(wtype_id) end
装備可能判定
Source: show
# File Game_BattlerBase.rb, line 797 def equippable?(item) return false unless item.is_a?(RPG::EquipItem) return false if equip_type_sealed?(item.etype_id) return equip_wtype_ok?(item.wtype_id) if item.is_a?(RPG::Weapon) return equip_atype_ok?(item.atype_id) if item.is_a?(RPG::Armor) return false end
ステートの消去
Source: show
# File Game_BattlerBase.rb, line 119 def erase_state(state_id) @states.delete(state_id) @state_turns.delete(state_id) @state_steps.delete(state_id) end
特徴を保持する全オブジェクトの配列取得
Source: show
# File Game_BattlerBase.rb, line 196 def feature_objects states end
特徴オブジェクトの配列取得(特徴コードを限定)
Source: show
# File Game_BattlerBase.rb, line 210 def features(code) all_features.select {|ft| ft.code == code } end
特徴値の総乗計算
Source: show
# File Game_BattlerBase.rb, line 224 def features_pi(code, id) features_with_id(code, id).inject(1.0) {|r, ft| r *= ft.value } end
特徴の集合和計算
Source: show
# File Game_BattlerBase.rb, line 245 def features_set(code) features(code).inject([]) {|r, ft| r |= [ft.data_id] } end
特徴値の総和計算(データ ID を指定)
Source: show
# File Game_BattlerBase.rb, line 231 def features_sum(code, id) features_with_id(code, id).inject(0.0) {|r, ft| r += ft.value } end
特徴値の総和計算(データ ID は非指定)
Source: show
# File Game_BattlerBase.rb, line 238 def features_sum_all(code) features(code).inject(0.0) {|r, ft| r += ft.value } end
特徴オブジェクトの配列取得(特徴コードとデータ ID を限定)
Source: show
# File Game_BattlerBase.rb, line 217 def features_with_id(code, id) all_features.select {|ft| ft.code == code && ft.data_id == id } end
防御の判定
Source: show
# File Game_BattlerBase.rb, line 495 def guard? special_flag(FLAG_ID_GUARD) && movable? end
防御のスキル ID を取得
Source: show
# File Game_BattlerBase.rb, line 815 def guard_skill_id return 2 end
防御の使用可能判定
Source: show
# File Game_BattlerBase.rb, line 829 def guard_usable? usable?($data_skills[guard_skill_id]) end
隠れ状態取得
Source:
HP の変更
Source: show
# File Game_BattlerBase.rb, line 524 def hp=(hp) @hp = hp refresh end
HP の割合を取得
Source: show
# File Game_BattlerBase.rb, line 586 def hp_rate @hp.to_f / mhp end
コマンド入力可能判定
Source: show
# File Game_BattlerBase.rb, line 656 def inputable? normal? && !auto_battle? end
アイテムの使用可能条件チェック
Source: show
# File Game_BattlerBase.rb, line 781 def item_conditions_met?(item) usable_item_conditions_met?(item) && $game_party.has_item?(item) end
TP の最大値を取得
Source: show
# File Game_BattlerBase.rb, line 560 def max_tp return 100 end
各種能力値の略称によるアクセスメソッド
Source: show
# File Game_BattlerBase.rb, line 60 def mhp; param(0); end
最重要のステート継続メッセージを取得
Source: show
# File Game_BattlerBase.rb, line 714 def most_important_state_text states.each {|state| return state.message3 unless state.message3.empty? } return "" end
行動可能判定
Source: show
# File Game_BattlerBase.rb, line 663 def movable? exist? && restriction < 4 end
MP の変更
Source: show
# File Game_BattlerBase.rb, line 532 def mp=(mp) @mp = mp refresh end
MP の割合を取得
Source: show
# File Game_BattlerBase.rb, line 593 def mp_rate mmp > 0 ? @mp.to_f / mmp : 0 end
正常判定
Source: show
# File Game_BattlerBase.rb, line 649 def normal? exist? && restriction == 0 end
スキル/アイテムの使用可能時チェック
Source: show
# File Game_BattlerBase.rb, line 758 def occasion_ok?(item) $game_party.in_battle ? item.battle_ok? : item.menu_ok? end
通常能力値の取得
Source: show
# File Game_BattlerBase.rb, line 297 def param(param_id) value = param_base(param_id) + param_plus(param_id) value *= param_rate(param_id) * param_buff_rate(param_id) [[value, param_max(param_id)].min, param_min(param_id)].max.to_i end
通常能力値の基本値取得
Source: show
# File Game_BattlerBase.rb, line 252 def param_base(param_id) return 0 end
通常能力値の強化/弱体による変化率取得
Source: show
# File Game_BattlerBase.rb, line 290 def param_buff_rate(param_id) @buffs[param_id] * 0.25 + 1.0 end
通常能力値の最大値取得
Source: show
# File Game_BattlerBase.rb, line 274 def param_max(param_id) return 999999 if param_id == 0 # MHP return 9999 if param_id == 1 # MMP return 999 end
通常能力値の最小値取得
Source: show
# File Game_BattlerBase.rb, line 266 def param_min(param_id) return 0 if param_id == 1 # MMP return 1 end
通常能力値の加算値取得
Source: show
# File Game_BattlerBase.rb, line 259 def param_plus(param_id) @param_plus[param_id] end
通常能力値の変化率取得
Source: show
# File Game_BattlerBase.rb, line 283 def param_rate(param_id) features_pi(FEATURE_PARAM, param_id) end
パーティ能力判定
Source: show
# File Game_BattlerBase.rb, line 481 def party_ability(ability_id) features(FEATURE_PARTY_ABILITY).any? {|ft| ft.data_id == ability_id } end
スキル使用コストの支払い
Source: show
# File Game_BattlerBase.rb, line 750 def pay_skill_cost(skill) self.mp -= skill_mp_cost(skill) self.tp -= skill_tp_cost(skill) end
TP持ち越しの判定
Source: show
# File Game_BattlerBase.rb, line 509 def preserve_tp? special_flag(FLAG_ID_PRESERVE_TP) end
全回復
Source: show
# File Game_BattlerBase.rb, line 577 def recover_all clear_states @hp = mhp @mp = mmp end
リフレッシュ
Source: show
# File Game_BattlerBase.rb, line 567 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) end
制約の取得
現在付加されているステートから最大の restriction を取得する。
Source: show
# File Game_BattlerBase.rb, line 707 def restriction states.collect {|state| state.restriction }.push(0).max end
スキルの使用可能条件チェック
Source: show
# File Game_BattlerBase.rb, line 772 def skill_conditions_met?(skill) usable_item_conditions_met?(skill) && skill_wtype_ok?(skill) && skill_cost_payable?(skill) && !skill_sealed?(skill.id) && !skill_type_sealed?(skill.stype_id) end
スキル使用コストの支払い可能判定
Source: show
# File Game_BattlerBase.rb, line 743 def skill_cost_payable?(skill) tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill) end
スキルの消費 MP 計算
Source: show
# File Game_BattlerBase.rb, line 729 def skill_mp_cost(skill) (skill.mp_cost * mcr).to_i end
スキル封印の判定
Source: show
# File Game_BattlerBase.rb, line 411 def skill_sealed?(skill_id) features_set(FEATURE_SKILL_SEAL).include?(skill_id) end
スキルの消費 TP 計算
Source: show
# File Game_BattlerBase.rb, line 736 def skill_tp_cost(skill) skill.tp_cost end
スキルタイプ封印の判定
Source: show
# File Game_BattlerBase.rb, line 397 def skill_type_sealed?(stype_id) features_set(FEATURE_STYPE_SEAL).include?(stype_id) end
スキルの必要武器を装備しているか
Source: show
# File Game_BattlerBase.rb, line 722 def skill_wtype_ok?(skill) return true end
スロットタイプの取得
Source: show
# File Game_BattlerBase.rb, line 446 def slot_type features_set(FEATURE_SLOT_TYPE).max || 0 end
ステートの並び替え
配列 `@states` の内容を表示優先度の大きい順に並び替える。
Source: show
# File Game_BattlerBase.rb, line 699 def sort_states @states = @states.sort_by {|id| [-$data_states[id].priority, id] } end
特殊能力値の取得
Source: show
# File Game_BattlerBase.rb, line 313 def sparam(sparam_id) features_pi(FEATURE_SPARAM, sparam_id) end
特殊フラグ判定
Source: show
# File Game_BattlerBase.rb, line 467 def special_flag(flag_id) features(FEATURE_SPECIAL_FLAG).any? {|ft| ft.data_id == flag_id } end
ステートの検査
Source: show
# File Game_BattlerBase.rb, line 136 def state?(state_id) @states.include?(state_id) end
現在のステートをアイコン番号の配列で取得
Source: show
# File Game_BattlerBase.rb, line 164 def state_icons icons = states.collect {|state| state.icon_index } icons.delete(0) icons end
ステート有効度の取得
Source: show
# File Game_BattlerBase.rb, line 334 def state_rate(state_id) features_pi(FEATURE_STATE_RATE, state_id) end
無効化されているステートの判定
Source: show
# File Game_BattlerBase.rb, line 348 def state_resist?(state_id) state_resist_set.include?(state_id) end
無効化するステートの配列を取得
Source: show
# File Game_BattlerBase.rb, line 341 def state_resist_set features_set(FEATURE_STATE_RESIST) end
現在のステートをオブジェクトの配列で取得
Source: show
# File Game_BattlerBase.rb, line 157 def states @states.collect {|id| $data_states[id] } end
身代わりの判定
Source: show
# File Game_BattlerBase.rb, line 502 def substitute? special_flag(FLAG_ID_SUBSTITUTE) && movable? end
TP の変更
Source: show
# File Game_BattlerBase.rb, line 553 def tp=(tp) @tp = [[tp, max_tp].min, 0].max end
TP の割合を取得
Source: show
# File Game_BattlerBase.rb, line 600 def tp_rate @tp.to_f / 100 end
スキル/アイテムの使用可能判定
Source: show
# File Game_BattlerBase.rb, line 788 def usable?(item) return skill_conditions_met?(item) if item.is_a?(RPG::Skill) return item_conditions_met?(item) if item.is_a?(RPG::Item) return false end