mirror of https://github.com/AxioDL/metaforce.git
Implement CPlayer::UpdateGrappleState
This commit is contained in:
parent
a71e48cf43
commit
4017f2acdd
|
@ -37,6 +37,7 @@ struct ITweakPlayer : ITweak
|
|||
virtual float GetPlayerBallHalfExtent() const=0; // x27c
|
||||
virtual float GetGrappleSwingPeriod() const=0;
|
||||
virtual float GetGrappleJumpForce() const=0;
|
||||
virtual float GetGrappleReleaseTime() const=0;
|
||||
virtual uint32_t GetGrappleJumpMode() const=0;
|
||||
virtual float GetX124() const=0; // x134
|
||||
virtual float GetX184() const=0; // x184
|
||||
|
|
|
@ -383,8 +383,8 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader)
|
|||
x2c4_ = __dna_reader.readFloatBig();
|
||||
/* x2c8_grappleJumpForce */
|
||||
x2c8_grappleJumpForce = __dna_reader.readFloatBig();
|
||||
/* x2cc_ */
|
||||
x2cc_ = __dna_reader.readFloatBig();
|
||||
/* x2cc_grappleReleaseTime */
|
||||
x2cc_grappleReleaseTime = __dna_reader.readFloatBig();
|
||||
/* x2d0_grappleJumpMode */
|
||||
x2d0_grappleJumpMode = __dna_reader.readUint32Big();
|
||||
/* x2d4_ */
|
||||
|
@ -823,8 +823,8 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const
|
|||
__dna_writer.writeFloatBig(x2c4_);
|
||||
/* x2c8_grappleJumpForce */
|
||||
__dna_writer.writeFloatBig(x2c8_grappleJumpForce);
|
||||
/* x2cc_ */
|
||||
__dna_writer.writeFloatBig(x2cc_);
|
||||
/* x2cc_grappleReleaseTime */
|
||||
__dna_writer.writeFloatBig(x2cc_grappleReleaseTime);
|
||||
/* x2d0_grappleJumpMode */
|
||||
__dna_writer.writeUint32Big(x2d0_grappleJumpMode);
|
||||
/* x2d4_ */
|
||||
|
@ -1338,8 +1338,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin)
|
|||
x2c4_ = __dna_docin.readFloat("x2c4_");
|
||||
/* x2c8_grappleJumpForce */
|
||||
x2c8_grappleJumpForce = __dna_docin.readFloat("x2c8_grappleJumpForce");
|
||||
/* x2cc_ */
|
||||
x2cc_ = __dna_docin.readFloat("x2cc_");
|
||||
/* x2cc_grappleReleaseTime */
|
||||
x2cc_grappleReleaseTime = __dna_docin.readFloat("x2cc_grappleReleaseTime");
|
||||
/* x2d0_grappleJumpMode */
|
||||
x2d0_grappleJumpMode = __dna_docin.readUint32("x2d0_grappleJumpMode");
|
||||
/* x2d4_ */
|
||||
|
@ -1838,8 +1838,8 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const
|
|||
__dna_docout.writeFloat("x2c4_", x2c4_);
|
||||
/* x2c8_grappleJumpForce */
|
||||
__dna_docout.writeFloat("x2c8_grappleJumpForce", x2c8_grappleJumpForce);
|
||||
/* x2cc_ */
|
||||
__dna_docout.writeFloat("x2cc_", x2cc_);
|
||||
/* x2cc_grappleReleaseTime */
|
||||
__dna_docout.writeFloat("x2cc_grappleReleaseTime", x2cc_grappleReleaseTime);
|
||||
/* x2d0_grappleJumpMode */
|
||||
__dna_docout.writeUint32("x2d0_grappleJumpMode", x2d0_grappleJumpMode);
|
||||
/* x2d4_ */
|
||||
|
|
|
@ -158,7 +158,7 @@ struct CTweakPlayer : ITweakPlayer
|
|||
Value<float> x2c0_;
|
||||
Value<float> x2c4_;
|
||||
Value<float> x2c8_grappleJumpForce;
|
||||
Value<float> x2cc_;
|
||||
Value<float> x2cc_grappleReleaseTime;
|
||||
Value<atUint32> x2d0_grappleJumpMode;
|
||||
Value<bool> x2d4_;
|
||||
Value<bool> x2d5_;
|
||||
|
@ -202,6 +202,7 @@ struct CTweakPlayer : ITweakPlayer
|
|||
float GetPlayerBallHalfExtent() const { return x27c_playerBallHalfExtent; }
|
||||
float GetGrappleSwingPeriod() const { return x2a8_grappleSwingPeriod; }
|
||||
float GetGrappleJumpForce() const { return x2c8_grappleJumpForce; }
|
||||
float GetGrappleReleaseTime() const { return x2cc_grappleReleaseTime; }
|
||||
uint32_t GetGrappleJumpMode() const { return x2d0_grappleJumpMode; }
|
||||
float GetX124() const { return x134_; }
|
||||
float GetX184() const { return x184_; }
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
LookRight,
|
||||
LookUp,
|
||||
LookDown,
|
||||
JumpOrBoost,
|
||||
FireOrBomb,
|
||||
MissileOrPowerBomb,
|
||||
JumpOrBoost = 10,
|
||||
FireOrBomb = 11,
|
||||
MissileOrPowerBomb = 12,
|
||||
Morph,
|
||||
AimUp,
|
||||
AimDown,
|
||||
|
|
|
@ -16,4 +16,19 @@ void CGrappleArm::SetAnimState(EArmState state)
|
|||
|
||||
}
|
||||
|
||||
void CGrappleArm::Activate(bool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGrappleArm::GrappleBeamDisconnected()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGrappleArm::GrappleBeamConnected()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,11 +26,26 @@ public:
|
|||
private:
|
||||
CModelData x0_modelData;
|
||||
zeus::CTransform x220_;
|
||||
EArmState x334_animState;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
bool x3b2_25_beamActive : 1;
|
||||
};
|
||||
u32 _dummy = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
CGrappleArm(const zeus::CVector3f& vec);
|
||||
void AsyncLoadSuit(CStateManager& mgr);
|
||||
void SetX220(const zeus::CTransform& xf) { x220_ = xf; }
|
||||
void SetAnimState(EArmState state);
|
||||
EArmState GetAnimState() const { return x334_animState; }
|
||||
bool BeamActive() const { return x3b2_25_beamActive; }
|
||||
void Activate(bool);
|
||||
void GrappleBeamDisconnected();
|
||||
void GrappleBeamConnected();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
namespace urde
|
||||
{
|
||||
|
||||
static const CMaterialFilter SolidMaterialFilter =
|
||||
CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid));
|
||||
|
||||
static const CMaterialFilter TargetingFilter =
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid},
|
||||
{EMaterialTypes::ProjectilePassthrough,
|
||||
EMaterialTypes::ScanPassthrough,
|
||||
EMaterialTypes::Player});
|
||||
|
||||
static CModelData MakePlayerAnimRes(ResId resId, const zeus::CVector3f& scale)
|
||||
{
|
||||
return {CAnimRes(resId, 0, scale, 0, true), 1};
|
||||
|
@ -948,9 +957,6 @@ static const u16 skPlayerLandSfxHard[] =
|
|||
0x064B, 0x064F, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0652, 0x064D
|
||||
};
|
||||
|
||||
static const CMaterialFilter SolidMaterialFilter =
|
||||
CMaterialFilter::MakeInclude(CMaterialList(EMaterialTypes::Solid));
|
||||
|
||||
void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr)
|
||||
{
|
||||
switch (msg)
|
||||
|
@ -1379,7 +1385,221 @@ void CPlayer::ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, f
|
|||
|
||||
bool CPlayer::ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr) { return false; }
|
||||
|
||||
void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) {}
|
||||
void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr)
|
||||
{
|
||||
if (!mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GrappleBeam) ||
|
||||
x2f8_morphTransState == EPlayerMorphBallState::Morphed ||
|
||||
mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan ||
|
||||
mgr.GetPlayerState()->GetTransitioningVisor() == CPlayerState::EPlayerVisor::Scan)
|
||||
return;
|
||||
|
||||
if (x310_orbitTargetId == kInvalidUniqueId)
|
||||
{
|
||||
x3b8_grappleState = EGrappleState::Zero;
|
||||
AddMaterial(EMaterialTypes::GroundCollider, mgr);
|
||||
return;
|
||||
}
|
||||
|
||||
TCastToPtr<CScriptGrapplePoint> point = mgr.ObjectById(x310_orbitTargetId);
|
||||
if (point)
|
||||
{
|
||||
zeus::CVector3f eyePosition = GetEyePosition();
|
||||
zeus::CVector3f playerToPoint = point->GetTranslation() - eyePosition;
|
||||
zeus::CVector3f playerToPointFlat = playerToPoint;
|
||||
playerToPointFlat.z = 0.f;
|
||||
if (playerToPoint.canBeNormalized() && playerToPointFlat.canBeNormalized() &&
|
||||
playerToPointFlat.magnitude() > 2.f)
|
||||
{
|
||||
switch (x304_orbitState)
|
||||
{
|
||||
case EPlayerOrbitState::Five:
|
||||
switch (g_tweakPlayer->GetGrappleJumpMode())
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
if (ControlMapper::GetPressInput(ControlMapper::ECommands::FireOrBomb, input))
|
||||
{
|
||||
if (TCastToPtr<CScriptGrapplePoint> point2 = mgr.ObjectById(x33c_))
|
||||
{
|
||||
playerToPoint = point2->GetTranslation() - eyePosition;
|
||||
playerToPoint.z = 0.f;
|
||||
if (playerToPoint.canBeNormalized())
|
||||
{
|
||||
x490_gun->GetGrappleArm().GrappleBeamDisconnected();
|
||||
x3c0_grappleSwingAxis.x = playerToPoint.y;
|
||||
x3c0_grappleSwingAxis.y = -playerToPoint.x;
|
||||
x3c0_grappleSwingAxis.normalize();
|
||||
x3bc_grappleSwingTimer = 0.f;
|
||||
SetOrbitTargetId(x33c_, mgr);
|
||||
x3b8_grappleState = EGrappleState::Two;
|
||||
x33c_ = kInvalidUniqueId;
|
||||
x490_gun->GetGrappleArm().GrappleBeamConnected();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!g_tweakPlayer->GetGrappleJumpMode() && x3d8_grappleJumpTimeout <= 0.f)
|
||||
ApplyGrappleJump(mgr);
|
||||
BreakGrapple(EPlayerOrbitRequest::Zero, mgr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case EPlayerOrbitState::One:
|
||||
if (playerToPoint.canBeNormalized())
|
||||
{
|
||||
CRayCastResult result =
|
||||
mgr.RayStaticIntersection(eyePosition, playerToPoint.normalized(), playerToPoint.magnitude(),
|
||||
TargetingFilter);
|
||||
if (result.IsInvalid())
|
||||
{
|
||||
HolsterGun(mgr);
|
||||
switch (x3b8_grappleState)
|
||||
{
|
||||
case EGrappleState::One:
|
||||
case EGrappleState::Three:
|
||||
switch (g_tweakPlayer->GetGrappleJumpMode())
|
||||
{
|
||||
case 0:
|
||||
switch (x490_gun->GetGrappleArm().GetAnimState())
|
||||
{
|
||||
case CGrappleArm::EArmState::One:
|
||||
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input))
|
||||
x490_gun->GetGrappleArm().SetAnimState(CGrappleArm::EArmState::Two);
|
||||
break;
|
||||
case CGrappleArm::EArmState::Six:
|
||||
BeginGrapple(playerToPoint, mgr);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input))
|
||||
{
|
||||
switch (x490_gun->GetGrappleArm().GetAnimState())
|
||||
{
|
||||
case CGrappleArm::EArmState::One:
|
||||
x490_gun->GetGrappleArm().SetAnimState(CGrappleArm::EArmState::Two);
|
||||
break;
|
||||
case CGrappleArm::EArmState::Six:
|
||||
BeginGrapple(playerToPoint, mgr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch (x490_gun->GetGrappleArm().GetAnimState())
|
||||
{
|
||||
case CGrappleArm::EArmState::One:
|
||||
x490_gun->GetGrappleArm().SetAnimState(CGrappleArm::EArmState::Two);
|
||||
break;
|
||||
case CGrappleArm::EArmState::Six:
|
||||
BeginGrapple(playerToPoint, mgr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EGrappleState::Zero:
|
||||
x3b8_grappleState = EGrappleState::One;
|
||||
x490_gun->GetGrappleArm().Activate(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (x304_orbitState != EPlayerOrbitState::Five)
|
||||
{
|
||||
if (x304_orbitState >= EPlayerOrbitState::Five)
|
||||
return;
|
||||
if (x304_orbitState != EPlayerOrbitState::One)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!point)
|
||||
{
|
||||
BreakGrapple(EPlayerOrbitRequest::Three, mgr);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (g_tweakPlayer->GetGrappleJumpMode())
|
||||
{
|
||||
case 0:
|
||||
if (x3b8_grappleState == EGrappleState::Four)
|
||||
{
|
||||
x3d8_grappleJumpTimeout -= input.DeltaTime();
|
||||
if (x3d8_grappleJumpTimeout <= 0.f)
|
||||
{
|
||||
BreakGrapple(EPlayerOrbitRequest::Zero, mgr);
|
||||
SetMoveState(EPlayerMovementState::StartingJump, mgr);
|
||||
ComputeMovement(input, mgr, input.DeltaTime());
|
||||
PreventFallingCameraPitch();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
switch (x3b8_grappleState)
|
||||
{
|
||||
case EGrappleState::Three:
|
||||
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) &&
|
||||
x3d8_grappleJumpTimeout <= 0.f)
|
||||
{
|
||||
x3d8_grappleJumpTimeout = g_tweakPlayer->GetGrappleReleaseTime();
|
||||
x3b8_grappleState = EGrappleState::Four;
|
||||
ApplyGrappleJump(mgr);
|
||||
}
|
||||
break;
|
||||
case EGrappleState::Four:
|
||||
x3d8_grappleJumpTimeout -= input.DeltaTime();
|
||||
if (x3d8_grappleJumpTimeout <= 0.f)
|
||||
{
|
||||
SetMoveState(EPlayerMovementState::StartingJump, mgr);
|
||||
ComputeMovement(input, mgr, input.DeltaTime());
|
||||
BreakGrapple(EPlayerOrbitRequest::Zero, mgr);
|
||||
PreventFallingCameraPitch();
|
||||
}
|
||||
break;
|
||||
case EGrappleState::One:
|
||||
case EGrappleState::Two:
|
||||
if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input))
|
||||
BreakGrapple(EPlayerOrbitRequest::Zero, mgr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
zeus::CVector3f eyePos = GetEyePosition();
|
||||
zeus::CVector3f playerToPoint = point->GetTranslation() - eyePos;
|
||||
if (playerToPoint.canBeNormalized())
|
||||
{
|
||||
CRayCastResult result =
|
||||
mgr.RayStaticIntersection(eyePos, playerToPoint.normalized(), playerToPoint.magnitude(),
|
||||
TargetingFilter);
|
||||
if (result.IsValid())
|
||||
{
|
||||
BreakGrapple(EPlayerOrbitRequest::Twelve, mgr);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (x490_gun->GetGrappleArm().BeamActive() && g_tweakPlayer->GetGrappleJumpMode() == 1 &&
|
||||
!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input))
|
||||
BreakGrapple(EPlayerOrbitRequest::Zero, mgr);
|
||||
}
|
||||
|
||||
void CPlayer::ApplyGrappleJump(CStateManager& mgr)
|
||||
{
|
||||
|
|
|
@ -68,7 +68,8 @@ public:
|
|||
Eight,
|
||||
Nine,
|
||||
Ten,
|
||||
Eleven
|
||||
Eleven,
|
||||
Twelve
|
||||
};
|
||||
|
||||
enum class EOrbitObjectType
|
||||
|
|
Loading…
Reference in New Issue