バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ のクラスは Game_Battler クラスのスーパークラスとして使用されます。

Methods
A
B
C
D
E
F
G
H
I
L
M
N
O
P
R
S
T
U
X
Constants
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
 
Attributes
[R] hp

公開インスタンス変数

[R] mp
[R] tp
Class Public methods
new()

オブジェクト初期化

# File Game_BattlerBase.rb, line 92
def initialize
  @hp = @mp = @tp = 0
  @hidden = false
  clear_param_plus
  clear_states
  clear_buffs
end
Instance Public methods
action_plus_set()

行動回数追加確率の配列を取得

# File Game_BattlerBase.rb, line 460
def action_plus_set
  features(FEATURE_ACTION_PLUS).collect {|ft| ft.value }
end
actor?()

アクターか否かの判定

# File Game_BattlerBase.rb, line 684
def actor?
  return false
end
add_param(param_id, value)

能力値の加算

# File Game_BattlerBase.rb, line 516
def add_param(param_id, value)
  @param_plus[param_id] += value
  refresh
end
added_skill_types()

追加スキルタイプの取得

# File Game_BattlerBase.rb, line 390
def added_skill_types
  features_set(FEATURE_STYPE_ADD)
end
added_skills()

追加スキルの取得

# File Game_BattlerBase.rb, line 404
def added_skills
  features_set(FEATURE_SKILL_ADD)
end
agi()
# File Game_BattlerBase.rb, line 66
def agi;  param(6);   end
alive?()

生存判定

# File Game_BattlerBase.rb, line 642
def alive?
  exist? && !death_state?
end
all_features()

全ての特徴オブジェクトの配列取得

# File Game_BattlerBase.rb, line 203
def all_features
  feature_objects.inject([]) {|r, obj| r + obj.features }
end
appear()

現れる

# File Game_BattlerBase.rb, line 614
def appear
  @hidden = false
end
atk()
# File Game_BattlerBase.rb, line 62
def atk;  param(2);   end
atk_elements()

攻撃時属性の取得

# File Game_BattlerBase.rb, line 355
def atk_elements
  features_set(FEATURE_ATK_ELEMENT)
end
atk_speed()

攻撃速度補正の取得

# File Game_BattlerBase.rb, line 376
def atk_speed
  features_sum_all(FEATURE_ATK_SPEED)
end
atk_states()

攻撃時ステートの取得

# File Game_BattlerBase.rb, line 362
def atk_states
  features_set(FEATURE_ATK_STATE)
end
atk_states_rate(state_id)

攻撃時ステートの発動率取得

# File Game_BattlerBase.rb, line 369
def atk_states_rate(state_id)
  features_sum(FEATURE_ATK_STATE, state_id)
end
atk_times_add()

攻撃追加回数の取得

# File Game_BattlerBase.rb, line 383
def atk_times_add
  [features_sum_all(FEATURE_ATK_TIMES), 0].max
end
attack_skill_id()

通常攻撃のスキル ID を取得

# File Game_BattlerBase.rb, line 808
def attack_skill_id
  return 1
end
attack_usable?()

通常攻撃の使用可能判定

# File Game_BattlerBase.rb, line 822
def attack_usable?
  usable?($data_skills[attack_skill_id])
end
auto_battle?()

自動戦闘の判定

# File Game_BattlerBase.rb, line 488
def auto_battle?
  special_flag(FLAG_ID_AUTO_BATTLE)
end
buff_icon_index(buff_level, param_id)

強化/弱体に対応するアイコン番号を取得

# 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
buff_icons()

現在の強化/弱体をアイコン番号の配列で取得

# 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
cev()
# File Game_BattlerBase.rb, line 71
def cev;  xparam(3);  end
change_hp(value, enable_death)

HP の増減(イベント用)

value : 増減値 enable_death : 戦闘不能を許可

# 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
clear_buffs()

能力強化情報をクリア

