54 lines
1.3 KiB
Rust
54 lines
1.3 KiB
Rust
use crate::common_usings::*;
|
|
use crate::pokemon::heal_each_end_of_turn::HealEachEndOfTurnEffect;
|
|
|
|
script!(
|
|
HealEachEndOfTurn,
|
|
"heal_each_end_of_turn",
|
|
heal_percent: AtomicF32
|
|
);
|
|
|
|
impl Script for HealEachEndOfTurn {
|
|
fn new() -> Self {
|
|
Self {
|
|
heal_percent: 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<Rc<EffectParameter>>>,
|
|
) {
|
|
self.heal_percent.store(
|
|
parameters.unwrap().get(0).unwrap().as_float() / 100.0,
|
|
Ordering::SeqCst,
|
|
);
|
|
}
|
|
|
|
fn on_secondary_effect(&self, _mv: ExecutingMove, target: Pokemon, _hit: u8) {
|
|
let script = target.add_volatile_by_name("heal_each_end_of_turn_effect");
|
|
let amount = self.heal_percent.load(Ordering::SeqCst);
|
|
script
|
|
.as_any()
|
|
.downcast_ref::<HealEachEndOfTurnEffect>()
|
|
.unwrap()
|
|
.heal_percent
|
|
.store(amount, Ordering::SeqCst);
|
|
}
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
self
|
|
}
|
|
}
|