Class: PFM::PokemonBattler

Inherits:
Pokemon show all
Includes:
Hooks
Defined in:
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00400 Grounded.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/01000 MoveHistory.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/01100 DamageHistory.rb,
scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb

Overview

Class defining a Pokemon during a battle, it aim to copy its properties but also to have the methods related to the battle.

Defined Under Namespace

Classes: DamageHistory, MoveHistory

Constant Summary collapse

MIN_STAGE =

Minimal value of the stat modifier level (stage)

-6
# Maximal value of the stat modifier level (stage)
MAX_STAGE =

Maximal value of the stat modifier level (stage)

6
COPIED_PROPERTIES =

List of properties to copy

%i[
  @id @form @given_name @code @ability @nature
  @iv_hp @iv_atk @iv_dfe @iv_spd @iv_ats @iv_dfs
  @ev_hp @ev_atk @ev_dfe @ev_spd @ev_ats @ev_dfs
  @trainer_id @trainer_name @step_remaining @loyalty
  @exp @hp @status @status_count @item_holding
  @captured_with @captured_in @captured_at @captured_level
  @gender @skill_learnt @ribbons @character
  @exp_rate @hp_rate @egg_at @egg_in
]
TRANSFORM_COPIED_PROPERTIES =

List of properties to copy with transform

%i[
  @id @form @ability @nature
  @ev_hp @ev_atk @ev_dfe @ev_spd @ev_ats @ev_dfs
  @gender
]
BACK_PROPERTIES =

List of properties to copy back to original

%i[
  @id @form
  @trainer_id @trainer_name @step_remaining @loyalty
  @hp @status @status_count @item_holding
  @captured_with @captured_in @captured_at @captured_level
  @gender @character @hp_rate
]

Constants inherited from Pokemon

PFM::Pokemon::ABILITY_CHANCES, PFM::Pokemon::ArceusItem, PFM::Pokemon::BATTLER_SIZE, PFM::Pokemon::EGG_FILENAMES, PFM::Pokemon::FLAG_CAUGHT_BY_PLAYER, PFM::Pokemon::FLAG_FROM_THIS_GAME, PFM::Pokemon::FLAG_PRESENT_TIME, PFM::Pokemon::FLAG_UNKOWN_USE, PFM::Pokemon::FOOT_SIZE, PFM::Pokemon::FORM_CALIBRATE, PFM::Pokemon::FORM_GENERATION, PFM::Pokemon::GIF_FILENAMES, PFM::Pokemon::G_FORM, PFM::Pokemon::G_GR, PFM::Pokemon::G_ID, PFM::Pokemon::G_MOVE, PFM::Pokemon::G_NV, PFM::Pokemon::G_OBJ, PFM::Pokemon::G_SHINY, PFM::Pokemon::G_STAT, PFM::Pokemon::GenesectModules, PFM::Pokemon::ICON_FILENAMES, PFM::Pokemon::ICON_SIZE, PFM::Pokemon::SPECIAL_EVOLUTION_ID, PFM::Pokemon::SPRITES_FILENAMES, PFM::Pokemon::SPRITES_TO_CHECK, PFM::Pokemon::Shiny_IV, PFM::Pokemon::SilvallyROM

Instance Attribute Summary collapse

Attributes inherited from Pokemon

#ability_index, #ability_used, #attack_order, #battle_stage, #captured_at, #captured_in, #captured_level, #captured_with, #character, #code, #confuse, #critical_modifier, #egg_at, #egg_in, #ev_atk, #ev_ats, #ev_dfe, #ev_dfs, #ev_hp, #ev_spd, #exp, #exp_rate, #form, #game_code, #given_name, #hp, #hp_rate, #id, #item_holding, #iv_atk, #iv_ats, #iv_dfe, #iv_dfs, #iv_hp, #iv_spd, #level, #loyalty, #memo_text, #nature, #prepared_skill, #ribbons, #skill_learnt, #skills_set, #status, #status_count, #step_remaining, #sub_code, #sub_form, #sub_id, #trainer_id, #trainer_name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#exec_hooks, #force_return, included, register, remove, remove_without_name

Methods inherited from Pokemon

#ability_descr, #ability_name, #absofusion, #absofusionned?, #add_bonus, #add_ev_atk, #add_ev_ats, #add_ev_dfe, #add_ev_dfs, #add_ev_hp, #add_ev_spd, add_evolution_criteria, #add_ribbon, #alive?, #asleep?, back_filename, back_gif_filename, #ball_color, #ball_image, #ball_sprite, #base_atk, #base_ats, #base_dfe, #base_dfs, #base_exp, #base_spd, #battle_list, #battler_back, #battler_face, #burn?, #calyrex_form, #can_be_asleep?, #can_be_burn?, #can_be_frozen?, #can_be_paralyzed?, #can_be_poisoned?, #can_learn?, #can_learn_skill_at_this_level?, #can_mega_evolve?, #captured_zone_name, #caught_by_player?, #character_name, #check_skill_and_learn, #cry, #cure, #current_deerling_form, #data, #db_symbol, #dead?, #dv_modifier, #edit_bonus, #egg?, #egg_finish, #egg_init, #egg_zone_name, #elv_armulys, #elv_blindalys, #elv_demanta, #elv_kapoera, #elv_kicklee, #elv_nymphali, #elv_pandarbare, #elv_sepiatroce, #elv_tygnon, #encode, #ev_atk_text, #ev_ats_text, #ev_check, #ev_dfe_text, #ev_dfs_text, #ev_hp_text, #ev_spd_text, #ev_var, #evolve, #evolve_check, #exp_list, #exp_lvl, #exp_remaining_text, #exp_text, #exp_type, #female?, #find_skill, #flags, #flags=, #flavor_disliked?, #flavor_liked?, #forget_skill, #form_calibrate, #form_generation, #from_past?, #from_player?, front_filename, front_gif_filename, #front_offset_y, #frozen?, #genderless?, generate_from_hash, #get_dv_value, #gif_back, #gif_face, #hp_pokemon_number, #hp_text, #icon, icon_filename, #id_text, #id_text2, #id_text3, #item_hold, #item_name, #iv_atk_text, #iv_ats_text, #iv_dfe_text, #iv_dfs_text, #iv_hp_text, #iv_spd_text, #kyurem_form, #learn_skill, #level_pokemon_number, #level_text, #level_text2, #level_up, #level_up_stat_refresh, #level_up_window_call, #load_skill_from_array, #male?, #max_hp, #max_level, #max_level=, #mega_evolve, #mega_evolved?, #modifier_stage, #name, #name_upper, #nature_text, #necrozma_form, #no_preferences?, #paralyzed?, #poisoned?, #primary_data, #remindable_skills, #replace_skill_index, #ribbon_got?, #separate, #shaymin_form, #shiny=, #shiny?, #shiny_rate, #skill_learnt?, #sleep_check, #status?, #status_burn, #status_frozen, #status_paralyze, #status_poison, #status_sleep, #status_toxic, #swap_skills_index, #total_ev, #toxic?, #trainer_id_text, #type?, #type_bug?, #type_dark?, #type_dragon?, #type_electric?, #type_fairy?, #type_fighting?, #type_fire?, #type_flying?, #type_ghost?, #type_grass?, #type_ground?, #type_ice?, #type_normal?, #type_poison?, #type_psychic?, #type_rock?, #type_steel?, #type_water?, #unmega_evolve, #update_ability, #update_loyalty, #zone_id

Constructor Details

#initialize(original, scene, max_level = Float::INFINITY) ⇒ PokemonBattler

Create a new PokemonBattler from a Pokemon

Parameters:

  • original (PFM::Pokemon)

    original Pokemon (protected during the battle)

  • scene (Battle::Scene)

    current battle scene

  • max_level (Integer) (defaults to: Float::INFINITY)

    new max level for Online battle



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 119

def initialize(original, scene, max_level = Float::INFINITY)
  @original = original
  # @type [PFM::Pokemon]
  @transform = nil
  @scene = scene
  scene.logic.transform_handler.initialize_transform_attempt(self)
  copy_properties
  copy_moveset
  @battle_stage = Array.new(7, 0)
  @battle_properties = {}
  reset_states
  @battle_max_level = max_level
  @level = original.level < max_level ? original.level : max_level
  @type3 = 0
  @bank = 0
  @position = -1
  @battle_item_data = []
  @battle_item = @item_holding
  @last_battle_turn = -1
  @last_sent_turn = -1
  @move_history = []
  @damage_history = []
  @encounter_list = []
  @mega_evolved = false
  @exp_distributed = false
  @item_consumed = false
  @consumed_item = :__undef__
  self.hp = (max_hp * hp_rate).to_i
  initialize_set_is_follower
end

Instance Attribute Details

#bagPFM::Bag

Get the bag of the battler

Returns:



83
84
85
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 83

def bag
  @bag
end

#bankInteger

Returns Bank where the Pokemon is supposed to be.

Returns:

  • (Integer)

    Bank where the Pokemon is supposed to be



56
57
58
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 56

def bank
  @bank
end

#battle_itemInteger

Get the item held during battle

Returns:



91
92
93
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 91

def battle_item
  @battle_item
end

#battle_item_dataArray (readonly)

Get the data associated to the item if needed

Returns:

  • (Array)


95
96
97
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 95

def battle_item_data
  @battle_item_data
end

#consumed_itemSymbol

Returns the symbol of the consumed item.

Returns:

  • (Symbol)

    the symbol of the consumed item



109
110
111
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 109

def consumed_item
  @consumed_item
end

#damage_historyArray<DamageHistory> (readonly)

Get the damage history

Returns:



71
72
73
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 71

def damage_history
  @damage_history
end

#effectsBattle::Effects::EffectsHandler (readonly)

Get the effect hanndler



6
7
8
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb', line 6

def effects
  @effects
end

#encounter_listArray<PFM::PokemonBattler> (readonly)

Get the encounter list

Returns:



75
76
77
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 75

def encounter_list
  @encounter_list
end

#exp_distributedBoolean

Tell if the Pokemon already distributed its experience during the battle

Returns:

  • (Boolean)


87
88
89
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 87

def exp_distributed
  @exp_distributed
end

#is_followerBoolean

Get the information if the Pokemon is actually a follower or not (changing its go-in-out animation)

Returns:

  • (Boolean)


79
80
81
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 79

def is_follower
  @is_follower
end

#item_consumedBoolean

Tell if the Pokemon has its item consumed

Returns:

  • (Boolean)


106
107
108
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 106

def item_consumed
  @item_consumed
end

#last_battle_turnInteger

Last turn the Pokemon fought

Returns:



40
41
42
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 40

def last_battle_turn
  @last_battle_turn
end

#last_hit_by_moveBattle::Move

Returns last move that hit the pokemon.

Returns:



47
48
49
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 47

def last_hit_by_move
  @last_hit_by_move
end

#last_sent_turnInteger

Last turn the pokemon was sent out

Returns:



44
45
46
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 44

def last_sent_turn
  @last_sent_turn
end

#mimic_moveArray<Battle::Move, Integer>

Mimic move that was replace by another move with its index

Returns:



102
103
104
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 102

def mimic_move
  @mimic_move
end

#move_historyArray<MoveHistory> (readonly)

Get the move history

Returns:



67
68
69
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 67

def move_history
  @move_history
end

#movesetArray<Battle::Move> (readonly)

Returns the moveset of the Pokemon.

Returns:



32
33
34
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 32

def moveset
  @moveset
end

#originalPFM::Pokemon (readonly)

Get the original Pokemon

Returns:



63
64
65
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 63

def original
  @original
end

#party_idInteger

Returns the ID of the party that control the Pokemon in the bank.

Returns:

  • (Integer)

    the ID of the party that control the Pokemon in the bank



53
54
55
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 53

def party_id
  @party_id
end

#positionInteger

Returns Position of the Pokemon in the bank.

Returns:

  • (Integer)

    Position of the Pokemon in the bank



59
60
61
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 59

def position
  @position
end

#switching=(value) ⇒ Boolean (writeonly)

Returns set switching state.

Returns:

  • (Boolean)

    set switching state



98
99
100
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 98

def switching=(value)
  @switching = value
end

#transformPFM::Pokemon

Get the transform pokemon

Returns:



113
114
115
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 113

def transform
  @transform
end

#turn_countInteger Also known as: battle_turns

Returns number of turn the Pokemon is in battle.

Returns:

  • (Integer)

    number of turn the Pokemon is in battle



35
36
37
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 35

def turn_count
  @turn_count
end

#type3Integer

Returns 3rd type (Mega / Move effect).

Returns:

  • (Integer)

    3rd type (Mega / Move effect)



244
245
246
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 244

def type3
  return @battle_properties[:type3] || super
end

Class Method Details

.register_force_flying_hook(reason) {|pokemon, scene| ... }

Register a hook forcing Pokemon to be flying (ie not grounded)

Parameters:

  • reason (String)

    reason of the force_flying hook

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the Pokemon is forced to be “flying”



32
33
34
35
36
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00400 Grounded.rb', line 32

def register_force_flying_hook(reason)
  Hooks.register(PokemonBattler, :force_flying, reason) do
    force_return(false) if yield(self, @scene)
  end
end

.register_force_grounded_hook(reason) {|pokemon, scene| ... }

Register a hook forcing Pokemon to be grounded

Parameters:

  • reason (String)

    reason of the force_grounded hook

Yield Parameters:

Yield Returns:

  • (Boolean)

    if the Pokemon is forced to be grounded



21
22
23
24
25
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00400 Grounded.rb', line 21

def register_force_grounded_hook(reason)
  Hooks.register(PokemonBattler, :force_grounded, reason) do
    force_return(true) if yield(self, @scene)
  end
end

Instance Method Details

#abilityInteger

Return the battler's combat property

Returns:



110
111
112
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 110

def ability
  return @battle_properties[:ability] || super
end

#ability=(value)

Set the battler's combat property

Parameters:



116
117
118
119
120
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 116

def ability=(value)
  return log_error("Wrong ability id : #{value}") if data_ability(value).id != value

  @battle_properties[:ability] = value
end

#ability_db_symbolSymbol

Return the db_symbol of the current ability of the Pokemon

Returns:

  • (Symbol)


168
169
170
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 168

def ability_db_symbol
  return data_ability(ability || -1).db_symbol
end

#ability_effectBattle::Effects::Ability

Get the ability effect



38
39
40
41
42
43
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb', line 38

def ability_effect
  db_symbol = battle_ability_db_symbol
  db_symbol = :__undef__ unless has_ability?(db_symbol)
  @ability_effect = Battle::Effects::Ability.new(@scene.logic, self, db_symbol) if !@ability_effect || @ability_effect.db_symbol != db_symbol
  return @ability_effect
end

#acc_stageInteger

Return the accuracy stage

Returns:



109
110
111
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 109

def acc_stage
  return @battle_stage[Configs.stats.acc_stage_index]
end

#acc_stage=(value) ⇒ Integer

Set the acc stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



205
206
207
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 205

def acc_stage=(value)
  return set_stat_stage(Configs.stats.acc_stage_index, value)
end

#add_battler_to_encounter_list(battler)

Note:

The battler is not added if it is already present in the list

Add a battler to the encounter list

Parameters:



243
244
245
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 243

def add_battler_to_encounter_list(battler)
  @encounter_list << battler unless @encounter_list.include?(battler)
end

#add_damage_to_history(damage, launcher, move, ko)

Note:

This method should only be used for sucessfull damages!!!

Add a damage to the damage history

Parameters:



236
237
238
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 236

def add_damage_to_history(damage, launcher, move, ko)
  @damage_history << DamageHistory.new(damage, launcher, move, ko)
end

#add_move_to_history(move, targets)

Note:

This method should only be used for sucessfull moves!!!

Add a move to the move history

Parameters:



226
227
228
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 226

def add_move_to_history(move, targets)
  @move_history << MoveHistory.new(move, targets, attack_order)
end

#affected_by_terrain?Boolean

Is the pokemon affected by the terrain ?

Returns:

  • (Boolean)


381
382
383
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 381

def affected_by_terrain?
  return grounded? && !effects.has?(&:out_of_reach?)
end

#apply_flinch(forced = false)

Apply the flinch effect

Parameters:

  • forced (Boolean) (defaults to: false)

    this parameter is ignored since flinch effect is volatile



362
363
364
365
366
367
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 362

def apply_flinch(forced = false)
  old_effect = effects.get(:flinch)
  return if old_effect && !old_effect.dead?

  effects.add(Battle::Effects::Flinch.new(@scene.logic, self))
end

#atkInteger

Return the current atk

Returns:



10
11
12
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 10

def atk
  return (atk_basis * atk_modifier).floor
end

#atk_basisInteger

Return the battler's combat property

Returns:



8
9
10
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 8

def atk_basis
  return @battle_properties[:atk_basis] || super
end

#atk_basis=(value)

Set the battler's combat property

Parameters:



14
15
16
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 14

def atk_basis=(value)
  @battle_properties[:atk_basis] = value
end

#atk_modifierFloat

Return the atk modifier

Returns:

  • (Float)

    the multiplier



43
44
45
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 43

def atk_modifier
  return stat_multiplier_regular(atk_stage)
end

#atk_stageInteger

Return the atk stage

Returns:



73
74
75
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 73

def atk_stage
  return @battle_stage[Configs.stats.atk_stage_index]
end

#atk_stage=(value) ⇒ Integer

Set the atk stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



219
220
221
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 219

def atk_stage=(value)
  return set_stat_stage(Configs.stats.atk_stage_index, value)
end

#atsInteger

Return the current ats

Returns:



31
32
33
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 31

def ats
  return (ats_basis * ats_modifier).floor
end

#ats_basisInteger

Return the battler's combat property

Returns:



25
26
27
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 25

def ats_basis
  return @battle_properties[:ats_basis] || super
end

#ats_basis=(value)

Set the battler's combat property

Parameters:



31
32
33
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 31

def ats_basis=(value)
  @battle_properties[:ats_basis] = value
end

#ats_modifierFloat

Return the ats modifier

Returns:

  • (Float)

    the multiplier



61
62
63
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 61

def ats_modifier
  return stat_multiplier_regular(ats_stage)
end

#ats_stageInteger

Return the ats stage

Returns:



91
92
93
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 91

def ats_stage
  return @battle_stage[Configs.stats.ats_stage_index]
end

#ats_stage=(value) ⇒ Integer

Set the ats stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



226
227
228
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 226

def ats_stage=(value)
  return set_stat_stage(Configs.stats.ats_stage_index, value)
end

#base_hpInteger

Return the base HP

Returns:



304
305
306
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 304

def base_hp
  @original.base_hp
end

#battle_ability_db_symbolSymbol

Return the db_symbol of the current ability of the Pokemon for battle

Returns:

  • (Symbol)


174
175
176
177
178
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 174

def battle_ability_db_symbol
  return :__undef__ if effects.has?(:ability_suppressed) && $scene.is_a?(Battle::Scene)

  return ability_db_symbol
end

#battle_item_db_symbolSymbol

Get the item for battle

Returns:

  • (Symbol)


195
196
197
198
199
200
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 195

def battle_item_db_symbol
  return :__undef__ if @scene.logic.terrain_effects.has?(&:on_held_item_use_prevention)
  return :__undef__ if battle_ability_db_symbol == :klutz

  return item_db_symbol
end

#can_be_lowered_or_canceled?(test = true) ⇒ Boolean

Test if the Pokemon can have a lowering stat or have its move canceled (return false if the Pokemon has mold breaker)

List of ability that should be affected: :battle_armor|:clear_body|:damp|:dry_skin|:filter|:flash_fire|:flower_gift|:heatproof|:hyper_cutter|:immunity|:inner_focus|:insomnia| :keen_eye|:leaf_guard|:levitate|:lightning_rod|:limber|:magma_armor|:marvel_scale|:motor_drive|:oblivious|:own_tempo|:sand_veil|:shell_armor| :shield_dust|:simple|:snow_cloak|:solid_rock|:soundproof|:sticky_hold|:storm_drain|:sturdy|:suction_cups|:tangled_feet|:thick_fat|:unaware|:vital_spirit| :volt_absorb|:water_absorb|:water_veil|:white_smoke|:wonder_guard|:big_pecks|:contrary|:friend_guard|:heavy_metal|:light_metal|:magic_bounce|:multiscale| :sap_sipper|:telepathy|:wonder_skin|:aroma_veil|:bulletproof|:flower_veil|:fur_coat|:overcoat|:sweet_veil|:dazzling|:disguise|:fluffy|:queenly_majesty| :water_bubble|:mirror_armor|:punk_rock|:ice_scales|:ice_face|:pastel_veil

Parameters:

  • test (Boolean) (defaults to: true)

    if the test should be done

Returns:

  • (Boolean)

    potential changed result



284
285
286
287
288
289
290
291
292
293
294
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 284

def can_be_lowered_or_canceled?(test = true)
  return false unless test
  return test unless has_ability?(:mold_breaker) || has_ability?(:teravolt) || has_ability?(:turboblaze)

  unless ability_used
    @scene.visual.show_ability(self)

    self.ability_used = true
  end
  return false
end

#can_fight?Boolean

Is the Pokemon able to fight ?

Returns:

  • (Boolean)


152
153
154
155
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 152

def can_fight?
  log_error("The pokemon #{self} has undefined position, it should be -1 if not in battle") unless @position
  return @position && @position >= 0 && !dead?
end

#can_move?Boolean

Test if the Pokemon can use a move

Returns:

  • (Boolean)


267
268
269
270
271
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 267

def can_move?
  return false if moveset.all? { |move| move.pp == 0 || move.disabled?(self) }

  return true
end

#change_acc(amount) ⇒ Integer

Change the acc stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



190
191
192
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 190

def change_acc(amount)
  return change_stat(Configs.stats.acc_stage_index, amount)
end

#change_atk(amount) ⇒ Integer

Change the atk stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



148
149
150
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 148

def change_atk(amount)
  return change_stat(Configs.stats.atk_stage_index, amount)
end

#change_ats(amount) ⇒ Integer

Change the ats stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



169
170
171
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 169

def change_ats(amount)
  return change_stat(Configs.stats.ats_stage_index, amount)
end

#change_dfe(amount) ⇒ Integer

Change the dfe stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



155
156
157
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 155

def change_dfe(amount)
  return change_stat(Configs.stats.dfe_stage_index, amount)
end

#change_dfs(amount) ⇒ Integer

Change the dfs stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



176
177
178
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 176

def change_dfs(amount)
  return change_stat(Configs.stats.dfs_stage_index, amount)
end

#change_eva(amount) ⇒ Integer

Change the eva stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



183
184
185
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 183

def change_eva(amount)
  return change_stat(Configs.stats.eva_stage_index, amount)
end

#change_spd(amount) ⇒ Integer

Change the spd stage

Parameters:

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



162
163
164
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 162

def change_spd(amount)
  return change_stat(Configs.stats.spd_stage_index, amount)
end

#change_stat(stat_id, amount) ⇒ Integer

Change a stat stage

Parameters:

  • stat_id (Integer)

    id of the stat : 0 = atk, 1 = dfe, 2 = spd, 3 = ats, 4 = dfs, 5 = eva, 6 = acc

  • amount (Integer)

    the amount to change on the stat stage

Returns:

  • (Integer)

    the difference between the current and the last stage value



139
140
141
142
143
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 139

def change_stat(stat_id, amount)
  last_value = @battle_stage[stat_id]
  @battle_stage[stat_id] = (@battle_stage[stat_id] + amount).clamp(MIN_STAGE, MAX_STAGE)
  return @battle_stage[stat_id] - last_value
end

#change_types(*types)

Change the type of the pokemons

Parameters:



395
396
397
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 395

def change_types(*types)
  self.type1, self.type2, self.type3 = types
end

#confused?Boolean

Is the Pokemon confused?

Returns:

  • (Boolean)


356
357
358
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 356

def confused?
  return effects.has?(:confusion)
end

#copy_properties_back_to_original

Copy all the properties back to the original pokemon



309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 309

def copy_properties_back_to_original
  return if @scene.battle_info.max_level

  @battle_properties.clear
  self.transform = nil
  original = @original
  BACK_PROPERTIES.each do |ivar_name|
    original.instance_variable_set(ivar_name, instance_variable_get(ivar_name))
  end
  @moveset.each_with_index do |move, i|
    @original.skills_set[i]&.pp = move.pp
  end
end

#delete_battler_to_encounter_list(battler)

Delete a battler to the encounter list

Parameters:



249
250
251
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 249

def delete_battler_to_encounter_list(battler)
  @encounter_list.delete(battler)
end

#dfeInteger

Return the current dfe

Returns:



16
17
18
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 16

def dfe
  return (dfe_basis * dfe_modifier).floor
end

#dfe_basisInteger

Return the battler's combat property

Returns:



42
43
44
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 42

def dfe_basis
  return @battle_properties[:dfe_basis] || super
end

#dfe_basis=(value)

Set the battler's combat property

Parameters:



48
49
50
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 48

def dfe_basis=(value)
  @battle_properties[:dfe_basis] = value
end

#dfe_modifierFloat

Return the dfe modifier

Returns:

  • (Float)

    the multiplier



49
50
51
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 49

def dfe_modifier
  return stat_multiplier_regular(dfe_stage)
end

#dfe_stageInteger

Return the dfe stage

Returns:



79
80
81
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 79

def dfe_stage
  return @battle_stage[Configs.stats.dfe_stage_index]
end

#dfe_stage=(value) ⇒ Integer

Set the dfe stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



233
234
235
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 233

def dfe_stage=(value)
  return set_stat_stage(Configs.stats.dfe_stage_index, value)
end

#dfsInteger

Return the current dfs

Returns:



37
38
39
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 37

def dfs
  return (dfs_basis * dfs_modifier).floor
end

#dfs_basisInteger

Return the battler's combat property

Returns:



59
60
61
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 59

def dfs_basis
  return @battle_properties[:dfs_basis] || super
end

#dfs_basis=(value)

Set the battler's combat property

Parameters:



65
66
67
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 65

def dfs_basis=(value)
  @battle_properties[:dfs_basis] = value
end

#dfs_modifierFloat

Return the dfs modifier

Returns:

  • (Float)

    the multiplier



67
68
69
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 67

def dfs_modifier
  return stat_multiplier_regular(dfs_stage)
end

#dfs_stageInteger

Return the dfs stage

Returns:



97
98
99
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 97

def dfs_stage
  return @battle_stage[Configs.stats.dfs_stage_index]
end

#dfs_stage=(value) ⇒ Integer

Set the dfs stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



240
241
242
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 240

def dfs_stage=(value)
  return set_stat_stage(Configs.stats.dfs_stage_index, value)
end

#encountered?(battler) ⇒ Boolean

Test if the Pokemon has encountered the battler

Parameters:

Returns:

  • (Boolean)


255
256
257
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 255

def encountered?(battler)
  return @encounter_list.include?(battler)
end

#eva_stageInteger

Return the evasion stage

Returns:



103
104
105
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 103

def eva_stage
  return @battle_stage[Configs.stats.eva_stage_index]
end

#eva_stage=(value) ⇒ Integer

Set the eva stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



247
248
249
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 247

def eva_stage=(value)
  return set_stat_stage(Configs.stats.eva_stage_index, value)
end

#evaluate_effects(yielder)

Evaluate all the effects related to this Pokemon

Parameters:

  • yielder (Proc)

    proc to call with the effect



14
15
16
17
18
19
20
21
22
23
24
25
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb', line 14

def evaluate_effects(yielder)
  # Status Effect
  yielder.call(status_effect)
  # Ability Effect
  yielder.call(ability_effect)
  # Item effect
  yielder.call(item_effect)
  # Move effect
  effects.each(&yielder)
  # Position effects
  @scene.logic.position_effects[bank][position]&.each(&yielder)
end

#from_party?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 162

def from_party?
  $actors.include?(@original)
end

#genderInteger

Return the battler's combat property

Returns:



167
168
169
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 167

def gender
  return @battle_properties[:gender] || super
end

#gender=(value)

Set the battler's combat property

Parameters:



173
174
175
176
177
178
179
180
181
182
183
184
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 173

def gender=(value)
  if primary_data.female_rate == -1
    @battle_properties[:gender]  = 0
  elsif primary_data.female_rate == 0
    @battle_properties[:gender]  = 1
  elsif primary_data.female_rate == 100
    @battle_properties[:gender]  = 2
  else
    gender = %w[i m f].index(gender.downcase).to_i if gender.is_a?(String)
    @battle_properties[:gender]  = gender.clamp(0, 2)
  end
end

#grounded?Boolean

Check if the pokemon is grounded

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00400 Grounded.rb', line 5

def grounded?
  exec_hooks(PokemonBattler, :force_grounded, binding)
  exec_hooks(PokemonBattler, :force_flying, binding)
  return true
rescue Hooks::ForceReturn => e
  log_data("# pokemon = #{self}")
  log_data("# FR: grounded? #{e.data} from #{e.hook_name} (#{e.reason})")
  return e.data
end

#has_ability?(db_symbol) ⇒ Boolean

Tell if the pokemon has an ability

Parameters:

  • db_symbol (Symbol)

    db_symbol of the ability

Returns:

  • (Boolean)


183
184
185
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 183

def has_ability?(db_symbol)
  return battle_ability_db_symbol == db_symbol
end

#heightInteger

Return the battler's combat property

Returns:



129
130
131
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 129

def height
  return @battle_properties[:height] || super
end

#height=(value)

Set the battler's combat property

Parameters:



135
136
137
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 135

def height=(value)
  @battle_properties[:height] = value
end

#hold_berry?(db_symbol) ⇒ Boolean

Tell if the pokemon hold a berry

Parameters:

  • db_symbol (Symbol)

    db_symbol of the item

Returns:

  • (Boolean)


216
217
218
219
220
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 216

def hold_berry?(db_symbol)
  return false unless data_item(db_symbol)&.socket == 4

  return hold_item?(db_symbol)
end

#hold_item?(db_symbol) ⇒ Boolean

Tell if the pokemon hold an item

Parameters:

  • db_symbol (Symbol)

    db_symbol of the item

Returns:

  • (Boolean)


205
206
207
208
209
210
211
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 205

def hold_item?(db_symbol)
  return false if @scene.logic.terrain_effects.has?(&:on_held_item_use_prevention)
  return false if effects.has?(:item_stolen) || effects.has?(:item_burnt)
  return false if db_symbol == :__undef__

  return battle_item_db_symbol == db_symbol
end

#ignore_types(*types, default: data_type(:normal).id)

Neutralize a type on the Pokemon

Parameters:

  • types (Array<Integer>)
  • default (Integer) (defaults to: data_type(:normal).id)

    (default: id of :normal) type applied when no other types are defined



388
389
390
391
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 388

def ignore_types(*types, default: data_type(:normal).id)
  self.type1, self.type2, self.type3 = [type1, type2, type3].reject { |t| types.include?(t) }
  self.type1 = default unless type1
end

#item_db_symbolSymbol

Return the db_symbol of the current item the Pokemon is holding

Returns:

  • (Symbol)


189
190
191
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 189

def item_db_symbol
  data_item(@battle_item || -1).db_symbol
end

#item_effectBattle::Effects::Item

Get the item effect



47
48
49
50
51
52
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb', line 47

def item_effect
  db_symbol = battle_item_db_symbol
  db_symbol = :__undef__ unless hold_item?(db_symbol)
  @item_effect = Battle::Effects::Item.new(@scene.logic, self, db_symbol) if !@item_effect || @item_effect.db_symbol != db_symbol
  return @item_effect
end

#last_successfull_move_is?(db_symbol) ⇒ Boolean

Test if the last move was of a certain symbol

Parameters:

  • db_symbol (Symbol)

    symbol of the move

Returns:

  • (Boolean)


261
262
263
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 261

def last_successfull_move_is?(db_symbol)
  return @move_history.last&.db_symbol == db_symbol
end

#level_up_copy

Copy some important data upon level up



423
424
425
426
427
428
429
430
431
432
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 423

def level_up_copy
  self.level = @original.level
  self.exp = @original.exp
  return level_up_stat_refresh if @transform

  self.hp = original.hp
  %i[@ev_hp @ev_atk @ev_dfe @ev_spd @ev_ats @ev_dfs].each do |ivar_name|
    instance_variable_set(ivar_name, original.instance_variable_get(ivar_name))
  end
end

#level_up_copy_moveset(moveset_before)

Copy the moveset upon level up

Parameters:



407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 407

def level_up_copy_moveset(moveset_before)
  if moveset_before.size < original.skills_set.size
    indexes = moveset_before.size.upto(original.skills_set.size - 1).to_a
  else
    indexes = (moveset_before - original.skills_set).map { |i| moveset_before.index(i) }
  end
  moveset = @transform ? @moveset_before_transform : @moveset
  moveset = @moveset unless @moveset_before_transform
  indexes.each do |i|
    next unless (skill = original.skills_set[i])

    moveset[i] = Battle::Move[skill.symbol].new(skill.id, skill.pp, skill.ppmax, @scene)
  end
end

#nature_idInteger

Return the battler's combat property

Returns:



93
94
95
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 93

def nature_id
  return @battle_properties[:nature_id] || super
end

#nature_id=(value)

Set the battler's combat property

Parameters:



99
100
101
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 99

def nature_id=(value)
  @battle_properties[:nature_id] = value
end

#rarenessInteger

Return the Pokemon rareness

Returns:



193
194
195
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 193

def rareness
  return @battle_properties[:rareness] || super
end

#rareness=(value)

Set the battler's combat property

Parameters:



199
200
201
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 199

def rareness=(value)
  @battle_properties[:rareness] = value.clamp(0, 255)
end

#reset_states

Function that resets everything from the pokemon once it got switched out of battle



324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 324

def reset_states
  @battle_stage.map! { 0 }
  @battle_properties.clear
  exec_hooks(PFM::PokemonBattler, :on_reset_states, binding)
  @switching = false
  @turn_count = 0
  @type1 = @type2 = @type3 = nil
  if mimic_move
    @moveset[mimic_move.last] = mimic_move.first
    @moveset.compact!
    @mimic_move = nil
  end
end

#restore_ability

Restore the battler's property original value



123
124
125
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 123

def restore_ability
  @battle_properties.delete(:ability)
end

#restore_atk_basis

Restore the battler's property original value



19
20
21
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 19

def restore_atk_basis
  @battle_properties.delete(:atk_basis)
end

#restore_ats_basis

Restore the battler's property original value



36
37
38
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 36

def restore_ats_basis
  @battle_properties.delete(:ats_basis)
end

#restore_dfe_basis

Restore the battler's property original value



53
54
55
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 53

def restore_dfe_basis
  @battle_properties.delete(:dfe_basis)
end

#restore_dfs_basis

Restore the battler's property original value



70
71
72
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 70

def restore_dfs_basis
  @battle_properties.delete(:dfs_basis)
end

#restore_gender

Restore the battler's property original value



187
188
189
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 187

def restore_gender
  @battle_properties.delete(:gender)
end

#restore_height

Restore the battler's property original value



140
141
142
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 140

def restore_height
  @battle_properties.delete(:height)
end

#restore_nature_id

Restore the battler's property original value



104
105
106
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 104

def restore_nature_id
  @battle_properties.delete(:nature_id)
end

#restore_rareness

Restore the battler's property original value



204
205
206
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 204

def restore_rareness
  @battle_properties.delete(:rareness)
end

#restore_spd_basis

Restore the battler's property original value



87
88
89
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 87

def restore_spd_basis
  @battle_properties.delete(:spd_basis)
end

#restore_type1

Restore the battler's property original value



221
222
223
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 221

def restore_type1
  @battle_properties.delete(:type1)
end

#restore_type2

Restore the battler's property original value



238
239
240
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 238

def restore_type2
  @battle_properties.delete(:type2)
end

#restore_type3

Restore the battler's property original value



255
256
257
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 255

def restore_type3
  @battle_properties.delete(:type3)
end

#restore_types

Restore all Pokemon types



260
261
262
263
264
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 260

def restore_types
  restore_type1
  restore_type2
  restore_type3
end

#restore_weight

Restore the battler's property original value



161
162
163
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 161

def restore_weight
  @battle_properties.delete(:weight)
end

#set_stat_stage(stat_id, value) ⇒ Integer

Set a stat stage

Parameters:

  • stat_id (Integer)

    id of the stat : 0 = atk, 1 = dfe, 2 = spd, 3 = ats, 4 = dfs, 5 = eva, 6 = acc

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



198
199
200
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 198

def set_stat_stage(stat_id, value)
  return @battle_stage[stat_id] = value.clamp(MIN_STAGE, MAX_STAGE)
end

#spdInteger

Return the current spd

Returns:



22
23
24
25
26
27
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 22

def spd
  raw_spd = (spd_basis * spd_modifier).floor
  return @scene.logic.each_effects(self).reduce(raw_spd) do |product, e|
    (product * e.spd_modifier).floor
  end
end

#spd_basisInteger

Return the battler's combat property

Returns:



76
77
78
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 76

def spd_basis
  return @battle_properties[:spd_basis] || super
end

#spd_basis=(value)

Set the battler's combat property

Parameters:



82
83
84
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 82

def spd_basis=(value)
  @battle_properties[:spd_basis] = value
end

#spd_modifierFloat

Return the spd modifier

Returns:

  • (Float)

    the multiplier



55
56
57
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 55

def spd_modifier
  return stat_multiplier_regular(spd_stage)
end

#spd_stageInteger

Return the spd stage

Returns:



85
86
87
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 85

def spd_stage
  return @battle_stage[Configs.stats.spd_stage_index]
end

#spd_stage=(value) ⇒ Integer

Set the spd stage

Parameters:

  • value (Integer)

    the new value of the stat stage

Returns:

  • (Integer)

    the new stat stage value



212
213
214
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 212

def spd_stage=(value)
  return set_stat_stage(Configs.stats.spd_stage_index, value)
end

#stat_multiplier_acceva(stage) ⇒ Float

Return the accuracy related stat multiplier

Parameters:

  • stage (Integer)

    the value of the stage

Returns:

  • (Float)

    the multiplier



127
128
129
130
131
132
133
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 127

def stat_multiplier_acceva(stage)
  if stage >= 0
    return (3 + stage) / 3.0
  else
    return 3.0 / (3 - stage)
  end
end

#stat_multiplier_regular(stage) ⇒ Float

Return the regular stat multiplier

Parameters:

  • stage (Integer)

    the value of the stage

Returns:

  • (Float)

    the multiplier



116
117
118
119
120
121
122
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00300 Statistics.rb', line 116

def stat_multiplier_regular(stage)
  if stage >= 0
    return (2 + stage) / 2.0
  else
    return 2.0 / (2 - stage)
  end
end

#status_confuse(_ = false) ⇒ Boolean

Confuse the Pokemon

Parameters:

  • _ (Boolean) (defaults to: false)

    (ignored)

Returns:

  • (Boolean)

    if the pokemon has been confused



347
348
349
350
351
352
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 347

def status_confuse(_ = false)
  return false if dead? || confused?

  effects.add(Battle::Effects::Confusion.new(@scene.logic, self))
  return true
end

#status_effectBattle::Effects::Status

Get the status effect



29
30
31
32
33
34
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00500 Effects.rb', line 29

def status_effect
  if !@status_effect || @status_effect.status_id != @status
    @status_effect = Battle::Effects::Status.new(@scene.logic, self, Configs.states.symbol(@status))
  end
  return @status_effect
end

#switching?Boolean

if the pokemon is switching during this turn

Returns:

  • (Boolean)


340
341
342
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 340

def switching?
  @switching
end

#to_s Also known as: inspect



157
158
159
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 157

def to_s
  "<PB:#{name},#{@bank},#{@position} lv=#{@level} hp=#{@hp_rate.round(3)} st=#{@status}>"
end

#type1Integer

Return the battler's combat property

Returns:



210
211
212
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 210

def type1
  return @battle_properties[:type1] || super
end

#type1=(value)

Set the battler's combat property

Parameters:



216
217
218
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 216

def type1=(value)
  @battle_properties[:type1] = value
end

#type2Integer

Return the battler's combat property

Returns:



227
228
229
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 227

def type2
  return @battle_properties[:type2] || super
end

#type2=(value)

Set the battler's combat property

Parameters:



233
234
235
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 233

def type2=(value)
  @battle_properties[:type2] = value
end

#typeless?Boolean

Is the Pokemon typeless?

Returns:

  • (Boolean)


401
402
403
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 401

def typeless?
  return type1 == 0 && type2 == 0 && type3 == 0
end

#weightInteger

Return the battler's combat property

Returns:



146
147
148
149
150
151
152
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 146

def weight
  w = @battle_properties[:weight] || super

  w *= 2 if has_ability?(:heavy_metal)
  w /= 2 if has_ability?(:light_metal)
  return w
end

#weight=(value)

Set the battler's combat property

Parameters:



156
157
158
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 156

def weight=(value)
  @battle_properties[:weight] = value
end