Commit 0dc8dbd8 authored by Mikleo's avatar Mikleo
Browse files

move commander vote candidates into hint box

parent 4899e10b
Pipeline #11935 passed with stages
......@@ -8,7 +8,7 @@
#include <empstats>
#include <updater>
#define PluginVersion "1.11"
#define PluginVersion "1.12"
#define UPDATE_URL "https://sourcemod.docs.empiresmod.com/DraftPick/dist/updater.txt"
......@@ -1080,6 +1080,9 @@ public Action Timer_Tick(Handle timer,client)
tickTime --;
}
if(stage == STAGE_CAPTAINVOTE || stage == STAGE_AUTOPICKWAIT && dp_autodraft_comms.IntValue == 1)
{
if(captainWaitStartTime == 0 && tickTime <= 0)
......@@ -1103,8 +1106,36 @@ public Action Timer_Tick(Handle timer,client)
captainVoteLimit = 1;
int leader1,leader2 = -1;
captainsInVote = NumCaptains() + GetVoteLeaders(captainVoteLimit,leader1,leader2);
int leader1,leader2,leader1votes,leader2votes = -1;
captainsInVote = NumCaptains() + GetVoteLeaders(captainVoteLimit,leader1,leader2,leader1votes,leader2votes);
// display hint box.
if(IsHintTextAvailable())
{
char hintMsg[256];
char clientName[32];
if(leader1 != -1)
Format(hintMsg,sizeof(hintMsg),"Commander Vote Leaders");
else
Format(hintMsg,sizeof(hintMsg),"Requesting Commander Candidates");
if(leader1 != -1)
{
GetClientName(leader1,clientName,sizeof(clientName));
Format(hintMsg,sizeof(hintMsg),"%s\n%s: %d",hintMsg,clientName,leader1votes);
}
if(leader2 != -1)
{
GetClientName(leader2,clientName,sizeof(clientName));
Format(hintMsg,sizeof(hintMsg),"%s\n%s: %d",hintMsg,clientName,leader2votes);
}
Format(hintMsg,sizeof(hintMsg),"%s\n%d votes required",hintMsg,captainVoteLimit);
PrintHintTextToAll(hintMsg);
}
}
......@@ -1155,24 +1186,13 @@ public Action Timer_Tick(Handle timer,client)
if(tickTime == 0 && dp_autodraft_comms.IntValue == 1)
{
int s = (time/10) %3;
if(s == 0)
{
Format(text,sizeof(text),"Each Commander needs %d votes",captainVoteLimit);
}
else
{
int interval = time % 4;
if(interval == 0)
Format(text,sizeof(text)," - Waiting for Commanders - ");
else if(interval == 1 || interval == 3 )
Format(text,sizeof(text)," - Waiting for Commanders - ");
else if(interval == 2 )
Format(text,sizeof(text),"- Waiting for Commanders -");
}
int interval = time % 4;
if(interval == 0)
Format(text,sizeof(text)," - Waiting for Commanders - ");
else if(interval == 1 || interval == 3 )
Format(text,sizeof(text)," - Waiting for Commanders - ");
else if(interval == 2 )
Format(text,sizeof(text),"- Waiting for Commanders -");
}
else
......@@ -1203,6 +1223,9 @@ public Action Timer_Tick(Handle timer,client)
{
yPos -= 0.02;
Format(teamText,sizeof(teamText),"Vote for Commanders %d/2\n%s",captainsInVote,teamText);
}
......@@ -1216,6 +1239,11 @@ public Action Timer_Tick(Handle timer,client)
}
bool IsHintTextAvailable()
{
ConVar sm_vote_progress_hintbox = FindConVar("sm_vote_progress_hintbox");
return !IsVoteInProgress() || sm_vote_progress_hintbox.IntValue == 0;
}
public Action Event_PlayerTeam_Pre(Event event, const char[] name, bool dontBroadcast)
{
......@@ -1349,47 +1377,57 @@ public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcas
return Plugin_Continue;
}
bool IsOptedIn(int client)
{
return GetEntProp(EU_ResourceEntity(), Prop_Send, "m_bWantsCommand",_,client) == 1;
}
int GetVoteLeaders(int numRequired,int &leader1,int &leader2)
int GetVoteLeaders(int numRequired,int &leader1,int &leader2, int &leader1votes,int &leader2votes)
{
int votes[MAXPLAYERS+1] = {0,...}; // votes for each player
EU_GetCommVoteCount(2,votes);
int voteLeaders = 0;
int mostVotesClient = -1;
int mostVotes = numRequired -1;
int secondMostVotesClient = -1;
int secondMostVotes = numRequired -1;
leader1 = -1;
leader1votes = -1;
leader2 = -1;
leader2votes = -1;
for (int i=1; i<=MaxClients; i++)
{
if(votes[i] >mostVotes)
if(IsOptedIn(i))
{
if(mostVotesClient != -1)
if(votes[i] >leader1votes)
{
if(leader1 != -1)
{
leader2votes = leader1votes;
leader2 = leader1;
}
leader1votes = votes[i];
leader1 = i;
}else if(votes[i] >leader2votes)
{
secondMostVotes = mostVotes;
secondMostVotesClient = mostVotesClient;
leader2votes = votes[i];
leader2 = i;
}
mostVotes = votes[i];
mostVotesClient = i;
}else if(votes[i] >secondMostVotes)
{
secondMostVotes = votes[i];
secondMostVotesClient = i;
}
}
if(mostVotesClient >=0)
{
leader1 = mostVotesClient;
voteLeaders++;
}
if(secondMostVotesClient >= 0 )
{
leader2 = secondMostVotesClient;
voteLeaders++;
}
if(leader1votes >= numRequired)
voteLeaders++;
if(leader2votes >= numRequired)
voteLeaders++;
return voteLeaders;
}
......@@ -1399,7 +1437,9 @@ bool TryAssignCaptains()
int requiredCaptains = 2- numCaptains;
int leader1 = -1;
int leader2 = -1;
if(GetVoteLeaders(captainVoteLimit,leader1,leader2) >= requiredCaptains)
int leader1votes = -1;
int leader2votes = -1;
if(GetVoteLeaders(captainVoteLimit,leader1,leader2,leader1votes,leader2votes) >= requiredCaptains)
{
if(requiredCaptains >=1)
SetCaptain(leader1,0);
......
......@@ -4,7 +4,7 @@
{
"Version"
{
"Latest" "1.11"
"Latest" "1.12"
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment