mirror of https://github.com/AxioDL/metaforce.git
CDamageInfo fixes, initial CPuffer
This commit is contained in:
parent
660e7cd239
commit
a7e81073ae
|
@ -1,4 +1,11 @@
|
|||
#include "CPuffer.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "CSimplePool.hpp"
|
||||
#include "World/CKnockBackController.hpp"
|
||||
#include "World/CPlayer.hpp"
|
||||
#include "World/CFire.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
|
@ -8,8 +15,144 @@ CPuffer::CPuffer(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
|||
float hoverSpeed, CAssetId cloudEffect, const CDamageInfo& cloudDamage, CAssetId cloudSteam, float f2,
|
||||
bool b1, bool b2, bool b3, const CDamageInfo& explosionDamage, s16 sfxId)
|
||||
: CPatterned(ECharacter::Puffer, uid, name, EFlavorType::Zero, info, xf, std::move(modelData), patternedInfo,
|
||||
EMovementType::Flyer, EColliderType::One, EBodyType::RestrictedFlyer, actorParameters, EKnockBackVariant::Small)
|
||||
EMovementType::Flyer, EColliderType::One, EBodyType::RestrictedFlyer, actorParameters,
|
||||
EKnockBackVariant::Small), x568_face(xf.frontVector()),
|
||||
x574_cloudEffect(g_SimplePool->GetObj({SBIG('PART'), cloudEffect})), x57c_cloudDamage(cloudDamage), x598_24_(b1),
|
||||
x598_25_(b3), x598_26_(b2), x59a_(CSfxManager::TranslateSFXID(sfxId)), x59c_explosionDamage(explosionDamage),
|
||||
x5b8_(f2), x5bc_cloudSteam(cloudSteam)
|
||||
{
|
||||
CreateShadow(false);
|
||||
x460_knockBackController.SetImpulseDurationIdx(1);
|
||||
x574_cloudEffect.Lock();
|
||||
}
|
||||
|
||||
void CPuffer::Accept(IVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(this);
|
||||
}
|
||||
|
||||
void CPuffer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||
{
|
||||
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case EScriptObjectMessage::Registered:
|
||||
x450_bodyController->Activate(mgr);
|
||||
SetMaterialFilter(
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player}, {EMaterialTypes::NoStaticCollision}));
|
||||
break;
|
||||
case EScriptObjectMessage::Action:
|
||||
if (GetActive())
|
||||
x401_30_pendingDeath = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPuffer::Think(float dt, CStateManager& mgr)
|
||||
{
|
||||
CPatterned::Think(dt, mgr);
|
||||
sub8025bfa4(mgr);
|
||||
zeus::CVector3f moveVector = x450_bodyController->GetCommandMgr().GetMoveVector();
|
||||
|
||||
if (x5cc_ != x2dc_destObj)
|
||||
{
|
||||
x5cc_ = x2dc_destObj;
|
||||
CSfxManager::AddEmitter(x59a_, GetTranslation(), {}, true, false, 127, -1);
|
||||
}
|
||||
|
||||
x450_bodyController->GetCommandMgr().ClearLocomotionCmds();
|
||||
if (moveVector.canBeNormalized())
|
||||
{
|
||||
zeus::CVector3f vec = x5c0_move * (1.f - (dt / 0.5f)) + (moveVector * (dt / 0.5f));
|
||||
x5c0_move = moveVector.normalized();
|
||||
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(x5c0_move, x568_face, 1.f));
|
||||
}
|
||||
}
|
||||
|
||||
std::experimental::optional<zeus::CAABox> CPuffer::GetTouchBounds() const
|
||||
{
|
||||
auto touchBounds = CPatterned::GetTouchBounds();
|
||||
if (touchBounds)
|
||||
{
|
||||
touchBounds->accumulateBounds(touchBounds->min - 0.5f);
|
||||
touchBounds->accumulateBounds(touchBounds->max + 0.5f);
|
||||
}
|
||||
|
||||
return touchBounds;
|
||||
}
|
||||
|
||||
void CPuffer::Touch(CActor& act, CStateManager& mgr)
|
||||
{
|
||||
CPatterned::Touch(act, mgr);
|
||||
|
||||
if (x400_25_alive && act.GetUniqueId() == mgr.GetPlayer().GetUniqueId())
|
||||
x401_30_pendingDeath = true;
|
||||
}
|
||||
|
||||
void CPuffer::Death(CStateManager& mgr, zeus::CVector3f& vec, EScriptObjectState state)
|
||||
{
|
||||
CPatterned::Death(mgr, vec, state);
|
||||
mgr.ApplyDamageToWorld(GetUniqueId(), *this, GetTranslation(), x59c_explosionDamage,
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}));
|
||||
zeus::CTransform xf = GetTransform() * zeus::CTransform::Scale(x57c_cloudDamage.GetRadius());
|
||||
zeus::CAABox aabox(-1.f, 1.f);
|
||||
mgr.AddObject(new CFire(x574_cloudEffect, mgr.AllocateUniqueId(), GetAreaIdAlways(), true, GetUniqueId(),
|
||||
GetTransform(), x57c_cloudDamage, aabox.getTransformedAABox(xf), {1.f, 1.f, 1.f}, true, x5bc_cloudSteam,
|
||||
x598_24_, x598_26_, x598_25_, 1.f, x5b8_, 1.f, 1.f));
|
||||
}
|
||||
|
||||
static const char* GasLocators[14] =
|
||||
{
|
||||
"Gas_01_LCTR",
|
||||
"Gas_02_LCTR",
|
||||
"Gas_03_LCTR",
|
||||
"Gas_04_LCTR",
|
||||
"Gas_05_LCTR",
|
||||
"Gas_06_LCTR",
|
||||
"Gas_07_LCTR",
|
||||
"Gas_08_LCTR",
|
||||
"Gas_09_LCTR",
|
||||
"Gas_10_LCTR",
|
||||
"Gas_11_LCTR",
|
||||
"Gas_12_LCTR",
|
||||
"Gas_13_LCTR",
|
||||
"Gas_14_LCTR",
|
||||
};
|
||||
|
||||
static const char* GesJetLocators[14] =
|
||||
{
|
||||
"GasJet01",
|
||||
"GasJet02",
|
||||
"GasJet03",
|
||||
"GasJet04",
|
||||
"GasJet05",
|
||||
"GasJet06",
|
||||
"GasJet07",
|
||||
"GasJet08",
|
||||
"GasJet09",
|
||||
"GasJet10",
|
||||
"GasJet11",
|
||||
"GasJet12",
|
||||
"GasJet13",
|
||||
"GasJet14",
|
||||
};
|
||||
|
||||
void CPuffer::sub8025bfa4(CStateManager& mgr)
|
||||
{
|
||||
zeus::CVector3f moveVector = x450_bodyController->GetCommandMgr().GetMoveVector();
|
||||
|
||||
if (x5d4_gasLocators.empty())
|
||||
{
|
||||
for (u32 i = 0 ; i < 14; ++i)
|
||||
x5d4_gasLocators.push_back(GetScaledLocatorTransform(GasLocators[i]).frontVector());
|
||||
}
|
||||
|
||||
if (moveVector.canBeNormalized())
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,34 @@ namespace urde::MP1
|
|||
{
|
||||
class CPuffer : public CPatterned
|
||||
{
|
||||
zeus::CVector3f x568_face;
|
||||
TToken<CGenDescription> x574_cloudEffect;
|
||||
CDamageInfo x57c_cloudDamage;
|
||||
bool x598_24_ : 1;
|
||||
bool x598_25_ : 1;
|
||||
bool x598_26_ : 1;
|
||||
s16 x59a_;
|
||||
CDamageInfo x59c_explosionDamage;
|
||||
float x5b8_;
|
||||
CAssetId x5bc_cloudSteam;
|
||||
zeus::CVector3f x5c0_move;
|
||||
TUniqueId x5cc_ = kInvalidUniqueId;
|
||||
s32 x5d0_ = 0;
|
||||
rstl::reserved_vector<zeus::CVector3f, 14> x5d4_gasLocators;
|
||||
|
||||
void sub8025bfa4(CStateManager&);
|
||||
public:
|
||||
DEFINE_PATTERNED(Puffer)
|
||||
|
||||
CPuffer(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
|
||||
const CActorParameters&, const CPatternedInfo&, float, CAssetId, const CDamageInfo&, CAssetId,
|
||||
float, bool, bool, bool, const CDamageInfo&, s16);
|
||||
|
||||
void Accept(IVisitor&);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
||||
void Think(float, CStateManager&);
|
||||
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
|
||||
void Touch(CActor&, CStateManager&);
|
||||
void Death(CStateManager&, zeus::CVector3f&, EScriptObjectState);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -243,6 +243,8 @@ public:
|
|||
bool IsIndirectTextured() const { return x28_loadedGenDesc->x54_x40_TEXR && x28_loadedGenDesc->x58_x44_TIND; }
|
||||
void SetModelsUseLights(bool v) { x26d_26_modelsUseLights = v; }
|
||||
static void SetMoveRedToAlphaBuffer(bool);
|
||||
|
||||
s32 GetMaxParticles() const { return x90_MAXP; }
|
||||
};
|
||||
ENABLE_BITWISE_ENUM(CElementGen::EOptionalSystemFlags)
|
||||
|
||||
|
|
|
@ -47,4 +47,14 @@ float CDamageInfo::GetRadiusDamage(const CDamageVulnerability& dVuln) const
|
|||
|
||||
return xc_radiusDamage;
|
||||
}
|
||||
|
||||
CDamageInfo::CDamageInfo(const CDamageInfo& other, float dt)
|
||||
{
|
||||
x0_weaponMode = other.x0_weaponMode;
|
||||
x8_damage = other.x8_damage * (60.f * dt);
|
||||
xc_radiusDamage = x8_damage;
|
||||
x10_radius = other.x10_radius;
|
||||
x14_knockback = other.x14_knockback;
|
||||
x18_noImmunity = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
}
|
||||
|
||||
CDamageInfo(const CDamageInfo& other) = default;
|
||||
CDamageInfo(const CDamageInfo&, float);
|
||||
CDamageInfo(const DataSpec::SShotParam& other);
|
||||
CDamageInfo& operator=(const DataSpec::SShotParam& other);
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
#include "CFire.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "CActorParameters.hpp"
|
||||
#include "CStateManager.hpp"
|
||||
#include "CPlayer.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
CFire::CFire(TToken<CGenDescription> effect, TUniqueId uid, TAreaId aId, bool active, TUniqueId owner,
|
||||
const zeus::CTransform& xf, const CDamageInfo& dInfo, const zeus::CAABox& aabox, const zeus::CVector3f& vec,
|
||||
bool b1, CAssetId visorEffect, bool b2, bool b3, bool b4, float f1, float f2, float f3, float f4)
|
||||
: CActor(uid, active, "Fire"sv, CEntityInfo(aId, NullConnectionList), xf, CModelData::CModelDataNull(),
|
||||
CMaterialList(EMaterialTypes::Projectile), CActorParameters::None(), owner)
|
||||
, xe8_(new CElementGen(effect))
|
||||
, xec_ownerId(owner)
|
||||
, xf0_damageInfo(dInfo)
|
||||
, x10c_damageInfo(dInfo)
|
||||
, x128_(aabox)
|
||||
, x144_(f1)
|
||||
, x148_24_(b2)
|
||||
, x148_25_(b3)
|
||||
, x148_26_(b4)
|
||||
, x148_27_(b4 && b3 && b2)
|
||||
, x148_28_(false)
|
||||
, x148_29_(b1)
|
||||
, x14c_(f2)
|
||||
, x150_(visorEffect)
|
||||
, x154_(f3)
|
||||
, x158_(f4)
|
||||
{
|
||||
xe8_->SetGlobalScale(vec);
|
||||
xe8_->SetTranslation(xf.origin);
|
||||
}
|
||||
|
||||
void CFire::Accept(IVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(this);
|
||||
}
|
||||
|
||||
void CFire::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
||||
{
|
||||
CActor::AcceptScriptMsg(msg, uid, mgr);
|
||||
|
||||
if (msg == EScriptObjectMessage::Registered)
|
||||
{
|
||||
xe8_->SetParticleEmission(true);
|
||||
SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CFire::Think(float dt, CStateManager& mgr)
|
||||
{
|
||||
float particleCount = xe8_->GetParticleCount() / xe8_->GetMaxParticles();
|
||||
if (GetActive())
|
||||
{
|
||||
xe8_->Update(dt * x144_);
|
||||
float f0;
|
||||
if (particleCount <= 0.5f)
|
||||
f0 = 0.5f;
|
||||
else
|
||||
f0 = particleCount;
|
||||
|
||||
x10c_damageInfo = CDamageInfo(xf0_damageInfo, dt * f0);
|
||||
}
|
||||
|
||||
bool doFree = false;
|
||||
if (xe8_->IsSystemDeletable())
|
||||
doFree = true;
|
||||
|
||||
if (x148_29_)
|
||||
{
|
||||
auto playerBounds = mgr.GetPlayer().GetTouchBounds();
|
||||
auto bounds = GetTouchBounds();
|
||||
if (playerBounds->intersects(*bounds) && doFree && particleCount > 0.5f)
|
||||
mgr.GetPlayer().SetVisorSteam(particleCount * x14c_, x154_, x158_, x150_, true);
|
||||
else
|
||||
mgr.GetPlayer().SetVisorSteam(0.f, 1.f, 1.f, {}, true);
|
||||
}
|
||||
|
||||
x15c_ += dt;
|
||||
|
||||
if (x15c_ > 45.f)
|
||||
doFree = true;
|
||||
|
||||
if (doFree)
|
||||
mgr.FreeScriptObject(GetUniqueId());
|
||||
}
|
||||
|
||||
void CFire::Touch(CActor& act, CStateManager& mgr)
|
||||
{
|
||||
if (act.GetUniqueId() == xec_ownerId)
|
||||
return;
|
||||
|
||||
mgr.ApplyDamage(GetUniqueId(), act.GetUniqueId(), GetUniqueId(), x10c_damageInfo,
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
||||
}
|
||||
|
||||
void CFire::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const
|
||||
{
|
||||
printf("AddToRenderer\n");
|
||||
bool r31 = true;
|
||||
if (!x148_27_)
|
||||
{
|
||||
using EPlayerVisor = CPlayerState::EPlayerVisor;
|
||||
CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
||||
if (visor == EPlayerVisor::Combat || visor == EPlayerVisor::Scan)
|
||||
r31 = x148_24_;
|
||||
else if (visor == EPlayerVisor::XRay)
|
||||
r31 = x148_26_;
|
||||
else if (visor == EPlayerVisor::Thermal)
|
||||
r31 = x148_25_;
|
||||
}
|
||||
|
||||
if (r31)
|
||||
g_Renderer->AddParticleGen(*xe8_);
|
||||
CActor::AddToRenderer(frustum, mgr);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include "CActor.hpp"
|
||||
#include "CDamageInfo.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CElementGen;
|
||||
class CFire : public CActor
|
||||
{
|
||||
std::unique_ptr<CElementGen> xe8_;
|
||||
TUniqueId xec_ownerId;
|
||||
CDamageInfo xf0_damageInfo;
|
||||
CDamageInfo x10c_damageInfo;
|
||||
std::experimental::optional<zeus::CAABox> x128_;
|
||||
float x144_;
|
||||
bool x148_24_ : 1;
|
||||
bool x148_25_ : 1;
|
||||
bool x148_26_ : 1;
|
||||
bool x148_27_ : 1;
|
||||
bool x148_28_ : 1;
|
||||
bool x148_29_ : 1;
|
||||
float x14c_;
|
||||
CAssetId x150_;
|
||||
float x154_;
|
||||
float x158_;
|
||||
float x15c_ = 0.f;
|
||||
public:
|
||||
CFire(TToken<CGenDescription>, TUniqueId, TAreaId, bool, TUniqueId, const zeus::CTransform&, const CDamageInfo&,
|
||||
const zeus::CAABox&, const zeus::CVector3f&, bool, CAssetId, bool, bool, bool, float, float, float, float);
|
||||
|
||||
void Accept(IVisitor&);
|
||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
||||
void Think(float, CStateManager&);
|
||||
std::experimental::optional<zeus::CAABox> GetTouchBounds() const
|
||||
{
|
||||
if (GetActive())
|
||||
return x128_;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void Touch(CActor&, CStateManager&);
|
||||
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
|
||||
};
|
||||
}
|
|
@ -283,7 +283,7 @@ void CPatterned::Think(float dt, CStateManager& mgr)
|
|||
mgr.GetActorModelParticles()->StartElectric(*this);
|
||||
if (x3f0_pendingShockDamage > 0.f && x400_25_alive)
|
||||
{
|
||||
CDamageInfo dInfo({EWeaponType::Wave}, x3f0_pendingShockDamage, 0.f, 0.f);
|
||||
CDamageInfo dInfo({{EWeaponType::Wave}, x3f0_pendingShockDamage, 0.f, 0.f}, dt);
|
||||
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ void CPatterned::Think(float dt, CStateManager& mgr)
|
|||
if (x400_25_alive)
|
||||
{
|
||||
mgr.GetActorModelParticles()->LightDudeOnFire(*this);
|
||||
CDamageInfo dInfo({EWeaponType::Plasma}, x3ec_pendingFireDamage, 0.f, 0.f);
|
||||
CDamageInfo dInfo({{EWeaponType::Plasma}, x3ec_pendingFireDamage, 0.f, 0.f}, dt);
|
||||
mgr.ApplyDamage(kInvalidUniqueId, GetUniqueId(), kInvalidUniqueId, dInfo,
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void CScriptTrigger::UpdateInhabitants(float dt, CStateManager& mgr)
|
|||
sendInside = true;
|
||||
InhabitantIdle(*act, mgr);
|
||||
if (act->HealthInfo(mgr) && x100_damageInfo.GetDamage() > 0.f)
|
||||
mgr.ApplyDamage(GetUniqueId(), act->GetUniqueId(), GetUniqueId(), x100_damageInfo,
|
||||
mgr.ApplyDamage(GetUniqueId(), act->GetUniqueId(), GetUniqueId(), {x100_damageInfo, dt},
|
||||
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}),
|
||||
zeus::CVector3f::skZero);
|
||||
|
||||
|
|
Loading…
Reference in New Issue