Skip to content
Draft
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
9 changes: 6 additions & 3 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,8 @@ set(UNITY_SOURCE_NEO_SRC_CLIENT
neo/c_neo_te_tocflash.cpp
neo/neo_fixup_glshaders.cpp
neo/c_neo_bloom_controller.cpp
neo/neo_killer_damage_info.cpp
neo/c_neo_local_killed.cpp
)

set_source_files_properties(
Expand All @@ -1590,7 +1592,8 @@ target_sources_grouped(
neo/c_neo_player.h
neo/c_neo_te_tocflash.h
neo/neo_fixup_glshaders.h
neo/c_neo_killer_damage_infos.h
neo/c_neo_killer_infos.h
neo/c_neo_local_killed.h
${UNITY_SOURCE_NEO_SRC_CLIENT}
)

Expand Down Expand Up @@ -1658,7 +1661,7 @@ set(UNITY_SOURCE_NEO_UI
neo/ui/neo_hud_ghost_beacons.cpp
neo/ui/neo_hud_ghost_cap_point.cpp
neo/ui/neo_hud_ghost_marker.cpp
neo/ui/neo_hud_killer_damage_info.cpp
neo/ui/neo_hud_killer_info.cpp
neo/ui/neo_hud_ghost_uplink_state.cpp
neo/ui/neo_hud_health_thermoptic_aux.cpp
neo/ui/neo_hud_hint.cpp
Expand Down Expand Up @@ -1697,7 +1700,7 @@ target_sources_grouped(
neo/ui/neo_hud_ghost_beacons.h
neo/ui/neo_hud_ghost_cap_point.h
neo/ui/neo_hud_ghost_marker.h
neo/ui/neo_hud_killer_damage_info.h
neo/ui/neo_hud_killer_info.h
neo/ui/neo_hud_ghost_uplink_state.h
neo/ui/neo_hud_health_thermoptic_aux.h
neo/ui/neo_hud_hint.h
Expand Down
3 changes: 0 additions & 3 deletions src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,9 +1445,6 @@ void CHLClient::PostInit()
if (iCfgVerMajor < 22)
{
SetupBindIfNotSet("+attack3", MOUSE_MIDDLE); // Ping location
SetupBindIfNotSet("kdinfo_toggle", KEY_F11); // KD-info toggle
SetupBindIfNotSet("kdinfo_page_prev", KEY_P); // KD-info page previous
SetupBindIfNotSet("kdinfo_page_next", KEY_N); // KD-info page next
SetupBindIfNotSet("neo_mp3", KEY_M); // MP3 player toggle

// neo_aim_hold removal, +aim split to +aim and toggle_aim
Expand Down
8 changes: 8 additions & 0 deletions src/game/client/hl2mp/c_hl2mp_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,14 @@ void C_HL2MP_Player::PostDataUpdate( DataUpdateType_t updateType )
{
MoveToLastReceivedPosition( true );
ResetLatched();
#ifdef NEO
// NEO NOTE (nullsystem): Respawning doesn't trigger
// C_NEO_Player::Spawn/m_bFirstAliveTick without this
if (IsLocalPlayer())
{
static_cast<C_NEO_Player *>(this)->m_bFirstAliveTick = true;
}
#endif
m_iSpawnInterpCounterCache = m_iSpawnInterpCounter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

static constexpr const int WEP_NAME_MAXSTRLEN = 32;

struct CNEOKillerInfo
struct CNEOKillerInfos
{
bool bHasDmgInfos = false;
wchar_t wszKillerName[MAX_PLAYER_NAME_LENGTH + 1];
int iEntIndex;
int iClass;
int iHP;
float flDistance;
wchar_t wszKilledWith[WEP_NAME_MAXSTRLEN];
};

struct CNEOKillerDamageInfos
{
bool bHasDmgInfos = false;
CNEOKillerInfo killerInfo;
wchar_t wszKillerName[MAX_PLAYER_NAME_LENGTH + 1];
};

// Global instance of CNEOKillerDamageInfos
inline CNEOKillerDamageInfos g_neoKDmgInfos;
// Global instance of CNEOKillerInfos
inline CNEOKillerInfos g_neoKillerInfos;
10 changes: 10 additions & 0 deletions src/game/client/neo/c_neo_local_killed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "c_neo_local_killed.h"

#include "strtools.h"

void NeoUserIDsLocalKilledClear()
{
g_neoUserIDsLocalKilledSize = 0;
V_memset(g_neoUserIDsLocalKilled, 0, sizeof(g_neoUserIDsLocalKilled));
}

9 changes: 9 additions & 0 deletions src/game/client/neo/c_neo_local_killed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "shareddefs.h"

void NeoUserIDsLocalKilledClear();

inline int g_neoUserIDsLocalKilledSize;
inline int g_neoUserIDsLocalKilled[MAX_PLAYERS_ARRAY_SAFE];

10 changes: 7 additions & 3 deletions src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#include "rendertexture.h"
#include "ivieweffects.h"
#include "iachievementmgr.h"
#include "c_neo_killer_damage_infos.h"
#include "c_neo_killer_infos.h"
#include <vgui/ILocalize.h>
#include <tier3.h>

Expand All @@ -58,6 +58,7 @@
#include "neo_player_shared.h"

#include "c_playerresource.h"
#include "c_neo_local_killed.h"

// Don't alias here
#if defined( CNEO_Player )
Expand Down Expand Up @@ -479,6 +480,7 @@ C_NEO_Player::C_NEO_Player()
m_flTocFactor = 0.15f;

memset(m_szNeoNameWDupeIdx, 0, sizeof(m_szNeoNameWDupeIdx));
if (IsLocalPlayer()) NeoUserIDsLocalKilledClear();
m_szNameDupePos = 0;
}

Expand Down Expand Up @@ -1207,6 +1209,9 @@ void C_NEO_Player::PreThink( void )
CLocalPlayerFilter filter;
enginesound->SetPlayerDSP(filter, 0, true);

NeoUserIDsLocalKilledClear();
V_memset(&g_neoKillerInfos, 0, sizeof(CNEOKillerInfos));

// Reset the cache of other players crosshair data on spawning in
if (CHudCrosshair *crosshair = GET_HUDELEMENT(CHudCrosshair))
{
Expand Down Expand Up @@ -1625,11 +1630,10 @@ void C_NEO_Player::Spawn( void )
m_rfAttackersAccumlator.GetForModify(i) = 0.0f;
m_rfAttackersHits.GetForModify(i) = 0;
}
V_memset(m_rfNeoPlayerIdxsKilledByLocal, 0, sizeof(m_rfNeoPlayerIdxsKilledByLocal));
if (IsLocalPlayer()) NeoUserIDsLocalKilledClear();

Weapon_SetZoom(false);


SetViewOffset(VEC_VIEW_NEOSCALE(this));

auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer();
Expand Down
5 changes: 2 additions & 3 deletions src/game/client/neo/c_neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ class C_NEO_Player : public C_HL2MP_Player
unsigned char m_NeoFlags;

private:
friend C_HL2MP_Player;

bool m_bFirstAliveTick;
bool m_bFirstDeathTick;
bool m_bPreviouslyReloading;
Expand All @@ -278,9 +280,6 @@ class C_NEO_Player : public C_HL2MP_Player
mutable char m_szNeoNameWDupeIdx[MAX_PLAYER_NAME_LENGTH + 10];
mutable int m_szNeoNameLocalDupeIdx;

public:
bool m_rfNeoPlayerIdxsKilledByLocal[MAX_PLAYERS_ARRAY_SAFE];

private:
C_NEO_Player(const C_NEO_Player &);
};
Expand Down
151 changes: 151 additions & 0 deletions src/game/client/neo/neo_killer_damage_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#include <cbase.h>

#include "c_neo_player.h"
#include "neo_gamerules.h"

#include "c_user_message_register.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

// Console + activation of damage info
static void __MsgFunc_KillerDamageInfo(bf_read &msg)
{
const int killerIdx = msg.ReadShort();
char killedBy[MAX_PLAYER_NAME_LENGTH] = {};
const bool foundKilledBy = msg.ReadString(killedBy, sizeof(killedBy), false);

auto *localPlayer = C_NEO_Player::GetLocalNEOPlayer();
if (!localPlayer)
{
return;
}

// Print damage stats into the console
// Print to console
AttackersTotals totals = {};

const int thisIdx = localPlayer->entindex();

// Can't rely on Msg as it can print out of order, so do it in chunks
static char killByLine[512];

static const char *BORDER = "==========================\n";
bool setKillByLine = false;

V_memset(&g_neoKillerInfos, 0, sizeof(CNEOKillerInfos));
g_neoKillerInfos.bHasDmgInfos = true;

if (killerIdx > 0 && killerIdx <= gpGlobals->maxClients)
{
auto *neoAttacker = assert_cast<C_NEO_Player*>(UTIL_PlayerByIndex(killerIdx));
if (neoAttacker && neoAttacker->entindex() != thisIdx)
{
g_pVGuiLocalize->ConvertANSIToUnicode(neoAttacker->GetNeoPlayerName(),
g_neoKillerInfos.wszKillerName,
sizeof(g_neoKillerInfos.wszKillerName));
}
// If not neoAttacker, already cleared out by memset earlier

if (neoAttacker)
{
g_neoKillerInfos.iEntIndex = killerIdx;
g_neoKillerInfos.iClass = neoAttacker->GetClass();
g_neoKillerInfos.iHP = neoAttacker->GetHealth();
g_neoKillerInfos.flDistance = METERS_PER_INCH * neoAttacker->GetAbsOrigin().DistTo(localPlayer->GetAbsOrigin());
if (foundKilledBy)
{
// Rename very long names
if (V_strcmp(killedBy, "MURATA SUPA 7") == 0)
{
V_strcpy_safe(killedBy, "SUPA 7");
}
g_pVGuiLocalize->ConvertANSIToUnicode(killedBy,
g_neoKillerInfos.wszKilledWith,
sizeof(g_neoKillerInfos.wszKilledWith));
}
else
{
g_neoKillerInfos.wszKilledWith[0] = L'\0';
}

V_sprintf_safe(killByLine, "Killed by: %s [%s | %d hp] with %s at %.0f m\n",
neoAttacker->GetNeoPlayerName(), GetNeoClassName(g_neoKillerInfos.iClass),
g_neoKillerInfos.iHP, foundKilledBy ? killedBy : "", g_neoKillerInfos.flDistance);
setKillByLine = true;
}
}
else if (killerIdx == NEO_ENVIRON_KILLED)
{
g_neoKillerInfos.iEntIndex = NEO_ENVIRON_KILLED;
g_neoKillerInfos.wszKilledWith[0] = L'\0';
if (foundKilledBy && V_strcmp(killedBy, "neo_npc_targetsystem") == 0)
{
const char *pszMap = IGameSystem::MapName();
if (V_strcmp(pszMap, "ntre_rogue_ctg") == 0)
{
V_wcscpy_safe(g_neoKillerInfos.wszKilledWith, L"184-J IFV");
}
else
{
V_wcscpy_safe(g_neoKillerInfos.wszKilledWith, L"Turret");
}
}
}

ConMsg("%sDamage infos (Round %d):\n%s\n", BORDER, NEORules()->roundNumber(), setKillByLine ? killByLine : "");

for (int pIdx = 1; pIdx <= gpGlobals->maxClients; ++pIdx)
{
if (pIdx == thisIdx)
{
continue;
}

auto* neoAttacker = assert_cast<C_NEO_Player*>(UTIL_PlayerByIndex(pIdx));
if (!neoAttacker || neoAttacker->IsHLTV())
{
continue;
}

const char *dmgerName = neoAttacker->GetNeoPlayerName();
if (!dmgerName)
{
continue;
}

const AttackersTotals attackerInfo = {
.dealtDmgs = neoAttacker->GetAttackersScores(thisIdx),
.dealtHits = neoAttacker->GetAttackerHits(thisIdx),
.takenDmgs = localPlayer->GetAttackersScores(pIdx),
.takenHits = localPlayer->GetAttackerHits(pIdx),
};
if (attackerInfo.dealtDmgs > 0 || attackerInfo.takenDmgs > 0)
{
const char *dmgerClass = GetNeoClassName(neoAttacker->GetClass());

char infoLine[128] = {};
if (attackerInfo.dealtDmgs > 0)
{
V_sprintf_safe(infoLine, "Damage dealt to %s [%s]: %d in %d hits\n",
dmgerName, dmgerClass,
attackerInfo.dealtDmgs, attackerInfo.dealtHits);
}
if (attackerInfo.takenDmgs > 0)
{
V_sprintf_safe(infoLine, "Damage taken from %s [%s]: %d in %d hits\n",
dmgerName, dmgerClass,
attackerInfo.takenDmgs, attackerInfo.takenHits);
}
ConMsg("%s", infoLine);

totals += attackerInfo;
}
}

ConMsg("Total damage dealt: %d in %d hits\nTotal damage received from players: %d in %d hits\n%s\n",
totals.dealtDmgs, totals.dealtHits,
totals.takenDmgs, totals.takenHits,
BORDER);
}
USER_MESSAGE_REGISTER(KillerDamageInfo);
12 changes: 8 additions & 4 deletions src/game/client/neo/ui/neo_hud_deathnotice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include "neo_hud_childelement.h"
#include "spectatorgui.h"
#include "takedamageinfo.h"
#include "c_neo_killer_damage_infos.h"
#include "c_neo_killer_infos.h"
#include "c_neo_local_killed.h"
#include "neo_scoreboard.h"

// memdbgon must be the last include file in a .cpp file!!!
Expand Down Expand Up @@ -765,7 +766,8 @@ void CNEOHud_DeathNotice::AddPlayerDeath(IGameEvent* event)
{
// the event should be "player_death"
const int killer = engine->GetPlayerForUserID(event->GetInt("attacker"));
const int victim = engine->GetPlayerForUserID(event->GetInt("userid"));
const int iVictimUserID = event->GetInt("userid");
const int victim = engine->GetPlayerForUserID(iVictimUserID);
const int assistInt = event->GetInt("assists");
const int assist = engine->GetPlayerForUserID(assistInt);
const bool hasAssists = assist > 0;
Expand Down Expand Up @@ -859,9 +861,11 @@ void CNEOHud_DeathNotice::AddPlayerDeath(IGameEvent* event)
deathMsg.bInvolved = killer == GetLocalPlayerIndex() || victim == GetLocalPlayerIndex() || assist == GetLocalPlayerIndex();
Assert(victim >= 0 && victim < (MAX_PLAYERS + 1));
C_NEO_Player *localPlayer = C_NEO_Player::GetLocalNEOPlayer();
if (localPlayer)
if (localPlayer
&& killer == localPlayer->entindex()
&& g_neoUserIDsLocalKilledSize < MAX_PLAYERS_ARRAY_SAFE)
{
localPlayer->m_rfNeoPlayerIdxsKilledByLocal[victim] = (killer == localPlayer->entindex());
g_neoUserIDsLocalKilled[g_neoUserIDsLocalKilledSize++] = iVictimUserID;
}

SetDeathNoticeItemDimensions(&deathMsg);
Expand Down
Loading