Implements first few actual move effects.
This commit is contained in:
		
							
								
								
									
										40
									
								
								gen_7_scripts/src/moves/acrobatics.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								gen_7_scripts/src/moves/acrobatics.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon}; | ||||
| use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; | ||||
|  | ||||
| pub struct Acrobatics {} | ||||
|  | ||||
| impl Acrobatics { | ||||
|     pub const fn get_const_name() -> &'static str { | ||||
|         "acrobatics" | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Script for Acrobatics { | ||||
|     fn new() -> Self { | ||||
|         Self {} | ||||
|     } | ||||
|  | ||||
|     fn get_name() -> &'static str { | ||||
|         Self::get_const_name() | ||||
|     } | ||||
|  | ||||
|     fn get_capabilities(&self) -> &[ScriptCapabilities] { | ||||
|         &[ScriptCapabilities::ChangeBasePower] | ||||
|     } | ||||
|  | ||||
|     fn change_base_power( | ||||
|         &self, | ||||
|         mv: ExecutingMove, | ||||
|         _target: Pokemon, | ||||
|         _hit: u8, | ||||
|         base_power: &mut u8, | ||||
|     ) { | ||||
|         if mv.user().held_item().is_none() { | ||||
|             if *base_power >= 128_u8 { | ||||
|                 *base_power = 255 | ||||
|             } else { | ||||
|                 *base_power *= 2; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										35
									
								
								gen_7_scripts/src/moves/acupressure.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								gen_7_scripts/src/moves/acupressure.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| use core::mem::transmute; | ||||
| use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon, Statistic}; | ||||
| use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; | ||||
|  | ||||
| pub struct Acupressure {} | ||||
|  | ||||
| impl Acupressure { | ||||
|     pub const fn get_const_name() -> &'static str { | ||||
|         "acupressure" | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Script for Acupressure { | ||||
|     fn new() -> Self { | ||||
|         Self {} | ||||
|     } | ||||
|  | ||||
|     fn get_name() -> &'static str { | ||||
|         Self::get_const_name() | ||||
|     } | ||||
|  | ||||
|     fn get_capabilities(&self) -> &[ScriptCapabilities] { | ||||
|         &[ScriptCapabilities::OnSecondaryEffect] | ||||
|     } | ||||
|  | ||||
|     fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, hit: u8) { | ||||
|         if target == mv.user() { | ||||
|             mv.get_hit_data(&target, hit).fail(); | ||||
|             return; | ||||
|         } | ||||
|         let rand_stat: Statistic = | ||||
|             unsafe { transmute(target.battle().unwrap().random().get_between(1, 6) as u8) }; | ||||
|         target.change_stat_boost(rand_stat, 2, false); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										35
									
								
								gen_7_scripts/src/moves/after_you.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								gen_7_scripts/src/moves/after_you.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| use pkmn_lib_interface::app_interface::{ExecutingMove, Pokemon}; | ||||
| use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; | ||||
|  | ||||
| pub struct AfterYou {} | ||||
|  | ||||
| impl AfterYou { | ||||
|     pub const fn get_const_name() -> &'static str { | ||||
|         "after_you" | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Script for AfterYou { | ||||
|     fn new() -> Self { | ||||
|         Self {} | ||||
|     } | ||||
|  | ||||
|     fn get_name() -> &'static str { | ||||
|         Self::get_const_name() | ||||
|     } | ||||
|  | ||||
|     fn get_capabilities(&self) -> &[ScriptCapabilities] { | ||||
|         &[ScriptCapabilities::OnSecondaryEffect] | ||||
|     } | ||||
|  | ||||
|     fn on_secondary_effect(&self, mv: ExecutingMove, target: Pokemon, hit: u8) { | ||||
|         if !target | ||||
|             .battle() | ||||
|             .unwrap() | ||||
|             .choice_queue() | ||||
|             .move_pokemon_choice_next(&target) | ||||
|         { | ||||
|             mv.get_hit_data(&target, hit).fail() | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										4
									
								
								gen_7_scripts/src/moves/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								gen_7_scripts/src/moves/mod.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| pub mod acrobatics; | ||||
| pub mod acupressure; | ||||
| pub mod after_you; | ||||
| pub mod multi_hit_move; | ||||
							
								
								
									
										37
									
								
								gen_7_scripts/src/moves/multi_hit_move.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								gen_7_scripts/src/moves/multi_hit_move.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| use pkmn_lib_interface::app_interface::TurnChoice; | ||||
| use pkmn_lib_interface::handling::{Script, ScriptCapabilities}; | ||||
|  | ||||
| pub struct MultiHitMove {} | ||||
|  | ||||
| impl MultiHitMove { | ||||
|     pub const fn get_const_name() -> &'static str { | ||||
|         "2_5_hit_move" | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Script for MultiHitMove { | ||||
|     fn new() -> Self { | ||||
|         Self {} | ||||
|     } | ||||
|  | ||||
|     fn get_name() -> &'static str { | ||||
|         Self::get_const_name() | ||||
|     } | ||||
|  | ||||
|     fn get_capabilities(&self) -> &[ScriptCapabilities] { | ||||
|         &[ScriptCapabilities::ChangeNumberOfHits] | ||||
|     } | ||||
|  | ||||
|     fn change_number_of_hits(&self, choice: TurnChoice, number_of_hits: &mut u8) { | ||||
|         // 35% chance that it will hit 2 times, a 35% chance it will hit 3 times, a 15% chance it | ||||
|         // will hit 4 times, and a 15% chance it will hit 5 times. | ||||
|         let rand_value = choice.user().battle().unwrap().random().get_between(0, 100); | ||||
|         *number_of_hits = match rand_value { | ||||
|             0..=34 => 2, | ||||
|             35..=69 => 3, | ||||
|             70..=84 => 4, | ||||
|             85..=100 => 5, | ||||
|             _ => *number_of_hits, | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user