Skip to content
Open
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
7 changes: 4 additions & 3 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,7 @@ 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
)

set_source_files_properties(
Expand All @@ -1590,7 +1591,7 @@ 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
${UNITY_SOURCE_NEO_SRC_CLIENT}
)

Expand Down Expand Up @@ -1658,7 +1659,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 +1698,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
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;
2 changes: 1 addition & 1 deletion 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 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);
2 changes: 1 addition & 1 deletion src/game/client/neo/ui/neo_hud_deathnotice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#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 "neo_scoreboard.h"

// memdbgon must be the last include file in a .cpp file!!!
Expand Down
Loading