Merge pull request #7969 from bencie/add-deep-solo

Add /solo and /deep as practice commands
This commit is contained in:
Dennis Felsing 2024-02-12 16:40:30 +00:00 committed by GitHub
commit 76aeb8e781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 0 deletions

View file

@ -1783,6 +1783,35 @@ void CGameContext::ConPracticeUnSolo(IConsole::IResult *pResult, void *pUserData
pChr->SetSolo(false);
}
void CGameContext::ConPracticeSolo(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if(!pPlayer)
return;
CCharacter *pChr = pPlayer->GetCharacter();
if(!pChr)
return;
if(g_Config.m_SvTeam == SV_TEAM_FORBIDDEN || g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
{
pSelf->SendChatTarget(pPlayer->GetCID(), "Command is not available on solo servers");
return;
}
CGameTeams &Teams = pSelf->m_pController->Teams();
int Team = pSelf->GetDDRaceTeam(pResult->m_ClientID);
if(!Teams.IsPractice(Team))
{
pSelf->SendChatTarget(pPlayer->GetCID(), "You're not in a team with /practice turned on. Note that you can't earn a rank with practice enabled.");
return;
}
pChr->SetSolo(true);
}
void CGameContext::ConPracticeUnDeep(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
@ -1807,6 +1836,29 @@ void CGameContext::ConPracticeUnDeep(IConsole::IResult *pResult, void *pUserData
pChr->UnFreeze();
}
void CGameContext::ConPracticeDeep(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!CheckClientID(pResult->m_ClientID))
return;
CPlayer *pPlayer = pSelf->m_apPlayers[pResult->m_ClientID];
if(!pPlayer)
return;
CCharacter *pChr = pPlayer->GetCharacter();
if(!pChr)
return;
CGameTeams &Teams = pSelf->m_pController->Teams();
int Team = pSelf->GetDDRaceTeam(pResult->m_ClientID);
if(!Teams.IsPractice(Team))
{
pSelf->SendChatTarget(pPlayer->GetCID(), "You're not in a team with /practice turned on. Note that you can't earn a rank with practice enabled.");
return;
}
pChr->SetDeepFrozen(true);
}
void CGameContext::ConProtectedKill(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;

View file

@ -3652,7 +3652,9 @@ void CGameContext::RegisterChatCommands()
Console()->Register("tc", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeleCursor, this, "Teleport yourself to player or to where you are spectating/or looking if no player name is given");
Console()->Register("telecursor", "?r[player name]", CFGFLAG_CHAT | CFGFLAG_SERVER, ConTeleCursor, this, "Teleport yourself to player or to where you are spectating/or looking if no player name is given");
Console()->Register("unsolo", "", CFGFLAG_CHAT, ConPracticeUnSolo, this, "Puts you out of solo part");
Console()->Register("solo", "", CFGFLAG_CHAT, ConPracticeSolo, this, "Puts you into solo part");
Console()->Register("undeep", "", CFGFLAG_CHAT, ConPracticeUnDeep, this, "Puts you out of deep freeze");
Console()->Register("deep", "", CFGFLAG_CHAT, ConPracticeDeep, this, "Puts you into deep freeze");
Console()->Register("kill", "", CFGFLAG_CHAT | CFGFLAG_SERVER, ConProtectedKill, this, "Kill yourself when kill-protected during a long game (use f1, kill for regular kill)");
}

View file

@ -463,7 +463,9 @@ private:
static void ConTeleCursor(IConsole::IResult *pResult, void *pUserData);
static void ConLastTele(IConsole::IResult *pResult, void *pUserData);
static void ConPracticeUnSolo(IConsole::IResult *pResult, void *pUserData);
static void ConPracticeSolo(IConsole::IResult *pResult, void *pUserData);
static void ConPracticeUnDeep(IConsole::IResult *pResult, void *pUserData);
static void ConPracticeDeep(IConsole::IResult *pResult, void *pUserData);
static void ConProtectedKill(IConsole::IResult *pResult, void *pUserData);
static void ConVoteMute(IConsole::IResult *pResult, void *pUserData);