Adds effects for changing target stats.
This commit is contained in:
		
							
								
								
									
										38
									
								
								gen_7_scripts/src/moves/automize.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								gen_7_scripts/src/moves/automize.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | ||||
| use crate::script; | ||||
| use core::any::Any; | ||||
| use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon, Statistic}; | ||||
| use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; | ||||
|  | ||||
| script!(Automize, "automize"); | ||||
|  | ||||
| impl Script for Automize { | ||||
|     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(); | ||||
|         let stats = user.boosted_stats(); | ||||
|         let original_speed = stats.speed(); | ||||
|         let original_weight = user.weight(); | ||||
|         user.change_stat_boost(Statistic::Speed, 2, true); | ||||
|         if user.boosted_stats().speed() != original_speed { | ||||
|             user.set_weight(original_weight - 100.0); | ||||
|             if user.weight() != original_weight { | ||||
|                 // TODO: Became nimble dialog. | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fn as_any(&self) -> &dyn Any { | ||||
|         self | ||||
|     } | ||||
| } | ||||
							
								
								
									
										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 | ||||
|     } | ||||
| } | ||||
							
								
								
									
										74
									
								
								gen_7_scripts/src/moves/change_target_stats.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								gen_7_scripts/src/moves/change_target_stats.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| 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}; | ||||
|  | ||||
| macro_rules! change_stat_effect { | ||||
|     ( | ||||
|         $stat:ident | ||||
|     ) => { | ||||
|         paste::paste! { | ||||
|             pub struct [<ChangeTarget $stat>] { | ||||
|                 amount: AtomicI8, | ||||
|             } | ||||
|  | ||||
|             impl [<ChangeTarget $stat>] { | ||||
|                 pub const fn get_const_name() -> &'static str { | ||||
|                     stringify!([<"change_target_" $stat:snake>]) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             impl Script for [<ChangeTarget $stat>] { | ||||
|                 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) { | ||||
|                     target.change_stat_boost( | ||||
|                         Statistic::$stat, | ||||
|                         self.amount.load(Ordering::SeqCst), | ||||
|                         mv.user() == target, | ||||
|                     ); | ||||
|                 } | ||||
|  | ||||
|                 fn as_any(&self) -> &dyn Any { | ||||
|                     self | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
| } | ||||
|  | ||||
| change_stat_effect!(Attack); | ||||
| change_stat_effect!(Defense); | ||||
| change_stat_effect!(SpecialAttack); | ||||
| change_stat_effect!(SpecialDefense); | ||||
| change_stat_effect!(Speed); | ||||
| @@ -5,6 +5,9 @@ pub mod assist; | ||||
| pub mod assurance; | ||||
| pub mod attract; | ||||
| pub mod aurora_veil; | ||||
| pub mod automize; | ||||
| pub mod change_all_target_stats; | ||||
| pub mod change_target_stats; | ||||
| pub mod light_screen; | ||||
| pub mod multi_hit_move; | ||||
| pub mod reflect; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user