Add T6 Attachment dumper

This commit is contained in:
Jan 2021-03-07 15:25:58 +01:00
parent b891f9527e
commit 5db7eaeec3
10 changed files with 344 additions and 45 deletions

View File

@ -1,5 +1,78 @@
#pragma once #pragma once
namespace T6
{
inline const char* szAttachmentTypeNames[]
{
"none",
"acog",
"dualclip",
"dualoptic",
"dw",
"extbarrel",
"extclip",
"extramags",
"fastads",
"fastreload",
"fmj",
"gl",
"grip",
"holo",
"ir",
"is",
"longbreath",
"mk",
"mms",
"rangefinder",
"reflex",
"rf",
"sf",
"silencer",
"stackfire",
"stalker",
"steadyaim",
"swayreduc",
"tacknife",
"vzoom"
};
inline const char* szWeapFireTypeNames[]
{
"Full Auto",
"Single Shot",
"2-Round Burst",
"3-Round Burst",
"4-Round Burst",
"5-Round Burst",
"Stacked Fire",
"Minigun",
"Charge Shot",
"Jetgun"
};
inline const char* penetrateTypeNames[]
{
"none",
"small",
"medium",
"large"
};
inline const char* s_constraintTypeNames[]
{
"none",
"point",
"distance",
"hinge",
"joint",
"actuator",
"fake_shake",
"launch",
"rope",
"light",
};
}
class CommonT6 class CommonT6
{ {
public: public:

View File

@ -119,8 +119,32 @@ namespace T6
enum constraintsFieldType_t enum constraintsFieldType_t
{ {
CFT_TYPE = 0x12, CFT_TYPE = CSPFT_NUM_BASE_FIELD_TYPES,
CFT_NUM CFT_NUM_FIELD_TYPES
}; };
enum attachmentFieldType_t
{
AFT_ATTACHMENTTYPE = CSPFT_NUM_BASE_FIELD_TYPES,
AFT_UNKNOWN1,
AFT_UNKNOWN2,
AFT_UNKNOWN3,
AFT_UNKNOWN4,
AFT_PENETRATE_TYPE,
AFT_FIRETYPE,
AFT_NUM
};
enum attachmentUniqueFieldType_t
{
AUFT_ATTACHMENTTYPE = CSPFT_NUM_BASE_FIELD_TYPES,
AUFT_HIDETAGS,
AUFT_OVERLAYRETICLE,
AUFT_CAMO,
AUFT_NUM_FIELD_TYPES,
};
} }

View File

@ -1719,6 +1719,13 @@ namespace T6
int customBool2; int customBool2;
}; };
struct WeaponAttachmentUniqueFull
{
WeaponAttachmentUnique attachment;
const char* szXAnims[88];
uint16_t hideTags[32];
float locationDamageMultipliers[21];
};
struct WeaponCamo struct WeaponCamo
{ {

View File

@ -3,6 +3,8 @@
#include <cassert> #include <cassert>
#include <type_traits> #include <type_traits>
#include "Game/T6/CommonT6.h"
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
using namespace T6; using namespace T6;
@ -89,20 +91,6 @@ cspField_t AssetDumperPhysConstraints::phys_constraints_fields[]
namespace T6 namespace T6
{ {
const char* s_constraintTypeNames[]
{
"none",
"point",
"distance",
"hinge",
"joint",
"actuator",
"fake_shake",
"launch",
"rope",
"light",
};
class InfoStringFromPhysConstraintsConverter final : public InfoStringFromStructConverter class InfoStringFromPhysConstraintsConverter final : public InfoStringFromStructConverter
{ {
protected: protected:
@ -114,7 +102,6 @@ namespace T6
FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, std::extent<decltype(s_constraintTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, s_constraintTypeNames, std::extent<decltype(s_constraintTypeNames)>::value);
break; break;
case CFT_NUM:
default: default:
assert(false); assert(false);
break; break;

View File

@ -5,6 +5,7 @@
#include <type_traits> #include <type_traits>
#include <cstring> #include <cstring>
#include "Game/T6/CommonT6.h"
#include "Game/T6/InfoStringT6.h" #include "Game/T6/InfoStringT6.h"
using namespace T6; using namespace T6;
@ -1088,20 +1089,6 @@ namespace T6
"dwlefthand" "dwlefthand"
}; };
const char* szWeapFireTypeNames[]
{
"Full Auto",
"Single Shot",
"2-Round Burst",
"3-Round Burst",
"4-Round Burst",
"5-Round Burst",
"Stacked Fire",
"Minigun",
"Charge Shot",
"Jetgun"
};
const char* szWeapClipTypeNames[] const char* szWeapClipTypeNames[]
{ {
"bottom", "bottom",
@ -1122,14 +1109,6 @@ namespace T6
"Quad Barrel Double Alternate" "Quad Barrel Double Alternate"
}; };
const char* penetrateTypeNames[]
{
"none",
"small",
"medium",
"large"
};
const char* impactTypeNames[] const char* impactTypeNames[]
{ {
"none", "none",
@ -1625,11 +1604,11 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo<WeaponVariantDef>* asset) InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo<WeaponVariantDef>* asset)
{ {
auto* fullDef = new WeaponFullDef; const auto fullDef = std::make_unique<WeaponFullDef>();
memset(fullDef, 0, sizeof(WeaponFullDef)); memset(fullDef.get(), 0, sizeof(WeaponFullDef));
CopyToFullDef(asset->Asset(), fullDef); CopyToFullDef(asset->Asset(), fullDef.get());
InfoStringFromWeaponConverter converter(fullDef, weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string InfoStringFromWeaponConverter converter(fullDef.get(), weapon_fields, std::extent<decltype(weapon_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.size()); assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size()) if (scrStr >= asset->m_zone->m_script_strings.size())

View File

@ -0,0 +1,175 @@
#include "AssetDumperWeaponAttachment.h"
#include <cassert>
#include <sstream>
#include <type_traits>
#include <cstring>
#include "Game/T6/CommonT6.h"
#include "Game/T6/InfoStringT6.h"
using namespace T6;
cspField_t AssetDumperWeaponAttachment::attachment_fields[]
{
{"displayName", offsetof(WeaponAttachment, szDisplayName), CSPFT_STRING},
{"attachmentType", offsetof(WeaponAttachment, attachmentType), AFT_ATTACHMENTTYPE},
{"penetrateType", offsetof(WeaponAttachment, penetrateType), AFT_PENETRATE_TYPE},
{"firstRaisePriority", offsetof(WeaponAttachment, firstRaisePriority), CSPFT_INT},
{"hipIdleAmount", offsetof(WeaponAttachment, fHipIdleAmount), CSPFT_FLOAT},
{"fireType", offsetof(WeaponAttachment, fireType), AFT_FIRETYPE},
{"damageRangeScale", offsetof(WeaponAttachment, fDamageRangeScale), CSPFT_FLOAT},
{"adsZoomFov1", offsetof(WeaponAttachment, fAdsZoomFov1), CSPFT_FLOAT},
{"adsZoomFov2", offsetof(WeaponAttachment, fAdsZoomFov2), CSPFT_FLOAT},
{"adsZoomFov3", offsetof(WeaponAttachment, fAdsZoomFov3), CSPFT_FLOAT},
{"adsZoomInFrac", offsetof(WeaponAttachment, fAdsZoomInFrac), CSPFT_FLOAT},
{"adsZoomOutFrac", offsetof(WeaponAttachment, fAdsZoomOutFrac), CSPFT_FLOAT},
{"adsTransInTimeScale", offsetof(WeaponAttachment, fAdsTransInTimeScale), CSPFT_FLOAT},
{"adsTransOutTimeScale", offsetof(WeaponAttachment, fAdsTransOutTimeScale), CSPFT_FLOAT},
{"adsRecoilReductionRate", offsetof(WeaponAttachment, fAdsRecoilReductionRate), CSPFT_FLOAT},
{"adsRecoilReductionLimit", offsetof(WeaponAttachment, fAdsRecoilReductionLimit), CSPFT_FLOAT},
{"adsViewKickCenterSpeedScale", offsetof(WeaponAttachment, fAdsViewKickCenterSpeedScale), CSPFT_FLOAT},
{"adsIdleAmountScale", offsetof(WeaponAttachment, fAdsIdleAmountScale), CSPFT_FLOAT},
{"swayOverride", offsetof(WeaponAttachment, swayOverride), CSPFT_BOOL},
{"swayMaxAngle", offsetof(WeaponAttachment, swayMaxAngle), CSPFT_FLOAT},
{"swayLerpSpeed", offsetof(WeaponAttachment, swayLerpSpeed), CSPFT_FLOAT},
{"swayPitchScale", offsetof(WeaponAttachment, swayPitchScale), CSPFT_FLOAT},
{"swayYawScale", offsetof(WeaponAttachment, swayYawScale), CSPFT_FLOAT},
{"swayHorizScale", offsetof(WeaponAttachment, swayHorizScale), CSPFT_FLOAT},
{"swayVertScale", offsetof(WeaponAttachment, swayVertScale), CSPFT_FLOAT},
{"adsSwayOverride", offsetof(WeaponAttachment, adsSwayOverride), CSPFT_BOOL},
{"adsSwayMaxAngle", offsetof(WeaponAttachment, adsSwayMaxAngle), CSPFT_FLOAT},
{"adsSwayLerpSpeed", offsetof(WeaponAttachment, adsSwayLerpSpeed), CSPFT_FLOAT},
{"adsSwayPitchScale", offsetof(WeaponAttachment, adsSwayPitchScale), CSPFT_FLOAT},
{"adsSwayYawScale", offsetof(WeaponAttachment, adsSwayYawScale), CSPFT_FLOAT},
{"adsSwayHorizScale", offsetof(WeaponAttachment, fAdsSwayHorizScale), CSPFT_FLOAT},
{"adsSwayVertScale", offsetof(WeaponAttachment, fAdsSwayVertScale), CSPFT_FLOAT},
{"adsMoveSpeedScale", offsetof(WeaponAttachment, adsMoveSpeedScale), CSPFT_FLOAT},
{"hipSpreadMinScale", offsetof(WeaponAttachment, fHipSpreadMinScale), CSPFT_FLOAT},
{"hipSpreadMaxScale", offsetof(WeaponAttachment, fHipSpreadMaxScale), CSPFT_FLOAT},
{"strafeRotR", offsetof(WeaponAttachment, strafeRotR), CSPFT_FLOAT},
{"standMoveF", offsetof(WeaponAttachment, standMoveF), CSPFT_FLOAT},
{"standRotP", offsetof(WeaponAttachment, vStandRot.x), CSPFT_FLOAT},
{"standRotY", offsetof(WeaponAttachment, vStandRot.y), CSPFT_FLOAT},
{"standRotR", offsetof(WeaponAttachment, vStandRot.z), CSPFT_FLOAT},
{"fireTimeScale", offsetof(WeaponAttachment, fFireTimeScale), CSPFT_FLOAT},
{"reloadTimeScale", offsetof(WeaponAttachment, fReloadTimeScale), CSPFT_FLOAT},
{"reloadEmptyTimeScale", offsetof(WeaponAttachment, fReloadEmptyTimeScale), CSPFT_FLOAT},
{"reloadAddTimeScale", offsetof(WeaponAttachment, fReloadAddTimeScale), CSPFT_FLOAT},
{"reloadQuickTimeScale", offsetof(WeaponAttachment, fReloadQuickTimeScale), CSPFT_FLOAT},
{"reloadQuickEmptyTimeScale", offsetof(WeaponAttachment, fReloadQuickEmptyTimeScale), CSPFT_FLOAT},
{"reloadQuickAddTimeScale", offsetof(WeaponAttachment, fReloadQuickAddTimeScale), CSPFT_FLOAT},
{"perks1", offsetof(WeaponAttachment, perks[0]), CSPFT_UINT},
{"perks0", offsetof(WeaponAttachment, perks[1]), CSPFT_UINT},
{"altWeaponAdsOnly", offsetof(WeaponAttachment, bAltWeaponAdsOnly), CSPFT_BOOL},
{"altWeaponDisableSwitching", offsetof(WeaponAttachment, bAltWeaponDisableSwitching), CSPFT_BOOL},
{"altScopeADSTransInTime", offsetof(WeaponAttachment, altScopeADSTransInTime), CSPFT_FLOAT},
{"altScopeADSTransOutTime", offsetof(WeaponAttachment, altScopeADSTransOutTime), CSPFT_FLOAT},
{"silenced", offsetof(WeaponAttachment, bSilenced), CSPFT_BOOL},
{"dualMag", offsetof(WeaponAttachment, bDualMag), CSPFT_BOOL},
{"laserSight", offsetof(WeaponAttachment, laserSight), CSPFT_BOOL},
{"infrared", offsetof(WeaponAttachment, bInfraRed), CSPFT_BOOL},
{"useAsMelee", offsetof(WeaponAttachment, bUseAsMelee), CSPFT_BOOL},
{"dualWield", offsetof(WeaponAttachment, bDualWield), CSPFT_BOOL},
{"sharedAmmo", offsetof(WeaponAttachment, sharedAmmo), CSPFT_BOOL},
{"mmsWeapon", offsetof(WeaponAttachment, mmsWeapon), CSPFT_BOOL},
{"mmsInScope", offsetof(WeaponAttachment, mmsInScope), CSPFT_BOOL},
{"mmsFOV", offsetof(WeaponAttachment, mmsFOV), CSPFT_FLOAT},
{"mmsAspect", offsetof(WeaponAttachment, mmsAspect), CSPFT_FLOAT},
{"mmsMaxDist", offsetof(WeaponAttachment, mmsMaxDist), CSPFT_FLOAT},
{"clipSizeScale", offsetof(WeaponAttachment, clipSizeScale), CSPFT_FLOAT},
{"clipSize", offsetof(WeaponAttachment, iClipSize), CSPFT_INT},
{"stackFire", offsetof(WeaponAttachment, stackFire), CSPFT_FLOAT},
{"stackFireSpread", offsetof(WeaponAttachment, stackFireSpread), CSPFT_FLOAT},
{"stackFireAccuracyDecay", offsetof(WeaponAttachment, stackFireAccuracyDecay), CSPFT_FLOAT},
{"customFloat0", offsetof(WeaponAttachment, customFloat0), CSPFT_FLOAT},
{"customFloat1", offsetof(WeaponAttachment, customFloat1), CSPFT_FLOAT},
{"customFloat2", offsetof(WeaponAttachment, customFloat2), CSPFT_FLOAT},
{"customBool0", offsetof(WeaponAttachment, customBool0), CSPFT_BOOL},
{"customBool1", offsetof(WeaponAttachment, customBool1), CSPFT_BOOL},
{"customBool2", offsetof(WeaponAttachment, customBool2), CSPFT_BOOL},
};
namespace T6
{
class InfoStringFromAttachmentConverter final : public InfoStringFromStructConverter
{
protected:
void FillFromExtensionField(const cspField_t& field) override
{
switch (static_cast<attachmentFieldType_t>(field.iFieldType))
{
case AFT_ATTACHMENTTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szAttachmentTypeNames, std::extent<decltype(szAttachmentTypeNames)>::value);
break;
case AFT_PENETRATE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value);
break;
case AFT_FIRETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent<decltype(szWeapFireTypeNames)>::value);
break;
default:
break;
}
}
public:
InfoStringFromAttachmentConverter(const WeaponAttachment* structure, const cspField_t* fields, const size_t fieldCount, std::function<std::string(scr_string_t)> scriptStringValueCallback)
: InfoStringFromStructConverter(structure, fields, fieldCount, std::move(scriptStringValueCallback))
{
}
};
}
InfoString AssetDumperWeaponAttachment::CreateInfoString(XAssetInfo<WeaponAttachment>* asset)
{
InfoStringFromAttachmentConverter converter(asset->Asset(), attachment_fields, std::extent<decltype(attachment_fields)>::value, [asset](const scr_string_t scrStr) -> std::string
{
assert(scrStr < asset->m_zone->m_script_strings.size());
if (scrStr >= asset->m_zone->m_script_strings.size())
return "";
return asset->m_zone->m_script_strings[scrStr];
});
return converter.Convert();
}
bool AssetDumperWeaponAttachment::ShouldDump(XAssetInfo<WeaponAttachment>* asset)
{
return true;
}
bool AssetDumperWeaponAttachment::CanDumpAsRaw()
{
return true;
}
bool AssetDumperWeaponAttachment::CanDumpAsGdtEntry()
{
return true;
}
std::string AssetDumperWeaponAttachment::GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponAttachment>* asset)
{
return "attachment/" + asset->m_name;
}
GdtEntry AssetDumperWeaponAttachment::DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponAttachment>* asset)
{
const auto infoString = CreateInfoString(asset);
GdtEntry gdtEntry(asset->m_name, GDF_NAME);
infoString.ToGdtProperties(FILE_TYPE_STR, gdtEntry);
return gdtEntry;
}
void AssetDumperWeaponAttachment::DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponAttachment>* asset, std::ostream& stream)
{
const auto infoString = CreateInfoString(asset);
const auto stringValue = infoString.ToString(FILE_TYPE_STR);
stream.write(stringValue.c_str(), stringValue.size());
}

View File

@ -0,0 +1,26 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T6/T6.h"
#include "Utils/InfoString.h"
namespace T6
{
class AssetDumperWeaponAttachment final : public AbstractAssetDumper<WeaponAttachment>
{
static constexpr const char* FILE_TYPE_STR = "ATTACHMENTFILE";
static constexpr const char* GDF_NAME = "attachment.gdf";
static cspField_t attachment_fields[];
static InfoString CreateInfoString(XAssetInfo<WeaponAttachment>* asset);
protected:
bool ShouldDump(XAssetInfo<WeaponAttachment>* asset) override;
bool CanDumpAsRaw() override;
bool CanDumpAsGdtEntry() override;
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponAttachment>* asset) override;
GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponAttachment>* asset) override;
void DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponAttachment>* asset, std::ostream& stream) override;
};
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "Dumping/AbstractAssetDumper.h"
#include "Game/T6/T6.h"
#include "Utils/InfoString.h"
namespace T6
{
class AssetDumperWeaponAttachmentUnique final : public AbstractAssetDumper<WeaponAttachmentUnique>
{
static constexpr const char* FILE_TYPE_STR = "ATTACHMENTUNIQUEFILE";
static constexpr const char* GDF_NAME = "attachmentunique.gdf";
static cspField_t attachment_unique_fields[];
static void CopyToFullDef(const WeaponAttachmentUnique* weapon, WeaponAttachmentUniqueFull* fullDef);
static InfoString CreateInfoString(XAssetInfo<WeaponAttachmentUnique>* asset);
protected:
bool ShouldDump(XAssetInfo<WeaponAttachmentUnique>* asset) override;
bool CanDumpAsRaw() override;
bool CanDumpAsGdtEntry() override;
std::string GetFileNameForAsset(Zone* zone, XAssetInfo<WeaponAttachmentUnique>* asset) override;
GdtEntry DumpGdtEntry(AssetDumpingContext& context, XAssetInfo<WeaponAttachmentUnique>* asset) override;
void DumpRaw(AssetDumpingContext& context, XAssetInfo<WeaponAttachmentUnique>* asset, std::ostream& stream) override;
};
}

View File

@ -16,6 +16,7 @@
#include "AssetDumpers/AssetDumperTracer.h" #include "AssetDumpers/AssetDumperTracer.h"
#include "AssetDumpers/AssetDumperVehicle.h" #include "AssetDumpers/AssetDumperVehicle.h"
#include "AssetDumpers/AssetDumperWeapon.h" #include "AssetDumpers/AssetDumperWeapon.h"
#include "AssetDumpers/AssetDumperWeaponAttachment.h"
#include "AssetDumpers/AssetDumperZBarrier.h" #include "AssetDumpers/AssetDumperZBarrier.h"
using namespace T6; using namespace T6;
@ -59,7 +60,7 @@ bool ZoneDumper::DumpZone(AssetDumpingContext& context) const
// DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def); // DUMP_ASSET_POOL(AssetDumperMenuDef, m_menu_def);
DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize); DUMP_ASSET_POOL(AssetDumperLocalizeEntry, m_localize);
DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon); DUMP_ASSET_POOL(AssetDumperWeapon, m_weapon);
// DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment); DUMP_ASSET_POOL(AssetDumperWeaponAttachment, m_attachment);
// DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique); // DUMP_ASSET_POOL(AssetDumperWeaponAttachmentUnique, m_attachment_unique);
// DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo); // DUMP_ASSET_POOL(AssetDumperWeaponCamo, m_camo);
// DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals); // DUMP_ASSET_POOL(AssetDumperSndDriverGlobals, m_snd_driver_globals);