1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-12-12 11:29:50 +00:00
UltimateTrainingModpack/src/lib.rs

77 lines
2.6 KiB
Rust
Raw Normal View History

#![feature(proc_macro_hygiene)]
2020-04-30 23:13:49 +00:00
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(dead_code)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![feature(with_options)]
#![feature(asm)]
2020-04-08 04:21:52 +00:00
2020-04-30 23:13:49 +00:00
mod hitbox_visualizer;
2020-05-01 00:36:56 +00:00
mod training;
2020-04-30 23:13:49 +00:00
mod common;
2020-04-30 23:13:49 +00:00
use smash::hash40;
use smash::lib::lua_const::{*};
use smash::lib::{self, L2CAgent, L2CValue};
use smash::app::{self};
use smash::app::lua_bind::{*};
use smash::app::sv_animcmd::{self};
use smash::app::sv_system::{self};
use smash::lua2cpp::L2CFighterCommon;
2020-05-07 00:50:31 +00:00
use skyline::libc::{size_t, c_int, c_void, strlen, fopen, fwrite, fclose};
2020-04-30 23:13:49 +00:00
use smash::Result;
use skyline::nn;
use skyline::patching::patch_data_from_text;
use skyline::{from_c_str, c_str, hooks::A64HookFunction, logging::hex_dump_ptr, logging::HexDump};
2020-04-30 23:13:49 +00:00
use std::fs;
2020-05-05 01:55:19 +00:00
use skyline::nro::{self, NroInfo};
2020-05-05 01:55:19 +00:00
#[allow(unused_unsafe)]
#[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);
if (*menu).MASH_STATE == MASH_ATTACK && (*menu).ATTACK_STATE == MASH_GRAB {
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));
}
}
}
}
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 {
"common" =>
{
println!("Loaded common NRO!");
skyline::install_hook!(handle_sub_guard_cont);
2020-05-05 01:55:19 +00:00
},
_ => ()
}
}
2020-04-30 23:13:49 +00:00
#[skyline::main(name = "test")]
2020-04-16 04:55:22 +00:00
pub fn main() {
2020-04-30 23:13:49 +00:00
println!("Training modpack initialized.");
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 {
common::menu = &mut common::menu_struct;
let buffer = format!("{:x}", common::menu as u64);
println!("Writing training_modpack.log with {}...\n", buffer);
2020-05-07 00:50:31 +00:00
let f = fopen("sd:/SaltySD/training_modpack.log\u{0}".as_bytes().as_ptr(), "w\u{0}".as_bytes().as_ptr());
println!("File pointer: {:#?}", f);
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
}