2018-11-18 05:10:06 +00:00
|
|
|
#include "MP1/World/CMetaree.hpp"
|
|
|
|
#include "Weapon/CGameProjectile.hpp"
|
|
|
|
#include "World/CPlayer.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "CPlayerState.hpp"
|
|
|
|
|
|
|
|
#include "TCastTo.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde::MP1 {
|
2017-11-13 06:19:18 +00:00
|
|
|
CMetaree::CMetaree(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
|
|
|
|
const CDamageInfo& dInfo, float f1, const zeus::CVector3f& v1, float f2, EBodyType bodyType,
|
|
|
|
float f3, float f4, const CActorParameters& aParms)
|
2017-08-21 00:29:59 +00:00
|
|
|
: CPatterned(ECharacter::Metaree, uid, name, flavor, info, xf, std::move(mData), pInfo, EMovementType::Flyer,
|
2018-11-06 06:16:12 +00:00
|
|
|
EColliderType::Zero, bodyType, aParms, EKnockBackVariant::Small)
|
2018-11-18 05:10:06 +00:00
|
|
|
, x568_delay(f3)
|
2017-08-21 00:29:59 +00:00
|
|
|
, x56c_(f4)
|
2018-11-18 05:10:06 +00:00
|
|
|
, x570_dropHeight(f1)
|
|
|
|
, x574_offset(v1)
|
|
|
|
, x580_attackSpeed(f2)
|
2017-08-21 00:29:59 +00:00
|
|
|
, x5ca_24_(true)
|
2018-11-18 05:10:06 +00:00
|
|
|
, x5ca_25_started(false)
|
2018-12-08 05:30:43 +00:00
|
|
|
, x5ca_26_deactivated(false) {}
|
2017-08-21 00:29:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-08-21 00:29:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
2017-08-21 00:29:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (msg == EScriptObjectMessage::Start)
|
|
|
|
x5ca_25_started = true;
|
|
|
|
else if (msg == EScriptObjectMessage::Registered)
|
|
|
|
x450_bodyController->Activate(mgr);
|
2017-08-21 00:29:59 +00:00
|
|
|
}
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::Think(float dt, CStateManager& mgr) {
|
|
|
|
bool target = true;
|
|
|
|
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal &&
|
|
|
|
mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan) {
|
|
|
|
target = x5ca_26_deactivated;
|
|
|
|
}
|
|
|
|
xe7_31_targetable = target;
|
|
|
|
CPatterned::Think(dt, mgr);
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::Explode(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg != EStateMsg::Activate)
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), x5ac_damgeInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
|
|
|
MassiveDeath(mgr);
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::Touch(CActor& act, CStateManager& mgr) {
|
|
|
|
if (!x400_25_alive)
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (TCastToPtr<CGameProjectile> projectile = act) {
|
|
|
|
if (projectile->GetOwnerId() != mgr.GetPlayer().GetUniqueId())
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x400_24_hitByPlayerProjectile = true;
|
|
|
|
x590_projectileDelta = projectile->GetTranslation() - projectile->GetPreviousPos();
|
|
|
|
}
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2019-02-08 07:56:54 +00:00
|
|
|
void CMetaree::CollidedWith(TUniqueId id, const CCollisionInfoList& colList, CStateManager& mgr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!x400_25_alive || colList.GetCount() <= 0)
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.ApplyDamageToWorld(GetUniqueId(), *this, GetTranslation(), x5ac_damgeInfo,
|
|
|
|
CMaterialFilter::MakeInclude({EMaterialTypes::Player}));
|
|
|
|
SendScriptMsgs(EScriptObjectState::Arrived, mgr, EScriptObjectMessage::None);
|
|
|
|
MassiveDeath(mgr);
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::Flee(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
ApplyImpulseWR(5.f * (GetMass() * (x590_projectileDelta * zeus::CVector3f{1.f, 1.f, 0.f})),
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CAxisAngle());
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
SetMomentumWR({0.f, 0.f, -GetGravityConstant() * GetMass()});
|
|
|
|
SetTranslation(GetTranslation());
|
|
|
|
x5a8_ = 0;
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
if (x5a8_ != 0)
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::LieOnGround) {
|
|
|
|
x5a8_ = 1;
|
|
|
|
return;
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockDownCmd({0.f, 1.f, 0.f}, pas::ESeverity::Zero));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMetaree::Dead(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg != EStateMsg::Activate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mgr.ApplyDamageToWorld(GetUniqueId(), *this, GetTranslation(), x5ac_damgeInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player}, {}));
|
|
|
|
DeathDelete(mgr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMetaree::Attack(CStateManager&, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x5a8_ = 0;
|
|
|
|
zeus::CVector3f dir = (x584_lookPos - GetTranslation()).normalized();
|
|
|
|
SetVelocityWR(x580_attackSpeed * dir);
|
|
|
|
CSfxManager::AddEmitter(x5c8_attackSfx, GetTranslation(), {}, true, false, 127, kInvalidAreaId);
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
|
|
|
|
x59c_velocity = x580_attackSpeed * dir;
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
if (x450_bodyController->GetPercentageFrozen() == 0.f)
|
|
|
|
SetVelocityWR(x59c_velocity);
|
|
|
|
else {
|
|
|
|
Stop();
|
|
|
|
SetVelocityWR({});
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMetaree::Halt(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg != EStateMsg::Activate)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Stop();
|
|
|
|
SetVelocityWR({});
|
|
|
|
SetMomentumWR({});
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Lurk);
|
|
|
|
x584_lookPos = x574_offset + mgr.GetPlayer().GetTranslation();
|
|
|
|
SetTransform(zeus::lookAt(GetTranslation(), x584_lookPos));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMetaree::Active(CStateManager& mgr, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
x400_24_hitByPlayerProjectile = false;
|
|
|
|
x584_lookPos = GetTranslation() - zeus::CVector3f{0.f, 0.f, x570_dropHeight};
|
|
|
|
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero, x584_lookPos));
|
|
|
|
SetMomentumWR({0.f, 0.f, -GetGravityConstant() * GetMass()});
|
|
|
|
} else if (msg == EStateMsg::Update) {
|
|
|
|
x450_bodyController->GetCommandMgr().SetTargetVector(
|
|
|
|
(mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized());
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
SetMomentumWR({});
|
|
|
|
}
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CMetaree::InActive(CStateManager&, EStateMsg msg, float) {
|
|
|
|
if (msg == EStateMsg::Activate) {
|
|
|
|
if (!x5ca_26_deactivated)
|
|
|
|
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
|
|
|
} else if (msg == EStateMsg::Deactivate) {
|
|
|
|
x5ca_26_deactivated = true;
|
|
|
|
}
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CMetaree::InRange(CStateManager& mgr, float arg) {
|
|
|
|
if (x5ca_25_started)
|
|
|
|
return true;
|
2018-11-18 05:10:06 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return CPatterned::InRange(mgr, arg);
|
2018-11-18 05:10:06 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CMetaree::ShouldAttack(CStateManager&, float) { return GetTranslation().z() < x584_lookPos.z(); }
|
|
|
|
} // namespace urde::MP1
|