Class: Battle::Actions::Attack
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb
Overview
Class describing the Attack Action
Direct Known Subclasses
Defined Under Namespace
Classes: Encore
Instance Attribute Summary collapse
-
#ignore_speed ⇒ Boolean
Tell if this action can ignore speed of the other pokemon.
-
#launcher ⇒ PFM::PokemonBattler
readonly
Get the user of this move.
-
#move ⇒ Battle::Move
readonly
Get the move of this action.
-
#pursuit_enabled ⇒ Boolean
Tell if pursuit on this action is enabled.
-
#sub_launchers ⇒ Array
readonly
List all the sub launcher that will use the same move due to their ability (Dancer).
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare this action with another.
-
#execute
Execute the action.
-
#initialize(scene, move, launcher, target_bank, target_position) ⇒ Attack
constructor
Create a new attack action.
-
#priority ⇒ Integer
Get the priority of the move.
-
#target ⇒ PFM::PokemonBattler?
Get the target of the move.
Methods inherited from Base
Constructor Details
#initialize(scene, move, launcher, target_bank, target_position) ⇒ Attack
Create a new attack action
26 27 28 29 30 31 32 33 34 35 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 26 def initialize(scene, move, launcher, target_bank, target_position) super(scene) @move = move @launcher = launcher @target_bank = target_bank @target_position = target_position @pursuit_enabled = false @ignore_speed = false @sub_launchers = [] end |
Instance Attribute Details
#ignore_speed ⇒ Boolean
Tell if this action can ignore speed of the other pokemon
16 17 18 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 16 def ignore_speed @ignore_speed end |
#launcher ⇒ PFM::PokemonBattler (readonly)
Get the user of this move
10 11 12 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 10 def launcher @launcher end |
#move ⇒ Battle::Move (readonly)
Get the move of this action
7 8 9 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 7 def move @move end |
#pursuit_enabled ⇒ Boolean
Tell if pursuit on this action is enabled
13 14 15 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 13 def pursuit_enabled @pursuit_enabled end |
#sub_launchers ⇒ Array (readonly)
List all the sub launcher that will use the same move due to their ability (Dancer)
19 20 21 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 19 def sub_launchers @sub_launchers end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare this action with another
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 40 def <=>(other) return 1 if other.is_a?(HighPriorityItem) unless @pursuit_enabled && other.is_a?(Attack) && other.pursuit_enabled return -1 if @pursuit_enabled return 1 if other.is_a?(Attack) && other.pursuit_enabled end return -1 if other.is_a?(Flee) && move.relative_priority > 0 return 1 unless other.is_a?(Attack) attack = Attack.from(other) return -1 if @ignore_speed && attack.move.priority(attack.launcher) == @move.priority(@launcher) priority_return = attack.move.priority(attack.launcher) <=> @move.priority(@launcher) return priority_return if priority_return != 0 return -1 if (@launcher.hold_item?(:lagging_tail) && !attack.launcher.hold_item?(:lagging_tail)) || (@launcher.hold_item?(:full_incense) && !attack.launcher.hold_item?(:full_incense)) return -1 if @launcher.has_ability?(:stall) && !attack.launcher.has_ability?(:stall) trick_room_factor = @scene.logic.terrain_effects.has?(:trick_room) ? -1 : 1 return (attack.launcher.spd <=> @launcher.spd) * trick_room_factor end |
#execute
Execute the action
82 83 84 85 86 87 88 89 90 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 82 def execute # Reset flee attempt count @scene.battle_info.flee_attempt_count = 0 if @launcher.from_party? @move.proceed(@launcher, @target_bank, @target_position) @sub_launchers.each do |launcher| @scene.visual.show_ability(launcher) @move.dup.proceed(launcher, @target_bank, @target_position) end end |
#priority ⇒ Integer
Get the priority of the move
66 67 68 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 66 def priority return @pursuit_enabled ? 999 : @move.priority end |
#target ⇒ PFM::PokemonBattler?
Get the target of the move
72 73 74 75 76 77 78 79 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00002 Attack.rb', line 72 def target targets = @move.battler_targets(@launcher, @scene.logic).select(&:alive?) best_target = targets.select { |battler| battler.position == @target_position && battler.bank == @target_bank }.first return best_target if best_target best_target = targets.select { |battler| battler.bank == @target_bank }.first return best_target || targets.first end |