From ec83a227de2c5c451604bf65a59189ee5a3690d2 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 15 Sep 2020 01:35:22 -0400 Subject: [PATCH] CDrone: Finish Attack --- Runtime/MP1/World/CDrone.cpp | 39 +++++++++++++++++++++++++++++------- Runtime/MP1/World/CDrone.hpp | 2 +- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Runtime/MP1/World/CDrone.cpp b/Runtime/MP1/World/CDrone.cpp index 975392488..0c3a86dfe 100644 --- a/Runtime/MP1/World/CDrone.cpp +++ b/Runtime/MP1/World/CDrone.cpp @@ -225,7 +225,7 @@ void CDrone::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateM } case EScriptObjectMessage::Deactivate: case EScriptObjectMessage::Deleted: { - for (TUniqueId& unkId : x7d8_) { + for (TUniqueId& unkId : x7d8_laserIds) { if (unkId != kInvalidUniqueId) { mgr.FreeScriptObject(unkId); unkId = kInvalidUniqueId; @@ -568,14 +568,39 @@ void CDrone::Attack(CStateManager& mgr, EStateMsg msg, float dt) { x7c8_ = 0; x834_31_attackOver = false; const auto playerAimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f); - const auto frontVec = GetTransform().frontVector(); + const auto& xf = GetTransform(); + const auto frontVec = xf.frontVector(); zeus::CVector3f out; if ((playerAimPos - GetTranslation()).normalized().dot(frontVec) >= 0.8f) { out = playerAimPos; } else { out = GetTranslation() + 10.f * frontVec; } - // TODO complete + s32 state = mgr.GetActiveRandom()->Next() % 4; + if (state == 0) { + x7e0_[0] = out + (3.f * xf.rightVector()) - (4.f * xf.upVector()); + x7fc_[0] = out - (3.f * xf.rightVector()) + (4.f * xf.upVector()); + x7e0_[1] = out - (3.f * xf.rightVector()) - (4.f * xf.upVector()); + x7fc_[1] = out + (3.f * xf.rightVector()) + (4.f * xf.upVector()); + } else if (state == 1) { + x7e0_[0] = out + (3.f * xf.rightVector()) + (4.f * xf.upVector()); + x7fc_[0] = out - (3.f * xf.rightVector()) - (4.f * xf.upVector()); + x7e0_[1] = out - (3.f * xf.rightVector()) + (4.f * xf.upVector()); + x7fc_[1] = out + (3.f * xf.rightVector()) - (4.f * xf.upVector()); + } else if (state == 2) { + x7e0_[0] = out - (4.f * xf.rightVector()) - (3.f * xf.upVector()); + x7fc_[0] = out + (4.f * xf.rightVector()) + (3.f * xf.upVector()); + x7e0_[1] = out + (4.f * xf.rightVector()) - (3.f * xf.upVector()); + x7fc_[1] = out - (4.f * xf.rightVector()) + (3.f * xf.upVector()); + } else if (state == 3) { + x7e0_[0] = out - (4.f * xf.rightVector()) + (3.f * xf.upVector()); + x7fc_[0] = out + (4.f * xf.rightVector()) - (3.f * xf.upVector()); + x7e0_[1] = out + (4.f * xf.rightVector()) + (3.f * xf.upVector()); + x7fc_[1] = out - (4.f * xf.rightVector()) - (3.f * xf.upVector()); + } + x818_[0] = 0.f; + x818_[1] = 0.f; + x835_24_ = true; } else if (msg == EStateMsg::Update) { if (x7c8_ == 0) { if (GetBodyController()->GetCurrentStateId() == pas::EAnimationState::ProjectileAttack) { @@ -962,11 +987,11 @@ void CDrone::RemoveFromTeam(CStateManager& mgr) const { } void CDrone::UpdateLaser(CStateManager& mgr, u32 laserIdx, bool active) { - if (active && x7d8_[laserIdx] == kInvalidUniqueId) { - x7d8_[laserIdx] = mgr.AllocateUniqueId(); - mgr.AddObject(new CDroneLaser(x7d8_[laserIdx], GetAreaIdAlways(), GetTransform(), x568_laserParticlesId)); + if (active && x7d8_laserIds[laserIdx] == kInvalidUniqueId) { + x7d8_laserIds[laserIdx] = mgr.AllocateUniqueId(); + mgr.AddObject(new CDroneLaser(x7d8_laserIds[laserIdx], GetAreaIdAlways(), GetTransform(), x568_laserParticlesId)); } - if (CEntity* ent = mgr.ObjectById(x7d8_[laserIdx])) { + if (CEntity* ent = mgr.ObjectById(x7d8_laserIds[laserIdx])) { mgr.SendScriptMsg(ent, GetUniqueId(), active ? EScriptObjectMessage::Activate : EScriptObjectMessage::Deactivate); } } diff --git a/Runtime/MP1/World/CDrone.hpp b/Runtime/MP1/World/CDrone.hpp index 12bf2fb7b..e757d7236 100644 --- a/Runtime/MP1/World/CDrone.hpp +++ b/Runtime/MP1/World/CDrone.hpp @@ -74,7 +74,7 @@ class CDrone : public CPatterned { s32 x7c8_ = 0; s16 x7cc_; CSfxHandle x7d0_; - rstl::reserved_vector x7d8_ = {{kInvalidUniqueId, kInvalidUniqueId}}; + rstl::reserved_vector x7d8_laserIds = {{kInvalidUniqueId, kInvalidUniqueId}}; rstl::reserved_vector x7e0_ = {{zeus::skZero3f, zeus::skZero3f}}; rstl::reserved_vector x7fc_ = {{zeus::skZero3f, zeus::skZero3f}}; rstl::reserved_vector x818_ = {{0.f, 0.f}};