diff --git a/src/ZoneCode.lua b/src/ZoneCode.lua index 96258090..600ba751 100644 --- a/src/ZoneCode.lua +++ b/src/ZoneCode.lua @@ -29,7 +29,7 @@ ZoneCode.Assets = { "LocalizeEntry", -- "WeaponCompleteDef", -- "SndDriverGlobals", - -- "FxEffectDef", + "FxEffectDef", -- "FxImpactTable", "RawFile", "StringTable", diff --git a/src/ZoneCode/Game/IW4/IW4_Commands.txt b/src/ZoneCode/Game/IW4/IW4_Commands.txt index d74c8e32..62341e2f 100644 --- a/src/ZoneCode/Game/IW4/IW4_Commands.txt +++ b/src/ZoneCode/Game/IW4/IW4_Commands.txt @@ -29,7 +29,7 @@ asset menuDef_t ASSET_TYPE_MENU; asset LocalizeEntry ASSET_TYPE_LOCALIZE_ENTRY; // asset WeaponCompleteDef ASSET_TYPE_WEAPON; // asset SndDriverGlobals ASSET_TYPE_SNDDRIVER_GLOBALS; -// asset FxEffectDef ASSET_TYPE_FX; +asset FxEffectDef ASSET_TYPE_FX; // asset FxImpactTable ASSET_TYPE_IMPACT_FX; asset RawFile ASSET_TYPE_RAWFILE; asset StringTable ASSET_TYPE_STRINGTABLE; @@ -566,6 +566,56 @@ use StringList; set count strings totalStrings; set string strings; +// ========================================= +// FxEffectDef +// ========================================= +use FxEffectDef; +set string name; +set name name; +set count elemDefs elemDefCountEmission + elemDefCountLooping + elemDefCountOneShot; + +// FxElemDef +use FxElemDef; +set count velSamples velIntervalCount + 1; +set count visSamples visStateIntervalCount + 1; + +// FxElemDefVisuals +use FxElemDefVisuals; +set condition markArray FxElemDef::elemType == FX_ELEM_TYPE_DECAL; +set count markArray FxElemDef::visualCount; +set condition array FxElemDef::visualCount > 1; +set count array FxElemDef::visualCount; + +// FxElemVisuals +use FxElemVisuals; +set condition anonymous never; +set condition model FxElemDef::elemType == FX_ELEM_TYPE_MODEL; +set condition effectDef FxElemDef::elemType == FX_ELEM_TYPE_RUNNER; +set condition soundName FxElemDef::elemType == FX_ELEM_TYPE_SOUND; +set string soundName; +set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD +|| FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_ORIENTED +|| FxElemDef::elemType == FX_ELEM_TYPE_TAIL +|| FxElemDef::elemType == FX_ELEM_TYPE_TRAIL +|| FxElemDef::elemType == FX_ELEM_TYPE_CLOUD +|| FxElemDef::elemType == FX_ELEM_TYPE_SPARK_CLOUD +|| FxElemDef::elemType == FX_ELEM_TYPE_SPARK_FOUNTAIN; + +// FxEffectDefRef +use FxEffectDefRef; +set condition handle never; +set string name; + +// FxElemExtendedDefPtr +use FxElemExtendedDefPtr; +set condition trailDef FxElemDef::elemType == FX_ELEM_TYPE_TRAIL; +set condition sparkFountainDef FxElemDef::elemType == FX_ELEM_TYPE_SPARK_FOUNTAIN; + +// FxTrailDef +use FxTrailDef; +set count verts vertCount; +set count inds indCount; + // ========================================= // RawFile // ========================================= diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index 48df1f57..07dafd98 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -130,7 +130,7 @@ GameAssetPoolIW4::GameAssetPoolIW4(const int priority) m_localize = nullptr; // m_weapon = nullptr; // m_snd_driver_globals = nullptr; - // m_fx = nullptr; + m_fx = nullptr; // m_fx_impact_table = nullptr; m_raw_file = nullptr; m_string_table = nullptr; @@ -183,7 +183,7 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); // CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); // CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); - // CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); + CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); // CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); @@ -243,7 +243,7 @@ void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); - // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); + CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); // CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); @@ -312,7 +312,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::AddAsset(asset_type_t type, std::string nam CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); // CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); // CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals); - // CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); + CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); // CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); @@ -372,7 +372,7 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); // CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); // CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals); - // CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); + CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); // CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 0e7105cb..cd1119f8 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -42,7 +42,7 @@ public: std::unique_ptr> m_localize; // std::unique_ptr> m_weapon; // std::unique_ptr> m_snd_driver_globals; - // std::unique_ptr> m_fx; + std::unique_ptr> m_fx; // std::unique_ptr> m_fx_impact_table; std::unique_ptr> m_raw_file; std::unique_ptr> m_string_table; diff --git a/src/ZoneCommon/Game/IW4/IW4_Assets.h b/src/ZoneCommon/Game/IW4/IW4_Assets.h index 92ce233f..f8fc9289 100644 --- a/src/ZoneCommon/Game/IW4/IW4_Assets.h +++ b/src/ZoneCommon/Game/IW4/IW4_Assets.h @@ -101,11 +101,10 @@ namespace IW4 struct LocalizeEntry; // struct WeaponCompleteDef; // struct SndDriverGlobals; - // struct FxEffectDef; + struct FxEffectDef; // struct FxImpactTable; struct RawFile; struct StringTable; - // struct LeaderboardDef; // struct StructuredDataDefSet; // struct TracerDef; @@ -142,7 +141,7 @@ namespace IW4 LocalizeEntry* localize; // WeaponCompleteDef* weapon; // SndDriverGlobals* sndDriverGlobals; - // FxEffectDef* fx; + FxEffectDef* fx; // FxImpactTable* impactFx; RawFile* rawfile; StringTable* stringTable; @@ -1399,6 +1398,221 @@ namespace IW4 menuDef_t** menus; }; + enum FxElemType + { + FX_ELEM_TYPE_SPRITE_BILLBOARD = 0x0, + FX_ELEM_TYPE_SPRITE_ORIENTED = 0x1, + FX_ELEM_TYPE_TAIL = 0x2, + FX_ELEM_TYPE_TRAIL = 0x3, + FX_ELEM_TYPE_CLOUD = 0x4, + FX_ELEM_TYPE_SPARK_CLOUD = 0x5, + FX_ELEM_TYPE_SPARK_FOUNTAIN = 0x6, + FX_ELEM_TYPE_MODEL = 0x7, + FX_ELEM_TYPE_OMNI_LIGHT = 0x8, + FX_ELEM_TYPE_SPOT_LIGHT = 0x9, + FX_ELEM_TYPE_SOUND = 0xA, + FX_ELEM_TYPE_DECAL = 0xB, + FX_ELEM_TYPE_RUNNER = 0xC, + FX_ELEM_TYPE_COUNT = 0xD, + FX_ELEM_TYPE_LAST_SPRITE = 0x3, + FX_ELEM_TYPE_LAST_DRAWN = 0x9, + }; + + struct FxIntRange + { + int base; + int amplitude; + }; + + struct FxSpawnDefOneShot + { + FxIntRange count; + }; + + struct FxSpawnDefLooping + { + int intervalMsec; + int count; + }; + + union FxSpawnDef + { + FxSpawnDefLooping looping; + FxSpawnDefOneShot oneShot; + }; + + struct FxFloatRange + { + float base; + float amplitude; + }; + + struct FxElemAtlas + { + char behavior; + char index; + char fps; + char loopCount; + char colIndexBits; + char rowIndexBits; + __int16 entryCount; + }; + + struct FxElemVec3Range + { + float base[3]; + float amplitude[3]; + }; + + struct FxElemVelStateInFrame + { + FxElemVec3Range velocity; + FxElemVec3Range totalDelta; + }; + + struct FxElemVelStateSample + { + FxElemVelStateInFrame local; + FxElemVelStateInFrame world; + }; + + struct FxElemVisualState + { + char color[4]; + float rotationDelta; + float rotationTotal; + float size[2]; + float scale; + }; + + struct FxElemVisStateSample + { + FxElemVisualState base; + FxElemVisualState amplitude; + }; + + union FxEffectDefRef + { + FxEffectDef* handle; + const char* name; + }; + + union FxElemVisuals + { + const void* anonymous; + Material* material; + XModel* model; + FxEffectDefRef effectDef; + const char* soundName; + }; + + struct FxElemMarkVisuals + { + Material* materials[2]; + }; + + union FxElemDefVisuals + { + FxElemMarkVisuals* markArray; + FxElemVisuals* array; + FxElemVisuals instance; + }; + + struct FxTrailVertex + { + float pos[2]; + float normal[2]; + float texCoord; + }; + + struct FxTrailDef + { + int scrollTimeMsec; + int repeatDist; + float invSplitDist; + float invSplitArcDist; + float invSplitTime; + int vertCount; + FxTrailVertex* verts; + int indCount; + unsigned __int16* inds; + }; + + struct FxSparkFountainDef + { + float gravity; + float bounceFrac; + float bounceRand; + float sparkSpacing; + float sparkLength; + int sparkCount; + float loopTime; + float velMin; + float velMax; + float velConeFrac; + float restSpeed; + float boostTime; + float boostFactor; + }; + + union FxElemExtendedDefPtr + { + FxTrailDef* trailDef; + FxSparkFountainDef* sparkFountainDef; + char* unknownDef; + }; + + struct FxElemDef + { + int flags; + FxSpawnDef spawn; + FxFloatRange spawnRange; + FxFloatRange fadeInRange; + FxFloatRange fadeOutRange; + float spawnFrustumCullRadius; + FxIntRange spawnDelayMsec; + FxIntRange lifeSpanMsec; + FxFloatRange spawnOrigin[3]; + FxFloatRange spawnOffsetRadius; + FxFloatRange spawnOffsetHeight; + FxFloatRange spawnAngles[3]; + FxFloatRange angularVelocity[3]; + FxFloatRange initialRotation; + FxFloatRange gravity; + FxFloatRange reflectionFactor; + FxElemAtlas atlas; + char elemType; + char visualCount; + char velIntervalCount; + char visStateIntervalCount; + FxElemVelStateSample* velSamples; + FxElemVisStateSample* visSamples; + FxElemDefVisuals visuals; + Bounds collBounds; + FxEffectDefRef effectOnImpact; + FxEffectDefRef effectOnDeath; + FxEffectDefRef effectEmitted; + FxFloatRange emitDist; + FxFloatRange emitDistVariance; + FxElemExtendedDefPtr extended; + char sortOrder; + char lightingFrac; + char useItemClip; + char fadeInfo; + }; + + struct FxEffectDef + { + const char* name; + int flags; + int totalSize; + int msecLoopingLife; + int elemDefCountLooping; + int elemDefCountOneShot; + int elemDefCountEmission; + FxElemDef* elemDefs; + }; + #ifndef __zonecodegenerator } #endif diff --git a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp index fa797c32..71085e17 100644 --- a/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp +++ b/src/ZoneLoading/Game/IW4/ContentLoaderIW4.cpp @@ -8,7 +8,7 @@ //#include "Game/IW4/XAssets/clipmap_t/clipmap_t_load_db.h" //#include "Game/IW4/XAssets/comworld/comworld_load_db.h" //#include "Game/IW4/XAssets/font_s/font_s_load_db.h" -//#include "Game/IW4/XAssets/fxeffectdef/fxeffectdef_load_db.h" +#include "Game/IW4/XAssets/fxeffectdef/fxeffectdef_load_db.h" //#include "Game/IW4/XAssets/fximpacttable/fximpacttable_load_db.h" //#include "Game/IW4/XAssets/fxworld/fxworld_load_db.h" //#include "Game/IW4/XAssets/gameworldmp/gameworldmp_load_db.h" @@ -131,7 +131,7 @@ void ContentLoaderIW4::LoadXAsset(const bool atStreamStart) LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize); // LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon); SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals); - // LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx); + LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx); // LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx); LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile); LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable);