chore: dump iw5 weapon sound overrides

This commit is contained in:
Jan 2024-04-07 14:08:06 +02:00
parent 8554939c91
commit ea0cb66eae
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
4 changed files with 78 additions and 4 deletions

View File

@ -117,6 +117,7 @@ namespace IW5
WFT_ANIM_NAME, WFT_ANIM_NAME,
WFT_ATTACHMENT, WFT_ATTACHMENT,
WFT_ANIM_OVERRIDES, WFT_ANIM_OVERRIDES,
WFT_SOUND_OVERRIDES,
WFT_NUM_FIELD_TYPES, WFT_NUM_FIELD_TYPES,
}; };

View File

@ -3923,13 +3923,24 @@ namespace IW5
int altTime; int altTime;
}; };
enum SoundOverrideTypes : unsigned int
{
SNDTYPE_NONE = 0x0,
SNDTYPE_FIRE = 0x1,
SNDTYPE_PLAYER_FIRE = 0x2,
SNDTYPE_PLAYER_AKIMBO = 0x3,
SNDTYPE_PLAYER_LASTSHOT = 0x4,
SNDTYPE_PLAYER_COUNT
};
struct SoundOverrideEntry struct SoundOverrideEntry
{ {
unsigned short attachment1; WeaponAttachmentCombination attachment1;
unsigned short attachment2; WeaponAttachmentCombination attachment2;
SndAliasCustom overrideSound; SndAliasCustom overrideSound;
SndAliasCustom altmodeSound; SndAliasCustom altmodeSound;
unsigned int soundType; SoundOverrideTypes soundType;
}; };
struct FXOverrideEntry struct FXOverrideEntry

View File

@ -4,7 +4,6 @@
namespace IW5 namespace IW5
{ {
// WeaponCompleteDef: // WeaponCompleteDef:
// TODO: soundOverrides
// TODO: fxOverrides // TODO: fxOverrides
// TODO: reloadOverrides // TODO: reloadOverrides
// TODO: notetrackOverrides // TODO: notetrackOverrides
@ -734,6 +733,7 @@ namespace IW5
{"missileConeSoundCrossfadeBottomSize", offsetof(WeaponFullDef, weapDef.missileConeSoundCrossfadeBottomSize), CSPFT_FLOAT }, {"missileConeSoundCrossfadeBottomSize", offsetof(WeaponFullDef, weapDef.missileConeSoundCrossfadeBottomSize), CSPFT_FLOAT },
{"attachments", offsetof(WeaponFullDef, scopes), WFT_ATTACHMENT }, {"attachments", offsetof(WeaponFullDef, scopes), WFT_ATTACHMENT },
{"animOverrides", offsetof(WeaponFullDef, weapCompleteDef.animOverrides), WFT_ANIM_OVERRIDES }, {"animOverrides", offsetof(WeaponFullDef, weapCompleteDef.animOverrides), WFT_ANIM_OVERRIDES },
{"soundOverrides", offsetof(WeaponFullDef, weapCompleteDef.soundOverrides), WFT_SOUND_OVERRIDES },
}; };
inline const char* szWeapTypeNames[]{ inline const char* szWeapTypeNames[]{
@ -925,4 +925,13 @@ namespace IW5
"ads_down", "alt_adjust", "ads_down", "alt_adjust",
}; };
static_assert(std::extent_v<decltype(weapAnimFilesNames)> == WEAP_ANIM_COUNT); static_assert(std::extent_v<decltype(weapAnimFilesNames)> == WEAP_ANIM_COUNT);
inline const char* soundOverrideTypeNames[]{
"none",
"fire",
"player_fire",
"player_akimbo",
"player_lastshot",
};
static_assert(std::extent_v<decltype(soundOverrideTypeNames)> == SNDTYPE_PLAYER_COUNT);
} // namespace IW5 } // namespace IW5

View File

@ -221,6 +221,10 @@ namespace IW5
FillFromAnimOverrides(std::string(field.szName)); FillFromAnimOverrides(std::string(field.szName));
break; break;
case WFT_SOUND_OVERRIDES:
FillFromSoundOverrides(std::string(field.szName));
break;
case WFT_NUM_FIELD_TYPES: case WFT_NUM_FIELD_TYPES:
default: default:
assert(false); assert(false);
@ -357,6 +361,55 @@ namespace IW5
m_info_string.SetValueForKey(key, ss.str()); m_info_string.SetValueForKey(key, ss.str());
} }
void FillFromSoundOverrides(const std::string& key)
{
std::stringstream ss;
bool first = true;
for (auto i = 0u; i < m_weapon->weapCompleteDef.numSoundOverrides; i++)
{
const auto& soundOverride = m_weapon->weapCompleteDef.soundOverrides[i];
if (!first)
ss << "\n";
else
first = false;
assert(soundOverride.soundType < SNDTYPE_PLAYER_COUNT);
if (soundOverride.attachment1.fields)
ss << GetNameForSingleWeaponAttachment(soundOverride.attachment1);
else
ss << "none";
ss << ' ';
if (soundOverride.attachment2.fields)
ss << GetNameForSingleWeaponAttachment(soundOverride.attachment2);
else
ss << "none";
ss << ' ';
if (soundOverride.soundType < SNDTYPE_PLAYER_COUNT)
ss << soundOverrideTypeNames[soundOverride.soundType] << ' ';
if (soundOverride.overrideSound.name && soundOverride.overrideSound.name->soundName && soundOverride.overrideSound.name->soundName[0])
ss << soundOverride.overrideSound.name->soundName;
else
ss << "none";
ss << ' ';
if (soundOverride.altmodeSound.name && soundOverride.altmodeSound.name->soundName && soundOverride.altmodeSound.name->soundName[0])
ss << soundOverride.altmodeSound.name->soundName;
else
ss << "none";
}
m_info_string.SetValueForKey(key, ss.str());
}
const WeaponFullDef* m_weapon; const WeaponFullDef* m_weapon;
}; };
} // namespace IW5 } // namespace IW5