# File Game_BattlerBase.rb, line 128
def clear_buffs
  @buffs = Array.new(8) { 0 }
  @buff_turns = {}
end
clear_param_plus()

能力値に加算する値をクリア

# File Game_BattlerBase.rb, line 103
def clear_param_plus
  @param_plus = [0] * 8
end
clear_states()

ステート情報をクリア

# File Game_BattlerBase.rb, line 110
def clear_states
  @states = []
  @state_turns = {}
  @state_steps = {}
end
cnt()
# File Game_BattlerBase.rb, line 74
def cnt;  xparam(6);  end
collapse_type()

消滅エフェクトの取得

# File Game_BattlerBase.rb, line 474
def collapse_type
  features_set(FEATURE_COLLAPSE_TYPE).max || 0
end
confusion?()

混乱状態判定

# File Game_BattlerBase.rb, line 670
def confusion?
  exist? && restriction >= 1 && restriction <= 3
end
confusion_level()

混乱レベル取得

# File Game_BattlerBase.rb, line 677
def confusion_level
  confusion? ? restriction : 0
end
cri()
# File Game_BattlerBase.rb, line 70
def cri;  xparam(2);  end
dead?()

戦闘不能判定

# File Game_BattlerBase.rb, line 635
def dead?
  exist? && death_state?
end
death_state?()

戦闘不能ステートの検査

# File Game_BattlerBase.rb, line 143
def death_state?
  state?(death_state_id)
end
death_state_id()

戦闘不能のステート ID を取得

# File Game_BattlerBase.rb, line 150
def death_state_id
  return 1
end
debuff_rate(param_id)

弱体有効度の取得

# File Game_BattlerBase.rb, line 327
def debuff_rate(param_id)
  features_pi(FEATURE_DEBUFF_RATE, param_id)
end
def()
# File Game_BattlerBase.rb, line 63
def def;  param(3);   end
dual_wield?()

二刀流の判定

# File Game_BattlerBase.rb, line 453
def dual_wield?
  slot_type == 1
end
element_rate(element_id)

属性有効度の取得

# File Game_BattlerBase.rb, line 320
def element_rate(element_id)
  features_pi(FEATURE_ELEMENT_RATE, element_id)
end
enemy?()

敵キャラか否かの判定

# File Game_BattlerBase.rb, line 691
def enemy?
  return false
end
equip_atype_ok?(atype_id)

防具装備可能の判定

# File Game_BattlerBase.rb, line 425
def equip_atype_ok?(atype_id)
  features_set(FEATURE_EQUIP_ATYPE).include?(atype_id)
end
equip_type_fixed?(etype_id)

装備固定の判定

# File Game_BattlerBase.rb, line 432
def equip_type_fixed?(etype_id)
  features_set(FEATURE_EQUIP_FIX).include?(etype_id)
end
equip_type_sealed?(etype_id)

装備封印の判定

# File Game_BattlerBase.rb, line 439
def equip_type_sealed?(etype_id)
  features_set(FEATURE_EQUIP_SEAL).include?(etype_id)
end
equip_wtype_ok?(wtype_id)

武器装備可能の判定

# File Game_BattlerBase.rb, line 418
def equip_wtype_ok?(wtype_id)
  features_set(FEATURE_EQUIP_WTYPE).include?(wtype_id)
end
equippable?(item)

装備可能判定

# 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
erase_state(state_id)

ステートの消去

# 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
eva()
# File Game_BattlerBase.rb, line 69
def eva;  xparam(1);  end
exist?()

存在判定

# File Game_BattlerBase.rb, line 628
def exist?
  !hidden?
end
exr()
# File Game_BattlerBase.rb, line 87
def exr;  sparam(9);  end
fdr()
# File Game_BattlerBase.rb, line 86
def fdr;  sparam(8);  end
feature_objects()

特徴を保持する全オブジェクトの配列取得

# File Game_BattlerBase.rb, line 196
def feature_objects
  states
end
features(code)

特徴オブジェクトの配列取得(特徴コードを限定)

# File Game_BattlerBase.rb, line 210
def features(code)
  all_features.select {|ft| ft.code == code }
end
features_pi(code, id)

特徴値の総乗計算

# 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
features_set(code)

特徴の集合和計算

# File Game_BattlerBase.rb, line 245
def features_set(code)
  features(code).inject([]) {|r, ft| r |= [ft.data_id] }
end
features_sum(code, id)

特徴値の総和計算(データ ID を指定)

# 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
features_sum_all(code)

特徴値の総和計算(データ ID は非指定)

# File Game_BattlerBase.rb, line 238
def features_sum_all(code)
  features(code).inject(0.0) {|r, ft| r += ft.value }
end
features_with_id(code, id)

特徴オブジェクトの配列取得(特徴コードとデータ ID を限定)

# File Game_BattlerBase.rb, line 217
def features_with_id(code, id)
  all_features.select {|ft| ft.code == code && ft.data_id == id }
end
grd()
# File Game_BattlerBase.rb, line 79
def grd;  sparam(1);  end
guard?()

防御の判定

# File Game_BattlerBase.rb, line 495
def guard?
  special_flag(FLAG_ID_GUARD) && movable?
end
guard_skill_id()

防御のスキル ID を取得

# File Game_BattlerBase.rb, line 815
def guard_skill_id
  return 2
end
guard_usable?()

防御の使用可能判定

# File Game_BattlerBase.rb, line 829
def guard_usable?
  usable?($data_skills[guard_skill_id])
end
hidden?()

隠れ状態取得

# File Game_BattlerBase.rb, line 621
def hidden?
  @hidden
end
hide()

隠れる

# File Game_BattlerBase.rb, line 607
def hide
  @hidden = true
end
hit()
# File Game_BattlerBase.rb, line 68
def hit;  xparam(0);  end
hp=(hp)

HP の変更

# File Game_BattlerBase.rb, line 524
def hp=(hp)
  @hp = hp
  refresh
end
hp_rate()

HP の割合を取得

# File Game_BattlerBase.rb, line 586
def hp_rate
  @hp.to_f / mhp
end
hrg()
# File Game_BattlerBase.rb, line 75
def hrg;  xparam(7);  end
inputable?()

コマンド入力可能判定

# File Game_BattlerBase.rb, line 656
def inputable?
  normal? && !auto_battle?
end
item_conditions_met?(item)

アイテムの使用可能条件チェック

# File Game_BattlerBase.rb, line 781
def item_conditions_met?(item)
  usable_item_conditions_met?(item) && $game_party.has_item?(item)
end
luk()
# File Game_BattlerBase.rb, line 67
def luk;  param(7);   end
mat()
# File Game_BattlerBase.rb, line 64
def mat;  param(4);   end
max_tp()

TP の最大値を取得

# File Game_BattlerBase.rb, line 560
def max_tp
  return 100
end
mcr()
# File Game_BattlerBase.rb, line 82
def mcr;  sparam(4);  end
mdf()
# File Game_BattlerBase.rb, line 65
def mdf;  param(5);   end
mdr()
# File Game_BattlerBase.rb, line 85
def mdr;  sparam(7);  end
mev()
# File Game_BattlerBase.rb, line 72
def mev;  xparam(4);  end
mhp()

各種能力値の略称によるアクセスメソッド

# File Game_BattlerBase.rb, line 60
def mhp;  param(0);   end
mmp()
# File Game_BattlerBase.rb, line 61
def mmp;  param(1);   end
most_important_state_text()

最重要のステート継続メッセージを取得

# File Game_BattlerBase.rb, line 714
def most_important_state_text
  states.each {|state| return state.message3 unless state.message3.empty? }
  return ""
end
movable?()

行動可能判定

# File Game_BattlerBase.rb, line 663
def movable?
  exist? && restriction < 4
