アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors) の内部で使用され、Game_Party クラス($game_party)からも参照されます。

Methods
A
B
C
D
E
F
G
I
L
M
N
O
P
R
S
T
U
W
Attributes
[R] action_input_index
[R] character_index
[R] character_name
[R] class_id
[R] face_index
[R] face_name
[R] last_skill
[R] level
[RW] name

公開インスタンス変数

[RW] nickname
Class Public methods
new(actor_id)

オブジェクト初期化

# File Game_Actor.rb, line 25
def initialize(actor_id)
  super()
  setup(actor_id)
  @last_skill = Game_BaseItem.new
end
Instance Public methods
actor()

アクターオブジェクト取得

# File Game_Actor.rb, line 53
def actor
  $data_actors[@actor_id]
end
actor?()

アクターか否かの判定

# File Game_Actor.rb, line 327
def actor?
  return true
end
armors()

防具オブジェクトの配列取得

# File Game_Actor.rb, line 182
def armors
  @equips.select {|item| item.is_armor? }.collect {|item| item.object }
end
atk_animation_id1()

通常攻撃 アニメーション ID の取得

# File Game_Actor.rb, line 428
def atk_animation_id1
  if dual_wield?
    return weapons[0].animation_id if weapons[0]
    return weapons[1] ? 0 : 1
  else
    return weapons[0] ? weapons[0].animation_id : 1
  end
end
atk_animation_id2()

通常攻撃 アニメーション ID の取得(二刀流:武器2)

# File Game_Actor.rb, line 440
def atk_animation_id2
  if dual_wield?
    return weapons[1] ? weapons[1].animation_id : 0
  else
    return 0
  end
end
atk_elements()

攻撃時属性の取得

# File Game_Actor.rb, line 397
def atk_elements
  set = super
  set |= [1] if weapons.compact.empty?  # 素手:物理属性
  return set
end
basic_floor_damage()

床ダメージの基本値を取得

# File Game_Actor.rb, line 726
def basic_floor_damage
  return 10
end
battle_member?()

バトルメンバー判定

# File Game_Actor.rb, line 362
def battle_member?
  $game_party.battle_members.include?(self)
end
change_class(class_id, keep_exp = false)

職業の変更

keep_exp : 経験値を引き継ぐ

# File Game_Actor.rb, line 563
def change_class(class_id, keep_exp = false)
  @exp[class_id] = exp if keep_exp
  @class_id = class_id
  change_exp(@exp[@class_id] || 0, false)
  refresh
end
change_equip(slot_id, item)

装備の変更

slot_id : 装備スロット ID item : 武器/防具(nil なら装備解除)

# File Game_Actor.rb, line 208
def change_equip(slot_id, item)
  return unless trade_item_with_party(item, equips[slot_id])
  return if item && equip_slots[slot_id] != item.etype_id
  @equips[slot_id].object = item
  refresh
end
change_equip_by_id(slot_id, item_id)

装備の変更(ID で指定)

slot_id : 装備スロット ID item_id : 武器/防具 ID

# File Game_Actor.rb, line 243
def change_equip_by_id(slot_id, item_id)
  if equip_slots[slot_id] == 0
    change_equip(slot_id, $data_weapons[item_id])
  else
    change_equip(slot_id, $data_armors[item_id])
  end
end
change_exp(exp, show)

経験値の変更

show : レベルアップ表示フラグ

# File Game_Actor.rb, line 452
def change_exp(exp, show)
  @exp[@class_id] = [exp, 0].max
  last_level = @level
  last_skills = skills
  level_up while !max_level? && self.exp >= next_level_exp
  level_down while self.exp < current_level_exp
  display_level_up(skills - last_skills) if show && @level > last_level
  refresh
end
change_level(level, show)

レベルの変更

show : レベルアップ表示フラグ

# File Game_Actor.rb, line 523
def change_level(level, show)
  level = [[level, max_level].min, 1].max
  change_exp(exp_for_level(level), show)
end
check_floor_effect()

床効果判定

# File Game_Actor.rb, line 710
def check_floor_effect
  execute_floor_damage if $game_player.on_damage_floor?
end
class()

職業オブジェクト取得

# File Game_Actor.rb, line 369
def class
  $data_classes[@class_id]
end
clear_actions()

戦闘行動のクリア

# File Game_Actor.rb, line 747
def clear_actions
  super
  @action_input_index = 0
end
clear_equipments()

装備を全て外す

# File Game_Actor.rb, line 276
def clear_equipments
  equip_slots.size.times do |i|
    change_equip(i, nil) if equip_change_ok?(i)
  end
end
current_level_exp()

現在のレベルの最低経験値を取得

# File Game_Actor.rb, line 91
def current_level_exp
  exp_for_level(@level)
end
description()

説明の取得

# File Game_Actor.rb, line 555
def description
  actor.description
end
discard_equip(item)

装備の破棄

item : 破棄する武器/防具

# File Game_Actor.rb, line 255
def discard_equip(item)
  slot_id = equips.index(item)
  @equips[slot_id].object = nil if slot_id
end
display_level_up(new_skills)

レベルアップメッセージの表示

new_skills : 新しく習得したスキルの配列

# File Game_Actor.rb, line 490
def display_level_up(new_skills)
  $game_message.new_page
  $game_message.add(sprintf(Vocab::LevelUp, @name, Vocab::level, @level))
  new_skills.each do |skill|
    $game_message.add(sprintf(Vocab::ObtainSkill, skill.name))
  end
end
empty_slot(etype_id)

装備タイプからスロット ID に変換(空きを優先)

# File Game_Actor.rb, line 159
def empty_slot(etype_id)
  list = slot_list(etype_id)
  list.find {|i| @equips[i].is_nil? } || list[0]
end
equip_change_ok?(slot_id)

装備変更の可能判定

slot_id : 装備スロット ID

# File Game_Actor.rb, line 197
def equip_change_ok?(slot_id)
  return false if equip_type_fixed?(equip_slots[slot_id])
  return false if equip_type_sealed?(equip_slots[slot_id])
  return true
end
equip_slots()

装備スロットの配列を取得

# File Game_Actor.rb, line 167
def equip_slots
  return [0,0,2,3,4] if dual_wield?       # 二刀流
  return [0,1,2,3,4]                      # 通常
end
equips()

装備品オブジェクトの配列取得

# File Game_Actor.rb, line 189
def equips
  @equips.collect {|item| item.object }
end
execute_floor_damage()

床ダメージの処理

# File Game_Actor.rb, line 717
def execute_floor_damage
  damage = (basic_floor_damage * fdr).to_i
  self.hp -= [damage, max_floor_damage].min
  perform_map_damage_effect if damage > 0
end
exp()

経験値の取得

# File Game_Actor.rb, line 84
def exp
  @exp[@class_id]
end
exp_for_level(level)

指定レベルに上がるのに必要な累計経験値の取得

# File Game_Actor.rb, line 70
def exp_for_level(level)
  self.class.exp_for_level(level)
end
feature_objects()

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

# File Game_Actor.rb, line 390
def feature_objects
  super + [actor] + [self.class] + equips.compact
end
final_exp_rate()

最終的な経験獲得率の計算

# File Game_Actor.rb, line 508
def final_exp_rate
  exr * (battle_member? ? 1 : reserve_members_exp_rate)
end
force_change_equip(slot_id, item)

装備の強制変更

slot_id : 装備スロット ID item : 武器/防具(nil なら装備解除)

# File Game_Actor.rb, line 220
def force_change_equip(slot_id, item)
  @equips[slot_id].object = item
  release_unequippable_items(false)
  refresh
end
forget_skill(skill_id)

スキルを忘れる

# File Game_Actor.rb, line 541
def forget_skill(skill_id)
  @skills.delete(skill_id)
end
friends_unit()

味方ユニットを取得

# File Game_Actor.rb, line 334
def friends_unit
  $game_party
end
gain_exp(exp)

経験値の獲得(経験獲得率を考慮)

# File Game_Actor.rb, line 501
def gain_exp(exp)
  change_exp(self.exp + (exp * final_exp_rate).to_i, true)
end
id()

アクター ID 取得

# File Game_Actor.rb, line 348
def id
  @actor_id
end
index()

インデックス取得

# File Game_Actor.rb, line 355
def index
  $game_party.members.index(self)
end
index_to_etype_id(index)

エディタで設定されたインデックスを装備タイプ ID に変換

# File Game_Actor.rb, line 143
def index_to_etype_id(index)
  index == 1 && dual_wield? ? 0 : index
end
init_equips(equips)

装備品の初期化

equips : 初期装備の配列

# File Game_Actor.rb, line 130
def init_equips(equips)
  @equips = Array.new(equip_slots.size) { Game_BaseItem.new }
  equips.each_with_index do |item_id, i|
    etype_id = index_to_etype_id(i)
    slot_id = empty_slot(etype_id)
    @equips[slot_id].set_equip(etype_id == 0, item_id) if slot_id
  end
  refresh
end
init_exp()

経験値の初期化

# File Game_Actor.rb, line 77
def init_exp
  @exp[@class_id] = current_level_exp
end
init_graphics()

グラフィックの初期化

# File Game_Actor.rb, line 60
def init_graphics
  @character_name = actor.character_name
  @character_index = actor.character_index
  @face_name = actor.face_name
  @face_index = actor.face_index
end
init_skills()

スキルの初期化

# File Game_Actor.rb, line 119
def init_skills
  @skills = []
  self.class.learnings.each do |learning|
    learn_skill(learning.skill_id) if learning.level <= @level
  end
end
input()

入力中の戦闘行動を取得

# File Game_Actor.rb, line 755
def input
  @actions[@action_input_index]
end
learn_skill(skill_id)

スキルを覚える

# File Game_Actor.rb, line 531
def learn_skill(skill_id)
  unless skill_learn?($data_skills[skill_id])
    @skills.push(skill_id)
    @skills.sort!
  end
end
level_down()

レベルダウン

# File Game_Actor.rb, line 482
def level_down
  @level -= 1
end
level_up()

レベルアップ

# File Game_Actor.rb, line 472
def level_up
  @level += 1
  self.class.learnings.each do |learning|
    learn_skill(learning.skill_id) if learning.level == @level
  end
end
make_action_list()

自動戦闘用の行動候補リストを作成

# File Game_Actor.rb, line 609
def make_action_list
  list = []
  list.push(Game_Action.new(self).set_attack.evaluate)
  usable_skills.each do |skill|
    list.push(Game_Action.new(self).set_skill(skill.id).evaluate)
  end
  list
end
make_actions()

戦闘行動の作成

# File Game_Actor.rb, line 639
def make_actions
  super
  if auto_battle?
    make_auto_battle_actions
  elsif confusion?
    make_confusion_actions
  end
end
make_auto_battle_actions()

自動戦闘時の戦闘行動を作成

# File Game_Actor.rb, line 621
def make_auto_battle_actions
  @actions.size.times do |i|
    @actions[i] = make_action_list.max {|action| action.value }
  end
end
make_confusion_actions()

混乱時の戦闘行動を作成

# File Game_Actor.rb, line 630
def make_confusion_actions
  @actions.size.times do |i|
    @actions[i].set_confusion
  end
end
max_floor_damage()

床ダメージの最大値を取得

# File Game_Actor.rb, line 733
def max_floor_damage
  $data_system.opt_floor_death ? hp : [hp - 1, 0].max
end
max_level()

最大レベル

