Properly cleanup Xorg in visigen, various fixes and cleanups in URDE, more CRidley imps

This commit is contained in:
Phillip Stephens 2019-11-19 15:06:25 -08:00
parent 4762c7b832
commit 8b6dff70b4
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
20 changed files with 610 additions and 190 deletions

View File

@ -23,6 +23,9 @@ public:
std::vector<CAssetId> x20_elsc;
std::vector<CAssetId> x30_elsc;
CParticleResData(CInputStream& in, u16 tableCount);
CParticleResData(const std::vector<CAssetId>& part, const std::vector<CAssetId>& swhc,
const std::vector<CAssetId>& elsc1, const std::vector<CAssetId>& elsc2)
: x0_part(part), x10_swhc(swhc), x20_elsc(elsc1), x30_elsc(elsc2) {}
};
private:

View File

@ -298,7 +298,7 @@ CSegIdToIndexConverter::CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals
std::fill(std::begin(x0_indices), std::end(x0_indices), -1);
for (u32 b = 0; b < totals.x24_boneChanCount; ++b) {
u16 segId = totals.xc_segIds2[b];
if (segId >= 96)
if (segId >= 100)
continue;
x0_indices[segId] = b;
}

View File

@ -85,7 +85,7 @@ public:
};
class CSegIdToIndexConverter {
s32 x0_indices[96];
std::array<s32,100> x0_indices;
public:
CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals& totals);

View File

@ -27,6 +27,7 @@ class CStaticRes {
zeus::CVector3f x4_scale;
public:
constexpr CStaticRes()=default;
CStaticRes(CAssetId id, const zeus::CVector3f& scale) : x0_cmdlId(id), x4_scale(scale) {}
CAssetId GetId() const { return x0_cmdlId; }

View File

@ -64,7 +64,7 @@ enum class EHurledState {
Seven
};
enum class EFallState { Invalid = -1, Zero, One };
enum class EFallState { Invalid = -1, Zero, One , Two};
enum class EReactionType { Invalid = -1, Zero, One, Two, Three };

View File

@ -1189,6 +1189,7 @@ void CBooRenderer::PrepareDynamicLights(const std::vector<CLight>& lights) {
void CBooRenderer::SetGXRegister1Color(const zeus::CColor& color) { CGraphics::g_ColorRegs[1] = color; }
void CBooRenderer::SetWorldLightFadeLevel(float level) { x2fc_tevReg1Color = zeus::CColor(level, level, level, 1.f); }
void CBooRenderer::SetWorldLightMultiplyColor(const zeus::CColor& color) { CGraphics::g_ColorRegs[2] = color;}
void CBooRenderer::ReallyDrawPhazonSuitIndirectEffect(const zeus::CColor& vertColor, /*const CTexture& maskTex,*/
const CTexture& indTex, const zeus::CColor& modColor, float scale,

View File

@ -284,6 +284,7 @@ public:
void PrepareDynamicLights(const std::vector<CLight>& lights) override;
void SetGXRegister1Color(const zeus::CColor& color) override;
void SetWorldLightFadeLevel(float level) override;
void SetWorldLightMultiplyColor(const zeus::CColor& col) override;
void DrawPhazonSuitIndirectEffect(const zeus::CColor& nonIndirectMod, const TLockedToken<CTexture>& indTex,
const zeus::CColor& indirectMod, float blurRadius, float indScale, float indOffX,
float indOffY);

View File

@ -96,9 +96,10 @@ public:
virtual void DoThermalBlendCold() = 0;
virtual void DoThermalBlendHot() = 0;
virtual u32 GetStaticWorldDataSize() = 0;
virtual void PrepareDynamicLights(const std::vector<CLight>& lights) = 0;
virtual void SetGXRegister1Color(const zeus::CColor& color) = 0;
virtual void SetWorldLightMultiplyColor(const zeus::CColor& color) = 0;
virtual void SetWorldLightFadeLevel(float level) = 0;
virtual void PrepareDynamicLights(const std::vector<CLight>& lights) = 0;
};
} // namespace urde

View File

@ -36,6 +36,7 @@ set(MP1_WORLD_SOURCES
CFlaahgraProjectile.hpp CFlaahgraProjectile.cpp
CSpankWeed.hpp CSpankWeed.cpp
CPuddleSpore.hpp CPuddleSpore.cpp
CRipper.hpp CRipper.cpp)
CRipper.hpp CRipper.cpp
CThardus.hpp CThardus.cpp)
runtime_add_list(World MP1_WORLD_SOURCES)

View File

@ -43,7 +43,7 @@ struct SSomeRidleyStruct2 {
s32 x8_;
};
std::array<std::array<SSomeRidleyStruct2, 12>, 5> skSomeRidleyStruct{{
constexpr std::array<std::array<SSomeRidleyStruct2, 12>, 5> skSomeRidleyStruct{{
{{
{0, 100.f, -1},
{3, 100.f, -1},
@ -116,12 +116,12 @@ std::array<std::array<SSomeRidleyStruct2, 12>, 5> skSomeRidleyStruct{{
}},
}};
std::array<SSomeRidleyStruct, 5> skSomeStruct{{{4, 6, 50.f, 50.f, 0.f, 33.f, 0.f, 1, 0, 0, 0, 0},
{4, 6, 20.f, 20.f, 60.f, 50.f, 0.f, 2, 0, 0, 0, 0},
{4, 6, 40.f, 40.f, 20.f, 50.f, 50.f, 2, 1, 0, 0, 0},
{3, 5, 10.f, 15.f, 75.f, 100.f, 25.f, 2, 0, 0, 0, 0},
{3, 5, 30.f, 30.f, 40.f, 50.f, 50.f, 2, 1, 0, 0, 0}}};
std::array skWingBones{
constexpr std::array<SSomeRidleyStruct, 5> skSomeStruct{{{4, 6, 50.f, 50.f, 0.f, 33.f, 0.f, 1, 0, 0, 0, 0},
{4, 6, 20.f, 20.f, 60.f, 50.f, 0.f, 2, 0, 0, 0, 0},
{4, 6, 40.f, 40.f, 20.f, 50.f, 50.f, 2, 1, 0, 0, 0},
{3, 5, 10.f, 15.f, 75.f, 100.f, 25.f, 2, 0, 0, 0, 0},
{3, 5, 30.f, 30.f, 40.f, 50.f, 50.f, 2, 1, 0, 0, 0}}};
constexpr std::array skWingBones{
"L_wingBone1_1"sv, "L_wingBone1_2"sv, "L_wingBone2_1"sv, "L_wingBone2_2"sv, "L_wingBone3_1"sv,
"L_wingBone3_2"sv, "L_wingFlesh1_1"sv, "L_wingFlesh1_2"sv, "L_wingFlesh2_1"sv, "L_wingFlesh2_2"sv,
"L_wingFlesh3_1"sv, "L_wingFlesh3_2"sv, "R_wingBone1_1"sv, "R_wingBone1_2"sv, "R_wingBone2_1"sv,
@ -130,7 +130,7 @@ std::array skWingBones{
"L_wingtip_2_LCTR"sv, "L_wingtip_3_LCTR"sv, "R_wingtip_1_LCTR"sv, "R_wingtip_2_LCTR"sv, "R_wingtip_3_LCTR"sv,
};
std::array skWingEffects{
constexpr std::array skWingEffects{
"WingSmokeSmall1"sv,
"WingSmokeSmall2"sv,
"WingSmokeSmall3"sv,
@ -157,21 +157,21 @@ std::array skWingEffects{
"WingSparks8"sv,
};
std::array<SOBBRadiiJointInfo, 4> skTail{{{"Tail_1", "Tail_3", 0.66f},
{"Tail_3", "Tail_5", 0.66f},
{"Tail_5", "Tail_7", 0.66f},
{"Tail_7", "Tail_9", 0.66f}}};
constexpr std::array<SOBBRadiiJointInfo, 4> skTail{{{"Tail_1", "Tail_3", 0.66f},
{"Tail_3", "Tail_5", 0.66f},
{"Tail_5", "Tail_7", 0.66f},
{"Tail_7", "Tail_9", 0.66f}}};
std::array<SSphereJointInfo, 10> skSphereJoints{{{"Skeleton_Root", 0.6f},
{"Spine_2", 0.6f},
{"breastPlate_LCTR", 0.6f},
{"Head_1", 0.6f},
{"L_wrist", 0.5f},
{"R_wrist", 0.5f},
{"L_ankle", 0.6f},
{"R_ankle", 0.6f},
{"L_pinky_1", 0.4f},
{"R_pinky_1", 0.4f}}};
constexpr std::array<SSphereJointInfo, 10> skSphereJoints{{{"Skeleton_Root", 0.6f},
{"Spine_2", 0.6f},
{"breastPlate_LCTR", 0.6f},
{"Head_1", 0.6f},
{"L_wrist", 0.5f},
{"R_wrist", 0.5f},
{"L_ankle", 0.6f},
{"R_ankle", 0.6f},
{"L_pinky_1", 0.4f},
{"R_pinky_1", 0.4f}}};
struct SSomeRidleyStruct3 {
float x0_;
@ -182,12 +182,29 @@ struct SSomeRidleyStruct3 {
float x14_;
};
std::array<SSomeRidleyStruct3, 6> skFloats{{{0.0, 20.0, 40.0, 0.0, 0.0, 40.0},
{0.0, 0.0, 70.0, 0.0, 0.0, 30.0},
{0.0, 60.0, 0.0, 0.0, 0.0, 40.0},
{0.0, 40.0, 30.0, 0.0, 0.0, 30.0},
{0.0, 0.0, 50.0, 0.0, 0.0, 50.0},
{0.0, 40.0, 60.0, 0.0, 0.0, 0.0}}};
constexpr std::array<SSomeRidleyStruct3, 6> skFloats{{{0.0, 20.0, 40.0, 0.0, 0.0, 40.0},
{0.0, 0.0, 70.0, 0.0, 0.0, 30.0},
{0.0, 60.0, 0.0, 0.0, 0.0, 40.0},
{0.0, 40.0, 30.0, 0.0, 0.0, 30.0},
{0.0, 0.0, 50.0, 0.0, 0.0, 50.0},
{0.0, 40.0, 60.0, 0.0, 0.0, 0.0}}};
const CDamageVulnerability skDirectNormal{EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EDeflectType::None};
const CDamageVulnerability skIceWeakness{EVulnerability::DirectNormal, EVulnerability::DirectWeak,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EVulnerability::DirectNormal,
EVulnerability::DirectNormal, EDeflectType::None};
} // namespace
CRidleyData::CRidleyData(CInputStream& in, u32 propCount)
: x0_(in)
@ -367,7 +384,7 @@ void CRidley::SetupCollisionActors(CStateManager& mgr) {
for (size_t i = 0; i < x984_bodyCollision->GetNumCollisionActors(); ++i) {
const auto& colDesc = x984_bodyCollision->GetCollisionDescFromIndex(i);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(colDesc.GetCollisionActorId())) {
colAct->SetDamageVulnerability(CDamageVulnerability::NormalVulnerabilty());
colAct->SetDamageVulnerability(skDirectNormal);
colAct->HealthInfo(mgr)->SetHP(1000.f);
colAct->SetMaterialFilter(CMaterialFilter::MakeInclude({EMaterialTypes::Player, EMaterialTypes::Platform}));
colAct->SetWeaponCollisionResponseType(EWeaponCollisionResponseTypes::EnemyNormal);
@ -396,8 +413,8 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
break;
}
case EScriptObjectMessage::Activate: {
mgr.SetBossParams(GetUniqueId(), xb1c_ + (xb18_ + xcb8_), 90);
HealthInfo(mgr)->SetHP(xb1c_ + (xb10_ + xb18_));
mgr.SetBossParams(GetUniqueId(), xb1c_ + xcb8_ + xb18_, 90);
HealthInfo(mgr)->SetHP(xb1c_ + xb10_ + xb18_);
mgr.GetPlayer().SetIsOverrideRadarRadius(true);
mgr.GetPlayer().SetRadarXYRadiusOverride(350.f);
mgr.GetPlayer().SetRadarZRadiusOverride(175.f);
@ -428,7 +445,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
if (TCastToConstPtr<CScriptWaypoint> wpNext = mgr.GetObjectById(wp->NextWaypoint(mgr))) {
xab4_ = (wpNext->GetTranslation() - wp->GetTranslation()).toVec2f().magnitude();
xab8_ = wpNext->GetTranslation().z() - xa84_.origin.z();
if (TCastToConstPtr<CScriptWaypoint> wpNextNext = mgr.GetObjectById(wp->NextWaypoint(mgr))) {
if (TCastToConstPtr<CScriptWaypoint> wpNextNext = mgr.GetObjectById(wpNext->NextWaypoint(mgr))) {
xabc_ = (wpNextNext->GetTranslation().toVec2f() - xa84_.origin.toVec2f()).magnitude();
xac0_ = wpNextNext->GetTranslation().z() - xa84_.origin.z();
zeus::CVector3f min(xa84_.origin.x() - xabc_, xa84_.origin.y() - xabc_, xa84_.origin.z() - 10.f);
@ -441,15 +458,15 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
}
case EScriptObjectMessage::Damage: {
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
float f31 = 1000.f - colAct->HealthInfo(mgr)->GetHP();
float lowHealth = 1000.f - colAct->HealthInfo(mgr)->GetHP();
colAct->HealthInfo(mgr)->SetHP(1000.f);
bool r27 = false;
bool dontKnockback = false;
if (xc64_aiStage == 2) {
if (xa33_28_) {
r27 = true;
dontKnockback = true;
} else {
bool r26 = false;
xb10_ -= f31;
xb10_ -= lowHealth;
xb24_ = 0.33f;
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb10_ <= 0.f) {
@ -468,17 +485,15 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
} else {
if (xb10_ < xcbc_) {
xa32_27_ = true;
r27 = true;
dontKnockback = true;
xcb0_ += 1;
u32 r0 = 4;
if (xcb0_ < 5)
r0 = xcb0_;
xcb0_ = r0;
xcb0_ = xcb0_ < 5 ? xcb0_ : 4;
r26 = true;
xcbc_ = 2.f * (5 - xcb0_);
xcbc_ = .2f * (5 - (xcb0_ + 1)) * xcb8_;
xcb4_ = 0;
xcc8_ = 2.f * 0.33f;
} else if (xa33_26_ && xa31_31_ && f31 > x568_data.x3f4_) {
} else if (xa33_26_ && !xa31_31_ && lowHealth > x568_data.x3f4_) {
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Zero));
}
@ -489,7 +504,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
if (xa32_29_) {
zeus::CTransform xf = GetLctrTransform(xb90_headSegId);
if (xf.basis[1].dot(mgr.GetPlayer().GetTranslation() - xf.origin) < 0.5f) {
r27 = true;
dontKnockback = true;
} else {
TakeDamage(zeus::skForward, 1.f);
xb20_ = 0.33f;
@ -498,11 +513,12 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
CWeaponMode wMode = proj->GetDamageInfo().GetWeaponMode();
if (!wMode.IsCharged() && !wMode.IsComboed() && wMode.GetType() == EWeaponType::Missile)
xb14_ = 0.f;
xb14_ -= f31;
xb14_ -= lowHealth;
xb24_ = 0.33f;
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb10_ <= 0.f) {
xa32_29_ = false;
dontKnockback = true;
xa32_28_shotAt = true;
xb14_ = x568_data.x38_;
}
@ -510,29 +526,29 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
} else if (xa31_27_) {
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb18_ > 0.f) {
xb18_ -= f31;
xb18_ -= lowHealth;
if (xb18_ <= 0.f) {
xa31_26_ = true;
r27 = true;
dontKnockback = true;
xb18_ = 0.f;
xcbc_ = 0.6667 * x568_data.x40_;
} else if (xb18_ < xcbc_) {
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.33329999f * x568_data.x3c_);
xcbc_ -= (0.333f * x568_data.x3c_);
}
}
} else {
xb1c_ -= f31;
xb1c_ -= lowHealth;
if (xb1c_ <= 0.f) {
x401_30_pendingDeath = true;
mgr.GetPlayer().SetIsOverrideRadarRadius(false);
xb1c_ = 0.f;
} else if (xb1c_ < xcbc_) {
r27 = true;
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.33329999f * x568_data.x3c_);
xcbc_ -= (0.333f * x568_data.x40_);
}
}
}
@ -540,7 +556,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
}
HealthInfo(mgr)->SetHP(xb1c_ + xb10_ + xb18_);
if (r27) {
if (!dontKnockback) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
KnockBack(proj->GetTranslation() - proj->GetPreviousPos(), mgr, proj->GetDamageInfo(), EKnockBackType::Radius,
false, proj->GetDamageInfo().GetKnockBackPower());
@ -550,25 +566,30 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
break;
}
case EScriptObjectMessage::InvulnDamage: {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid)) {
TUniqueId tmpId = kInvalidUniqueId;
bool r4 = false;
if (xc64_aiStage == 2 && xa31_31_) {
tmpId = x98a_breastPlateId;
r4 = true;
} else if (xc64_aiStage == 3) {
if (xa32_29_) {
tmpId = x988_headId;
r4 = true;
} else if (xa31_27_) {
/* This code never executes, should have a `TCastTo<CCollisionActor>` followed by `GetLastTouchedObject` */
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(uid)) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
TUniqueId tmpId = kInvalidUniqueId;
bool doDamage = false;
if (xc64_aiStage == 3) {
if (!xa32_29_ && xa31_27_) {
tmpId = x98a_breastPlateId;
doDamage = true;
} else {
tmpId = x988_headId;
doDamage = true;
}
} else if (xc64_aiStage == 2 && !xa31_31_) {
tmpId = x98a_breastPlateId;
r4 = true;
doDamage = true;
}
}
if (!r4) {
mgr.ApplyDamage(uid, tmpId, proj->GetOwnerId(), proj->GetDamageInfo(),
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
if (doDamage) {
CDamageInfo info = proj->GetDamageInfo();
info.SetRadius(0.f);
mgr.ApplyDamage(uid, tmpId, proj->GetOwnerId(), info,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
}
}
}
break;
@ -624,7 +645,8 @@ void CRidley::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
}
CPlayerState::EPlayerVisor r28 = mgr.GetPlayerState()->GetActiveVisor(mgr);
if (r28 == CPlayerState::EPlayerVisor::Thermal && GetModelData()->GetNumMaterialSets() == (matSet + 1))
bool atLastMat = GetModelData()->GetNumMaterialSets() == (matSet + 1);
if (r28 == CPlayerState::EPlayerVisor::Thermal && atLastMat)
xb4_drawFlags.x2_flags |= 0x40;
else
xb4_drawFlags.x2_flags &= 0x40;
@ -632,13 +654,49 @@ void CRidley::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
if (xa33_27_) {
float zDiff = std::max(0.f, GetTranslation().z() - xa84_.origin.z());
// xccc_ = 1.f + zeus::Clamp()
xccc_ = 1.f + zeus::clamp(0.f, zDiff - 20.f, 1.f);
zeus::CVector3f extents = x9c_renderBounds.max - x9c_renderBounds.min;
zeus::CVector3f something = 0.5f * (xccc_ * extents - extents);
zeus::CAABox box(GetRenderBounds().min - something, GetRenderBounds().max + something);
if ((r28 != CPlayerState::EPlayerVisor::Combat && r28 != CPlayerState::EPlayerVisor::Scan) ||
!xac4_.intersects(box) || zDiff <= -10.f) {
xd10_->Unset_X80();
} else {
xd10_->RenderShadowBuffer(mgr, *GetModelData(), GetTransform(), atLastMat, {}, xccc_, 10.f + zDiff);
}
} else {
xd10_->Unset_X80();
}
}
void CRidley::Render(const CStateManager& mgr) const { CPatterned::Render(mgr); }
void CRidley::Render(const CStateManager& mgr) const {
zeus::CColor multiplyColor = zeus::skBlack;
if (xb24_ > 0.f) {
multiplyColor = zeus::CColor::lerp(zeus::skWhite, x430_damageColor, xb24_ / 0.33f);
}
g_Renderer->SetWorldLightMultiplyColor(multiplyColor);
const zeus::CTransform xf = GetLctrTransform(xa30_breastPlateSegId);
if (xa31_25_) {
if (xb24_ > 0.f) {
x9e4_.Render(mgr, xf, GetActorLights(),
CModelFlags(2, 0, 3, zeus::CColor::lerp(zeus::skBlack, x430_damageColor, xb24_ / 0.33f)));
} else {
x9e4_.Render(mgr, xf, GetActorLights(), CModelFlags(0, 0, 3, zeus::skWhite));
}
} else if (xa31_24_) {
if (xb20_ > 0.f) {
x998_.Render(mgr, xf, GetActorLights(),
CModelFlags(2, 0, 3, zeus::CColor::lerp(zeus::skBlack, x430_damageColor, xb20_ / 0.33f)));
} else {
x998_.Render(mgr, xf, GetActorLights(), CModelFlags(0, 0, 3, zeus::skWhite));
}
}
CPatterned::Render(mgr);
}
void CRidley::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const {
CPatterned::AddToRenderer(frustum, mgr);
if (xce0_ && frustum.aabbFrustumTest(*xce0_->GetBounds())) {
@ -672,7 +730,6 @@ void CRidley::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUs
}
case EUserEventType::EggLay: {
if (xa32_24_) {
if (!xc3c_.Token().IsLoaded()) {
xc3c_.Token().GetObj();
break;
@ -693,7 +750,7 @@ void CRidley::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUs
mgr.AddObject(proj);
proj->SetCameraShake(x568_data.xcc_);
} else if (xc64_aiStage == 3) {
xa31_27_ = false;
xa31_24_ = false;
}
break;
}
@ -787,7 +844,7 @@ void CRidley::sub8025784c(CStateManager& mgr) {
for (size_t i = 0; i < x984_bodyCollision->GetNumCollisionActors(); ++i) {
const auto& colDesc = x984_bodyCollision->GetCollisionDescFromIndex(i);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(colDesc.GetCollisionActorId())) {
colAct->SetDamageVulnerability(CDamageVulnerability::ImmuneVulnerabilty());
colAct->SetDamageVulnerability(i == 3 ? skIceWeakness : CDamageVulnerability::ImmuneVulnerabilty());
colAct->HealthInfo(mgr)->SetHP(1000.f);
colAct->CreateShadow(true);
}
@ -798,12 +855,14 @@ void CRidley::sub8025784c(CStateManager& mgr) {
}
void CRidley::sub80255d58(urde::CStateManager& mgr) {
const auto& someVal = skSomeRidleyStruct[xcb0_][xcb4_];
xb04_ = someVal.x4_ < mgr.GetActiveRandom()->Range(0.f, 100.f) ? someVal.x8_ : someVal.x0_;
xb04_ = skSomeRidleyStruct[xcb0_][xcb4_].x4_ < mgr.GetActiveRandom()->Range(0.f, 100.f)
? skSomeRidleyStruct[xcb0_][xcb4_].x8_
: skSomeRidleyStruct[xcb0_][xcb4_].x0_;
if (xb04_ == -1) {
xcb4_ = 0;
const auto& someVal2 = skSomeRidleyStruct[xcb0_][xcb4_];
xb04_ = someVal.x4_ < mgr.GetActiveRandom()->Range(0.f, 100.f) ? someVal2.x8_ : someVal2.x0_;
xb04_ = skSomeRidleyStruct[xcb0_][xcb4_].x4_ < mgr.GetActiveRandom()->Range(0.f, 100.f)
? skSomeRidleyStruct[xcb0_][xcb4_].x8_
: skSomeRidleyStruct[xcb0_][xcb4_].x0_;
}
++xcb4_;
@ -814,8 +873,7 @@ void CRidley::sub80257744(urde::CStateManager& mgr) {
for (size_t i = 0; i < x984_bodyCollision->GetNumCollisionActors(); ++i) {
const auto& colDesc = x984_bodyCollision->GetCollisionDescFromIndex(i);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(colDesc.GetCollisionActorId())) {
colAct->SetDamageVulnerability(i == 2 ? CDamageVulnerability::ImmuneVulnerabilty()
: CDamageVulnerability::NormalVulnerabilty());
colAct->SetDamageVulnerability(i == 2 ? skDirectNormal : CDamageVulnerability::ImmuneVulnerabilty());
colAct->HealthInfo(mgr)->SetHP(1000.f);
colAct->CreateShadow(true);
}
@ -891,8 +949,9 @@ void CRidley::sub802563a8(float dt) {
zeus::CVector3f posDiff = GetTranslation() - xa84_.origin;
float mag = posDiff.magnitude();
posDiff *= zeus::CVector3f(1.f / mag);
if (mag > xab4_ + (-6.f * zeus::clamp(-1.f, posDiff.dot(xa84_.basis[1]), 0.f)) && GetVelocity().dot(posDiff) > 0.f)
Stop();
if (xab4_ + -6.f * zeus::clamp(-1.f, posDiff.dot(xa84_.basis[1]), 0.f) < mag)
if (GetVelocity().dot(posDiff) > 0.f)
Stop();
MoveToInOneFrameWR(GetTranslation() - posDiff, dt);
}
@ -999,12 +1058,13 @@ void CRidley::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
xbe4_ = (GetTranslation() + zeus::skUp) - (8.f * GetTransform().basis[0]);
xbfc_ = xbf0_ = GetTransform().basis[0];
xc08_ = xc0c_ = xc10_ = 0.f;
xc08_ = xc0c_ = 0.f;
xc10_ = 240.f;
x32c_animState = EAnimState::Ready;
xa32_25_ = true;
--xcc4_;
} else if (msg == EStateMsg::Update) {
if (xa31_29_) {
if (!xa31_29_) {
FacePlayer(arg, mgr);
} else {
xc0c_ = std::min(0.5f, 0.5f * arg + xc0c_);
@ -1039,9 +1099,9 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(uid)) {
zeus::CVector3f wpPos = wp->GetTranslation();
const float mag = xa84_.basis[0].dot(wpPos - xa84_.origin);
if ((xa33_24_ && mag >= 1.f) || (!xa33_24_ && mag <= 1.f)) {
if ((xa33_24_ && mag > 0.f) || (!xa33_24_ && mag <= 0.f)) {
xbc4_ = wp->GetTranslation();
xbd0_ = wp->GetTransform().basis[0];
xbd0_ = wp->GetTransform().basis[1];
x2ec_reflectedDestPos = GetTranslation();
break;
}
@ -1050,8 +1110,8 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
}
xbdc_ = 0.f;
xbe0_ = 0.f;
xa31_31_ = false;
xbe0_ = 800.f;
xa31_30_ = false;
xa31_31_ = true;
xc10_ = 120.f;
xa32_24_ = true;
@ -1092,11 +1152,13 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
dir = pas::EStepDirection::Forward;
pas::EStepType type = pas::EStepType::Normal;
if (xa33_24_)
type = pas::EStepType::BreakDodge;
x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(dir, type));
xa31_30_ = true;
} else {
local_54 *= zeus::CVector3f(1.f / mag);
xbdc_ += zeus::clamp(-100.f, xbe0_ - xbdc_, 100.f);
xbdc_ += zeus::clamp(-100.f * arg, xbe0_ - xbdc_, 100.f * arg);
sub80255fe8(xbdc_, arg, local_54);
x450_bodyController->FaceDirection(xbd0_, arg * zeus::clamp(1.f, 10.f / mag, 10.f));
}
@ -1110,7 +1172,7 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
}
if (xa32_24_) {
xcac_ = 0;
xcac_.reset();
}
xa32_24_ = false;
xa32_25_ = false;
@ -1156,36 +1218,40 @@ void CRidley::JumpBack(CStateManager& mgr, EStateMsg msg, float arg) {
include.Remove(EMaterialTypes::Solid);
exclude.Add(EMaterialTypes::Solid);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
xa32_26_ = false;
xc7c_ =
zeus::CVector2f::getAngleDiff((x2e0_destPos - GetTranslation()).toVec2f(), GetTransform().basis[1].toVec2f());
if (GetTransform().basis[0].dot(x2e0_destPos - GetTranslation()) > 0.f)
xc7c_ = -xc7c_;
xc78_ = 0.f;
CCharAnimTime ikLock =
GetModelData()->GetAnimationData()->GetTimeOfUserEvent(EUserEventType::IkLock, CCharAnimTime::Infinity());
CCharAnimTime ikRelease =
GetModelData()->GetAnimationData()->GetTimeOfUserEvent(EUserEventType::IkRelease, CCharAnimTime::Infinity());
if (ikLock != CCharAnimTime::Infinity() && ikRelease != CCharAnimTime::Infinity()) {
xc78_ = ikRelease.GetSeconds() - ikLock.GetSeconds();
}
if (xa32_26_) {
zeus::CQuaternion q;
q.rotateZ((xc7c_ * arg) / xc78_);
RotateInOneFrameOR(q, arg);
}
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 4);
if (x32c_animState == EAnimState::Repeat) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
if (xc78_ == 0.f) {}
if (xc78_ == 0.f) {
CCharAnimTime ikLock =
GetModelData()->GetAnimationData()->GetTimeOfUserEvent(EUserEventType::IkLock, CCharAnimTime::Infinity());
CCharAnimTime ikRelease = GetModelData()->GetAnimationData()->GetTimeOfUserEvent(EUserEventType::IkRelease,
CCharAnimTime::Infinity());
if (ikLock != CCharAnimTime::Infinity() && ikRelease != CCharAnimTime::Infinity()) {
xc78_ = ikRelease.GetSeconds() - ikLock.GetSeconds();
}
}
if (xa32_26_) {
zeus::CQuaternion q;
q.rotateZ((xc7c_ * arg) / xc78_);
RotateInOneFrameOR(q, arg);
}
}
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::DoubleSnap(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
@ -1224,9 +1290,12 @@ void CRidley::Crouch(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
sub80253710(mgr);
}
} else if (msg == EStateMsg::Update) {
zeus::CVector3f vec = mgr.GetPlayer().GetTranslation() - GetTranslation().normalized();
if (vec.dot(GetTransform().basis[1]) < 0.9f)
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, vec, 1.f));
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Turn)
return;
zeus::CVector3f faceDir = (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized();
if (faceDir.dot(GetTransform().basis[1]) < 0.9f)
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, faceDir, 1.f));
}
}
void CRidley::FadeOut(CStateManager& mgr, EStateMsg msg, float arg) {
@ -1243,7 +1312,7 @@ void CRidley::FadeOut(CStateManager& mgr, EStateMsg msg, float arg) {
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack, 5);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
xcbc_ = arg * x568_data.x3c_;
xcbc_ = 0.6667f * x568_data.x3c_;
}
}
void CRidley::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
@ -1259,11 +1328,12 @@ void CRidley::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
void CRidley::Flee(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
zeus::CVector3f destPos =
xa84_.origin.toVec2f() + (20.f + xabc_) * (GetTranslation().toVec2f() - xa84_.origin.toVec2f()).normalized();
xa84_.origin.toVec2f() + (40.f + xabc_) * (GetTranslation().toVec2f() - xa84_.origin.toVec2f()).normalized();
destPos.z() = xac0_ + xa84_.origin.z();
SetDestPos(destPos);
} else if (msg == EStateMsg::Update) {
sub80255fe8(50.f, arg, (x2e0_destPos - GetTranslation()).normalized());
x450_bodyController->FaceDirection((x2e0_destPos - GetTranslation()).normalized(), arg);
}
}
void CRidley::Lurk(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
@ -1287,7 +1357,6 @@ void CRidley::Lurk(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
float f31 = xabc_ * std::cos(0.f);
float f0 = xabc_ * std::sin(0.f);
zeus::CVector3f destPos = xa84_ * zeus::CVector3f(f0, f31, f30);
fmt::print(fmt("Setting dest pos to {}\n"), destPos);
SetDestPos(destPos);
zeus::CVector3f vec = GetTransform().basis[1].toVec2f().normalized();
zeus::CTransform xf(vec.cross(zeus::skUp), vec, zeus::skUp, GetTranslation());
@ -1338,6 +1407,7 @@ void CRidley::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) {
sub8025784c(mgr);
x32c_animState = EAnimState::Ready;
xa32_25_ = true;
sub80256580();
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::ProjectileAttack, &CPatterned::TryProjectileAttack, 0);
} else if (msg == EStateMsg::Deactivate) {
@ -1350,13 +1420,21 @@ void CRidley::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) {
void CRidley::Jump(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
xc88_ = (mgr.GetPlayer().GetTranslation() - GetTranslation()).magnitude() < xae4_ ? 4 : 5;
xc88_ = (mgr.GetPlayer().GetTranslation() - GetTranslation()).magnitude() <= xae4_ ? 4 : 5;
x402_28_isMakingBigStrike = x568_data.x3ac_ > 0.f;
xc8c_ = x568_data.x390_;
sub80256580();
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, xc88_);
if (x330_stateMachineState.GetTime() < 1.75f)
FacePlayer(arg, mgr);
} else if (msg == EStateMsg::Deactivate) {
AddMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
x402_28_isMakingBigStrike = false;
x504_damageDur = 0.f;
xc8c_ = GetContactDamage();
x32c_animState = EAnimState::NotReady;
xa34_25_ = false;
}
}
void CRidley::Explode(CStateManager& mgr, EStateMsg msg, float arg) {
@ -1425,6 +1503,7 @@ void CRidley::Approach(CStateManager& mgr, EStateMsg msg, float arg) {
void CRidley::Enraged(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
AddMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
zeus::CVector3f vec = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f()).normalized();
mgr.AddObject(new CExplosion(
x98c_, mgr.AllocateUniqueId(), true, CEntityInfo(GetAreaIdAlways(), NullConnectionList), ""sv,
@ -1452,7 +1531,7 @@ void CRidley::Land(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
zeus::CVector3f diff = zeus::CVector3f(mgr.GetPlayer().GetTranslation().x() - xa84_.origin.x(),
mgr.GetPlayer().GetTranslation().y() - xa84_.origin.y(), 0.f);
SetDestPos(xa84_.origin + std::min(5.f, diff.magnitude()) * diff.normalized());
SetDestPos(xa84_.origin + std::min(5.f + xab4_, diff.magnitude()) * diff.normalized());
x32c_animState = EAnimState::Ready;
AddMaterial(EMaterialTypes::Solid, mgr);
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
@ -1487,15 +1566,14 @@ void CRidley::Land(CStateManager& mgr, EStateMsg msg, float arg) {
}
}
}
bool CRidley::Attacked(CStateManager& mgr, float arg) {
fmt::print(fmt("Attacked\n"));
return xa31_24_ && xa31_26_;
}
bool CRidley::Attacked(CStateManager& mgr, float arg) { return xa31_24_ && xa31_26_; }
bool CRidley::TooClose(CStateManager& mgr, float arg) {
fmt::print(fmt("TooClose\n"));
if (xb0c_ == 4)
return true;
if (xb08_ == 4)
return false;
zeus::CVector3f diff = mgr.GetPlayer().GetTranslation() - GetTranslation();
if (diff.magnitude() < x2fc_minAttackRange && 0.7f * diff.magnitude() < diff.dot(GetTransform().basis[1])) {
xb0c_ = 4;
@ -1506,50 +1584,22 @@ bool CRidley::TooClose(CStateManager& mgr, float arg) {
}
bool CRidley::InRange(CStateManager& mgr, float arg) {
float mag = (GetTranslation() - x2e0_destPos).magnitude();
fmt::print(fmt("InRange: distance to {}, curpos {}, destpos {}\n"), mag, GetTranslation(), x2e0_destPos);
return mag < 2.f;
}
bool CRidley::ShouldAttack(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldAttack\n"));
return (xc64_aiStage == 3 && xb0c_ == 2) || (xc64_aiStage == 2 && xb04_ == 0);
}
bool CRidley::ShouldDoubleSnap(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldDoubleSnap\n"));
return xa33_30_;
}
bool CRidley::ShouldTurn(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldTurn {}\n"), xb04_);
return xb04_ == 5;
}
bool CRidley::HitSomething(CStateManager& mgr, float arg) {
fmt::print(fmt("HitSomething\n"));
return xa32_27_ || xc64_aiStage == 3;
}
bool CRidley::AttackOver(CStateManager& mgr, float arg) {
fmt::print(fmt("AttackOver\n"));
return xcc4_ == 0;
}
bool CRidley::ShouldDoubleSnap(CStateManager& mgr, float arg) { return xa33_30_; }
bool CRidley::ShouldTurn(CStateManager& mgr, float arg) { return xb04_ == 5; }
bool CRidley::HitSomething(CStateManager& mgr, float arg) { return xa32_27_ || xc64_aiStage == 3; }
bool CRidley::AttackOver(CStateManager& mgr, float arg) { return xcc4_ == 0; }
bool CRidley::ShouldTaunt(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldTaunt\n"));
return (xc64_aiStage == 3 && xb0c_ == 1) || (xc64_aiStage == 2 && xb04_ == 4);
}
bool CRidley::ShouldFire(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldFire\n"));
return xc64_aiStage == 2 && xb04_ == 2;
}
bool CRidley::ShouldDodge(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldDodge\n"));
return xb04_ == 3;
}
bool CRidley::ShouldRetreat(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldRetreat\n"));
return xa34_26_;
}
bool CRidley::ShouldCrouch(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldCrouch\n"));
return xb04_ == 1;
}
bool CRidley::ShouldFire(CStateManager& mgr, float arg) { return xc64_aiStage == 2 && xb04_ == 2; }
bool CRidley::ShouldDodge(CStateManager& mgr, float arg) { return xb04_ == 3; }
bool CRidley::ShouldRetreat(CStateManager& mgr, float arg) { return xa34_26_; }
bool CRidley::ShouldCrouch(CStateManager& mgr, float arg) { return xb04_ == 1; }
bool CRidley::ShouldMove(urde::CStateManager& mgr, float arg) {
if (xb0c_ == 5) {
xa34_25_ = true;
@ -1566,25 +1616,14 @@ bool CRidley::ShouldMove(urde::CStateManager& mgr, float arg) {
return false;
}
bool CRidley::ShotAt(CStateManager& mgr, float arg) {
fmt::print(fmt("ShotAt\n"));
return xa32_28_shotAt;
}
bool CRidley::ShotAt(CStateManager& mgr, float arg) { return xa32_28_shotAt; }
bool CRidley::SetAIStage(CStateManager& mgr, float arg) {
fmt::print(fmt("SetAIStage {}\n"), arg);
xc64_aiStage = arg;
return true;
}
bool CRidley::AIStage(CStateManager& mgr, float arg) {
fmt::print(fmt("AIStage {}\n"), arg);
return xc64_aiStage >= arg;
}
bool CRidley::ShouldStrafe(CStateManager& mgr, float arg) {
fmt::print(fmt("ShouldStrafe\n"));
return xa33_29_doStrafe;
}
bool CRidley::AIStage(CStateManager& mgr, float arg) { return xc64_aiStage >= arg; }
bool CRidley::ShouldStrafe(CStateManager& mgr, float arg) { return xa33_29_doStrafe; }
bool CRidley::IsDizzy(CStateManager& mgr, float arg) {
fmt::print(fmt("IsDizzy\n"));
if (xb0c_ == 3)
return true;

View File

@ -208,6 +208,7 @@ public:
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
void Render(const CStateManager& mgr) const override;
void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override;
zeus::CAABox GetSortingBounds(const CStateManager&) const override { return GetBoundingBox(); }
const CDamageVulnerability* GetDamageVulnerability() const override {
return &CDamageVulnerability::ImmuneVulnerabilty();
}

View File

@ -0,0 +1,148 @@
#include "Runtime/MP1/World/CThardus.hpp"
#include "Runtime/CStateManager.hpp"
#include "Runtime/Collision/CCollisionActor.hpp"
#include "Runtime/Collision/CCollisionActorManager.hpp"
#include "Runtime/World/CPatternedInfo.hpp"
#include "Runtime/World/CPlayer.hpp"
#include "TCastTo.hpp" // Generated file, do not modify include path
namespace urde::MP1 {
CThardus::CThardus(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo,
std::vector<CModelData> mData1, std::vector<CModelData> mData2, CAssetId particle1,
CAssetId particle2, CAssetId particle3, float f1, float f2, float f3, float f4, float f5, float f6,
CAssetId stateMachine, CAssetId particle4, CAssetId particle5, CAssetId particle6,
CAssetId particle7, CAssetId particle8, CAssetId particle9, CAssetId texture, u32 sfxId1,
CAssetId particle10, u32 sfxId2, u32 sfxId3, u32 sfxId4)
: CPatterned(ECharacter::Thardus, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Ground, EColliderType::One, EBodyType::BiPedal, actParms, EKnockBackVariant::Large)
, x5cc_(std::move(mData1))
, x5dc_(std::move(mData2))
, x600_(particle1)
, x604_(particle2)
, x608_(particle3)
, x630_(stateMachine)
, x694_(f1)
, x698_(f2)
, x69c_(f3)
, x6a0_(f4)
, x6a4_(f5)
, x6a8_(f6)
, x6d0_(particle4)
, x6d4_(particle5)
, x6d8_(particle6)
, x6dc_(particle7)
, x6e0_(particle8)
, x6e4_(particle9)
, x6e8_(texture)
, x6ec_(CSfxManager::TranslateSFXID(sfxId1))
, x6f0_(particle10)
, x758_(sfxId2)
, x75c_(sfxId3)
, x760_(sfxId4)
, x7f0_(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f) {
CMaterialList exclude = GetMaterialFilter().GetExcludeList();
CMaterialList include = GetMaterialFilter().GetIncludeList();
exclude.Add(EMaterialTypes::Player);
exclude.Add(EMaterialTypes::Character);
exclude.Add(EMaterialTypes::CollisionActor);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
std::vector<CAssetId> gens;
gens.reserve(6);
gens.push_back(particle4);
gens.push_back(particle5);
gens.push_back(particle6);
gens.push_back(particle7);
gens.push_back(particle8);
gens.push_back(particle9);
GetModelData()->GetAnimationData()->GetParticleDB().CacheParticleDesc(
CCharacterInfo::CParticleResData(gens, {}, {}, {}));
x798_.reserve(6);
x7a8_.reserve(16);
UpdateThermalFrozenState(true);
xd0_damageMag = 0.f;
x50c_baseDamageMag = 0.f;
x8f4_.reserve(16);
x91c_.Lock();
x403_26_stateControlledMassiveDeath = false;
x460_knockBackController.SetAutoResetImpulse(false);
SetMass(100000.f);
}
void CThardus::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CPatterned::AcceptScriptMsg(msg, uid, mgr);
switch (msg) {
case EScriptObjectMessage::Reset: {
x95c_ = true;
x450_bodyController->SetFallState(pas::EFallState::Zero);
x450_bodyController->SetState(pas::EAnimationState::Locomotion);
x93d_ = false;
break;
}
case EScriptObjectMessage::SetToMax: {
for (size_t i = x648_; i < x610_.size() - 1; ++i) {
if (CEntity* ent = mgr.ObjectById(x610_[i]))
ent->SetActive(false);
++x648_;
}
break;
}
case EScriptObjectMessage::Stop: {
Death(mgr, {}, EScriptObjectState::DeathRattle);
break;
}
case EScriptObjectMessage::Action: {
if (!x5c8_)
x5c8_ = true;
break;
}
case EScriptObjectMessage::Touched: {
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(uid)) {
if (TCastToPtr<CPlayer> pl = mgr.ObjectById(colAct->GetLastTouchedObject())) {
} else if (TCastToConstPtr<CBomb> bomb = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
u32 rand = mgr.GetActiveRandom()->Next();
float f = 1.f;
zeus::CVector3f vec;
if (x644_ == 1) {
f = 2.f;
if ((rand & (1 ^ rand) >> 0x1f) == rand >> 31) {
vec = zeus::skRight;
} else
vec = zeus::skLeft;
}
}
}
break;
}
case EScriptObjectMessage::Registered: {
x610_.reserve(x5cc_.size());
x6b0_.reserve(x5cc_.size());
x6c0_.reserve(x5cc_.size());
x90c_.reserve(x5cc_.size());
/*
for (const auto& mData : x5cc_) {
}*/
AddMaterial(EMaterialTypes::ScanPassthrough, mgr);
AddMaterial(EMaterialTypes::CameraPassthrough, mgr);
RemoveMaterial(EMaterialTypes::Orbit, mgr);
RemoveMaterial(EMaterialTypes::Target, mgr);
//sub801ddbe4(mgr);
x450_bodyController->SetFallState(pas::EFallState::Two);
x450_bodyController->Activate(mgr);
x450_bodyController->BodyStateInfo().SetLocoAnimChangeAtEndOfAnimOnly(true);
//sub801db560(0, mgr);
//sub801dec80();
AddMaterial(EMaterialTypes::RadarObject, mgr);
break;
}
default:
break;
}
}
}

View File

@ -0,0 +1,154 @@
#pragma once
#include "Runtime/World/CPatterned.hpp"
#include "Runtime/World/CPathFindSearch.hpp"
namespace urde {
class CCollisionActorManager;
namespace MP1 {
class CThardus : public CPatterned {
class CThardusSomething {
TUniqueId x0_ = kInvalidUniqueId;
zeus::CVector3f x4_;
bool x10_24_ : 1;
public:
CThardusSomething() : x10_24_(false) {}
};
u32 x568_;
TUniqueId x56c_ = kInvalidUniqueId;
u32 x570_ = 0;
u32 x574_ = 0;
u32 x578_ = 0;
u32 x5c4_ = 1;
bool x5c8_ = false;
std::vector<CModelData> x5cc_;
std::vector<CModelData> x5dc_;
s32 x5ec_ = -1;
std::unique_ptr<CCollisionActorManager> x5f4_;
std::unique_ptr<CCollisionActorManager> x5f8_;
TUniqueId x5fc_ = kInvalidUniqueId;
CAssetId x600_;
CAssetId x604_;
CAssetId x608_;
TEditorId x60c_ = kInvalidEditorId;
std::vector<TUniqueId> x610_;
u32 x624_;
u32 x628_;
u32 x62c_;
CAssetId x630_;
u32 x634_;
u32 x638_ = 0;
u32 x63c_ = 0;
u32 x640_ = 0;
s32 x644_ = -1;
u32 x648_ = 0;
TUniqueId x64c_ = kInvalidUniqueId;
zeus::CVector2f x650_ = zeus::CVector2f(0.f, 1.f);
s32 x658_ = -1;
s32 x65c_ = -1;
u32 x660_ = 0;
u32 x664_ = 0;
bool x688_ = false;
bool x690_ = false;
float x694_;
float x698_;
float x69c_;
float x6a0_;
float x6a4_;
float x6a8_;
float x6ac_;
std::vector<char> x6b0_; /* TODO: Determine real value */
std::vector<TUniqueId> x6c0_;
CAssetId x6d0_;
CAssetId x6d4_;
CAssetId x6d8_;
CAssetId x6dc_;
CAssetId x6e0_;
CAssetId x6e4_;
CAssetId x6e8_;
s16 x6ec_;
CAssetId x6f0_;
u32 x6f4_ = 0;
float x6f8_ = 0.3f;
std::array<CThardusSomething, 4> x6fc_;
zeus::CVector3f x74c_ = zeus::skForward;
s32 x758_;
s32 x75c_;
s32 x760_;
zeus::CTransform x764_;
u32 x794_ = 0;
std::vector<TUniqueId> x798_;
std::vector<TUniqueId> x7a8_;
float x7b8_ = 0.f;
float x7bc_ = 10.f;
u32 x7c4_ = 0;
bool x7c8_ = false;
zeus::CVector3f x7cc_;
zeus::CVector3f x7d8_;
zeus::CVector3f x7e4_;
CPathFindSearch x7f0_;
bool x8d4_ = false;
zeus::CVector3f x8d8_;
zeus::CVector3f x8e4_;
bool x8f0_ = false;
std::vector<TUniqueId> x8f4_;
u32 x904_ = 0;
bool x908_ = false;
std::vector<float> x90c_;
TLockedToken<CTexture> x91c_;
TUniqueId x928_;
zeus::CVector3f x92c_;
bool x938_ = false;
bool x939_ = false;
bool x93a_ = false;
bool x93b_ = false;
bool x93c_ = false;
bool x93d_ = true;
u32 x940_ = 0;
float x944_ = 0.3f;
u32 x948_;
bool x94c_ = false;
bool x94d_ = false;
zeus::CVector3f x950_;
bool x95c_ = false;
bool x95d_ = false;
bool x95e_ = false;
public:
DEFINE_PATTERNED(Thardus)
CThardus(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo,
std::vector<CModelData> mData1, std::vector<CModelData> mData2, CAssetId particle1, CAssetId particle2,
CAssetId particle3, float f1, float f2, float f3, float f4, float f5, float f6, CAssetId stateMachine,
CAssetId particle4, CAssetId particle5, CAssetId particle6, CAssetId particle7, CAssetId particle8,
CAssetId particle9, CAssetId texture, u32 sfxId1, CAssetId particle10, u32 sfxId2, u32 sfxId3, u32 sfxId4);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
void Generate(CStateManager& mgr, EStateMsg msg, float arg) override {
if (msg == EStateMsg::Activate) {
x5ec_ = 0;
} else if (msg == EStateMsg::Update) {
if (x5ec_ == 0) {
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Getup) {
x5ec_ = 2;
} else {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGetupCmd(pas::EGetupType::Zero));
}
} else if (x5ec_ == 2 && x450_bodyController->GetCurrentStateId() != pas::EAnimationState::Getup) {
x5ec_ = 3;
}
} else if (msg == EStateMsg::Deactivate) {
x93d_ = false;
}
}
void GetUp(CStateManager& mgr, EStateMsg msg, float arg) override {
if (msg != EStateMsg::Activate)
return;
RemoveMaterial(EMaterialTypes::RadarObject, mgr);
}
};
} // namespace MP1
} // namespace urde

View File

@ -68,7 +68,7 @@ private:
int m_maxMAXP = 256;
u16 x94_randomSeed = g_GlobalSeed;
float x98_generatorRate = 1.f;
float x9c_cextValues[16] = {};
float x9c_externalVars[16] = {};
zeus::CVector3f xdc_translation;
zeus::CVector3f xe8_globalTranslation;
@ -186,8 +186,8 @@ public:
u32 GetParticleCountAll() const { return x264_recursiveParticleCount; }
void EndLifetime();
void ForceParticleCreation(int amount);
float GetCEXTValue(int i) const { return x9c_cextValues[i]; }
void SetCEXTValue(int i, float v) { x9c_cextValues[i] = v; }
float GetExternalVar(int i) const { return x9c_externalVars[i]; }
void SetCEXTValue(int i, float v) { x9c_externalVars[i] = v; }
bool InternalUpdate(double);
void RenderModels(const CActorLights* actLights);

View File

@ -560,7 +560,7 @@ std::unique_ptr<CRealElement> CParticleDataFactory::GetRealElement(CInputStream&
}
case SBIG('CEXT'): {
auto a = GetIntElement(in);
return std::make_unique<CRECEXT>(std::move(a));
return std::make_unique<CREExternalVar>(std::move(a));
}
case SBIG('ITRL'): {
auto a = GetIntElement(in);

View File

@ -289,11 +289,11 @@ bool CREVectorZToReal::GetValue(int frame, float& valOut) const {
return false;
}
bool CRECEXT::GetValue(int frame, float& valOut) const {
bool CREExternalVar::GetValue(int frame, float& valOut) const {
int a;
x4_a->GetValue(frame, a);
int cv = std::max(0, a);
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetCEXTValue(cv & 0xf);
valOut = CParticleGlobals::g_currentParticleSystem->x4_system->GetExternalVar(cv & 0xf);
return false;
}

View File

@ -284,11 +284,11 @@ public:
bool GetValue(int frame, float& valOut) const override;
};
class CRECEXT : public CRealElement {
class CREExternalVar : public CRealElement {
std::unique_ptr<CIntElement> x4_a;
public:
CRECEXT(std::unique_ptr<CIntElement>&& a) : x4_a(std::move(a)) {}
CREExternalVar(std::unique_ptr<CIntElement>&& a) : x4_a(std::move(a)) {}
bool GetValue(int frame, float& valOut) const override;
};

View File

@ -209,7 +209,7 @@ private:
float x3f0_vertFreeLookAngleVel = 0.f;
TUniqueId x3f4_aimTarget = kInvalidUniqueId;
zeus::CVector3f x3f8_targetAimPosition = zeus::skZero3f;
TReservedAverage<zeus::CVector3f, 20> x404_aimTargetAverage;
TReservedAverage<zeus::CVector3f, 10> x404_aimTargetAverage;
zeus::CVector3f x480_assistedTargetAim = zeus::skZero3f;
float x48c_aimTargetTimer = 0.f;
std::unique_ptr<CPlayerGun> x490_gun;

View File

@ -99,6 +99,7 @@
#include "MP1/World/CAtomicBeta.hpp"
#include "CSimplePool.hpp"
#include "CStateManager.hpp"
#include "Runtime/MP1/World/CThardus.hpp"
#include "CWallCrawlerSwarm.hpp"
#include "CWorld.hpp"
#include "Camera/CCinematicCamera.hpp"
@ -126,7 +127,8 @@ constexpr SObjectTag MorphballDoorANCS = {FOURCC('ANCS'), 0x1F9DA858};
static bool EnsurePropertyCount(int count, int expected, const char* structName) {
if (count < expected) {
Log.report(logvisor::Warning, fmt("Insufficient number of props ({}/{}) for {} entity"), count, expected, structName);
Log.report(logvisor::Warning, fmt("Insufficient number of props ({}/{}) for {} entity"), count, expected,
structName);
return false;
}
return true;
@ -1340,8 +1342,8 @@ CEntity* ScriptLoader::LoadSpacePirate(CStateManager& mgr, CInputStream& in, int
return nullptr;
if (animParms.GetCharacter() == 0) {
Log.report(logvisor::Warning, fmt("SpacePirate <{}> has AnimationInformation property with invalid character selected"),
head.x0_name);
Log.report(logvisor::Warning,
fmt("SpacePirate <{}> has AnimationInformation property with invalid character selected"), head.x0_name);
animParms.SetCharacter(2);
}
@ -1420,7 +1422,7 @@ CEntity* ScriptLoader::LoadMetroidBeta(CStateManager& mgr, CInputStream& in, int
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
return nullptr;
//return new MP1::CMetroidBeta(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, actParms, metData);
// return new MP1::CMetroidBeta(mgr.AllocateUniqueId(), name, info, xf, std::move(mData), pInfo, actParms, metData);
}
CEntity* ScriptLoader::LoadChozoGhost(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
@ -2003,7 +2005,8 @@ CEntity* ScriptLoader::LoadMetroid(CStateManager& mgr, CInputStream& in, int pro
CModelData mData(
CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), scale, animParms.GetInitialAnimation(), true));
return nullptr;
//return new MP1::CMetroid(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, actParms, metData,
// return new MP1::CMetroid(mgr.AllocateUniqueId(), name, flavor, info, xf, std::move(mData), pInfo, actParms,
// metData,
// kInvalidUniqueId);
}
@ -2502,7 +2505,70 @@ CEntity* ScriptLoader::LoadPlayerStateChange(CStateManager& mgr, CInputStream& i
}
CEntity* ScriptLoader::LoadThardus(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) {
return nullptr;
if (!EnsurePropertyCount(propCount, 43, "Thardus")) {
return nullptr;
}
SScaledActorHead actHead = LoadScaledActorHead(in, mgr);
const auto [isValid, patternedCount] = CPatternedInfo::HasCorrectParameterCount(in);
if (!isValid)
return nullptr;
CPatternedInfo pInfo(in, patternedCount);
CActorParameters actParms = LoadActorParameters(in);
in.readBool();
in.readBool();
const CAnimationParameters& animParms = pInfo.GetAnimationParameters();
if (!animParms.GetACSFile().IsValid())
return nullptr;
CStaticRes staticRes[2][7];
staticRes[0][6] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][5] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][4] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][3] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][2] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][1] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[0][0] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][6] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][5] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][4] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][3] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][2] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][1] = CStaticRes(CAssetId(in), zeus::skOne3f);
staticRes[1][0] = CStaticRes(CAssetId(in), zeus::skOne3f);
CAssetId particle1(in);
CAssetId particle2(in);
CAssetId particle3(in);
CAssetId stateMachine(in);
CAssetId particle4(in);
CAssetId particle5(in);
CAssetId particle6(in);
CAssetId particle7(in);
CAssetId particle8(in);
CAssetId particle9(in);
float f1 = in.readFloatBig();
float f2 = in.readFloatBig();
float f3 = in.readFloatBig();
float f4 = in.readFloatBig();
float f5 = in.readFloatBig();
float f6 = in.readFloatBig();
CAssetId texture(in);
int sfxID1 = in.readUint32Big();
CAssetId particle10 = (propCount < 44) ? CAssetId() : CAssetId(in);
int sfxID2 = in.readUint32Big();
int sfxID3 = in.readUint32Big();
int sfxID4 = in.readUint32Big();
std::vector<CModelData> mData1(7);
std::vector<CModelData> mData2(7);
mData1.assign(std::rbegin(staticRes[1]), std::rend(staticRes[1]));
mData2.assign(std::rbegin(staticRes[0]), std::rend(staticRes[0]));
CModelData mData(CAnimRes(animParms.GetACSFile(), 0, actHead.x40_scale, animParms.GetInitialAnimation(), true));
return new MP1::CThardus(mgr.AllocateUniqueId(), actHead.x0_name, info, actHead.x10_transform, std::move(mData),
actParms, pInfo, std::move(mData2), std::move(mData1), particle1, particle2, particle3, f1,
f2, f3, f4, f5, f6, stateMachine, particle4, particle5, particle6, particle7, particle8,
particle9, texture, sfxID1, particle10, sfxID2, sfxID3, sfxID4);
}
CEntity* ScriptLoader::LoadWallCrawlerSwarm(CStateManager& mgr, CInputStream& in, int propCount,
@ -3599,7 +3665,8 @@ CEntity* ScriptLoader::LoadEnergyBall(CStateManager& mgr, CInputStream& in, int
CModelData mData(CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), actorHead.x40_scale,
animParms.GetInitialAnimation(), true));
return new MP1::CEnergyBall(mgr.AllocateUniqueId(), actorHead.x0_name, info, actorHead.x10_transform, std::move(mData),
actParms, pInfo, w1, f1, dInfo1, f2, a1, sfxId1, a2, a3, sfxId2, f3, f4, a4, dInfo2, f5);
return new MP1::CEnergyBall(mgr.AllocateUniqueId(), actorHead.x0_name, info, actorHead.x10_transform,
std::move(mData), actParms, pInfo, w1, f1, dInfo1, f2, a1, sfxId1, a2, a3, sfxId2, f3, f4,
a4, dInfo2, f5);
}
} // namespace urde

View File

@ -299,5 +299,8 @@ int main(int argc, const char** argv) {
if (clientThread.joinable())
clientThread.join();
glXDestroyWindow(xDisp, glxWindow);
XDestroyWindow(xDisp, windowId);
XCloseDisplay(xDisp);
return renderer.ReturnVal();
}