Adds effects for changing target stats.
This commit is contained in:
58
gen_7_scripts/src/moves/change_all_target_stats.rs
Normal file
58
gen_7_scripts/src/moves/change_all_target_stats.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use crate::script;
|
||||
use core::any::Any;
|
||||
use core::sync::atomic::{AtomicI8, Ordering};
|
||||
use pkmn_lib_interface::app_interface::list::ImmutableList;
|
||||
use pkmn_lib_interface::app_interface::{
|
||||
DynamicLibrary, EffectParameter, ExecutingMove, Pokemon, Statistic,
|
||||
};
|
||||
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
|
||||
|
||||
script!(
|
||||
ChangeAllTargetStats,
|
||||
"change_all_target_stats",
|
||||
amount: AtomicI8
|
||||
);
|
||||
|
||||
impl Script for ChangeAllTargetStats {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
amount: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_name(&self) -> &'static str {
|
||||
Self::get_const_name()
|
||||
}
|
||||
|
||||
fn get_capabilities(&self) -> &[ScriptCapabilities] {
|
||||
&[
|
||||
ScriptCapabilities::Initialize,
|
||||
ScriptCapabilities::OnSecondaryEffect,
|
||||
]
|
||||
}
|
||||
|
||||
fn on_initialize(
|
||||
&self,
|
||||
library: &DynamicLibrary,
|
||||
parameters: Option<ImmutableList<EffectParameter>>,
|
||||
) {
|
||||
self.amount.store(
|
||||
parameters.unwrap().get(0).unwrap().as_int() as i8,
|
||||
Ordering::SeqCst,
|
||||
);
|
||||
}
|
||||
|
||||
fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, _hit: u8) {
|
||||
let user = mv.user();
|
||||
let amount = self.amount.load(Ordering::SeqCst);
|
||||
target.change_stat_boost(Statistic::Attack, amount, user == target);
|
||||
target.change_stat_boost(Statistic::Defense, amount, user == target);
|
||||
target.change_stat_boost(Statistic::SpecialAttack, amount, user == target);
|
||||
target.change_stat_boost(Statistic::SpecialDefense, amount, user == target);
|
||||
target.change_stat_boost(Statistic::Speed, amount, user == target);
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user