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
30 changes: 30 additions & 0 deletions game/neo/scripts/game_sounds_weapons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,36 @@
"wave" "weapons/zr68/zr68_reload.wav"
}

// ZR68 reload in per-step pieces (sv_neo_reload_experimental), named reload_<step>; a step's later sounds add _part2, _part3.
// Each file starts just before its first transient

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

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

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

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

"weapon_zr68.npc_reload"
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
5 changes: 5 additions & 0 deletions src/game/shared/hl2mp/hl2mp_playeranimstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ void CHL2MPPlayerAnimState::DoAnimationEvent( PlayerAnimEvent_t event, int nData
{
#ifdef NEO
AddToGestureSlot(GESTURE_SLOT_ATTACK_AND_RELOAD, CalcReloadSequence(), true);
if (nData == RELOAD_EVENT_RESUMED)
{
// A reload resumed by the draw starts with the weapon change, which would otherwise clear the gesture
m_hActiveWeapon = GetBasePlayer()->GetActiveWeapon();
}
#else
// Weapon reload.
if ( GetBasePlayer()->GetFlags() & FL_DUCKING )
Expand Down
3 changes: 3 additions & 0 deletions src/game/shared/hl2mp/hl2mp_playeranimstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class CHL2MPPlayerAnimState : public CMultiPlayerAnimState
virtual float GetCurrentMaxGroundSpeed();
#ifdef NEO
virtual void ComputeSequences(CStudioHdr* pStudioHdr);

// Reload event data: the draw resumes an interrupted reload
static constexpr int RELOAD_EVENT_RESUMED = 1;
#endif

void DebugShowAnimStateFull(int iStartLine);
Expand Down
9 changes: 9 additions & 0 deletions src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <utility>

extern ConVar weaponstay;
extern ConVar sv_neo_reload_experimental;
#endif

ConVar sv_neo_loopback_warmup_round("sv_neo_loopback_warmup_round", "0", FCVAR_REPLICATED, "Allow loopback server to do warmup rounds.", true, 0.0f, true, 1.0f);
Expand Down Expand Up @@ -306,6 +307,7 @@ BEGIN_NETWORK_TABLE_NOBASE( CNEORules, DT_NEORules )
RecvPropInt(RECVINFO(m_iForcedSkin)),
RecvPropInt(RECVINFO(m_iForcedWeapon)),
RecvPropBool(RECVINFO(m_bCyberspaceLevel)),
RecvPropBool(RECVINFO(m_bReloadExperimental)),
RecvPropString(RECVINFO(m_szNeoJinraiClantag)),
RecvPropString(RECVINFO(m_szNeoNSFClantag)),
RecvPropInt(RECVINFO(m_iGhosterTeam)),
Expand Down Expand Up @@ -349,6 +351,7 @@ BEGIN_NETWORK_TABLE_NOBASE( CNEORules, DT_NEORules )
SendPropInt(SENDINFO(m_iForcedSkin)),
SendPropInt(SENDINFO(m_iForcedWeapon)),
SendPropBool(SENDINFO(m_bCyberspaceLevel)),
SendPropBool(SENDINFO(m_bReloadExperimental)),
SendPropString(SENDINFO(m_szNeoJinraiClantag)),
SendPropString(SENDINFO(m_szNeoNSFClantag)),
SendPropInt(SENDINFO(m_iGhosterTeam), NumBitsForCount(TEAM__TOTAL), SPROP_UNSIGNED),
Expand Down Expand Up @@ -705,6 +708,12 @@ CNEORules::CNEORules()
m_iForcedSkin = -1;
m_iForcedWeapon = -1;
m_bCyberspaceLevel = false;
#ifdef GAME_DLL
// Read once per map so that every weapon, and the client's prediction of it, sees one value for the whole map
m_bReloadExperimental = sv_neo_reload_experimental.GetBool();
#else
m_bReloadExperimental = false;
#endif

m_iClassLimitRecon = -1;
m_iClassLimitAssault = -1;
Expand Down
2 changes: 2 additions & 0 deletions src/game/shared/neo/neo_gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class CNEORules : public CHL2MPRules, public CGameEventListener
int GetForcedSkin();
int GetForcedWeapon();
bool IsCyberspace();
bool IsReloadExperimental() const { return m_bReloadExperimental; }
virtual const char* GetGameTypeName(void) OVERRIDE;
bool CanChangeTeamClassLoadoutWhenAlive();
bool CanRespawnAnyTime();
Expand Down Expand Up @@ -555,6 +556,7 @@ class CNEORules : public CHL2MPRules, public CGameEventListener
CNetworkVar(int, m_iForcedSkin);
CNetworkVar(int, m_iForcedWeapon);
CNetworkVar(bool, m_bCyberspaceLevel);
CNetworkVar(bool, m_bReloadExperimental);
CNetworkVar(int, m_nGameTypeSelected);
CNetworkVar(int, m_iRoundNumber);
CNetworkVar(bool, m_bIsMatchPoint);
Expand Down
2 changes: 1 addition & 1 deletion src/game/shared/neo/neo_predicted_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void CNEOPredictedViewModel::CalcViewModelView(CBasePlayer *pOwner,
return;
}

CNEOWeaponInfo data = weapon->GetNEOWpnData();
const CNEOWeaponInfo &data = weapon->GetNEOWpnData();

Vector vForward, vRight, vUp, newPos, vOffset;
QAngle newAng, angOffset;
Expand Down
75 changes: 75 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,80 @@ CNEOWeaponInfo::CNEOWeaponInfo()
}


// 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_reloadTables.Purge();
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_reloadTables.Count() < RELOAD_PHASE_TABLES_MAX; pSeq = pSeq->GetNextTrueSubKey())
{
ReloadPhaseTable_t &table = m_reloadTables[m_reloadTables.AddToTail()];
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_reloadTables.Count(); ++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 +113,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
56 changes: 56 additions & 0 deletions src/game/shared/neo/weapons/neo_weapon_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,55 @@
#endif

#include "hl2mp_weapon_parse.h"
#include "utlvector.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 +74,8 @@ class CNEOWeaponInfo : public CHL2MPSWeaponInfo
int m_iBullets;
float m_flCycleTime;
float m_flReloadReadyBeforeEnd;
// Empty: the weapon reloads without phases. Allocated only for scripts with a ReloadPhases block.
CUtlVector<ReloadPhaseTable_t> m_reloadTables;
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 +90,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