48 lines
1.2 KiB
Rust
48 lines
1.2 KiB
Rust
use crate::common_usings::*;
|
|
use crate::side::aurora_veil_effect::AuroraVeilEffect;
|
|
use crate::weather::hail::Hail;
|
|
use pkmn_lib_interface::PkmnResult;
|
|
|
|
script!(AuroraVeil, "aurora_veil");
|
|
|
|
impl Script for AuroraVeil {
|
|
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) -> PkmnResult<()> {
|
|
if target
|
|
.battle()?
|
|
.unwrap()
|
|
.has_weather(Hail::get_const_name())?
|
|
{
|
|
mv.get_hit_data(&target, hit)?.fail()?;
|
|
return Ok(());
|
|
}
|
|
let binding = target.battle_side()?;
|
|
let script = binding
|
|
.add_volatile(Box::new(AuroraVeilEffect::new()))?
|
|
.as_any()
|
|
.downcast_ref::<AuroraVeilEffect>()
|
|
.unwrap();
|
|
if mv.user().has_held_item("light_clay")? {
|
|
script.turns.store(8, Ordering::SeqCst);
|
|
} else {
|
|
script.turns.store(5, Ordering::SeqCst);
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|