mirror of https://github.com/AxioDL/metaforce.git
CEnergyProjectile: Make use of const where applicable
While we're at it, make use of consistent bracing, given some conditionals traveled over one line.
This commit is contained in:
parent
9cf95b5c10
commit
c14721611b
|
@ -35,8 +35,11 @@ CEnergyProjectile::CEnergyProjectile(bool active, const TToken<CWeaponDescriptio
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::PlayImpactSound(const zeus::CVector3f& pos, EWeaponCollisionResponseTypes type) {
|
void CEnergyProjectile::PlayImpactSound(const zeus::CVector3f& pos, EWeaponCollisionResponseTypes type) {
|
||||||
s32 sfxId = x170_projectile.GetSoundIdForCollision(type);
|
const s32 sfxId = x170_projectile.GetSoundIdForCollision(type);
|
||||||
if (sfxId >= 0) {
|
if (sfxId < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CAudioSys::C3DEmitterParmData parmData = {};
|
CAudioSys::C3DEmitterParmData parmData = {};
|
||||||
parmData.x18_maxDist = x170_projectile.GetAudibleRange();
|
parmData.x18_maxDist = x170_projectile.GetAudibleRange();
|
||||||
parmData.x1c_distComp = x170_projectile.GetAudibleFallOff();
|
parmData.x1c_distComp = x170_projectile.GetAudibleFallOff();
|
||||||
|
@ -45,15 +48,22 @@ void CEnergyProjectile::PlayImpactSound(const zeus::CVector3f& pos, EWeaponColli
|
||||||
parmData.x26_maxVol = 1.f;
|
parmData.x26_maxVol = 1.f;
|
||||||
parmData.x27_minVol = 0.16f;
|
parmData.x27_minVol = 0.16f;
|
||||||
parmData.x29_prio = 0x7f;
|
parmData.x29_prio = 0x7f;
|
||||||
CSfxHandle hnd = CSfxManager::AddEmitter(parmData, true, 0x7f, false, kInvalidAreaId);
|
|
||||||
if (x2e4_26_waterUpdate)
|
const CSfxHandle hnd = CSfxManager::AddEmitter(parmData, true, 0x7f, false, kInvalidAreaId);
|
||||||
CSfxManager::PitchBend(hnd, -1.f);
|
if (!x2e4_26_waterUpdate) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSfxManager::PitchBend(hnd, -1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::ChangeProjectileOwner(TUniqueId owner, CStateManager& mgr) {
|
void CEnergyProjectile::ChangeProjectileOwner(TUniqueId owner, CStateManager& mgr) {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(owner)) {
|
const TCastToConstPtr<CActor> act = mgr.GetObjectById(owner);
|
||||||
float rDam = g_tweakPlayerGun->GetRichochetDamage(u32(x110_origDamageInfo.GetWeaponMode().GetType()));
|
if (!act) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float rDam = g_tweakPlayerGun->GetRichochetDamage(u32(x110_origDamageInfo.GetWeaponMode().GetType()));
|
||||||
x110_origDamageInfo.MultiplyDamageAndRadius(rDam);
|
x110_origDamageInfo.MultiplyDamageAndRadius(rDam);
|
||||||
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
||||||
xec_ownerId = owner;
|
xec_ownerId = owner;
|
||||||
|
@ -63,32 +73,36 @@ void CEnergyProjectile::ChangeProjectileOwner(TUniqueId owner, CStateManager& mg
|
||||||
xf8_filter.ExcludeList().Add(EMaterialTypes::Character);
|
xf8_filter.ExcludeList().Add(EMaterialTypes::Character);
|
||||||
xf8_filter.ExcludeList().Remove(EMaterialTypes::Player);
|
xf8_filter.ExcludeList().Remove(EMaterialTypes::Player);
|
||||||
xf8_filter = CMaterialFilter::MakeIncludeExclude(xf8_filter.GetIncludeList(), xf8_filter.GetExcludeList());
|
xf8_filter = CMaterialFilter::MakeIncludeExclude(xf8_filter.GetIncludeList(), xf8_filter.GetExcludeList());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
void CEnergyProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case EScriptObjectMessage::Deleted:
|
case EScriptObjectMessage::Deleted:
|
||||||
if (x2e4_24_active)
|
if (x2e4_24_active) {
|
||||||
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
||||||
|
}
|
||||||
if (x2e8_sfx) {
|
if (x2e8_sfx) {
|
||||||
CSfxManager::RemoveEmitter(x2e8_sfx);
|
CSfxManager::RemoveEmitter(x2e8_sfx);
|
||||||
x2e8_sfx.reset();
|
x2e8_sfx.reset();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EScriptObjectMessage::Registered: {
|
case EScriptObjectMessage::Registered: {
|
||||||
if (CElementGen* ps1 = x170_projectile.GetAttachedPS1())
|
if (CElementGen* ps1 = x170_projectile.GetAttachedPS1()) {
|
||||||
if (ps1->SystemHasLight())
|
if (ps1->SystemHasLight()) {
|
||||||
CreateProjectileLight("ProjectileLight_GameProjectile", ps1->GetLight(), mgr);
|
CreateProjectileLight("ProjectileLight_GameProjectile", ps1->GetLight(), mgr);
|
||||||
TLockedToken<CWeaponDescription> desc = x170_projectile.GetWeaponDescription();
|
}
|
||||||
s32 sfx = desc->xa8_PJFX;
|
}
|
||||||
|
const TLockedToken<CWeaponDescription> desc = x170_projectile.GetWeaponDescription();
|
||||||
|
const s32 sfx = desc->xa8_PJFX;
|
||||||
if (sfx != -1) {
|
if (sfx != -1) {
|
||||||
float range = 50.f;
|
float range = 50.f;
|
||||||
float falloff = 0.2f;
|
float falloff = 0.2f;
|
||||||
if (CRealElement* rnge = desc->xac_RNGE.get())
|
if (CRealElement* rnge = desc->xac_RNGE.get()) {
|
||||||
rnge->GetValue(0, range);
|
rnge->GetValue(0, range);
|
||||||
if (CRealElement* foff = desc->xb0_FOFF.get())
|
}
|
||||||
|
if (CRealElement* foff = desc->xb0_FOFF.get()) {
|
||||||
foff->GetValue(0, falloff);
|
foff->GetValue(0, falloff);
|
||||||
|
}
|
||||||
|
|
||||||
CAudioSys::C3DEmitterParmData parmData = {};
|
CAudioSys::C3DEmitterParmData parmData = {};
|
||||||
parmData.x0_pos = x170_projectile.GetTranslation();
|
parmData.x0_pos = x170_projectile.GetTranslation();
|
||||||
|
@ -117,22 +131,27 @@ void CEnergyProjectile::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
static constexpr u64 kCheckMaterial = 0xE3FFFE;
|
static constexpr u64 kCheckMaterial = 0xE3FFFE;
|
||||||
|
|
||||||
void CEnergyProjectile::ResolveCollisionWithWorld(const CRayCastResult& res, CStateManager& mgr) {
|
void CEnergyProjectile::ResolveCollisionWithWorld(const CRayCastResult& res, CStateManager& mgr) {
|
||||||
EWeaponCollisionResponseTypes crType = CCollisionResponseData::GetWorldCollisionResponseType(
|
const auto crType = CCollisionResponseData::GetWorldCollisionResponseType(
|
||||||
CMaterialList::BitPosition((res.GetMaterial().GetValue() & 0xffffffff) & kCheckMaterial));
|
CMaterialList::BitPosition((res.GetMaterial().GetValue() & 0xffffffff) & kCheckMaterial));
|
||||||
if ((xe8_projectileAttribs & (EProjectileAttrib::Wave | EProjectileAttrib::ComboShot)) !=
|
|
||||||
|
if ((xe8_projectileAttribs & (EProjectileAttrib::Wave | EProjectileAttrib::ComboShot)) ==
|
||||||
(EProjectileAttrib::Wave | EProjectileAttrib::ComboShot)) {
|
(EProjectileAttrib::Wave | EProjectileAttrib::ComboShot)) {
|
||||||
/* Not wavebuster */
|
return;
|
||||||
if (Explode(res.GetPoint(), res.GetPlane().normal(), crType, mgr, CDamageVulnerability::NormalVulnerabilty(),
|
|
||||||
kInvalidUniqueId))
|
|
||||||
mgr.ApplyDamageToWorld(xec_ownerId, *this, res.GetPoint(), x12c_curDamageInfo, xf8_filter);
|
|
||||||
x2c2_lastResolvedObj = kInvalidUniqueId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not wavebuster
|
||||||
|
if (Explode(res.GetPoint(), res.GetPlane().normal(), crType, mgr, CDamageVulnerability::NormalVulnerabilty(),
|
||||||
|
kInvalidUniqueId)) {
|
||||||
|
mgr.ApplyDamageToWorld(xec_ownerId, *this, res.GetPoint(), x12c_curDamageInfo, xf8_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
x2c2_lastResolvedObj = kInvalidUniqueId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr) {
|
void CEnergyProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr) {
|
||||||
x2c2_lastResolvedObj = act.GetUniqueId();
|
x2c2_lastResolvedObj = act.GetUniqueId();
|
||||||
EWeaponCollisionResponseTypes crType = act.GetCollisionResponseType(
|
const auto crType = act.GetCollisionResponseType(res.GetPoint(), x34_transform.basis[1].normalized(),
|
||||||
res.GetPoint(), x34_transform.basis[1].normalized(), x12c_curDamageInfo.GetWeaponMode(), xe8_projectileAttribs);
|
x12c_curDamageInfo.GetWeaponMode(), xe8_projectileAttribs);
|
||||||
act.Touch(*this, mgr);
|
act.Touch(*this, mgr);
|
||||||
const CDamageVulnerability* dVuln = act.GetDamageVulnerability();
|
const CDamageVulnerability* dVuln = act.GetDamageVulnerability();
|
||||||
if (!Explode(res.GetPoint(), res.GetPlane().normal(), crType, mgr, *dVuln, act.GetUniqueId())) {
|
if (!Explode(res.GetPoint(), res.GetPlane().normal(), crType, mgr, *dVuln, act.GetUniqueId())) {
|
||||||
|
@ -142,7 +161,7 @@ void CEnergyProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CAc
|
||||||
CGameProjectile::ResolveCollisionWithActor(res, act, mgr);
|
CGameProjectile::ResolveCollisionWithActor(res, act, mgr);
|
||||||
ApplyDamageToActors(mgr, x12c_curDamageInfo);
|
ApplyDamageToActors(mgr, x12c_curDamageInfo);
|
||||||
}
|
}
|
||||||
if (TCastToPtr<CEnergyProjectile> proj = act) {
|
if (const TCastToPtr<CEnergyProjectile> proj = act) {
|
||||||
proj->Explode(GetTranslation(), x34_transform.basis[1], EWeaponCollisionResponseTypes::OtherProjectile, mgr,
|
proj->Explode(GetTranslation(), x34_transform.basis[1], EWeaponCollisionResponseTypes::OtherProjectile, mgr,
|
||||||
*GetDamageVulnerability(), GetUniqueId());
|
*GetDamageVulnerability(), GetUniqueId());
|
||||||
}
|
}
|
||||||
|
@ -151,33 +170,38 @@ void CEnergyProjectile::ResolveCollisionWithActor(const CRayCastResult& res, CAc
|
||||||
void CEnergyProjectile::Think(float dt, CStateManager& mgr) {
|
void CEnergyProjectile::Think(float dt, CStateManager& mgr) {
|
||||||
CWeapon::Think(dt, mgr);
|
CWeapon::Think(dt, mgr);
|
||||||
if (mgr.GetWorld()->GetCurrentAreaId() != GetAreaIdAlways() &&
|
if (mgr.GetWorld()->GetCurrentAreaId() != GetAreaIdAlways() &&
|
||||||
(xe8_projectileAttribs & EProjectileAttrib::ArmCannon) == EProjectileAttrib::ArmCannon)
|
(xe8_projectileAttribs & EProjectileAttrib::ArmCannon) == EProjectileAttrib::ArmCannon) {
|
||||||
mgr.SetActorAreaId(*this, mgr.GetWorld()->GetCurrentAreaId());
|
mgr.SetActorAreaId(*this, mgr.GetWorld()->GetCurrentAreaId());
|
||||||
|
}
|
||||||
|
|
||||||
UpdateProjectileMovement(dt, mgr);
|
UpdateProjectileMovement(dt, mgr);
|
||||||
TUniqueId id = kInvalidUniqueId;
|
TUniqueId id = kInvalidUniqueId;
|
||||||
CRayCastResult res = DoCollisionCheck(id, mgr);
|
const CRayCastResult res = DoCollisionCheck(id, mgr);
|
||||||
if (res.IsValid()) {
|
if (res.IsValid()) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(id))
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(id)) {
|
||||||
ResolveCollisionWithActor(res, *act, mgr);
|
ResolveCollisionWithActor(res, *act, mgr);
|
||||||
else
|
} else {
|
||||||
ResolveCollisionWithWorld(res, mgr);
|
ResolveCollisionWithWorld(res, mgr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x170_projectile.UpdateParticleFX();
|
x170_projectile.UpdateParticleFX();
|
||||||
if (x2e4_24_active && x3d0_26_)
|
if (x2e4_24_active && x3d0_26_) {
|
||||||
Explode(GetTranslation(), zeus::skUp, EWeaponCollisionResponseTypes::Default, mgr,
|
Explode(GetTranslation(), zeus::skUp, EWeaponCollisionResponseTypes::Default, mgr,
|
||||||
CDamageVulnerability::NormalVulnerabilty(), kInvalidUniqueId);
|
CDamageVulnerability::NormalVulnerabilty(), kInvalidUniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
if (x2c8_projectileLight != kInvalidUniqueId) {
|
if (x2c8_projectileLight != kInvalidUniqueId) {
|
||||||
if (TCastToPtr<CGameLight> light = mgr.ObjectById(x2c8_projectileLight)) {
|
if (const TCastToPtr<CGameLight> light = mgr.ObjectById(x2c8_projectileLight)) {
|
||||||
light->SetTransform(GetTransform());
|
light->SetTransform(GetTransform());
|
||||||
light->SetTranslation(GetTranslation());
|
light->SetTranslation(GetTranslation());
|
||||||
if (CElementGen* ps1 = x170_projectile.GetAttachedPS1())
|
if (CElementGen* ps1 = x170_projectile.GetAttachedPS1()) {
|
||||||
if (ps1->SystemHasLight())
|
if (ps1->SystemHasLight()) {
|
||||||
light->SetLight(ps1->GetLight());
|
light->SetLight(ps1->GetLight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (x2e8_sfx) {
|
if (x2e8_sfx) {
|
||||||
CSfxManager::UpdateEmitter(x2e8_sfx, x170_projectile.GetTranslation(), x170_projectile.GetVelocity(), 1.f);
|
CSfxManager::UpdateEmitter(x2e8_sfx, x170_projectile.GetTranslation(), x170_projectile.GetVelocity(), 1.f);
|
||||||
|
@ -185,22 +209,24 @@ void CEnergyProjectile::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
x3d4_curTime += dt;
|
x3d4_curTime += dt;
|
||||||
if (x3d4_curTime > 45.f || x170_projectile.IsSystemDeletable() || x3d0_24_dead)
|
if (x3d4_curTime > 45.f || x170_projectile.IsSystemDeletable() || x3d0_24_dead) {
|
||||||
mgr.FreeScriptObject(GetUniqueId());
|
mgr.FreeScriptObject(GetUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::Render(CStateManager& mgr) {
|
void CEnergyProjectile::Render(CStateManager& mgr) {
|
||||||
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CEnergyProjectile::Render WPSC_{}"), x2cc_wpscId).c_str(), zeus::skOrange);
|
SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CEnergyProjectile::Render WPSC_{}"), x2cc_wpscId).c_str(), zeus::skOrange);
|
||||||
|
|
||||||
CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
const auto visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
||||||
if (visor == CPlayerState::EPlayerVisor::Combat) {
|
if (visor == CPlayerState::EPlayerVisor::Combat) {
|
||||||
if ((xe8_projectileAttribs & EProjectileAttrib::Charged) == EProjectileAttrib::Charged ||
|
if ((xe8_projectileAttribs & EProjectileAttrib::Charged) == EProjectileAttrib::Charged ||
|
||||||
(xe8_projectileAttribs & EProjectileAttrib::ComboShot) == EProjectileAttrib::ComboShot) {
|
(xe8_projectileAttribs & EProjectileAttrib::ComboShot) == EProjectileAttrib::ComboShot) {
|
||||||
float warpTime = 1.f - float(x170_projectile.GameTime());
|
const float warpTime = 1.f - float(x170_projectile.GameTime());
|
||||||
if (warpTime > 0.f)
|
if (warpTime > 0.f) {
|
||||||
mgr.DrawSpaceWarp(GetTranslation(), warpTime * 0.75f);
|
mgr.DrawSpaceWarp(GetTranslation(), warpTime * 0.75f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (visor == CPlayerState::EPlayerVisor::XRay) {
|
if (visor == CPlayerState::EPlayerVisor::XRay) {
|
||||||
CElementGen::SetSubtractBlend((xe8_projectileAttribs & EProjectileAttrib::Ice) != EProjectileAttrib::Ice);
|
CElementGen::SetSubtractBlend((xe8_projectileAttribs & EProjectileAttrib::Ice) != EProjectileAttrib::Ice);
|
||||||
|
@ -222,11 +248,12 @@ void CEnergyProjectile::Render(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEnergyProjectile::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
|
void CEnergyProjectile::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
|
||||||
auto bounds = x170_projectile.GetBounds();
|
const auto bounds = x170_projectile.GetBounds();
|
||||||
if (bounds && !frustum.aabbFrustumTest(*bounds))
|
if (bounds && !frustum.aabbFrustumTest(*bounds)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
const auto visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
||||||
if (visor != CPlayerState::EPlayerVisor::XRay &&
|
if (visor != CPlayerState::EPlayerVisor::XRay &&
|
||||||
((xe8_projectileAttribs & EProjectileAttrib::Ice) != EProjectileAttrib::Ice ||
|
((xe8_projectileAttribs & EProjectileAttrib::Ice) != EProjectileAttrib::Ice ||
|
||||||
mgr.GetThermalDrawFlag() != EThermalDrawFlag::Hot)) {
|
mgr.GetThermalDrawFlag() != EThermalDrawFlag::Hot)) {
|
||||||
|
@ -247,7 +274,8 @@ bool CEnergyProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVector3
|
||||||
bool retargetPlayer = false;
|
bool retargetPlayer = false;
|
||||||
bool deflect = false;
|
bool deflect = false;
|
||||||
zeus::CVector3f targetPos;
|
zeus::CVector3f targetPos;
|
||||||
EVulnerability vulnType = dVuln.GetVulnerability(x12c_curDamageInfo.GetWeaponMode(), false);
|
const EVulnerability vulnType = dVuln.GetVulnerability(x12c_curDamageInfo.GetWeaponMode(), false);
|
||||||
|
|
||||||
if (vulnType == EVulnerability::Deflect) {
|
if (vulnType == EVulnerability::Deflect) {
|
||||||
deflect = true;
|
deflect = true;
|
||||||
EDeflectType deflectType = dVuln.GetDeflectionType(x12c_curDamageInfo.GetWeaponMode());
|
EDeflectType deflectType = dVuln.GetDeflectionType(x12c_curDamageInfo.GetWeaponMode());
|
||||||
|
@ -259,17 +287,19 @@ bool CEnergyProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVector3
|
||||||
case EDeflectType::Three:
|
case EDeflectType::Three:
|
||||||
if (deflectType != EDeflectType::Two ||
|
if (deflectType != EDeflectType::Two ||
|
||||||
(xf0_weaponType != EWeaponType::Missile &&
|
(xf0_weaponType != EWeaponType::Missile &&
|
||||||
(xe8_projectileAttribs & EProjectileAttrib::ComboShot) != EProjectileAttrib::ComboShot))
|
(xe8_projectileAttribs & EProjectileAttrib::ComboShot) != EProjectileAttrib::ComboShot)) {
|
||||||
if (xf8_filter.GetExcludeList().HasMaterial(EMaterialTypes::Player))
|
if (xf8_filter.GetExcludeList().HasMaterial(EMaterialTypes::Player)) {
|
||||||
retargetPlayer = true;
|
retargetPlayer = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (retargetPlayer) {
|
if (retargetPlayer) {
|
||||||
float ang = mgr.GetActiveRandom()->Range(0.f, 2.f * M_PIF);
|
const float ang = mgr.GetActiveRandom()->Range(0.f, 2.f * M_PIF);
|
||||||
float y = std::sin(ang);
|
const float y = std::sin(ang);
|
||||||
float x = std::cos(ang);
|
const float x = std::cos(ang);
|
||||||
targetPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f) + zeus::CVector3f(x, 0.f, y);
|
targetPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f) + zeus::CVector3f(x, 0.f, y);
|
||||||
ChangeProjectileOwner(hitActor, mgr);
|
ChangeProjectileOwner(hitActor, mgr);
|
||||||
}
|
}
|
||||||
|
@ -278,7 +308,8 @@ bool CEnergyProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVector3
|
||||||
if (vulnType != EVulnerability::Immune && !deflect) {
|
if (vulnType != EVulnerability::Immune && !deflect) {
|
||||||
deflect =
|
deflect =
|
||||||
(type == EWeaponCollisionResponseTypes::Unknown15 || type == EWeaponCollisionResponseTypes::EnemyShielded ||
|
(type == EWeaponCollisionResponseTypes::Unknown15 || type == EWeaponCollisionResponseTypes::EnemyShielded ||
|
||||||
(type >= EWeaponCollisionResponseTypes::Unknown69 && type <= EWeaponCollisionResponseTypes::AtomicAlphaReflect));
|
(type >= EWeaponCollisionResponseTypes::Unknown69 &&
|
||||||
|
type <= EWeaponCollisionResponseTypes::AtomicAlphaReflect));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTranslation(offsetPos);
|
SetTranslation(offsetPos);
|
||||||
|
@ -309,29 +340,30 @@ bool CEnergyProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVector3
|
||||||
zeus::CVector3f scale = zeus::skOne3f;
|
zeus::CVector3f scale = zeus::skOne3f;
|
||||||
bool camClose = false;
|
bool camClose = false;
|
||||||
if (mgr.GetPlayer().GetCameraState() == CPlayer::EPlayerCameraState::FirstPerson) {
|
if (mgr.GetPlayer().GetCameraState() == CPlayer::EPlayerCameraState::FirstPerson) {
|
||||||
float mag = (offsetPos - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation()).magnitude();
|
const float mag = (offsetPos - mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTranslation()).magnitude();
|
||||||
if (mag < 4.f) {
|
if (mag < 4.f) {
|
||||||
scale = zeus::CVector3f(0.75f * (mag * 0.25f) + 0.25f);
|
scale = zeus::CVector3f(0.75f * (mag * 0.25f) + 0.25f);
|
||||||
camClose = true;
|
camClose = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
u32 explodeFlags = 0x8;
|
u32 explodeFlags = 0x8;
|
||||||
if ((xe8_projectileAttribs & EProjectileAttrib::Ice) == EProjectileAttrib::Ice)
|
if ((xe8_projectileAttribs & EProjectileAttrib::Ice) == EProjectileAttrib::Ice) {
|
||||||
explodeFlags |= 0x4;
|
explodeFlags |= 0x4;
|
||||||
if (camClose)
|
}
|
||||||
|
if (camClose) {
|
||||||
explodeFlags |= 0x2;
|
explodeFlags |= 0x2;
|
||||||
CEntityInfo explosionInfo(GetAreaIdAlways(), CEntity::NullConnectionList);
|
}
|
||||||
CExplosion* explosion =
|
const CEntityInfo explosionInfo(GetAreaIdAlways(), CEntity::NullConnectionList);
|
||||||
new CExplosion(*particle, mgr.AllocateUniqueId(), true, explosionInfo, "Projectile collision response",
|
auto* explosion = new CExplosion(*particle, mgr.AllocateUniqueId(), true, explosionInfo,
|
||||||
particleXf, explodeFlags, scale, zeus::skWhite);
|
"Projectile collision response", particleXf, explodeFlags, scale, zeus::skWhite);
|
||||||
mgr.AddObject(explosion);
|
mgr.AddObject(explosion);
|
||||||
if (TCastToPtr<CActor> hActor = mgr.ObjectById(hitActor)) {
|
if (const TCastToPtr<CActor> hActor = mgr.ObjectById(hitActor)) {
|
||||||
bool validPlat = false;
|
bool validPlat = false;
|
||||||
CScriptPlatform* plat = TCastToPtr<CScriptPlatform>(hActor.GetPtr()).GetPtr();
|
CScriptPlatform* plat = TCastToPtr<CScriptPlatform>(hActor.GetPtr()).GetPtr();
|
||||||
validPlat = plat != nullptr;
|
validPlat = plat != nullptr;
|
||||||
if (!validPlat && hActor->GetMaterialList().HasMaterial(EMaterialTypes::Bomb)) {
|
if (!validPlat && hActor->GetMaterialList().HasMaterial(EMaterialTypes::Bomb)) {
|
||||||
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList()) {
|
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList()) {
|
||||||
if (TCastToPtr<CScriptPlatform> otherPlat = ent) {
|
if (const TCastToPtr<CScriptPlatform> otherPlat = ent) {
|
||||||
if (otherPlat->IsSlave(hitActor)) {
|
if (otherPlat->IsSlave(hitActor)) {
|
||||||
plat = otherPlat.GetPtr();
|
plat = otherPlat.GetPtr();
|
||||||
validPlat = true;
|
validPlat = true;
|
||||||
|
@ -340,22 +372,24 @@ bool CEnergyProjectile::Explode(const zeus::CVector3f& pos, const zeus::CVector3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (validPlat)
|
if (validPlat) {
|
||||||
plat->AddSlave(explosion->GetUniqueId(), mgr);
|
plat->AddSlave(explosion->GetUniqueId(), mgr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
x3d0_24_dead = true;
|
x3d0_24_dead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((xe8_projectileAttribs & (EProjectileAttrib::ComboShot | EProjectileAttrib::Ice)) ==
|
if ((xe8_projectileAttribs & (EProjectileAttrib::ComboShot | EProjectileAttrib::Ice)) ==
|
||||||
(EProjectileAttrib::ComboShot | EProjectileAttrib::Ice)) {
|
(EProjectileAttrib::ComboShot | EProjectileAttrib::Ice)) {
|
||||||
/* Ice Spreader */
|
// Ice Spreader
|
||||||
TLockedToken<CGenDescription> iceSpreadParticle = g_SimplePool->GetObj("IceSpread1");
|
const TLockedToken<CGenDescription> iceSpreadParticle = g_SimplePool->GetObj("IceSpread1");
|
||||||
|
|
||||||
u32 flags = (xe6_27_thermalVisorFlags & 0x2) == 0 ? 1 : 0;
|
u32 flags = (xe6_27_thermalVisorFlags & 0x2) == 0 ? 1 : 0;
|
||||||
flags |= 0x2;
|
flags |= 0x2;
|
||||||
CIceImpact* iceImpact =
|
|
||||||
new CIceImpact(iceSpreadParticle, mgr.AllocateUniqueId(), GetAreaIdAlways(), true, "Ice spread explosion",
|
auto* iceImpact = new CIceImpact(iceSpreadParticle, mgr.AllocateUniqueId(), GetAreaIdAlways(), true,
|
||||||
particleXf, flags, zeus::skOne3f, zeus::skWhite);
|
"Ice spread explosion", particleXf, flags, zeus::skOne3f, zeus::skWhite);
|
||||||
mgr.AddObject(iceImpact);
|
mgr.AddObject(iceImpact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue