2020-04-08 10:28:33 +00:00
|
|
|
#![feature(proc_macro_hygiene)]
|
2020-04-30 23:13:49 +00:00
|
|
|
#![feature(with_options)]
|
2020-05-15 23:43:37 +00:00
|
|
|
#![feature(const_mut_refs)]
|
2020-04-08 04:21:52 +00:00
|
|
|
|
2020-05-13 20:52:20 +00:00
|
|
|
mod common;
|
2020-04-30 23:13:49 +00:00
|
|
|
mod hitbox_visualizer;
|
2020-05-01 00:36:56 +00:00
|
|
|
mod training;
|
2020-04-08 10:28:33 +00:00
|
|
|
|
2020-05-13 20:36:55 +00:00
|
|
|
use crate::common::consts::*;
|
2020-05-13 20:52:20 +00:00
|
|
|
use crate::common::*;
|
2020-05-13 20:36:55 +00:00
|
|
|
|
2020-05-13 20:52:20 +00:00
|
|
|
use skyline::c_str;
|
2020-05-15 15:48:34 +00:00
|
|
|
use skyline::libc::{c_void, mkdir, fclose, fopen, fwrite};
|
2020-05-13 20:52:20 +00:00
|
|
|
use skyline::nro::{self, NroInfo};
|
|
|
|
use smash::app::lua_bind::*;
|
2020-05-15 23:49:25 +00:00
|
|
|
use smash::app::sv_system;
|
2020-05-13 20:52:20 +00:00
|
|
|
use smash::lib::lua_const::*;
|
|
|
|
use smash::lib::L2CValue;
|
2020-05-13 19:20:52 +00:00
|
|
|
use smash::lua2cpp::L2CFighterCommon;
|
2020-04-08 10:28:33 +00:00
|
|
|
|
2020-05-13 19:20:52 +00:00
|
|
|
#[skyline::hook(replace = smash::lua2cpp::L2CFighterCommon_sub_guard_cont)]
|
|
|
|
pub unsafe fn handle_sub_guard_cont(fighter: &mut L2CFighterCommon) -> L2CValue {
|
|
|
|
let module_accessor = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
|
2020-05-15 15:48:34 +00:00
|
|
|
if is_training_mode() && is_operation_cpu(module_accessor) {
|
2020-05-15 23:43:37 +00:00
|
|
|
if menu.MASH_STATE == MASH_ATTACK && menu.ATTACK_STATE == MASH_GRAB {
|
2020-05-15 15:48:34 +00:00
|
|
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
|
|
|
if WorkModule::get_int(
|
|
|
|
module_accessor,
|
|
|
|
*FIGHTER_INSTANCE_WORK_ID_INT_INVALID_CATCH_FRAME,
|
|
|
|
) == 0
|
|
|
|
{
|
|
|
|
if WorkModule::is_enable_transition_term(
|
|
|
|
module_accessor,
|
|
|
|
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_CATCH,
|
|
|
|
) {
|
|
|
|
fighter.fighter_base.change_status(
|
|
|
|
L2CValue::new_int(*FIGHTER_STATUS_KIND_CATCH as u64),
|
|
|
|
L2CValue::new_bool(true),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 23:43:37 +00:00
|
|
|
if menu.MASH_STATE == MASH_SPOTDODGE {
|
2020-05-15 15:48:34 +00:00
|
|
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
2020-05-13 20:52:20 +00:00
|
|
|
if WorkModule::is_enable_transition_term(
|
|
|
|
module_accessor,
|
2020-05-15 15:48:34 +00:00
|
|
|
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ESCAPE,
|
2020-05-13 20:52:20 +00:00
|
|
|
) {
|
|
|
|
fighter.fighter_base.change_status(
|
2020-05-15 15:48:34 +00:00
|
|
|
L2CValue::new_int(*FIGHTER_STATUS_KIND_ESCAPE as u64),
|
2020-05-13 20:52:20 +00:00
|
|
|
L2CValue::new_bool(true),
|
|
|
|
);
|
2020-05-13 19:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 23:43:37 +00:00
|
|
|
if menu.MASH_STATE == MASH_UP_B {
|
2020-05-15 15:48:34 +00:00
|
|
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
|
|
|
// if WorkModule::is_enable_transition_term(
|
|
|
|
// module_accessor,
|
|
|
|
// *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_SQUAT_BUTTON,
|
|
|
|
// ) {
|
|
|
|
fighter.fighter_base.change_status(
|
|
|
|
L2CValue::new_int(*FIGHTER_STATUS_KIND_SPECIAL_HI as u64),
|
|
|
|
L2CValue::new_bool(false),
|
|
|
|
);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 23:43:37 +00:00
|
|
|
if menu.MASH_STATE == MASH_UP_SMASH {
|
2020-05-15 15:48:34 +00:00
|
|
|
if StatusModule::prev_status_kind(module_accessor, 0) == FIGHTER_STATUS_KIND_GUARD_DAMAGE {
|
|
|
|
// if WorkModule::is_enable_transition_term(
|
|
|
|
// module_accessor,
|
|
|
|
// *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_JUMP_SQUAT_BUTTON,
|
|
|
|
// ) {
|
|
|
|
fighter.fighter_base.change_status(
|
|
|
|
L2CValue::new_int(*FIGHTER_STATUS_KIND_ATTACK_HI4_START as u64),
|
|
|
|
L2CValue::new_bool(false),
|
|
|
|
);
|
|
|
|
// }
|
2020-05-14 20:54:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-05-13 19:20:52 +00:00
|
|
|
original!()(fighter)
|
2020-05-05 01:55:19 +00:00
|
|
|
}
|
2020-04-09 09:10:23 +00:00
|
|
|
|
2020-05-05 01:55:19 +00:00
|
|
|
fn nro_main(nro: &NroInfo) {
|
|
|
|
match nro.name {
|
2020-05-13 20:52:20 +00:00
|
|
|
"common" => {
|
|
|
|
println!("Loaded common NRO!");
|
|
|
|
skyline::install_hook!(handle_sub_guard_cont);
|
|
|
|
}
|
|
|
|
_ => (),
|
2020-05-05 01:55:19 +00:00
|
|
|
}
|
2020-04-09 06:15:39 +00:00
|
|
|
}
|
|
|
|
|
2020-05-14 20:54:32 +00:00
|
|
|
#[skyline::main(name = "training_modpack")]
|
2020-04-16 04:55:22 +00:00
|
|
|
pub fn main() {
|
2020-04-30 23:13:49 +00:00
|
|
|
println!("Training modpack initialized.");
|
2020-05-13 19:20:52 +00:00
|
|
|
hitbox_visualizer::hitbox_visualization();
|
2020-05-01 00:36:56 +00:00
|
|
|
training::training_mods();
|
2020-05-05 01:55:19 +00:00
|
|
|
nro::add_hook(nro_main).unwrap();
|
2020-04-09 09:10:23 +00:00
|
|
|
|
2020-05-07 00:50:31 +00:00
|
|
|
unsafe {
|
2020-05-15 23:43:37 +00:00
|
|
|
let buffer = format!("{:x}", common::menu as *const _ as u64);
|
2020-05-13 19:20:52 +00:00
|
|
|
println!("Writing training_modpack.log with {}...\n", buffer);
|
2020-05-15 15:48:34 +00:00
|
|
|
mkdir("sd:/TrainingModpack/\u{0}".as_bytes().as_ptr(), 0777);
|
2020-05-13 20:52:20 +00:00
|
|
|
let f = fopen(
|
2020-05-15 15:48:34 +00:00
|
|
|
"sd:/TrainingModpack/training_modpack.log\u{0}".as_bytes().as_ptr(),
|
2020-05-13 20:52:20 +00:00
|
|
|
"w\u{0}".as_bytes().as_ptr(),
|
|
|
|
);
|
2020-05-07 00:50:31 +00:00
|
|
|
|
|
|
|
if !f.is_null() {
|
|
|
|
fwrite(c_str(&buffer) as *const c_void, 1, buffer.len(), f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
2020-04-16 04:55:22 +00:00
|
|
|
}
|