CEnergyProjectile: Properly set hitProjectileOwner

Fixes #359
This commit is contained in:
Luke Street 2020-09-26 10:38:22 -04:00
parent 902b5644f7
commit dad16bf59b
3 changed files with 7 additions and 4 deletions

View File

@ -158,6 +158,7 @@ void CEnergyProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CAc
ApplyDamageToActors(mgr, x12c_curDamageInfo); ApplyDamageToActors(mgr, x12c_curDamageInfo);
} }
if (const TCastToPtr<CEnergyProjectile> proj = act) { if (const TCastToPtr<CEnergyProjectile> proj = act) {
proj->SetHitProjectileOwner(xec_ownerId);
proj->Explode(GetTranslation(), x34_transform.basis[1], EWeaponCollisionResponseTypes::OtherProjectile, mgr, proj->Explode(GetTranslation(), x34_transform.basis[1], EWeaponCollisionResponseTypes::OtherProjectile, mgr,
*GetDamageVulnerability(), GetUniqueId()); *GetDamageVulnerability(), GetUniqueId());
} }

View File

@ -42,7 +42,7 @@ protected:
double x2b8_curHomingTime = x2a8_homingDt; double x2b8_curHomingTime = x2a8_homingDt;
TUniqueId x2c0_homingTargetId; TUniqueId x2c0_homingTargetId;
TUniqueId x2c2_lastResolvedObj = kInvalidUniqueId; TUniqueId x2c2_lastResolvedObj = kInvalidUniqueId;
TUniqueId x2c4_ = kInvalidUniqueId; TUniqueId x2c4_hitProjectileOwner = kInvalidUniqueId;
TUniqueId x2c6_pendingDamagee = kInvalidUniqueId; TUniqueId x2c6_pendingDamagee = kInvalidUniqueId;
TUniqueId x2c8_projectileLight = kInvalidUniqueId; TUniqueId x2c8_projectileLight = kInvalidUniqueId;
CAssetId x2cc_wpscId; CAssetId x2cc_wpscId;
@ -88,5 +88,6 @@ public:
TUniqueId GetHomingTargetId() const { return x2c0_homingTargetId; } TUniqueId GetHomingTargetId() const { return x2c0_homingTargetId; }
zeus::CVector3f GetPreviousPos() const { return x298_previousPos; } zeus::CVector3f GetPreviousPos() const { return x298_previousPos; }
void SetMinHomingDistance(float dist) { x2e0_minHomingDist = dist; } void SetMinHomingDistance(float dist) { x2e0_minHomingDist = dist; }
void SetHitProjectileOwner(TUniqueId id) { x2c4_hitProjectileOwner = id; }
}; };
} // namespace urde } // namespace urde

View File

@ -35,7 +35,8 @@ bool CTargetableProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVec
const CDamageVulnerability& dVuln, TUniqueId hitActor) { const CDamageVulnerability& dVuln, TUniqueId hitActor) {
bool ret = CEnergyProjectile::Explode(pos, normal, type, mgr, dVuln, hitActor); bool ret = CEnergyProjectile::Explode(pos, normal, type, mgr, dVuln, hitActor);
if (x2e4_24_active || x2c4_ == kInvalidUniqueId || x2c4_ != mgr.GetPlayer().GetUniqueId()) { if (x2e4_24_active || x2c4_hitProjectileOwner == kInvalidUniqueId ||
x2c4_hitProjectileOwner != mgr.GetPlayer().GetUniqueId()) {
return ret; return ret;
} }
@ -43,13 +44,13 @@ bool CTargetableProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVec
TUniqueId uid = mgr.AllocateUniqueId(); TUniqueId uid = mgr.AllocateUniqueId();
zeus::CTransform xf = zeus::lookAt(x170_projectile.GetTranslation(), act->GetAimPosition(mgr, 0.f), zeus::skUp); zeus::CTransform xf = zeus::lookAt(x170_projectile.GetTranslation(), act->GetAimPosition(mgr, 0.f), zeus::skUp);
auto* projectile = new CEnergyProjectile(true, x3d8_weaponDesc, xf0_weaponType, xf, EMaterialTypes::Player, auto* projectile = new CEnergyProjectile(true, x3d8_weaponDesc, xf0_weaponType, xf, EMaterialTypes::Player,
x3e0_damage, uid, GetAreaIdAlways(), x2c4_, xec_ownerId, x3e0_damage, uid, GetAreaIdAlways(), x2c4_hitProjectileOwner, xec_ownerId,
EProjectileAttrib::None, false, zeus::skOne3f, {}, 0xFFFF, false); EProjectileAttrib::None, false, zeus::skOne3f, {}, 0xFFFF, false);
mgr.AddObject(projectile); mgr.AddObject(projectile);
projectile->AddMaterial(EMaterialTypes::Orbit); projectile->AddMaterial(EMaterialTypes::Orbit);
mgr.GetPlayer().ResetAimTargetPrediction(uid); mgr.GetPlayer().ResetAimTargetPrediction(uid);
mgr.GetPlayer().SetOrbitTargetId(uid, mgr); mgr.GetPlayer().SetOrbitTargetId(uid, mgr);
x2c4_ = kInvalidUniqueId; x2c4_hitProjectileOwner = kInvalidUniqueId;
} }
return ret; return ret;