1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-02-17 22:50:32 +00:00

Implement Tilts (#102)

* Code Formatting

* Cleanup

* Implement Tilts

* Update TrainingModpackOverlay

* Move is_shielding to Commong

* Fix Flash Shield

Fixed not dropping shield again

* Formatting

* Remove ToDos
This commit is contained in:
sidschingis 2020-06-28 21:21:20 +02:00 committed by GitHub
parent c6cf52af33
commit 186c6ddc2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 61 additions and 52 deletions

@ -1 +1 @@
Subproject commit eff9297a01f3df86d5bc2a0e80d00c537f44e247
Subproject commit ff248838a589e1d3316d1493e1cd16f89e1e1373

View file

@ -77,9 +77,10 @@ pub enum Attack {
UpSmash = 9,
Grab = 10,
Jab = 11,
Ftilt = 12, // @TODO implement
Utilt = 13, // @TODO implement
Dtilt = 14, // @TODO implement
Ftilt = 12,
Utilt = 13,
Dtilt = 14,
Nothing = 9999,
}
impl From<i32> for Attack {
@ -98,7 +99,11 @@ impl From<i32> for Attack {
8 => DownB,
9 => UpSmash,
10 => Grab,
_ => panic!("Invalid mash attack state {}", x),
11 => Jab,
12 => Ftilt,
13 => Utilt,
14 => Dtilt,
_ => Nothing,
}
}
}

View file

@ -74,6 +74,13 @@ pub unsafe fn is_in_hitstun(module_accessor: &mut app::BattleObjectModuleAccesso
(*FIGHTER_STATUS_KIND_DAMAGE..=*FIGHTER_STATUS_KIND_DAMAGE_FALL).contains(&status_kind)
}
pub fn is_shielding(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool {
unsafe{
let status_kind = StatusModule::status_kind(module_accessor) as i32;
(*FIGHTER_STATUS_KIND_GUARD_ON..=*FIGHTER_STATUS_KIND_GUARD_DAMAGE).contains(&status_kind)
}
}
pub unsafe fn is_in_shieldstun(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
let status_kind = StatusModule::status_kind(module_accessor);
let prev_status = StatusModule::prev_status_kind(module_accessor, 0);
@ -82,4 +89,3 @@ pub unsafe fn is_in_shieldstun(module_accessor: &mut app::BattleObjectModuleAcce
|| (prev_status == FIGHTER_STATUS_KIND_GUARD_DAMAGE
&& status_kind == FIGHTER_STATUS_KIND_GUARD_OFF)
}

View file

@ -321,11 +321,6 @@ unsafe fn mod_handle_catch(lua_state: u64) {
);
}
pub unsafe fn is_shielding(module_accessor: *mut app::BattleObjectModuleAccessor) -> bool {
let status_kind = StatusModule::status_kind(module_accessor) as i32;
(*FIGHTER_STATUS_KIND_GUARD_ON..=*FIGHTER_STATUS_KIND_GUARD_DAMAGE).contains(&status_kind)
}
#[skyline::hook(replace = GrabModule::set_rebound)]
pub unsafe fn handle_set_rebound(
module_accessor: *mut app::BattleObjectModuleAccessor,
@ -335,7 +330,10 @@ pub unsafe fn handle_set_rebound(
original!()(module_accessor, rebound);
}
unsafe fn mod_handle_handle_set_rebound(module_accessor: *mut app::BattleObjectModuleAccessor, rebound: bool) {
unsafe fn mod_handle_handle_set_rebound(
module_accessor: *mut app::BattleObjectModuleAccessor,
rebound: bool,
) {
if !is_training_mode() {
return;
}

View file

@ -13,25 +13,25 @@ pub unsafe fn register_counter() -> usize {
index
}
pub unsafe fn start_counting(index:usize) {
pub unsafe fn start_counting(index: usize) {
SHOULD_COUNT[index] = true;
}
pub unsafe fn stop_counting(index:usize) {
SHOULD_COUNT[index] = false;
pub unsafe fn stop_counting(index: usize) {
SHOULD_COUNT[index] = false;
}
pub unsafe fn reset_frame_count(index:usize) {
pub unsafe fn reset_frame_count(index: usize) {
COUNTERS[index] = 0;
}
pub unsafe fn get_frame_count(index:usize) -> u32 {
pub unsafe fn get_frame_count(index: usize) -> u32 {
COUNTERS[index]
}
pub unsafe fn tick() {
for (index, _frame) in COUNTERS.iter().enumerate() {
if !SHOULD_COUNT[index]{
if !SHOULD_COUNT[index] {
continue;
}
COUNTERS[index] += 1;

View file

@ -93,16 +93,13 @@ unsafe fn check_buffer(module_accessor: &mut app::BattleObjectModuleAccessor) {
let mut action = MENU.mash_state;
if action == Mash::Random {
let mut random_cmds = vec![
Mash::Jump,
Mash::Attack,
];
let mut random_cmds = vec![Mash::Jump, Mash::Attack];
if is_airborne(module_accessor){
if is_airborne(module_accessor) {
random_cmds.push(Mash::Airdodge);
}
if is_grounded(module_accessor){
if is_grounded(module_accessor) {
random_cmds.push(Mash::RollBack);
random_cmds.push(Mash::RollForward);
random_cmds.push(Mash::Spotdodge);
@ -159,11 +156,16 @@ unsafe fn perform_action(module_accessor: &mut app::BattleObjectModuleAccessor)
Doesn't actually cause the shield, but will clear the buffer once shield is possible.
Shield hold is performed trough shield::should_hold_shield
*/
return get_flag(
module_accessor,
*FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON,
*FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE,
);
// return get_flag(
// module_accessor,
// *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_GUARD_ON,
// *FIGHTER_PAD_CMD_CAT1_FLAG_AIR_ESCAPE,
// );
if is_shielding(module_accessor) {
reset();
}
return 0;
}
_ => return 0,
}
@ -227,6 +229,18 @@ unsafe fn get_attack_flag(module_accessor: &mut app::BattleObjectModuleAccessor)
action_flag = *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_N;
transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK;
}
Ftilt => {
action_flag = *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_S3;
transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_S3;
}
Utilt => {
action_flag = *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_HI3;
transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_HI3;
}
Dtilt => {
action_flag = *FIGHTER_PAD_CMD_CAT1_FLAG_ATTACK_LW3;
transition_flag = *FIGHTER_STATUS_TRANSITION_TERM_ID_CONT_ATTACK_LW3;
}
_ => return 0,
}

View file

@ -151,8 +151,8 @@ 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(
|| original!()(module_accessor, button))
shield::check_button_on(module_accessor, button)
.unwrap_or_else(|| original!()(module_accessor, button))
}
#[skyline::hook(replace = ControlModule::check_button_off)]

View file

@ -1,9 +1,9 @@
use crate::common::*;
use crate::training::mash;
use smash::app::{self, lua_bind::*};
use smash::hash40;
use smash::lib::lua_const::*;
use smash::phx::{Hash40, Vector3f};
use smash::hash40;
#[derive(PartialEq)]
enum SaveState {
@ -119,11 +119,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor,
};
PostureModule::set_pos(module_accessor, &pos);
StatusModule::change_status_request(
module_accessor,
*FIGHTER_STATUS_KIND_DEAD,
false,
);
StatusModule::change_status_request(module_accessor, *FIGHTER_STATUS_KIND_DEAD, false);
return;
}

View file

@ -1,6 +1,5 @@
use crate::common::consts::*;
use crate::common::*;
use crate::hitbox_visualizer;
use crate::training::frame_counter;
use crate::training::mash;
use smash::app;
@ -153,21 +152,13 @@ pub unsafe fn should_hold_shield(module_accessor: &mut app::BattleObjectModuleAc
match mash::get_current_buffer() {
Mash::Attack => {} // Handle attack below
// Mash::RollForward => {return true}
// Mash::RollBack => {return true}
// If we are not mashing attack then we will always hold shield
_ => return true,
}
// We will hold shield if we are in shieldstun and our attack can be performed OOS
match mash::get_current_attack() {
// Attack::UpSmash => return true,
Attack::Grab => return true,
// Attack::UpB => return true,
// Attack::Nair => return true,
// Attack::Fair => return true,
// Attack::UpAir => return true,
// Attack::Bair => return true,
Attack::Grab => return true, // Grab has 4 extra shield frames
_ => return false,
}
}
@ -196,7 +187,7 @@ unsafe fn mod_handle_sub_guard_cont(fighter: &mut L2CFighterCommon) {
return;
}
if !hitbox_visualizer::is_shielding(module_accessor) {
if !is_shielding(module_accessor) {
return;
}
@ -320,7 +311,7 @@ fn needs_oos_handling_drop_shield() -> bool {
return true;
}
}
_ => {},
_ => {}
}
false

View file

@ -126,8 +126,8 @@ pub unsafe fn get_command_flag_cat(
.contains(&status)
{
let random_statuses = vec![
*FIGHTER_STATUS_KIND_DOWN_STAND, // Normal Getup
*FIGHTER_STATUS_KIND_DOWN_STAND_FB, // Getup Roll
*FIGHTER_STATUS_KIND_DOWN_STAND, // Normal Getup
*FIGHTER_STATUS_KIND_DOWN_STAND_FB, // Getup Roll
*FIGHTER_STATUS_KIND_DOWN_STAND_ATTACK, // Getup Attack
];
@ -142,7 +142,6 @@ pub unsafe fn get_command_flag_cat(
}
}
pub unsafe fn change_motion(
module_accessor: &mut app::BattleObjectModuleAccessor,
motion_kind: u64,