Skip to content

Commit

Permalink
Rollback kvgetsound.
Browse files Browse the repository at this point in the history
https: //github.com/redsunservers/issues/62
Co-Authored-By: Mir <[email protected]>
  • Loading branch information
HotoCocoaco and gaejuck committed May 4, 2022
1 parent fad4cb5 commit 4b55e23
Showing 1 changed file with 140 additions and 11 deletions.
151 changes: 140 additions & 11 deletions addons/sourcemod/scripting/scp_sf/gamemode.sp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ static SoundEnum MusicAlone;
static SoundEnum MusicFloors[10];

int VIPsAlive;
int MTFsAlive;
int ChaosAlive;
bool DebugPreventRoundWin;

ArrayList Gamemode_Setup(KeyValues main, KeyValues map)
Expand Down Expand Up @@ -956,7 +958,7 @@ static bool EndRoundRelay(int group)
return false;
}

static void KvGetSound(KeyValues kv, const char[] string, SoundEnum sound, const SoundEnum defaul = {})
static void KvGetSound(KeyValues kv, const char[] string, SoundEnum sound, const SoundEnum defaul = 0)
{
static char buffers[3][PLATFORM_MAX_PATH];
kv.GetString(string, buffers[0], sizeof(buffers[]));
Expand Down Expand Up @@ -1084,20 +1086,152 @@ public bool Gamemode_ConditionClassic(TFTeam &team)
return true;
}

public bool Gamemode_ConditionSlnew(TFTeam &team)
{
ClassEnum class;
bool salive, ralive, balive;
for(int i=1; i<=MaxClients; i++)
{
if(!IsValidClient(i) || IsSpec(i) || !Classes_GetByIndex(Client[i].Class, class))
continue;

if(class.Vip)
return false;

if(class.Human && Client[i].Disarmer)
continue;

if(!class.Group) // SCPs
{
salive = true;
}
else if(class.Group == 1)// Chaos
{
ralive = true;
}
else if(class.Group > 1) // Guards and MTF Squads
{
balive = true;
}
}

if(balive && (salive || ralive))
return false;

int descape, dcapture, dtotal, sescape, scapture, stotal, pkill, ptotal;
GameInfo.GetValue("descape", descape);
GameInfo.GetValue("dcapture", dcapture);
GameInfo.GetValue("dtotal", dtotal);
GameInfo.GetValue("sescape", sescape);
GameInfo.GetValue("scapture", scapture);
GameInfo.GetValue("stotal", stotal);
GameInfo.GetValue("pkill", pkill);
GameInfo.GetValue("ptotal", ptotal);

int sscore = sescape - scapture;
int dscore = descape - dcapture;
int pscore = ptotal - pkill;
int group;

if(!salive)
{
if(ralive) // Only Class-D and Chaos
{
if(sscore > dscore) // More Scientists and Capture Class-D than Class-D and Capture Scientists
{
team = TFTeam_Unassigned; // Stalemate
group = 0;
}
else
{
team = TFTeam_Red; // Class-D win
group = 1;
}
}
else if(balive) // Only MTF
{
if(sscore > dscore)
{
team = TFTeam_Blue; // MTF win
group = 2;
}
else
{
team = TFTeam_Unassigned; // Stalemate
group = 0;
}
}
else // Nobody escaped, no SCPs alive
{
team = TFTeam_Unassigned;// Stalemate
group = 0;
}
}
else
{
if(pscore > sscore && pscore > dscore)
{
team = TFTeam_Red; // SCPs win
group = 3;
}
else if(pscore > sscore && pscore < dscore)
{
team = TFTeam_Red; // Class-D win
group = 1;
}
else
{
team = TFTeam_Unassigned; // Stalemate
group = 0;
}
}

EndRoundRelay(group);

int minutes, seconds;
TimeToMinutesSeconds(GetGameTime() - RoundStartAt, minutes, seconds);

char buffer[16];
FormatEx(buffer, sizeof(buffer), "team_%d", group);
SetHudTextParamsEx(-1.0, 0.3, 17.5, TeamColors[group], {255, 255, 255, 255}, 1, 2.0, 1.0, 1.0);
for(int client=1; client<=MaxClients; client++)
{
if(!IsValidClient(client))
continue;

SetGlobalTransTarget(client);
ShowSyncHudText(client, HudGame, "%t", "end_screen", buffer, descape, dtotal, sescape, stotal, pkill, ptotal, minutes, seconds);
}
return true;
}

public bool Gamecode_CountVIPs()
{
ClassEnum class;
bool salive;

VIPsAlive = 0;
ChaosAlive = 0;
MTFsAlive = 0;

for(int i=1; i<=MaxClients; i++)
{
if(!IsValidClient(i) || IsSpec(i) || !Classes_GetByIndex(Client[i].Class, class))
continue;

if(class.Vip) // Class-D and Scientists
if(class.Vip) // Class-D and Scientists
{
VIPsAlive++;

}
else if(class.Group == 1) // Chaos
{
ChaosAlive++;
}
else if(class.Group > 1) // Guards and MTF Squads
{
MTFsAlive++;
}

if(!class.Group) // SCPs
salive = true;
}
Expand All @@ -1122,22 +1256,17 @@ public bool Gamemode_ConditionVip(TFTeam &team)
GameInfo.GetValue("ptotal", ptotal);

int group;
if(sescape > descape) // More Scientists than Class-D
if(sescape + dcapture > descape + scapture) // More Scientists and Capture Class-D than Class-D and Capture Scientists
{
team = TFTeam_Blue;
group = 2;
}
else if(sescape<descape || scapture>dcapture) // More Class-D than Scientists || More Scientists than Class-D
else if(descape + scapture > sescape + dcapture) // More Class-D and Capture Scientists than Scientists and capture Class-D
{
team = TFTeam_Red;
group = 1;
}
else if(scapture < dcapture) // More Class-D than Scientists
{
team = TFTeam_Blue;
group = 2;
}
else if(salive && !sescape) // SCP alive and none escaped
else if(salive && !sescape && !dcapture && !descape && !scapture) // SCP alive and none escaped
{
team = TFTeam_Red;
group = 3;
Expand Down

0 comments on commit 4b55e23

Please sign in to comment.