1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 08:54:15 +00:00

Steve save states (#316)

* Mario, Samus, Sheik, GnW, Wii Fit, Hero. Wario incomplete.

* Wario, Mewtwo, Plant

* Rob, Lucario, Squirtle

* Steve, Sora, Incin attempted, all easy ones done

* Steve!

* Donkey Kong

* Most flashes, Samus/Gunner effects

* All except Sheik and DK

* Sheik and DK

* Hero Fix

* First Cleanup

* Cleanup 2

* Full Implementation

* subtract instead of handle

* option tweaking

* made default tools the actual defaults

* remove tar from setup

* prepare for skyline update
This commit is contained in:
GradualSyrup 2022-03-14 18:45:57 -05:00 committed by GitHub
parent e2a5620ee3
commit 01a0d51548
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 155 additions and 6 deletions

View file

@ -1,6 +1,7 @@
use smash::app::{self}; use smash::app::{self};
mod bowser; mod bowser;
pub mod steve;
/** /**
* Checks if the current status matches the expected status * Checks if the current status matches the expected status

View file

@ -0,0 +1,124 @@
use smash::app::{self, lua_bind::*};
use smash::lib::lua_const::*;
#[derive(Copy, Clone)]
pub struct SteveState {
pub mat_g1: i32,
pub mat_wood: i32,
pub mat_stone: i32,
pub mat_iron: i32,
pub mat_gold: i32,
pub mat_redstone: i32,
pub mat_diamond: i32,
pub sword_mat: char, // is actually FighterPickelMaterialKind, but char is same size and works
pub sword_durability: f32,
pub axe_mat: char,
pub axe_durability: f32,
pub pick_mat: char,
pub pick_durability: f32,
pub shovel_mat: char,
pub shovel_durability: f32,
}
fn is_steve(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
let fighter_id;
unsafe {
fighter_id = app::utility::get_kind(module_accessor);
}
fighter_id == *FIGHTER_KIND_PICKEL
}
pub fn save_steve_state(module_accessor: &mut app::BattleObjectModuleAccessor) -> Option<SteveState> {
// Returns None if not Steve, a SteveState if it is
if !is_steve(module_accessor) {
return None;
} else {
unsafe {
Some(save(module_accessor)) // should return the SteveState
}
}
}
pub fn load_steve_state(module_accessor: &mut app::BattleObjectModuleAccessor, steve_state: SteveState) -> bool {
// Returns false if not Steve, true if it is and we've set the variables
if !is_steve(module_accessor) {
return false;
} else {
unsafe {
load(module_accessor, steve_state)
}
return true;
}
}
unsafe fn save(module_accessor: &mut app::BattleObjectModuleAccessor) -> SteveState {
let mat_g1 = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_GRADE_1);
let mat_wood = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_WOOD);
let mat_stone = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_STONE);
let mat_iron = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_IRON);
let mat_gold = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_GOLD);
let mat_redstone = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_RED_STONE);
let mat_diamond = WorkModule::get_int(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_DIAMOND);
let extend_buffer_address = WorkModule::get_int64(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_EXTEND_BUFFER);
let sword_mat = *((extend_buffer_address + (0xC * 0)) as *const char);
let sword_durability = *(((extend_buffer_address + ((0xC * 0) + 4))) as *const f32);
let axe_mat = *((extend_buffer_address + (0xC * 1)) as *const char);
let axe_durability = *(((extend_buffer_address + ((0xC * 1) + 4))) as *const f32);
let pick_mat = *((extend_buffer_address + (0xC * 2)) as *const char);
let pick_durability = *(((extend_buffer_address + ((0xC * 2) + 4))) as *const f32);
let shovel_mat = *((extend_buffer_address + (0xC * 3)) as *const char);
let shovel_durability = *(((extend_buffer_address + ((0xC * 3) + 4))) as *const f32);
SteveState {
mat_g1,
mat_wood,
mat_stone,
mat_iron,
mat_gold,
mat_redstone,
mat_diamond,
sword_mat,
sword_durability,
axe_mat,
axe_durability,
pick_mat,
pick_durability,
shovel_mat,
shovel_durability,
}
}
unsafe fn load(module_accessor: &mut app::BattleObjectModuleAccessor, steve_state: SteveState) {
WorkModule::set_int(module_accessor, steve_state.mat_g1, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_GRADE_1);
WorkModule::set_int(module_accessor, steve_state.mat_wood, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_WOOD);
WorkModule::set_int(module_accessor, steve_state.mat_stone, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_STONE);
WorkModule::set_int(module_accessor, steve_state.mat_iron, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_IRON);
WorkModule::set_int(module_accessor, steve_state.mat_gold, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_GOLD);
WorkModule::set_int(module_accessor, steve_state.mat_redstone, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_RED_STONE);
WorkModule::set_int(module_accessor, steve_state.mat_diamond, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_MATERIAL_NUM_DIAMOND);
let extend_buffer_address = WorkModule::get_int64(module_accessor, *FIGHTER_PICKEL_INSTANCE_WORK_ID_INT_EXTEND_BUFFER);
// We have to grab the address every time instead of saving it, because loading
// a state from a separate training mode instance would cause a crash
*((extend_buffer_address + (0xC * 0)) as *mut char) = steve_state.sword_mat;
*((extend_buffer_address + (0xC * 1)) as *mut char) = steve_state.axe_mat;
*((extend_buffer_address + (0xC * 2)) as *mut char) = steve_state.pick_mat;
*((extend_buffer_address + (0xC * 3)) as *mut char) = steve_state.shovel_mat;
// Update durability
*((extend_buffer_address + (0xC * 0) + 4) as *mut f32) = steve_state.sword_durability;
*((extend_buffer_address + (0xC * 1) + 4) as *mut f32) = steve_state.axe_durability;
*((extend_buffer_address + (0xC * 2) + 4) as *mut f32) = steve_state.pick_durability;
*((extend_buffer_address + (0xC * 3) + 4) as *mut f32) = steve_state.shovel_durability;
// Update UI meter at the bottom by subtracting the materials by 0 after setting them
let mut curr_material = 0;
while curr_material < 7 {
app::FighterSpecializer_Pickel::sub_material_num(module_accessor,curr_material,0);
curr_material += 1;
}
}

View file

@ -6,14 +6,14 @@ use crate::common::is_dead;
use crate::common::MENU; use crate::common::MENU;
use crate::training::buff; use crate::training::buff;
use crate::training::reset; use crate::training::reset;
//use crate::training::charge; use crate::training::charge::{self, ChargeState};
//use crate::training::charge::ChargeState;
use crate::training::charge::{self, ChargeState}; // is this the same as the above 2 lines?
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::*;
use smash::phx::{Hash40, Vector3f}; use smash::phx::{Hash40, Vector3f};
use crate::training::character_specific::steve;
#[derive(PartialEq)] #[derive(PartialEq)]
enum SaveState { enum SaveState {
Save, Save,
@ -33,6 +33,7 @@ struct SavedState {
state: SaveState, state: SaveState,
fighter_kind: i32, fighter_kind: i32,
charge: ChargeState, charge: ChargeState,
steve_state: Option<steve::SteveState>,
} }
macro_rules! default_save_state { macro_rules! default_save_state {
@ -51,8 +52,25 @@ macro_rules! default_save_state {
float_x: None, float_x: None,
float_y: None, float_y: None,
float_z: None, float_z: None,
has_charge: None has_charge: None,
} },
steve_state: Some(steve::SteveState {
mat_g1: 36,
mat_wood: 18,
mat_stone: 0,
mat_iron: 3,
mat_gold: 0,
mat_redstone: 2,
mat_diamond: 0,
sword_mat: 1 as char,
sword_durability: 25.0,
axe_mat: 1 as char,
axe_durability: 70.0,
pick_mat: 1 as char,
pick_durability: 70.0,
shovel_mat: 1 as char,
shovel_durability: 70.0,
}),
} }
}; };
} }
@ -288,6 +306,10 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
if fighter_is_buffable { if fighter_is_buffable {
save_state.state = ApplyBuff; save_state.state = ApplyBuff;
} }
// Perform fighter specific loading actions
save_state.steve_state.map(|load_steve| {
steve::load_steve_state(module_accessor,load_steve);
});
// Play Training Reset SFX, since silence is eerie // Play Training Reset SFX, since silence is eerie
// Only play for the CPU so we don't have 2 overlapping // Only play for the CPU so we don't have 2 overlapping
if is_cpu { if is_cpu {
@ -345,6 +367,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
// Always store fighter kind so that charges are handled properly // Always store fighter kind so that charges are handled properly
save_state.fighter_kind = app::utility::get_kind(module_accessor); save_state.fighter_kind = app::utility::get_kind(module_accessor);
save_state.charge = charge::get_charge(module_accessor, fighter_kind); save_state.charge = charge::get_charge(module_accessor, fighter_kind);
// Perform fighter specific saving actions
save_state.steve_state = steve::save_steve_state(module_accessor);
let zeros = Vector3f { let zeros = Vector3f {
x: 0.0, x: 0.0,