StickyTeams, TeamStrict Logic and fixed some team bugs

This commit is contained in:
GreYFoXGTi 2011-02-14 20:36:30 +02:00
parent 29c9bf531d
commit d68e853ca7
6 changed files with 53 additions and 19 deletions

View file

@ -166,6 +166,7 @@ MACRO_CONFIG_STR(SvRulesLine10, sv_rules_line10, 40, "", CFGFLAG_SERVER, "Rules
MACRO_CONFIG_INT(SvTeam, sv_team, 0, -1, 1, CFGFLAG_SERVER, "Teams configuration", 4)
MACRO_CONFIG_INT(SvTeamStrict, sv_team_strict, 0, 0, 1, CFGFLAG_SERVER, "Kill or not all team if someone left game in team", 4)
MACRO_CONFIG_INT(SvStickyTeams, sv_sticky_teams, 1, 0, 1, CFGFLAG_SERVER, "Whether players stays in a team after death or not", 4)
MACRO_CONFIG_STR(SvAnnouncementFileName, sv_announcement_filename, 24, "announcement.txt", CFGFLAG_SERVER, "file which will have the announcement, each one at a line", 3)
MACRO_CONFIG_INT(SvAnnouncementInterval, sv_announcement_interval, 30, 15, 9999, CFGFLAG_SERVER, "time(minutes) in which the announcement will be displayed from the announcement file", 3)
@ -206,4 +207,5 @@ MACRO_CONFIG_INT(SvChatPenalty, sv_chat_penalty, 250, 50, 1000, CFGFLAG_SERVER,
MACRO_CONFIG_INT(SvChatThreshold, sv_chat_threshold, 1000, 50, 10000 , CFGFLAG_SERVER, "if chatscore exceeds this, the player will be muted for sv_spam_mute_duration seconds", 3)
MACRO_CONFIG_INT(SvSpamMuteDuration, sv_spam_mute_duration, 60, 0, 3600 , CFGFLAG_SERVER, "how many seconds to mute, if player triggers mute on spam. 0 = off", 3)
#endif

View file

@ -687,7 +687,7 @@ void CGameContext::ConKill(IConsole::IResult *pResult, void *pUserData, int Clie
CGameContext *pSelf = (CGameContext *)pUserData;
CPlayer *pPlayer = pSelf->m_apPlayers[ClientID];
if(pPlayer->m_Last_Kill && pPlayer->m_Last_Kill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick())
if(!pPlayer || (pPlayer->m_Last_Kill && pPlayer->m_Last_Kill + pSelf->Server()->TickSpeed() * g_Config.m_SvKillDelay > pSelf->Server()->Tick()))
return;
pPlayer->m_Last_Kill = pSelf->Server()->Tick();

View file

@ -756,15 +756,15 @@ void CCharacter::Die(int Killer, int Weapon)
m_pPlayer->m_DieTick = Server()->Tick();
m_Alive = false;
MarkDestroy();
//GameServer()->m_World.RemoveEntity(this);
MarkDestroy();
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID(), Teams()->TeamMask(Team()));
// we got to wait 0.5 secs before respawning
m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.SetForceCharacterTeam(m_pPlayer->GetCID(), 0);
Teams()->OnCharacterDeath(m_pPlayer->GetCID());
}
bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)

View file

@ -43,8 +43,8 @@ void CGameTeams::OnCharacterStart(int ClientID)
{
if(Team == m_Core.Team(i))
{
CCharacter* Char = Character(i);
if(Char->m_DDRaceState == DDRACE_FINISHED)
CCharacter* pChar = Character(i);
if(pChar && pChar->IsAlive() && pChar->m_DDRaceState == DDRACE_FINISHED)
{
Waiting = true;
if(m_LastChat[ClientID] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
@ -62,6 +62,17 @@ void CGameTeams::OnCharacterStart(int ClientID)
m_LastChat[i] = Tick;
}
}
else if(pChar && pChar->IsAlive() && pChar->m_DDRaceState == DDRACE_STARTED)
{
Waiting = true;
if(m_LastChat[ClientID] + Server()->TickSpeed() + g_Config.m_SvChatDelay < Tick)
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s has started, wait for him, ask him to kill or join another team.", Server()->ClientName(i));
GameServer()->SendChatTarget(ClientID, aBuf);
m_LastChat[ClientID] = Tick;
}
}
}
}
@ -72,12 +83,12 @@ void CGameTeams::OnCharacterStart(int ClientID)
{
if(Team == m_Core.Team(i))
{
CCharacter* Char = Character(i);
if(Char)
CCharacter* pChar = Character(i);
if(pChar && pChar->IsAlive())
{
Char->m_DDRaceState = DDRACE_STARTED;
Char->m_StartTime = Tick;
Char->m_RefreshTime = Tick;
pChar->m_DDRaceState = DDRACE_STARTED;
pChar->m_StartTime = Tick;
pChar->m_RefreshTime = Tick;
}
}
}
@ -102,10 +113,10 @@ void CGameTeams::OnCharacterFinish(int ClientID)
{
if(Team == m_Core.Team(i))
{
CCharacter * Char = Character(i);
if(Char != 0)
CCharacter * pChar = Character(i);
if(pChar != 0 && pChar->m_DDRaceState == DDRACE_STARTED)
{
Char->OnFinish();
pChar->OnFinish();
m_TeeFinished[i] = false;
}
}
@ -115,6 +126,23 @@ void CGameTeams::OnCharacterFinish(int ClientID)
}
}
void CGameTeams::OnCharacterDeath(int ClientID)
{
if(g_Config.m_SvTeamStrict && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
for(int LoopClientID = 0; LoopClientID < MAX_CLIENTS; ++LoopClientID)
{
if(m_Core.Team(ClientID) == m_Core.Team(LoopClientID))
{
CCharacter* pChar = Character(LoopClientID);
if(pChar)
pChar->Die(ClientID, WEAPON_SELF);
}
}
if(!g_Config.m_SvStickyTeams && m_Core.Team(ClientID) != TEAM_FLOCK && m_Core.Team(ClientID) != TEAM_SUPER)
SetForceCharacterTeam(ClientID, 0);
}
int CGameTeams::SetCharacterTeam(int ClientID, int Team)
{
//Check on wrong parameters. +1 for TEAM_SUPER
@ -157,12 +185,11 @@ void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
m_TeamState[OldTeam] = TEAMSTATE_EMPTY;
}
if(Count(OldTeam) > 0)
m_MembersCount[OldTeam]--;
m_Core.Team(ClientID, Team);
if(Team)
if(Team != TEAM_SUPER)
{
str_format(aBuf, sizeof(aBuf), "\'%s\' joined team %d.", pServ->ClientName(pPlayer->GetCID()), Team);
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
@ -224,8 +251,12 @@ int CGameTeams::Count(int Team) const
bool CGameTeams::TeamFinished(int Team)
{
for(int i = 0; i < MAX_CLIENTS; ++i)
if(m_Core.Team(i) == Team && !m_TeeFinished[i])
{
CCharacter *pChar = (GameServer()->m_apPlayers[i]) ? GameServer()->m_apPlayers[i]->GetCharacter() : 0;
if(pChar)
if(m_Core.Team(i) == Team && (!m_TeeFinished[i] && pChar->m_DDRaceState == DDRACE_STARTED))
return false;
}
return true;
}

View file

@ -36,6 +36,7 @@ public:
void OnCharacterStart(int ClientID);
void OnCharacterFinish(int ClientID);
void OnCharacterDeath(int ClientID);
int SetCharacterTeam(int ClientID, int Team);
enum TeamErrors

View file

@ -3,6 +3,6 @@
#ifndef GAME_VERSION_H
#define GAME_VERSION_H
#define GAME_VERSION "0.5 trunk, 1.05a"
#define GAME_VERSION "0.5 trunk, 1.051a"
#define GAME_NETVERSION "0.5 b67d1f1a1eea234e"
#endif