Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Autorelease #4

Open
wants to merge 1 commit into
base: zCatch
Choose a base branch
from
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
11 changes: 9 additions & 2 deletions src/game/server/gamecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ void CGameContext::OnClientEnter(int ClientID)
for(int i = 0; i < MAX_CLIENTS; i++)
if(m_apPlayers[i] && ((leader && m_apPlayers[i]->m_zCatchNumKillsInARow > leader->m_zCatchNumKillsInARow) || (!leader && m_apPlayers[i]->m_zCatchNumKillsInARow)))
leader = m_apPlayers[i];
if(leader)
if(leader && !g_Config.m_SvAutoRelease)
leader->AddZCatchVictim(ClientID, CPlayer::ZCATCH_CAUGHT_REASON_JOINING);
else
p->m_SpecExplicit = false;
Expand All @@ -724,7 +724,7 @@ void CGameContext::OnClientEnter(int ClientID)

/* zCatch begin */
SendChatTarget(ClientID, "Welcome to zCatch! Type /info for more.");
if(g_Config.m_SvAllowJoin == 2 && leader)
if(g_Config.m_SvAllowJoin == 2 && leader && !g_Config.m_SvAutoRelease)
{
char buf[128];
str_format(buf, sizeof(buf), "You will join the game when '%s' dies", Server()->ClientName(leader->GetCID()));
Expand Down Expand Up @@ -1569,6 +1569,12 @@ void CGameContext::ConRestart(IConsole::IResult *pResult, void *pUserData)
pSelf->m_pController->StartRound();
}

void CGameContext::ConEndRound(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
pSelf->m_pController->EndRound();
}

void CGameContext::ConBroadcast(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
Expand Down Expand Up @@ -2016,6 +2022,7 @@ void CGameContext::OnConsoleInit()
Console()->Register("pause", "", CFGFLAG_SERVER, ConPause, this, "Pause/unpause game");
Console()->Register("change_map", "?r", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, "Change map");
Console()->Register("restart", "?i", CFGFLAG_SERVER|CFGFLAG_STORE, ConRestart, this, "Restart in x seconds (0 = abort)");
Console()->Register("end_round", "", CFGFLAG_SERVER|CFGFLAG_STORE, ConEndRound, this, "Ends round");
Console()->Register("broadcast", "r", CFGFLAG_SERVER, ConBroadcast, this, "Broadcast message");
Console()->Register("say", "r", CFGFLAG_SERVER, ConSay, this, "Say in chat");
Console()->Register("set_team", "ii?i", CFGFLAG_SERVER, ConSetTeam, this, "Set team of player to team");
Expand Down
1 change: 1 addition & 0 deletions src/game/server/gamecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CGameContext : public IGameServer
static void ConPause(IConsole::IResult *pResult, void *pUserData);
static void ConChangeMap(IConsole::IResult *pResult, void *pUserData);
static void ConRestart(IConsole::IResult *pResult, void *pUserData);
static void ConEndRound(IConsole::IResult *pResult, void *pUserData);
static void ConBroadcast(IConsole::IResult *pResult, void *pUserData);
static void ConSay(IConsole::IResult *pResult, void *pUserData);
static void ConSetTeam(IConsole::IResult *pResult, void *pUserData);
Expand Down
14 changes: 10 additions & 4 deletions src/game/server/gamemodes/zcatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,16 @@ int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CP
if(pKiller->GetTeam() != TEAM_SPECTATORS)
{
++pKiller->m_zCatchNumKillsInARow;
pKiller->AddZCatchVictim(victim->GetCID(), CPlayer::ZCATCH_CAUGHT_REASON_KILLED);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "You are caught until '%s' dies.", Server()->ClientName(pKiller->GetCID()));
GameServer()->SendChatTarget(victim->GetCID(), aBuf);
if(!g_Config.m_SvAutoRelease) {
pKiller->AddZCatchVictim(victim->GetCID(), CPlayer::ZCATCH_CAUGHT_REASON_KILLED);
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "You are caught until '%s' dies.", Server()->ClientName(pKiller->GetCID()));
GameServer()->SendChatTarget(victim->GetCID(), aBuf);
} else {
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "You were caught by '%s', but auto-released by the server.", Server()->ClientName(pKiller->GetCID()));
GameServer()->SendChatTarget(victim->GetCID(), aBuf);
}
}
}
else
Expand Down
1 change: 1 addition & 0 deletions src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ MACRO_CONFIG_INT(SvKillPenalty, sv_kill_penalty, 5, 0, 50, CFGFLAG_SERVER, "The
// zCatch/TeeVi
MACRO_CONFIG_INT(SvLastStandingPlayers, sv_last_standing_players, 10, 2, 16, CFGFLAG_SERVER, "How many players are needed to have last standing rounds")
MACRO_CONFIG_INT(SvBotDetection, sv_bot_detection, 0, 0, 3, CFGFLAG_SERVER, "Bot detection (0=off, 1=fast aim, 2=follow, 3=all)")
MACRO_CONFIG_INT(SvAutoRelease, sv_auto_release, 0, 0, 1, CFGFLAG_SERVER, "Auto release players (0=off, 1=on)")
#endif