diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 8e0fab78a..77cd05b1d 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -27,7 +27,7 @@ namespace urde void ViewManager::BuildTestPART(urde::IObjectStore& objStore) { - m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend"); +// m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend"); #if 0 SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.*")); SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend")); diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index d149eab13..d48dd4221 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -15,41 +15,41 @@ enum class EUserEventType { - Projectile, - EggLay, - LoopedSoundStop, - AlignTargetPos, - AlignTargetRot, - ChangeMaterial, - Delete, - GenerateEnd, - DamageOn, - DamageOff, - AlignTargetPosStart, - DeGenerate, - Landing, - TakeOff, - FadeIn, - FadeOut, - ScreenShake, - BeginAction, - EndAction, - BecomeRagDoll, - IkLock, - IkRelease, - BreakLockOn, - BecomeShootThrough, - RemoveCollision, - ObjectPickUp, - ObjectDrop, - EventStart, - EventStop, - Activate, - Deactivate, - SoundPlay, - SoundStop, - EffectOn, - EffectOff + Projectile = 0, + EggLay = 1, + LoopedSoundStop = 2, + AlignTargetPos = 3, + AlignTargetRot = 4, + ChangeMaterial = 5, + Delete = 6, + GenerateEnd = 7, + DamageOn = 8, + DamageOff = 9, + AlignTargetPosStart = 10, + DeGenerate = 11, + Landing = 12, + TakeOff = 13, + FadeIn = 14, + FadeOut = 15, + ScreenShake = 16, + BeginAction = 17, + EndAction = 18, + BecomeRagDoll = 19, + IkLock = 20, + IkRelease = 21, + BreakLockOn = 22, + BecomeShootThrough = 23, + RemoveCollision = 24, + ObjectPickUp = 25, + ObjectDrop = 26, + EventStart = 27, + EventStop = 28, + Activate = 29, + Deactivate = 30, + SoundPlay = 31, + SoundStop = 32, + EffectOn = 33, + EffectOff = 34 }; namespace urde diff --git a/Runtime/Graphics/CLight.hpp b/Runtime/Graphics/CLight.hpp index 9aaa4ac46..bc2b01db3 100644 --- a/Runtime/Graphics/CLight.hpp +++ b/Runtime/Graphics/CLight.hpp @@ -41,7 +41,7 @@ class CLight float x30_angleC; float x34_angleL; float x38_angleQ; - u32 x3c_ = 0; + u32 x3c_priority = 0; u32 x40_loadedIdx = 0; float x44_cachedRadius; float x48_cachedIntensity; diff --git a/Runtime/MP1/World/CActorContraption.cpp b/Runtime/MP1/World/CActorContraption.cpp index 3235480cb..f4c254070 100644 --- a/Runtime/MP1/World/CActorContraption.cpp +++ b/Runtime/MP1/World/CActorContraption.cpp @@ -1,5 +1,6 @@ #include "MP1/World/CActorContraption.hpp" #include "Weapon/CFlameThrower.hpp" +#include "Character/CInt32POINode.hpp" #include "GameGlobalObjects.hpp" #include "CSimplePool.hpp" #include "CStateManager.hpp" @@ -30,14 +31,38 @@ void MP1::CActorContraption::Think(float dt, CStateManager& mgr) { CScriptActor::Think(dt, mgr); - for (const std::pair& uid : x2ec_children) + for (const std::pair& uid : x2e4_children) { CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); if (act && act->GetActive()) - { act->SetTransform(x34_transform * act->GetScaledLocatorTransform(uid.second)); - } } } + +void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType evType) +{ + if (evType == EUserEventType::DamageOff) + { + for (const std::pair& uid : x2e4_children) + { + CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); + if (act && act->GetX400_25()) + act->Reset(mgr, false); + } + } + else if (evType == EUserEventType::DamageOn) + { + CFlameThrower* fl = CreateFlameThrower(node.GetLocatorName(), mgr); + if (fl && fl->GetX400_25()) + fl->Fire(GetTransform(), mgr, false); + } + else + CActor::DoUserAnimEvent(mgr, node, evType); +} + +CFlameThrower* MP1::CActorContraption::CreateFlameThrower(const std::string&, CStateManager&) +{ + return nullptr; +} } diff --git a/Runtime/MP1/World/CActorContraption.hpp b/Runtime/MP1/World/CActorContraption.hpp index f95012cc8..e68834dfb 100644 --- a/Runtime/MP1/World/CActorContraption.hpp +++ b/Runtime/MP1/World/CActorContraption.hpp @@ -6,12 +6,13 @@ namespace urde { +class CFlameThrower; namespace MP1 { class CActorContraption : public CScriptActor { /* AKA Why Zoid?!?!?!? */ - std::vector> x2ec_children; + std::vector> x2e4_children; TToken x300_flameThrowerGen; ResId x308_partId; CDamageInfo x30c_dInfo; @@ -23,6 +24,8 @@ public: void Accept(IVisitor &visitor); void Think(float, CStateManager &); + void DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType); + CFlameThrower* CreateFlameThrower(const std::string&, CStateManager&); }; } } diff --git a/Runtime/Weapon/CBeamProjectile.hpp b/Runtime/Weapon/CBeamProjectile.hpp index 06e56ef17..5ba39138e 100644 --- a/Runtime/Weapon/CBeamProjectile.hpp +++ b/Runtime/Weapon/CBeamProjectile.hpp @@ -10,7 +10,7 @@ public: CBeamProjectile(const TToken&, const std::string&, EWeaponType, const zeus::CTransform&, int, float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool); - virtual void Accept(IVisitor &visitor); + void Accept(IVisitor &visitor); float GetMaxRadius() const; zeus::CVector3f GetSurfaceNormal() const; void GetDamageType() const; diff --git a/Runtime/Weapon/CFlameThrower.cpp b/Runtime/Weapon/CFlameThrower.cpp index 310a400cc..682083929 100644 --- a/Runtime/Weapon/CFlameThrower.cpp +++ b/Runtime/Weapon/CFlameThrower.cpp @@ -23,4 +23,13 @@ CFlameThrower::CFlameThrower(const TToken& wDesc, const std: void CFlameThrower::Accept(IVisitor& visitor) { visitor.Visit(this); } void CFlameThrower::SetTransform(const zeus::CTransform& xf) { x2e8_ = xf; } + +void CFlameThrower::Reset(CStateManager&, bool) +{ +} + +void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool) +{ + +} } diff --git a/Runtime/Weapon/CFlameThrower.hpp b/Runtime/Weapon/CFlameThrower.hpp index 5afb4ead7..4978dc4c9 100644 --- a/Runtime/Weapon/CFlameThrower.hpp +++ b/Runtime/Weapon/CFlameThrower.hpp @@ -14,14 +14,25 @@ class CFlameThrower : public CGameProjectile zeus::CAABox x318_ = zeus::CAABox::skNullBox; TToken x33c_flameDesc; std::unique_ptr x348_flameGen; + + union + { + struct + { + bool x400_25 : 1; + }; + u32 _dummy = 0; + }; public: CFlameThrower(const TToken& wDesc, const std::string& name, EWeaponType wType, const CFlameInfo& flameInfo, const zeus::CTransform& xf, EMaterialTypes matType, const CDamageInfo& dInfo, TUniqueId owner, TAreaId aId, TUniqueId uid, u32 w1); void Accept(IVisitor &visitor); - void SetTransform(const zeus::CTransform& xf); + void Reset(CStateManager&, bool); + void Fire(const zeus::CTransform&, CStateManager&, bool); + bool GetX400_25() const { return x400_25; } }; } #endif // __URDE_CFLAMETHROWER_HPP__ diff --git a/Runtime/Weapon/CGameProjectile.cpp b/Runtime/Weapon/CGameProjectile.cpp index 6d3d6f0c0..6f924fc33 100644 --- a/Runtime/Weapon/CGameProjectile.cpp +++ b/Runtime/Weapon/CGameProjectile.cpp @@ -1,4 +1,7 @@ #include "Weapon/CGameProjectile.hpp" +#include "Graphics/CLight.hpp" +#include "World/CGameLight.hpp" +#include "CStateManager.hpp" #include "TCastTo.hpp" namespace urde @@ -16,6 +19,35 @@ CGameProjectile::CGameProjectile(bool active, const TToken&, { } +void CGameProjectile::Accept(urde::IVisitor& visitor) { visitor.Visit(this); } + +void CGameProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId /*uid*/, CStateManager& mgr) +{ + if (msg == EScriptObjectMessage::InternalMessage15) + { + if (!x2e4_27_) + { + x2e4_27_ = true; + x2e4_26_ = true; + } + } + else if (msg == EScriptObjectMessage::InternalMessage16) + { + if (!x2e4_26_) + x2e4_26_ = true; + } + else if (msg == EScriptObjectMessage::InternalMessage17) + { + if (x2e4_26_) + { + x2e4_26_ = false; + x2e4_27_ = false; + } + } + else if (msg == EScriptObjectMessage::Deleted) + DeleteProjectileLight(mgr); +} + CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType) { if (wType == EWeaponType::Ice) @@ -30,9 +62,25 @@ CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType) return EProjectileAttrib::None; } -void CGameProjectile::Accept(urde::IVisitor& visitor) +void CGameProjectile::DeleteProjectileLight(CStateManager& mgr) +{ + if (x2c8_projectileLight != kInvalidUniqueId) + { + mgr.FreeScriptObject(x2c8_projectileLight); + x2c8_projectileLight = kInvalidUniqueId; + } +} + +void CGameProjectile::CreateProjectileLight(const std::string& name, const CLight& light, CStateManager& mgr) +{ + DeleteProjectileLight(mgr); + x2c8_projectileLight = mgr.AllocateUniqueId(); + mgr.AddObject(new CGameLight(x2c8_projectileLight, GetAreaId(), GetActive(), name, GetTransform(), GetUniqueId(), + light, x2cc_, 0, 0.f)); +} + +void CGameProjectile::Chase(float dt, CStateManager& mgr) { - visitor.Visit(this); } } diff --git a/Runtime/Weapon/CGameProjectile.hpp b/Runtime/Weapon/CGameProjectile.hpp index 15d643476..061fb057b 100644 --- a/Runtime/Weapon/CGameProjectile.hpp +++ b/Runtime/Weapon/CGameProjectile.hpp @@ -7,6 +7,7 @@ #include "World/CDamageInfo.hpp" #include "RetroTypes.hpp" #include "CToken.hpp" +#include "Weapon/CProjectileWeapon.hpp" namespace urde { @@ -14,13 +15,31 @@ class CGenDescription; class CWeaponDescription; class CGameProjectile : public CWeapon { + //CProjectileWeapon x170_; + TUniqueId x2c8_projectileLight; + u32 x2cc_; + union + { + struct + { + bool x2e4_24_ : 1; + bool x2e4_25_ : 1; + bool x2e4_26_ : 1; + bool x2e4_27_ : 1; + bool x2e4_28_ : 1; + }; + }; public: CGameProjectile(bool, const TToken&, const std::string&, EWeaponType, const zeus::CTransform&, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool, const zeus::CVector3f&, const rstl::optional_object>&, s16, bool); virtual void Accept(IVisitor &visitor); + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); static EProjectileAttrib GetBeamAttribType(EWeaponType wType); + void DeleteProjectileLight(CStateManager&); + void CreateProjectileLight(const std::string&, const CLight&, CStateManager&); + void Chase(float, CStateManager&); }; } diff --git a/Runtime/Weapon/CProjectileWeapon.cpp b/Runtime/Weapon/CProjectileWeapon.cpp index e5d8ff630..ecfef7033 100644 --- a/Runtime/Weapon/CProjectileWeapon.cpp +++ b/Runtime/Weapon/CProjectileWeapon.cpp @@ -1,9 +1,15 @@ #include "CProjectileWeapon.hpp" +#include "Particle/CWeaponDescription.hpp" namespace urde { CRandom16 CProjectileWeapon::g_GlobalSeed = 99; +CProjectileWeapon::CProjectileWeapon(const TToken& wDesc, const zeus::CVector3f&, const zeus::CTransform&, + const zeus::CVector3f&, s32) +: x4_weaponDesc(wDesc) +{ +} } diff --git a/Runtime/Weapon/CProjectileWeapon.hpp b/Runtime/Weapon/CProjectileWeapon.hpp index 502cbfa34..e58a125fe 100644 --- a/Runtime/Weapon/CProjectileWeapon.hpp +++ b/Runtime/Weapon/CProjectileWeapon.hpp @@ -3,17 +3,71 @@ #include "RetroTypes.hpp" #include "CRandom16.hpp" +#include "CToken.hpp" +#include "zeus/CVector3f.hpp" +#include "Particle/CParticleSwoosh.hpp" +#include "Particle/CElementGen.hpp" namespace urde { - +class CModel; +class CWeaponDescription; class CProjectileWeapon { static CRandom16 g_GlobalSeed; + TLockedToken x4_weaponDesc; + CRandom16 x10_random; + zeus::CTransform x14_; + zeus::CTransform x44_; + zeus::CVector3f x74_ = zeus::CVector3f::skZero; + zeus::CVector3f x80_ = zeus::CVector3f::skZero; + zeus::CVector3f x8c_ = zeus::CVector3f::skZero; + zeus::CVector3f x98_ = zeus::CVector3f::skOne; + zeus::CVector3f xa4_ = zeus::CVector3f::skZero; + zeus::CVector3f xb0_ = zeus::CVector3f::skZero; + zeus::CVector3f xbc_ = zeus::CVector3f::skZero; + zeus::CColor xc8_ = zeus::CColor::skWhite; + double xd0_ = 0.0; + double xd8_ = 0.0; + float xe0_; + u32 xe4_; + u32 xe8_lifetime = 0x7FFFFF; + u32 xec_ = 0; + u32 xf0_ = 0; + u32 xf4_ = 0; + u32 xf8_ = 0; + u32 xfc_ = 0; + std::unique_ptr x104_particle1; + std::unique_ptr x104_particle2; + TToken x108_model; + bool x114_hasModel = false; + std::unique_ptr x118_swoosh1; + std::unique_ptr x11c_swoosh2; + std::unique_ptr x120_swoosh3; + union + { + struct + { + bool x124_24_ : 1; + bool x124_25_ : 1; + bool x124_26_ap11 : 1; + bool x124_27_ap21 : 1; + bool x124_28_as11 : 1; + bool x124_29_as12 : 1; + bool x124_30_as13 : 1; + }; + u32 _dummy = 0; + }; + public: + CProjectileWeapon(const TToken& wDesc, const zeus::CVector3f&, const zeus::CTransform&, + const zeus::CVector3f&, s32); + void GetTransform(); + void Update(float); + void UpdateParticleFx(); + void UpdateChildParticleSystems(float); static void SetGlobalSeed(u16 seed) { g_GlobalSeed.SetSeed(seed); } }; - } #endif // __URDE_CPROJECTILEWEAPON_HPP__ diff --git a/Runtime/Weapon/CWeapon.cpp b/Runtime/Weapon/CWeapon.cpp index 5618b61f3..d44f4890d 100644 --- a/Runtime/Weapon/CWeapon.cpp +++ b/Runtime/Weapon/CWeapon.cpp @@ -6,10 +6,11 @@ namespace urde { CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId, EWeaponType, const std::string& name, - const zeus::CTransform& xf, const CMaterialFilter&, const CMaterialList& mList, const CDamageInfo&, + const zeus::CTransform& xf, const CMaterialFilter& filter, const CMaterialList& mList, const CDamageInfo&, EProjectileAttrib, CModelData&& mData) : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList, CActorParameters::None(), kInvalidUniqueId) +, xf8_(filter) { } diff --git a/Runtime/Weapon/CWeapon.hpp b/Runtime/Weapon/CWeapon.hpp index 7577753b9..749b533b5 100644 --- a/Runtime/Weapon/CWeapon.hpp +++ b/Runtime/Weapon/CWeapon.hpp @@ -3,6 +3,7 @@ #include "World/CActor.hpp" #include "Weapon/WeaponCommon.hpp" +#include "World/CDamageInfo.hpp" #include "Collision/CMaterialFilter.hpp" namespace urde @@ -24,6 +25,17 @@ public: private: EProjectileAttrib xe8_projectileAttribs; + TUniqueId xec_uid; + EWeaponType xf0_weaponType; + u32 xf4_; + CMaterialFilter xf8_; + u32 x10c_; + CDamageInfo x110_; + CDamageInfo x12c_; + float x148_; + float x14c_; + float x150_; + float x154_; public: CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&, const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&); diff --git a/Runtime/World/CGameLight.cpp b/Runtime/World/CGameLight.cpp index 64be60810..992de0533 100644 --- a/Runtime/World/CGameLight.cpp +++ b/Runtime/World/CGameLight.cpp @@ -10,7 +10,7 @@ CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const std::strin TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1) : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId), - xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_lifeTime(f1) + xe8_parentId(parentId), xec_light(light), x13c_loadedIdx(w1), x140_priority(w2), x144_lifeTime(f1) { xec_light.GetRadius(); xec_light.GetIntensity(); @@ -34,8 +34,8 @@ void CGameLight::Think(float dt, CStateManager& mgr) void CGameLight::SetLightPriorityAndId() { - xec_light.x3c_ = x140_; - xec_light.x40_loadedIdx = x13c_; + xec_light.x3c_priority = x140_priority; + xec_light.x40_loadedIdx = x13c_loadedIdx; } void CGameLight::SetLight(const CLight& light) diff --git a/Runtime/World/CGameLight.hpp b/Runtime/World/CGameLight.hpp index 73552b0b9..4f0144d0f 100644 --- a/Runtime/World/CGameLight.hpp +++ b/Runtime/World/CGameLight.hpp @@ -9,8 +9,8 @@ class CGameLight : public CActor { TUniqueId xe8_parentId; CLight xec_light; - u32 x13c_; - u32 x140_; + u32 x13c_loadedIdx; + u32 x140_priority; float x144_lifeTime; public: