2022-09-10 11:08:44 +00:00
|
|
|
use crate::script;
|
|
|
|
use core::any::Any;
|
|
|
|
use pkmn_lib_interface::app_interface::{DamageSource, ExecutingMove, Pokemon, TurnChoice};
|
|
|
|
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
|
|
|
|
|
|
|
script!(Struggle, "struggle");
|
|
|
|
|
|
|
|
impl Script for Struggle {
|
|
|
|
fn new() -> Self {
|
|
|
|
Self {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
|
|
Self::get_const_name()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
|
|
|
&[
|
|
|
|
ScriptCapabilities::ChangeEffectiveness,
|
|
|
|
ScriptCapabilities::IsInvulnerable,
|
|
|
|
ScriptCapabilities::ChangeNumberOfHits,
|
|
|
|
ScriptCapabilities::OnSecondaryEffect,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn change_effectiveness(
|
|
|
|
&self,
|
|
|
|
_move: ExecutingMove,
|
|
|
|
_target: Pokemon,
|
|
|
|
_hit: u8,
|
|
|
|
effectiveness: &mut f32,
|
|
|
|
) {
|
|
|
|
*effectiveness = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn is_invulnerable(&self, _move: ExecutingMove, _target: Pokemon, invulnerable: &mut bool) {
|
|
|
|
*invulnerable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn change_number_of_hits(&self, _choice: TurnChoice, number_of_hits: &mut u8) {
|
|
|
|
*number_of_hits = 1
|
|
|
|
}
|
|
|
|
|
2022-09-16 09:01:17 +00:00
|
|
|
fn on_secondary_effect(&self, mv: ExecutingMove, _target: Pokemon, _hit: u8) {
|
2022-09-10 11:08:44 +00:00
|
|
|
let mut damage = mv.user().max_health() / 4;
|
|
|
|
if damage == 0 {
|
|
|
|
damage = 1
|
|
|
|
}
|
|
|
|
mv.user().damage(damage, DamageSource::Struggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|