More CPatterned imps

This commit is contained in:
Phillip Stephens 2018-09-13 17:49:34 -07:00
parent 34c4a038aa
commit 679ce01a61
24 changed files with 491 additions and 43 deletions

View File

@ -90,7 +90,7 @@ void CBodyController::Update(float dt, CStateManager& mgr)
if (x300_25_active) if (x300_25_active)
{ {
x300_24_animationOver = x300_24_animationOver =
!x0_actor.GetModelData()->GetAnimationData()->IsAnimTimeRemaining(dt, "Whole Body"); !x0_actor.GetModelData()->GetAnimationData()->IsAnimTimeRemaining(dt, "Whole Body"sv);
x4_cmdMgr.BlendSteeringCmds(); x4_cmdMgr.BlendSteeringCmds();
x2dc_rot = zeus::CQuaternion::skNoRotation; x2dc_rot = zeus::CQuaternion::skNoRotation;
UpdateBody(dt, mgr); UpdateBody(dt, mgr);
@ -306,7 +306,7 @@ void CBodyController::UpdateFrozenInfo(float dt, CStateManager& mgr)
{ {
UnFreeze(); UnFreeze();
x0_actor.SendScriptMsgs(EScriptObjectState::UnFrozen, mgr, EScriptObjectMessage::None); x0_actor.SendScriptMsgs(EScriptObjectState::UnFrozen, mgr, EScriptObjectMessage::None);
mgr.GetActorModelParticles()->StartIce(x0_actor, mgr); mgr.GetActorModelParticles()->StartIce(x0_actor);
return; return;
} }
if (x310_timeFrozen <= totalTime) if (x310_timeFrozen <= totalTime)

View File

@ -110,7 +110,7 @@ CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals()
if (i < x10_treeNodes.size()-1) if (i < x10_treeNodes.size()-1)
{ {
node = CTreeUtils::GetTransitionTree(node, node = CTreeUtils::GetTransitionTree(node,
CAnimTreeNode::Cast(x10_treeNodes[i+1]->Clone()), x0_animCtx); CAnimTreeNode::Cast(std::move(x10_treeNodes[i+1]->Clone())), x0_animCtx);
} }
} }
} }

View File

@ -19,6 +19,7 @@ public:
}; };
private: private:
public: public:
DEFINE_PATTERNED(Beetle)
CBeetle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CBeetle(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&, const CPatternedInfo&, CPatterned::EFlavorType,EEntranceType, const CDamageInfo &, const CDamageVulnerability&,
const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&, const zeus::CVector3f&, float, float, float, const CDamageVulnerability&, const CActorParameters&,

View File

@ -35,7 +35,7 @@ class CMetaree : public CPatterned
u32 x5cc_; u32 x5cc_;
public: public:
static constexpr ECharacter CharacterType = ECharacter::Metaree; DEFINE_PATTERNED(Metaree)
CMetaree(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CMetaree(TUniqueId, std::string_view, EFlavorType, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, const CDamageInfo&, float, const zeus::CVector3f&, float, EBodyType, float, float, const CPatternedInfo&, const CDamageInfo&, float, const zeus::CVector3f&, float, EBodyType, float, float,
const CActorParameters&); const CActorParameters&);

View File

@ -29,7 +29,7 @@ public:
class CMetroid : public CPatterned class CMetroid : public CPatterned
{ {
public: public:
static constexpr ECharacter CharacterType = ECharacter::Metroid; DEFINE_PATTERNED(Metroid)
CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CMetroid(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, const CMetroidData& metroidData); const CActorParameters& aParms, const CMetroidData& metroidData);

View File

@ -10,7 +10,7 @@ namespace urde::MP1
class CMetroidBeta : public CPatterned class CMetroidBeta : public CPatterned
{ {
public: public:
static constexpr ECharacter CharacterType = ECharacter::MetroidBeta; DEFINE_PATTERNED(MetroidBeta)
CMetroidBeta(TUniqueId uid, std::string_view name, const CEntityInfo& info, CMetroidBeta(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, const CMetroidData& metroidData); const CActorParameters& aParms, const CMetroidData& metroidData);

View File

@ -103,7 +103,7 @@ struct SPrimeExoRoomParameters
class CMetroidPrimeExo : public CPatterned class CMetroidPrimeExo : public CPatterned
{ {
public: public:
static constexpr ECharacter CharacterType = ECharacter::MetroidPrimeExo; DEFINE_PATTERNED(MetroidPrimeExo)
CMetroidPrimeExo(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CMetroidPrimeExo(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& aParms,
u32 pw1, const CCameraShakeData& shakeData1, const CCameraShakeData& shakeData2, u32 pw1, const CCameraShakeData& shakeData1, const CCameraShakeData& shakeData2,

View File

@ -13,6 +13,7 @@ namespace MP1
class CNewIntroBoss : public CPatterned class CNewIntroBoss : public CPatterned
{ {
public: public:
DEFINE_PATTERNED(NewIntroBoss)
CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info, CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo, const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo,

View File

@ -38,6 +38,7 @@ struct CParasiteInfo
class CParasite : public CWallWalker class CParasite : public CWallWalker
{ {
public: public:
DEFINE_PATTERNED(Parasite)
CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf, CParasite(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CPatternedInfo&, u32, float, float, float, float, float, float, float, float, float, CModelData&& mData, const CPatternedInfo&, u32, float, float, float, float, float, float, float, float, float,
float, float, float, float, float, float, float, float, float, bool, u32, const CDamageVulnerability&, const CParasiteInfo&, u16, u16, float, float, float, float, float, float, float, float, float, bool, u32, const CDamageVulnerability&, const CParasiteInfo&, u16, u16,

View File

@ -9,7 +9,7 @@ namespace urde::MP1
class CPuddleToadGamma : public CPatterned class CPuddleToadGamma : public CPatterned
{ {
public: public:
static constexpr ECharacter CharacterType = ECharacter::PuddleToad; DEFINE_PATTERNED(PuddleToad)
CPuddleToadGamma(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CPuddleToadGamma(TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& aParms, float f1, float f2, float f3, const zeus::CVector3f& v1, const CActorParameters& aParms, float f1, float f2, float f3, const zeus::CVector3f& v1,

View File

@ -62,6 +62,7 @@ class CRidley : public CPatterned
{ {
CRidleyData x568_; CRidleyData x568_;
public: public:
DEFINE_PATTERNED(Ridley)
CRidley(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CRidley(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CPatternedInfo&, const CActorParameters&, CInputStream&, u32); const CPatternedInfo&, const CActorParameters&, CInputStream&, u32);

View File

@ -10,6 +10,7 @@ namespace MP1
class CSeedling : public CWallWalker class CSeedling : public CWallWalker
{ {
public: public:
DEFINE_PATTERNED(Seedling)
CSeedling(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CSeedling(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&,
CModelData&&, const CPatternedInfo&, const CActorParameters&, CModelData&&, const CPatternedInfo&, const CActorParameters&,
CAssetId, CAssetId, const CDamageInfo&, const CDamageInfo&, CAssetId, CAssetId, const CDamageInfo&, const CDamageInfo&,

View File

@ -9,6 +9,10 @@ namespace urde::MP1
class CSpacePirate : public CPatterned class CSpacePirate : public CPatterned
{ {
public:
DEFINE_PATTERNED(SpacePirate)
private:
class CSpacePirateData class CSpacePirateData
{ {
float x0_; float x0_;

View File

@ -9,7 +9,7 @@ namespace urde
class CThardusRockProjectile : public CPatterned class CThardusRockProjectile : public CPatterned
{ {
public: public:
static constexpr ECharacter CharacterType = ECharacter::ThardusRockProjectile; DEFINE_PATTERNED(ThardusRockProjectile)
CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info, CThardusRockProjectile(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& modelData, const CActorParameters& aParms, const zeus::CTransform& xf, CModelData&& modelData, const CActorParameters& aParms,
const CPatternedInfo& patternedInfo, const std::vector<CModelData>& mDataVec, u32); const CPatternedInfo& patternedInfo, const std::vector<CModelData>& mDataVec, u32);

View File

@ -11,6 +11,7 @@ namespace MP1
class CWarWasp : public CPatterned class CWarWasp : public CPatterned
{ {
public: public:
DEFINE_PATTERNED(WarWasp)
CWarWasp(TUniqueId uid, std::string_view name, const CEntityInfo& info, CWarWasp(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
CPatterned::EFlavorType flavor, CPatterned::EColliderType, const CDamageInfo& dInfo1, CPatterned::EFlavorType flavor, CPatterned::EColliderType, const CDamageInfo& dInfo1,

View File

@ -288,9 +288,18 @@ std::list<CActorModelParticles::CItem>::iterator CActorModelParticles::FindOrCre
return x0_items.emplace(x0_items.end(), act, *this); return x0_items.emplace(x0_items.end(), act, *this);
} }
void CActorModelParticles::StartIce(CActor& actor, CStateManager& mgr) void CActorModelParticles::StartIce(CActor& actor)
{ {
}
void CActorModelParticles::StopElectric(CActor& act)
{
if (!act.GetPointGeneratorParticles())
{
auto iter = FindSystem(act.GetUniqueId());
if (iter != x0_items.cend() && iter->xc0_particleElectric)
iter->xc0_particleElectric->SetParticleEmission(false);
}
} }
void CActorModelParticles::AddRainSplashGenerator(CActor& act, CStateManager& mgr, u32 maxSplashes, void CActorModelParticles::AddRainSplashGenerator(CActor& act, CStateManager& mgr, u32 maxSplashes,

View File

@ -95,11 +95,30 @@ public:
void SetupHook(TUniqueId uid); void SetupHook(TUniqueId uid);
std::list<CItem>::const_iterator FindSystem(TUniqueId uid) const; std::list<CItem>::const_iterator FindSystem(TUniqueId uid) const;
std::list<CItem>::iterator FindOrCreateSystem(CActor& act); std::list<CItem>::iterator FindOrCreateSystem(CActor& act);
void StartIce(CActor& actor, CStateManager& mgr); void StartIce(CActor& actor);
void AddRainSplashGenerator(CActor& act, CStateManager& mgr, u32 maxSplashes, void AddRainSplashGenerator(CActor& act, CStateManager& mgr, u32 maxSplashes,
u32 genRate, float minZ); u32 genRate, float minZ);
void RemoveRainSplashGenerator(CActor& act); void RemoveRainSplashGenerator(CActor& act);
void Render(const CActor& actor) const; void Render(const CActor& actor) const;
void StartElectric(CActor& act)
{
auto iter = FindOrCreateSystem(act);
if (iter->xc0_particleElectric && !iter->xc0_particleElectric->GetParticleEmission())
iter->xc0_particleElectric->SetParticleEmission(true);
}
void StopElectric(CActor& act);
void LightDudeOnFire(CActor& act)
{
auto iter = FindOrCreateSystem(act);
/* iter->sub801e5a04(false); */
if (iter->x6c_ > 0.f)
iter->x70_ = true;
}
}; };
} }

View File

@ -9,6 +9,7 @@ namespace urde
enum class EStateMsg enum class EStateMsg
{ {
One = 1, One = 1,
Two = 2,
Twenty = 20 Twenty = 20
}; };

View File

@ -1,5 +1,6 @@
#include <Runtime/CStateManager.hpp> #include <Runtime/MP1/World/CSpacePirate.hpp>
#include "CPatterned.hpp" #include "CPatterned.hpp"
#include "Runtime/CStateManager.hpp"
#include "CPatternedInfo.hpp" #include "CPatternedInfo.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
@ -9,6 +10,9 @@
#include "CPlayer.hpp" #include "CPlayer.hpp"
#include "Weapon/CGameProjectile.hpp" #include "Weapon/CGameProjectile.hpp"
#include "Character/CAnimData.hpp" #include "Character/CAnimData.hpp"
#include "TCastTo.hpp"
#include "MP1/World/CSpacePirate.hpp"
#include "World/CStateMachine.hpp"
namespace urde namespace urde
{ {
@ -54,7 +58,7 @@ x3fc_flavor(flavor)
x402_30_ = x402_31_ = actorParms.HasThermalHeat(); x402_30_ = x402_31_ = actorParms.HasThermalHeat();
x403_25_ = true; x403_25_ = true;
x403_26_ = true; x403_26_ = true;
x404_ = pInfo.x34_damageInfo; x404_contactDamage = pInfo.x34_contactDamageInfo;
x424_damageWaitTime = pInfo.x50_damageWaitTime; x424_damageWaitTime = pInfo.x50_damageWaitTime;
x454_deathSfx = pInfo.xe8_deathSfx; x454_deathSfx = pInfo.xe8_deathSfx;
x458_iceShatterSfx = pInfo.x134_iceShatterSfx; x458_iceShatterSfx = pInfo.x134_iceShatterSfx;
@ -76,15 +80,117 @@ x3fc_flavor(flavor)
if (pInfo.x130_particle2.IsValid()) if (pInfo.x130_particle2.IsValid())
x54c_ = { g_SimplePool->GetObj({FOURCC('PART'), pInfo.x130_particle2})}; x54c_ = { g_SimplePool->GetObj({FOURCC('PART'), pInfo.x130_particle2})};
if (x404_.GetRadius() > 0.f) if (x404_contactDamage.GetRadius() > 0.f)
x404_.SetRadius(0.f); x404_contactDamage.SetRadius(0.f);
xe6_29_renderParticleDBInside = false; xe6_29_renderParticleDBInside = false;
x402_27_ = x64_modelData->HasModel(CModelData::EWhichModel::XRay); x402_27_ = x64_modelData->HasModel(CModelData::EWhichModel::XRay);
BuildBodyController(bodyType); BuildBodyController(bodyType);
} }
void CPatterned::Think(float dt, urde::CStateManager& mgr) void CPatterned::Accept(urde::IVisitor& visitor)
{
visitor.Visit(this);
}
void CPatterned::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
CAi::AcceptScriptMsg(msg, uid, mgr);
switch(msg)
{
case EScriptObjectMessage::Registered:
{
if (x508_colliderType == EColliderType::Zero)
{
CMaterialList include = GetMaterialFilter().GetIncludeList();
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
include.Remove(EMaterialTypes::Character);
exclude.Add(EMaterialTypes::Character);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
}
if (HasModelData() && GetModelData()->HasAnimData() && GetModelData()->GetAnimationData()->GetIceModel())
{
/* TODO Initialize CVertexMorphEffect located at 0x8007CC7C */
}
xf8_25_angularEnabled = true;
x450_bodyController->Activate(mgr);
break;
}
case EScriptObjectMessage::OnFloor:
{
if (!x328_25_)
{
x150_momentum = {};
AddMaterial(EMaterialTypes::GroundCollider, mgr);
}
x328_27_onGround = true;
break;
}
case EScriptObjectMessage::Falling:
{
if (!x328_25_)
{
if (x450_bodyController->GetPercentageFrozen() == 0.f)
{
x150_momentum = {0.f, 0.f, -GetWeight()};
RemoveMaterial(EMaterialTypes::GroundCollider, mgr);
}
}
x328_27_onGround = false;
break;
}
case EScriptObjectMessage::Activate:
x3a0_ = GetTranslation();
break;
case EScriptObjectMessage::Deleted:
if (x330_stateMachineState.GetActorState() != nullptr)
x330_stateMachineState.GetActorState()->CallFunc(mgr, *this, EStateMsg::Two, 0.f);
break;
case EScriptObjectMessage::Damage:
{
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid))
{
const CDamageInfo& info = proj->GetDamageInfo();
if (info.GetWeaponMode().GetType() == EWeaponType::Wave)
{
if (x460_.x81_26_ && info.GetWeaponMode().IsComboed() && HealthInfo(mgr))
{
x401_31_ = true;
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::One, false,
info.GetKnockBackPower());
// x460_.sub80233D30(2);
}
}
else if (info.GetWeaponMode().GetType() == EWeaponType::Plasma)
{
if (x460_.x81_27_ && info.GetWeaponMode().IsCharged() && HealthInfo(mgr))
{
KnockBack(GetTransform().frontVector(), mgr, info, EKnockBackType::One, false, info.GetKnockBackPower());
// x460_.sub80233D30(2);
}
}
if (mgr.GetPlayer().GetUniqueId() == proj->GetOwnerId())
x400_24_ = true;
}
break;
}
case EScriptObjectMessage::InvulnDamage:
{
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid))
{
if (proj->GetOwnerId() == mgr.GetPlayer().GetUniqueId())
x400_24_ = true;
}
break;
}
default: break;
}
}
void CPatterned::Think(float dt, CStateManager& mgr)
{ {
if (!GetActive()) if (!GetActive())
return; return;
@ -103,6 +209,146 @@ void CPatterned::Think(float dt, urde::CStateManager& mgr)
if (froz > 0.8f) if (froz > 0.8f)
x400_29_ = true; x400_29_ = true;
} }
if (x400_25_ && !x400_28_ && x400_29_)
{
if (x3e0_ > 0.f && x400_29_)
{
SendScriptMsgs(EScriptObjectState::UNKS4, mgr, EScriptObjectMessage::None);
sub8007ab34(mgr);
}
else
{
SendScriptMsgs(EScriptObjectState::UNKS4, mgr, EScriptObjectMessage::None);
sub8007ace8(mgr);
}
}
else if (!x400_29_)
{
x3e0_ -= dt;
if (x403_26_)
{
if (x330_stateMachineState.sub8007FB9C())
{
u32 unk = x330_stateMachineState.sub8007FB9C();
bool isDead = false; //sub8007A454(unk, "Dead"sv);
if (!isDead && x330_stateMachineState.x8_time > 15.f)
sub8007ace8(mgr);
}
}
}
sub8007a68c(dt, mgr);
x3e4_ = HealthInfo(mgr)->GetHP();
if (!x330_stateMachineState.x4_state)
x330_stateMachineState.SetState(mgr, *this, GetStateMachine(), "Start"sv);
zeus::CVector3f diffVec = x4e4_ - GetTranslation();
if (!x328_25_)
diffVec.z = 0.f;
if (diffVec.magSquared() > (0.1f * dt))
x4f0_ += dt;
else
x4f0_ = 0.f;
if (x460_.x81_26_ && x401_31_ && x402_24_)
Shock(0.5f + mgr.GetActiveRandom()->Range(0.f, 0.5f), 0.2f);
x402_24_ = x401_24_;
x401_31_ = false;
if (x450_bodyController->IsElectrocuting())
{
mgr.GetActorModelParticles()->StartElectric(*this);
if (x3f0_ > 0.f && x400_25_)
{
CDamageInfo dInfo({EWeaponType::Wave}, x3f0_, 0.f, 0.f);
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
}
}
else
{
if (x3f0_!= 0.f)
{
//x450_bodyController->sub80139f0c(x3f0_);
mgr.GetActorModelParticles()->StopElectric(*this);
}
}
if (x450_bodyController->IsOnFire())
{
if (x400_25_)
{
mgr.GetActorModelParticles()->LightDudeOnFire(*this);
CDamageInfo dInfo({EWeaponType::Wave}, x3f0_, 0.f, 0.f);
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
}
}
else if (x3ec_ > 0.f)
x3ec_ = 0.f;
//if (x450_bodyController->IsFrozen())
//mgr.GetActorModelParticles()->sub801e5044(*this);
if (!x401_27_ || x401_28_)
x3e8_ = -0.33333334f;
if (x401_30_)
{
x401_30_ = false;
Death(mgr, GetTransform().frontVector(), EStateMsg::Twenty);
}
float thinkDt = (x400_25_ ? dt : dt * sub80078a88());
x450_bodyController->Update(thinkDt, mgr);
x450_bodyController->MultiplyPlaybackRate(x3b4_speed);
SAdvancementDeltas deltas = UpdateAnimation(thinkDt, mgr, !x450_bodyController->IsFrozen());
x434_posDelta = deltas.x0_posDelta;
x440_rotDelta = deltas.xc_rotDelta;
if (x403_25_ && x450_bodyController->GetPercentageFrozen() < 1.f)
x330_stateMachineState.Update(mgr, *this, thinkDt);
ThinkAboutMove(thinkDt);
//x460_.sub80233b58(thinkDt, mgr, *this);
x4e4_ = GetTranslation() + PredictMotion(thinkDt).x0_translation;
x328_26_ = false;
if (x420_ > 0.f)
x420_ -= dt;
if (x401_28_ && x3f4_ > dt)
x3f4_ -= dt;
xd0_thermalMag = x50c_thermalMag;
sub8007a5b8(dt);
if (!x450_bodyController->IsFrozen())
{
if (x3a0_ == zeus::CVector3f())
x3a0_ = GetTranslation();
if (x3cc_playerLeashRadius != 0.f)
{
zeus::CVector3f diffVec = (GetTranslation() - mgr.GetPlayer().GetTranslation());
if (diffVec.magSquared() > x3cc_playerLeashRadius)
x3d4_curPlayerLeashTime += dt;
else
x3d4_curPlayerLeashTime = 0.f;
}
}
else
RemoveEmitter();
if (x2f8_ > 0.f)
x2f8_ -= dt;
} }
void CPatterned::Touch(CActor& act, CStateManager& mgr) void CPatterned::Touch(CActor& act, CStateManager& mgr)
@ -117,6 +363,17 @@ void CPatterned::Touch(CActor& act, CStateManager& mgr)
} }
} }
std::experimental::optional<zeus::CAABox> CPatterned::GetTouchBounds() const
{
return GetBoundingBox();
}
bool CPatterned::CanRenderUnsorted(const urde::CStateManager& mgr) const
{
return x64_modelData->GetAnimationData()->GetParticleDB().AreAnySystemsDrawnWithModel() ? false :
CActor::CanRenderUnsorted(mgr);
}
zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float dt) const zeus::CVector3f CPatterned::GetAimPosition(const urde::CStateManager& mgr, float dt) const
{ {
zeus::CVector3f offset; zeus::CVector3f offset;
@ -172,4 +429,109 @@ void CPatterned::SetupPlayerCollision(bool v)
} }
float CPatterned::sub80078a88()
{
float f0 = (x401_28_ ? x3f4_ / 1.f : 1.f);
return zeus::max(0.1f, f0);
}
void CPatterned::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum)
{
#if 1
if (mgr.GetPlayerState()->GetActiveVisor(mgr ) == CPlayerState::EPlayerVisor::Thermal)
{
SetCalculateLighting(false);
x90_actorLights->BuildConstantAmbientLighting(zeus::CColor::skWhite);
}
else
SetCalculateLighting(true);
zeus::CColor col = x42c_;
u8 alpha = GetModelAlphau8(mgr);
if (x402_27_ && mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)
alpha = 0x4C;
if (alpha < 0xFF)
{
if (col.r == 0.f && col.g == 0.f && col.b == 0.f)
col = zeus::CColor::skWhite;
}
if (x401_29_ && alpha > 0x7F)
{
}
#endif
CActor::PreRender(mgr, frustum);
}
void CPatterned::ThinkAboutMove(float dt)
{
bool doMove = true;
if (!x328_25_ && ! x328_27_onGround)
{
x310_.zeroOut();
doMove = false;
}
if (doMove && x39c_ < x390_)
{
zeus::CVector3f frontVec = GetTransform().frontVector();
zeus::CVector3f x31cCpy = x31c_;
if (x31c_.magSquared() > 0.1f)
x31cCpy.normalize();
float mag = frontVec.dot(x31cCpy);
switch (x3f8_)
{
case 0:
if (!x328_26_)
break;
case 1:
{
doMove = false;
if (mag > 0.85)
{
doMove = true;
x3f8_ = 2;
break;
}
x3f8_ = 1;
}
case 2:
x3f8_ = 3;
case 3:
{
doMove = true;
if (!x328_26_)
{
x3f8_ = 0;
break;
}
if (mag > 0.89)
x3f8_ = 4;
break;
}
case 4:
{
x328_24_ = true;
doMove = false;
x3f8_ = 0;
}
default:
break;
}
}
if (!x401_26_ && doMove)
{
const CBodyState* state = x450_bodyController->GetBodyStateInfo().GetCurrentState();
if (state->ApplyAnimationDeltas() && !zeus::close_enough(x2e0_ - GetTranslation(), {}))
MoveToOR((x64_modelData->GetScale() * x434_posDelta) * x55c_, dt);
}
RotateToOR(x440_rotDelta, dt);
}
} }

View File

@ -10,10 +10,14 @@
#include "TCastTo.hpp" #include "TCastTo.hpp"
#include "CDamageInfo.hpp" #include "CDamageInfo.hpp"
#ifndef DEFINE_PATTERNED
#define DEFINE_PATTERNED(type) static constexpr ECharacter CharacterType = ECharacter::type;
#endif
namespace urde namespace urde
{ {
class CPatternedInfo; class CPatternedInfo;
class CProjectileInfo;
class CPatternedUnknown2 class CPatternedUnknown2
{ {
friend class CPatterned; friend class CPatterned;
@ -112,6 +116,7 @@ protected:
float x308_attackTimeVariation; float x308_attackTimeVariation;
u32 x30c_ = 0; u32 x30c_ = 0;
zeus::CVector3f x310_; zeus::CVector3f x310_;
zeus::CVector3f x31c_;
union union
{ {
struct struct
@ -152,7 +157,7 @@ protected:
float x3c8_leashRadius; float x3c8_leashRadius;
float x3cc_playerLeashRadius; float x3cc_playerLeashRadius;
float x3d0_playerLeashTime; float x3d0_playerLeashTime;
float x3d4_ = 0.f; float x3d4_curPlayerLeashTime = 0.f;
float x3d8_; float x3d8_;
float x3dc_; float x3dc_;
float x3e0_; float x3e0_;
@ -199,12 +204,14 @@ protected:
u32 _dummy2 = 0; u32 _dummy2 = 0;
}; };
CDamageInfo x404_; CDamageInfo x404_contactDamage;
float x420_ = 0.f; float x420_ = 0.f;
float x424_damageWaitTime; float x424_damageWaitTime;
float x428_ = -1.f; float x428_ = -1.f;
zeus::CColor x42c_ = zeus::CColor::skBlack; zeus::CColor x42c_ = zeus::CColor::skBlack;
zeus::CColor x430_ = skDamageColor; zeus::CColor x430_ = skDamageColor;
zeus::CVector3f x434_posDelta;
zeus::CQuaternion x440_rotDelta;
CSteeringBehaviors x45c_; CSteeringBehaviors x45c_;
std::unique_ptr<CBodyController> x450_bodyController; std::unique_ptr<CBodyController> x450_bodyController;
u32 x454_deathSfx; u32 x454_deathSfx;
@ -226,20 +233,21 @@ protected:
std::experimental::optional<TLockedToken<CElectricDescription>> x530_; std::experimental::optional<TLockedToken<CElectricDescription>> x530_;
zeus::CVector3f x540_; zeus::CVector3f x540_;
std::experimental::optional<TLockedToken<CGenDescription>> x54c_; std::experimental::optional<TLockedToken<CGenDescription>> x54c_;
/* x55c_ */ zeus::CVector3f x55c_;
/* x560_ */
/* x564_ */
public: public:
CPatterned(ECharacter character, TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info, CPatterned(ECharacter character, TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo,
CPatterned::EMovementType movement, EColliderType collider, EBodyType body, CPatterned::EMovementType movement, EColliderType collider, EBodyType body,
const CActorParameters& params, int variant); const CActorParameters& params, int variant);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) {} void Accept(IVisitor&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&); void Think(float, CStateManager&);
void PreRender(CStateManager&, const zeus::CFrustum&);
void Touch(CActor&, CStateManager&); void Touch(CActor&, CStateManager&);
virtual void Death(CStateManager&, const zeus::CVector3f&, EStateMsg) {} std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
virtual void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float) {} bool CanRenderUnsorted(const CStateManager& mgr) const;
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const
{ {
return GetAimPosition(mgr, 0.f); return GetAimPosition(mgr, 0.f);
@ -247,6 +255,46 @@ public:
zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const; zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const;
void Death(CStateManager&, const zeus::CVector3f&, EStateMsg) {}
void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float) {}
void TakeDamage(const zeus::CVector3f&, float) { x428_ = 0.33f;}
bool FixedRandom(CStateManager&, float) { return x330_stateMachineState.GetRandom() < x330_stateMachineState.x14_; }
bool Random(CStateManager&, float dt) { return x330_stateMachineState.GetRandom() < dt; }
//bool FixedDelay(CStateManager&, float dt) { return x330_stateMachineState.GetDelay() == dt; }
bool Default() { return true; }
virtual bool KnockbackWhenFrozen() const { return true;}
virtual void sub8007ace8(CStateManager&) {}
virtual void sub8007ab34(CStateManager&) {}
virtual void Burn(float, float) {}
virtual void Shock(float, float) {}
virtual void ThinkAboutMove(float);
virtual void GetSearchPath() {}
virtual CDamageInfo GetContactDamage() { return x404_contactDamage; }
virtual u8 GetModelAlphau8(const CStateManager&) const { return u8(x42c_.a * 255);}
virtual bool IsOnGround() const { return x328_27_onGround; }
virtual float GetGravityConstant() const { return 24.525002f; }
virtual CProjectileInfo* GetProjectileInfo() { return nullptr; }
virtual void PhazeOut(CStateManager&) {}
virtual TLockedToken<CGenDescription>& GetX520() { return x520_.value(); }
float GetDamageDuration() const { return x504_damageDur; }
zeus::CVector3f GetGunEyePos() const;
void BuildBodyController(EBodyType);
const CBodyController* GetBodyController() const { return x450_bodyController.get(); }
CBodyController* BodyController() { return x450_bodyController.get(); }
void SetupPlayerCollision(bool);
void sub8007a68c(float, CStateManager&) {}
float sub80078a88();
void sub8007a5b8(float) {}
bool GetX328_26() const { return x328_26_; }
bool GetX402_28() const { return x402_28_; }
//region Casting Functions
template <class T> template <class T>
static T* CastTo(CEntity* ent) static T* CastTo(CEntity* ent)
{ {
@ -279,18 +327,7 @@ public:
return nullptr; return nullptr;
} }
bool GetX328_26() const { return x328_26_; } //endregion
bool GetX402_28() const { return x402_28_; }
virtual bool IsOnGround() const { return x328_27_onGround; }
virtual float GetGravityConstant() const { return 24.525002f; }
float GetDamageDuration() const { return x504_damageDur; }
zeus::CVector3f GetGunEyePos() const;
void BuildBodyController(EBodyType);
const CBodyController* GetBodyController() const { return x450_bodyController.get(); }
CBodyController* BodyController() { return x450_bodyController.get(); }
void SetupPlayerCollision(bool);
}; };
} }

View File

@ -18,7 +18,7 @@ CPatternedInfo::CPatternedInfo(CInputStream& in, u32 pcount)
, x28_leashRadius(in.readFloatBig()) , x28_leashRadius(in.readFloatBig())
, x2c_playerLeashRadius(in.readFloatBig()) , x2c_playerLeashRadius(in.readFloatBig())
, x30_playerLeashTime(in.readFloatBig()) , x30_playerLeashTime(in.readFloatBig())
, x34_damageInfo(in) , x34_contactDamageInfo(in)
, x50_damageWaitTime(in.readFloatBig()) , x50_damageWaitTime(in.readFloatBig())
, x54_healthInfo(in) , x54_healthInfo(in)
, x5c_damageVulnerability(in) , x5c_damageVulnerability(in)

View File

@ -27,7 +27,7 @@ class CPatternedInfo
float x28_leashRadius; float x28_leashRadius;
float x2c_playerLeashRadius; float x2c_playerLeashRadius;
float x30_playerLeashTime; float x30_playerLeashTime;
CDamageInfo x34_damageInfo; CDamageInfo x34_contactDamageInfo;
float x50_damageWaitTime; float x50_damageWaitTime;
CHealthInfo x54_healthInfo; CHealthInfo x54_healthInfo;
CDamageVulnerability x5c_damageVulnerability; CDamageVulnerability x5c_damageVulnerability;

View File

@ -86,7 +86,7 @@ void CStateMachineState::Setup(const CStateMachine* machine)
x0_machine = machine; x0_machine = machine;
x4_state = nullptr; x4_state = nullptr;
x8_time = 0.f; x8_time = 0.f;
xc_ = 0.f; xc_random = 0.f;
x10_ = 0.f; x10_ = 0.f;
} }

View File

@ -35,6 +35,7 @@ public:
class CAiState class CAiState
{ {
friend class CStateMachineState;
CAiStateFunc x0_func; CAiStateFunc x0_func;
const char* x4_name; const char* x4_name;
u32 x8_; u32 x8_;
@ -77,11 +78,13 @@ public:
class CStateMachineState class CStateMachineState
{ {
friend class CPatterned;
const CStateMachine* x0_machine = nullptr; const CStateMachine* x0_machine = nullptr;
CAiState* x4_state = nullptr; CAiState* x4_state = nullptr;
float x8_time = 0.f; float x8_time = 0.f;
float xc_ = 0.f; float xc_random = 0.f;
float x10_ = 0.f; float x10_ = 0.f;
float x14_;
union union
{ {
struct struct
@ -93,7 +96,7 @@ class CStateMachineState
public: public:
CStateMachineState()=default; CStateMachineState()=default;
void GetActorState() const; CAiState* GetActorState() const { return x4_state; }
float GetTime() const; float GetTime() const;
void Update(CStateManager& mgr, CAi& ai, float delta) void Update(CStateManager& mgr, CAi& ai, float delta)
@ -108,8 +111,15 @@ public:
void Setup(const CStateMachine* machine); void Setup(const CStateMachine* machine);
std::string GetName() const; std::string GetName() const;
void SetDelay(float); void SetDelay(float);
void GetRandom() const; float GetRandom() const { return xc_random; }
float GetDelay() const; float GetDelay() const;
u32 sub8007FB9C() const
{
if (x4_state)
return x4_state->xc_;
return 0;
}
}; };
CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, CFactoryFnReturn FAiFiniteStateMachineFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,