# File Game_Actor.rb, line 105
def max_level
  actor.max_level
end
max_level?()

最大レベル判定

# File Game_Actor.rb, line 112
def max_level?
  @level >= max_level
end
next_command()

次のコマンド入力へ

# File Game_Actor.rb, line 762
def next_command
  return false if @action_input_index >= @actions.size - 1
  @action_input_index += 1
  return true
end
next_level_exp()

次のレベルの経験値を取得

# File Game_Actor.rb, line 98
def next_level_exp
  exp_for_level(@level + 1)
end
on_player_walk()

プレイヤーが 1 歩動いたときの処理

# File Game_Actor.rb, line 651
def on_player_walk
  @result.clear
  check_floor_effect
  if $game_player.normal_walk?
    turn_end_on_map
    states.each {|state| update_state_steps(state) }
    show_added_states
    show_removed_states
  end
end
opponents_unit()

敵ユニットを取得

# File Game_Actor.rb, line 341
def opponents_unit
  $game_troop
end
optimize_equipments()

最強装備

# File Game_Actor.rb, line 285
def optimize_equipments
  clear_equipments
  equip_slots.size.times do |i|
    next if !equip_change_ok?(i)
    items = $game_party.equip_items.select do |item|
      item.etype_id == equip_slots[i] &&
      equippable?(item) && item.performance >= 0
    end
    change_equip(i, items.max_by {|item| item.performance })
  end
end
param_base(param_id)

通常能力値の基本値取得

# File Game_Actor.rb, line 414
def param_base(param_id)
  self.class.params[param_id, @level]
end
param_max(param_id)

通常能力値の最大値取得

# File Game_Actor.rb, line 406
def param_max(param_id)
  return 9999 if param_id == 0  # MHP
  return super
end
param_plus(param_id)

通常能力値の加算値取得

# File Game_Actor.rb, line 421
def param_plus(param_id)
  equips.compact.inject(super) {|r, item| r += item.params[param_id] }
end
perform_collapse_effect()

コラプス効果の実行

# File Game_Actor.rb, line 599
def perform_collapse_effect
  if $game_party.in_battle
    @sprite_effect_type = :collapse
    Sound.play_actor_collapse
  end
end
perform_damage_effect()

ダメージ効果の実行

# File Game_Actor.rb, line 590
def perform_damage_effect
  $game_troop.screen.start_shake(5, 5, 10)
  @sprite_effect_type = :blink
  Sound.play_actor_damage
end
perform_map_damage_effect()

マップ上でのダメージ効果の実行

# File Game_Actor.rb, line 740
def perform_map_damage_effect
  $game_map.screen.start_flash_for_damage
end
prior_command()

前のコマンド入力へ

# File Game_Actor.rb, line 771
def prior_command
  return false if @action_input_index <= 0
  @action_input_index -= 1
  return true
end
refresh()

リフレッシュ

# File Game_Actor.rb, line 319
def refresh
  release_unequippable_items
  super
end
release_unequippable_items(item_gain = true)

装備できない装備品を外す

item_gain : 外した装備品をパーティに戻す

# File Game_Actor.rb, line 264
def release_unequippable_items(item_gain = true)
  @equips.each_with_index do |item, i|
    if !equippable?(item.object) || item.object.etype_id != equip_slots[i]
      trade_item_with_party(nil, item.object) if item_gain
      item.object = nil
    end
  end
end
reserve_members_exp_rate()

控えメンバーの経験獲得率を取得

# File Game_Actor.rb, line 515
def reserve_members_exp_rate
  $data_system.opt_extra_exp ? 1 : 0
end
set_graphic(character_name, character_index, face_name, face_index)

グラフィックの変更

# File Game_Actor.rb, line 573
def set_graphic(character_name, character_index, face_name, face_index)
  @character_name = character_name
  @character_index = character_index
  @face_name = face_name
  @face_index = face_index
end
setup(actor_id)

セットアップ

# File Game_Actor.rb, line 34
def setup(actor_id)
  @actor_id = actor_id
  @name = actor.name
  @nickname = actor.nickname
  init_graphics
  @class_id = actor.class_id
  @level = actor.initial_level
  @exp = {}
  @equips = []
  init_exp
  init_skills
  init_equips(actor.equips)
  clear_param_plus
  recover_all
end
show_added_states()

付加されたステートの表示

# File Game_Actor.rb, line 675
def show_added_states
  @result.added_state_objects.each do |state|
    $game_message.add(name + state.message1) unless state.message1.empty?
  end
end
show_removed_states()

解除されたステートの表示

# File Game_Actor.rb, line 684
def show_removed_states
  @result.removed_state_objects.each do |state|
    $game_message.add(name + state.message4) unless state.message4.empty?
  end
end
skill_learn?(skill)

スキルの習得済み判定

# File Game_Actor.rb, line 548
def skill_learn?(skill)
  skill.is_a?(RPG::Skill) && @skills.include?(skill.id)
end
skill_wtype_ok?(skill)

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

# File Game_Actor.rb, line 300
def skill_wtype_ok?(skill)
  wtype_id1 = skill.required_wtype_id1
  wtype_id2 = skill.required_wtype_id2
  return true if wtype_id1 == 0 && wtype_id2 == 0
  return true if wtype_id1 > 0 && wtype_equipped?(wtype_id1)
  return true if wtype_id2 > 0 && wtype_equipped?(wtype_id2)
  return false
end
skills()

スキルオブジェクトの配列取得

# File Game_Actor.rb, line 376
def skills
  (@skills | added_skills).sort.collect {|id| $data_skills[id] }
end
slot_list(etype_id)

装備タイプからスロット ID のリストに変換

# File Game_Actor.rb, line 150
def slot_list(etype_id)
  result = []
  equip_slots.each_with_index {|e, i| result.push(i) if e == etype_id }
  result
end
steps_for_turn()

何歩歩いたときに戦闘中の 1 ターン相当とみなすか

# File Game_Actor.rb, line 693
def steps_for_turn
  return 20
end
trade_item_with_party(new_item, old_item)

パーティとアイテムを交換する

new_item : パーティから取り出すアイテム old_item : パーティに返すアイテム

# File Game_Actor.rb, line 231
def trade_item_with_party(new_item, old_item)
  return false if new_item && !$game_party.has_item?(new_item)
  $game_party.gain_item(old_item, 1)
  $game_party.lose_item(new_item, 1)
  return true
end
turn_end_on_map()

マップ画面上でのターン終了処理

# File Game_Actor.rb, line 700
def turn_end_on_map
  if $game_party.steps % steps_for_turn == 0
    on_turn_end
    perform_map_damage_effect if @result.hp_damage > 0
  end
end
update_state_steps(state)

ステートの歩数カウントを更新

# File Game_Actor.rb, line 665
def update_state_steps(state)
  if state.remove_by_walking
    @state_steps[state.id] -= 1 if @state_steps[state.id] > 0
    remove_state(state.id) if @state_steps[state.id] == 0
  end
end
usable_skills()

現在使用できるスキルの配列取得

# File Game_Actor.rb, line 383
def usable_skills
  skills.select {|skill| usable?(skill) }
end
use_sprite?()

スプライトを使うか?

# File Game_Actor.rb, line 583
def use_sprite?
  return false
end
weapons()

武器オブジェクトの配列取得

# File Game_Actor.rb, line 175
def weapons
  @equips.select {|item| item.is_weapon? }.collect {|item| item.object }
end
wtype_equipped?(wtype_id)

特定のタイプの武器を装備しているか

# File Game_Actor.rb, line 312
def wtype_equipped?(wtype_id)
  weapons.any? {|weapon| weapon.wtype_id == wtype_id }
end