敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の 内部で使用されます。
- A
- C
- D
- E
- F
- G
- I
- M
- N
- O
- P
- S
- T
- U
[R] | enemy_id | |
[R] | index | 公開インスタンス変数 |
[RW] | letter | |
[R] | original_name | |
[RW] | plural | |
[RW] | screen_x | |
[RW] | screen_y |
オブジェクト初期化
Source: show
# File Game_Enemy.rb, line 22 def initialize(index, enemy_id) super() @index = index @enemy_id = enemy_id enemy = $data_enemies[@enemy_id] @original_name = enemy.name @letter = "" @plural = false @screen_x = 0 @screen_y = 0 @battler_name = enemy.battler_name @battler_hue = enemy.battler_hue @hp = mhp @mp = mmp end
現在の状況で戦闘行動が有効か否かを判定
action : RPG::Enemy::Action
Source: show
# File Game_Enemy.rb, line 257 def action_valid?(action) conditions_met?(action) && usable?($data_skills[action.skill_id]) end
行動条件合致判定
action : RPG::Enemy::Action
Source: show
# File Game_Enemy.rb, line 189 def conditions_met?(action) method_table = { 1 => :conditions_met_turns?, 2 => :conditions_met_hp?, 3 => :conditions_met_mp?, 4 => :conditions_met_state?, 5 => :conditions_met_party_level?, 6 => :conditions_met_switch?, } method_name = method_table[action.condition_type] if method_name send(method_name, action.condition_param1, action.condition_param2) else true end end
行動条件合致判定[HP]
Source: show
# File Game_Enemy.rb, line 221 def conditions_met_hp?(param1, param2) hp_rate >= param1 && hp_rate <= param2 end
行動条件合致判定[MP]
Source: show
# File Game_Enemy.rb, line 228 def conditions_met_mp?(param1, param2) mp_rate >= param1 && mp_rate <= param2 end
行動条件合致判定[パーティレベル]
Source: show
# File Game_Enemy.rb, line 242 def conditions_met_party_level?(param1, param2) $game_party.highest_level >= param1 end
行動条件合致判定[ステート]
Source: show
# File Game_Enemy.rb, line 235 def conditions_met_state?(param1, param2) state?(param1) end
行動条件合致判定[スイッチ]
Source: show
# File Game_Enemy.rb, line 249 def conditions_met_switch?(param1, param2) $game_switches[param1] end
行動条件合致判定[ターン数]
Source: show
# File Game_Enemy.rb, line 209 def conditions_met_turns?(param1, param2) n = $game_troop.turn_count if param2 == 0 n == param1 else n > 0 && n >= param1 && n % param2 == param1 % param2 end end
ドロップアイテム取得率の倍率を取得
Source: show
# File Game_Enemy.rb, line 117 def drop_item_rate $game_party.drop_item_double? ? 2 : 1 end
敵キャラオブジェクト取得
Source: show
# File Game_Enemy.rb, line 62 def enemy $data_enemies[@enemy_id] end
特徴を保持する全オブジェクトの配列取得
Source: show
# File Game_Enemy.rb, line 69 def feature_objects super + [enemy] end
味方ユニットを取得
Source: show
# File Game_Enemy.rb, line 48 def friends_unit $game_troop end
アイテムオブジェクトの取得
Source: show
# File Game_Enemy.rb, line 124 def item_object(kind, data_id) return $data_items [data_id] if kind == 1 return $data_weapons[data_id] if kind == 2 return $data_armors [data_id] if kind == 3 return nil end
戦闘行動の作成
Source: show
# File Game_Enemy.rb, line 279 def make_actions super return if @actions.empty? action_list = enemy.actions.select {|a| action_valid?(a) } return if action_list.empty? rating_max = action_list.collect {|a| a.rating }.max rating_zero = rating_max - 3 action_list.reject! {|a| a.rating <= rating_zero } @actions.each do |action| action.set_enemy_action(select_enemy_action(action_list, rating_zero)) end end
ドロップアイテムの配列作成
Source: show
# File Game_Enemy.rb, line 104 def make_drop_items enemy.drop_items.inject([]) do |r, di| if di.kind > 0 && rand * di.denominator < drop_item_rate r.push(item_object(di.kind, di.data_id)) else r end end end
表示名の取得
Source: show
# File Game_Enemy.rb, line 76 def name @original_name + (@plural ? letter : "") end
敵ユニットを取得
Source: show
# File Game_Enemy.rb, line 55 def opponents_unit $game_party end
通常能力値の基本値取得
Source: show
# File Game_Enemy.rb, line 83 def param_base(param_id) enemy.params[param_id] end
コラプス効果の実行
Source: show
# File Game_Enemy.rb, line 156 def perform_collapse_effect case collapse_type when 0 @sprite_effect_type = :collapse Sound.play_enemy_collapse when 1 @sprite_effect_type = :boss_collapse Sound.play_boss_collapse1 when 2 @sprite_effect_type = :instant_collapse end end
ダメージ効果の実行
Source: show
# File Game_Enemy.rb, line 148 def perform_damage_effect @sprite_effect_type = :blink Sound.play_enemy_damage end
バトル画面 Z 座標の取得
Source: show
# File Game_Enemy.rb, line 141 def screen_z return 100 end
戦闘行動をランダムに選択
action_list : RPG::Enemy::Action の配列 rating_zero : ゼロとみなすレーティング値
Source: show
# File Game_Enemy.rb, line 266 def select_enemy_action(action_list, rating_zero) sum = action_list.inject(0) {|r, a| r += a.rating - rating_zero } return nil if sum <= 0 value = rand(sum) action_list.each do |action| return action if value < action.rating - rating_zero value -= action.rating - rating_zero end end
変身
Source: show
# File Game_Enemy.rb, line 172 def transform(enemy_id) @enemy_id = enemy_id if enemy.name != @original_name @original_name = enemy.name @letter = "" @plural = false end @battler_name = enemy.battler_name @battler_hue = enemy.battler_hue refresh make_actions unless @actions.empty? end