diff --git a/gen_7_scripts/src/moves/cure_party_status.rs b/gen_7_scripts/src/moves/cure_party_status.rs new file mode 100644 index 0000000..dec69f1 --- /dev/null +++ b/gen_7_scripts/src/moves/cure_party_status.rs @@ -0,0 +1,41 @@ +use crate::script; +use core::any::Any; +use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon}; +use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; + +script!(CurePartyStatus, "cure_party_status"); + +impl Script for CurePartyStatus { + 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 = mv.user(); + user.clear_status(); + let party = user.battle().unwrap().find_party_for_pokemon(&user); + if let Some(party) = party { + let p = party.party(); + for index in 0..p.length() { + let mon = p.get_pokemon(index); + if let Some(mon) = mon { + if mon != user { + mon.clear_status(); + } + } + } + } + } + + fn as_any(&self) -> &dyn Any { + self + } +} diff --git a/gen_7_scripts/src/moves/mod.rs b/gen_7_scripts/src/moves/mod.rs index 516dc0c..d051254 100755 --- a/gen_7_scripts/src/moves/mod.rs +++ b/gen_7_scripts/src/moves/mod.rs @@ -8,6 +8,7 @@ pub mod aurora_veil; pub mod automize; pub mod change_all_target_stats; pub mod change_target_stats; +pub mod cure_party_status; pub mod light_screen; pub mod multi_hit_move; pub mod reflect; diff --git a/gen_7_scripts/src/registered_scripts.rs b/gen_7_scripts/src/registered_scripts.rs index 4210d25..d5e4a6a 100755 --- a/gen_7_scripts/src/registered_scripts.rs +++ b/gen_7_scripts/src/registered_scripts.rs @@ -42,6 +42,7 @@ pub fn get_script(category: ScriptCategory, name: &StringKey) -> Option {} diff --git a/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs b/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs index d37bc1f..5a6d7aa 100755 --- a/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs +++ b/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs @@ -178,6 +178,13 @@ impl Pokemon { } } + #[cfg(not(feature = "mock_data"))] + pub fn clear_status(&self) { + unsafe { + pokemon_clear_status(self.reference()); + } + } + #[cfg(not(feature = "mock_data"))] pub fn battle_side(&self) -> BattleSide { self.battle() @@ -327,6 +334,7 @@ extern "wasm" { fn pokemon_damage(r: ExternRef, damage: u32, source: DamageSource); fn pokemon_heal(r: ExternRef, amount: u32, allow_revive: bool) -> bool; fn pokemon_set_weight(r: ExternRef, weight: f32); + fn pokemon_clear_status(r: ExternRef); fn pokemon_add_volatile_by_name(r: ExternRef, name: *const c_char) -> ScriptPtr; fn pokemon_add_volatile(r: ExternRef, script: ScriptPtr) -> ScriptPtr;