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 @nature
  @ev_hp @ev_atk @ev_dfe @ev_spd @ev_ats @ev_dfs
]
TRANSFORM_BP_METHODS =

List of @battle_properties to copy with transform

%i[
  ability weight height type1 type2 gender shiny
  atk_basis dfe_basis ats_basis dfs_basis spd_basis
  atk_stage dfe_stage ats_stage dfs_stage spd_stage
]
TRANSFORM_SETTER_CACHE =

Setter cache for the Transform properties to write

TRANSFORM_BP_METHODS.to_h { |key| [key, :"#{key}="] }
ILLUSION_COPIED_PROPERTIES =

List of properties to copy with Illusion

%i[
  @id @form @gender @given_name @code @captured_in
]
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
]
MOVES_IGNORING_ABILITIES =

List of moves that ignore abilities

%i[sunsteel_strike moongeist_beam photon_geyser]

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::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_SIZE, PFM::Pokemon::SPECIAL_EVOLUTION_ID, 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, #cramorant_form, #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_toxtricity_amped, #elv_toxtricity_low_key, #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?, missing_resources_error, #modifier_stage, #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, #single_type?, #skill_learnt?, #sleep_check, #status?, #status_burn, #status_frozen, #status_paralyze, #status_poison, #status_sleep, #status_toxic, #swap_skills_index, #third_type?, #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, #zygarde_form

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



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 137

def initialize(original, scene, max_level = Float::INFINITY)
  @original = original
  # @type [PFM::Pokemon]
  @battle_properties = {}
  @transform = @illusion = nil
  @scene = scene
  copy_properties
  copy_moveset
  @battle_stage = Array.new(7, 0)
  reset_states
  @battle_max_level = max_level
  @level = original.level < max_level ? original.level : max_level
  @type3 = 0
  @bank = 0
  @position = -1
  @place_in_party = scene.logic.battle_info.party(self).index(self.original)
  @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 = hp_rate > 0 ? (max_hp * hp_rate).to_i.clamp(1, max_hp) : 0
  initialize_set_is_follower
end

Instance Attribute Details

#bagPFM::Bag

Get the bag of the battler

Returns:



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

def bag
  @bag
end

#bankInteger

Returns Bank where the Pokemon is supposed to be.

Returns:

  • (Integer)

    Bank where the Pokemon is supposed to be



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

def bank
  @bank
end

#battle_itemInteger

Get the item held during battle

Returns:

  • (Integer)


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

def battle_item
  @battle_item
end

#battle_item_dataArray (readonly)

Get the data associated to the item if needed

Returns:

  • (Array)


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

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



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

def consumed_item
  @consumed_item
end

#damage_historyArray<DamageHistory> (readonly)

Get the damage history

Returns:



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

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:



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

def encounter_list
  @encounter_list
end

#exp_distributedBoolean

Tell if the Pokemon already distributed its experience during the battle

Returns:

  • (Boolean)


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

def exp_distributed
  @exp_distributed
end

#illusionPFM::PokemonBattler

Get the Illusion pokemon

Returns:



131
132
133
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 131

def illusion
  @illusion
end

#is_followerBoolean

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

Returns:

  • (Boolean)


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

def is_follower
  @is_follower
end

#item_consumedBoolean

Tell if the Pokemon has its item consumed

Returns:

  • (Boolean)


120
121
122
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 120

def item_consumed
  @item_consumed
end

#last_battle_turnInteger

Last turn the Pokemon fought

Returns:

  • (Integer)


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

def last_battle_turn
  @last_battle_turn
end

#last_hit_by_moveBattle::Move

Returns last move that hit the pokemon.

Returns:



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

def last_hit_by_move
  @last_hit_by_move
end

#last_sent_turnInteger

Last turn the pokemon was sent out

Returns:

  • (Integer)


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

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:



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

def mimic_move
  @mimic_move
end

#move_historyArray<MoveHistory> (readonly)

Get the move history

Returns:



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

def move_history
  @move_history
end

#movesetArray<Battle::Move> (readonly)

Returns the moveset of the Pokemon.

Returns:



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

def moveset
  @moveset
end

#originalPFM::Pokemon (readonly)

Get the original Pokemon

Returns:



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

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



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

def party_id
  @party_id
end

#place_in_partyInteger

Returns Place in the team of the Pokemon.

Returns:

  • (Integer)

    Place in the team of the Pokemon



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

def place_in_party
  @place_in_party
end

#positionInteger

Returns Position of the Pokemon in the bank.

Returns:

  • (Integer)

    Position of the Pokemon in the bank



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

def position
  @position
end

#switching=(value) ⇒ Boolean (writeonly)

Returns set switching state.

Returns:

  • (Boolean)

    set switching state



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

def switching=(value)
  @switching = value
end

#transformPFM::PokemonBattler

Get the transform pokemon

Returns:



127
128
129
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 127

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



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

def turn_count
  @turn_count
end

#type3Integer

Returns 3rd type (Mega / Move effect).

Returns:

  • (Integer)

    3rd type (Mega / Move effect)



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

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:

  • (Integer)


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:

  • value (Integer)


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)


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

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:

  • (Integer)


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:



273
274
275
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 273

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:



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

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:



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

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)


430
431
432
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 430

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



405
406
407
408
409
410
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 405

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:

  • (Integer)


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:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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:

  • (Integer)


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:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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:

  • (Integer)


346
347
348
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 346

def base_hp
  data.base_hp
end

#battle_ability_db_symbolSymbol

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

Returns:

  • (Symbol)


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

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)


219
220
221
222
223
224
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 219

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



314
315
316
317
318
319
320
321
322
323
324
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 314

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) || current_move_ignoring_ability?

  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)


170
171
172
173
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 170

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)


297
298
299
300
301
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 297

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:

  • types (Array<Integer>)


444
445
446
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 444

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

#confused?Boolean

Is the Pokemon confused?

Returns:

  • (Boolean)


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

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

#copy_properties_back_to_original

Copy all the properties back to the original pokemon



351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 351

def copy_properties_back_to_original
  return if @scene.battle_info.max_level

  @battle_properties.clear
  self.transform = nil
  self.illusion = 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

#current_move_ignoring_ability?Boolean

Tell if the Pokémon is using a move ignoring ability

Returns:

  • (Boolean)


330
331
332
333
334
335
336
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 330

def current_move_ignoring_ability?
  return $scene.logic.turn_actions.any? do |a|
    a.is_a?(Battle::Actions::Attack) &&
    Battle::Actions::Attack.from(a).launcher == self &&
    MOVES_IGNORING_ABILITIES.include?(Battle::Actions::Attack.from(a).move.db_symbol)
  end
end

#delete_battler_to_encounter_list(battler)

Delete a battler to the encounter list

Parameters:



279
280
281
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 279

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

#dfeInteger

Return the current dfe

Returns:

  • (Integer)


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:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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:

  • (Integer)


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:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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)


285
286
287
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 285

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

#eva_stageInteger

Return the evasion stage

Returns:

  • (Integer)


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)


180
181
182
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 180

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

#from_player_party?Boolean

Return if the Pokemon is in the player current team @ Return [Boolean]

Returns:

  • (Boolean)


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

def from_player_party?
  @party_id == 0 && @bank == 0
end

#genderInteger

Return the battler's combat property

Returns:

  • (Integer)


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:

  • value (Integer)


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

def gender=(value)
  return log_info("Gender changed to #{value}") && @battle_properties[:gender] = value.clamp(0, 2) if value.is_a?(Integer)
  
  @battle_properties[:gender] = super
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)


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

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

#heightInteger

Return the battler's combat property

Returns:

  • (Integer)


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:

  • value (Integer)


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)


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

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)


229
230
231
232
233
234
235
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 229

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



437
438
439
440
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 437

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)


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

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)


291
292
293
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 291

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



472
473
474
475
476
477
478
479
480
481
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 472

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:



456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 456

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

#nameString

Return the Pokemon name in the Pokedex (using the original)

Returns:



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

def name
  return Studio::Text.get(0,@step_remaining==0 ? (@illusion ? @id : original.id) : 0)
end

#nature_idInteger

Return the battler's combat property

Returns:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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

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

#rareness=(value)

Set the battler's combat property

Parameters:

  • value (Integer)


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

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



367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 367

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
  @ability = original.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



180
181
182
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00200 Properties.rb', line 180

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



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

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



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

def restore_type1
  @battle_properties.delete(:type1)
end

#restore_type2

Restore the battler's property original value



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

def restore_type2
  @battle_properties.delete(:type2)
end

#restore_type3

Restore the battler's property original value



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

def restore_type3
  @battle_properties.delete(:type3)
end

#restore_types

Restore all Pokemon types



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

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:

  • (Integer)


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:

  • (Integer)


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:

  • value (Integer)


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:

  • (Integer)


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



390
391
392
393
394
395
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 390

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)


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

def switching?
  @switching
end

#to_s Also known as: inspect



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

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:

  • (Integer)


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

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

#type1=(value)

Set the battler's combat property

Parameters:

  • value (Integer)


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

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

#type2Integer

Return the battler's combat property

Returns:

  • (Integer)


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

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

#type2=(value)

Set the battler's combat property

Parameters:

  • value (Integer)


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

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

#typeless?Boolean

Is the Pokemon typeless?

Returns:

  • (Boolean)


450
451
452
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 450

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

#weightInteger

Return the battler's combat property

Returns:

  • (Integer)


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:

  • value (Integer)


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