end
mp=(mp)

MP の変更

# File Game_BattlerBase.rb, line 532
def mp=(mp)
  @mp = mp
  refresh
end
mp_rate()

MP の割合を取得

# File Game_BattlerBase.rb, line 593
def mp_rate
  mmp > 0 ? @mp.to_f / mmp : 0
end
mrf()
# File Game_BattlerBase.rb, line 73
def mrf;  xparam(5);  end
mrg()
# File Game_BattlerBase.rb, line 76
def mrg;  xparam(8);  end
normal?()

正常判定

# File Game_BattlerBase.rb, line 649
def normal?
  exist? && restriction == 0
end
occasion_ok?(item)

スキル/アイテムの使用可能時チェック

# File Game_BattlerBase.rb, line 758
def occasion_ok?(item)
  $game_party.in_battle ? item.battle_ok? : item.menu_ok?
end
param(param_id)

通常能力値の取得

# 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
param_base(param_id)

通常能力値の基本値取得

# File Game_BattlerBase.rb, line 252
def param_base(param_id)
  return 0
end
param_buff_rate(param_id)

通常能力値の強化/弱体による変化率取得

# File Game_BattlerBase.rb, line 290
def param_buff_rate(param_id)
  @buffs[param_id] * 0.25 + 1.0
end
param_max(param_id)

通常能力値の最大値取得

# 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
param_min(param_id)

通常能力値の最小値取得

# File Game_BattlerBase.rb, line 266
def param_min(param_id)
  return 0 if param_id == 1  # MMP
  return 1
end
param_plus(param_id)

通常能力値の加算値取得

# File Game_BattlerBase.rb, line 259
def param_plus(param_id)
  @param_plus[param_id]
end
param_rate(param_id)

通常能力値の変化率取得

# File Game_BattlerBase.rb, line 283
def param_rate(param_id)
  features_pi(FEATURE_PARAM, param_id)
end
party_ability(ability_id)

パーティ能力判定

# File Game_BattlerBase.rb, line 481
def party_ability(ability_id)
  features(FEATURE_PARTY_ABILITY).any? {|ft| ft.data_id == ability_id }
end
pay_skill_cost(skill)

スキル使用コストの支払い

# File Game_BattlerBase.rb, line 750
def pay_skill_cost(skill)
  self.mp -= skill_mp_cost(skill)
  self.tp -= skill_tp_cost(skill)
end
pdr()
# File Game_BattlerBase.rb, line 84
def pdr;  sparam(6);  end
pha()
# File Game_BattlerBase.rb, line 81
def pha;  sparam(3);  end
preserve_tp?()

TP持ち越しの判定

# File Game_BattlerBase.rb, line 509
def preserve_tp?
  special_flag(FLAG_ID_PRESERVE_TP)
end
rec()
# File Game_BattlerBase.rb, line 80
def rec;  sparam(2);  end
recover_all()

全回復

# File Game_BattlerBase.rb, line 577
def recover_all
  clear_states
  @hp = mhp
  @mp = mmp
end
refresh()

リフレッシュ

# 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()

制約の取得

現在付加されているステートから最大の restriction を取得する。

# File Game_BattlerBase.rb, line 707
def restriction
  states.collect {|state| state.restriction }.push(0).max
end
skill_conditions_met?(skill)

スキルの使用可能条件チェック

# 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
skill_cost_payable?(skill)

スキル使用コストの支払い可能判定

# File Game_BattlerBase.rb, line 743
def skill_cost_payable?(skill)
  tp >= skill_tp_cost(skill) && mp >= skill_mp_cost(skill)
end
skill_mp_cost(skill)

スキルの消費 MP 計算

# File Game_BattlerBase.rb, line 729
def skill_mp_cost(skill)
  (skill.mp_cost * mcr).to_i
end
skill_sealed?(skill_id)

スキル封印の判定

