Skip to content

Commit

Permalink
Side dashing mp2
Browse files Browse the repository at this point in the history
  • Loading branch information
vyuuui committed Aug 26, 2024
1 parent 50c96c9 commit b7d7255
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
16 changes: 15 additions & 1 deletion mp2/compute_move.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ float gravboost_force = 13000.f;
float crouch_height = 1.5f;
// Speed damping for crouching samus
float crouch_max_speed_damp = 0.5f;
// Impulse to apply for each side dash
float side_dash_impulse = 10.f;
// Amount to reduce the height of the side dash by
float side_dash_jump_height_reduction = 0.5f;

char debug_output[2048];
}
Expand Down Expand Up @@ -329,7 +333,17 @@ void hooked_computemovement(CPlayer* player, CFinalInput* input, CStateManager&
num_jumps == 2 && water_depth < 1.25f;
const bool gravboost_jump = jump_this_tick && has_gravboost && num_jumps == 2;
if (first_jump || second_jump) {
vel.z = jump_impulse * jump_restraint_table[static_cast<int>(restraint)];
float side_input =
get_analog_input(player->get_input_mask(), ECommands::TurnOrLookRight, input) -
get_analog_input(player->get_input_mask(), ECommands::TurnOrLookLeft, input);
if (player->get_orbit_state() != EPlayerOrbitState::NoOrbit && fabs(side_input) > 0.05) {
vec3 rt = player->get_transform().right() * side_input * side_dash_impulse;
vel += rt;
vel.z = jump_impulse * jump_restraint_table[static_cast<int>(restraint)] *
side_dash_jump_height_reduction;
} else {
vel.z = jump_impulse * jump_restraint_table[static_cast<int>(restraint)];
}
vel += half_grav;
player->set_move_state(EPlayerMovementState::Jump, mgr);
player->set_velocity_wr(vel);
Expand Down
18 changes: 15 additions & 3 deletions mp2/mpsdk/player.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ enum class EPlayerMorphBallState { Unmorphed, Morphed, Morphing, Unmorphing };
// There's more of em, though for the most part they don't matter
enum class ESurfaceRestraints { Normal, Air, Unk0, Unk1, Unk2, Water, DarkWater, TheWeeds };

enum class EPlayerOrbitState {
NoOrbit,
OrbitObject,
OrbitPoint,
OrbitCarcass,
ForcedOrbitObject, // For CMetroidBeta attack
Grapple
};

class CPlayer : public CPhysicsActor {
public:
EPlayerMovementState movement_state; // 2d0
Expand Down Expand Up @@ -41,11 +50,13 @@ public:
aabox fp_bounds; // 36c
uint8_t cplayer_unk4[0x8]; // 384
EPlayerMorphBallState morphball_state; // 38c
uint8_t cplayer_unk5[0xeb8]; // 390
uint8_t cplayer_unk5[0x14]; // 390
EPlayerOrbitState orbit_state; // 3a4
uint8_t cplayer_unk6[0xea0]; // 3a8
float water_depth; // 1248
uint8_t cplayer_unk6[0xc8]; // 124c
uint8_t cplayer_unk7[0xc8]; // 124c
CPlayerState* player_state; // 1314
uint8_t cplayer_unk7[0xb8]; // 1318
uint8_t cplayer_unk8[0xb8]; // 1318
rstl::reserved_vector<bool, 0x4c> player_input_mask; // 13d0

public:
Expand All @@ -57,6 +68,7 @@ public:
void set_fpbounds_z(float z) { fp_bounds.maxes.z = z; }
float get_fpbounds_z() { return fp_bounds.maxes.z; }
void* get_collision_prim() { return &collision_primitive; }
EPlayerOrbitState get_orbit_state() { return orbit_state; }
CPlayerState const* get_player_state() const { return player_state; }
CPlayerState* get_player_state() { return player_state; }
float get_water_depth() const { return water_depth; }
Expand Down
2 changes: 2 additions & 0 deletions mp2/source_movement_mp2.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<cvar> rocket_jump_speed_falloff_max f32
<cvar> rocket_jump_speed_falloff_min f32
<cvar> rocket_jump_max_damage f32
<cvar> side_dash_impulse f32
<cvar> side_dash_jump_height_reduction f32
<vthook> hooked_energyprojectile_think 803b2fe0
<trampoline> hooked_computemovement 801883ec
<callgate> _callgate_table _mod_dispatch_table _callgate_dispatch _trampoline_restore_table
Expand Down

0 comments on commit b7d7255

Please # to comment.