Skip to content

Commit

Permalink
Add 2 more convars to push non-traitors two times into players array
Browse files Browse the repository at this point in the history
  • Loading branch information
Bara committed Apr 9, 2018
1 parent 5d5c122 commit bd627b0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/ttt/core/config.sp
Expand Up @@ -122,6 +122,8 @@ void SetupConfig()
g_cDamageKarmaDI = AutoExecConfig_CreateConVar("ttt_damage_karma_attacker_detective_victim_innocent_subtract", "1", "The amount of karma a detective will lose for damage an innocent.");
g_cDamageKarmaDT = AutoExecConfig_CreateConVar("ttt_damage_karma_attacker_detective_victim_traitor_add", "1", "The amount of karma a detective will recieve for damage a traitor.");
g_cDamageKarmaDD = AutoExecConfig_CreateConVar("ttt_damage_karma_attacker_detective_victim_detective_subtract", "1", "The amount of karma a detective will lose for damage a detective.");
g_cDoublePushInno = AutoExecConfig_CreateConVar("ttt_double_push_innocents", "1", "Push innocents (from last round) two times into players array? This should increase the chance to get traitor in the new round.", _, true, 0.0, true, 1.0);
g_cDoublePushDete = AutoExecConfig_CreateConVar("ttt_double_push_detective", "1", "Push detective (from last round) two times into players array? This should increase the chance to get traitor in the new round.", _, true, 0.0, true, 1.0);

g_cpluginTag.AddChangeHook(OnConVarChanged);
g_ckickImmunity.AddChangeHook(OnConVarChanged);
Expand Down
2 changes: 2 additions & 0 deletions addons/sourcemod/scripting/ttt/core/globals.sp
Expand Up @@ -268,6 +268,8 @@ ConVar g_cDamageKarmaTD = null;
ConVar g_cDamageKarmaDI = null;
ConVar g_cDamageKarmaDT = null;
ConVar g_cDamageKarmaDD = null;
ConVar g_cDoublePushInno = null;
ConVar g_cDoublePushDete = null;

Handle g_hRules = null;
bool g_bRules[MAXPLAYERS + 1] = { false, ... };
Expand Down
61 changes: 41 additions & 20 deletions addons/sourcemod/scripting/ttt/ttt.sp
Expand Up @@ -759,6 +759,11 @@ public Action Timer_Selection(Handle hTimer)
}

aPlayers.Push(i);

if ((g_cDoublePushInno.BoolValue && g_iLastRole[i] == TTT_TEAM_INNOCENT) || (g_cDoublePushDete.BoolValue && g_iLastRole[i] == TTT_TEAM_DETECTIVE))
{
aPlayers.Push(i);
}
}

Action res = Plugin_Continue;
Expand Down Expand Up @@ -845,12 +850,16 @@ public Action Timer_Selection(Handle hTimer)
if (client > 0)
{
iIndex = aPlayers.FindValue(client);

if (iIndex != -1)
{
g_iRole[client] = TTT_TEAM_TRAITOR;
iTraitors++;
g_iLastRole[client] = TTT_TEAM_TRAITOR;
if (g_iRole[client] == TTT_TEAM_UNASSIGNED)
{
g_iRole[client] = TTT_TEAM_TRAITOR;
g_iLastRole[client] = TTT_TEAM_TRAITOR;
iTraitors++;
}

aPlayers.Erase(iIndex);
}
}
Expand All @@ -864,10 +873,14 @@ public Action Timer_Selection(Handle hTimer)

if (TTT_IsClientValid(client) && (g_iLastRole[client] != TTT_TEAM_TRAITOR || GetRandomInt(1, 6) == 4))
{
g_iRole[client] = TTT_TEAM_TRAITOR;
g_iLastRole[client] = TTT_TEAM_TRAITOR;
if (g_iRole[client] == TTT_TEAM_UNASSIGNED)
{
g_iRole[client] = TTT_TEAM_TRAITOR;
g_iLastRole[client] = TTT_TEAM_TRAITOR;
iTraitors++;
}

aPlayers.Erase(iRand);
iTraitors++;
}
}

Expand All @@ -883,9 +896,13 @@ public Action Timer_Selection(Handle hTimer)

if (iIndex != -1)
{
g_iLastRole[client] = TTT_TEAM_DETECTIVE;
g_iRole[client] = TTT_TEAM_DETECTIVE;
iDetectives++;
if (g_iRole[client] == TTT_TEAM_UNASSIGNED)
{
g_iLastRole[client] = TTT_TEAM_DETECTIVE;
g_iRole[client] = TTT_TEAM_DETECTIVE;
iDetectives++;
}

aPlayers.Erase(iIndex);
}
}
Expand All @@ -910,17 +927,21 @@ public Action Timer_Selection(Handle hTimer)

if (TTT_IsClientValid(client) && ((TTT_GetClientKarma(client) > g_cminKarmaDetective.IntValue && g_iLastRole[client] == TTT_TEAM_INNOCENT) || GetRandomInt(1, 6) == 4))
{
if (g_bAvoidDetective[client] == true)
{
g_iLastRole[client] = TTT_TEAM_INNOCENT;
g_iRole[client] = TTT_TEAM_INNOCENT;
}
else
if (g_iRole[client] == TTT_TEAM_UNASSIGNED)
{
g_iLastRole[client] = TTT_TEAM_DETECTIVE;
g_iRole[client] = TTT_TEAM_DETECTIVE;
iDetectives++;
if (g_bAvoidDetective[client] == true)
{
g_iLastRole[client] = TTT_TEAM_INNOCENT;
g_iRole[client] = TTT_TEAM_INNOCENT;
}
else
{
g_iLastRole[client] = TTT_TEAM_DETECTIVE;
g_iRole[client] = TTT_TEAM_DETECTIVE;
iDetectives++;
}
}

aPlayers.Erase(iRand);
}
}
Expand All @@ -930,7 +951,7 @@ public Action Timer_Selection(Handle hTimer)
while (aPlayers.Length > 0)
{
client = aPlayers.Get(0);
if (TTT_IsClientValid(client))
if (TTT_IsClientValid(client) && g_iRole[client] == TTT_TEAM_UNASSIGNED)
{
g_iLastRole[client] = TTT_TEAM_INNOCENT;
g_iRole[client] = TTT_TEAM_INNOCENT;
Expand Down

0 comments on commit bd627b0

Please sign in to comment.