# File Game_BattlerBase.rb, line 411
def skill_sealed?(skill_id)
  features_set(FEATURE_SKILL_SEAL).include?(skill_id)
end
skill_tp_cost(skill)

スキルの消費 TP 計算

# File Game_BattlerBase.rb, line 736
def skill_tp_cost(skill)
  skill.tp_cost
end
skill_type_sealed?(stype_id)

スキルタイプ封印の判定

# File Game_BattlerBase.rb, line 397
def skill_type_sealed?(stype_id)
  features_set(FEATURE_STYPE_SEAL).include?(stype_id)
end
skill_wtype_ok?(skill)

スキルの必要武器を装備しているか

# File Game_BattlerBase.rb, line 722
def skill_wtype_ok?(skill)
  return true
end
slot_type()

スロットタイプの取得

# File Game_BattlerBase.rb, line 446
def slot_type
  features_set(FEATURE_SLOT_TYPE).max || 0
end
sort_states()

ステートの並び替え

配列 `@states` の内容を表示優先度の大きい順に並び替える。

# File Game_BattlerBase.rb, line 699
def sort_states
  @states = @states.sort_by {|id| [-$data_states[id].priority, id] }
end
sparam(sparam_id)

特殊能力値の取得

# File Game_BattlerBase.rb, line 313
def sparam(sparam_id)
  features_pi(FEATURE_SPARAM, sparam_id)
end
special_flag(flag_id)

特殊フラグ判定

# File Game_BattlerBase.rb, line 467
def special_flag(flag_id)
  features(FEATURE_SPECIAL_FLAG).any? {|ft| ft.data_id == flag_id }
end
state?(state_id)

ステートの検査

# File Game_BattlerBase.rb, line 136
def state?(state_id)
  @states.include?(state_id)
end
state_icons()

現在のステートをアイコン番号の配列で取得

# File Game_BattlerBase.rb, line 164
def state_icons
  icons = states.collect {|state| state.icon_index }
  icons.delete(0)
  icons
end
state_rate(state_id)

ステート有効度の取得

# File Game_BattlerBase.rb, line 334
def state_rate(state_id)
  features_pi(FEATURE_STATE_RATE, state_id)
end
state_resist?(state_id)

無効化されているステートの判定

# File Game_BattlerBase.rb, line 348
def state_resist?(state_id)
  state_resist_set.include?(state_id)
end
state_resist_set()

無効化するステートの配列を取得

# File Game_BattlerBase.rb, line 341
def state_resist_set
  features_set(FEATURE_STATE_RESIST)
end
states()

現在のステートをオブジェクトの配列で取得

# File Game_BattlerBase.rb, line 157
def states
  @states.collect {|id| $data_states[id] }
end
substitute?()

身代わりの判定

# File Game_BattlerBase.rb, line 502
def substitute?
  special_flag(FLAG_ID_SUBSTITUTE) && movable?
end
tcr()
# File Game_BattlerBase.rb, line 83
def tcr;  sparam(5);  end
tgr()
# File Game_BattlerBase.rb, line 78
def tgr;  sparam(0);  end
tp=(tp)

TP の変更

# File Game_BattlerBase.rb, line 553
def tp=(tp)
  @tp = [[tp, max_tp].min, 0].max
end
tp_rate()

TP の割合を取得

# File Game_BattlerBase.rb, line 600
def tp_rate
  @tp.to_f / 100
end
trg()
# File Game_BattlerBase.rb, line 77
def trg;  xparam(9);  end
usable?(item)

スキル/アイテムの使用可能判定

# 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
usable_item_conditions_met?(item)

スキル/アイテムの共通使用可能条件チェック

# File Game_BattlerBase.rb, line 765
def usable_item_conditions_met?(item)
  movable? && occasion_ok?(item)
end
xparam(xparam_id)

追加能力値の取得

# File Game_BattlerBase.rb, line 306
def xparam(xparam_id)
  features_sum(FEATURE_XPARAM, xparam_id)
end