Skip to content
Merged
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: 9 additions & 0 deletions game/neo/scripts/HudLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -983,4 +983,13 @@
"wide" "300"
"tall" "200"
}

neo_killer_damage_info
{
"fieldName" "neo_killer_damage_info"
"xpos" "0"
"ypos" "0"
"wide" "640"
"tall" "480"
}
}
3 changes: 3 additions & 0 deletions game/neo/scripts/kb_act.lst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"timeleft" "Time Left in Round"
"askconnect_accept" "#Valve_Accept_Redirect"
"neo_mp3" "MP3 Player"
"kdinfo_toggle" "Toggle killer damage info"
"kdinfo_page_prev" "Killer damage info previous page"
"kdinfo_page_next" "Killer damage info next page"
"blank" "=========================="
"blank" "#Valve_Miscellaneous_Keyboard_Keys_Title"
"blank" "=========================="
Expand Down
5 changes: 4 additions & 1 deletion game/neo/scripts/kb_def.lst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"w" "+forward"
"y" "messagemode"
"f" "+use"
"p" "neo_mp3"
"m" "neo_mp3"
"ALT" "+walk"
"CTRL" "+duck"
"SHIFT" "+sprint"
Expand All @@ -44,6 +44,9 @@
"F8" "joinstar 4"
"F9" "joinstar 5"
"F10" "joinstar 0"
"F11" "kdinfo_toggle"
"p" "kdinfo_page_prev"
"n" "kdinfo_page_next"
"MWHEELDOWN" "invprev"
"MWHEELUP" "invnext"
"MOUSE1" "+attack"
Expand Down
3 changes: 3 additions & 0 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,7 @@ target_sources_grouped(
neo/neo_fixup_glshaders.cpp
neo/neo_fixup_glshaders.h
neo/c_neo_bloom_controller.cpp
neo/c_neo_killer_damage_infos.h
)

target_sources_grouped(
Expand Down Expand Up @@ -1590,6 +1591,8 @@ target_sources_grouped(
neo/ui/neo_hud_ghost_cap_point.h
neo/ui/neo_hud_ghost_marker.cpp
neo/ui/neo_hud_ghost_marker.h
neo/ui/neo_hud_killer_damage_info.cpp
neo/ui/neo_hud_killer_damage_info.h
neo/ui/neo_hud_ghost_uplink_state.cpp
neo/ui/neo_hud_ghost_uplink_state.h
neo/ui/neo_hud_health_thermoptic_aux.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/game/client/c_playerresource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ const char *C_PlayerResource::GetPlayerName( int iIndex )
{
if (dupeIdx > 0)
{
Q_snprintf(m_szDispNameWDupeIdx[iIndex], sizeof(m_szDispNameWDupeIdx[iIndex]), "%s (%d)", m_szNeoName[iIndex], dupeIdx);
V_sprintf_safe(m_szDispNameWDupeIdx[iIndex], "%s (%d)", m_szNeoName[iIndex], dupeIdx);
return m_szDispNameWDupeIdx[iIndex];
}
return m_szNeoName[iIndex];
}

if (clientWantNeoName && dupeIdx > 0)
{
Q_snprintf(m_szDispNameWDupeIdx[iIndex], sizeof(m_szDispNameWDupeIdx[iIndex]), "%s (%d)", m_szName[iIndex], dupeIdx);
V_sprintf_safe(m_szDispNameWDupeIdx[iIndex], "%s (%d)", m_szName[iIndex], dupeIdx);
return m_szDispNameWDupeIdx[iIndex];
}
#endif
Expand Down
22 changes: 22 additions & 0 deletions src/game/client/neo/c_neo_killer_damage_infos.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

static constexpr const int WEP_NAME_MAXSTRLEN = 32;

struct CNEOKillerInfo
{
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;
87 changes: 6 additions & 81 deletions src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
#include <materialsystem/itexture.h>
#include "rendertexture.h"
#include "ivieweffects.h"
#include "c_neo_killer_damage_infos.h"
#include <vgui/ILocalize.h>
#include <tier3.h>

#include "model_types.h"

Expand Down Expand Up @@ -119,85 +122,6 @@ BEGIN_PREDICTION_DATA(C_NEO_Player)
DEFINE_PRED_FIELD_TOL(m_flJumpLastTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE, TD_MSECTOLERANCE),
END_PREDICTION_DATA()

static void __MsgFunc_DamageInfo(bf_read& msg)
{
const int killerIdx = msg.ReadShort();
char killedBy[32];
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;
if (killerIdx > 0 && killerIdx <= gpGlobals->maxClients)
{
auto *neoAttacker = assert_cast<C_NEO_Player*>(UTIL_PlayerByIndex(killerIdx));
if (neoAttacker && neoAttacker->entindex() != thisIdx)
{
KillerLineStr(killByLine, sizeof(killByLine), neoAttacker, localPlayer, foundKilledBy ? killedBy : NULL);
setKillByLine = true;
}
}

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());

static char infoLine[128];
DmgLineStr(infoLine, sizeof(infoLine), dmgerName, dmgerClass, attackerInfo);
ConMsg("%s", infoLine);

totals += attackerInfo;
}
}

ConMsg("\nTOTAL: Dealt: %d in %d hits | Taken: %d in %d hits\n%s\n",
totals.dealtDmgs, totals.dealtHits,
totals.takenDmgs, totals.takenHits,
BORDER);
}
USER_MESSAGE_REGISTER(DamageInfo);

static void __MsgFunc_IdleRespawnShowMenu(bf_read &)
{
if (C_NEO_Player::GetLocalNEOPlayer())
Expand Down Expand Up @@ -659,7 +583,7 @@ const char *C_NEO_Player::InternalGetNeoPlayerName() const
if (dupePos != m_szNeoNameLocalDupeIdx)
{
m_szNeoNameLocalDupeIdx = dupePos;
V_snprintf(m_szNeoNameWDupeIdx, sizeof(m_szNeoNameWDupeIdx), "%s (%d)", neoName, dupePos);
V_sprintf_safe(m_szNeoNameWDupeIdx, "%s (%d)", neoName, dupePos);
}
return m_szNeoNameWDupeIdx;
}
Expand All @@ -672,7 +596,7 @@ const char *C_NEO_Player::InternalGetNeoPlayerName() const
if (dupePos != m_szNeoNameLocalDupeIdx)
{
m_szNeoNameLocalDupeIdx = dupePos;
V_snprintf(m_szNeoNameWDupeIdx, sizeof(m_szNeoNameWDupeIdx), "%s (%d)", stndName, dupePos);
V_sprintf_safe(m_szNeoNameWDupeIdx, "%s (%d)", stndName, dupePos);
}
return m_szNeoNameWDupeIdx;
}
Expand Down Expand Up @@ -1543,6 +1467,7 @@ void C_NEO_Player::Spawn( void )
{
m_rfAttackersHits.Set(i, 0);
}
V_memset(m_rfNeoPlayerIdxsKilledByLocal, 0, sizeof(m_rfNeoPlayerIdxsKilledByLocal));

Weapon_SetZoom(false);

Expand Down
3 changes: 3 additions & 0 deletions src/game/client/neo/c_neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ 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 + 1];

private:
C_NEO_Player(const C_NEO_Player &);
};
Expand Down
9 changes: 8 additions & 1 deletion src/game/client/neo/ui/neo_hud_deathnotice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "neo_hud_childelement.h"
#include "spectatorgui.h"
#include "takedamageinfo.h"
#include "c_neo_killer_damage_infos.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
Expand Down Expand Up @@ -797,6 +798,12 @@ void CNEOHud_DeathNotice::AddPlayerDeath(IGameEvent* event)
const char* deathIcon = event->GetString("deathIcon");
g_pVGuiLocalize->ConvertANSIToUnicode(deathIcon, deathMsg.szDeathIcon, sizeof(deathMsg.szDeathIcon));
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)
{
localPlayer->m_rfNeoPlayerIdxsKilledByLocal[victim] = (killer == localPlayer->entindex());
}

SetDeathNoticeItemDimensions(&deathMsg);

Expand Down Expand Up @@ -977,4 +984,4 @@ void CNEOHud_DeathNotice::Paint()
{
BaseClass::Paint();
PaintNeoElement();
}
}
Loading
Loading