More CFlaahgra imps

This commit is contained in:
Phillip Stephens 2019-06-19 14:11:13 -07:00
parent 568e15a89a
commit 8c35cd02f0
3 changed files with 105 additions and 4 deletions

View File

@ -226,6 +226,56 @@ void CFlaahgra::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM
}
CPatterned::AcceptScriptMsg(msg, uid, mgr);
}
void CFlaahgra::Death(CStateManager& mgr, const zeus::CVector3f& dir, EScriptObjectState state) {
if (!x400_25_alive)
return;
x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Dead"sv);
if (x450_bodyController->GetPercentageFrozen() > 0.f)
x450_bodyController->UnFreeze();
x400_25_alive = false;
}
void CFlaahgra::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
switch(type) {
case EUserEventType::Projectile: {
// TODO: Implement
break;
}
case EUserEventType::BeginAction: {
x8e4_26_ = true;
x7c4_ = GetEndActionTime();
break;
}
case EUserEventType::ScreenShake: {
// TODO: Implement
break;
}
case EUserEventType::AlignTargetRot: {
if (x77c_ == kInvalidUniqueId)
break;
if (TCastToPtr<CScriptWaypoint> wp = mgr.ObjectById(x77c_)) {
mgr.SendScriptMsg(wp, GetUniqueId(), EScriptObjectMessage::Arrived);
if (x7f8_ > 0)
--x7f8_;
}
break;
}
case EUserEventType::GenerateEnd: {
// TODO: Implement
break;
}
case EUserEventType::ObjectDrop: {
SendScriptMsgs(EScriptObjectState::Modify, mgr, EScriptObjectMessage::None);
break;
}
default: break;
}
CPatterned::DoUserAnimEvent(mgr, node, type, dt);
}
void CFlaahgra::LoadDependencies(CAssetId dgrpId) {
if (!dgrpId.IsValid()) {
ResetModelDataAndBodyController();
@ -420,6 +470,12 @@ void CFlaahgra::sub801ae980(CStateManager& mgr) {
++x788_;
}
void CFlaahgra::UpdateHeadDamageVulnerability(CStateManager& mgr, bool b) {
if (TCastToPtr<CCollisionActor> head = mgr.ObjectById(x80c_headActor)) {
head->SetDamageVulnerability(b ? *GetDamageVulnerability() : x56c_.x10_);
}
}
void CFlaahgra::FadeIn(CStateManager& mgr, EStateMsg msg, float) {
if (msg != EStateMsg::Activate)
return;
@ -475,7 +531,38 @@ void CFlaahgra::UpdateSmallScaleReGrowth(float dt) {
x7d8_ += dt;
}
void CFlaahgra::UpdateHealthInfo(CStateManager&) {}
void CFlaahgra::UpdateHealthInfo(CStateManager& mgr) {
float tmp = 0.f;
for (const TUniqueId& uid : x7fc_sphereColliders) {
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
CHealthInfo* inf = colAct->HealthInfo(mgr);
tmp = zeus::max(tmp, x818_ - inf->GetHP());
}
}
if (x780_ == 3) {
if (!IsDizzy(mgr, 0.f))
x814_ += tmp;
else
x810_ += tmp;
} else {
x814_ = 0.f;
x810_ = 0.f;
}
CHealthInfo* hInfo = HealthInfo(mgr);
if (hInfo->GetHP() <= 0.f) {
Death(mgr, {}, EScriptObjectState::DeathRattle);
RemoveMaterial(EMaterialTypes::Orbit, mgr);
return;
}
for (const TUniqueId& uid : x7fc_sphereColliders) {
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
colAct->HealthInfo(mgr)->SetHP(x818_);
}
}
}
void CFlaahgra::UpdateAimPosition(CStateManager& mgr, float dt) {
if (TCastToConstPtr<CCollisionActor> head = mgr.GetObjectById(x80c_headActor)) {
pas::EAnimationState animState = x450_bodyController->GetBodyStateInfo().GetCurrentStateId();
@ -643,4 +730,12 @@ void CFlaahgra::Generate(CStateManager& mgr, EStateMsg msg, float) {
x7c0_ = 11.f;
}
}
zeus::CVector3f CFlaahgra::GetAttacktargetPos(CStateManager& mgr) const {
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed)
return mgr.GetPlayer().GetMorphBall()->GetBallToWorld().origin;
return mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, -.5f + mgr.GetPlayer().GetEyeHeight());
}
} // namespace urde::MP1

View File

@ -151,8 +151,9 @@ class CFlaahgra : public CPatterned {
void UpdateScale(float, float, float);
float GetEndActionTime();
void SetupHealthInfo(CStateManager&);
zeus::CVector3f GetAttacktargetPos(CStateManager&) const;
bool sub801e4f8() { return x7a8_ == 0 || x7a8_ == 1; }
void UpdateHeadDamageVulnerability(CStateManager&, bool);
public:
DEFINE_PATTERNED(Flaahgra);
CFlaahgra(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, const CAnimRes&,
@ -163,13 +164,18 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
bool CanRenderUnsorted(const CStateManager&) const { return true; }
zeus::CVector3f GetAimPosition(const CStateManager&, float) const { return x820_; }
void Death(CStateManager&, const zeus::CVector3f&, EScriptObjectState);
void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt);
CProjectileInfo* GetProjectileInfo() { return x8e4_30_ ? &x704_ : &x6dc_; }
bool AnimOver(CStateManager&, float) { return x568_ == 4; }
bool AIStage(CStateManager&, float arg) { return x780_ == u32(arg); }
bool HitSomething(CStateManager&, float arg) { return x7d0_ > 0; }
bool OffLine(CStateManager&, float) { return (!x8e5_29_ && !x8e5_28_); }
bool ShouldTurn(CStateManager&, float);
bool ShouldAttacK(CStateManager&, float) { return true; }
bool ShouldAttack(CStateManager&, float) { return true; }
bool BreakAttack(CStateManager&, float) { return x7d4_ >= x56c_.xc_ && !x8e4_29_getup; }
void FadeIn(CStateManager&, EStateMsg, float);
void FadeOut(CStateManager&, EStateMsg, float);