Complete C*Projectile construction chain, add CScriptBeam

This commit is contained in:
Phillip Stephens 2016-12-22 11:57:21 -08:00
parent 0fa395f9e1
commit 8460b3b565
24 changed files with 442 additions and 43 deletions

View File

@ -172,7 +172,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
x90c_loaderFuncs[int(EScriptObjectType::Seedling)] = ScriptLoader::LoadSeedling;
x90c_loaderFuncs[int(EScriptObjectType::ThermalHeatFader)] = ScriptLoader::LoadThermalHeatFader;
x90c_loaderFuncs[int(EScriptObjectType::Burrower)] = ScriptLoader::LoadBurrower;
x90c_loaderFuncs[int(EScriptObjectType::ScriptBeam)] = ScriptLoader::LoadScriptBeam;
x90c_loaderFuncs[int(EScriptObjectType::ScriptBeam)] = ScriptLoader::LoadBeam;
x90c_loaderFuncs[int(EScriptObjectType::WorldLightFader)] = ScriptLoader::LoadWorldLightFader;
x90c_loaderFuncs[int(EScriptObjectType::MetroidPrimeStage2)] = ScriptLoader::LoadMetroidPrimeStage2;
x90c_loaderFuncs[int(EScriptObjectType::MetroidPrimeStage1)] = ScriptLoader::LoadMetroidPrimeStage1;

View File

@ -23,11 +23,13 @@ enum class EMaterialTypes
Thirten = 13,
Fourteen = 14,
Fifteen = 15,
Eighteen = 18,
Nineteen = 19,
TwentyOne = 21,
ThirtyTwo = 32,
ThirtyThree = 33,
ThirtyFour = 34,
ThirtyFive = 35,
ThirtySeven = 37,
ThirtyEight = 38,
ThirtyNine = 39,

View File

View File

@ -0,0 +1,53 @@
#ifndef __URDE_CBEAMINFO_HPP__
#define __URDE_CBEAMINFO_HPP__
#include "RetroTypes.hpp"
#include "IOStreams.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
struct CBeamInfo
{
u32 x0_;
u32 x4_;
ResId x8_;
ResId xc_;
ResId x10_;
ResId x14_;
u32 x18_;
float x1c_;
float x20_;
float x24_;
float x28_;
float x2c_;
float x30_;
float x34_;
float x38_;
zeus::CColor x3c_;
zeus::CColor x40_;
CBeamInfo(CInputStream& in)
: x0_(in.readUint32Big())
, x4_(in.readUint32Big())
, x8_(in.readUint32Big())
, xc_(in.readUint32Big())
, x10_(in.readUint32Big())
, x14_(in.readUint32Big())
, x18_(in.readFloatBig())
, x1c_(in.readFloatBig())
, x20_(in.readFloatBig())
, x24_(in.readFloatBig())
, x28_(in.readFloatBig())
, x2c_(in.readFloatBig())
, x30_(in.readFloatBig())
, x34_(in.readFloatBig())
, x38_(in.readFloatBig())
, x3c_(zeus::CColor::ReadRGBABig(in))
, x40_(zeus::CColor::ReadRGBABig(in))
{
}
};
}
#endif // __URDE_CBEAMINFO_HPP__

View File

@ -0,0 +1,38 @@
#include "Weapon/CBeamProjectile.hpp"
namespace urde
{
CBeamProjectile::CBeamProjectile(const TToken<CWeaponDescription>& wDesc, const std::string& name, EWeaponType wType,
const zeus::CTransform& xf, int attribs, float f1, float f2, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, u32 w1, bool b1)
: CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, owner, aid, uid, kInvalidUniqueId, w1, false,
zeus::CVector3f::skOne, {}, -1, false)
{
}
void CBeamProjectile::Think(float, CStateManager &)
{
}
rstl::optional_object<zeus::CAABox> CBeamProjectile::GetTouchBounds() const
{
return {};
}
void CBeamProjectile::Touch(CActor &, CStateManager &)
{
}
void CBeamProjectile::ResetBeam(CStateManager &, bool)
{
}
void CBeamProjectile::UpdateFX(const zeus::CTransform &, float, CStateManager &)
{
}
}

View File

@ -0,0 +1,33 @@
#ifndef __URDE_CBEAMPROJECTILE_HPP__
#define __URDE_CBEAMPROJECTILE_HPP__
#include "Weapon/CGameProjectile.hpp"
namespace urde
{
class CBeamProjectile : public CGameProjectile
{
public:
CBeamProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, int,
float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool);
float GetMaxRadius() const;
zeus::CVector3f GetSurfaceNormal() const;
void GetDamageType() const;
void GetCurrentPos() const;
void PointCache();
void GetPointCache() const;
void CauseDamage(bool);
zeus::CVector3f GetBeamOrigin() const;
void GetInvMaxLength() const;
void GetCurrentLength();
void GetMaxLength();
s32 GetIntMaxLength();
void Think(float, CStateManager&);
rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void Touch(CActor&, CStateManager&);
virtual void ResetBeam(CStateManager&, bool);
virtual void UpdateFX(const zeus::CTransform&, float, CStateManager&);
};
}
#endif // __URDE_CBEAMPROJECTILE_HPP__

View File

@ -0,0 +1,32 @@
#include "Weapon/CGameProjectile.hpp"
namespace urde
{
CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&, const std::string& name,
EWeaponType wType, const zeus::CTransform& xf, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid, TUniqueId uid, TUniqueId,
u32 w1, bool b2, const zeus::CVector3f&,
const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool b3)
: CWeapon(owner, aid, uid, active, wType, name, xf,
CMaterialFilter(
CMaterialList(EMaterialTypes::Fifty, matType),
CMaterialList(EMaterialTypes::ThirtyFive, EMaterialTypes::Eighteen, matType, EMaterialTypes::Nineteen),
CMaterialFilter::EFilterType::Three),
CMaterialList(), dInfo, EProjectileAttrib(w1) | GetBeamAttribType(wType), CModelData::CModelDataNull())
{
}
CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType)
{
if (wType == EWeaponType::Ice)
return EProjectileAttrib::Ice;
else if (wType == EWeaponType::Wave)
return EProjectileAttrib::Wave;
else if (wType == EWeaponType::Plasma)
return EProjectileAttrib::Plasma;
else if (wType == EWeaponType::Phazon)
return EProjectileAttrib::Phazon;
return EProjectileAttrib::None;
}
}

View File

@ -0,0 +1,26 @@
#ifndef __URDE_CGAMEPROJECTILE_HPP__
#define __URDE_CGAMEPROJECTILE_HPP__
#include "Collision/CMaterialList.hpp"
#include "Weapon/CWeaponMode.hpp"
#include "Weapon/CWeapon.hpp"
#include "World/CDamageInfo.hpp"
#include "RetroTypes.hpp"
#include "CToken.hpp"
namespace urde
{
class CGenDescription;
class CWeaponDescription;
class CGameProjectile : public CWeapon
{
public:
CGameProjectile(bool, const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&,
EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool,
const zeus::CVector3f&, const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool);
static EProjectileAttrib GetBeamAttribType(EWeaponType wType);
};
}
#endif // __URDE_CGAMEPROJECTILE_HPP__

View File

@ -1,4 +1,5 @@
set(WEAPON_SOURCES
WeaponCommon.hpp
CWeaponMgr.hpp CWeaponMgr.cpp
CGunController.hpp CGunController.cpp
CGunMotion.hpp CGunMotion.cpp
@ -15,6 +16,11 @@ set(WEAPON_SOURCES
CGSFreeLook.hpp CGSFreeLook.cpp
CGSComboFire.hpp CGSComboFire.cpp
CGSFidget.hpp CGSFidget.cpp
CFidget.hpp CFidget.cpp)
CFidget.hpp CFidget.cpp
CWeapon.hpp CWeapon.cpp
CGameProjectile.hpp CGameProjectile.cpp
CBeamProjectile.hpp CBeamProjectile.cpp
CBeamInfo.hpp CBeamInfo.cpp
CPlasmaProjectile.hpp CPlasmaProjectile.cpp)
runtime_add_list(Weapon WEAPON_SOURCES)

View File

@ -0,0 +1,13 @@
#include "CPlasmaProjectile.hpp"
namespace urde
{
CPlasmaProjectile::CPlasmaProjectile(const TToken<CWeaponDescription>& wDesc, const std::string& name,
EWeaponType wType, const CBeamInfo& bInfo, const zeus::CTransform& xf,
EMaterialTypes matType, const CDamageInfo& dInfo, TUniqueId owner, TAreaId aid,
TUniqueId uid, u32 w1, bool b1, u32 w2)
: CBeamProjectile(wDesc, name, wType, xf, bInfo.x18_, bInfo.x1c_, bInfo.x38_, matType, dInfo, owner, aid, uid, w2, b1)
{
}
}

View File

@ -0,0 +1,19 @@
#ifndef __URDE_CPLASMAPROJECTILE_HPP__
#define __URDE_CPLASMAPROJECTILE_HPP__
#include "Weapon/CBeamProjectile.hpp"
#include "Weapon/CBeamInfo.hpp"
#include "World/CDamageInfo.hpp"
namespace urde
{
class CPlasmaProjectile : public CBeamProjectile
{
public:
CPlasmaProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const CBeamInfo&,
const zeus::CTransform&, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32,
bool, u32);
};
}
#endif // __URDE_CPLASMAPROJECTILE_HPP__

View File

@ -0,0 +1,14 @@
#include "CWeapon.hpp"
#include "World/CActorParameters.hpp"
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&,
EProjectileAttrib, CModelData&& mData)
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList,
CActorParameters::None(), kInvalidUniqueId)
{
}
}

View File

@ -0,0 +1,49 @@
#ifndef __URDE_CWEAPON_HPP__
#define __URDE_CWEAPON_HPP__
#include "World/CActor.hpp"
#include "Weapon/WeaponCommon.hpp"
#include "Collision/CMaterialFilter.hpp"
namespace urde
{
class CWeapon : public CActor
{
public:
enum class EProjectileAttrib
{
None = 0,
Ice = (1 << 3),
Wave = (1 << 4),
Plasma = (1 << 5),
Phazon = (1 << 6)
};
private:
public:
CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&,
const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&);
bool HasAttrib(EProjectileAttrib) const;
EProjectileAttrib GetAttribField() const;
const CMaterialFilter& GetFilter() const;
void SetFilter(const CMaterialFilter&);
TUniqueId GetOwnerId() const;
void SetOwnerId(TUniqueId);
EWeaponType GetType() const;
const CDamageInfo& GetDamageInfo() const;
CDamageInfo& DamageInfo();
void SetDamageInfo(const CDamageInfo&);
void Think(float, CStateManager &) {}
void Render(const CStateManager&) const {}
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, CWeaponMode&,
int)
{
return EWeaponCollisionResponseTypes::Default;
}
void FluidFXThink(EFluidState, CScriptWater&, CStateManager&) {}
};
ENABLE_BITWISE_ENUM(CWeapon::EProjectileAttrib)
}
#endif // __URDE_CWEAPON_HPP__

View File

@ -2,30 +2,11 @@
#define __URDE_CWEAPONMGR_HPP__
#include "RetroTypes.hpp"
#include "WeaponCommon.hpp"
namespace urde
{
enum class EWeaponType
{
None = -1,
Power = 0,
Ice,
Wave,
Plasma,
Bomb,
PowerBomb,
Missile,
BoostBall,
Phazon,
AI,
PoisonWater,
Lava,
Hot,
Unused1,
Unused2
};
class CWeaponMgr
{
std::map<TUniqueId, rstl::reserved_vector<s32, 10>> x0_weapons;

View File

@ -7,6 +7,11 @@ CWeaponMode::CWeaponMode(EWeaponType type, bool, bool)
{
}
EWeaponType CWeaponMode::GetType() const
{
return x0_weaponType;
}
CWeaponMode CWeaponMode::Invalid()
{
return CWeaponMode(EWeaponType::None, false, false);

View File

@ -1,13 +1,13 @@
#ifndef __URDE_CWEAPONMODE_HPP__
#define __URDE_CWEAPONMODE_HPP__
#include "CWeaponMgr.hpp"
#include "WeaponCommon.hpp"
namespace urde
{
class CWeaponMode
{
EWeaponType x0_weaponType;
EWeaponType x0_weaponType = EWeaponType::None;
union
{
struct
@ -19,7 +19,8 @@ class CWeaponMode
u8 dummy = 0;
};
public:
CWeaponMode(EWeaponType, bool, bool);
CWeaponMode() = default;
CWeaponMode(EWeaponType, bool = false, bool = false);
EWeaponType GetType() const;

View File

@ -0,0 +1,29 @@
#ifndef __URDE_WEAPONCOMMON_HPP__
#define __URDE_WEAPONCOMMON_HPP__
#include "RetroTypes.hpp"
namespace urde
{
enum class EWeaponType
{
None = -1,
Power = 0,
Ice,
Wave,
Plasma,
Bomb,
PowerBomb,
Missile,
BoostBall,
Phazon,
AI,
PoisonWater,
Lava,
Hot,
Unused1,
Unused2
};
}
#endif // __URDE_WEAPONCOMMON_HPP__

View File

@ -3,6 +3,7 @@
#include "RetroTypes.hpp"
#include "Weapon/CWeaponMgr.hpp"
#include "Weapon/CWeaponMode.hpp"
namespace urde
{
@ -10,17 +11,7 @@ namespace urde
class CDamageVulnerability;
class CDamageInfo
{
EWeaponType x0_type = EWeaponType::None;
union
{
struct
{
bool x4_24_ : 1;
bool x4_25_ : 1;
bool x4_26_ : 1;
};
u8 _dummy = 0;
};
CWeaponMode x0_weaponMode;
float x8_damage;
float xc_radiusDamage;
float x10_radius;
@ -31,13 +22,21 @@ public:
CDamageInfo(CInputStream& in)
{
in.readUint32Big();
x0_type = EWeaponType(in.readUint32Big());
x0_weaponMode = CWeaponMode(EWeaponType(in.readUint32Big()));
x8_damage = in.readFloatBig();
xc_radiusDamage = x8_damage;
x10_radius = in.readFloatBig();
x14_knockback = in.readFloatBig();
}
CDamageInfo(const CWeaponMode&, float damage, float radius, float knockback);
CDamageInfo(const CDamageInfo& other) = default;
const CWeaponMode& GetWeaponMode() const { return x0_weaponMode; }
float GetRadius() const { return x10_radius; }
void SetRadius(float r) { x10_radius = r; }
float GetKnockBackPower() const { return x14_knockback; }
float GetDamage() const { return x8_damage; }
void GetDamage(const CDamageVulnerability& dVuln);
float GetRadiusDamage() const { return xc_radiusDamage; }
float GetRadiusDamage(const CDamageVulnerability& dVuln);
};

View File

@ -69,6 +69,7 @@ set(WORLD_SOURCES
CRepulsor.hpp CRepulsor.cpp
CScriptCameraPitchVolume.hpp CScriptCameraPitchVolume.cpp
CScriptCameraHintTrigger.hpp CScriptCameraHintTrigger.cpp
CScriptBeam.hpp CScriptBeam.cpp
CGrappleParameters.hpp
CActorParameters.hpp
CLightParameters.hpp

View File

@ -0,0 +1,57 @@
#include "CScriptBeam.hpp"
#include "CActorParameters.hpp"
#include "Particle/CWeaponDescription.hpp"
#include "Weapon/CPlasmaProjectile.hpp"
#include "CStateManager.hpp"
namespace urde
{
CScriptBeam::CScriptBeam(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
bool active, const TToken<CWeaponDescription>& weaponDesc, const CBeamInfo& bInfo,
const CDamageInfo& dInfo)
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(),
kInvalidUniqueId)
, xe8_weaponDescription(weaponDesc)
, xf4_beamInfo(bInfo)
, x138_damageInfo(dInfo)
{
}
void CScriptBeam::Think(float dt, CStateManager& mgr)
{
#if 0
CPlasmaProjectile* proj = static_cast<CPlasmaProjectile*>(mgr.GetObjectById(x154_projectileId));
if (proj)
{
if (proj->GetActive())
proj->UpdateFx(x34_transform, dt, mgr);
}
else
x154_projectileId = kInvalidUniqueId;
#endif
}
void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::Increment)
{
}
else if (msg == EScriptObjectMessage::Decrement)
{
}
else if (msg == EScriptObjectMessage::InternalMessage11)
{
x154_projectileId = mgr.AllocateUniqueId();
mgr.AddObject(new CPlasmaProjectile(xe8_weaponDescription, x10_name + "-Projectile",
x138_damageInfo.GetWeaponMode().GetType(), xf4_beamInfo, x34_transform,
EMaterialTypes::ThirtyFive, x138_damageInfo, x8_uid, x4_areaId,
x154_projectileId, 8, false, 2));
}
else if (msg == EScriptObjectMessage::InternalMessage12)
{
}
CActor::AcceptScriptMsg(msg, objId, mgr);
}
}

View File

@ -0,0 +1,25 @@
#ifndef __URDE_CSCRIPTBEAM_HPP__
#define __URDE_CSCRIPTBEAM_HPP__
#include "CActor.hpp"
#include "Weapon/CBeamInfo.hpp"
#include "CDamageInfo.hpp"
namespace urde
{
class CWeaponDescription;
class CScriptBeam : public CActor
{
TCachedToken<CWeaponDescription> xe8_weaponDescription;
CBeamInfo xf4_beamInfo;
CDamageInfo x138_damageInfo;
TUniqueId x154_projectileId;
public:
CScriptBeam(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, bool,
const TToken<CWeaponDescription>&, const CBeamInfo&, const CDamageInfo&);
void Think(float, CStateManager &);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
};
}
#endif // __URDE_CSCRIPTBEAM_HPP__

View File

@ -17,7 +17,7 @@ public:
};
private:
//TReservedAverage<float, 8> x2e0_;
TReservedAverage<float, 8> x2e0_;
public:
CScriptDebris(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, ResId, const zeus::CVector3f&, float, const zeus::CVector3f&,

View File

@ -11,6 +11,7 @@
#include "CWorld.hpp"
#include "Character/CModelData.hpp"
#include "Collision/CMaterialList.hpp"
#include "Particle/CWeaponDescription.hpp"
#include "CDamageInfo.hpp"
#include "CScriptActor.hpp"
#include "CScriptWaypoint.hpp"
@ -52,6 +53,7 @@
#include "CRepulsor.hpp"
#include "CScriptCameraPitchVolume.hpp"
#include "CScriptCameraHintTrigger.hpp"
#include "CScriptBeam.hpp"
#include "Camera/CCinematicCamera.hpp"
#include "MP1/CNewIntroBoss.hpp"
#include "MP1/CBeetle.hpp"
@ -748,8 +750,8 @@ CEntity* ScriptLoader::LoadCamera(CStateManager& mgr, CInputStream& in, int prop
if (propCount > 14)
b10 = in.readBool();
u32 flags = u32(b2) | u32(b3) << 1 | u32(b4) << 2 | u32(b5) << 3 | u32(b6) << 4 |
u32(b7) << 5 | u32(b8) << 6 | u32(b9) << 8;
u32 flags = u32(b2) | u32(b3) << 1 | u32(b4) << 2 | u32(b5) << 3 | u32(b6) << 4 | u32(b7) << 5 | u32(b8) << 6 |
u32(b9) << 8;
return new CCinematicCamera(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, b1, f1,
f2 / CCameraManager::Aspect(), CCameraManager::NearPlane(), CCameraManager::FarPlane(),
@ -1993,9 +1995,23 @@ CEntity* ScriptLoader::LoadBurrower(CStateManager& mgr, CInputStream& in, int pr
return nullptr;
}
CEntity* ScriptLoader::LoadScriptBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
CEntity* ScriptLoader::LoadBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)
{
return nullptr;
if (!EnsurePropertyCount(propCount, 7, "Beam"))
return nullptr;
SActorHead aHead = LoadActorHead(in, mgr);
bool active = in.readBool();
u32 weaponDescId = in.readUint32Big();
if (!g_ResFactory->GetResourceTypeById(weaponDescId))
return nullptr;
CBeamInfo beamInfo(in);
CDamageInfo dInfo(in);
TToken<CWeaponDescription> weaponDesc = g_SimplePool->GetObj({SBIG('WPSC'), weaponDescId});
return new CScriptBeam(mgr.AllocateUniqueId(), aHead.x0_name, info, aHead.x10_transform, active,
weaponDesc, beamInfo, dInfo);
}
CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)

View File

@ -152,7 +152,7 @@ public:
static CEntity* LoadSeedling(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadThermalHeatFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadBurrower(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadScriptBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadBeam(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadWorldLightFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadMetroidPrimeStage2(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);
static CEntity* LoadMetroidPrimeStage1(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info);