1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-14 02:16:10 +00:00

Shield Tilt & Refactor Training Checks (#150)

* Rename Module

left_stick => air_dodge_direction

* Extract Method

Added shared hook that is called once per frame per fighter

* Refactor Training Mode Checks

Moved checks to skyline hook

* Add Reset Module

Unlink SDI from mash toggle

* Add Shield Tilt Toggle

* Version +

* Fix Rumble

* Remove Debugging Code
This commit is contained in:
sidschingis 2020-08-28 01:35:38 +02:00 committed by GitHub
parent 7d153da81c
commit 4753258874
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 361 additions and 329 deletions

View file

@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
APP_TITLE := Training Modpack
APP_VERSION := 2.5.1Beta
APP_VERSION := 2.5.2Beta
TARGET := ovlTrainingModpack
BUILD := build

View file

@ -66,16 +66,10 @@ during hitlag.
)"""";
// Left Stick
const std::string left_stick_help = R""""(
Specified Direction
CPUs left stick will be
in the direction specified
const std::string air_dodge_direction_help = R""""(
Air Dodge Direction
(relative to the player's facing
position).
Currently only used for
- Airdodge
)"""";
// Ledge Option
@ -178,25 +172,6 @@ The option will be random
among the selected options.
)"""";
// Shield States
#define SHIELD_INFINITE 1
#define SHIELD_HOLD 2
const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
const std::string shield_help = R""""(
Use these toggles in conjunction
with Mash toggles to practice
moves on shield.
Infinite
CPUs will hold a shield that does
not deteriorate over time or
by damage.
Hold
CPUs will hold a normal shield.
This shield will not deteriorate
until hit once.)"""";
// Hitbox visualization
const std::string hitbox_help = R""""(
Currently, hitboxes and
@ -232,6 +207,25 @@ use on the first boot after
upgrading Training Modpack
versions.)"""";
// Shield States
#define SHIELD_INFINITE 1
#define SHIELD_HOLD 2
const std::vector<std::string> shield_items{"None", "Infinite", "Hold"};
const std::string shield_help = R""""(
Use these toggles in conjunction
with Mash toggles to practice
moves on shield.
Infinite
CPUs will hold a shield that does
not deteriorate over time or
by damage.
Hold
CPUs will hold a normal shield.
This shield will not deteriorate
until hit once.)"""";
// OOS
const std::string oos_help = R""""(
Option to delay oos options
@ -249,6 +243,10 @@ in frames.
Used to delay OOS Options.)"""";
const std::string shield_tilt_help = R""""(
Shield Tilt Direction
)"""";
// Mash in neutral
const std::string mash_neutral_help = R""""(
Force mash options to

View file

@ -12,7 +12,7 @@ static struct TrainingModpackMenu
OnOffFlags HITBOX_VIS = OnOffFlag::On;
Directions DI_STATE = Directions::None;
Directions SDI_STATE = Directions::None;
Directions LEFT_STICK = Directions::None;
Directions AIR_DODGE_DIR = Directions::None;
ActionFlags MASH_STATE = ActionFlags::None;
ActionFlags FOLLOW_UP = ActionFlags::None;
LedgeFlags LEDGE_STATE = LedgeFlags::All;
@ -22,6 +22,7 @@ static struct TrainingModpackMenu
DefensiveFlags DEFENSIVE_STATE = DefensiveFlags::All;
DelayFlags OOS_OFFSET = DelayFlags::None;
DelayFlags REACTION_TIME = DelayFlags::None;
Directions SHIELD_TILT = Directions::None;
OnOffFlags MASH_IN_NEUTRAL = OnOffFlags::None;
BoolFlags FAST_FALL = BoolFlags::None;
DelayFlags FAST_FALL_DELAY = DelayFlags::None;
@ -388,7 +389,7 @@ tsl::elm::Element* GuiMain::createUI()
list->addItem(createBitFlagOption(&menu.DI_STATE, "Set DI", di_help, this));
list->addItem(createBitFlagOption(&menu.SDI_STATE, "Set SDI", sdi_help, this));
list->addItem(createBitFlagOption(&menu.LEFT_STICK, "Airdodge Direction", left_stick_help, this));
list->addItem(createBitFlagOption(&menu.AIR_DODGE_DIR, "Airdodge Direction", air_dodge_direction_help, this));
list->addItem(new tsl::elm::CategoryHeader("Shield", true));
@ -416,6 +417,7 @@ tsl::elm::Element* GuiMain::createUI()
list->addItem(createBitFlagOption(&menu.OOS_OFFSET, "OOS Offset", oos_help, this));
list->addItem(createBitFlagOption(&menu.REACTION_TIME, "Reaction Time", reaction_time_help, this));
list->addItem(createBitFlagOption(&menu.SHIELD_TILT, "Shield Tilt", shield_tilt_help, this));
list->addItem(new tsl::elm::CategoryHeader("Chase", true));

