Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ out
# Match session restore file
/game/neo/scripts/match_session_restore_point.txt

# Reload phases copied from neoAssets
/game/neo/scripts/weapon_*_reload_phases.txt

# Shader state debug image dumps
/game/neo/*.tga

Expand Down
83 changes: 83 additions & 0 deletions game/neo/scripts/game_sounds_weapons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"wave" "weapons/milso/milso_reload.wav"
}

// MilSO reload in per-step pieces (sv_neo_reload_experimental): only the load step has a sound; the slide release
// (3_cycle) is silent in the shipped wav. NEO TODO (sunzenshen): placeholder wav from the research branch.
"weapon_milso.reload_2_load"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"CompatibilityAttenuation" "1.0"
"pitch" "PITCH_NORM"
"wave" "weapons/milso/milso_reload_2_load.wav"
}

//------------------

"weapon_milso.npc_reload"
Expand Down Expand Up @@ -586,6 +598,47 @@
"wave" "weapons/m41/m41_reload.wav"
}

// M41 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 and _3 are a step's second and
// third sounds (seat rattle, tap, slap). The ZR68 entries above use ")" in front of the wave; these do not, as
// weapon_m41.reload does not. NEO TODO (sunzenshen): the wavs are placeholders from the research branch; re-cut from
// m41_reload.wav as the ZR68 pieces were (zr68c-sound-align.md).

"weapon_m41.reload_2_load"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" "weapons/m41/m41_reload_2_load.wav"
}

"weapon_m41.reload_2_load_2"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" "weapons/m41/m41_reload_2_load_2.wav"
}

"weapon_m41.reload_2_load_3"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" "weapons/m41/m41_reload_2_load_3.wav"
}

"weapon_m41.reload_3_cycle"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" "weapons/m41/m41_reload_3_cycle.wav"
}

//-------------------

"weapon_m41.npc_reload"
Expand Down Expand Up @@ -759,6 +812,36 @@
"wave" "weapons/zr68/zr68_reload.wav"
}

// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named after the step; _2 is a step's second sound.
// Each file starts just before its first transient

"weapon_zr68.reload_2_load"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" ")weapons/zr68/zr68_reload_2_load.wav"
}

"weapon_zr68.reload_2_load_2"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" ")weapons/zr68/zr68_reload_2_load_2.wav"
}

"weapon_zr68.reload_3_cycle"
{
"channel" "CHAN_ITEM"
"soundlevel" "SNDLVL_NORM"
"volume" "1.0"
"pitch" "PITCH_NORM"
"wave" ")weapons/zr68/zr68_reload_3_cycle.wav"
}

//-------------------

"weapon_zr68.npc_reload"
Expand Down
9 changes: 9 additions & 0 deletions game/neo/scripts/weapon_m41.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#base "weapon_mosok41_reload_phases.txt"
// NEO TODO (sunzenshen): M41 (one reload, no 30+1 rule): decide the fire point (clip end or ReloadReadyBeforeEnd) and whether the resume keeps
// the _empty name; resume after 2_load and the 3 sounds in 2_load are not done; see the plan's Open TODO list.

// M41

WeaponData
Expand All @@ -16,6 +20,11 @@ WeaponData
"Penetration" "32.0"
"CycleTime" "0.166666" // time between shots
"ReloadReadyBeforeEnd" "0.393" // the reload is done at the last reload click, this long before its animation ends

// Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers
// NEO TODO (sunzenshen): with the flag on, the magazine loads at the 2_load ammo time, not at the end minus
// ReloadReadyBeforeEnd above (user decision U1); decide whether the M41's fire point moves with it (U2).
"ReloadPhases" {}

"TPMuzzleFlashScale" "0.5"

Expand Down
12 changes: 11 additions & 1 deletion game/neo/scripts/weapon_milso.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#base "weapon_milso_reload_phases.txt"
// NEO TODO (sunzenshen): MilSO: resume after 2_load (dry slide release) needs a resume that keeps the clip; tactical resume must keep the
// chambered round; ReloadReadyBeforeEnd 0.467 s vs the new fire point; see the plan's Open TODO list.

// Milso
WeaponData
{
Expand All @@ -14,7 +18,13 @@ WeaponData
"Penetration" "12.0"
"CycleTime" "0.212121"
"ReloadReadyBeforeEnd" "0.467" // the reload is done at the last reload click, this long before its animation ends


// Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers.
// The pistol ships two reloads (reload, reloadempty); the phases file has a table for each and a resume for each.
// NEO TODO (sunzenshen): the same U1/U2 question as the M41: with the flag on, the magazine loads at the 2_load ammo
// time, not at the end minus ReloadReadyBeforeEnd above.
"ReloadPhases" {}

"TPMuzzleFlashScale" "0.5"

"clip_size" "12"
Expand Down
5 changes: 5 additions & 0 deletions game/neo/scripts/weapon_zr68c.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#base "weapon_zr68c_reload_phases.txt"

// ZR68S

WeaponData
Expand All @@ -16,6 +18,9 @@ WeaponData
"Penetration" "28.0"
"CycleTime" "0.090909" // time between shots
"ReloadReadyBeforeEnd" "0.483" // the reload is done at the last reload click, this long before its animation ends

// Reload phases (sv_neo_reload_experimental): the rows come from neoAssets, timed from its Blender markers
"ReloadPhases" {}

"TPMuzzleFlashScale" "0.5"

Expand Down
3 changes: 3 additions & 0 deletions src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,8 @@ void CNEO_Player::Weapon_DropOnDeath(CNEOBaseCombatWeapon* pNeoWeapon, Vector da
pNeoWeapon->AddEffects(EF_BONEMERGE);
}

pNeoWeapon->StopReloadOnDrop();

Vector playerVelocity = vec3_origin;
GetVelocity(&playerVelocity, nullptr);
pNeoWeapon->Drop(playerVelocity);
Expand Down Expand Up @@ -2953,6 +2955,7 @@ void CNEO_Player::Weapon_Drop( CBaseCombatWeapon *pWeapon,
return; // Return early to not drop weapon
}

neoWeapon->StopReloadOnDrop();
pWeapon->m_bInReload = false;
pWeapon->StopWeaponSound(RELOAD_NPC);

Expand Down
76 changes: 76 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,88 @@ CNEOWeaponInfo::CNEOWeaponInfo()
m_flPenetration = 0.f;
m_bDropOnDeath = true;
iAimFOV = 0;
m_iNumReloadTables = 0;

m_flVMFov = m_flVMAimFov = 0.f;
m_vecVMPosOffset = m_vecVMAimPosOffset = vec3_origin;
m_angVMAngOffset = m_angVMAimAngOffset = vec3_angle;
}


// Weapon-script names of the reload phases, by ReloadPhase_t
static constexpr const char *RELOAD_PHASE_NAMES[RELOAD_PHASE_COUNT] = { "", "1_unload", "2_load", "3_cycle" };
// Weapon-script keys of a phase's sound pieces: { sound name, time }
static constexpr const char *RELOAD_SOUND_KEYS[RELOAD_SOUNDS_PER_ROW][2] = {
{ "sound_name", "sound" }, { "sound2_name", "sound2" }, { "sound3_name", "sound3" }
};

static ReloadPhase_t ReloadPhaseFromName(const char *pszName)
{
for (int i = RELOAD_PHASE_UNLOADED; i < RELOAD_PHASE_COUNT; ++i)
{
if (V_stricmp(pszName, RELOAD_PHASE_NAMES[i]) == 0)
{
return static_cast<ReloadPhase_t>(i);
}
}
return RELOAD_PHASE_NONE;
}

// "ReloadPhases" { "<sequence>" { "<phase>" { "ammo" "s" "sound" "s" "sound_name" "name" "resume" "sequence" } ... } ... }
void CNEOWeaponInfo::ParseReloadPhases(KeyValues *pBlock)
{
m_iNumReloadTables = 0;
if (!pBlock)
{
return;
}

if (!pBlock->GetFirstTrueSubKey())
{
Warning("%s: \"ReloadPhases\" is empty (is its neoAssets #base file missing?); reloading without phases\n", szClassName);
return;
}

for (KeyValues *pSeq = pBlock->GetFirstTrueSubKey(); pSeq && m_iNumReloadTables < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey())
{
ReloadPhaseTable_t &table = m_reloadTables[m_iNumReloadTables++];
V_strncpy(table.szSequence, pSeq->GetName(), sizeof(table.szSequence));
table.iNumRows = 0;

for (KeyValues *pRow = pSeq->GetFirstTrueSubKey(); pRow && table.iNumRows < RELOAD_PHASE_ROWS_MAX; pRow = pRow->GetNextTrueSubKey())
{
const ReloadPhase_t phase = ReloadPhaseFromName(pRow->GetName());
if (phase == RELOAD_PHASE_NONE)
{
Warning("%s: unknown reload phase \"%s\" in \"%s\"\n", szClassName, pRow->GetName(), table.szSequence);
continue;
}

ReloadPhaseRow_t &row = table.rows[table.iNumRows++];
row.phase = phase;
row.flAmmo = pRow->GetFloat("ammo");
for (int j = 0; j < RELOAD_SOUNDS_PER_ROW; ++j)
{
row.sounds[j].flAt = pRow->GetFloat(RELOAD_SOUND_KEYS[j][1]);
V_strncpy(row.sounds[j].szName, pRow->GetString(RELOAD_SOUND_KEYS[j][0]), sizeof(row.sounds[j].szName));
}
V_strncpy(row.szResume, pRow->GetString("resume"), sizeof(row.szResume));
}
}
}

int CNEOWeaponInfo::FindReloadTable(const char *pszSequence) const
{
for (int i = 0; i < m_iNumReloadTables; ++i)
{
if (V_stricmp(m_reloadTables[i].szSequence, pszSequence) == 0)
{
return i;
}
}
return -1;
}

void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
BaseClass::Parse( pKeyValuesData, szWeaponName );
Expand All @@ -39,6 +114,7 @@ void CNEOWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName
m_iBullets = pKeyValuesData->GetInt( "Bullets", 1 );
m_flCycleTime = pKeyValuesData->GetFloat( "CycleTime", 0.15 );
m_flReloadReadyBeforeEnd = pKeyValuesData->GetFloat( "ReloadReadyBeforeEnd", 0.0f );
ParseReloadPhases(pKeyValuesData->FindKey("ReloadPhases"));

const char *notFoundStr = "notfound";
Q_strncpy(szViewModel2, pKeyValuesData->GetString("team2viewmodel", notFoundStr), MAX_WEAPON_STRING);
Expand Down
55 changes: 55 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,54 @@

#include "hl2mp_weapon_parse.h"

// A reload is a linear sequence of phases; a reload sequence finishes each phase at a point of its animation
enum ReloadPhase_t
{
RELOAD_PHASE_NONE = 0, // no reload in progress, or none pending
RELOAD_PHASE_UNLOADED, // 1_unload: the old magazine is out
RELOAD_PHASE_LOADED, // 2_load: the fresh magazine is in
RELOAD_PHASE_CYCLED, // 3_cycle: the bolt or charging handle chambered a round

RELOAD_PHASE_COUNT
};

// bits to network a phase
static constexpr int RELOAD_PHASE_BITS = 2;
static_assert((1 << RELOAD_PHASE_BITS) >= RELOAD_PHASE_COUNT, "RELOAD_PHASE_BITS cannot hold every phase");
static constexpr int RELOAD_PHASE_TABLES_MAX = 12;
// bits to network a table index, signed so that -1 (no table) fits
static constexpr int RELOAD_PHASE_TABLE_BITS = 5;
static_assert((1 << (RELOAD_PHASE_TABLE_BITS - 1)) >= RELOAD_PHASE_TABLES_MAX, "RELOAD_PHASE_TABLE_BITS cannot hold every table index");
static constexpr int RELOAD_PHASE_ROWS_MAX = RELOAD_PHASE_COUNT - 1;
static constexpr int RELOAD_SOUND_NAME_MAX = 64;
static constexpr int RELOAD_SEQUENCE_NAME_MAX = 32;
// a phase may need more than one sound piece, such as loading a magazine and the tap after it
static constexpr int RELOAD_SOUNDS_PER_ROW = 3;

// A sound piece of a phase
struct ReloadSoundPiece_t
{
float flAt; // when the piece's first transient plays, seconds from the sequence start
char szName[RELOAD_SOUND_NAME_MAX];
};

// One phase of a reload sequence: when its ammo counts, and the sound pieces that go with it
struct ReloadPhaseRow_t
{
ReloadPhase_t phase;
float flAmmo; // seconds from the sequence start
ReloadSoundPiece_t sounds[RELOAD_SOUNDS_PER_ROW];
char szResume[RELOAD_SEQUENCE_NAME_MAX]; // the sequence that resumes a reload interrupted after this phase, or empty
};

// The phases one reload sequence carries, in order
struct ReloadPhaseTable_t
{
char szSequence[RELOAD_SEQUENCE_NAME_MAX];
int iNumRows;
ReloadPhaseRow_t rows[RELOAD_PHASE_ROWS_MAX];
};

//--------------------------------------------------------------------------------------------------------
class CNEOWeaponInfo : public CHL2MPSWeaponInfo
{
Expand All @@ -25,6 +73,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo
int m_iBullets;
float m_flCycleTime;
float m_flReloadReadyBeforeEnd;
int m_iNumReloadTables; // 0: the weapon reloads without phases
ReloadPhaseTable_t m_reloadTables[RELOAD_PHASE_TABLES_MAX];
char szViewModel2[MAX_WEAPON_STRING]; // Team 2 (NSF) wep vm
char szBulletCharacter[MAX_BULLET_CHARACTER];// character used to display ammunition in current clip
char szDeathIcon[MAX_BULLET_CHARACTER];
Expand All @@ -39,6 +89,11 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo
float m_flVMAimFov;
Vector m_vecVMAimPosOffset;
QAngle m_angVMAimAngOffset;

int FindReloadTable(const char *pszSequence) const;

private:
void ParseReloadPhases(::KeyValues *pBlock);
};


Expand Down
Loading
Loading