Implements flinch effect
This commit is contained in:
parent
156b4e146d
commit
3c8bd5f7c5
|
@ -0,0 +1,54 @@
|
||||||
|
use crate::script;
|
||||||
|
use alloc::boxed::Box;
|
||||||
|
use core::any::Any;
|
||||||
|
use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon};
|
||||||
|
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
target.add_volatile(Box::new(FlinchEffect::new()));
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
*prevent = true;
|
||||||
|
mv.user().remove_volatile(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_any(&self) -> &dyn Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ pub mod change_all_target_stats;
|
||||||
pub mod change_target_stats;
|
pub mod change_target_stats;
|
||||||
pub mod cure_party_status;
|
pub mod cure_party_status;
|
||||||
pub mod drain;
|
pub mod drain;
|
||||||
|
pub mod flinch;
|
||||||
pub mod light_screen;
|
pub mod light_screen;
|
||||||
pub mod multi_hit_move;
|
pub mod multi_hit_move;
|
||||||
pub mod reflect;
|
pub mod reflect;
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub fn get_script(category: ScriptCategory, name: &StringKey) -> Option<Box<dyn
|
||||||
change_target_stats::ChangeTargetSpeed,
|
change_target_stats::ChangeTargetSpeed,
|
||||||
cure_party_status::CurePartyStatus,
|
cure_party_status::CurePartyStatus,
|
||||||
drain::Drain,
|
drain::Drain,
|
||||||
|
flinch::Flinch,
|
||||||
struggle::Struggle,
|
struggle::Struggle,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue