Class: Battle::Effects::Confusion

Inherits:
PokemonTiedEffectBase show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb

Overview

Effect describing confusion

Instance Method Summary collapse

Methods inherited from PokemonTiedEffectBase

#on_baton_pass_switch

Methods inherited from EffectBase

#base_power_multiplier, #can_attack_hit_out_of_reach?, #chance_of_hit_multiplier, #counter=, #dead?, #effect_chance_modifier, #force_next_move?, #kill, #mod1_multiplier, #mod2_multiplier, #mod3_multiplier, #on_damage_prevention, #on_delete, #on_end_turn_event, #on_fterrain_prevention, #on_held_item_use_prevention, #on_move_ability_immunity, #on_move_disabled_check, #on_move_prevention_target, #on_move_priority_change, #on_move_type_change, #on_post_accuracy_check, #on_post_action_event, #on_post_damage, #on_post_damage_death, #on_post_fterrain_change, #on_post_item_change, #on_post_status_change, #on_post_weather_change, #on_pre_item_change, #on_single_type_multiplier_overwrite, #on_stat_change, #on_stat_change_post, #on_stat_decrease_prevention, #on_stat_increase_prevention, #on_status_prevention, #on_switch_event, #on_switch_passthrough, #on_switch_prevention, #on_transform_event, #on_two_turn_shortcut, #on_weather_prevention, #out_of_reach?, #rapid_spin_affected?, #sp_atk_multiplier, #sp_def_multiplier, #spd_modifier, #targetted?, #update_counter

Constructor Details

#initialize(logic, pokemon, turn_count = logic.generic_rng.rand(1..4)) ⇒ Confusion

Create a new Pokemon tied effect

Parameters:



9
10
11
12
# File 'scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb', line 9

def initialize(logic, pokemon, turn_count = logic.generic_rng.rand(1..4))
  super(logic, pokemon)
  self.counter = turn_count + 1
end

Instance Method Details

#confuse_damageInteger

Return the amount of damage the Pokemon receive from confusion

Returns:



16
17
18
# File 'scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb', line 16

def confuse_damage
  return ((@pokemon.level * 2 / 5 + 2) * 40 * @pokemon.atk / @pokemon.dfe / 50).floor
end

#damage_chanceFloat

Get the damage chance (between 0 & 1) of the confusion

Returns:

  • (Float)


45
46
47
# File 'scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb', line 45

def damage_chance
  0.5 # 50% in Gen6 and 33% in Gen7
end

#nameSymbol

Get the name of the effect

Returns:

  • (Symbol)


51
52
53
# File 'scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb', line 51

def name
  :confusion
end

#on_move_prevention_user(user, targets, move) ⇒ :prevent?

Function called when we try to use a move as the user (returns :prevent if user fails)

Parameters:

Returns:

  • (:prevent, nil)

    :prevent if the move cannot continue



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'scripts/01600 Alpha 25 Battle Engine/04000 Effects/00500 Move Effects/01000 Confusion.rb', line 25

def on_move_prevention_user(user, targets, move)
  return if dead? || user != @pokemon

  if @counter == 1 # Last turn
    move.scene.display_message_and_wait(parse_text_with_pokemon(19, 351, user))
    kill
  else
    move.scene.visual.show_rmxp_animation(user, 475)
    move.scene.display_message_and_wait(parse_text_with_pokemon(19, 348, user))
    if bchance?(damage_chance)
      move.scene.visual.show_hp_animations([user], [-confuse_damage]) do
        move.scene.display_message_and_wait(parse_text(18, 83))
      end
      return :prevent
    end
  end
end