View file

@ -296,7 +296,7 @@ pub struct TrainingModpackMenu {
pub hitbox_vis: HitboxVisualization,
pub di_state: Direction,
pub sdi_state: Direction,
pub left_stick: Direction, // Currently only used for air dodge direction
pub air_dodge_dir: Direction,
pub mash_state: Action,
pub follow_up: Action,
pub ledge_state: LedgeOption,
@ -306,6 +306,7 @@ pub struct TrainingModpackMenu {
pub defensive_state: Defensive,
pub oos_offset: Delay,
pub reaction_time: Delay,
pub shield_tilt: Direction,
pub mash_in_neutral: OnOff,
pub fast_fall: BoolFlag,
pub fast_fall_delay: Delay,

View file

@ -9,7 +9,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
hitbox_vis: HitboxVisualization::On,
di_state: Direction::empty(),
sdi_state: Direction::empty(),
left_stick: Direction::empty(),
air_dodge_dir: Direction::empty(),
mash_state: Action::empty(),
follow_up: Action::empty(),
ledge_state: LedgeOption::all(),
@ -18,6 +18,7 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
shield_state: Shield::None,
defensive_state: Defensive::all(),
oos_offset: Delay::empty(),
shield_tilt: Direction::empty(),
reaction_time: Delay::empty(),
mash_in_neutral: OnOff::Off,
fast_fall: BoolFlag::empty(),

View file

@ -108,7 +108,8 @@ pub unsafe fn generate_hitbox_effects(
z: 0.0,
};
if false { // is_fighter(module_accessor) {
if false {
// is_fighter(module_accessor) {
EffectModule::req_on_joint(
module_accessor,
Hash40::new("sys_shield"),
@ -154,19 +155,7 @@ pub unsafe fn generate_hitbox_effects(
}
}
pub unsafe fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
if !is_training_mode() {
return;
}
// apply only once per frame
if category != 0 {
return;
}
pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
// Resume Effect AnimCMD incase we don't display hitboxes
MotionAnimcmdModule::set_sleep_effect(module_accessor, false);
@ -222,15 +211,14 @@ pub unsafe fn get_command_flag_cat(
// Necessary to ensure we visualize on the first frame of the hitbox
#[skyline::hook(replace = sv_animcmd::ATTACK)]
unsafe fn handle_attack(lua_state: u64) {
mod_handle_attack(lua_state);
if is_training_mode() {
mod_handle_attack(lua_state);
}
original!()(lua_state);
}
unsafe fn mod_handle_attack(lua_state: u64) {
if !is_training_mode() {
return;
}
let mut l2c_agent = L2CAgent::new(lua_state);
// hacky way of forcing no shield damage on all hitboxes
@ -283,15 +271,14 @@ unsafe fn mod_handle_attack(lua_state: u64) {
#[skyline::hook(replace = sv_animcmd::CATCH)]
unsafe fn handle_catch(lua_state: u64) {
mod_handle_catch(lua_state);
if is_training_mode() {
mod_handle_catch(lua_state);
}
original!()(lua_state);
}
unsafe fn mod_handle_catch(lua_state: u64) {
if !is_training_mode() {
return;
}
if MENU.hitbox_vis == HitboxVisualization::Off {
return;
}
@ -327,7 +314,10 @@ pub unsafe fn handle_set_rebound(
module_accessor: *mut app::BattleObjectModuleAccessor,
rebound: bool,
) {
mod_handle_handle_set_rebound(module_accessor, rebound);
if is_training_mode() {
mod_handle_handle_set_rebound(module_accessor, rebound);
}
original!()(module_accessor, rebound);
}
@ -335,10 +325,6 @@ unsafe fn mod_handle_handle_set_rebound(
module_accessor: *mut app::BattleObjectModuleAccessor,
rebound: bool,
) {
if !is_training_mode() {
return;
}
if rebound != false {
return;
}

View file

@ -31,10 +31,6 @@ pub unsafe fn mod_get_stick_y(
}
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 {
if !is_training_mode() {
return ANGLE_NONE;
}
if !is_operation_cpu(module_accessor) {
return ANGLE_NONE;
}
@ -44,15 +40,13 @@ unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f6
return ANGLE_NONE;
}
STICK_DIRECTION = MENU.left_stick.get_random();
STICK_DIRECTION = MENU.air_dodge_dir.get_random();
let mut angle: f64 = STICK_DIRECTION.into_angle();
if angle == ANGLE_NONE {
return ANGLE_NONE;
}
// TODO: if left_stick is used for something other than
// directional airdodge, this may not make sense.
let launch_speed_x = KineticEnergy::get_speed_x(KineticModule::get_energy(
module_accessor,
*FIGHTER_KINETIC_ENERGY_ID_DAMAGE,

View file

@ -40,7 +40,7 @@ macro_rules! actionable_statuses {
unsafe fn is_actionable(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool {
actionable_statuses!().iter().any(
|actionable_transition|
|actionable_transition|
WorkModule::is_enable_transition_term(module_accessor, **actionable_transition))
|| CancelModule::is_enable_cancel(module_accessor)
}
@ -61,7 +61,7 @@ pub unsafe fn is_enable_transition_term(
// This is in the case that the transition term becomes enabled after our initial check
// and the user buffers that action on that frame.
if !PLAYER_ACTIONABLE &&
if !PLAYER_ACTIONABLE &&
(
(is && actionable_statuses!().iter().any(|actionable_transition| *actionable_transition == transition_term))
||
@ -69,7 +69,7 @@ pub unsafe fn is_enable_transition_term(
) {
PLAYER_ACTIVE_FRAME = frame_counter::get_frame_count(FRAME_COUNTER_INDEX);
PLAYER_ACTIONABLE = true;
// if both are now active
if PLAYER_ACTIONABLE && CPU_ACTIONABLE {
if FRAME_ADVANTAGE_CHECK {
@ -87,16 +87,7 @@ pub unsafe fn is_enable_transition_term(
pub unsafe fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
if !is_training_mode() {
return;
}
if category != FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
let entry_id_int =
WorkModule::get_int(module_accessor, *FIGHTER_INSTANCE_WORK_ID_INT_ENTRY_ID) as i32;
// do only once.

View file

@ -11,15 +11,14 @@ pub unsafe fn handle_correct_damage_vector_common(
fighter: &mut L2CFighterCommon,
arg1: L2CValue,
) -> L2CValue {
mod_handle_di(fighter, arg1);
if is_training_mode() {
mod_handle_di(fighter, arg1);
}
original!()(fighter, arg1)
}
unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
if !is_training_mode() {
return;
}
if MENU.di_state == Direction::empty() {
return;
}

View file

@ -12,7 +12,7 @@ static mut DELAY: u32 = 0;
static mut FAST_FALL: bool = false;
fn should_fast_fall() -> bool {
unsafe{
unsafe {
return FAST_FALL;
}
}
@ -29,19 +29,7 @@ pub fn init() {
}
}
pub unsafe fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
if !is_training_mode() {
return;
}
// Once per frame
if category != FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !should_fast_fall() {
return;
}
@ -55,35 +43,37 @@ pub unsafe fn get_command_flag_cat(
}
// Need to be falling
if !is_falling(module_accessor) {
// Roll FF delay
DELAY = MENU.fast_fall_delay.get_random().to_index();
frame_counter::full_reset(FRAME_COUNTER);
return;
unsafe {
if !is_falling(module_accessor) {
// Roll FF delay
DELAY = MENU.fast_fall_delay.get_random().to_index();
frame_counter::full_reset(FRAME_COUNTER);
return;
}
if !is_correct_status(module_accessor) {
return;
}
// Already in fast fall, nothing to do
if WorkModule::is_flag(module_accessor, *FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_DIVE) {
return;
}
// Check delay
if frame_counter::should_delay(DELAY, FRAME_COUNTER) {
return;
}
// Set Fast Fall Flag
WorkModule::set_flag(
module_accessor,
true,
*FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_DIVE,
);
add_spark_effect(module_accessor);
}
if !is_correct_status(module_accessor) {
return;
}
// Already in fast fall, nothing to do
if WorkModule::is_flag(module_accessor, *FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_DIVE) {
return;
}
// Check delay
if frame_counter::should_delay(DELAY, FRAME_COUNTER) {
return;
}
// Set Fast Fall Flag
WorkModule::set_flag(
module_accessor,
true,
*FIGHTER_STATUS_WORK_ID_FLAG_RESERVE_DIVE,
);
add_spark_effect(module_accessor);
}
/**

View file

@ -64,32 +64,31 @@ pub fn get_frame_count(index: usize) -> u32 {
unsafe { COUNTERS[index] }
}
pub unsafe fn tick() {
for (index, _frame) in COUNTERS.iter().enumerate() {
if !SHOULD_COUNT[index] {
continue;
fn tick() {
unsafe {
for (index, _frame) in COUNTERS.iter().enumerate() {
if !SHOULD_COUNT[index] {
continue;
}
COUNTERS[index] += 1;
}
COUNTERS[index] += 1;
}
}
pub unsafe fn get_command_flag_cat(
pub fn reset_all(){
unsafe {
for (index, _frame) in COUNTERS.iter().enumerate() {
full_reset(index);
}
}
}
pub fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
if !is_training_mode() {
return;
}
// Only do once per frame
if category != FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
if !is_operation_cpu(module_accessor) {
return;
}
//~
tick();
}

View file

@ -48,10 +48,6 @@ unsafe fn should_return_none_in_check_button(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
if !is_training_mode() {
return true;
}
if !is_operation_cpu(module_accessor) {
return true;
}

View file

@ -5,7 +5,7 @@ use crate::training::mash;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
const NOT_SET :u32 = 9001;
const NOT_SET: u32 = 9001;
static mut LEDGE_DELAY: u32 = NOT_SET;
static mut LEDGE_DELAY_COUNTER: usize = 0;
@ -15,15 +15,15 @@ pub fn init() {
}
}
pub fn reset_ledge_delay(){
unsafe{
pub fn reset_ledge_delay() {
unsafe {
LEDGE_DELAY = NOT_SET;
}
}
fn roll_ledge_delay(){
unsafe{
if LEDGE_DELAY != NOT_SET {
fn roll_ledge_delay() {
unsafe {
if LEDGE_DELAY != NOT_SET {
return;
}
@ -64,26 +64,16 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor
StatusModule::change_status_request_from_script(module_accessor, status, true);
}
pub unsafe fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
// Only do once per frame
if category != FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
if !is_training_mode() {
return;
}
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_operation_cpu(module_accessor) {
return;
}
if MENU.ledge_state == LedgeOption::empty() {
return;
}
unsafe {
if MENU.ledge_state == LedgeOption::empty() {
return;
}
force_option(module_accessor);
}
force_option(module_accessor);
}
}

View file

@ -4,7 +4,6 @@ use crate::training::character_specific;
use crate::training::fast_fall;
use crate::training::frame_counter;
use crate::training::full_hop;
use crate::training::sdi;
use crate::training::shield;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
@ -94,10 +93,6 @@ pub fn set_aerial(attack: Action) {
pub unsafe fn get_attack_air_kind(
module_accessor: &mut app::BattleObjectModuleAccessor,
) -> Option<i32> {
if !is_training_mode() {
return None;
}
if !is_operation_cpu(module_accessor) {
return None;
}
@ -114,10 +109,6 @@ pub unsafe fn get_command_flag_cat(
return 0;
}
if !is_training_mode() {
return 0;
}
if !is_operation_cpu(module_accessor) {
return 0;
}
@ -129,14 +120,6 @@ pub unsafe fn get_command_flag_cat(
unsafe fn check_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) {
if QUEUE.len() > 0 {
/*
Reset when CPU is idle to prevent deadlocks
and to reset when using the training mode reset
*/
if should_reset(module_accessor) {
full_reset();
}
return;
}
@ -147,25 +130,6 @@ unsafe fn check_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) {
buffer_menu_mash();
}
fn should_reset(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if !is_idle(module_accessor) {
return false;
}
let prev_status;
unsafe {
prev_status = StatusModule::prev_status_kind(module_accessor, 0);
}
// Only reset on training mode reset
if prev_status != *FIGHTER_STATUS_KIND_NONE {
return false;
}
return true;
}
fn should_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
unsafe {
if MENU.mash_in_neutral == OnOff::On {
@ -193,7 +157,6 @@ pub fn buffer_menu_mash() -> Action {
full_hop::roll_full_hop();
fast_fall::roll_fast_fall();
FALLING_AERIAL = MENU.falling_aerials.get_random().into_bool();
sdi::roll_direction();
action
}

View file

@ -1,23 +1,25 @@
use crate::common::{FIGHTER_MANAGER_ADDR, STAGE_MANAGER_ADDR};
use crate::common::{is_training_mode, FIGHTER_MANAGER_ADDR, STAGE_MANAGER_ADDR};
use crate::hitbox_visualizer;
use skyline::nn::ro::LookupSymbol;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
pub mod combo;
pub mod directional_influence;
pub mod sdi;
pub mod shield;
pub mod tech;
mod air_dodge_direction;
mod character_specific;
pub mod combo;
mod fast_fall;
mod frame_counter;
mod full_hop;
mod ledge;
mod left_stick;
mod mash;
mod reset;
mod save_states;
mod shield_tilt;
#[skyline::hook(replace = WorkModule::get_param_float)]
pub unsafe fn handle_get_param_float(
@ -25,8 +27,12 @@ pub unsafe fn handle_get_param_float(
param_type: u64,
param_hash: u64,
) -> f32 {
shield::get_param_float(module_accessor, param_type, param_hash)
.unwrap_or_else(|| original!()(module_accessor, param_type, param_hash))
let ori = original!()(module_accessor, param_type, param_hash);
if !is_training_mode() {
return ori;
}
shield::get_param_float(module_accessor, param_type, param_hash).unwrap_or(ori)
}
#[skyline::hook(replace = WorkModule::get_param_int)]
@ -35,19 +41,29 @@ pub unsafe fn handle_get_param_int(
param_type: u64,
param_hash: u64,
) -> i32 {
save_states::get_param_int(module_accessor, param_type, param_hash)
.unwrap_or_else(|| original!()(module_accessor, param_type, param_hash))
let ori = original!()(module_accessor, param_type, param_hash);
if !is_training_mode() {
return ori;
}
save_states::get_param_int(module_accessor, param_type, param_hash).unwrap_or(ori)
}
#[skyline::hook(replace = ControlModule::get_attack_air_kind)]
pub unsafe fn handle_get_attack_air_kind(
module_accessor: &mut app::BattleObjectModuleAccessor,
) -> i32 {
let ori = original!()(module_accessor);
if !is_training_mode() {
return ori;
}
// bool replace;
// int kind = InputRecorder::get_attack_air_kind(module_accessor, replace);
// if (replace) return kind;
mash::get_attack_air_kind(module_accessor).unwrap_or_else(|| original!()(module_accessor))
mash::get_attack_air_kind(module_accessor).unwrap_or(ori)
}
#[skyline::hook(replace = ControlModule::get_command_flag_cat)]
@ -55,27 +71,46 @@ pub unsafe fn handle_get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) -> i32 {
save_states::save_states(module_accessor, category);
let mut flag = original!()(module_accessor, category);
frame_counter::get_command_flag_cat(module_accessor, category);
combo::get_command_flag_cat(module_accessor, category);
if !is_training_mode() {
return flag;
}
// bool replace;
// int ret = InputRecorder::get_command_flag_cat(module_accessor, category, flag, replace);
// if (replace) return ret;
shield::get_command_flag_cat(module_accessor);
flag |= mash::get_command_flag_cat(module_accessor, category);
ledge::get_command_flag_cat(module_accessor, category);
tech::get_command_flag_cat(module_accessor, category);
hitbox_visualizer::get_command_flag_cat(module_accessor, category);
fast_fall::get_command_flag_cat(module_accessor, category);
once_per_frame_per_fighter(module_accessor, category);
flag
}
fn once_per_frame_per_fighter(
module_accessor: &mut app::BattleObjectModuleAccessor,
category: i32,
) {
if category != FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
unsafe {
combo::get_command_flag_cat(module_accessor);
hitbox_visualizer::get_command_flag_cat(module_accessor);
save_states::save_states(module_accessor);
tech::get_command_flag_cat(module_accessor);
}
fast_fall::get_command_flag_cat(module_accessor);
frame_counter::get_command_flag_cat(module_accessor);
ledge::get_command_flag_cat(module_accessor);
shield::get_command_flag_cat(module_accessor);
reset::check_reset(module_accessor);
}
/**
* This is called to get the stick position when
* shielding (shield tilt)
@ -83,8 +118,14 @@ pub unsafe fn handle_get_command_flag_cat(
*/
#[skyline::hook(replace = ControlModule::get_stick_x_no_clamp)]
pub unsafe fn get_stick_x_no_clamp(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
left_stick::mod_get_stick_x(module_accessor).unwrap_or_else(|| original!()(module_accessor))
let ori = original!()(module_accessor);
if !is_training_mode() {
return ori;
}
shield_tilt::mod_get_stick_x(module_accessor).unwrap_or(ori)
}
/**
* This is called to get the stick position when
* shielding (shield tilt)
@ -92,7 +133,12 @@ pub unsafe fn get_stick_x_no_clamp(module_accessor: &mut app::BattleObjectModule
*/
#[skyline::hook(replace = ControlModule::get_stick_y_no_clamp)]
pub unsafe fn get_stick_y_no_clamp(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
left_stick::mod_get_stick_y(module_accessor).unwrap_or_else(|| original!()(module_accessor))
let ori = original!()(module_accessor);
if !is_training_mode() {
return ori;
}
shield_tilt::mod_get_stick_y(module_accessor).unwrap_or(ori)
}
/**
@ -102,7 +148,12 @@ pub unsafe fn get_stick_y_no_clamp(module_accessor: &mut app::BattleObjectModule
*/
#[skyline::hook(replace = ControlModule::get_stick_x)]
pub unsafe fn get_stick_x(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
left_stick::mod_get_stick_x(module_accessor).unwrap_or_else(|| original!()(module_accessor))
let ori = original!()(module_accessor);
if !is_training_mode() {
return ori;
}
air_dodge_direction::mod_get_stick_x(module_accessor).unwrap_or(ori)
}
/**
@ -110,7 +161,12 @@ pub unsafe fn get_stick_x(module_accessor: &mut app::BattleObjectModuleAccessor)
*/
#[skyline::hook(replace = ControlModule::get_stick_y)]
pub unsafe fn get_stick_y(module_accessor: &mut app::BattleObjectModuleAccessor) -> f32 {
left_stick::mod_get_stick_y(module_accessor).unwrap_or_else(|| original!()(module_accessor))
let ori = original!()(module_accessor);
if !is_training_mode() {
return ori;
}
air_dodge_direction::mod_get_stick_y(module_accessor).unwrap_or(ori)
}
// int get_pad_flag(u64 module_accessor) {
@ -154,10 +210,13 @@ pub unsafe fn handle_check_button_on(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
shield::check_button_on(module_accessor, button).unwrap_or_else(|| {
full_hop::check_button_on(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
})
let ori = original!()(module_accessor, button);
if !is_training_mode() {
return ori;
}
shield::check_button_on(module_accessor, button)
.unwrap_or_else(|| full_hop::check_button_on(module_accessor, button).unwrap_or(ori))
}
#[skyline::hook(replace = ControlModule::check_button_off)]
@ -165,10 +224,13 @@ pub unsafe fn handle_check_button_off(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
shield::check_button_off(module_accessor, button).unwrap_or_else(|| {
full_hop::check_button_off(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
})
let ori = original!()(module_accessor, button);
if !is_training_mode() {
return ori;
}
shield::check_button_off(module_accessor, button)
.unwrap_or_else(|| full_hop::check_button_off(module_accessor, button).unwrap_or(ori))
}
#[skyline::hook(replace = MotionModule::change_motion)]
@ -182,11 +244,15 @@ pub unsafe fn handle_change_motion(
unk5: bool,
unk6: bool,
) -> u64 {
let motion_kind = tech::change_motion(module_accessor, motion_kind).unwrap_or(motion_kind);
let mut mod_motion_kind = motion_kind;
if is_training_mode() {
mod_motion_kind = tech::change_motion(module_accessor, motion_kind).unwrap_or(motion_kind);
}
original!()(
module_accessor,
motion_kind,
mod_motion_kind,
unk1,
unk2,
unk3,
@ -197,15 +263,19 @@ pub unsafe fn handle_change_motion(
}
#[skyline::hook(replace = WorkModule::is_enable_transition_term)]
pub unsafe fn handle_is_enable_transition_term(
pub unsafe fn handle_is_enable_transition_term(
module_accessor: *mut app::BattleObjectModuleAccessor,
transition_term: i32
transition_term: i32,
) -> bool {
let is = original!()(module_accessor, transition_term);
let ori = original!()(module_accessor, transition_term);
combo::is_enable_transition_term(module_accessor, transition_term, is);
if !is_training_mode() {
return ori;
}
is
combo::is_enable_transition_term(module_accessor, transition_term, ori);
ori
}
extern "C" {
@ -214,10 +284,8 @@ extern "C" {
}
#[skyline::hook(replace = set_dead_rumble)]
pub unsafe fn handle_set_dead_rumble(
lua_state: u64) -> u64 {
if crate::common::is_training_mode() {
pub unsafe fn handle_set_dead_rumble(lua_state: u64) -> u64 {
if is_training_mode() {
return 0;
}
@ -259,6 +327,9 @@ pub fn training_mods() {
// Directional AirDodge,
get_stick_x,
get_stick_y,
// Shield Tilt
get_stick_x_no_clamp,
get_stick_y_no_clamp,
// Combo
handle_is_enable_transition_term,
// SDI

47
src/training/reset.rs Normal file
View file

@ -0,0 +1,47 @@
use crate::common::*;
use crate::training::frame_counter;
use crate::training::ledge;
use crate::training::mash;
use crate::training::sdi;
use crate::training::shield_tilt;
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
pub fn check_reset(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_operation_cpu(module_accessor) {
return;
}
if !should_reset(module_accessor) {
return;
}
on_reset();
}
fn should_reset(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
if !is_idle(module_accessor) {
return false;
}
let prev_status;
unsafe {
prev_status = StatusModule::prev_status_kind(module_accessor, 0);
}
// Only reset automatically on training mode reset
if prev_status != *FIGHTER_STATUS_KIND_NONE {
return false;
}
return true;
}
pub fn on_reset() {
mash::full_reset();
sdi::roll_direction();
frame_counter::reset_all();
ledge::reset_ledge_delay();
shield_tilt::roll_direction();
}

View file

@ -1,5 +1,5 @@
use crate::common::*;
use crate::training::mash;
use crate::training::reset;
use smash::app::{self, lua_bind::*};
use smash::hash40;
use smash::lib::lua_const::*;
@ -45,10 +45,6 @@ pub unsafe fn get_param_int(
param_type: u64,
param_hash: u64,
) -> Option<i32> {
if !is_training_mode() {
return None;
}
if param_type == hash40("common") {
if param_hash == hash40("dead_rebirth_wait_frame") {
return Some(1);
@ -70,15 +66,7 @@ pub unsafe fn get_param_int(
None
}
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor, category: i32) {
if !is_training_mode() {
return;
}
if category != *FIGHTER_PAD_COMMAND_CATEGORY1 {
return;
}
pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) {
let status = StatusModule::status_kind(module_accessor) as i32;
let save_state: &mut SavedState;
if is_operation_cpu(module_accessor) {
@ -95,7 +83,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor,
SAVE_STATE_PLAYER.state = KillPlayer;
SAVE_STATE_CPU.state = KillPlayer;
}
mash::full_reset();
reset::on_reset();
return;
}

View file

@ -26,34 +26,26 @@ pub unsafe fn process_hit_stop_delay(
x: L2CValue,
y: L2CValue,
) -> L2CValue {
let mut new_x: L2CValue = x;
let mut new_y: L2CValue = y;
let res;
if is_training_mode() {
let option = mod_sdi_direction(fighter);
let new_x: L2CValue;
let new_y: L2CValue;
let vector = mod_sdi_direction(fighter);
if vector.is_some() {
new_x = vector.unwrap().x.into();
new_y = vector.unwrap().y.into();
}
else {
new_x = x;
new_y = y;
if option.is_some() {
let angle = option.unwrap();
new_x = (angle.cos() as f32).into();
new_y = (angle.sin() as f32).into();
}
}
res = original!()(fighter, arg1, hit_stop_delay_flick_mul, new_x, new_y);
res
original!()(fighter, arg1, hit_stop_delay_flick_mul, new_x, new_y)
}
fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<Vector2f> {
fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<f64> {
unsafe {
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
if !is_training_mode() {
return None;
}
if !is_operation_cpu(module_accessor) {
return None;
}
@ -72,10 +64,7 @@ fn mod_sdi_direction(fighter: &mut L2CFighterCommon) -> Option<Vector2f> {
angle = PI - angle;
}
return Some(Vector2f {
x: angle.cos() as f32,
y: angle.sin() as f32,
});
return Some(angle);
}
#[skyline::hook(replace = FighterControlModuleImpl::check_hit_stop_delay_command)]
@ -84,9 +73,12 @@ pub unsafe fn check_hit_stop_delay_command(
arg1: *mut Vector2f,
) -> u64 {
let ori = original!()(module_accessor, arg1);
let res = mod_check_hit_stop_delay_command(module_accessor, arg1).unwrap_or_else(|| ori);
res
if !is_training_mode() {
return ori;
}
mod_check_hit_stop_delay_command(module_accessor, arg1).unwrap_or(ori)
}
/**
@ -96,12 +88,6 @@ fn mod_check_hit_stop_delay_command(
module_accessor: &mut app::BattleObjectModuleAccessor,
_arg1: *mut Vector2f,
) -> Option<u64> {
unsafe {
if !is_training_mode() {
return None;
}
}
if !is_operation_cpu(module_accessor) {
return None;
}

View file

@ -81,11 +81,7 @@ pub unsafe fn allow_oos() -> bool {
MULTI_HIT_OFFSET == 0
}
pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_training_mode() {
return;
}
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !is_operation_cpu(module_accessor) {
return;
}
@ -96,9 +92,11 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModule
}
// Reset when not shielding
let status_kind = StatusModule::status_kind(module_accessor);
if !(status_kind == FIGHTER_STATUS_KIND_GUARD) {
set_shield_decay(false);
unsafe {
let status_kind = StatusModule::status_kind(module_accessor);
if !(status_kind == FIGHTER_STATUS_KIND_GUARD) {
set_shield_decay(false);
}
}
}
@ -107,10 +105,6 @@ pub unsafe fn get_param_float(
param_type: u64,
param_hash: u64,
) -> Option<f32> {
if !is_training_mode() {
return None;
}
if !is_operation_cpu(module_accessor) {
return None;
}
@ -160,13 +154,19 @@ pub fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAccessor)
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)]
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
let ori = original!()(fighter);
if !is_training_mode() {
return ori;
}
mod_handle_sub_guard_cont(fighter);
original!()(fighter)
ori
}
unsafe fn mod_handle_sub_guard_cont(fighter: &mut L2CFighterCommon) {
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
if !is_training_mode() || !is_operation_cpu(module_accessor) {
if !is_operation_cpu(module_accessor) {
return;
}
@ -343,10 +343,6 @@ unsafe fn should_return_none_in_check_button(
module_accessor: &mut app::BattleObjectModuleAccessor,
button: i32,
) -> bool {
if !is_training_mode() {
return true;
}
if !is_operation_cpu(module_accessor) {
return true;
}

View file

@ -0,0 +1,45 @@
use crate::common::consts::*;
use crate::common::*;
use smash::app::{self};
static mut STICK_DIRECTION: Direction = Direction::OUT;
pub fn roll_direction() {
unsafe {
STICK_DIRECTION = MENU.shield_tilt.get_random();
}
}
pub unsafe fn mod_get_stick_x(
module_accessor: &mut app::BattleObjectModuleAccessor,
) -> Option<f32> {
let angle: f64 = get_angle(module_accessor);
if angle == ANGLE_NONE {
return None;
}
Some(angle.cos() as f32)
}
pub unsafe fn mod_get_stick_y(
module_accessor: &mut app::BattleObjectModuleAccessor,
) -> Option<f32> {
let angle: f64 = get_angle(module_accessor);
if angle == ANGLE_NONE {
return None;
}
Some(angle.sin() as f32)
}
unsafe fn get_angle(module_accessor: &mut app::BattleObjectModuleAccessor) -> f64 {
if !is_operation_cpu(module_accessor) {
return ANGLE_NONE;
}
let angle: f64 = STICK_DIRECTION.into_angle();
angle
}

View file

@ -16,9 +16,11 @@ pub unsafe fn handle_change_status(
status_kind: L2CValue,
unk: L2CValue,
) -> L2CValue {
let mut status_kind = status_kind;
let mut unk = unk;
mod_handle_change_status(fighter, &mut status_kind, &mut unk);
if is_training_mode() {
let mut status_kind = status_kind;
let mut unk = unk;
mod_handle_change_status(fighter, &mut status_kind, &mut unk);
}
original!()(fighter, status_kind, unk)
}
@ -28,10 +30,6 @@ unsafe fn mod_handle_change_status(
status_kind: &mut L2CValue,
unk: &mut L2CValue,
) {
if !is_training_mode() {
return;
}
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
if !is_operation_cpu(module_accessor) {
return;
@ -91,12 +89,7 @@ unsafe fn mod_handle_change_status(
pub unsafe fn get_command_flag_cat(
module_accessor: &mut app::BattleObjectModuleAccessor,
_category: i32,
) {
if !is_training_mode() {
return;
}
if !is_operation_cpu(module_accessor) {
return;
}
@ -133,10 +126,6 @@ pub unsafe fn change_motion(
module_accessor: &mut app::BattleObjectModuleAccessor,
motion_kind: u64,
) -> Option<u64> {
if !is_training_mode() {
return None;
}
if !is_operation_cpu(module_accessor) {
return None;
}