mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-04-29 17:09:19 +00:00
Add back frame advantage using raygun shot printer (#219)
* raygun print frame advantage * Don't release, but allow action for raygun-print branch * Add as menu option, only print in that case * revert change to workflow file
This commit is contained in:
parent
427d6ee953
commit
3d563b9450
7 changed files with 240 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "training_modpack"
|
name = "training_modpack"
|
||||||
version = "2.7.0"
|
version = "3.0.0"
|
||||||
authors = ["jugeeya <jugeeya@live.com>"]
|
authors = ["jugeeya <jugeeya@live.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -738,6 +738,7 @@ url_params! {
|
||||||
pub input_delay: i32,
|
pub input_delay: i32,
|
||||||
pub save_damage: OnOff,
|
pub save_damage: OnOff,
|
||||||
pub save_state_mirroring: SaveStateMirroring,
|
pub save_state_mirroring: SaveStateMirroring,
|
||||||
|
pub frame_advantage: OnOff,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,6 +781,7 @@ impl TrainingModpackMenu {
|
||||||
(stage_hazards = OnOff::from_val(val))
|
(stage_hazards = OnOff::from_val(val))
|
||||||
(tech_state = TechFlags::from_bits(val))
|
(tech_state = TechFlags::from_bits(val))
|
||||||
(save_damage = OnOff::from_val(val))
|
(save_damage = OnOff::from_val(val))
|
||||||
|
(frame_advantage = OnOff::from_val(val))
|
||||||
|
|
||||||
(save_state_mirroring = num::FromPrimitive::from_u32(val))
|
(save_state_mirroring = num::FromPrimitive::from_u32(val))
|
||||||
);
|
);
|
||||||
|
|
|
@ -321,6 +321,12 @@ pub unsafe fn write_menu() {
|
||||||
MENU.stage_hazards as usize,
|
MENU.stage_hazards as usize,
|
||||||
(MENU.stage_hazards as usize & OnOff::On as usize) != 0
|
(MENU.stage_hazards as usize & OnOff::On as usize) != 0
|
||||||
);
|
);
|
||||||
|
overall_menu.add_sub_menu_onoff(
|
||||||
|
"Frame Advantage",
|
||||||
|
"frame_advantage",
|
||||||
|
MENU.frame_advantage as usize,
|
||||||
|
(MENU.frame_advantage as usize & OnOff::On as usize) != 0
|
||||||
|
);
|
||||||
overall_menu.add_sub_menu_onoff(
|
overall_menu.add_sub_menu_onoff(
|
||||||
"Mash In Neutral",
|
"Mash In Neutral",
|
||||||
"mash_in_neutral",
|
"mash_in_neutral",
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
pub mod consts;
|
pub mod consts;
|
||||||
pub mod menu;
|
pub mod menu;
|
||||||
pub mod release;
|
pub mod release;
|
||||||
|
pub mod raygun_printer;
|
||||||
|
|
||||||
use crate::common::consts::*;
|
use crate::common::consts::*;
|
||||||
use smash::app::{self, lua_bind::*};
|
use smash::app::{self, lua_bind::*};
|
||||||
use smash::hash40;
|
use smash::hash40;
|
||||||
use smash::lib::lua_const::*;
|
use smash::lib::lua_const::*;
|
||||||
|
|
||||||
|
|
||||||
pub static mut MENU: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
pub static mut MENU: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
||||||
hitbox_vis: OnOff::On,
|
hitbox_vis: OnOff::On,
|
||||||
stage_hazards: OnOff::Off,
|
stage_hazards: OnOff::Off,
|
||||||
|
@ -35,6 +37,7 @@ pub static mut MENU: consts::TrainingModpackMenu = consts::TrainingModpackMenu {
|
||||||
input_delay: 0,
|
input_delay: 0,
|
||||||
save_damage: OnOff::On,
|
save_damage: OnOff::On,
|
||||||
save_state_mirroring: SaveStateMirroring::None,
|
save_state_mirroring: SaveStateMirroring::None,
|
||||||
|
frame_advantage: OnOff::Off
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static mut FIGHTER_MANAGER_ADDR: usize = 0;
|
pub static mut FIGHTER_MANAGER_ADDR: usize = 0;
|
||||||
|
|
214
src/common/raygun_printer.rs
Normal file
214
src/common/raygun_printer.rs
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
use smash::phx::{Vector3f, Hash40};
|
||||||
|
use smash::app;
|
||||||
|
|
||||||
|
pub static RAYGUN_LENGTH : f32 = 8.0;
|
||||||
|
pub static RAYGUN_HEIGHT : f32 = 6.0;
|
||||||
|
pub static RAYGUN_HORIZ_OFFSET : f32 = 2.0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
segment data list : {Z, Y, X, ZRot, Size}
|
||||||
|
segment labels :
|
||||||
|
_
|
||||||
|
|_| from top to top left, clockwise: a->f + g mid + \|/ from top mid to top left, clockwise: h->m + --two half g's: n, o
|
||||||
|
|_| /|\
|
||||||
|
*/
|
||||||
|
|
||||||
|
pub static segment_dict: [[f32; 5]; 15] = [
|
||||||
|
[0.0, RAYGUN_HEIGHT*2.0, 0.0, 0.0, 0.25], // a
|
||||||
|
[0.0, RAYGUN_HEIGHT, RAYGUN_LENGTH, 90.0, 0.25], // b
|
||||||
|
[0.0, 0.0, RAYGUN_LENGTH, 90.0, 0.25], // c
|
||||||
|
[0.0, 0.0, 0.0, 0.0, 0.25], // d
|
||||||
|
[0.0, 0.0, 0.0, 90.0, 0.25], // e
|
||||||
|
[0.0, RAYGUN_HEIGHT, 0.0, 90.0, 0.25], // f
|
||||||
|
[0.0, RAYGUN_HEIGHT, 0.0, 0.0, 0.25], // g mid
|
||||||
|
[0.0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2.0, 90.0, 0.25], // h
|
||||||
|
[0.0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2.0, 52.0, 0.2], // i
|
||||||
|
[0.0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2.0, -52.0, 0.2], // j
|
||||||
|
[0.0, 0.0, RAYGUN_LENGTH/2.0, 90.0, 0.25], // k
|
||||||
|
[0.0, RAYGUN_HEIGHT/2.0, RAYGUN_LENGTH*3.0/16.0, 52.0, 0.2], // l
|
||||||
|
[0.0, RAYGUN_HEIGHT*3.0/2.0, RAYGUN_LENGTH*3.0/16.0, -52.0, 0.2], // m
|
||||||
|
[0.0, RAYGUN_HEIGHT, 0.0, 0.0, 0.15], // n
|
||||||
|
[0.0, RAYGUN_HEIGHT, RAYGUN_LENGTH/2.0, 0.0, 0.15], // o
|
||||||
|
];
|
||||||
|
|
||||||
|
/*
|
||||||
|
Segments making up each character, each index corresponding to:
|
||||||
|
'A' through 'Z', '0' through '9', ' ', '-', '+', '#' (where '#' is all segments)
|
||||||
|
*/
|
||||||
|
pub static alphabet: [&str; 40] = [
|
||||||
|
"abcefg",
|
||||||
|
"adefijn",
|
||||||
|
"adef",
|
||||||
|
"eflm",
|
||||||
|
"adefn",
|
||||||
|
"aefn",
|
||||||
|
"acdefo",
|
||||||
|
"bcefg",
|
||||||
|
"adhk",
|
||||||
|
"bcd",
|
||||||
|
"efnij",
|
||||||
|
"def",
|
||||||
|
"bcefim",
|
||||||
|
"bcefjm",
|
||||||
|
"abcdef",
|
||||||
|
"abefg",
|
||||||
|
"abcdefj",
|
||||||
|
"aefijn",
|
||||||
|
"acdfg",
|
||||||
|
"ahk",
|
||||||
|
"bcdef",
|
||||||
|
"efil",
|
||||||
|
"bcefjl",
|
||||||
|
"ijlm",
|
||||||
|
"ikm",
|
||||||
|
"adil",
|
||||||
|
"abcdef",
|
||||||
|
"ef",
|
||||||
|
"abdeg",
|
||||||
|
"abcdg",
|
||||||
|
"bcfg",
|
||||||
|
"acdfg",
|
||||||
|
"acdefg",
|
||||||
|
"abc",
|
||||||
|
"abcdefg",
|
||||||
|
"abcdfg",
|
||||||
|
"",
|
||||||
|
"g",
|
||||||
|
"ghk",
|
||||||
|
"abcdefhijklmno",
|
||||||
|
];
|
||||||
|
|
||||||
|
// Each index is a segment's corresponding flipped segment, for when facing left
|
||||||
|
pub static segment_rev: [char; 15] = [
|
||||||
|
'a',
|
||||||
|
'f',
|
||||||
|
'e',
|
||||||
|
'd',
|
||||||
|
'c',
|
||||||
|
'b',
|
||||||
|
'g',
|
||||||
|
'h',
|
||||||
|
'm',
|
||||||
|
'l',
|
||||||
|
'k',
|
||||||
|
'j',
|
||||||
|
'i',
|
||||||
|
'o',
|
||||||
|
'n',
|
||||||
|
];
|
||||||
|
|
||||||
|
fn show_segment(module_accessor: &mut app::BattleObjectModuleAccessor, z: f32, y: f32, x: f32, zrot: f32, size: f32) {
|
||||||
|
let pos = Vector3f{x : x, y : y, z : z};
|
||||||
|
let rot = Vector3f{x : 0.0, y : 90.0, z : zrot};
|
||||||
|
let random = Vector3f{x : 0.0, y : 0.0, z : 0.0};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
app::lua_bind::EffectModule::req_on_joint(module_accessor,
|
||||||
|
Hash40::new("sys_raygun_bullet"), Hash40::new("top"),
|
||||||
|
&pos, &rot, size, &random, &random,
|
||||||
|
false, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn alphabet_index(to_print: char) -> i32 {
|
||||||
|
match to_print {
|
||||||
|
'A'..'Z' => to_print as i32 - 'A' as i32,
|
||||||
|
'0'..'9' => to_print as i32 - '0' as i32 + 'Z' as i32 - 'A' as i32 + 1,
|
||||||
|
' ' => 36,
|
||||||
|
'-' => 37,
|
||||||
|
'+' => 38,
|
||||||
|
'#' => 39,
|
||||||
|
_ => -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_char(module_accessor: &mut app::BattleObjectModuleAccessor,
|
||||||
|
to_print: char,
|
||||||
|
line_num: i32,
|
||||||
|
horiz_offset: f32,
|
||||||
|
facing_left: f32)
|
||||||
|
{
|
||||||
|
let alph_index = alphabet_index(to_print);
|
||||||
|
if (alph_index < 0 || alph_index >= 40) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let segment_str = alphabet[alph_index as usize];
|
||||||
|
let num_segments = segment_str.len();
|
||||||
|
|
||||||
|
let line_offset = 40.0 - ((line_num as f32) * 16.0);
|
||||||
|
|
||||||
|
for segment_char in segment_str.chars() {
|
||||||
|
let mut index = segment_char as i32 - 'a' as i32;
|
||||||
|
|
||||||
|
let segment: [f32; 5];
|
||||||
|
if facing_left == -1.0 {
|
||||||
|
index = segment_rev[index as usize] as i32 - 'a' as i32;
|
||||||
|
}
|
||||||
|
segment = segment_dict[index as usize];
|
||||||
|
|
||||||
|
let size_mult : f32 = 0.5;
|
||||||
|
|
||||||
|
let mut z = segment[0];
|
||||||
|
let mut y = segment[1] + line_offset;
|
||||||
|
let mut x = segment[2] + horiz_offset;
|
||||||
|
let mut zrot = segment[3];
|
||||||
|
|
||||||
|
if facing_left == -1.0 {
|
||||||
|
zrot *= -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut size = segment[4];
|
||||||
|
|
||||||
|
x *= size_mult;
|
||||||
|
x += facing_left * 5.0;
|
||||||
|
y *= size_mult;
|
||||||
|
y += 5.0;
|
||||||
|
z *= size_mult;
|
||||||
|
size *= size_mult;
|
||||||
|
show_segment(module_accessor, z, y, x, zrot, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn print_string(module_accessor: &mut app::BattleObjectModuleAccessor, to_write: &str) {
|
||||||
|
// Delete any previous strings
|
||||||
|
unsafe {
|
||||||
|
app::lua_bind::EffectModule::kill_kind(module_accessor, Hash40::new("sys_raygun_bullet"), false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut line_num = 0;
|
||||||
|
let mut horiz_offset = 0.0;
|
||||||
|
let mut char_num = 0;
|
||||||
|
|
||||||
|
let mut facing_left: f32 = 1.0;
|
||||||
|
unsafe {
|
||||||
|
facing_left = app::lua_bind::PostureModule::lr(module_accessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to_write.len() <= 8 && !to_write.contains("\n")) {
|
||||||
|
line_num = 1;
|
||||||
|
}
|
||||||
|
for curr_char in to_write.chars() {
|
||||||
|
if curr_char == '\n' {
|
||||||
|
horiz_offset = 0.0;
|
||||||
|
char_num = 0;
|
||||||
|
line_num += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_char(module_accessor, curr_char.to_uppercase().collect::<Vec<_>>()[0], line_num, horiz_offset, facing_left);
|
||||||
|
|
||||||
|
char_num += 1;
|
||||||
|
// short characters
|
||||||
|
if curr_char == 'D' || curr_char == '1' {
|
||||||
|
horiz_offset += facing_left * (RAYGUN_LENGTH/2.0 + 3.0);
|
||||||
|
} else {
|
||||||
|
horiz_offset += facing_left * (RAYGUN_LENGTH + 3.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (char_num > 8) {
|
||||||
|
horiz_offset = 0.0;
|
||||||
|
char_num = 0;
|
||||||
|
line_num += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
#![feature(with_options)]
|
#![feature(with_options)]
|
||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
|
#![feature(exclusive_range_pattern)]
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
mod hazard_manager;
|
mod hazard_manager;
|
||||||
|
|
|
@ -45,6 +45,15 @@ unsafe fn is_actionable(module_accessor: *mut app::BattleObjectModuleAccessor) -
|
||||||
|| CancelModule::is_enable_cancel(module_accessor)
|
|| CancelModule::is_enable_cancel(module_accessor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_frame_advantage(module_accessor: *mut app::BattleObjectModuleAccessor, new_frame_adv: i32) {
|
||||||
|
unsafe {
|
||||||
|
FRAME_ADVANTAGE = new_frame_adv;
|
||||||
|
if MENU.frame_advantage == consts::OnOff::On {
|
||||||
|
raygun_printer::print_string(&mut *module_accessor, &format!("{}", FRAME_ADVANTAGE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub unsafe fn is_enable_transition_term(
|
pub unsafe fn is_enable_transition_term(
|
||||||
module_accessor: *mut app::BattleObjectModuleAccessor,
|
module_accessor: *mut app::BattleObjectModuleAccessor,
|
||||||
transition_term: i32,
|
transition_term: i32,
|
||||||
|
@ -74,7 +83,8 @@ pub unsafe fn is_enable_transition_term(
|
||||||
if PLAYER_ACTIONABLE && CPU_ACTIONABLE && FRAME_ADVANTAGE_CHECK {
|
if PLAYER_ACTIONABLE && CPU_ACTIONABLE && FRAME_ADVANTAGE_CHECK {
|
||||||
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
|
let cpu_module_accessor = get_module_accessor(FighterId::CPU);
|
||||||
if was_in_hitstun(cpu_module_accessor) || was_in_shieldstun(cpu_module_accessor) {
|
if was_in_hitstun(cpu_module_accessor) || was_in_shieldstun(cpu_module_accessor) {
|
||||||
FRAME_ADVANTAGE = (CPU_ACTIVE_FRAME as i64 - PLAYER_ACTIVE_FRAME as i64) as i32;
|
update_frame_advantage(module_accessor,
|
||||||
|
(CPU_ACTIVE_FRAME as i64 - PLAYER_ACTIVE_FRAME as i64) as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_counter::stop_counting(FRAME_COUNTER_INDEX);
|
frame_counter::stop_counting(FRAME_COUNTER_INDEX);
|
||||||
|
@ -126,7 +136,8 @@ pub unsafe fn get_command_flag_cat(
|
||||||
// if both are now active
|
// if both are now active
|
||||||
if PLAYER_ACTIONABLE && CPU_ACTIONABLE && FRAME_ADVANTAGE_CHECK {
|
if PLAYER_ACTIONABLE && CPU_ACTIONABLE && FRAME_ADVANTAGE_CHECK {
|
||||||
if was_in_hitstun(cpu_module_accessor) || was_in_shieldstun(cpu_module_accessor) {
|
if was_in_hitstun(cpu_module_accessor) || was_in_shieldstun(cpu_module_accessor) {
|
||||||
FRAME_ADVANTAGE = (CPU_ACTIVE_FRAME as i64 - PLAYER_ACTIVE_FRAME as i64) as i32;
|
update_frame_advantage(player_module_accessor,
|
||||||
|
(CPU_ACTIVE_FRAME as i64 - PLAYER_ACTIVE_FRAME as i64) as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_counter::stop_counting(FRAME_COUNTER_INDEX);
|
frame_counter::stop_counting(FRAME_COUNTER_INDEX);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue