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