Implements struggle.
This commit is contained in:
		| @@ -13,3 +13,4 @@ pub mod drain; | ||||
| pub mod light_screen; | ||||
| pub mod multi_hit_move; | ||||
| pub mod reflect; | ||||
| pub mod struggle; | ||||
|   | ||||
							
								
								
									
										55
									
								
								gen_7_scripts/src/moves/struggle.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								gen_7_scripts/src/moves/struggle.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,55 @@ | ||||
| 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 | ||||
|     } | ||||
|  | ||||
|     fn on_secondary_effect(&self, mv: ExecutingMove, _target: Pokemon, hit: u8) { | ||||
|         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 | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user