mirror of https://github.com/AxioDL/metaforce.git
CTryclops: Fixes & cleanup
This commit is contained in:
parent
dbd52f8917
commit
a2bcb4d086
|
@ -47,18 +47,16 @@ void CTryclops::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM
|
||||||
|
|
||||||
void CTryclops::Think(float dt, CStateManager& mgr) {
|
void CTryclops::Think(float dt, CStateManager& mgr) {
|
||||||
CPatterned::Think(dt, mgr);
|
CPatterned::Think(dt, mgr);
|
||||||
|
if (x400_25_alive && x68c_ > 0.f) {
|
||||||
if (x400_25_alive && x68c_ > 0.f)
|
|
||||||
x68c_ -= dt;
|
x68c_ -= dt;
|
||||||
|
}
|
||||||
if (mgr.GetPlayer().GetAttachedActor() != GetUniqueId() || x698_27_dizzy)
|
if (mgr.GetPlayer().GetAttachedActor() != GetUniqueId() || x698_27_dizzy) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
x698_27_dizzy = (mgr.GetPlayer().GetAttachedActorStruggle() == 1.f && sub8025dbd0(mgr));
|
x698_27_dizzy = (mgr.GetPlayer().GetAttachedActorStruggle() == 1.f && sub8025dbd0(mgr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& poi, EUserEventType type, float dt) {
|
void CTryclops::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& poi, EUserEventType type, float dt) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EUserEventType::Projectile:
|
case EUserEventType::Projectile:
|
||||||
if (x694_bombId == kInvalidUniqueId) {
|
if (x694_bombId == kInvalidUniqueId) {
|
||||||
|
@ -94,7 +92,6 @@ void CTryclops::Death(CStateManager& mgr, const zeus::CVector3f& vec, EScriptObj
|
||||||
|
|
||||||
void CTryclops::Patrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::Patrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
CPatterned::Patrol(mgr, msg, arg);
|
CPatterned::Patrol(mgr, msg, arg);
|
||||||
|
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
|
@ -104,11 +101,10 @@ void CTryclops::Patrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
|
|
||||||
void CTryclops::PathFind(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::PathFind(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
CPatterned::PathFind(mgr, msg, arg);
|
CPatterned::PathFind(mgr, msg, arg);
|
||||||
|
const auto moveVec = x450_bodyController->GetCommandMgr().GetMoveVector();
|
||||||
zeus::CVector3f front = GetTransform().basis[1];
|
if (GetTransform().frontVector().dot(moveVec) < 0.f && moveVec.canBeNormalized()) {
|
||||||
if (front.dot(x450_bodyController->GetCommandMgr().GetMoveVector()) < 0.f && front.canBeNormalized()) {
|
|
||||||
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
||||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(front.normalized(), {}, 1.f));
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, moveVec.normalized(), 1.f));
|
||||||
}
|
}
|
||||||
ApplySeparation(mgr);
|
ApplySeparation(mgr);
|
||||||
}
|
}
|
||||||
|
@ -125,16 +121,15 @@ void CTryclops::SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate)
|
if (msg == EStateMsg::Activate) {
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
||||||
|
}
|
||||||
CPatterned::TargetPatrol(mgr, msg, arg);
|
CPatterned::TargetPatrol(mgr, msg, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::TargetPlayer(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::TargetPlayer(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
CPatterned::TargetPlayer(mgr, msg, arg);
|
CPatterned::TargetPlayer(mgr, msg, arg);
|
||||||
|
if (msg == EStateMsg::Activate && x694_bombId != kInvalidUniqueId) {
|
||||||
if (msg == EStateMsg::Update && x694_bombId != kInvalidUniqueId) {
|
|
||||||
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId)) {
|
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId)) {
|
||||||
bomb->SetFuseDisabled(false);
|
bomb->SetFuseDisabled(false);
|
||||||
bomb->SetIsBeingDragged(false);
|
bomb->SetIsBeingDragged(false);
|
||||||
|
@ -144,51 +139,57 @@ void CTryclops::TargetPlayer(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::TargetCover(CStateManager& mgr, EStateMsg msg, float) {
|
void CTryclops::TargetCover(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
if (msg == EStateMsg::Update) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
||||||
if (x694_bombId == kInvalidUniqueId)
|
if (x694_bombId == kInvalidUniqueId) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(x694_bombId))
|
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(x694_bombId)) {
|
||||||
SetDestPos(bomb->GetTranslation());
|
SetDestPos(bomb->GetTranslation());
|
||||||
else
|
} else {
|
||||||
x694_bombId = kInvalidUniqueId;
|
x694_bombId = kInvalidUniqueId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
|
auto& player = mgr.GetPlayer();
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
mgr.GetPlayer().Stop();
|
player.Stop();
|
||||||
mgr.GetPlayer().RemoveMaterial(EMaterialTypes::Solid, mgr);
|
player.RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
player.SetLeaveMorphBallAllowed(false);
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
x698_24_ = false;
|
x698_24_ = false;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 1);
|
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 1);
|
||||||
if (!x698_24_)
|
if (!x698_24_) {
|
||||||
DragPlayer(mgr, GetLctrTransform("bombGrab_locator"sv).origin);
|
DragPlayer(mgr, GetLctrTransform("bombGrab_locator"sv).origin);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId())
|
if (player.GetAttachedActor() == GetUniqueId()) {
|
||||||
mgr.GetPlayer().DetachActorFromPlayer();
|
player.DetachActorFromPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
mgr.GetPlayer().AddMaterial(EMaterialTypes::Solid, mgr);
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::JumpBack(CStateManager& mgr, EStateMsg msg, float) {
|
void CTryclops::JumpBack(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
if (TCastToConstPtr<CActor> wp = mgr.GetObjectById(GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
|
if (TCastToConstPtr<CActor> wp =
|
||||||
|
mgr.GetObjectById(GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
|
||||||
SetDestPos(wp->GetTranslation());
|
SetDestPos(wp->GetTranslation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x694_bombId != kInvalidUniqueId) {
|
if (x694_bombId != kInvalidUniqueId) {
|
||||||
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId))
|
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId)) {
|
||||||
bomb->SetFuseDisabled(false);
|
bomb->SetFuseDisabled(false);
|
||||||
else
|
} else {
|
||||||
x694_bombId = kInvalidUniqueId;
|
x694_bombId = kInvalidUniqueId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
|
||||||
|
@ -209,58 +210,64 @@ void CTryclops::TurnAround(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TUniqueId uid = GetWaypointForState(mgr, EScriptObjectState::Modify, EScriptObjectMessage::Follow);
|
TUniqueId uid = GetWaypointForState(mgr, EScriptObjectState::Modify, EScriptObjectMessage::Follow);
|
||||||
bool retreat = false;
|
bool retreat = uid == kInvalidUniqueId;
|
||||||
if (uid == kInvalidUniqueId) {
|
if (retreat) {
|
||||||
uid = GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow);
|
uid = GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow);
|
||||||
retreat = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TCastToConstPtr<CActor> wp = mgr.GetObjectById(uid)) {
|
if (TCastToConstPtr<CActor> wp = mgr.GetObjectById(uid)) {
|
||||||
zeus::CVector3f destVec =
|
zeus::CVector3f destVec =
|
||||||
(retreat ? wp->GetTransform().basis[1] : GetTranslation() - wp->GetTranslation()).normalized();
|
(retreat ? wp->GetTransform().frontVector() : wp->GetTranslation() - GetTranslation()).normalized();
|
||||||
destVec.z() = 0.f;
|
destVec.z() = 0.f;
|
||||||
SetDestPos(GetTranslation() + destVec);
|
SetDestPos(GetTranslation() + destVec);
|
||||||
|
|
||||||
if (std::fabs(zeus::CVector3f(GetTransform().basis[1].x(), GetTransform().basis[1].y(), 0.f).dot(destVec)) < 0.9998)
|
if (std::fabs(
|
||||||
|
zeus::CVector3f(GetTransform().frontVector().x(), GetTransform().frontVector().y(), 0.f).dot(destVec)) <
|
||||||
|
0.9998) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::Turn, &CPatterned::TryTurn, 0);
|
TryCommand(mgr, pas::EAnimationState::Turn, &CPatterned::TryTurn, 0);
|
||||||
|
|
||||||
if (x694_bombId == kInvalidUniqueId)
|
if (x694_bombId == kInvalidUniqueId) {
|
||||||
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
||||||
else
|
} else {
|
||||||
GrabBomb(mgr);
|
GrabBomb(mgr);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
mgr.GetPlayer().AddMaterial(EMaterialTypes::Solid, mgr);
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId())
|
if (player.GetAttachedActor() == GetUniqueId()) {
|
||||||
mgr.GetPlayer().DetachActorFromPlayer();
|
player.DetachActorFromPlayer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::Crouch(CStateManager& mgr, EStateMsg msg, float) {
|
void CTryclops::Crouch(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
|
auto& player = mgr.GetPlayer();
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
if (TCastToConstPtr<CActor> wp =
|
if (TCastToConstPtr<CActor> wp =
|
||||||
mgr.GetObjectById(GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
|
mgr.GetObjectById(GetWaypointForState(mgr, EScriptObjectState::Retreat, EScriptObjectMessage::Follow))) {
|
||||||
SetDestPos(wp->GetTranslation());
|
SetDestPos(wp->GetTranslation());
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr.GetPlayer().Stop();
|
player.Stop();
|
||||||
mgr.GetPlayer().RemoveMaterial(EMaterialTypes::Solid, mgr);
|
player.RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||||
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Inside, mgr, EScriptObjectMessage::None);
|
||||||
mgr.GetPlayer().AttachActorToPlayer(GetUniqueId(), true);
|
player.AttachActorToPlayer(GetUniqueId(), true);
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
player.SetLeaveMorphBallAllowed(false);
|
||||||
mgr.GetPlayer().GetMorphBall()->DisableHalfPipeStatus();
|
player.GetMorphBall()->DisableHalfPipeStatus();
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId())
|
if (player.GetAttachedActor() == GetUniqueId()) {
|
||||||
mgr.GetPlayer().DetachActorFromPlayer();
|
player.DetachActorFromPlayer();
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
}
|
||||||
mgr.GetPlayer().AddMaterial(EMaterialTypes::Solid, mgr);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,27 +286,29 @@ void CTryclops::GetUp(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::Suck(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::Suck(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
|
auto& player = mgr.GetPlayer();
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
player.SetLeaveMorphBallAllowed(false);
|
||||||
mgr.GetPlayer().GetMorphBall()->DisableHalfPipeStatus();
|
player.GetMorphBall()->DisableHalfPipeStatus();
|
||||||
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Internal6);
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Internal6);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
SuckPlayer(mgr, arg);
|
SuckPlayer(mgr, arg);
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
mgr.GetPlayer().AddMaterial(EMaterialTypes::Solid, mgr);
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::Cover(CStateManager& mgr, EStateMsg msg, float) {
|
void CTryclops::Cover(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
if (!x698_25_)
|
if (!x698_25_) {
|
||||||
x68c_ = 1.5f;
|
x68c_ = 1.5f;
|
||||||
|
}
|
||||||
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId()) {
|
auto& player = mgr.GetPlayer();
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(true);
|
if (player.GetAttachedActor() == GetUniqueId()) {
|
||||||
mgr.GetPlayer().AddMaterial(EMaterialTypes::Solid, mgr);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
mgr.GetPlayer().DetachActorFromPlayer();
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
|
player.DetachActorFromPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,18 +316,20 @@ void CTryclops::Cover(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
void CTryclops::Approach(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::Approach(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
CPatterned::PathFind(mgr, msg, arg);
|
CPatterned::PathFind(mgr, msg, arg);
|
||||||
ApplySeparation(mgr);
|
ApplySeparation(mgr);
|
||||||
if (msg == EStateMsg::Update)
|
if (msg == EStateMsg::Update) {
|
||||||
GrabBomb(mgr);
|
GrabBomb(mgr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::PathFindEx(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CTryclops::PathFindEx(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
CPatterned::PathFind(mgr, msg, arg);
|
CPatterned::PathFind(mgr, msg, arg);
|
||||||
ApplySeparation(mgr);
|
ApplySeparation(mgr);
|
||||||
|
|
||||||
CPlayer& player = mgr.GetPlayer();
|
auto& player = mgr.GetPlayer();
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
player.Stop();
|
player.Stop();
|
||||||
player.RemoveMaterial(EMaterialTypes::Solid, mgr);
|
player.RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||||
|
player.SetLeaveMorphBallAllowed(false);
|
||||||
player.GetMorphBall()->DisableHalfPipeStatus();
|
player.GetMorphBall()->DisableHalfPipeStatus();
|
||||||
player.AttachActorToPlayer(GetUniqueId(), true);
|
player.AttachActorToPlayer(GetUniqueId(), true);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
|
@ -327,30 +338,34 @@ void CTryclops::PathFindEx(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::Dizzy(CStateManager& mgr, EStateMsg msg, float) {
|
void CTryclops::Dizzy(CStateManager& mgr, EStateMsg msg, float) {
|
||||||
|
auto& player = mgr.GetPlayer();
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
mgr.GetPlayer().Stop();
|
player.Stop();
|
||||||
mgr.GetPlayer().RemoveMaterial(EMaterialTypes::Solid, mgr);
|
player.RemoveMaterial(EMaterialTypes::Solid, mgr);
|
||||||
mgr.GetPlayer().SetLeaveMorphBallAllowed(false);
|
player.SetLeaveMorphBallAllowed(false);
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
x698_24_ = false;
|
x698_24_ = false;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 0);
|
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 0);
|
||||||
if (!x698_24_)
|
if (!x698_24_) {
|
||||||
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
DragPlayer(mgr, GetLctrTransform("ballGrab_locator"sv).origin);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
if (mgr.GetPlayer().GetAttachedActor() == GetUniqueId()) {
|
if (player.GetAttachedActor() == GetUniqueId()) {
|
||||||
mgr.GetPlayer().DetachActorFromPlayer();
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
|
player.DetachActorFromPlayer();
|
||||||
x698_27_dizzy = false;
|
x698_27_dizzy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTryclops::InAttackPosition(CStateManager& mgr, float) {
|
bool CTryclops::InAttackPosition(CStateManager& mgr, float) {
|
||||||
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
|
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
CPlayer& player = mgr.GetPlayer();
|
auto& player = mgr.GetPlayer();
|
||||||
return sub80260180(player.GetTranslation(),
|
return sub80260180(player.GetTranslation(),
|
||||||
player.GetTranslation() + zeus::CVector3f(0.f, 0.f, player.GetMorphBall()->GetBallRadius()),
|
player.GetTranslation() + zeus::CVector3f(0.f, 0.f, player.GetMorphBall()->GetBallRadius()),
|
||||||
player.GetBoundingBox(), mgr);
|
player.GetBoundingBox(), mgr);
|
||||||
|
@ -362,32 +377,34 @@ bool CTryclops::InRange(CStateManager& mgr, float) {
|
||||||
return sub80260180(bomb->GetTranslation(), bomb->GetTranslation(), *bomb->GetTouchBounds(), mgr);
|
return sub80260180(bomb->GetTranslation(), bomb->GetTranslation(), *bomb->GetTouchBounds(), mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTryclops::InMaxRange(CStateManager& mgr, float) {
|
bool CTryclops::InMaxRange(CStateManager& mgr, float) {
|
||||||
if (x694_bombId != kInvalidUniqueId)
|
if (x694_bombId != kInvalidUniqueId) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
||||||
|
|
||||||
float dectRange = x3bc_detectionRange * x3bc_detectionRange;
|
float dectRange = x3bc_detectionRange * x3bc_detectionRange;
|
||||||
float dectRangeHeight = x3c0_detectionHeightRange * x3c0_detectionHeightRange;
|
float dectRangeHeight = x3c0_detectionHeightRange * x3c0_detectionHeightRange;
|
||||||
mgr.BuildNearList(nearList, {GetTranslation() - x3bc_detectionRange, GetTranslation() + x3bc_detectionRange},
|
zeus::CAABox aabb{GetTranslation() + zeus::CVector3f{-x3bc_detectionRange, -x3bc_detectionRange, 0.f},
|
||||||
CMaterialFilter::MakeInclude({EMaterialTypes::Bomb}), this);
|
GetTranslation() +
|
||||||
|
zeus::CVector3f{x3bc_detectionRange, x3bc_detectionRange, x3c0_detectionHeightRange}};
|
||||||
|
mgr.BuildNearList(nearList, aabb, CMaterialFilter::MakeInclude({EMaterialTypes::Bomb}), this);
|
||||||
|
|
||||||
x694_bombId = kInvalidUniqueId;
|
x694_bombId = kInvalidUniqueId;
|
||||||
|
|
||||||
for (TUniqueId uid : nearList) {
|
for (TUniqueId uid : nearList) {
|
||||||
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(uid)) {
|
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(uid)) {
|
||||||
if (!bomb->IsBeingDragged()) {
|
if (!bomb->IsBeingDragged()) {
|
||||||
float dist = (bomb->GetTranslation() - GetTranslation()).magSquared();
|
const auto dist = bomb->GetTranslation() - GetTranslation();
|
||||||
float height = (bomb->GetTranslation().z() - GetTranslation().z());
|
float distSq = dist.magSquared();
|
||||||
if (dist < dectRange && (height * height) < dectRangeHeight) {
|
if (distSq < dectRange && (dectRangeHeight <= 0.f || (dectRangeHeight > dist.z() * dist.z()))) {
|
||||||
if (x568_pathFindSearch.OnPath(bomb->GetTranslation()) == CPathFindSearch::EResult::Success) {
|
if (x568_pathFindSearch.OnPath(bomb->GetTranslation()) == CPathFindSearch::EResult::Success) {
|
||||||
dectRange = dist;
|
|
||||||
x694_bombId = bomb->GetUniqueId();
|
x694_bombId = bomb->GetUniqueId();
|
||||||
|
dectRange = distSq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,12 +423,11 @@ bool CTryclops::InMaxRange(CStateManager& mgr, float) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTryclops::InDetectionRange(CStateManager& mgr, float arg) {
|
bool CTryclops::InDetectionRange(CStateManager& mgr, float arg) {
|
||||||
CPlayer& player = mgr.GetPlayer();
|
auto& player = mgr.GetPlayer();
|
||||||
|
|
||||||
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed ||
|
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed ||
|
||||||
player.GetAttachedActor() != kInvalidUniqueId || x68c_ > 0.f || !CPatterned::InDetectionRange(mgr, arg))
|
player.GetAttachedActor() != kInvalidUniqueId || x68c_ > 0.f || !CPatterned::InDetectionRange(mgr, arg)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return x568_pathFindSearch.OnPath(player.GetBallPosition()) == CPathFindSearch::EResult::Success;
|
return x568_pathFindSearch.OnPath(player.GetBallPosition()) == CPathFindSearch::EResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,6 +451,7 @@ bool CTryclops::SpotPlayer(CStateManager& mgr, float) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTryclops::InPosition(CStateManager& mgr, float arg) {
|
bool CTryclops::InPosition(CStateManager& mgr, float arg) {
|
||||||
if (x694_bombId != kInvalidUniqueId) {
|
if (x694_bombId != kInvalidUniqueId) {
|
||||||
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(x694_bombId)) {
|
if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(x694_bombId)) {
|
||||||
|
@ -451,10 +468,9 @@ bool CTryclops::HearShot(CStateManager& mgr, float) {
|
||||||
if (TCastToConstPtr<CBomb>(mgr.GetObjectById(x694_bombId))) {
|
if (TCastToConstPtr<CBomb>(mgr.GetObjectById(x694_bombId))) {
|
||||||
x698_26_ = true;
|
x698_26_ = true;
|
||||||
return false;
|
return false;
|
||||||
} else
|
}
|
||||||
x694_bombId = kInvalidUniqueId;
|
x694_bombId = kInvalidUniqueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +491,6 @@ bool CTryclops::ShouldRetreat(CStateManager& mgr, float) {
|
||||||
SetDestPos(wp->GetTranslation());
|
SetDestPos(wp->GetTranslation());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,8 +500,9 @@ void CTryclops::LaunchPlayer(CStateManager& mgr, const zeus::CTransform& xf, flo
|
||||||
CPlayer& player = mgr.GetPlayer();
|
CPlayer& player = mgr.GetPlayer();
|
||||||
player.SetLeaveMorphBallAllowed(true);
|
player.SetLeaveMorphBallAllowed(true);
|
||||||
|
|
||||||
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
|
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x698_24_ = true;
|
x698_24_ = true;
|
||||||
x68c_ = 1.5f;
|
x68c_ = 1.5f;
|
||||||
|
@ -494,17 +510,17 @@ void CTryclops::LaunchPlayer(CStateManager& mgr, const zeus::CTransform& xf, flo
|
||||||
zeus::CTransform tmpXf = (xf * x64c_);
|
zeus::CTransform tmpXf = (xf * x64c_);
|
||||||
tmpXf.origin += zeus::CVector3f(0.f, 0.f, -0.5f);
|
tmpXf.origin += zeus::CVector3f(0.f, 0.f, -0.5f);
|
||||||
player.Teleport(tmpXf, mgr, false);
|
player.Teleport(tmpXf, mgr, false);
|
||||||
player.ApplyImpulseWR(f1 * (player.GetMass() * xf.basis[1].normalized()), zeus::CAxisAngle());
|
player.ApplyImpulseWR(f1 * (player.GetMass() * xf.frontVector().normalized()), zeus::CAxisAngle());
|
||||||
player.SetMoveState(CPlayer::EPlayerMovementState::ApplyJump, mgr);
|
player.SetMoveState(CPlayer::EPlayerMovementState::ApplyJump, mgr);
|
||||||
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
player.AddMaterial(EMaterialTypes::Solid, mgr);
|
||||||
mgr.ApplyDamage(GetUniqueId(), player.GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
mgr.ApplyDamage(GetUniqueId(), player.GetUniqueId(), GetUniqueId(), GetContactDamage(),
|
||||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), zeus::skZero3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::DragBomb(CStateManager& mgr, const zeus::CTransform& xf) {
|
void CTryclops::DragBomb(CStateManager& mgr, const zeus::CTransform& xf) {
|
||||||
if (x694_bombId != kInvalidUniqueId) {
|
if (x694_bombId != kInvalidUniqueId) {
|
||||||
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId)) {
|
if (TCastToPtr<CBomb> bomb = mgr.ObjectById(x694_bombId)) {
|
||||||
bomb->SetVelocityWR((5.f * mgr.GetActiveRandom()->Float() + 20.f) * xf.basis[1].normalized());
|
bomb->SetVelocityWR((5.f * mgr.GetActiveRandom()->Float() + 20.f) * xf.frontVector().normalized());
|
||||||
bomb->SetConstantAccelerationWR({0.f, 0.f, -CPhysicsActor::GravityConstant()});
|
bomb->SetConstantAccelerationWR({0.f, 0.f, -CPhysicsActor::GravityConstant()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,14 +531,16 @@ void CTryclops::DragBomb(CStateManager& mgr, const zeus::CTransform& xf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::ApplySeparation(CStateManager& mgr) {
|
void CTryclops::ApplySeparation(CStateManager& mgr) {
|
||||||
for (CEntity* ent : mgr.GetListeningAiObjectList()) {
|
for (CEntity* ent : mgr.GetAiWaypointObjectList()) {
|
||||||
if (TCastToPtr<CAi> ai = ent) {
|
if (TCastToPtr<CAi> ai = ent) {
|
||||||
if (ai == this || ai->GetAreaIdAlways() != GetAreaId())
|
if (ai == this || ai->GetAreaIdAlways() != GetAreaId()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
zeus::CVector3f sep = x45c_steeringBehaviors.Separation(*this, ai->GetTranslation(), 8.f);
|
zeus::CVector3f sep = x45c_steeringBehaviors.Separation(*this, ai->GetTranslation(), 8.f);
|
||||||
if (sep.x() != 0.f && sep.y() != 0.f && sep.z() != 0.f)
|
if (sep.x() != 0.f || sep.y() != 0.f || sep.z() != 0.f) {
|
||||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(sep, {}, 1.f));
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(sep, zeus::skZero3f, 1.f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,32 +569,34 @@ bool CTryclops::InRangeToLocator(const zeus::CVector3f& vec, float arg) const {
|
||||||
bool CTryclops::sub80260180(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, const zeus::CAABox& bounds,
|
bool CTryclops::sub80260180(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, const zeus::CAABox& bounds,
|
||||||
CStateManager& mgr) {
|
CStateManager& mgr) {
|
||||||
|
|
||||||
if (bounds.intersects(GetBoundingBox()))
|
if (bounds.intersects(GetBoundingBox())) {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
zeus::CTransform xf = GetLctrTransform("ballGrab_locator"sv);
|
|
||||||
zeus::CVector3f tmpVec2 = vec2 - (xf.origin - (1.f * GetTransform().basis[1]));
|
|
||||||
float f28 = tmpVec2.normalized().dot(GetTransform().basis[1]);
|
|
||||||
zeus::CVector3f tmpVec4 = (vec1 - (xf.origin - (4.f * GetTransform().basis[1]))).normalized();
|
|
||||||
float f30 = tmpVec4.dot(GetTransform().basis[1]);
|
|
||||||
float f29 = tmpVec2.magnitude();
|
|
||||||
|
|
||||||
if (f29 > 2.f) {
|
|
||||||
CRayCastResult res = mgr.RayStaticIntersection(
|
|
||||||
xf.origin, (1.f / f29) * tmpVec2, f29 - mgr.GetPlayer().GetMorphBall()->GetBallRadius(),
|
|
||||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Character, EMaterialTypes::Player,
|
|
||||||
EMaterialTypes::ProjectilePassthrough}));
|
|
||||||
if (res.IsValid())
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !(f29 >= x684_ || f28 <= 0.f || f30 <= x680_);
|
zeus::CTransform xf = GetLctrTransform("ballGrab_locator"sv);
|
||||||
|
zeus::CVector3f tmpVec2 = vec2 - (xf.origin - (1.f * GetTransform().frontVector()));
|
||||||
|
float tmpVec2Dot = tmpVec2.normalized().dot(GetTransform().frontVector());
|
||||||
|
zeus::CVector3f tmpVec1 = vec1 - (xf.origin - (4.f * GetTransform().frontVector()));
|
||||||
|
float tmpVec1Dot = tmpVec1.normalized().dot(GetTransform().frontVector());
|
||||||
|
float tmpVec2Mag = tmpVec2.magnitude();
|
||||||
|
|
||||||
|
if (tmpVec2Mag > 2.f) {
|
||||||
|
CRayCastResult res = mgr.RayStaticIntersection(
|
||||||
|
xf.origin, (1.f / tmpVec2Mag) * tmpVec2, tmpVec2Mag - mgr.GetPlayer().GetMorphBall()->GetBallRadius(),
|
||||||
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Character, EMaterialTypes::Player,
|
||||||
|
EMaterialTypes::ProjectilePassthrough}));
|
||||||
|
if (res.IsValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(x684_ <= tmpVec2Mag || tmpVec2Dot <= 0.f || tmpVec1Dot <= x680_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTryclops::SuckPlayer(CStateManager& mgr, float arg) {
|
void CTryclops::SuckPlayer(CStateManager& mgr, float arg) {
|
||||||
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
|
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
CPlayer& player = mgr.GetPlayer();
|
CPlayer& player = mgr.GetPlayer();
|
||||||
zeus::CTransform xf = GetLctrTransform("ballGrab_locator"sv);
|
zeus::CTransform xf = GetLctrTransform("ballGrab_locator"sv);
|
||||||
zeus::CVector3f diff = (player.GetTranslation() - xf.origin);
|
zeus::CVector3f diff = (player.GetTranslation() - xf.origin);
|
||||||
|
@ -585,7 +605,7 @@ void CTryclops::SuckPlayer(CStateManager& mgr, float arg) {
|
||||||
player.Stop();
|
player.Stop();
|
||||||
AttractPlayer(mgr, xf.origin, arg);
|
AttractPlayer(mgr, xf.origin, arg);
|
||||||
} else {
|
} else {
|
||||||
player.ApplyForceWR(((x67c_ * (x684_ / (diffMag * diffMag))) * (player.GetMass() * -diff)), {});
|
player.ApplyForceWR(((x67c_ * (x684_ / (diffMag * diffMag))) * player.GetMass() * -diff), {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,8 +639,7 @@ bool CTryclops::sub8025dbd0(CStateManager& mgr) {
|
||||||
matList};
|
matList};
|
||||||
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
||||||
mgr.BuildColliderList(nearList, player, colSphere.CalculateLocalAABox());
|
mgr.BuildColliderList(nearList, player, colSphere.CalculateLocalAABox());
|
||||||
constexpr CMaterialFilter matFilter{
|
constexpr auto matFilter = CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {EMaterialTypes::Player});
|
||||||
{EMaterialTypes::Solid}, {EMaterialTypes::Player}, CMaterialFilter::EFilterType::IncludeExclude};
|
|
||||||
const zeus::CTransform skIdentity4f{}; // TODO move to zeus & make constexpr
|
const zeus::CTransform skIdentity4f{}; // TODO move to zeus & make constexpr
|
||||||
if (CGameCollision::DetectStaticCollisionBoolean(mgr, colSphere, skIdentity4f, matFilter)) {
|
if (CGameCollision::DetectStaticCollisionBoolean(mgr, colSphere, skIdentity4f, matFilter)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue