Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function roundFloat(%value)
- {
- return mFloatLength(%value, 0);
- }
- function BBB_System::generateTeams(%BBB)
- {
- //Fetches a list of all players who exist and aren't spectating.
- %count = clientGroup.getCount();
- for(%i=0;%i<%count;%i++)
- {
- %client = clientGroup.getObject(%i);
- if(isObject(%client.player) && !%client.spectator)
- {
- if(%str $= "")
- %str = %client.player;
- else
- %str = %str SPC %client.player;
- }
- }
- for(%i=0;%i<%count;%i++)
- {
- %client = clientGroup.getObject(%i);
- if(!isObject(%client.player) || %client.spectator)
- {
- if(%str2 $= "")
- %str2 = %client;
- else
- %str2 = %str2 SPC %client;
- }
- }
- //Tells the system to get to work and create all the teams.
- %count = getWordCount(%str); //Gives out the total length of the list so we can use it accordingly.
- %str = %BBB.generateTraitors(%str,%count);
- %str = %BBB.generateDetectives(%str,%count);
- %BBB.generateInnocent(%str);
- %BBB.createFormattedTraitorList();
- }
- function BBB_System::generateTraitors(%BBB,%str,%count)
- {
- //Creates your traitors.
- %passes = %count/4; //We want atleast one out of every 6 players to be a traitor. The traitor count will increase every 6n players.
- if(%passes <= 0.25)
- %passes = 1; //Forces exactly one traitor per round, even if they are the only player.
- else
- %passes = roundFloat(%passes); //Rounds the previous number to closet number, in reality making %count/4 result in every 6th player.
- for(%i=0; %i<%passes; %i++)
- {
- %length = getWordCount(%str) - 1; //In a list containing 1 player (Who occupies slot number 0) this will essentially stop there from somehow not being a traitor.
- %pos = getRandom(0,%length);
- %player = getWord(%str,%pos);
- %player.makeRole("Traitor",1);
- commandToClient(%player.client,'BBBR_ReconstructShopGUI');
- %str = removeWord(%str,%pos);
- }
- return %str;
- }
- function BBB_System::generateDetectives(%BBB,%str,%count)
- {
- //Creates your detectives.
- %passes = %count/8;
- %passes = mFloor(%passes); //As oppossed to rounding our detectives we always force the detective to occur every 8th player.
- for(%i=0;%i<%passes;%i++)
- {
- %length = getWordCount(%str) - 1;
- %pos = getRandom(0,%length);
- %player = getWord(%str,%pos);
- %player.makeRole("Detective",0);
- commandToClient(%player.client,'BBBR_ReconstructShopGUI');
- %str = removeWord(%str,%pos);
- }
- return %str;
- }
- function BBB_System::generateInnocent(%BBB,%str,%count)
- {
- //Takes anyone left in the system and forces them to be an innocent.
- %count = getWordCount(%str);
- for(%i=0;%i<%count;%i++)
- {
- %player = getWord(%str,0);
- %player.makeRole("Innocent",0);
- %str = removeWord(%str,0);
- }
- }
- function player::makeRole(%player,%role,%alliance)
- {
- %BBB = BBB_System;
- %client = %player.client;
- //Corrects the counter and un-detectifies any player put into the system if they already had a role.
- if(%player.isTraitor !$= "")
- {
- if(%player.isTraitor)
- %BBB.TraitorCount --;
- else
- %BBB.InnocentCount --;
- %player.unMountImage(2);
- %client.applyBodyColors();
- %client.applyBodyParts();
- }
- //Sets the players values
- %player.isTraitor = %alliance;
- %player.role = %role;
- //Changes the alliance counts accordingly.
- if(%alliance)
- %BBB.TraitorCount ++;
- else
- %BBB.InnocentCount ++;
- //Gives detetives their well earned hat.
- if(%role $= "Detective")
- {
- %player.mountImage(DetectiveImage,2);
- for(%op = 0;$hat[%op] !$= "";%op++)
- {
- %player.hideNode($hat[%op]); //Hides all hats.
- }
- for(%qw = 0;$accent[%qw] !$= "";%qw++)
- {
- %player.hideNode($accent[%qw]);
- }
- %player.hasArmor = true;
- %player.credits = 2;
- }
- //Sets the list of Traitors so we can just fetch things from it.
- if(%role $= "Traitor")
- {
- if(%BBB.TraitorList $= "")
- %BBB.TraitorList = %player.client;
- else
- %BBB.TraitorList = %BBB.TraitorList SPC %player.client;
- %player.credits = 2;
- }
- commandToClient(%client,'centerPrint',"\c4You have been selected to be a(n)" @ BBB_System.RoleColor[%role] SPC %role @ "\c4.", 5);
- }
- function BBB_System::createFormattedTraitorList(%BBB)
- {
- %List = %BBB.TraitorList;
- %count = getWordCount(%List);
- %baseString = "\c3Fellow Traitors\c6:";
- for(%i = 0; %i < %count; %i ++)
- {
- %client = getWord(%List,%i);
- if(isObject(%client.player))
- %addString = "\c0" @ %client.name;
- else
- %addString = "\c7" @ %client.name;
- %baseString = %baseString SPC %addString;
- }
- %BBB.UITList = %baseString;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement