diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/server/entities/character.cpp | 105 | ||||
| -rw-r--r-- | src/game/server/entities/character.h | 3 | ||||
| -rw-r--r-- | src/game/server/entities/laser.cpp | 4 | ||||
| -rw-r--r-- | src/game/server/gamecontext.cpp | 322 | ||||
| -rw-r--r-- | src/game/server/gamecontext.h | 21 | ||||
| -rw-r--r-- | src/game/server/gamecontroller.h | 8 | ||||
| -rw-r--r-- | src/game/server/gamemodes/zcatch.cpp | 252 | ||||
| -rw-r--r-- | src/game/server/gamemodes/zcatch.h | 30 | ||||
| -rw-r--r-- | src/game/server/player.cpp | 87 | ||||
| -rw-r--r-- | src/game/server/player.h | 20 | ||||
| -rw-r--r-- | src/game/variables.h | 25 |
11 files changed, 833 insertions, 44 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 6794429d..d7da2498 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -45,6 +45,7 @@ CCharacter::CCharacter(CGameWorld *pWorld) m_ProximityRadius = ms_PhysSize; m_Health = 0; m_Armor = 0; + m_FreezeTicks = 0; } void CCharacter::Reset() @@ -56,9 +57,29 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) { m_EmoteStop = -1; m_LastAction = -1; + + /*zCatch */ + switch(g_Config.m_SvMode) + { + case 1: + m_ActiveWeapon = WEAPON_RIFLE; + m_LastWeapon = WEAPON_RIFLE; + break; + case 3: + m_ActiveWeapon = WEAPON_HAMMER; + m_LastWeapon = WEAPON_HAMMER; + break; + case 4: + m_ActiveWeapon = WEAPON_GRENADE; + m_LastWeapon = WEAPON_GRENADE; + break; + default: + m_ActiveWeapon = WEAPON_GUN; + m_LastWeapon = WEAPON_HAMMER; + } + /* end zCatch */ + m_LastNoAmmoSound = -1; - m_ActiveWeapon = WEAPON_GUN; - m_LastWeapon = WEAPON_HAMMER; m_QueuedWeapon = -1; m_pPlayer = pPlayer; @@ -116,6 +137,7 @@ void CCharacter::HandleNinja() if(m_ActiveWeapon != WEAPON_NINJA) return; + /* zCatch - Disable for Ninja-Mode if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) { // time's up, return @@ -125,7 +147,8 @@ void CCharacter::HandleNinja() SetWeapon(m_ActiveWeapon); return; } - + */ + // force ninja Weapon SetWeapon(WEAPON_NINJA); @@ -449,6 +472,17 @@ void CCharacter::HandleWeapons() // ammo regen int AmmoRegenTime = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Ammoregentime; + if(m_aWeapons[m_ActiveWeapon].m_Ammo > -1) + { + switch(m_ActiveWeapon) + { + case WEAPON_GUN: AmmoRegenTime = 125*5; break; + case WEAPON_GRENADE: AmmoRegenTime = 1000; break; + case WEAPON_RIFLE: AmmoRegenTime = 1200; break; + case WEAPON_SHOTGUN: AmmoRegenTime = 1000; break; + } + } + if(AmmoRegenTime) { // If equipped and not active, regen ammo? @@ -460,7 +494,7 @@ void CCharacter::HandleWeapons() if ((Server()->Tick() - m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart) >= AmmoRegenTime * Server()->TickSpeed() / 1000) { // Add some ammo - m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, 10); + m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, g_Config.m_SvWeaponsAmmo); m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1; } } @@ -504,6 +538,9 @@ void CCharacter::SetEmote(int Emote, int Tick) void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) { + if(m_FreezeTicks) + return; + // check for changes if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0) m_LastAction = Server()->Tick(); @@ -519,6 +556,9 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput) void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) { + if(m_FreezeTicks) + return; + mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput)); @@ -561,6 +601,23 @@ void CCharacter::Tick() m_Core.m_Input = m_Input; m_Core.Tick(true); + if(m_FreezeTicks) + { + if(Server()->Tick() % Server()->TickSpeed() == 0) + { + GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTicks/Server()->TickSpeed()+1); + GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); + } + //Set weapon back to the last one + if(m_FreezeTicks == 1) + { + m_ActiveWeapon = m_LastWeapon; + GameServer()->SendBroadcast("", m_pPlayer->GetCID()); + } + m_FreezeTicks--; + } + + // handle death-tiles and leaving gamelayer if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || @@ -717,6 +774,8 @@ void CCharacter::Die(int Killer, int Weapon) // this is for auto respawn after 3 secs m_pPlayer->m_DieTick = Server()->Tick(); + // unfreeze the player + m_FreezeTicks = 0; m_Alive = false; GameServer()->m_World.RemoveEntity(this); @@ -730,25 +789,20 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage) return false; + + /* zCatch */ + if(From == m_pPlayer->GetCID() || Weapon == WEAPON_GAME) + return false; - // m_pPlayer only inflicts half damage on self - if(From == m_pPlayer->GetCID()) - Dmg = max(1, Dmg/2); + if(g_Config.m_SvMode == 4 && Weapon == WEAPON_GRENADE && Dmg < g_Config.m_SvGrenadeMinDamage) + return false; + m_Health = 0; + m_Armor = 0; + /* end zCatch */ + m_DamageTaken++; - // create healthmod indicator - if(Server()->Tick() < m_DamageTakenTick+25) - { - // make sure that the damage indicators doesn't group together - GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); - } - else - { - m_DamageTaken = 0; - GameServer()->CreateDamageInd(m_Pos, 0, Dmg); - } - if(Dmg) { if(m_Armor) @@ -862,8 +916,8 @@ void CCharacter::Snap(int SnappingClient) if(m_pPlayer->GetCID() == SnappingClient || SnappingClient == -1 || (!g_Config.m_SvStrictSpectateMode && m_pPlayer->GetCID() == GameServer()->m_apPlayers[SnappingClient]->m_SpectatorID)) { - pCharacter->m_Health = m_Health; - pCharacter->m_Armor = m_Armor; + pCharacter->m_Health = (m_FreezeTicks) ? (m_FreezeTicks/Server()->TickSpeed())/10 : m_Health; + pCharacter->m_Armor = (m_FreezeTicks) ? (m_FreezeTicks/Server()->TickSpeed()) % 10 +1 : m_Armor; if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) pCharacter->m_AmmoCount = m_aWeapons[m_ActiveWeapon].m_Ammo; } @@ -876,3 +930,12 @@ void CCharacter::Snap(int SnappingClient) pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags; } + +void CCharacter::Freeze(int Ticks) +{ + m_FreezeTicks = Ticks; + m_LastWeapon = m_ActiveWeapon; + m_ActiveWeapon = WEAPON_NINJA; + ResetInput(); + GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); +} diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index d799d8a7..8bd1d3da 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -64,6 +64,9 @@ public: bool IsAlive() const { return m_Alive; } class CPlayer *GetPlayer() { return m_pPlayer; } + void Freeze(int Tick); + int m_FreezeTicks; + private: // player controlling this character class CPlayer *m_pPlayer; diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index eb40c4e1..eb1145c5 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -2,6 +2,7 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include <game/generated/protocol.h> #include <game/server/gamecontext.h> +#include <engine/shared/config.h> #include "laser.h" CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner) @@ -67,6 +68,9 @@ void CLaser::DoBounce() m_Energy = -1; GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE); + + if(m_Bounces == 1 && g_Config.m_SvLaserjumps) + GameServer()->CreateExplosion(m_Pos, m_Owner, WEAPON_GAME, false); } } else diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index bab48308..66829db2 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -9,10 +9,11 @@ #include <game/version.h> #include <game/collision.h> #include <game/gamecore.h> -#include "gamemodes/dm.h" +/*#include "gamemodes/dm.h" #include "gamemodes/tdm.h" #include "gamemodes/ctf.h" -#include "gamemodes/mod.h" +#include "gamemodes/mod.h"*/ +#include "gamemodes/zcatch.h" enum { @@ -37,6 +38,9 @@ void CGameContext::Construct(int Resetting) if(Resetting==NO_RESET) m_pVoteOptionHeap = new CHeap(); + + for(int i = 0; i < MAX_MUTES; i++) + m_aMutes[i].m_aIP[0] = 0; } CGameContext::CGameContext(int Resetting) @@ -257,7 +261,8 @@ void CGameContext::SendChat(int ChatterClientID, int Team, const char *pText) // send to the clients for(int i = 0; i < MAX_CLIENTS; i++) { - if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() == Team) + //if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() == Team) + if(m_apPlayers[i] && ChatterClientID >= 0 && ChatterClientID < MAX_CLIENTS && m_apPlayers[ChatterClientID] && m_apPlayers[ChatterClientID]->m_SpecExplicit == m_apPlayers[i]->m_SpecExplicit) Server()->SendPackMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i); } } @@ -447,7 +452,10 @@ void CGameContext::OnTick() bool aVoteChecked[MAX_CLIENTS] = {0}; for(int i = 0; i < MAX_CLIENTS; i++) { - if(!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS || aVoteChecked[i]) // don't count in votes by spectators + /* zCatch - Allow voting from players in spectators (needed or the last 2 players ingame can kick the whole server), + * but deny votes from players who are explicit in spec + */ + if(!m_apPlayers[i] || m_apPlayers[i]->m_SpecExplicit == 1 || aVoteChecked[i]) // don't count in votes by spectators continue; int ActVote = m_apPlayers[i]->m_Vote; @@ -535,6 +543,69 @@ void CGameContext::OnClientEnter(int ClientID) { //world.insert_entity(&players[client_id]); m_apPlayers[ClientID]->Respawn(); + + /* begin zCatch */ + int LeaderID = -1; + int StartTeam = m_pController->ClampTeam(1); + + int Num = 0; + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(IsClientReady(i)) + Num++; + } + if(Num < 3) + m_pController->EndRound(); + + if(g_Config.m_SvAllowJoin == 1) + { + m_apPlayers[ClientID]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT; + m_apPlayers[ClientID]->m_SpecExplicit = (Num < 3) ? 0 : 1; + StartTeam = (Num < 3) ? m_pController->ClampTeam(1) : TEAM_SPECTATORS; + SendBroadcast("You can join the game", ClientID); + } + else if(g_Config.m_SvAllowJoin == 2) + { + int Num2 = 0, PrevNum = 0; + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_apPlayers[i]) + { + Num2 = 0; + for(int j = 0; j < MAX_CLIENTS; j++) + if(m_apPlayers[j] && m_apPlayers[j]->m_CaughtBy == i) + Num2++; + + if(Num2 > PrevNum) + { + LeaderID = i; + PrevNum = Num2; + } + } + } + + if(LeaderID > -1) + { + m_apPlayers[ClientID]->m_CaughtBy = LeaderID; + m_apPlayers[ClientID]->m_SpecExplicit = 0; + m_apPlayers[ClientID]->m_SpectatorID = LeaderID; + StartTeam = TEAM_SPECTATORS; + } + else + { + m_apPlayers[ClientID]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT; + m_apPlayers[ClientID]->m_SpecExplicit = 0; + } + } + else + StartTeam = m_pController->GetAutoTeam(ClientID); + + m_apPlayers[ClientID]->SetTeamDirect(StartTeam); + + /* end zCatch */ + char aBuf[512]; str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientID), m_pController->GetTeamName(m_apPlayers[ClientID]->GetTeam())); SendChat(-1, CGameContext::CHAT_ALL, aBuf); @@ -543,6 +614,18 @@ void CGameContext::OnClientEnter(int ClientID) Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); m_VoteUpdate = true; + + /* zCatch begin */ + SendChatTarget(ClientID, "Welcome to zCatch!"); + SendChatTarget(ClientID, "type /cmdlist to get all commands"); + SendChatTarget(ClientID, "type /help for instructions"); + if(g_Config.m_SvAllowJoin == 2 && LeaderID > -1) + { + char buf[128]; + str_format(buf, sizeof(buf), "You will join the game when %s dies", Server()->ClientName(LeaderID)); + SendChatTarget(ClientID, buf); + } + /* zCatch end */ } void CGameContext::OnClientConnected(int ClientID) @@ -631,7 +714,53 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) pMessage++; } - SendChat(ClientID, Team, pMsg->m_pMessage); + /* begin zCatch*/ + if(!str_comp("/info", pMsg->m_pMessage) || !str_comp("/about", pMsg->m_pMessage)) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "zCatch version %s by erd and Teetime. Type /cmdlist for all commands.", ZCATCH_VERSION); + SendChatTarget(ClientID, " "); + SendChatTarget(ClientID, aBuf); + } + else if(!str_comp("/cmdlist", pMsg->m_pMessage)) + { + SendChatTarget(ClientID, " "); + SendChatTarget(ClientID, "/info or /about - see information about author."); + SendChatTarget(ClientID, "/help - learn how to play."); + } + else if(!str_comp("/help", pMsg->m_pMessage)) + { + SendChatTarget(ClientID, " "); + SendChatTarget(ClientID, "The winner is the tee which is left over at the end."); + SendChatTarget(ClientID, "If you die, all players that you killed will respawn."); + SendChatTarget(ClientID, "So the only way to win is to kill every player without beeing killed."); + SendChatTarget(ClientID, "Have fun!"); + } + else if(!str_comp_num("/", pMsg->m_pMessage, 1)) + SendChatTarget(ClientID, "Unknown command."); + else + { + //Check if muted + int Pos; + if((Pos = Muted(ClientID)) > -1) + { + char aBuf[128]; + int Expires = (m_aMutes[Pos].m_Expires - Server()->Tick())/Server()->TickSpeed(); + str_format(aBuf, sizeof(aBuf), "You are muted for %d minutes and %d seconds.", Expires/60, Expires%60); + SendChatTarget(ClientID, aBuf); + return; + } + //mute the player if he's spamming + else if(g_Config.m_SvMuteDuration && ((pPlayer->m_ChatTicks += g_Config.m_SvChatValue) > g_Config.m_SvChatThreshold)) + { + AddMute(ClientID, g_Config.m_SvMuteDuration, true); + pPlayer->m_ChatTicks = 0; + return; + } + + SendChat(ClientID, Team, pMsg->m_pMessage); + } + /* end zCatch */ } else if(MsgID == NETMSGTYPE_CL_CALLVOTE) { @@ -640,7 +769,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) int64 Now = Server()->Tick(); pPlayer->m_LastVoteTry = Now; - if(pPlayer->GetTeam() == TEAM_SPECTATORS) + // zCatch - Only People who are explicit in Spectators can't vote! + if(pPlayer->m_SpecExplicit == 1) //zCatch { SendChatTarget(ClientID, "Spectators aren't allowed to start a vote."); return; @@ -691,6 +821,11 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) return; } } + else if(g_Config.m_SvVoteForceReason && !pMsg->m_Reason[0]) + { + SendChatTarget(ClientID, "You must give a reason for your vote"); + return; + } else if(str_comp_nocase(pMsg->m_Type, "kick") == 0) { if(!g_Config.m_SvVoteKick) @@ -703,7 +838,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) { int PlayerNum = 0; for(int i = 0; i < MAX_CLIENTS; ++i) - if(m_apPlayers[i] && m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) + if(m_apPlayers[i] && m_apPlayers[i]->m_SpecExplicit != 1) // zCatch - Count all Players who are not explicit in spectator ++PlayerNum; if(PlayerNum < g_Config.m_SvVoteKickMin) @@ -826,14 +961,15 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team)) { pPlayer->m_LastSetTeam = Server()->Tick(); - if(pPlayer->GetTeam() == TEAM_SPECTATORS || pMsg->m_Team == TEAM_SPECTATORS) - m_VoteUpdate = true; pPlayer->SetTeam(pMsg->m_Team); - (void)m_pController->CheckTeamBalance(); - pPlayer->m_TeamChangeTick = Server()->Tick(); } else - SendBroadcast("Teams must be balanced, please join other team", ClientID); + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "You will join automatically when \"%s\" dies.", Server()->ClientName(pPlayer->m_CaughtBy)); + SendChatTarget(ClientID, aBuf); + return; + } } else { @@ -965,7 +1101,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) char aOldName[MAX_NAME_LENGTH]; str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName)); Server()->SetClientName(ClientID, pMsg->m_pName); - if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0) + if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0 && Muted(ClientID) == -1) { char aChatText[256]; str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); @@ -992,14 +1128,96 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) } else if (MsgID == NETMSGTYPE_CL_KILL && !m_World.m_Paused) { - if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) + /* begin zCatch*/ + if(pPlayer->GetTeam() == TEAM_SPECTATORS || (pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*3 > Server()->Tick()) || + (pPlayer->m_LastKillTry+Server()->TickSpeed()*3 > Server()->Tick())) return; - pPlayer->m_LastKill = Server()->Tick(); - pPlayer->KillCharacter(WEAPON_SELF); + if(g_Config.m_SvSuicideTime == 0) + { + SendChatTarget(ClientID, "Suicide is not allowed."); + } + else if(pPlayer->m_LastKill && pPlayer->m_LastKill+Server()->TickSpeed()*g_Config.m_SvSuicideTime > Server()->Tick()) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Only one suicide every %d seconds is allowed.", g_Config.m_SvSuicideTime); + SendChatTarget(ClientID, aBuf); + } + else if(pPlayer->GetCharacter() && pPlayer->GetCharacter()->m_FreezeTicks) + { + SendChatTarget(ClientID, "You can't kill yourself while you're frozen."); + } + else + { + pPlayer->m_LastKill = Server()->Tick(); + pPlayer->KillCharacter(WEAPON_SELF); + pPlayer->m_Deaths++; + return; + } + pPlayer->m_LastKillTry = Server()->Tick(); + /* end zCatch*/ } } +void CGameContext::AddMute(const char* pIP, int Secs) +{ + int Pos = Muted(pIP); + if(Pos > -1) + m_aMutes[Pos].m_Expires = Server()->TickSpeed() * Secs + Server()->Tick(); // overwrite mute + else + for(int i = 0; i < MAX_MUTES; i++) // find free slot + if(!m_aMutes[i].m_aIP[0]) + { + str_copy(m_aMutes[i].m_aIP, pIP, sizeof(m_aMutes[i].m_aIP)); + m_aMutes[i].m_Expires = Server()->TickSpeed() * Secs + Server()->Tick(); + break; + } +} + +void CGameContext::AddMute(int ClientID, int Secs, bool Auto) +{ + char aAddrStr[NETADDR_MAXSTRSIZE] = {0}; + Server()->GetClientAddr(ClientID, aAddrStr, sizeof(aAddrStr)); + AddMute(aAddrStr, Secs); + + char aBuf[128]; + if(Secs > 0) + str_format(aBuf, sizeof(aBuf), "%s has been %smuted for %d min and %d sec.", Server()->ClientName(ClientID), Auto ? "auto-" : "", Secs/60, Secs%60); + else + str_format(aBuf, sizeof(aBuf), "%s has been unmuted.", Server()->ClientName(ClientID)); + Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); + SendChatTarget(-1, aBuf); +} + +int CGameContext::Muted(const char *pIP) +{ + CleanMutes(); + int Pos = -1; + if(!pIP[0]) + return -1; + for(int i = 0; i < MAX_MUTES; i++) + if(!str_comp_num(pIP, m_aMutes[i].m_aIP, sizeof(m_aMutes[i].m_aIP))) + { + Pos = i; + break; + } + return Pos; +} + +int CGameContext::Muted(int ClientID) +{ + char aIP[NETADDR_MAXSTRSIZE] = {0}; + Server()->GetClientAddr(ClientID, aIP, sizeof(aIP)); + return Muted(aIP); +} + +void CGameContext::CleanMutes() +{ + for(int i = 0; i < MAX_MUTES; i++) + if(m_aMutes[i].m_Expires < Server()->Tick()) + m_aMutes[i].m_aIP[0] = 0; +} + void CGameContext::ConTuneParam(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; @@ -1418,6 +1636,66 @@ void CGameContext::ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *p } } +void CGameContext::ConMute(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int CID = pResult->GetInteger(0); + if(CID < 0 || CID >= MAX_CLIENTS || !pSelf->m_apPlayers[CID]) + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "Invalid ClientID"); + else + pSelf->AddMute(CID, pResult->GetInteger(1)); +} + +void CGameContext::ConMutes(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + char aBuf[128]; + int Sec, Count = 0; + pSelf->CleanMutes(); + for(int i = 0; i < MAX_MUTES; i++) + { + if(pSelf->m_aMutes[i].m_aIP[0] == 0) + continue; + + Sec = (pSelf->m_aMutes[i].m_Expires - pSelf->Server()->Tick())/pSelf->Server()->TickSpeed(); + str_format(aBuf, sizeof(aBuf), "#%d: %s for %d minutes and %d sec", i, pSelf->m_aMutes[i].m_aIP, Sec/60, Sec%60); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); + Count++; + } + str_format(aBuf, sizeof(aBuf), "%d mute(s)", Count); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); +} + +void CGameContext::ConUnmuteID(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int CID = pResult->GetInteger(0); + if(CID < 0 || CID >= MAX_CLIENTS || !pSelf->m_apPlayers[CID]) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "Invalid ClientID"); + } + else + pSelf->AddMute(CID, 0); +} + +void CGameContext::ConUnmuteIP(IConsole::IResult *pResult, void *pUserData) +{ + CGameContext *pSelf = (CGameContext *)pUserData; + int MuteID = pResult->GetInteger(0); + char aBuf[128]; + + if(MuteID < 0 || MuteID >= MAX_MUTES || pSelf->Muted(pSelf->m_aMutes[MuteID].m_aIP) == -1) + { + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", "mute not found"); + } + else + { + str_format(aBuf, sizeof(aBuf), "unmuted %s", pSelf->m_aMutes[MuteID].m_aIP); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Server", aBuf); + pSelf->AddMute(pSelf->m_aMutes[MuteID].m_aIP, 0); + } +} + void CGameContext::OnConsoleInit() { m_pServer = Kernel()->RequestInterface<IServer>(); @@ -1444,6 +1722,11 @@ void CGameContext::OnConsoleInit() Console()->Register("clear_votes", "", CFGFLAG_SERVER, ConClearVotes, this, "Clears the voting options"); Console()->Register("vote", "r", CFGFLAG_SERVER, ConVote, this, "Force a vote to yes/no"); + Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "Mutes a player for x sec"); + Console()->Register("unmuteid", "i", CFGFLAG_SERVER, ConUnmuteID, this, "Unmutes a player by its client id"); + Console()->Register("unmuteip", "i", CFGFLAG_SERVER, ConUnmuteIP, this, "Removes a mute by its index"); + Console()->Register("mutes", "", CFGFLAG_SERVER, ConMutes, this, "Show all mutes"); + Console()->Chain("sv_motd", ConchainSpecialMotdupdate, this); } @@ -1468,14 +1751,17 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/) //players = new CPlayer[MAX_CLIENTS]; // select gametype - if(str_comp(g_Config.m_SvGametype, "mod") == 0) + /*if(str_comp(g_Config.m_SvGametype, "mod") == 0) m_pController = new CGameControllerMOD(this); else if(str_comp(g_Config.m_SvGametype, "ctf") == 0) m_pController = new CGameControllerCTF(this); else if(str_comp(g_Config.m_SvGametype, "tdm") == 0) m_pController = new CGameControllerTDM(this); + else if(str_comp_nocase(g_Config.m_SvGametype, "zcatch") == 0) + m_pController = new CGameController_zCatch(this); else - m_pController = new CGameControllerDM(this); + m_pController = new CGameControllerDM(this);*/ + m_pController = new CGameController_zCatch(this); // setup core world //for(int i = 0; i < MAX_CLIENTS; i++) diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 2ffb0ab4..5d340613 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -15,6 +15,9 @@ #include "gameworld.h" #include "player.h" +#define MAX_MUTES 35 +#define ZCATCH_VERSION "0.4.8 BETA" + /* Tick Game Context (CGameContext::tick) @@ -64,6 +67,11 @@ class CGameContext : public IGameServer static void ConClearVotes(IConsole::IResult *pResult, void *pUserData); static void ConVote(IConsole::IResult *pResult, void *pUserData); static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); + + static void ConMute(IConsole::IResult *pResult, void *pUserData); + static void ConUnmuteID(IConsole::IResult *pResult, void *pUserData); + static void ConUnmuteIP(IConsole::IResult *pResult, void *pUserData); + static void ConMutes(IConsole::IResult *pResult, void *pUserData); CGameContext(int Resetting); void Construct(int Resetting); @@ -134,6 +142,19 @@ public: CHAT_RED=0, CHAT_BLUE=1 }; + + struct CMutes + { + char m_aIP[NETADDR_MAXSTRSIZE]; + int m_Expires; + }; + CMutes m_aMutes[MAX_MUTES]; + // helper functions + void AddMute(const char* pIP, int Secs); + void AddMute(int ClientID, int Secs, bool Auto = false); + int Muted(const char *pIP); + int Muted(int ClientID); + void CleanMutes(); // network void SendChatTarget(int To, const char *pText); diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index 1675fe35..fbf6ae79 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -12,13 +12,13 @@ */ class IGameController { +protected: vec2 m_aaSpawnPoints[3][64]; int m_aNumSpawnPoints[3]; class CGameContext *m_pGameServer; class IServer *m_pServer; -protected: CGameContext *GameServer() const { return m_pGameServer; } IServer *Server() const { return m_pServer; } @@ -73,8 +73,8 @@ public: void DoWarmup(int Seconds); - void StartRound(); - void EndRound(); + virtual void StartRound(); + virtual void EndRound(); void ChangeMap(const char *pToMap); bool IsFriendlyFire(int ClientID1, int ClientID2); @@ -138,7 +138,7 @@ public: virtual int GetAutoTeam(int NotThisID); virtual bool CanJoinTeam(int Team, int NotThisID); bool CheckTeamBalance(); - bool CanChangeTeam(CPlayer *pPplayer, int JoinTeam); + virtual bool CanChangeTeam(CPlayer *pPlayer, int JoinTeam); int ClampTeam(int Team); virtual void PostReset(); diff --git a/src/game/server/gamemodes/zcatch.cpp b/src/game/server/gamemodes/zcatch.cpp new file mode 100644 index 00000000..9bf12374 --- /dev/null +++ b/src/game/server/gamemodes/zcatch.cpp @@ -0,0 +1,252 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +/* zCatch by erd and Teetime */ + +#include <engine/shared/config.h> +#include <game/server/gamecontext.h> +#include <game/server/gamecontroller.h> +#include <game/server/entities/character.h> +#include <game/server/player.h> +#include "zcatch.h" + +CGameController_zCatch::CGameController_zCatch(class CGameContext *pGameServer) : + IGameController(pGameServer) +{ + m_pGameType = "zCatch"; + m_OldMode = g_Config.m_SvMode; +} + +void CGameController_zCatch::Tick() +{ + IGameController::Tick(); + if(m_GameOverTick == -1) + CalcPlayerColor(); + + if(m_OldMode != g_Config.m_SvMode) + { + Server()->MapReload(); + m_OldMode = g_Config.m_SvMode; + } +} + +void CGameController_zCatch::DoWincheck() +{ + if(m_GameOverTick == -1) + { + int Players = 0, Players_Spec = 0, Players_SpecExplicit = 0; + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i]) + { + Players++; + if(GameServer()->m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) + Players_Spec++; + if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 1) + Players_SpecExplicit++; + } + } + + if(Players == 1) + { + //Do nothing + } + else if((Players - Players_Spec == 1) && (Players != Players_Spec) && (Players - Players_SpecExplicit != 1)) + { + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS) + GameServer()->m_apPlayers[i]->m_Score += g_Config.m_SvBonus; + } + EndRound(); + } + + IGameController::DoWincheck(); //do also usual wincheck + } +} + +int CGameController_zCatch::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID) +{ + if(!pKiller) + return 0; + + int VictimID = pVictim->GetPlayer()->GetCID(); + + if(pKiller != pVictim->GetPlayer()) + { + pKiller->m_Kills++; + pVictim->GetPlayer()->m_Deaths++; + + pKiller->m_Score++; + + /* Check if the killer is already killed and in spectator (victim may died through wallshot) */ + if(pKiller->GetTeam() != TEAM_SPECTATORS) + { + pVictim->GetPlayer()->m_CaughtBy = pKiller->GetCID(); + pVictim->GetPlayer()->SetTeamDirect(TEAM_SPECTATORS); + + pVictim->GetPlayer()->m_SpectatorID = pKiller->GetCID(); // Let the victim follow his catcher + + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "Caught by \"%s\". You will join the game automatically when \"%s\" dies.", Server()->ClientName(pKiller->GetCID()), Server()->ClientName(pKiller->GetCID())); + GameServer()->SendChatTarget(VictimID, aBuf); + } + } + else + { + //Punish selfkill/death + if(WeaponID == WEAPON_SELF || WeaponID == WEAPON_WORLD) + pVictim->GetPlayer()->m_Score -= g_Config.m_SvKillPenalty; + } + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i]) + { + if(GameServer()->m_apPlayers[i]->m_CaughtBy == VictimID) + { + GameServer()->m_apPlayers[i]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT; + GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1)); + + if(pKiller != pVictim->GetPlayer()) + pKiller->m_Score++; + } + } + } + + // Update colors + OnPlayerInfoChange(pVictim->GetPlayer()); + + return 0; +} + +void CGameController_zCatch::OnPlayerInfoChange(class CPlayer *pP) +{ + if(g_Config.m_SvColorIndicator) + { + int Num = 161; + for(int i = 0; i < MAX_CLIENTS; i++) + if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_CaughtBy == pP->GetCID()) + Num -= 10; + pP->m_TeeInfos.m_ColorBody = Num * 0x010000 + 0xff00; + pP->m_TeeInfos.m_ColorFeet = Num * 0x010000 + 0xff00; + pP->m_TeeInfos.m_UseCustomColor = 1; + } +} + +void CGameController_zCatch::StartRound() +{ + IGameController::StartRound(); + + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i]) + { + GameServer()->m_apPlayers[i]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT; + GameServer()->m_apPlayers[i]->m_Kills = 0; + GameServer()->m_apPlayers[i]->m_Deaths = 0; + GameServer()->m_apPlayers[i]->m_TicksSpec = 0; + GameServer()->m_apPlayers[i]->m_TicksIngame = 0; + } + } +} + +void CGameController_zCatch::OnCharacterSpawn(class CCharacter *pChr) +{ + // default health and armor + pChr->IncreaseHealth(10); + if(g_Config.m_SvMode == 2) + pChr->IncreaseArmor(10); + + // give default weapons + switch(g_Config.m_SvMode) + { + case 1: /* Instagib - Only Riffle */ + pChr->GiveWeapon(WEAPON_RIFLE, -1); + break; + case 2: /* All Weapons */ + pChr->GiveWeapon(WEAPON_HAMMER, -1); + pChr->GiveWeapon(WEAPON_GUN, g_Config.m_SvWeaponsAmmo); + pChr->GiveWeapon(WEAPON_GRENADE, g_Config.m_SvWeaponsAmmo); + pChr->GiveWeapon(WEAPON_SHOTGUN, g_Config.m_SvWeaponsAmmo); + pChr->GiveWeapon(WEAPON_RIFLE, g_Config.m_SvWeaponsAmmo); + break; + case 3: /* Hammer */ + pChr->GiveWeapon(WEAPON_HAMMER, -1); + break; + case 4: /* Grenade */ + pChr->GiveWeapon(WEAPON_GRENADE, g_Config.m_SvGrenadeEndlessAmmo ? -1 : g_Config.m_SvWeaponsAmmo); + break; + case 5: /* Ninja */ + pChr->GiveNinja(); + break; + } + + //Update color of spawning tees + OnPlayerInfoChange(pChr->GetPlayer()); +} + +void CGameController_zCatch::EndRound() +{ + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(GameServer()->m_apPlayers[i]) + { + + if(GameServer()->m_apPlayers[i]->m_SpecExplicit == 0) + { + GameServer()->m_apPlayers[i]->SetTeamDirect(GameServer()->m_pController->ClampTeam(1)); + + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "Kills: %d | Deaths: %d", GameServer()->m_apPlayers[i]->m_Kills, GameServer()->m_apPlayers[i]->m_Deaths); + GameServer()->SendChatTarget(i, aBuf); + + if(GameServer()->m_apPlayers[i]->m_TicksSpec != 0 || GameServer()->m_apPlayers[i]->m_TicksIngame != 0) + { + double TimeInSpec = (GameServer()->m_apPlayers[i]->m_TicksSpec * 100.0) / (GameServer()->m_apPlayers[i]->m_TicksIngame + GameServer()->m_apPlayers[i]->m_TicksSpec); + str_format(aBuf, sizeof(aBuf), "Spec: %.2f%% | Ingame: %.2f%%", (double) TimeInSpec, (double) (100.0 - TimeInSpec)); + GameServer()->SendChatTarget(i, aBuf); + } + GameServer()->m_apPlayers[i]->m_CaughtBy = CPlayer::ZCATCH_NOT_CAUGHT; //Set all players in server as non-caught + } + } + } + + if(m_Warmup) // game can't end when we are running warmup + return; + + GameServer()->m_World.m_Paused = true; + m_GameOverTick = Server()->Tick(); + m_SuddenDeath = 0; +} + +bool CGameController_zCatch::CanChangeTeam(CPlayer *pPlayer, int JoinTeam) +{ + if(pPlayer->m_CaughtBy >= 0) + return false; + return true; +} + +bool CGameController_zCatch::OnEntity(int Index, vec2 Pos) +{ + if(Index == ENTITY_SPAWN) + m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos; + else if(Index == ENTITY_SPAWN_RED) + m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos; + else if(Index == ENTITY_SPAWN_BLUE) + m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos; + + return false; +} + +void CGameController_zCatch::CalcPlayerColor() +{ + for(int i = 0; i < MAX_CLIENTS; i++) + { + CPlayer *pP = GameServer()->m_apPlayers[i]; + if(!pP) + continue; + if(pP->GetTeam() != TEAM_SPECTATORS) + OnPlayerInfoChange(pP); + } +} diff --git a/src/game/server/gamemodes/zcatch.h b/src/game/server/gamemodes/zcatch.h new file mode 100644 index 00000000..af776644 --- /dev/null +++ b/src/game/server/gamemodes/zcatch.h @@ -0,0 +1,30 @@ +/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ +/* If you are missing that file, acquire a complete release at teeworlds.com. */ +/* zCatch by erd and Teetime */ + +#ifndef GAME_SERVER_GAMEMODES_ZCATCH_H +#define GAME_SERVER_GAMEMODES_ZCATCH_H + +#include <game/server/gamecontroller.h> + +class CGameController_zCatch: public IGameController +{ + int m_OldMode; + +public: + CGameController_zCatch(class CGameContext *pGameServer); + virtual void Tick(); + virtual void DoWincheck(); + + virtual void StartRound(); + virtual void OnCharacterSpawn(class CCharacter *pChr); + virtual void OnPlayerInfoChange(class CPlayer *pP); + virtual int OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int WeaponID); + virtual bool OnEntity(int Index, vec2 Pos); + virtual bool CanChangeTeam(CPlayer *pPlayer, int JoinTeam); + virtual void EndRound(); + + void CalcPlayerColor(); +}; + +#endif diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 4b37385f..7e07c07f 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -21,6 +21,16 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team) m_SpectatorID = SPEC_FREEVIEW; m_LastActionTick = Server()->Tick(); m_TeamChangeTick = Server()->Tick(); + + //zCatch + m_CaughtBy = -1; + m_SpecExplicit = 0; + m_Kills = 0; + m_Deaths = 0; + m_LastKillTry = Server()->Tick(); + m_TicksSpec = 0; + m_TicksIngame = 0; + m_ChatTicks = 0; } CPlayer::~CPlayer() @@ -38,6 +48,20 @@ void CPlayer::Tick() return; Server()->SetClientScore(m_ClientID, m_Score); + + /* begin zCatch*/ + + if(m_Team == TEAM_SPECTATORS) + m_TicksSpec++; + else + m_TicksIngame++; + + if(m_ChatTicks > 0) + m_ChatTicks--; + + if((g_Config.m_SvAnticamper == 2 && g_Config.m_SvMode == 1) || (g_Config.m_SvAnticamper == 1)) + Anticamper(); + /* end zCatch*/ // do latency stuff { @@ -179,6 +203,9 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput) if((m_PlayerFlags&PLAYERFLAG_CHATTING) && (NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)) return; + if(m_pCharacter && m_pCharacter->m_FreezeTicks) + return; + if(m_pCharacter) m_pCharacter->OnPredictedInput(NewInput); } @@ -204,6 +231,9 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) if(m_pCharacter) m_pCharacter->OnDirectInput(NewInput); + if(m_pCharacter && m_pCharacter->m_FreezeTicks) + return; + if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1)) m_Spawning = true; @@ -275,7 +305,15 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->m_SpectatorID == m_ClientID) GameServer()->m_apPlayers[i]->m_SpectatorID = SPEC_FREEVIEW; } + m_SpecExplicit = 1; } + else + m_SpecExplicit = 0; +} + +void CPlayer::SetTeamDirect(int Team) +{ + m_Team = Team; } void CPlayer::TryRespawn() @@ -290,3 +328,52 @@ void CPlayer::TryRespawn() m_pCharacter->Spawn(this, SpawnPos); GameServer()->CreatePlayerSpawn(SpawnPos); } + +int CPlayer::Anticamper() +{ + if(GameServer()->m_World.m_Paused || !m_pCharacter || m_Team == TEAM_SPECTATORS || m_pCharacter->m_FreezeTicks) + { + m_CampTick = -1; + m_SentCampMsg = false; + return 0; + } + + int AnticamperTime = g_Config.m_SvAnticamperTime; + int AnticamperRange = g_Config.m_SvAnticamperRange; + + if(m_CampTick == -1) + { + m_CampPos = m_pCharacter->m_Pos; + m_CampTick = Server()->Tick() + Server()->TickSpeed()*AnticamperTime; + } + + // Check if the player is moving + if((m_CampPos.x - m_pCharacter->m_Pos.x >= (float)AnticamperRange || m_CampPos.x - m_pCharacter->m_Pos.x <= -(float)AnticamperRange) + || (m_CampPos.y - m_pCharacter->m_Pos.y >= (float)AnticamperRange || m_CampPos.y - m_pCharacter->m_Pos.y <= -(float)AnticamperRange)) + { + m_CampTick = -1; + } + + // Send warning to the player + if(m_CampTick <= Server()->Tick() + Server()->TickSpeed() * AnticamperTime/2 && m_CampTick != -1 && !m_SentCampMsg) + { + GameServer()->SendBroadcast("ANTICAMPER: Move or die", m_ClientID); + m_SentCampMsg = true; + } + + // Kill him + if((m_CampTick <= Server()->Tick()) && (m_CampTick > 0)) + { + if(g_Config.m_SvAnticamperFreeze) + { + m_pCharacter->Freeze(Server()->TickSpeed()*g_Config.m_SvAnticamperFreeze); + GameServer()->SendBroadcast("You have been freezed due camping", m_ClientID); + } + else + m_pCharacter->Die(m_ClientID, WEAPON_GAME); + m_CampTick = -1; + m_SentCampMsg = false; + return 1; + } + return 0; +} diff --git a/src/game/server/player.h b/src/game/server/player.h index dd804a95..a19209a8 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -21,6 +21,7 @@ public: void TryRespawn(); void Respawn(); void SetTeam(int Team, bool DoChatMsg=true); + void SetTeamDirect(int Team); //zCatch int GetTeam() const { return m_Team; }; int GetCID() const { return m_ClientID; }; @@ -95,7 +96,24 @@ public: int m_Min; int m_Max; } m_Latency; - + + //zCatch: + enum { ZCATCH_NOT_CAUGHT = -1 }; + int m_CaughtBy; + int m_SpecExplicit; + int m_Deaths; + int m_Kills; + int m_LastKillTry; + + int m_TicksSpec; + int m_TicksIngame; + int m_ChatTicks; + //Anticamper + int Anticamper(); + bool m_SentCampMsg; + int m_CampTick; + vec2 m_CampPos; + private: CCharacter *m_pCharacter; CGameContext *m_pGameServer; diff --git a/src/game/variables.h b/src/game/variables.h index e57a0954..3a1fb419 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -90,4 +90,29 @@ MACRO_CONFIG_INT(SvVoteKickBantime, sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SE MACRO_CONFIG_INT(DbgFocus, dbg_focus, 0, 0, 1, CFGFLAG_CLIENT, "") MACRO_CONFIG_INT(DbgTuning, dbg_tuning, 0, 0, 1, CFGFLAG_CLIENT, "") + +//zCatch: +MACRO_CONFIG_INT(SvMode, sv_mode, 1, 1, 5, CFGFLAG_SERVER, "1 - Instagib; 2 - Everything; 3 - Hammerparty; 4 - Grenade; 5 - Ninja") +MACRO_CONFIG_INT(SvAllowJoin, sv_allow_join, 2, 1, 2, CFGFLAG_SERVER, "Allow new Players to join without waiting for the next round") +//1 = Allowed to join; 2 = Will join when person with the most kills die +MACRO_CONFIG_INT(SvColorIndicator, sv_color_indicator, 1, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently caught players") +MACRO_CONFIG_INT(SvBonus, sv_bonus, 0, 0, 100, CFGFLAG_SERVER, "Give the last player extra points") +MACRO_CONFIG_INT(SvLaserjumps, sv_laserjumps, 0, 0, 1, CFGFLAG_SERVER, "Use laserjumps - on a laser bounce a explosion will occur which takes no damage") + +MACRO_CONFIG_INT(SvChatValue, sv_chat_value, 250, 100, 1000, CFGFLAG_SERVER, "A value which is added on each message and decreased on each tick") +MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 250, 10000, CFGFLAG_SERVER, "If this threshold will exceed by too many messages the player will be muted") +MACRO_CONFIG_INT(SvMuteDuration, sv_mute_duration, 60, 0, 3600, CFGFLAG_SERVER, "How long the player will be muted (in seconds)") + +MACRO_CONFIG_INT(SvAnticamper, sv_anticamper, 2, 0, 2, CFGFLAG_SERVER, "0 disables, 1 enables anticamper in all modes and 2 only in Instagib") +MACRO_CONFIG_INT(SvAnticamperFreeze, sv_anticamper_freeze, 7, 0, 15, CFGFLAG_SERVER, "If a player should freeze on camping (and how long) or die") +MACRO_CONFIG_INT(SvAnticamperTime, sv_anticamper_time, 10, 5, 120, CFGFLAG_SERVER, "How long to wait till the player dies/freezes") +MACRO_CONFIG_INT(SvAnticamperRange, sv_anticamper_range, 200, 0, 1000, CFGFLAG_SERVER, "Distance how far away the player must move to escape anticamper") + +MACRO_CONFIG_INT(SvGrenadeMinDamage, sv_grenade_min_damage, 4, 1, 6, CFGFLAG_SERVER, "How much damage the grenade must do to kill the player (depends how far away it explodes)") +MACRO_CONFIG_INT(SvGrenadeEndlessAmmo, sv_grenade_endless_ammo, 1, 0, 1, CFGFLAG_SERVER, "Endless ammo for grenade (only mode 4). If not zero, set sv_grenade_bullets for the number of bullets") +MACRO_CONFIG_INT(SvWeaponsAmmo, sv_weapons_ammo, 7, 5, 10, CFGFLAG_SERVER, "Default amount of ammo for all weapons in mode 2 or grenade in mode 4. Your ammo will regenerate after some while") + +MACRO_CONFIG_INT(SvVoteForceReason, sv_vote_forcereason, 1, 0, 1, CFGFLAG_SERVER, "Allow only votes with a reason (except settings)") +MACRO_CONFIG_INT(SvSuicideTime, sv_suicide_time, 15, 0, 60, CFGFLAG_SERVER, "Minimum time between suicides. 0 to forbid suicides completely") +MACRO_CONFIG_INT(SvKillPenalty, sv_kill_penalty, 5, 0, 50, CFGFLAG_SERVER, "The amount of points which the score will be decreased on each suicide") #endif |