1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-10-02 17:24:28 +00:00

Fixes and formatting

This commit is contained in:
jugeeya 2023-08-24 12:35:39 -07:00
parent 64041cb21e
commit de1e2a6d28
14 changed files with 51 additions and 59 deletions

View file

@ -2,6 +2,7 @@ use std::collections::HashMap;
use crate::common::*;
use crate::input::{ControllerStyle::*, *};
use crate::training::frame_counter;
use crate::training::ui::menu::VANILLA_MENU_ACTIVE;
use lazy_static::lazy_static;
@ -136,7 +137,7 @@ pub fn handle_final_input_mapping(player_idx: i32, controller_struct: &mut SomeC
let p1_controller = &mut *controller_struct.controller;
let mut start_menu_request = false;
let menu_close_wait_frame = unsafe { *menu::VISUAL_FRAME_COUNTER.data_ptr() };
let menu_close_wait_frame = frame_counter::get_frame_count(*menu::MENU_CLOSE_FRAME_COUNTER);
if unsafe { MENU.menu_open_start_press == OnOff::On } {
let start_hold_frames = &mut *START_HOLD_FRAMES.lock();
if p1_controller.current_buttons.plus() {

View file

@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::fs;
use std::sync::Lazy;
use lazy_static::lazy_static;
use parking_lot::Mutex;
@ -14,6 +14,7 @@ use crate::consts::MENU_OPTIONS_PATH;
use crate::events::{Event, EVENT_QUEUE};
use crate::input::*;
use crate::logging::*;
use crate::training::frame_counter;
pub const MENU_CLOSE_WAIT_FRAMES: u32 = 15;
pub static mut QUICK_MENU_ACTIVE: bool = false;
@ -112,9 +113,8 @@ lazy_static! {
};
}
static MENU_CLOSE_FRAME_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::Real)
});
pub static MENU_CLOSE_FRAME_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::Real));
pub fn handle_final_input_mapping(
player_idx: i32,

View file

@ -6,7 +6,7 @@ use crate::is_operation_cpu;
use crate::training::frame_counter;
use crate::training::handle_add_limit;
use std::sync::Lazy;
use once_cell::sync::Lazy;
static mut BUFF_REMAINING_PLAYER: i32 = 0;
static mut BUFF_REMAINING_CPU: i32 = 0;
@ -14,9 +14,8 @@ static mut BUFF_REMAINING_CPU: i32 = 0;
static mut IS_BUFFING_PLAYER: bool = false;
static mut IS_BUFFING_CPU: bool = false;
static BUFF_DELAY_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static BUFF_DELAY_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
pub unsafe fn restart_buff(module_accessor: &mut app::BattleObjectModuleAccessor) {
if is_operation_cpu(module_accessor) {

View file

@ -5,7 +5,7 @@ use crate::common::consts::FighterId;
use crate::common::*;
use crate::training::*;
use std::sync::Lazy;
use once_cell::sync::Lazy;
pub static mut FRAME_ADVANTAGE: i32 = 0;
static mut PLAYER_ACTIONABLE: bool = false;
@ -14,9 +14,8 @@ static mut PLAYER_ACTIVE_FRAME: u32 = 0;
static mut CPU_ACTIVE_FRAME: u32 = 0;
static mut FRAME_ADVANTAGE_CHECK: bool = false;
static FRAME_COUNTER_INDEX: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static FRAME_COUNTER_INDEX: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
unsafe fn _was_in_hitstun(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool {
let prev_status = StatusModule::prev_status_kind(module_accessor, 0);

View file

@ -5,7 +5,7 @@ use smash::phx::{Hash40, Vector3f};
use crate::common::*;
use crate::training::{frame_counter, input_record};
use std::sync::Lazy;
use once_cell::sync::Lazy;
// The current fastfall delay
static mut DELAY: u32 = 0;
@ -22,9 +22,8 @@ pub fn roll_fast_fall() {
}
}
static FRAME_COUNTER_INDEX: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static FRAME_COUNTER_INDEX: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccessor) {
if !should_fast_fall() {

View file

@ -1,9 +1,10 @@
#[derive(PartialEq, Eq)]
pub enum FrameCounterType {
InGame,
// "Reset" occurs when we enter training mode and when we run L+R+A or save state load
// Some frame counters need in-game frames that do not reset when this occurs
InGameNoReset,
Real
Real,
}
pub struct FrameCounter {
@ -18,11 +19,11 @@ pub fn register_counter(counter_type: FrameCounterType) -> usize {
unsafe {
let index = COUNTERS.len();
COUNTERS.push(FrameCounter{
COUNTERS.push(FrameCounter {
count: 0,
should_count: false,
counter_type: counter_type
})
counter_type,
});
index
}
@ -97,7 +98,10 @@ pub fn tick_ingame() {
pub fn tick_real() {
unsafe {
for (index, counter) in COUNTERS.iter().enumerate() {
if !counter.should_count || (counter.counter_type == FrameCounterType::InGame || counter.counter_type == FrameCounterType::InGameNoReset) {
if !counter.should_count
|| (counter.counter_type == FrameCounterType::InGame
|| counter.counter_type == FrameCounterType::InGameNoReset)
{
continue;
}
tick_idx(index);

View file

@ -5,17 +5,14 @@ use crate::common::consts::*;
use crate::common::*;
use crate::training::{frame_counter, input_record, mash};
use std::sync::Lazy;
use once_cell::sync::Lazy;
const NOT_SET: u32 = 9001;
static mut LEDGE_DELAY: u32 = NOT_SET;
static mut LEDGE_DELAY_COUNTER: usize = 0;
static mut LEDGE_CASE: LedgeOption = LedgeOption::empty();
static LEDGE_DELAY_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static LEDGE_DELAY_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
pub fn reset_ledge_delay() {
unsafe {

View file

@ -11,6 +11,8 @@ use crate::training::input_record;
use crate::training::shield;
use crate::training::{attack_angle, save_states};
use once_cell::sync::Lazy;
const DISTANCE_CLOSE_THRESHOLD: f32 = 16.0;
const DISTANCE_MID_THRESHOLD: f32 = 37.0;
const DISTANCE_FAR_THRESHOLD: f32 = 64.0;
@ -22,9 +24,8 @@ static mut FALLING_AERIAL: bool = false;
static mut AERIAL_DELAY: u32 = 0;
static AERIAL_DELAY_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static AERIAL_DELAY_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
// Track if we're about to do another command flag cat run in the same frame for a dash or dash attack
static mut IS_TRANSITIONING_DASH: bool = false;

View file

@ -676,7 +676,7 @@ static OPCF_OFFSET: usize = 0x06b7fdc;
// One instruction after the CPU Control function completes
#[skyline::hook(offset = OPCF_OFFSET, inline)]
unsafe fn handle_once_per_cpu_frame(_ctx: &mut InlineCtx) {
frame_counter::tick();
frame_counter::tick_ingame();
// Tick notifications
let queue = &mut ui::notifications::QUEUE;
let notification = queue.first();
@ -806,15 +806,7 @@ pub fn training_mods() {
handle_final_input_mapping
);
combo::init();
shield::init();
fast_fall::init();
mash::init();
ledge::init();
throw::init();
buff::init();
items::init();
tech::init();
input_record::init();
ui::init();
}

View file

@ -10,7 +10,7 @@ use crate::common::consts::*;
use crate::common::*;
use crate::training::{frame_counter, input_record, mash, save_states};
use std::sync::Lazy;
use once_cell::sync::Lazy;
// How many hits to hold shield until picking an Out Of Shield option
static mut MULTI_HIT_OFFSET: u32 = 0;
@ -24,9 +24,8 @@ static mut WAS_IN_SHIELDSTUN: bool = false;
// For how many frames should the shield hold be overwritten
static mut SUSPEND_SHIELD: bool = false;
static REACTION_COUNTER_INDEX: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static REACTION_COUNTER_INDEX: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
// Toggle for shield decay
static mut SHIELD_DECAY: bool = false;

View file

@ -8,14 +8,13 @@ use crate::common::consts::*;
use crate::common::*;
use crate::training::{frame_counter, mash};
use std::sync::Lazy;
use once_cell::sync::Lazy;
static mut TECH_ROLL_DIRECTION: Direction = Direction::empty();
static mut MISS_TECH_ROLL_DIRECTION: Direction = Direction::empty();
static FRAME_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static FRAME_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
unsafe fn is_enable_passive(module_accessor: &mut BattleObjectModuleAccessor) -> bool {
let fighter = get_fighter_common_from_accessor(module_accessor);

View file

@ -6,17 +6,17 @@ use crate::common::*;
use crate::training::frame_counter;
use crate::training::mash;
use once_cell::sync::Lazy;
const NOT_SET: u32 = 9001;
static mut THROW_DELAY: u32 = NOT_SET;
static mut THROW_DELAY_COUNTER: usize = 0;
static mut PUMMEL_DELAY: u32 = NOT_SET;
static mut THROW_CASE: ThrowOption = ThrowOption::empty();
static THROW_DELAY_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static PUMMEL_DELAY_COUNTER: Lazy<u32> = Lazy::new(|| {
frame_counter::register_counter(frame_counter::FrameCounterType::InGame)
});
static THROW_DELAY_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
static PUMMEL_DELAY_COUNTER: Lazy<usize> =
Lazy::new(|| frame_counter::register_counter(frame_counter::FrameCounterType::InGame));
// Rolling Throw Delays and Pummel Delays separately

View file

@ -6,9 +6,8 @@ use smash::ui2d::{SmashPane, SmashTextBox};
use training_mod_tui::gauge::GaugeState;
use training_mod_tui::{App, AppPage, NUM_LISTS};
use crate::common::menu::{
MENU_CLOSE_WAIT_FRAMES, MENU_CLOSE_FRAME_COUNTER,
};
use crate::common::menu::{MENU_CLOSE_FRAME_COUNTER, MENU_CLOSE_WAIT_FRAMES};
use crate::training::frame_counter;
use crate::{common, common::menu::QUICK_MENU_ACTIVE, input::*};
use super::fade_out;

View file

@ -4,9 +4,12 @@ use sarc::SarcFile;
use skyline::nn::ui2d::*;
use training_mod_consts::{OnOff, MENU};
use crate::common::{is_ready_go, is_training_mode, menu::QUICK_MENU_ACTIVE};
#[cfg(feature = "layout_arc_from_file")]
use crate::consts::LAYOUT_ARC_PATH;
use crate::{
common::{is_ready_go, is_training_mode, menu::QUICK_MENU_ACTIVE},
training::frame_counter,
};
mod damage;
mod display;