Skip to content

Commit

Permalink
Initial deathmatch spawn implementation
Browse files Browse the repository at this point in the history
* Use info_player_deathmatch entity if possible
* Otherwise can just use the separate file
* also add some info command to tell if the map can dm or not
* fixes NeotokyoRebuild#691
  • Loading branch information
nullsystem committed Oct 10, 2024
1 parent 68ffa08 commit fec5d80
Show file tree
Hide file tree
Showing 15 changed files with 535 additions and 98 deletions.
2 changes: 2 additions & 0 deletions mp/src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,8 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version_info.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version_info.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.h
)

target_sources_grouped(
Expand Down
29 changes: 22 additions & 7 deletions mp/src/game/client/neo/ui/neo_hud_friendly_marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,32 @@ void CNEOHud_FriendlyMarker::DrawNeoHudElement()
const auto *pTargetPlayer = (localPlayer->GetObserverMode() == OBS_MODE_IN_EYE) ?
dynamic_cast<C_NEO_Player *>(localPlayer->GetObserverTarget()) : nullptr;

if (m_IsSpectator)
if (NEORules()->IsTeamplay())
{
auto nsf = GetGlobalTeam(TEAM_NSF);
DrawPlayerForTeam(nsf, localPlayer, pTargetPlayer);

auto jinrai = GetGlobalTeam(TEAM_JINRAI);
DrawPlayerForTeam(jinrai, localPlayer, pTargetPlayer);
if (m_IsSpectator)
{
auto nsf = GetGlobalTeam(TEAM_NSF);
DrawPlayerForTeam(nsf, localPlayer, pTargetPlayer);

auto jinrai = GetGlobalTeam(TEAM_JINRAI);
DrawPlayerForTeam(jinrai, localPlayer, pTargetPlayer);
}
else
{
DrawPlayerForTeam(team, localPlayer, pTargetPlayer);
}
}
else
{
DrawPlayerForTeam(team, localPlayer, pTargetPlayer);
if (m_IsSpectator)
{
// TODO: They're not really Jinrai/NSF?
auto nsf = GetGlobalTeam(TEAM_NSF);
DrawPlayerForTeam(nsf, localPlayer, pTargetPlayer);

auto jinrai = GetGlobalTeam(TEAM_JINRAI);
DrawPlayerForTeam(jinrai, localPlayer, pTargetPlayer);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion mp/src/game/client/neo/ui/neo_hud_ghost_cap_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void CNEOHud_GhostCapPoint::UpdateStateForNeoHudElementDraw()

void CNEOHud_GhostCapPoint::DrawNeoHudElement()
{
if (!ShouldDraw() || NEORules()->IsRoundOver())
if (!ShouldDraw() || NEORules()->IsRoundOver() || !NEORules()->IsTeamplay())
{
return;
}
Expand Down
150 changes: 94 additions & 56 deletions mp/src/game/client/neo/ui/neo_hud_round_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,25 @@ void CNEOHud_RoundState::UpdateStateForNeoHudElementDraw()
V_snwprintf(m_wszTime, 6, L"%02d:%02d", minutes, secsRemainder);

const int localPlayerTeam = GetLocalPlayerTeam();
if (localPlayerTeam == TEAM_JINRAI || localPlayerTeam == TEAM_NSF) {
V_snwprintf(m_wszLeftTeamScore, 3, L"%i", GetGlobalTeam(localPlayerTeam)->GetRoundsWon());
V_snwprintf(m_wszRightTeamScore, 3, L"%i", GetGlobalTeam(NEORules()->GetOpposingTeam(localPlayerTeam))->GetRoundsWon());
}
else {
V_snwprintf(m_wszLeftTeamScore, 3, L"%i", GetGlobalTeam(TEAM_JINRAI)->GetRoundsWon());
V_snwprintf(m_wszRightTeamScore, 3, L"%i", GetGlobalTeam(TEAM_NSF)->GetRoundsWon());
if (NEORules()->IsTeamplay())
{
if (localPlayerTeam == TEAM_JINRAI || localPlayerTeam == TEAM_NSF) {
V_snwprintf(m_wszLeftTeamScore, 3, L"%i", GetGlobalTeam(localPlayerTeam)->GetRoundsWon());
V_snwprintf(m_wszRightTeamScore, 3, L"%i", GetGlobalTeam(NEORules()->GetOpposingTeam(localPlayerTeam))->GetRoundsWon());
}
else {
V_snwprintf(m_wszLeftTeamScore, 3, L"%i", GetGlobalTeam(TEAM_JINRAI)->GetRoundsWon());
V_snwprintf(m_wszRightTeamScore, 3, L"%i", GetGlobalTeam(TEAM_NSF)->GetRoundsWon());
}
}

char szPlayersAliveANSI[9] = {};
if (NEORules()->GetGameType() == NEO_GAME_TYPE_TDM)
if (NEORules()->GetGameType() == NEO_GAME_TYPE_DM)
{
// NEO TODO (nullsystem): Show highest player score
V_sprintf_safe(szPlayersAliveANSI, "DM");
}
else if (NEORules()->GetGameType() == NEO_GAME_TYPE_TDM)
{
if (localPlayerTeam == TEAM_JINRAI || localPlayerTeam == TEAM_NSF) {
V_sprintf_safe(szPlayersAliveANSI, "%i:%i", GetGlobalTeam(localPlayerTeam)->Get_Score(), GetGlobalTeam(NEORules()->GetOpposingTeam(localPlayerTeam))->Get_Score());
Expand All @@ -301,6 +309,7 @@ void CNEOHud_RoundState::UpdateStateForNeoHudElementDraw()

// Update Objective
switch (NEORules()->GetGameType()) {
case NEO_GAME_TYPE_DM:
case NEO_GAME_TYPE_TDM:
V_sprintf_safe(szGameTypeDescription, "Score the most Points\n");
break;
Expand Down Expand Up @@ -399,70 +408,99 @@ void CNEOHud_RoundState::DrawNeoHudElement()
m_iRightPlayersTotal = 0;
int leftCount = 0;
int rightCount = 0;
bool bDMRightSide = false;
for (int i = 0; i < (MAX_PLAYERS + 1); i++)
{
if (g_PR->IsConnected(i))
{
const int playerTeam = g_PR->GetTeam(i);
if (playerTeam == leftTeam)
if (NEORules()->IsTeamplay())
{
const bool isSameSquad = g_PR->GetStar(i) == g_PR->GetStar(localPlayerIndex);
if (localPlayerSpec || isSameSquad)
if (playerTeam == leftTeam)
{
const int xOffset = (m_iLeftOffset - 4) - ((leftCount + 1) * m_ilogoSize) - (leftCount * 2);
DrawPlayer(i, leftCount, leftTeamInfo, xOffset, true);
leftCount++;
const bool isSameSquad = g_PR->GetStar(i) == g_PR->GetStar(localPlayerIndex);
if (localPlayerSpec || isSameSquad)
{
const int xOffset = (m_iLeftOffset - 4) - ((leftCount + 1) * m_ilogoSize) - (leftCount * 2);
DrawPlayer(i, leftCount, leftTeamInfo, xOffset, true);
leftCount++;
}

if (g_PR->IsAlive(i))
m_iLeftPlayersAlive++;
m_iLeftPlayersTotal++;
}
else if (playerTeam == rightTeam)
{
const int xOffset = (m_iRightOffset + 4) + (rightCount * m_ilogoSize) + (rightCount * 2);
DrawPlayer(i, rightCount, rightTeamInfo, xOffset, localPlayerSpec);
rightCount++;

if (g_PR->IsAlive(i))
m_iLeftPlayersAlive++;
m_iLeftPlayersTotal++;
if (g_PR->IsAlive(i))
m_iRightPlayersAlive++;
m_iRightPlayersTotal++;
}
}
else if (playerTeam == rightTeam)
else
{
const int xOffset = (m_iRightOffset + 4) + (rightCount * m_ilogoSize) + (rightCount * 2);
DrawPlayer(i, rightCount, rightTeamInfo, xOffset, localPlayerSpec);
rightCount++;
// TODO: Left-side highest, right-side lowest
if (!bDMRightSide)
{
const int xOffset = (m_iLeftOffset - 4) - ((leftCount + 1) * m_ilogoSize) - (leftCount * 2);
DrawPlayer(i, leftCount, leftTeamInfo, xOffset, true);
leftCount++;
m_iLeftPlayersAlive += g_PR->IsAlive(i);
m_iLeftPlayersTotal++;
}
else
{
const int xOffset = (m_iRightOffset + 4) + (rightCount * m_ilogoSize) + (rightCount * 2);
DrawPlayer(i, rightCount, rightTeamInfo, xOffset, localPlayerSpec);
rightCount++;
m_iRightPlayersAlive += g_PR->IsAlive(i);
m_iRightPlayersTotal++;
}

if (g_PR->IsAlive(i))
m_iRightPlayersAlive++;
m_iRightPlayersTotal++;
bDMRightSide = !bDMRightSide;
}
}
}

// Draw score logo
surface()->DrawSetTexture(leftTeamInfo.totalLogo);
surface()->DrawSetColor(COLOR_FADED_DARK);
surface()->DrawTexturedRect(m_rectLeftTeamTotalLogo.x0,
m_rectLeftTeamTotalLogo.y0,
m_rectLeftTeamTotalLogo.x1,
m_rectLeftTeamTotalLogo.y1);

surface()->DrawSetTexture(rightTeamInfo.totalLogo);
surface()->DrawTexturedRect(m_rectRightTeamTotalLogo.x0,
m_rectRightTeamTotalLogo.y0,
m_rectRightTeamTotalLogo.x1,
m_rectRightTeamTotalLogo.y1);

// Draw score
surface()->GetTextSize(m_hOCRFont, m_wszLeftTeamScore, fontWidth, fontHeight);
surface()->DrawSetTextFont(m_hOCRFont);
surface()->DrawSetTextPos(m_posLeftTeamScore.x - (fontWidth / 2), m_posLeftTeamScore.y);
surface()->DrawSetTextColor(leftTeamInfo.color);
surface()->DrawPrintText(m_wszLeftTeamScore, 2);

surface()->GetTextSize(m_hOCRFont, m_wszRightTeamScore, fontWidth, fontHeight);
surface()->DrawSetTextPos(m_posRightTeamScore.x - (fontWidth / 2), m_posRightTeamScore.y);
surface()->DrawSetTextColor(rightTeamInfo.color);
surface()->DrawPrintText(m_wszRightTeamScore, 2);

// Draw total players alive
surface()->DrawSetTextFont(m_hOCRSmallFont);
surface()->GetTextSize(m_hOCRSmallFont, m_wszPlayersAliveUnicode, fontWidth, fontHeight);
surface()->DrawSetTextColor(COLOR_WHITE);
surface()->DrawSetTextPos(m_iXpos - (fontWidth / 2), m_ilogoSize);
surface()->DrawPrintText(m_wszPlayersAliveUnicode, 9);
if (NEORules()->IsTeamplay())
{
// Draw score logo
surface()->DrawSetTexture(leftTeamInfo.totalLogo);
surface()->DrawSetColor(COLOR_FADED_DARK);
surface()->DrawTexturedRect(m_rectLeftTeamTotalLogo.x0,
m_rectLeftTeamTotalLogo.y0,
m_rectLeftTeamTotalLogo.x1,
m_rectLeftTeamTotalLogo.y1);

surface()->DrawSetTexture(rightTeamInfo.totalLogo);
surface()->DrawTexturedRect(m_rectRightTeamTotalLogo.x0,
m_rectRightTeamTotalLogo.y0,
m_rectRightTeamTotalLogo.x1,
m_rectRightTeamTotalLogo.y1);

// Draw score
surface()->GetTextSize(m_hOCRFont, m_wszLeftTeamScore, fontWidth, fontHeight);
surface()->DrawSetTextFont(m_hOCRFont);
surface()->DrawSetTextPos(m_posLeftTeamScore.x - (fontWidth / 2), m_posLeftTeamScore.y);
surface()->DrawSetTextColor(leftTeamInfo.color);
surface()->DrawPrintText(m_wszLeftTeamScore, 2);

surface()->GetTextSize(m_hOCRFont, m_wszRightTeamScore, fontWidth, fontHeight);
surface()->DrawSetTextPos(m_posRightTeamScore.x - (fontWidth / 2), m_posRightTeamScore.y);
surface()->DrawSetTextColor(rightTeamInfo.color);
surface()->DrawPrintText(m_wszRightTeamScore, 2);

// Draw total players alive
surface()->DrawSetTextFont(m_hOCRSmallFont);
surface()->GetTextSize(m_hOCRSmallFont, m_wszPlayersAliveUnicode, fontWidth, fontHeight);
surface()->DrawSetTextColor(COLOR_WHITE);
surface()->DrawSetTextPos(m_iXpos - (fontWidth / 2), m_ilogoSize);
surface()->DrawPrintText(m_wszPlayersAliveUnicode, 9);
}

}
else
Expand Down
23 changes: 2 additions & 21 deletions mp/src/game/client/neo/ui/neo_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,15 @@
#include <vgui/IInput.h>
#include <vgui_controls/Controls.h>

#include "neo_misc.h"

using namespace vgui;

static const wchar_t *ENABLED_LABELS[] = {
L"Disabled",
L"Enabled",
};

#define IN_BETWEEN_AR(min, cmp, max) (((min) <= (cmp)) && ((cmp) < (max)))
#define IN_BETWEEN_EQ(min, cmp, max) (((min) <= (cmp)) && ((cmp) <= (max)))

[[nodiscard]] static int LoopAroundMinMax(const int iValue, const int iMin, const int iMax)
{
if (iValue < iMin)
{
return iMax;
}
else if (iValue > iMax)
{
return iMin;
}
return iValue;
}

[[nodiscard]] static int LoopAroundInArray(const int iValue, const int iSize)
{
return LoopAroundMinMax(iValue, 0, iSize - 1);
}

namespace NeoUI
{

Expand Down
4 changes: 4 additions & 0 deletions mp/src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,8 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version_info.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version_info.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.h
neo/neo_client.cpp
neo/neo_detpack.cpp
neo/neo_detpack.h
Expand All @@ -1345,6 +1347,8 @@ target_sources_grouped(
neo/neo_te_tocflash.cpp
neo/neo_te_tocflash.h
neo/neo_tracefilter_collisiongroupdelta.h
neo/neo_dm_spawn.cpp
neo/neo_dm_spawn.h
)

target_sources_grouped(
Expand Down
7 changes: 7 additions & 0 deletions mp/src/game/server/neo/neo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ bool RespawnWithRet( CBaseEntity *pEdict, bool fCopyCorpse )
{
// respawn player
pPlayer->Spawn();
#if 0
CRecipientFilter filter;
filter.MakeReliable();
filter.AddRecipient(pPlayer);
UserMessageBegin(filter, "IdleRespawnShowMenu");
MessageEnd();
#endif
return true;
}
}
Expand Down
Loading

0 comments on commit fec5d80

Please sign in to comment.