58 lines
1.1 KiB
Rust
58 lines
1.1 KiB
Rust
use crate::common_usings::*;
|
|
|
|
script!(Flinch, "flinch");
|
|
|
|
impl Script for Flinch {
|
|
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,
|
|
_move: ExecutingMove,
|
|
target: Pokemon,
|
|
_hit: u8,
|
|
) -> PkmnResult<()> {
|
|
target.add_volatile(Box::new(FlinchEffect::new()))?;
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|
|
|
|
script!(FlinchEffect, "flinch_effect");
|
|
|
|
impl Script for FlinchEffect {
|
|
fn new() -> Self {
|
|
Self {}
|
|
}
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
Self::get_const_name()
|
|
}
|
|
|
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
|
&[ScriptCapabilities::PreventMove]
|
|
}
|
|
|
|
fn prevent_move(&self, mv: ExecutingMove, prevent: &mut bool) -> PkmnResult<()> {
|
|
*prevent = true;
|
|
mv.user().remove_volatile(self)?;
|
|
Ok(())
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|