2023-01-28 12:59:54 +00:00
|
|
|
use crate::common_usings::*;
|
2022-09-10 08:29:00 +00:00
|
|
|
use crate::pokemon::infatuated::Infatuated;
|
|
|
|
|
|
|
|
script!(Attract, "attract");
|
|
|
|
|
|
|
|
impl Script for Attract {
|
|
|
|
fn new() -> Self {
|
|
|
|
Self {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
|
|
Self::get_const_name()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
|
|
|
&[ScriptCapabilities::OnSecondaryEffect]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, hit: u8) {
|
|
|
|
let user_gender = mv.user().gender();
|
|
|
|
let target_gender = target.gender();
|
|
|
|
// If the move is used on a Pokémon that is the same gender as the user, it will fail
|
|
|
|
if target_gender == user_gender {
|
|
|
|
return mv.get_hit_data(&target, hit).fail();
|
|
|
|
}
|
|
|
|
// It will also fail if used by or on a gender-unknown Pokémon
|
|
|
|
if user_gender == Gender::Genderless || target_gender == Gender::Genderless {
|
|
|
|
return mv.get_hit_data(&target, hit).fail();
|
|
|
|
}
|
|
|
|
// If the target is the opposite gender of the Pokémon who launched the move, the target becomes infatuated
|
|
|
|
target.add_volatile_by_name(Infatuated::get_const_name());
|
|
|
|
}
|
|
|
|
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|