Class: PFM::PokemonBattler
- 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
-
#bag ⇒ PFM::Bag
Get the bag of the battler.
-
#bank ⇒ Integer
Bank where the Pokemon is supposed to be.
-
#battle_item ⇒ Integer
Get the item held during battle.
-
#battle_item_data ⇒ Array
readonly
Get the data associated to the item if needed.
-
#consumed_item ⇒ Symbol
The symbol of the consumed item.
-
#damage_history ⇒ Array<DamageHistory>
readonly
Get the damage history.
-
#effects ⇒ Battle::Effects::EffectsHandler
readonly
Get the effect hanndler.
-
#encounter_list ⇒ Array<PFM::PokemonBattler>
readonly
Get the encounter list.
-
#exp_distributed ⇒ Boolean
Tell if the Pokemon already distributed its experience during the battle.
-
#illusion ⇒ PFM::PokemonBattler
Get the Illusion pokemon.
-
#is_follower ⇒ Boolean
Get the information if the Pokemon is actually a follower or not (changing its go-in-out animation).
-
#item_consumed ⇒ Boolean
Tell if the Pokemon has its item consumed.
-
#last_battle_turn ⇒ Integer
Last turn the Pokemon fought.
-
#last_hit_by_move ⇒ Battle::Move
Last move that hit the pokemon.
-
#last_sent_turn ⇒ Integer
Last turn the pokemon was sent out.
-
#mimic_move ⇒ Array<Battle::Move, Integer>
Mimic move that was replace by another move with its index.
-
#move_history ⇒ Array<MoveHistory>
readonly
Get the move history.
-
#moveset ⇒ Array<Battle::Move>
readonly
The moveset of the Pokemon.
-
#original ⇒ PFM::Pokemon
readonly
Get the original Pokemon.
-
#party_id ⇒ Integer
The ID of the party that control the Pokemon in the bank.
-
#place_in_party ⇒ Integer
Place in the team of the Pokemon.
-
#position ⇒ Integer
Position of the Pokemon in the bank.
-
#switching ⇒ Boolean
writeonly
Set switching state.
-
#transform ⇒ PFM::PokemonBattler
Get the transform pokemon.
-
#turn_count ⇒ Integer
(also: #battle_turns)
Number of turn the Pokemon is in battle.
-
#type3 ⇒ Integer
3rd type (Mega / Move effect).
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
-
.register_force_flying_hook(reason) {|pokemon, scene| ... }
Register a hook forcing Pokemon to be flying (ie not grounded).
-
.register_force_grounded_hook(reason) {|pokemon, scene| ... }
Register a hook forcing Pokemon to be grounded.
Instance Method Summary collapse
-
#ability ⇒ Integer
Return the battler's combat property.
-
#ability=(value)
Set the battler's combat property.
-
#ability_db_symbol ⇒ Symbol
Return the db_symbol of the current ability of the Pokemon.
-
#ability_effect ⇒ Battle::Effects::Ability
Get the ability effect.
-
#acc_stage ⇒ Integer
Return the accuracy stage.
-
#acc_stage=(value) ⇒ Integer
Set the acc stage.
-
#add_battler_to_encounter_list(battler)
Add a battler to the encounter list.
-
#add_damage_to_history(damage, launcher, move, ko)
Add a damage to the damage history.
-
#add_move_to_history(move, targets)
Add a move to the move history.
-
#affected_by_terrain? ⇒ Boolean
Is the pokemon affected by the terrain ?.
-
#apply_flinch(forced = false)
Apply the flinch effect.
-
#atk ⇒ Integer
Return the current atk.
-
#atk_basis ⇒ Integer
Return the battler's combat property.
-
#atk_basis=(value)
Set the battler's combat property.
-
#atk_modifier ⇒ Float
Return the atk modifier.
-
#atk_stage ⇒ Integer
Return the atk stage.
-
#atk_stage=(value) ⇒ Integer
Set the atk stage.
-
#ats ⇒ Integer
Return the current ats.
-
#ats_basis ⇒ Integer
Return the battler's combat property.
-
#ats_basis=(value)
Set the battler's combat property.
-
#ats_modifier ⇒ Float
Return the ats modifier.
-
#ats_stage ⇒ Integer
Return the ats stage.
-
#ats_stage=(value) ⇒ Integer
Set the ats stage.
-
#base_hp ⇒ Integer
Return the base HP.
-
#battle_ability_db_symbol ⇒ Symbol
Return the db_symbol of the current ability of the Pokemon for battle.
-
#battle_item_db_symbol ⇒ Symbol
Get the item for battle.
-
#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).
-
#can_fight? ⇒ Boolean
Is the Pokemon able to fight ?.
-
#can_move? ⇒ Boolean
Test if the Pokemon can use a move.
-
#change_acc(amount) ⇒ Integer
Change the acc stage.
-
#change_atk(amount) ⇒ Integer
Change the atk stage.
-
#change_ats(amount) ⇒ Integer
Change the ats stage.
-
#change_dfe(amount) ⇒ Integer
Change the dfe stage.
-
#change_dfs(amount) ⇒ Integer
Change the dfs stage.
-
#change_eva(amount) ⇒ Integer
Change the eva stage.
-
#change_spd(amount) ⇒ Integer
Change the spd stage.
-
#change_stat(stat_id, amount) ⇒ Integer
Change a stat stage.
-
#change_types(*types)
Change the type of the pokemons.
-
#confused? ⇒ Boolean
Is the Pokemon confused?.
-
#copy_properties_back_to_original
Copy all the properties back to the original pokemon.
-
#current_move_ignoring_ability? ⇒ Boolean
Tell if the Pokémon is using a move ignoring ability.
-
#delete_battler_to_encounter_list(battler)
Delete a battler to the encounter list.
-
#dfe ⇒ Integer
Return the current dfe.
-
#dfe_basis ⇒ Integer
Return the battler's combat property.
-
#dfe_basis=(value)
Set the battler's combat property.
-
#dfe_modifier ⇒ Float
Return the dfe modifier.
-
#dfe_stage ⇒ Integer
Return the dfe stage.
-
#dfe_stage=(value) ⇒ Integer
Set the dfe stage.
-
#dfs ⇒ Integer
Return the current dfs.
-
#dfs_basis ⇒ Integer
Return the battler's combat property.
-
#dfs_basis=(value)
Set the battler's combat property.
-
#dfs_modifier ⇒ Float
Return the dfs modifier.
-
#dfs_stage ⇒ Integer
Return the dfs stage.
-
#dfs_stage=(value) ⇒ Integer
Set the dfs stage.
-
#encountered?(battler) ⇒ Boolean
Test if the Pokemon has encountered the battler.
-
#eva_stage ⇒ Integer
Return the evasion stage.
-
#eva_stage=(value) ⇒ Integer
Set the eva stage.
-
#evaluate_effects(yielder)
Evaluate all the effects related to this Pokemon.
- #from_party? ⇒ Boolean
-
#from_player_party? ⇒ Boolean
Return if the Pokemon is in the player current team @ Return [Boolean].
-
#gender ⇒ Integer
Return the battler's combat property.
-
#gender=(value)
Set the battler's combat property.
-
#grounded? ⇒ Boolean
Check if the pokemon is grounded.
-
#has_ability?(db_symbol) ⇒ Boolean
Tell if the pokemon has an ability.
-
#height ⇒ Integer
Return the battler's combat property.
-
#height=(value)
Set the battler's combat property.
-
#hold_berry?(db_symbol) ⇒ Boolean
Tell if the pokemon hold a berry.
-
#hold_item?(db_symbol) ⇒ Boolean
Tell if the pokemon hold an item.
-
#ignore_types(*types, default: data_type(:normal).id)
Neutralize a type on the Pokemon.
-
#initialize(original, scene, max_level = Float::INFINITY) ⇒ PokemonBattler
constructor
Create a new PokemonBattler from a Pokemon.
-
#item_db_symbol ⇒ Symbol
Return the db_symbol of the current item the Pokemon is holding.
-
#item_effect ⇒ Battle::Effects::Item
Get the item effect.
-
#last_successfull_move_is?(db_symbol) ⇒ Boolean
Test if the last move was of a certain symbol.
-
#level_up_copy
Copy some important data upon level up.
-
#level_up_copy_moveset(moveset_before)
Copy the moveset upon level up.
-
#name ⇒ String
Return the Pokemon name in the Pokedex (using the original).
-
#nature_id ⇒ Integer
Return the battler's combat property.
-
#nature_id=(value)
Set the battler's combat property.
-
#rareness ⇒ Integer
Return the Pokemon rareness.
-
#rareness=(value)
Set the battler's combat property.
-
#reset_states
Function that resets everything from the pokemon once it got switched out of battle.
-
#restore_ability
Restore the battler's property original value.
-
#restore_atk_basis
Restore the battler's property original value.
-
#restore_ats_basis
Restore the battler's property original value.
-
#restore_dfe_basis
Restore the battler's property original value.
-
#restore_dfs_basis
Restore the battler's property original value.
-
#restore_gender
Restore the battler's property original value.
-
#restore_height
Restore the battler's property original value.
-
#restore_nature_id
Restore the battler's property original value.
-
#restore_rareness
Restore the battler's property original value.
-
#restore_spd_basis
Restore the battler's property original value.
-
#restore_type1
Restore the battler's property original value.
-
#restore_type2
Restore the battler's property original value.
-
#restore_type3
Restore the battler's property original value.
-
#restore_types
Restore all Pokemon types.
-
#restore_weight
Restore the battler's property original value.
-
#set_stat_stage(stat_id, value) ⇒ Integer
Set a stat stage.
-
#spd ⇒ Integer
Return the current spd.
-
#spd_basis ⇒ Integer
Return the battler's combat property.
-
#spd_basis=(value)
Set the battler's combat property.
-
#spd_modifier ⇒ Float
Return the spd modifier.
-
#spd_stage ⇒ Integer
Return the spd stage.
-
#spd_stage=(value) ⇒ Integer
Set the spd stage.
-
#stat_multiplier_acceva(stage) ⇒ Float
Return the accuracy related stat multiplier.
-
#stat_multiplier_regular(stage) ⇒ Float
Return the regular stat multiplier.
-
#status_confuse(_ = false) ⇒ Boolean
Confuse the Pokemon.
-
#status_effect ⇒ Battle::Effects::Status
Get the status effect.
-
#switching? ⇒ Boolean
if the pokemon is switching during this turn.
- #to_s (also: #inspect)
-
#type1 ⇒ Integer
Return the battler's combat property.
-
#type1=(value)
Set the battler's combat property.
-
#type2 ⇒ Integer
Return the battler's combat property.
-
#type2=(value)
Set the battler's combat property.
-
#typeless? ⇒ Boolean
Is the Pokemon typeless?.
-
#weight ⇒ Integer
Return the battler's combat property.
-
#weight=(value)
Set the battler's combat property.
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
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
#bag ⇒ PFM::Bag
Get the bag of the battler
97 98 99 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 97 def bag @bag end |
#bank ⇒ Integer
Returns 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_item ⇒ Integer
Get the item held during battle
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_data ⇒ Array (readonly)
Get the data associated to the item if needed
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_item ⇒ Symbol
Returns 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_history ⇒ Array<DamageHistory> (readonly)
Get the damage history
85 86 87 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 85 def damage_history @damage_history end |
#effects ⇒ Battle::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_list ⇒ Array<PFM::PokemonBattler> (readonly)
Get the encounter list
89 90 91 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 89 def encounter_list @encounter_list end |
#exp_distributed ⇒ Boolean
Tell if the Pokemon already distributed its experience during the battle
101 102 103 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 101 def exp_distributed @exp_distributed end |
#illusion ⇒ PFM::PokemonBattler
Get the Illusion pokemon
131 132 133 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 131 def illusion @illusion end |
#is_follower ⇒ Boolean
Get the information if the Pokemon is actually a follower or not (changing its go-in-out animation)
93 94 95 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 93 def is_follower @is_follower end |
#item_consumed ⇒ Boolean
Tell if the Pokemon has its item consumed
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_turn ⇒ Integer
Last turn the Pokemon fought
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_move ⇒ Battle::Move
Returns last move that hit the pokemon.
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_turn ⇒ Integer
Last turn the pokemon was sent out
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_move ⇒ Array<Battle::Move, Integer>
Mimic move that was replace by another move with its index
116 117 118 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 116 def mimic_move @mimic_move end |
#move_history ⇒ Array<MoveHistory> (readonly)
Get the move history
81 82 83 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 81 def move_history @move_history end |
#moveset ⇒ Array<Battle::Move> (readonly)
Returns the moveset of the Pokemon.
43 44 45 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 43 def moveset @moveset end |
#original ⇒ PFM::Pokemon (readonly)
Get the original Pokemon
77 78 79 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 77 def original @original end |
#party_id ⇒ Integer
Returns 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_party ⇒ Integer
Returns 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 |
#position ⇒ Integer
Returns 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.
112 113 114 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 112 def switching=(value) @switching = value end |
#transform ⇒ PFM::PokemonBattler
Get the transform pokemon
127 128 129 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00100 PokemonBattler.rb', line 127 def transform @transform end |
#turn_count ⇒ Integer Also known as: battle_turns
Returns 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 |
#type3 ⇒ Integer
Returns 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)
32 33 34 35 36 |
# File 'scripts/01600 Alpha 25 Battle Engine/00100 PokemonBattler/00400 Grounded.rb', line 32 def (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
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
#ability ⇒ Integer
Return the battler's combat property
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
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_symbol ⇒ Symbol
Return the db_symbol of the current ability of the Pokemon
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_effect ⇒ Battle::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_stage ⇒ Integer
Return the accuracy stage
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
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)
The battler is not added if it is already present in the list
Add a battler to the encounter list
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)
This method should only be used for sucessfull damages!!!
Add a damage to the damage history
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)
This method should only be used for sucessfull moves!!!
Add a move to the move history
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 ?
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
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 |
#atk ⇒ Integer
Return the current atk
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_basis ⇒ Integer
Return the battler's combat property
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
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_modifier ⇒ Float
Return the atk modifier
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_stage ⇒ Integer
Return the atk stage
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
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 |
#ats ⇒ Integer
Return the current ats
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_basis ⇒ Integer
Return the battler's combat property
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
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_modifier ⇒ Float
Return the ats modifier
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_stage ⇒ Integer
Return the ats stage
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
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_hp ⇒ Integer
Return the base HP
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_symbol ⇒ Symbol
Return the db_symbol of the current ability of the Pokemon for battle
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_symbol ⇒ Symbol
Get the item for battle
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
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 ?
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
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
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
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
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
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
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
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
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
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
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?
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
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
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 |
#dfe ⇒ Integer
Return the current dfe
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_basis ⇒ Integer
Return the battler's combat property
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
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_modifier ⇒ Float
Return the dfe modifier
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_stage ⇒ Integer
Return the dfe stage
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
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 |
#dfs ⇒ Integer
Return the current dfs
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_basis ⇒ Integer
Return the battler's combat property
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
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_modifier ⇒ Float
Return the dfs modifier
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_stage ⇒ Integer
Return the dfs stage
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
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
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_stage ⇒ Integer
Return the evasion stage
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
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
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
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]
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 |
#gender ⇒ Integer
Return the battler's combat property
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
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
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
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 |
#height ⇒ Integer
Return the battler's combat property
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
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
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
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
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_symbol ⇒ Symbol
Return the db_symbol of the current item the Pokemon is holding
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_effect ⇒ Battle::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
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
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 |
#name ⇒ String
Return the Pokemon name in the Pokedex (using the original)
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_id ⇒ Integer
Return the battler's combat property
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
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 |
#rareness ⇒ Integer
Return the Pokemon rareness
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
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
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 |
#spd ⇒ Integer
Return the current spd
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_basis ⇒ Integer
Return the battler's combat property
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
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_modifier ⇒ Float
Return the spd modifier
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_stage ⇒ Integer
Return the spd stage
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
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
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
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
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_effect ⇒ Battle::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
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 |
#type1 ⇒ Integer
Return the battler's combat property
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
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 |
#type2 ⇒ Integer
Return the battler's combat property
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
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?
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 |
#weight ⇒ Integer
Return the battler's combat property
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
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 |