Implements CurePartyStatus

This commit is contained in:
Deukhoofd 2022-09-10 12:41:33 +02:00
parent 0f85f4f0a4
commit 19706c4c3c
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 51 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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;

View File

@ -42,6 +42,7 @@ pub fn get_script(category: ScriptCategory, name: &StringKey) -> Option<Box<dyn
change_target_stats::ChangeTargetSpecialAttack,
change_target_stats::ChangeTargetSpecialDefense,
change_target_stats::ChangeTargetSpeed,
cure_party_status::CurePartyStatus,
);
}
ScriptCategory::Ability => {}

View File

@ -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<Pokemon>, damage: u32, source: DamageSource);
fn pokemon_heal(r: ExternRef<Pokemon>, amount: u32, allow_revive: bool) -> bool;
fn pokemon_set_weight(r: ExternRef<Pokemon>, weight: f32);
fn pokemon_clear_status(r: ExternRef<Pokemon>);
fn pokemon_add_volatile_by_name(r: ExternRef<Pokemon>, name: *const c_char) -> ScriptPtr;
fn pokemon_add_volatile(r: ExternRef<Pokemon>, script: ScriptPtr) -> ScriptPtr;