2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Weapon/CPowerBomb.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CPlayerState.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
2018-09-10 01:04:57 +00:00
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
|
2018-09-10 01:04:57 +00:00
|
|
|
#include "DataSpec/DNAMP1/SFX/Weapons.h"
|
2019-12-22 20:04:07 +00:00
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2020-03-12 14:12:28 +00:00
|
|
|
#include <zeus/CColor.hpp>
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2020-03-12 14:12:28 +00:00
|
|
|
namespace urde {
|
|
|
|
constexpr zeus::CColor kFadeColor(COLOR(0xffffff7));
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CPowerBomb::CPowerBomb(const TToken<CGenDescription>& particle, TUniqueId uid, TAreaId aid, TUniqueId playerId,
|
|
|
|
const zeus::CTransform& xf, const CDamageInfo& dInfo)
|
|
|
|
: CWeapon(
|
|
|
|
uid, aid, true, playerId, EWeaponType::PowerBomb, "PowerBomb", xf,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid, EMaterialTypes::Immovable, EMaterialTypes::Trigger},
|
|
|
|
{EMaterialTypes::Projectile, EMaterialTypes::PowerBomb}),
|
|
|
|
{EMaterialTypes::Projectile, EMaterialTypes::PowerBomb}, dInfo, EProjectileAttrib::PowerBombs,
|
|
|
|
CModelData::CModelDataNull())
|
2018-09-10 01:04:57 +00:00
|
|
|
, x158_24_canStartFilter(true)
|
|
|
|
, x158_25_filterEnabled(false)
|
|
|
|
, x164_radiusIncrement(dInfo.GetRadius() / 2.5f)
|
2019-09-12 03:50:38 +00:00
|
|
|
, x168_particle(std::make_unique<CElementGen>(particle))
|
2018-12-08 05:30:43 +00:00
|
|
|
, x16c_radius(dInfo.GetRadius()) {
|
|
|
|
x168_particle->SetGlobalTranslation(GetTranslation());
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
if (msg == EScriptObjectMessage::Registered) {
|
|
|
|
mgr.AddWeaponId(xec_ownerId, xf0_weaponType);
|
|
|
|
if (mgr.GetPlayerState()->IsPlayerAlive()) {
|
|
|
|
CSfxManager::AddEmitter(SFXsfx0710, GetTranslation(), {}, true, false, 0x7f, -1);
|
|
|
|
mgr.InformListeners(GetTranslation(), EListenNoiseType::BombExplode);
|
|
|
|
} else {
|
|
|
|
auto handle = CSfxManager::AddEmitter(SFXsfx073F, GetTranslation(), {}, true, false, 0x7f, -1);
|
|
|
|
mgr.Player()->ApplySubmergedPitchBend(handle);
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Deleted) {
|
|
|
|
if (x15c_curTime > 0.7f)
|
|
|
|
mgr.GetCameraFilterPass(6).DisableFilter(0.f);
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.RemoveWeaponId(xec_ownerId, xf0_weaponType);
|
|
|
|
}
|
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::Think(float dt, CStateManager& mgr) {
|
|
|
|
CWeapon::Think(dt, mgr);
|
|
|
|
if (x158_24_canStartFilter) {
|
|
|
|
if (x15c_curTime > 1.f && !x158_25_filterEnabled) {
|
|
|
|
mgr.GetCameraFilterPass(6).SetFilter(EFilterType::Add, EFilterShape::Fullscreen, 1.5f, kFadeColor, -1);
|
|
|
|
x158_25_filterEnabled = true;
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 2.5f)
|
|
|
|
x158_24_canStartFilter = false;
|
|
|
|
} else if (x15c_curTime > 3.75 && x158_25_filterEnabled) {
|
|
|
|
mgr.GetCameraFilterPass(6).DisableFilter(.5f);
|
|
|
|
x158_25_filterEnabled = false;
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 7.f) {
|
|
|
|
if (x168_particle->IsSystemDeletable())
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 30.f) {
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
return;
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x15c_curTime > 1.f && x15c_curTime < 4.f) {
|
|
|
|
x110_origDamageInfo.SetRadius(x160_curRadius);
|
|
|
|
ApplyDynamicDamage(GetTranslation(), mgr);
|
|
|
|
x160_curRadius += x164_radiusIncrement;
|
|
|
|
}
|
2018-09-10 01:04:57 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x168_particle->Update(dt);
|
|
|
|
x15c_curTime += dt;
|
2018-09-10 01:04:57 +00:00
|
|
|
}
|
|
|
|
|
2020-04-05 11:54:02 +00:00
|
|
|
void CPowerBomb::AddToRenderer(const zeus::CFrustum&, CStateManager&) {
|
2018-12-08 05:30:43 +00:00
|
|
|
g_Renderer->AddParticleGen(*x168_particle);
|
2017-08-27 03:02:18 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CPowerBomb::ApplyDynamicDamage(const zeus::CVector3f& pos, urde::CStateManager& mgr) {
|
|
|
|
mgr.ApplyDamageToWorld(xec_ownerId, *this, pos, x12c_curDamageInfo, xf8_filter);
|
2017-08-27 03:02:18 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
} // namespace urde
|