Class: Battle::Logic::BattleEndHandler
- Inherits:
-
ChangeHandlerBase
- Object
- ChangeHandlerBase
- Battle::Logic::BattleEndHandler
- Includes:
- Hooks
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb,
scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandlerConstants.rb
Overview
Handler responsive of handling the end of the battle
Constant Summary collapse
- GrassItem =
List of Items (ID) got with Pickup on Grass
[ [155,151,158,150,152,149, 4, 79,154, 92], [151,158,150,152,149, 4, 79,154, 92, 85], [158, 26, 28, 27, 3, 76,154, 92, 85, 25], [ 26, 28, 27, 3, 76,154, 92, 85, 25, 38], [ 28, 27, 2, 76,154, 92, 85, 25, 38,278], [ 27, 2, 76,154, 28, 85, 24, 38,278,537], [ 2, 76,154, 28, 85, 24, 93,278,537, 40], [ 77,154, 28, 85, 24, 93, 50, 80, 40,537], [154, 28, 2, 24, 93, 50, 80, 40,537,234], [ 28, 2, 23, 93, 50, 80, 40, 51,234,537], [ 2, 23, 93, 50, 80, 40, 51,234, 53,537] ]
- CaveItem =
List of Items (ID) got with Pickup in Cave
[ [ 17, 18, 26, 78, 28, 27, 3, 79, 78, 92], [ 18, 4, 26, 28, 27, 3, 79, 78, 92, 82], [ 4, 26, 28, 27, 3, 76, 78, 92, 82, 25], [ 26, 28, 27, 3, 77, 78, 92, 82, 25, 38], [ 28, 27, 2, 77, 78, 92, 82, 25, 38,278], [ 27, 2, 77, 78, 28, 82, 24, 38,278,537], [ 2, 77, 78, 28, 82, 24, 93,278,537, 40], [ 77, 78, 28, 82, 24, 93, 50, 80, 40,537], [ 78, 28, 2, 24, 93, 50, 80, 40,537,234], [ 28, 2, 23, 93, 50, 80, 40, 51,234,537], [ 2, 23, 93, 50, 80, 40, 51,234, 53,537] ]
- WaterItem =
List of Items (ID) got with Pickup on Water
[ [ 17, 18, 26, 78, 28, 27, 3, 79, 78, 92], [ 18, 4, 26, 28, 27, 3, 79, 78, 92, 84], [ 4, 26, 28, 27, 3, 76, 78, 92, 84, 25], [ 26, 28, 27, 3, 77, 78, 92, 84, 25, 38], [ 28, 27, 2, 77, 78, 92, 84, 25, 38,278], [ 27, 2, 77, 78, 28, 84, 24, 38,278,537], [ 2, 77, 78, 28, 84, 24, 93,278,537, 40], [ 77, 78, 28, 84, 24, 93, 50, 80, 40,537], [ 78, 28, 2, 24, 93, 50, 80, 40,537,234], [ 28, 2, 23, 93, 50, 80, 40, 51,234,537], [ 2, 23, 93, 50, 80, 40, 51,234, 53,537] ]
- CommonItem =
List of Items (ID) got with Pickup on common tiles
[ [ 17, 18, 26, 78, 28, 27, 3, 79, 78, 92], [ 18, 4, 26, 28, 27, 3, 79, 78, 92, 83], [ 4, 26, 28, 27, 3, 76, 78, 92, 83, 25], [ 26, 28, 27, 3, 77, 78, 92, 83, 25, 38], [ 28, 27, 2, 77, 78, 92, 83, 25, 38,278], [ 27, 2, 77, 78, 28, 83, 24, 38,278,537], [ 2, 77, 78, 28, 83, 24, 93,278,537, 40], [ 77, 78, 28, 83, 24, 93, 50, 80, 40,537], [ 78, 28, 2, 24, 93, 50, 80, 40,537,234], [ 28, 2, 23, 93, 50, 80, 40, 51,234,537], [ 2, 23, 93, 50, 80, 40, 51,234, 53,537] ]
Instance Attribute Summary
Attributes inherited from ChangeHandlerBase
Class Method Summary collapse
-
.register(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure.
-
.register_no_defeat(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure when it's not a defeat.
-
.register_nuzlocke(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure when nuzlocke mode is enabled.
Instance Method Summary collapse
-
#pickup_item(pokemon) ⇒ Integer
Get the item to pick up.
-
#player_loose_sequence
Process the loose sequence when the battle doesn't allow defeat.
-
#process
Process the battle end.
Methods included from Hooks
#exec_hooks, #force_return, included, remove, remove_without_name
Methods inherited from ChangeHandlerBase
#initialize, #prevent_change, #process_prevention_reason, #reset_prevention_reason
Constructor Details
This class inherits a constructor from Battle::Logic::ChangeHandlerBase
Class Method Details
.register(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure
81 82 83 84 85 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 81 def register(reason) Hooks.register(BattleEndHandler, :battle_end, reason) do |hook_binding| yield(self, hook_binding.local_variable_get(:players_pokemon)) end end |
.register_no_defeat(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure when it's not a defeat
91 92 93 94 95 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 91 def register_no_defeat(reason) Hooks.register(BattleEndHandler, :battle_end_no_defeat, reason) do |hook_binding| yield(self, hook_binding.local_variable_get(:players_pokemon)) end end |
.register_nuzlocke(reason) {|handler, players_pokemon| ... }
Function that registers a battle end procedure when nuzlocke mode is enabled
101 102 103 104 105 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 101 def register_nuzlocke(reason) Hooks.register(BattleEndHandler, :battle_end_nuzlocke, reason) do |hook_binding| yield(self, hook_binding.local_variable_get(:players_pokemon)) end end |
Instance Method Details
#pickup_item(pokemon) ⇒ Integer
Get the item to pick up
26 27 28 29 30 31 32 33 34 35 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 26 def pickup_item(pokemon) off = (((pokemon.level - 1.0) / Configs.settings.max_level) * 10).to_i # Offset should always depends on the final max level ind = pickup_index(@logic.generic_rng.rand(100)) env = $env return GrassItem[off][ind] if env.tall_grass? || env.grass? return CaveItem[off][ind] if env.cave? || env.mount? return WaterItem[off][ind] if env.sea? || env.pond? return CommonItem[off][ind] end |
#player_loose_sequence
Process the loose sequence when the battle doesn't allow defeat
38 39 40 41 42 43 44 45 46 47 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 38 def player_loose_sequence lost_money = calculate_lost_money variables = { PFM::Text::TRNAME[0] => $trainer.name, PFM::Text::NUMXR => lost_money.to_s } @scene..stay_visible = true @scene.visual.lock do @scene.(parse_text(18, 56, variables)) @scene.(parse_text(18, @scene.battle_info.trainer_battle? ? 58 : 57, variables)) @scene.(parse_text(18, 59, variables)) end end |
#process
Process the battle end
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'scripts/01600 Alpha 25 Battle Engine/00200 Battle_Logic/00001 Handlers/01011 BattleEndHandler.rb', line 8 def process @scene..blocking = true players_pokemon = @logic.all_battlers.select(&:from_party?) players_pokemon.concat($actors) if players_pokemon.empty? $game_temp.battle_can_lose = false if PFM.game_state.nuzlocke.enabled? && !$game_switches[Yuki::Sw::BT_AUTHORIZE_DEFEAT_NUZLOCKE] exec_hooks(BattleEndHandler, :battle_end, binding) exec_hooks(BattleEndHandler, :battle_end_no_defeat, binding) if @logic.battle_result != 2 @logic.all_battlers(&:copy_properties_back_to_original) exec_hooks(BattleEndHandler, :battle_end_nuzlocke, binding) if PFM.game_state.nuzlocke.enabled? unless $scene.is_a?(Yuki::SoftReset) || $scene.is_a?(Scene_Title) $game_system.bgm_play($game_system.) $game_system.bgs_play($game_system.) end end |