mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-01-20 01:10:13 +00:00
Apply Bit Flag (#138)
* Apply Bit Flag Fast Fall Full Hop Falling Aerial * Fix DI Fixed neutral DI not overwriting previously set DI
This commit is contained in:
parent
3445edceaf
commit
c961d028d0
8 changed files with 98 additions and 44 deletions
|
@ -122,7 +122,7 @@ Specific options include:
|
|||
)"""";
|
||||
|
||||
// Mash States
|
||||
const std::string mash_help = R""""(
|
||||
const std::string mash_help = R""""(
|
||||
Use this toggle along with the Shield
|
||||
Options toggle to practice moves on
|
||||
shield.
|
||||
|
@ -151,7 +151,7 @@ are hit and remain grounded.
|
|||
// clang-format on
|
||||
DEFINE_ENUM_CLASS(ActionFlag);
|
||||
|
||||
const std::string follow_up_help = R""""(
|
||||
const std::string follow_up_help = R""""(
|
||||
Action to buffer
|
||||
after the first mash option
|
||||
)"""";
|
||||
|
@ -224,12 +224,18 @@ Force mash options to
|
|||
always occur, not just
|
||||
out of specific states.)"""";
|
||||
|
||||
// clang-format off
|
||||
#define ENUM_CLASS_DelayFlag(type,x) \
|
||||
x(type,D0,"0") \
|
||||
x(type,D1,"1") x(type,D2,"2") x(type,D3,"3") x(type,D4,"4") x(type,D5,"5") \
|
||||
x(type,D6,"6") x(type,D7,"7") x(type,D8,"8") x(type,D9,"9") x(type,D10,"10") \
|
||||
x(type,D11,"11") x(type,D12,"12") x(type,D13,"13") x(type,D14,"14") x(type,D15,"15") \
|
||||
x(type,D16,"16") x(type,D17,"17") x(type,D18,"18") x(type,D19,"19") x(type,D20,"20")
|
||||
|
||||
// clang-format on
|
||||
DEFINE_ENUM_CLASS(DelayFlag);
|
||||
|
||||
DEFINE_ENUM_CLASS(DelayFlag);
|
||||
|
||||
#define ENUM_CLASS_BoolFlag(type,x) \
|
||||
x(type,True,"True") x(type,False,"False")
|
||||
|
||||
DEFINE_ENUM_CLASS(BoolFlag);
|
|
@ -19,10 +19,10 @@ static struct TrainingModpackMenu
|
|||
DelayFlags OOS_OFFSET = DelayFlags::None;
|
||||
DelayFlags REACTION_TIME = DelayFlags::None;
|
||||
int MASH_IN_NEUTRAL = false;
|
||||
int FAST_FALL = false;
|
||||
BoolFlags FAST_FALL = BoolFlags::None;
|
||||
DelayFlags FAST_FALL_DELAY = DelayFlags::None;
|
||||
int FALLING_AERIALS = false;
|
||||
int FULL_HOP = false;
|
||||
BoolFlags FALLING_AERIALS = BoolFlags::None;
|
||||
BoolFlags FULL_HOP = BoolFlags::None;
|
||||
} menu;
|
||||
|
||||
static int FRAME_ADVANTAGE = 0;
|
||||
|
@ -412,20 +412,13 @@ tsl::elm::Element* GuiMain::createUI()
|
|||
|
||||
list->addItem(createBitFlagOption(&menu.REACTION_TIME, "Reaction Time", reaction_time_help));
|
||||
|
||||
ValueListItem* fastFallItem = new ValueListItem("Fast Fall", on_off, &menu.FAST_FALL, "fast_fall", "");
|
||||
list->addItem(fastFallItem);
|
||||
valueListItems.push_back(fastFallItem);
|
||||
list->addItem(createBitFlagOption(&menu.FAST_FALL, "Fast Fall", ""));
|
||||
|
||||
list->addItem(createBitFlagOption(&menu.FAST_FALL_DELAY, "Fast Fall Delay", "In Frames"));
|
||||
|
||||
ValueListItem* fallingAerialsItem =
|
||||
new ValueListItem("Falling Aerials", on_off, &menu.FALLING_AERIALS, "falling_aerials", "");
|
||||
list->addItem(fallingAerialsItem);
|
||||
valueListItems.push_back(fallingAerialsItem);
|
||||
list->addItem(createBitFlagOption(&menu.FALLING_AERIALS, "Falling Aerials", ""));
|
||||
|
||||
ValueListItem* fullHopItem = new ValueListItem("Full Hop", on_off, &menu.FULL_HOP, "full_hop", "");
|
||||
list->addItem(fullHopItem);
|
||||
valueListItems.push_back(fullHopItem);
|
||||
list->addItem(createBitFlagOption(&menu.FULL_HOP, "Full Hop", ""));
|
||||
|
||||
ClickableListItem* saveStateItem = new ClickableListItem(
|
||||
"Save States", save_state_items, nullptr, "saveStates", 0, "Save States", save_states_help);
|
||||
|
|
|
@ -254,14 +254,31 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/757266
|
||||
|
||||
impl Delay {
|
||||
to_vec_impl! {Delay}
|
||||
get_random_impl! {Delay}
|
||||
to_index_impl! {Delay}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct BoolFlag : u32 {
|
||||
const TRUE = 0x1;
|
||||
const FALSE = 0x2;
|
||||
}
|
||||
}
|
||||
|
||||
impl BoolFlag {
|
||||
to_vec_impl! {BoolFlag}
|
||||
get_random_impl! {BoolFlag}
|
||||
|
||||
pub fn into_bool(&self) -> bool {
|
||||
return match *self {
|
||||
BoolFlag::TRUE => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct TrainingModpackMenu {
|
||||
pub hitbox_vis: HitboxVisualization,
|
||||
|
@ -276,10 +293,10 @@ pub struct TrainingModpackMenu {
|
|||
pub oos_offset: Delay,
|
||||
pub reaction_time: Delay,
|
||||
pub mash_in_neutral: OnOff,
|
||||
pub fast_fall: OnOff,
|
||||
pub fast_fall: BoolFlag,
|
||||
pub fast_fall_delay: Delay,
|
||||
pub falling_aerials: OnOff,
|
||||
pub full_hop: OnOff,
|
||||
pub falling_aerials: BoolFlag,
|
||||
pub full_hop: BoolFlag,
|
||||
}
|
||||
|
||||
// Fighter Ids
|
||||
|
|
|
@ -18,10 +18,10 @@ pub static mut MENU_STRUCT: consts::TrainingModpackMenu = consts::TrainingModpac
|
|||
oos_offset: Delay::empty(),
|
||||
reaction_time: Delay::empty(),
|
||||
mash_in_neutral: OnOff::Off,
|
||||
fast_fall: OnOff::Off,
|
||||
fast_fall: BoolFlag::empty(),
|
||||
fast_fall_delay: Delay::empty(),
|
||||
falling_aerials: OnOff::Off,
|
||||
full_hop: OnOff::Off,
|
||||
falling_aerials: BoolFlag::empty(),
|
||||
full_hop: BoolFlag::empty(),
|
||||
};
|
||||
|
||||
pub static mut MENU: &'static mut consts::TrainingModpackMenu = unsafe { &mut MENU_STRUCT };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::common::consts::*;
|
||||
use crate::common::*;
|
||||
use core::f64::consts::PI;
|
||||
use smash::app::{lua_bind::*, sv_system};
|
||||
use smash::app::{self, lua_bind::*, sv_system};
|
||||
use smash::lib::lua_const::*;
|
||||
use smash::lib::L2CValue;
|
||||
use smash::lua2cpp::L2CFighterCommon;
|
||||
|
@ -33,6 +33,7 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
|||
let mut angle = MENU.di_state.get_random().into_angle();
|
||||
// Nothing to do on no DI
|
||||
if angle == ANGLE_NONE {
|
||||
set_x_y(module_accessor, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -41,15 +42,20 @@ unsafe fn mod_handle_di(fighter: &mut L2CFighterCommon, _arg1: L2CValue) {
|
|||
angle = PI - angle;
|
||||
}
|
||||
|
||||
WorkModule::set_float(
|
||||
module_accessor,
|
||||
angle.cos() as f32,
|
||||
*FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X,
|
||||
);
|
||||
WorkModule::set_float(
|
||||
module_accessor,
|
||||
angle.sin() as f32,
|
||||
*FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y,
|
||||
);
|
||||
set_x_y(module_accessor, angle.cos() as f32, angle.sin() as f32);
|
||||
}
|
||||
|
||||
fn set_x_y(module_accessor: &mut app::BattleObjectModuleAccessor, x: f32, y: f32) {
|
||||
unsafe {
|
||||
WorkModule::set_float(
|
||||
module_accessor,
|
||||
x,
|
||||
*FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_X,
|
||||
);
|
||||
WorkModule::set_float(
|
||||
module_accessor,
|
||||
y,
|
||||
*FIGHTER_STATUS_DAMAGE_WORK_FLOAT_VECOR_CORRECT_STICK_Y,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use crate::common::consts::OnOff;
|
||||
use crate::common::*;
|
||||
use crate::training::frame_counter;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
|
@ -10,6 +9,20 @@ static mut FRAME_COUNTER: usize = 0;
|
|||
// The current fastfall delay
|
||||
static mut DELAY: u32 = 0;
|
||||
|
||||
static mut FAST_FALL: bool = false;
|
||||
|
||||
fn should_fast_fall() -> bool {
|
||||
unsafe{
|
||||
return FAST_FALL;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn roll_fast_fall() {
|
||||
unsafe {
|
||||
FAST_FALL = MENU.fast_fall.get_random().into_bool();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
FRAME_COUNTER = frame_counter::register_counter();
|
||||
|
@ -29,7 +42,7 @@ pub unsafe fn get_command_flag_cat(
|
|||
return;
|
||||
}
|
||||
|
||||
if MENU.fast_fall != OnOff::On {
|
||||
if !should_fast_fall() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
use crate::common::consts::*;
|
||||
use crate::common::*;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
use smash::lib::lua_const::*;
|
||||
|
||||
// the current full hop status
|
||||
static mut FULL_HOP: bool = false;
|
||||
|
||||
pub fn should_full_hop() -> bool {
|
||||
unsafe{
|
||||
return FULL_HOP;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn roll_full_hop() {
|
||||
unsafe {
|
||||
FULL_HOP = MENU.full_hop.get_random().into_bool();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is needed to have the CPU put up shield
|
||||
*/
|
||||
pub unsafe fn check_button_on(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
|
@ -17,7 +30,6 @@ pub unsafe fn check_button_on(
|
|||
}
|
||||
|
||||
/**
|
||||
* This is needed to prevent dropping shield immediately
|
||||
*/
|
||||
pub unsafe fn check_button_off(
|
||||
module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||
|
@ -50,7 +62,7 @@ unsafe fn should_return_none_in_check_button(
|
|||
}
|
||||
|
||||
// Nothing to do if not toggled
|
||||
if MENU.full_hop != OnOff::On {
|
||||
if !should_full_hop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::common::consts::*;
|
|||
use crate::common::*;
|
||||
use crate::training::character_specific;
|
||||
use crate::training::fast_fall;
|
||||
use crate::training::full_hop;
|
||||
use crate::training::shield;
|
||||
use smash::app::{self, lua_bind::*};
|
||||
use smash::lib::lua_const::*;
|
||||
|
@ -9,6 +10,8 @@ use smash::lib::lua_const::*;
|
|||
static mut CURRENT_AERIAL: Action = Action::NAIR;
|
||||
static mut QUEUE: Vec<Action> = vec![];
|
||||
|
||||
static mut FALLING_AERIAL: bool = false;
|
||||
|
||||
pub fn buffer_action(action: Action) {
|
||||
unsafe {
|
||||
if QUEUE.len() > 0 {
|
||||
|
@ -173,6 +176,10 @@ pub fn buffer_menu_mash() -> Action {
|
|||
let action = MENU.mash_state.get_random();
|
||||
buffer_action(action);
|
||||
|
||||
full_hop::roll_full_hop();
|
||||
fast_fall::roll_fast_fall();
|
||||
FALLING_AERIAL = MENU.falling_aerials.get_random().into_bool();
|
||||
|
||||
action
|
||||
}
|
||||
}
|
||||
|
@ -371,14 +378,14 @@ unsafe fn get_aerial_flag(
|
|||
flag |= *FIGHTER_PAD_CMD_CAT1_FLAG_JUMP_BUTTON;
|
||||
|
||||
// Delay attack until we are airborne to get a full hop
|
||||
if MENU.full_hop == OnOff::On {
|
||||
if full_hop::should_full_hop() {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
let status = *FIGHTER_STATUS_KIND_ATTACK_AIR;
|
||||
|
||||
if MENU.falling_aerials == OnOff::On && !fast_fall::is_falling(module_accessor) {
|
||||
if FALLING_AERIAL && !fast_fall::is_falling(module_accessor) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue