mirror of https://github.com/AxioDL/metaforce.git
CElitePirate: Bug fixes, make member variables private, cleanup
This commit is contained in:
parent
ed254b460e
commit
684bbd5903
|
@ -1 +1 @@
|
|||
Checks: '*,-misc-unused-parameters,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-convert-member-functions-to-static,-readability-uppercase-literal-suffix,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-fuchsia-*,-google-runtime-references'
|
||||
Checks: '*,-misc-unused-parameters,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-convert-member-functions-to-static,-readability-uppercase-literal-suffix,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes,-fuchsia-*,-google-runtime-references'
|
||||
|
|
|
@ -14,14 +14,14 @@ CBouncyGrenade::CBouncyGrenade(TUniqueId uid, std::string_view name, const CEnti
|
|||
TUniqueId parentId, const SBouncyGrenadeData& data, float velocity,
|
||||
float explodePlayerDistance)
|
||||
: CPhysicsActor(uid, true, name, info, xf, std::move(mData), {EMaterialTypes::Projectile, EMaterialTypes::Solid}, {},
|
||||
SMoverData(data.x0_.x0_mass), actParams, 0.3f, 0.1f)
|
||||
SMoverData(data.GetUnkStruct().GetMass()), actParams, 0.3f, 0.1f)
|
||||
, x258_data(data)
|
||||
, x294_numBounces(data.x34_numBounces)
|
||||
, x294_numBounces(data.GetNumBounces())
|
||||
, x298_parentId(parentId)
|
||||
, x2a0_elementGen1(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.x24_elementGenId1})))
|
||||
, x2a4_elementGen2(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.x28_elementGenId2})))
|
||||
, x2a8_elementGen3(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.x2c_elementGenId3})))
|
||||
, x2ac_elementGen4(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.x30_elementGenId4})))
|
||||
, x2a0_elementGen1(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.GetElementGenId1()})))
|
||||
, x2a4_elementGen2(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.GetElementGenId2()})))
|
||||
, x2a8_elementGen3(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.GetElementGenId3()})))
|
||||
, x2ac_elementGen4(std::make_unique<CElementGen>(g_SimplePool->GetObj({'PART', data.GetElementGenId4()})))
|
||||
, x2b0_explodePlayerDistance(explodePlayerDistance)
|
||||
, x2b4_24_exploded(false)
|
||||
, x2b4_25_(false) {
|
||||
|
@ -81,10 +81,11 @@ void CBouncyGrenade::CollidedWith(TUniqueId id, const CCollisionInfoList& list,
|
|||
if (GetVelocity().dot(info.GetNormalLeft()) > 0.f) {
|
||||
normal = &info.GetNormalRight();
|
||||
}
|
||||
const zeus::CVector3f impulse = (x258_data.x0_.x4_ * GetConstantForce().magnitude()) * *normal;
|
||||
const zeus::CVector3f angle = -x258_data.x0_.x4_ * GetAngularMomentum();
|
||||
const zeus::CVector3f impulse =
|
||||
(x258_data.GetUnkStruct().GetSpeed() * GetConstantForce().magnitude()) * *normal;
|
||||
const zeus::CVector3f angle = -x258_data.GetUnkStruct().GetSpeed() * GetAngularMomentum();
|
||||
ApplyImpulseWR(impulse, angle);
|
||||
CSfxManager::AddEmitter(x258_data.x38_bounceSfx, GetTranslation(), zeus::skUp, false, false, 0x7f,
|
||||
CSfxManager::AddEmitter(x258_data.GetBounceSfx(), GetTranslation(), zeus::skUp, false, false, 0x7f,
|
||||
GetAreaIdAlways());
|
||||
x294_numBounces--;
|
||||
}
|
||||
|
@ -95,9 +96,7 @@ void CBouncyGrenade::CollidedWith(TUniqueId id, const CCollisionInfoList& list,
|
|||
CPhysicsActor::CollidedWith(id, list, mgr);
|
||||
}
|
||||
|
||||
std::optional<zeus::CAABox> CBouncyGrenade::GetTouchBounds() const {
|
||||
return GetModelData()->GetBounds(GetTransform());
|
||||
}
|
||||
std::optional<zeus::CAABox> CBouncyGrenade::GetTouchBounds() const { return GetModelData()->GetBounds(GetTransform()); }
|
||||
|
||||
void CBouncyGrenade::Render(const CStateManager& mgr) const {
|
||||
if (!x2b4_24_exploded) {
|
||||
|
@ -153,14 +152,14 @@ void CBouncyGrenade::Explode(CStateManager& mgr, TUniqueId uid) {
|
|||
}
|
||||
|
||||
x2b4_24_exploded = true;
|
||||
CSfxManager::AddEmitter(x258_data.x3a_explodeSfx, GetTranslation(), zeus::skUp, false, false, 0x7f,
|
||||
CSfxManager::AddEmitter(x258_data.GetExplodeSfx(), GetTranslation(), zeus::skUp, false, false, 0x7f,
|
||||
GetAreaIdAlways());
|
||||
x2a0_elementGen1->SetParticleEmission(true);
|
||||
x2a4_elementGen2->SetParticleEmission(true);
|
||||
x2a8_elementGen3->SetParticleEmission(true);
|
||||
x2ac_elementGen4->SetParticleEmission(false);
|
||||
|
||||
const CDamageInfo& dInfo = x258_data.x8_damageInfo;
|
||||
const CDamageInfo& dInfo = x258_data.GetDamageInfo();
|
||||
{
|
||||
bool isParent = x298_parentId == uid;
|
||||
if (TCastToConstPtr<CCollisionActor> actor = mgr.GetObjectById(uid)) {
|
||||
|
|
|
@ -10,13 +10,19 @@
|
|||
|
||||
namespace urde::MP1 {
|
||||
struct SGrenadeUnknownStruct {
|
||||
private:
|
||||
float x0_mass;
|
||||
float x4_; // speed?
|
||||
float x4_speed; // wrong name probably
|
||||
|
||||
SGrenadeUnknownStruct(CInputStream& in) : x0_mass(in.readFloatBig()), x4_(in.readFloatBig()) {}
|
||||
public:
|
||||
explicit SGrenadeUnknownStruct(CInputStream& in) : x0_mass(in.readFloatBig()), x4_speed(in.readFloatBig()) {}
|
||||
|
||||
[[nodiscard]] float GetMass() const { return x0_mass; }
|
||||
[[nodiscard]] float GetSpeed() const { return x4_speed; }
|
||||
};
|
||||
|
||||
struct SBouncyGrenadeData {
|
||||
private:
|
||||
SGrenadeUnknownStruct x0_;
|
||||
CDamageInfo x8_damageInfo;
|
||||
CAssetId x24_elementGenId1;
|
||||
|
@ -27,6 +33,7 @@ struct SBouncyGrenadeData {
|
|||
u16 x38_bounceSfx;
|
||||
u16 x3a_explodeSfx;
|
||||
|
||||
public:
|
||||
SBouncyGrenadeData(const SGrenadeUnknownStruct& unkStruct, const CDamageInfo& damageInfo, CAssetId w1, CAssetId w2,
|
||||
CAssetId w3, CAssetId w4, u32 w5, u16 s1, u16 s2)
|
||||
: x0_(unkStruct)
|
||||
|
@ -38,6 +45,16 @@ struct SBouncyGrenadeData {
|
|||
, x34_numBounces(w5)
|
||||
, x38_bounceSfx(s1)
|
||||
, x3a_explodeSfx(s2){};
|
||||
|
||||
[[nodiscard]] const SGrenadeUnknownStruct& GetUnkStruct() const { return x0_; }
|
||||
[[nodiscard]] const CDamageInfo& GetDamageInfo() const { return x8_damageInfo; }
|
||||
[[nodiscard]] CAssetId GetElementGenId1() const { return x24_elementGenId1; }
|
||||
[[nodiscard]] CAssetId GetElementGenId2() const { return x28_elementGenId2; }
|
||||
[[nodiscard]] CAssetId GetElementGenId3() const { return x2c_elementGenId3; }
|
||||
[[nodiscard]] CAssetId GetElementGenId4() const { return x30_elementGenId4; }
|
||||
[[nodiscard]] u32 GetNumBounces() const { return x34_numBounces; }
|
||||
[[nodiscard]] u16 GetBounceSfx() const { return x38_bounceSfx; }
|
||||
[[nodiscard]] u16 GetExplodeSfx() const { return x3a_explodeSfx; }
|
||||
};
|
||||
|
||||
class CBouncyGrenade : public CPhysicsActor {
|
||||
|
@ -61,7 +78,7 @@ public:
|
|||
|
||||
void Accept(IVisitor& visitor) override { visitor.Visit(this); }
|
||||
void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override;
|
||||
void CollidedWith(TUniqueId id, const CCollisionInfoList &list, CStateManager &mgr) override;
|
||||
void CollidedWith(TUniqueId id, const CCollisionInfoList& list, CStateManager& mgr) override;
|
||||
[[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override;
|
||||
void Render(const CStateManager& mgr) const override;
|
||||
void Think(float dt, CStateManager& mgr) override;
|
||||
|
|
|
@ -45,9 +45,9 @@ CElitePirateData::CElitePirateData(CInputStream& in, u32 propCount)
|
|||
, x4_tauntVariance(in.readFloatBig())
|
||||
, x8_(in.readFloatBig())
|
||||
, xc_(in.readFloatBig())
|
||||
, x10_(in.readFloatBig())
|
||||
, x14_(in.readFloatBig())
|
||||
, x18_(in.readFloatBig())
|
||||
, x10_attackChance(in.readFloatBig())
|
||||
, x14_shotAtTime(in.readFloatBig())
|
||||
, x18_shotAtTimeVariance(in.readFloatBig())
|
||||
, x1c_(in.readFloatBig())
|
||||
, x20_(in)
|
||||
, x24_sfxAbsorb(CSfxManager::TranslateSFXID(in.readUint32Big()))
|
||||
|
@ -84,12 +84,13 @@ CElitePirate::CElitePirate(TUniqueId uid, std::string_view name, const CEntityIn
|
|||
, x6f8_boneTracking(*GetModelData()->GetAnimationData(), "Head_1", zeus::degToRad(80.f), zeus::degToRad(180.f),
|
||||
EBoneTrackingFlags::None)
|
||||
, x738_(GetBoundingBox(), GetMaterialList())
|
||||
, x7a0_initialSpeed(x3b4_speed)
|
||||
, x7d0_pathFindSearch(nullptr, 1, pInfo.GetPathfindingIndex(), 1.f, 1.f)
|
||||
, x8c0_(5.f)
|
||||
, x988_24_(false)
|
||||
, x988_25_(false)
|
||||
, x988_26_(false)
|
||||
, x988_27_(false)
|
||||
, x988_27_shotAt(false)
|
||||
, x988_28_alert(false)
|
||||
, x988_29_(false)
|
||||
, x988_30_(false)
|
||||
|
@ -117,10 +118,10 @@ void CElitePirate::Think(float dt, CStateManager& mgr) {
|
|||
x730_collisionActorMgr2->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
||||
}
|
||||
x5d4_collisionActorMgr1->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
|
||||
if (sub_80229208() && x5d8_data.x11f_) {
|
||||
x3b4_speed = 2.f * x7a0_;
|
||||
if (sub_80229208() && x5d8_data.GetX11F()) {
|
||||
x3b4_speed = 2.f * x7a0_initialSpeed;
|
||||
} else {
|
||||
x3b4_speed = x7a0_;
|
||||
x3b4_speed = x7a0_initialSpeed;
|
||||
}
|
||||
sub_80228e50(dt);
|
||||
sub_80228798();
|
||||
|
@ -163,14 +164,14 @@ void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
|
|||
TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid);
|
||||
if (!actor) {
|
||||
if (uid == x772_launcherId && x772_launcherId != kInvalidUniqueId) {
|
||||
sub_8022759c(true, mgr);
|
||||
SetShotAt(true, mgr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
const TUniqueId& touchedUid = actor->GetLastTouchedObject();
|
||||
if (touchedUid != GetUniqueId()) {
|
||||
if (TCastToPtr<CGameProjectile>(mgr.ObjectById(touchedUid))) {
|
||||
sub_8022759c(true, mgr);
|
||||
SetShotAt(true, mgr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -230,7 +231,7 @@ void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
|
|||
} else if (uid == x79c_ && x760_energyAbsorbDesc->IsLoaded()) {
|
||||
CreateEnergyAbsorb(mgr, projectile->GetTransform());
|
||||
}
|
||||
sub_8022759c(true, mgr);
|
||||
SetShotAt(true, mgr);
|
||||
}
|
||||
} else if (uid == x772_launcherId && x772_launcherId != kInvalidUniqueId) {
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(
|
||||
|
@ -240,7 +241,7 @@ void CElitePirate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
|
|||
}
|
||||
break;
|
||||
case EScriptObjectMessage::InvulnDamage: {
|
||||
sub_8022759c(true, mgr);
|
||||
SetShotAt(true, mgr);
|
||||
if (!TCastToPtr<CCollisionActor>(mgr.ObjectById(uid))) {
|
||||
ApplyDamageToHead(mgr, uid);
|
||||
}
|
||||
|
@ -389,7 +390,7 @@ void CElitePirate::PathFind(CStateManager& mgr, EStateMsg msg, float dt) {
|
|||
x6f8_boneTracking.SetActive(true);
|
||||
sub_80228634(mgr);
|
||||
CPatterned::PathFind(mgr, msg, dt);
|
||||
x7bc_tauntTimer = x5d8_data.x4_tauntVariance * mgr.GetActiveRandom()->Float() + x5d8_data.x0_tauntInterval;
|
||||
x7bc_tauntTimer = x5d8_data.GetTauntVariance() * mgr.GetActiveRandom()->Float() + x5d8_data.GetTauntInterval();
|
||||
if (TooClose(mgr, 0.f)) {
|
||||
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
||||
}
|
||||
|
@ -515,7 +516,7 @@ void CElitePirate::Generate(CStateManager& mgr, EStateMsg msg, float) {
|
|||
x568_ = EState::Over;
|
||||
}
|
||||
} else if (msg == EStateMsg::Deactivate) {
|
||||
sub_8022759c(false, mgr);
|
||||
SetShotAt(false, mgr);
|
||||
sub_802289b0(mgr, true);
|
||||
}
|
||||
}
|
||||
|
@ -603,7 +604,7 @@ void CElitePirate::CallForBackup(CStateManager& mgr, EStateMsg msg, float) {
|
|||
if (msg == EStateMsg::Activate) {
|
||||
x568_ = EState::Zero;
|
||||
x988_30_ = true;
|
||||
sub_8022759c(false, mgr);
|
||||
SetShotAt(false, mgr);
|
||||
} else if (msg == EStateMsg::Update) {
|
||||
if (x568_ == EState::Zero) {
|
||||
if (x450_bodyController->GetCurrentStateId() == pas::EAnimationState::Generate) {
|
||||
|
@ -638,10 +639,10 @@ void CElitePirate::Cover(CStateManager& mgr, EStateMsg msg, float dt) {
|
|||
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
||||
}
|
||||
} else if (msg == EStateMsg::Update) {
|
||||
if (x988_27_) {
|
||||
x7c0_ -= dt;
|
||||
if (x7c0_ <= 0.f) {
|
||||
x988_27_ = false;
|
||||
if (x988_27_shotAt) {
|
||||
x7c0_shotAtTimer -= dt;
|
||||
if (x7c0_shotAtTimer <= 0.f) {
|
||||
x988_27_shotAt = false;
|
||||
}
|
||||
}
|
||||
x7a8_ = PathShagged(mgr, 0.f) ? x7a8_ + dt : 0.f;
|
||||
|
@ -717,7 +718,7 @@ bool CElitePirate::ShouldTaunt(CStateManager& mgr, float) { return x7bc_tauntTim
|
|||
|
||||
bool CElitePirate::ShouldFire(CStateManager& mgr, float) { return ShouldFireFromLauncher(mgr, x772_launcherId); }
|
||||
|
||||
bool CElitePirate::ShotAt(CStateManager& mgr, float) { return x988_27_; }
|
||||
bool CElitePirate::ShotAt(CStateManager& mgr, float) { return x988_27_shotAt; }
|
||||
|
||||
bool CElitePirate::ShouldSpecialAttack(CStateManager& mgr, float) {
|
||||
if (x7b8_attackTimer <= 0.f && GetAreaIdAlways() == mgr.GetPlayer().GetAreaIdAlways()) {
|
||||
|
@ -763,17 +764,18 @@ void CElitePirate::sub_80229248() {
|
|||
x7d0_pathFindSearch.SetCharacterHeight(3.f * scale);
|
||||
}
|
||||
|
||||
void CElitePirate::sub_8022759c(bool param_1, CStateManager& mgr) {
|
||||
if (!sub_802273b0() || x7b4_hp <= 0.f || !param_1) {
|
||||
x988_27_ = param_1;
|
||||
// TODO rename
|
||||
void CElitePirate::SetShotAt(bool val, CStateManager& mgr) {
|
||||
if (!sub_802273b0() || x7b4_hp <= 0.f || !val) {
|
||||
x988_27_shotAt = val;
|
||||
} else if (HealthInfo(mgr)->GetHP() / x7b4_hp <= x7b0_) {
|
||||
x7b0_ -= 0.2f;
|
||||
x988_27_ = true;
|
||||
x988_27_shotAt = true;
|
||||
}
|
||||
if (x988_27_) {
|
||||
x7c0_ = mgr.GetActiveRandom()->Float() * x5d8_data.x18_ + x5d8_data.x14_;
|
||||
if (x988_27_shotAt) {
|
||||
x7c0_shotAtTimer = mgr.GetActiveRandom()->Float() * x5d8_data.GetShotAtTimeVariance() + x5d8_data.GetShotAtTime();
|
||||
} else {
|
||||
x7c0_ = 0.f;
|
||||
x7c0_shotAtTimer = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -886,27 +888,16 @@ bool CElitePirate::IsArmClawCollider(std::string_view name, std::string_view loc
|
|||
}
|
||||
|
||||
void CElitePirate::CreateGrenadeLauncher(CStateManager& mgr, TUniqueId uid) {
|
||||
const CAnimationParameters& params = x5d8_data.x90_launcherAnimParams;
|
||||
const CAnimationParameters& params = x5d8_data.GetLauncherAnimParams();
|
||||
if (!params.GetACSFile().IsValid()) {
|
||||
return;
|
||||
}
|
||||
CModelData mData(CAnimRes(params.GetACSFile(), params.GetCharacter(), GetModelData()->GetScale(),
|
||||
params.GetInitialAnimation(), true));
|
||||
SBouncyGrenadeData grenadeData{x5d8_data.xd8_,
|
||||
x5d8_data.xa8_,
|
||||
x5d8_data.xc8_,
|
||||
x5d8_data.xcc_,
|
||||
x5d8_data.xd0_,
|
||||
x5d8_data.xd4_,
|
||||
x5d8_data.xf0_grenadeNumBounces,
|
||||
x5d8_data.xf4_,
|
||||
x5d8_data.xf6_};
|
||||
CGrenadeLauncherData launcherData{grenadeData, x5d8_data.xa4_, x5d8_data.x9c_, x5d8_data.xa0_,
|
||||
x5d8_data.xe0_trajectoryInfo};
|
||||
mgr.AddObject(new CGrenadeLauncher(uid, "Grenade Launcher", {GetAreaIdAlways(), CEntity::NullConnectionList},
|
||||
GetTransform(), std::move(mData), mData.GetBounds(GetTransform().getRotation()),
|
||||
CHealthInfo(x5d8_data.xc4_launcherHp, 10.f), x56c_vulnerability,
|
||||
x5d8_data.x28_launcherActParams, GetUniqueId(), launcherData, 0.f));
|
||||
mgr.AddObject(new CGrenadeLauncher(
|
||||
uid, "Grenade Launcher", {GetAreaIdAlways(), CEntity::NullConnectionList}, GetTransform(), std::move(mData),
|
||||
mData.GetBounds(GetTransform().getRotation()), CHealthInfo(x5d8_data.GetLauncherHP(), 10.f), x56c_vulnerability,
|
||||
x5d8_data.GetLauncherActParams(), GetUniqueId(), x5d8_data.GetGrenadeLauncherData(), 0.f));
|
||||
}
|
||||
|
||||
void CElitePirate::ApplyDamageToHead(CStateManager& mgr, TUniqueId uid) {
|
||||
|
@ -928,7 +919,8 @@ void CElitePirate::CreateEnergyAbsorb(CStateManager& mgr, const zeus::CTransform
|
|||
mgr.AddObject(new CExplosion(*x760_energyAbsorbDesc, mgr.AllocateUniqueId(), true,
|
||||
{GetAreaIdAlways(), CEntity::NullConnectionList}, "Absorb energy Fx", xf, 0,
|
||||
GetModelData()->GetScale(), zeus::skWhite));
|
||||
CSfxManager::AddEmitter(x5d8_data.x24_sfxAbsorb, GetTranslation(), zeus::skUp, false, false, 0x7f, GetAreaIdAlways());
|
||||
CSfxManager::AddEmitter(x5d8_data.GetSFXAbsorb(), GetTranslation(), zeus::skUp, false, false, 0x7f,
|
||||
GetAreaIdAlways());
|
||||
x7ac_energyAbsorbCooldown = 0.25f;
|
||||
}
|
||||
|
||||
|
@ -937,7 +929,7 @@ void CElitePirate::UpdateHealthInfo(CStateManager& mgr, TUniqueId uid) {
|
|||
if (uid != kInvalidUniqueId) {
|
||||
if (TCastToPtr<CCollisionActor> actor = mgr.ObjectById(uid)) {
|
||||
auto actHealth = actor->HealthInfo(mgr);
|
||||
actHealth->SetHP(x5d8_data.xc4_launcherHp);
|
||||
actHealth->SetHP(x5d8_data.GetLauncherHP());
|
||||
actHealth->SetKnockbackResistance(health->GetKnockbackResistance());
|
||||
actor->SetDamageVulnerability(x56c_vulnerability);
|
||||
}
|
||||
|
@ -972,7 +964,7 @@ void CElitePirate::sub_80228634(CStateManager& mgr) {
|
|||
}
|
||||
|
||||
void CElitePirate::sub_802285c4(CStateManager& mgr) {
|
||||
if (mgr.GetActiveRandom()->Float() > x5d8_data.x10_) {
|
||||
if (mgr.GetActiveRandom()->Float() > x5d8_data.GetAttackChance()) {
|
||||
x7b8_attackTimer = x308_attackTimeVariation * mgr.GetActiveRandom()->Float() + x304_averageAttackTime;
|
||||
}
|
||||
}
|
||||
|
@ -982,7 +974,7 @@ void CElitePirate::sub_80227a90(CStateManager& mgr) {
|
|||
}
|
||||
|
||||
void CElitePirate::sub_802277e0(CStateManager& mgr, float dt) {
|
||||
if (!x988_27_ || x450_bodyController->IsFrozen()) {
|
||||
if (!x988_27_shotAt || x450_bodyController->IsFrozen()) {
|
||||
return;
|
||||
}
|
||||
x7c4_ += dt;
|
||||
|
@ -1086,15 +1078,16 @@ bool CElitePirate::ShouldFireFromLauncher(CStateManager& mgr, TUniqueId launcher
|
|||
return false;
|
||||
}
|
||||
const zeus::CVector3f& target = CGrenadeLauncher::GrenadeTarget(mgr);
|
||||
float angleOut = x5d8_data.xe0_trajectoryInfo.x8_angleMin;
|
||||
float velocityOut = x5d8_data.xe0_trajectoryInfo.x0_;
|
||||
CGrenadeLauncher::CalculateGrenadeTrajectory(target, origin, x5d8_data.xe0_trajectoryInfo, angleOut, velocityOut);
|
||||
float angleOut = x5d8_data.GetGrenadeTrajectoryInfo().GetAngleMin();
|
||||
float velocityOut = x5d8_data.GetGrenadeTrajectoryInfo().GetVelocityMin();
|
||||
CGrenadeLauncher::CalculateGrenadeTrajectory(target, origin, x5d8_data.GetGrenadeTrajectoryInfo(), angleOut,
|
||||
velocityOut);
|
||||
const zeus::CVector3f& rot = GetTransform().rotate({0.f, std::cos(angleOut), std::sin(angleOut)});
|
||||
return !CPatterned::IsPatternObstructed(mgr, target, target + (7.5f * rot));
|
||||
}
|
||||
|
||||
bool CElitePirate::ShouldCallForBackupFromLauncher(CStateManager& mgr, TUniqueId uid) {
|
||||
if (!x988_30_ && uid == kInvalidUniqueId && x5d8_data.x11e_) {
|
||||
if (!x988_30_ && uid == kInvalidUniqueId && x5d8_data.GetX11E()) {
|
||||
return x7a8_ >= 3.f;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -14,14 +14,14 @@ class CCollisionActorManager;
|
|||
class CGenDescription;
|
||||
namespace MP1 {
|
||||
class CElitePirateData {
|
||||
public:
|
||||
private:
|
||||
float x0_tauntInterval;
|
||||
float x4_tauntVariance;
|
||||
float x8_;
|
||||
float xc_;
|
||||
float x10_;
|
||||
float x14_;
|
||||
float x18_;
|
||||
float x10_attackChance;
|
||||
float x14_shotAtTime;
|
||||
float x18_shotAtTimeVariance;
|
||||
float x1c_;
|
||||
CAssetId x20_;
|
||||
u16 x24_sfxAbsorb;
|
||||
|
@ -48,19 +48,43 @@ public:
|
|||
bool x11e_;
|
||||
bool x11f_;
|
||||
|
||||
public:
|
||||
CElitePirateData(CInputStream&, u32 propCount);
|
||||
|
||||
CAssetId GetX20() const { return x20_; }
|
||||
CAssetId GetXF8() const { return xf8_; }
|
||||
const CDamageInfo& GetXFC() const { return xfc_; }
|
||||
CAssetId GetX118() const { return x118_; }
|
||||
s16 GetX11C() const { return x11c_; }
|
||||
[[nodiscard]] float GetTauntInterval() const { return x0_tauntInterval; }
|
||||
[[nodiscard]] float GetTauntVariance() const { return x4_tauntVariance; }
|
||||
[[nodiscard]] float GetAttackChance() const { return x10_attackChance; }
|
||||
[[nodiscard]] float GetShotAtTime() const { return x14_shotAtTime; }
|
||||
[[nodiscard]] float GetShotAtTimeVariance() const { return x18_shotAtTimeVariance; }
|
||||
[[nodiscard]] CAssetId GetX20() const { return x20_; }
|
||||
[[nodiscard]] u16 GetSFXAbsorb() const { return x24_sfxAbsorb; }
|
||||
[[nodiscard]] const CActorParameters& GetLauncherActParams() const { return x28_launcherActParams; }
|
||||
[[nodiscard]] const CAnimationParameters& GetLauncherAnimParams() const { return x90_launcherAnimParams; }
|
||||
[[nodiscard]] float GetLauncherHP() const { return xc4_launcherHp; }
|
||||
[[nodiscard]] const SGrenadeTrajectoryInfo& GetGrenadeTrajectoryInfo() const { return xe0_trajectoryInfo; }
|
||||
[[nodiscard]] CAssetId GetXF8() const { return xf8_; }
|
||||
[[nodiscard]] const CDamageInfo& GetXFC() const { return xfc_; }
|
||||
[[nodiscard]] CAssetId GetX118() const { return x118_; }
|
||||
[[nodiscard]] s16 GetX11C() const { return x11c_; }
|
||||
[[nodiscard]] bool GetX11E() const { return x11e_; }
|
||||
[[nodiscard]] bool GetX11F() const { return x11f_; }
|
||||
|
||||
[[nodiscard]] SBouncyGrenadeData GetBouncyGrenadeData() const {
|
||||
return {xd8_, xa8_, xc8_, xcc_, xd0_, xd4_, xf0_grenadeNumBounces, xf4_, xf6_};
|
||||
}
|
||||
[[nodiscard]] SGrenadeLauncherData GetGrenadeLauncherData() const {
|
||||
return {GetBouncyGrenadeData(), xa4_, x9c_, xa0_, xe0_trajectoryInfo};
|
||||
}
|
||||
};
|
||||
|
||||
class CElitePirate : public CPatterned {
|
||||
private:
|
||||
struct SUnknownStruct {
|
||||
private:
|
||||
float x0_;
|
||||
rstl::reserved_vector<zeus::CVector3f, 16> x4_;
|
||||
|
||||
public:
|
||||
explicit SUnknownStruct(float f) : x0_(f * f) {}
|
||||
zeus::CVector3f GetValue(const zeus::CVector3f& v1, const zeus::CVector3f& v2);
|
||||
void AddValue(const zeus::CVector3f& vec);
|
||||
|
@ -81,7 +105,7 @@ class CElitePirate : public CPatterned {
|
|||
CElitePirateData x5d8_data;
|
||||
CBoneTracking x6f8_boneTracking;
|
||||
std::unique_ptr<CCollisionActorManager> x730_collisionActorMgr2;
|
||||
s32 x734_;
|
||||
// s32 x734_;
|
||||
CCollidableAABox x738_;
|
||||
std::optional<TLockedToken<CGenDescription>> x760_energyAbsorbDesc;
|
||||
TUniqueId x770_collisionHeadId = kInvalidUniqueId;
|
||||
|
@ -89,7 +113,7 @@ class CElitePirate : public CPatterned {
|
|||
rstl::reserved_vector<TUniqueId, 7> x774_collisionRJointIds;
|
||||
rstl::reserved_vector<TUniqueId, 7> x788_collisionLJointIds;
|
||||
TUniqueId x79c_ = kInvalidUniqueId;
|
||||
float x7a0_;
|
||||
float x7a0_initialSpeed;
|
||||
float x7a4_ = 1.f;
|
||||
float x7a8_ = 0.f;
|
||||
float x7ac_energyAbsorbCooldown = 0.f;
|
||||
|
@ -97,7 +121,7 @@ class CElitePirate : public CPatterned {
|
|||
float x7b4_hp = 0.f;
|
||||
float x7b8_attackTimer = 0.f;
|
||||
float x7bc_tauntTimer = 0.f;
|
||||
float x7c0_ = 0.f;
|
||||
float x7c0_shotAtTimer = 0.f;
|
||||
float x7c4_ = 0.f;
|
||||
s32 x7c8_currAnimId = -1;
|
||||
s32 x7cc_ = 0;
|
||||
|
@ -107,7 +131,7 @@ class CElitePirate : public CPatterned {
|
|||
bool x988_24_ : 1;
|
||||
bool x988_25_ : 1;
|
||||
bool x988_26_ : 1;
|
||||
bool x988_27_ : 1;
|
||||
bool x988_27_shotAt : 1;
|
||||
bool x988_28_alert : 1;
|
||||
bool x988_29_ : 1;
|
||||
bool x988_30_ : 1;
|
||||
|
@ -171,7 +195,7 @@ public:
|
|||
|
||||
private:
|
||||
void sub_80229248();
|
||||
void sub_8022759c(bool param_1, CStateManager& mgr);
|
||||
void SetShotAt(bool val, CStateManager& mgr);
|
||||
bool IsArmClawCollider(TUniqueId uid, const rstl::reserved_vector<TUniqueId, 7>& vec) const;
|
||||
void AddSphereCollisionList(const SSphereJointInfo* joints, size_t count,
|
||||
std::vector<CJointCollisionDescription>& outJoints) const;
|
||||
|
|
|
@ -15,7 +15,7 @@ CGrenadeLauncher::CGrenadeLauncher(TUniqueId uid, std::string_view name, const C
|
|||
const zeus::CTransform& xf, CModelData&& mData, const zeus::CAABox& bounds,
|
||||
const CHealthInfo& healthInfo, const CDamageVulnerability& vulnerability,
|
||||
const CActorParameters& actParams, TUniqueId parentId,
|
||||
const CGrenadeLauncherData& data, float f1)
|
||||
const SGrenadeLauncherData& data, float f1)
|
||||
: CPhysicsActor(uid, true, name, info, xf, std::move(mData), {EMaterialTypes::Character, EMaterialTypes::Solid}, bounds,
|
||||
{1000.f}, actParams, 0.3f, 0.1f)
|
||||
, x25c_healthInfo(healthInfo)
|
||||
|
@ -26,8 +26,8 @@ CGrenadeLauncher::CGrenadeLauncher(TUniqueId uid, std::string_view name, const C
|
|||
, x350_grenadeActorParams(actParams)
|
||||
, x3e8_thermalMag(actParams.GetThermalMag())
|
||||
, x3f8_explodePlayerDistance(f1) {
|
||||
if (data.x40_.IsValid()) {
|
||||
x3b8_particleGenDesc = g_SimplePool->GetObj({SBIG('PART'), data.x40_});
|
||||
if (data.GetExplosionGenDescId().IsValid()) {
|
||||
x3b8_particleGenDesc = g_SimplePool->GetObj({SBIG('PART'), data.GetExplosionGenDescId()});
|
||||
}
|
||||
GetModelData()->EnableLooping(true);
|
||||
const CPASDatabase& pasDatabase = GetModelData()->GetAnimationData()->GetCharacterInfo().GetPASDatabase();
|
||||
|
@ -48,31 +48,31 @@ zeus::CVector3f CGrenadeLauncher::GrenadeTarget(const CStateManager& mgr) {
|
|||
void CGrenadeLauncher::CalculateGrenadeTrajectory(const zeus::CVector3f& target, const zeus::CVector3f& origin,
|
||||
const SGrenadeTrajectoryInfo& info, float& angleOut,
|
||||
float& velocityOut) {
|
||||
float angle = info.x8_angleMin;
|
||||
float velocity = info.x0_;
|
||||
float delta = std::max(0.01f, 0.1f * (info.xc_angleMax - info.x8_angleMin));
|
||||
float angle = info.GetAngleMin();
|
||||
float velocity = info.GetVelocityMin();
|
||||
float delta = std::max(0.01f, 0.1f * (info.GetAngleMax() - info.GetAngleMin()));
|
||||
zeus::CVector3f dist = target - origin;
|
||||
float distXYMag = dist.toVec2f().magnitude();
|
||||
float qwSq = info.x0_ * info.x0_;
|
||||
float qxSq = info.x4_ * info.x4_;
|
||||
float velocityMinSq = info.GetVelocityMin() * info.GetVelocityMin();
|
||||
float velocityMaxSq = info.GetVelocityMax() * info.GetVelocityMax();
|
||||
float gravAdj = distXYMag * ((0.5f * CPhysicsActor::GravityConstant()) * distXYMag);
|
||||
float currAngle = info.x8_angleMin;
|
||||
float currAngle = info.GetAngleMin();
|
||||
float leastResult = FLT_MAX;
|
||||
while (info.xc_angleMax >= currAngle) {
|
||||
while (info.GetAngleMax() >= currAngle) {
|
||||
float cos = std::cos(currAngle);
|
||||
float sin = std::sin(currAngle);
|
||||
float result = (distXYMag * (cos * sin) - (dist.z() * (cos * cos)));
|
||||
if (result > FLT_EPSILON) {
|
||||
float div = gravAdj / result;
|
||||
if (qwSq <= result && result <= qxSq) {
|
||||
if (velocityMinSq <= result && result <= velocityMaxSq) {
|
||||
angle = currAngle;
|
||||
velocity = std::sqrt(div);
|
||||
break;
|
||||
}
|
||||
if (result <= qxSq) {
|
||||
result = qwSq - result;
|
||||
if (result <= velocityMaxSq) {
|
||||
result = velocityMinSq - result;
|
||||
} else {
|
||||
result = result - qxSq;
|
||||
result = result - velocityMaxSq;
|
||||
}
|
||||
if (result < leastResult) {
|
||||
angle = currAngle;
|
||||
|
@ -206,7 +206,7 @@ void CGrenadeLauncher::CreateExplosion(CStateManager& mgr) {
|
|||
mgr.AddObject(new CExplosion(*x3b8_particleGenDesc, mgr.AllocateUniqueId(), true,
|
||||
{GetAreaIdAlways(), CEntity::NullConnectionList}, "Grenade Launcher Explode Fx"sv,
|
||||
GetTransform(), 0, GetModelData()->GetScale(), zeus::skWhite));
|
||||
CSfxManager::SfxStart(x2d0_data.x44_launcherExplodeSfx, 1.f, 1.f, false, 0x7f, false, kInvalidAreaId);
|
||||
CSfxManager::SfxStart(x2d0_data.GetExplosionSfx(), 1.f, 1.f, false, 0x7f, false, kInvalidAreaId);
|
||||
}
|
||||
|
||||
void CGrenadeLauncher::sub_8022f9e0(CStateManager& mgr, float dt) {
|
||||
|
@ -302,9 +302,9 @@ void CGrenadeLauncher::LaunchGrenade(CStateManager& mgr) {
|
|||
const zeus::CVector3f& origin =
|
||||
GetTranslation() + GetTransform().rotate(GetLocatorTransform("grenade_LCTR"sv).origin);
|
||||
const zeus::CVector3f& target = GrenadeTarget(mgr);
|
||||
float angleOut = x2d0_data.x48_trajectoryInfo.x8_angleMin;
|
||||
float velocityOut = x2d0_data.x48_trajectoryInfo.x0_;
|
||||
CalculateGrenadeTrajectory(target, origin, x2d0_data.x48_trajectoryInfo, angleOut, velocityOut);
|
||||
float angleOut = x2d0_data.GetGrenadeTrajectoryInfo().GetAngleMin();
|
||||
float velocityOut = x2d0_data.GetGrenadeTrajectoryInfo().GetVelocityMin();
|
||||
CalculateGrenadeTrajectory(target, origin, x2d0_data.GetGrenadeTrajectoryInfo(), angleOut, velocityOut);
|
||||
|
||||
zeus::CVector3f dist = target - origin;
|
||||
dist.z() = 0.f;
|
||||
|
@ -322,10 +322,10 @@ void CGrenadeLauncher::LaunchGrenade(CStateManager& mgr) {
|
|||
|
||||
const zeus::CVector3f& look = zeus::CVector3f::slerp(dist, zeus::skUp, angleOut);
|
||||
const zeus::CTransform& xf = zeus::lookAt(origin, origin + look, zeus::skUp);
|
||||
CModelData mData{CStaticRes{x2d0_data.x3c_grenadeCmdl, GetModelData()->GetScale()}};
|
||||
CModelData mData{CStaticRes{x2d0_data.GetGrenadeModelId(), GetModelData()->GetScale()}};
|
||||
mgr.AddObject(new CBouncyGrenade(mgr.AllocateUniqueId(), "Bouncy Grenade"sv,
|
||||
{GetAreaIdAlways(), CEntity::NullConnectionList}, xf, std::move(mData),
|
||||
x350_grenadeActorParams, x2cc_parentId, x2d0_data.x0_grenadeData, velocityOut,
|
||||
x350_grenadeActorParams, x2cc_parentId, x2d0_data.GetGrenadeData(), velocityOut,
|
||||
x3f8_explodePlayerDistance));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,48 +21,62 @@
|
|||
|
||||
namespace urde::MP1 {
|
||||
struct SGrenadeTrajectoryInfo {
|
||||
float x0_;
|
||||
float x4_;
|
||||
private:
|
||||
float x0_velocityMin;
|
||||
float x4_velocityMax;
|
||||
float x8_angleMin;
|
||||
float xc_angleMax;
|
||||
|
||||
public:
|
||||
explicit SGrenadeTrajectoryInfo(CInputStream& in)
|
||||
: x0_(in.readFloatBig())
|
||||
, x4_(in.readFloatBig())
|
||||
: x0_velocityMin(in.readFloatBig())
|
||||
, x4_velocityMax(in.readFloatBig())
|
||||
, x8_angleMin(zeus::degToRad(in.readFloatBig()))
|
||||
, xc_angleMax(zeus::degToRad(in.readFloatBig())) {}
|
||||
|
||||
[[nodiscard]] float GetVelocityMin() const { return x0_velocityMin; }
|
||||
[[nodiscard]] float GetVelocityMax() const { return x4_velocityMax; }
|
||||
[[nodiscard]] float GetAngleMin() const { return x8_angleMin; }
|
||||
[[nodiscard]] float GetAngleMax() const { return xc_angleMax; }
|
||||
};
|
||||
|
||||
class CGrenadeLauncherData {
|
||||
public:
|
||||
struct SGrenadeLauncherData {
|
||||
private:
|
||||
SBouncyGrenadeData x0_grenadeData;
|
||||
CAssetId x3c_grenadeCmdl;
|
||||
CAssetId x40_;
|
||||
CAssetId x40_launcherExplodeGenDesc;
|
||||
u16 x44_launcherExplodeSfx;
|
||||
SGrenadeTrajectoryInfo x48_trajectoryInfo;
|
||||
|
||||
CGrenadeLauncherData(const SBouncyGrenadeData& data, CAssetId w1, CAssetId w2, u16 sfx,
|
||||
public:
|
||||
SGrenadeLauncherData(const SBouncyGrenadeData& data, CAssetId w1, CAssetId w2, u16 sfx,
|
||||
const SGrenadeTrajectoryInfo& trajectoryInfo)
|
||||
: x0_grenadeData(data)
|
||||
, x3c_grenadeCmdl(w1)
|
||||
, x40_(w2)
|
||||
, x40_launcherExplodeGenDesc(w2)
|
||||
, x44_launcherExplodeSfx(sfx)
|
||||
, x48_trajectoryInfo(trajectoryInfo){};
|
||||
|
||||
[[nodiscard]] const SBouncyGrenadeData& GetGrenadeData() const { return x0_grenadeData; }
|
||||
[[nodiscard]] CAssetId GetGrenadeModelId() const { return x3c_grenadeCmdl; }
|
||||
[[nodiscard]] CAssetId GetExplosionGenDescId() const { return x40_launcherExplodeGenDesc; }
|
||||
[[nodiscard]] u16 GetExplosionSfx() const { return x44_launcherExplodeSfx; }
|
||||
[[nodiscard]] const SGrenadeTrajectoryInfo& GetGrenadeTrajectoryInfo() const { return x48_trajectoryInfo; }
|
||||
};
|
||||
|
||||
class CGrenadeLauncher : public CPhysicsActor {
|
||||
public:
|
||||
private:
|
||||
int x258_started = 0;
|
||||
CHealthInfo x25c_healthInfo;
|
||||
CDamageVulnerability x264_vulnerability;
|
||||
TUniqueId x2cc_parentId;
|
||||
CGrenadeLauncherData x2d0_data;
|
||||
SGrenadeLauncherData x2d0_data;
|
||||
CCollidableSphere x328_cSphere;
|
||||
float x348_shotTimer = -1.f;
|
||||
zeus::CColor x34c_color1{1.f};
|
||||
CActorParameters x350_grenadeActorParams;
|
||||
std::optional<TLockedToken<CGenDescription>> x3b8_particleGenDesc;
|
||||
std::array<s32, 4> x3c8_animIds;
|
||||
std::array<s32, 4> x3c8_animIds{};
|
||||
float x3d8_ = 0.f;
|
||||
float x3dc_ = 0.f;
|
||||
float x3e0_ = 0.f;
|
||||
|
@ -76,10 +90,11 @@ public:
|
|||
bool x3fd_visible = true;
|
||||
bool x3fe_ = true;
|
||||
|
||||
public:
|
||||
CGrenadeLauncher(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||
CModelData&& mData, const zeus::CAABox& bounds, const CHealthInfo& healthInfo,
|
||||
const CDamageVulnerability& vulnerability, const CActorParameters& actParams, TUniqueId parentId,
|
||||
const CGrenadeLauncherData& data, float f1);
|
||||
const SGrenadeLauncherData& data, float f1);
|
||||
|
||||
void Accept(IVisitor& visitor) override { visitor.Visit(this); }
|
||||
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
||||
|
@ -97,7 +112,7 @@ public:
|
|||
static void CalculateGrenadeTrajectory(const zeus::CVector3f& target, const zeus::CVector3f& origin,
|
||||
const SGrenadeTrajectoryInfo& info, float& angleOut, float& velocityOut);
|
||||
|
||||
protected:
|
||||
private:
|
||||
void UpdateCollision();
|
||||
void UpdateColor(float arg);
|
||||
void sub_8022f69c(float arg);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace urde {
|
|||
class CPatternedInfo;
|
||||
class CProjectileInfo;
|
||||
class CPathFindSearch;
|
||||
typedef void (CPatterned::*CPatternedTryFunc)(CStateManager&, int);
|
||||
using CPatternedTryFunc = void (CPatterned::*)(CStateManager&, int);
|
||||
|
||||
class CPatterned : public CAi {
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue