Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateDNA() //Creates a random string of DNA for detectives. Wait, doesn't this mean two players can have the same DNA? %0.00001693508 chance of it happening, go play the lottery.
- {
- for(%i=0;%i<5;%i++)
- {
- %part = getRandom(0,9);
- if(%dna $= "")
- %dna = %part;
- else
- %dna = %dna SPC %part;
- }
- return getSubStr(sha1(%dna), 0, 6);
- }
- function player::getFormattedRole(%player) //This is a little bit of shorthand I wrote to get a formatted copy of a player's role, complete with color.
- {
- if(%player.role $= "") //If for some ungodful reason they don't have a role?
- return "\c3Unidentified"; //They're unidentified.
- return BBB_System.RoleColor[%player.role] @ %player.role; //Remember that shit in the server.cs? That contains the color definitions.
- }
- function gameConnection::provideAmmoUpdate(%client,%type) //We only ever update the ammo UI if something happens to change ammo. For example, if a gun is fired or switched or reloaded. Otherwise we don't give a shit.
- {
- if(%client.hasBBBRClient) //If we've gotten a handshake from the client, they deserve our shiny-ass UI
- %client.cycleUIBBB();
- else
- {
- %player = %client.player;
- %slot = %player.currTool;
- %curTool = %player.tool[%slot];
- commandToClient(%client,'centerPrint',"<just:right><font:impact:24><color:fff000>"@%type@" Ammo <font:impact:34>\c6" @ %player.toolAmmo[%slot] @ " / " @ %client.quantity[%type] @ "", 4, 2, 3, 4);
- }
- }
- function gameConnection::cycleUIBBB(%client) //This is the Spicy UI control, for both GUI and GUIless
- {
- %BBB = BBB_System;
- %player = %client.player; //I'm a lazy fuck okay?
- if(%client.hasBBBRClient) //We send very specialized data every second to the player if they have a GUI
- {
- if(isObject(%player)) //If we're alive, we need to gather all the information to send to the client.
- {
- %hp = 100 - mFloatLength(%player.getDamageLevel(),0); //I have no fucking memory why I do this. I guess sometimes damageLevels aren't perfect.
- %curAmmo = "--"; //We display ammo as --/-- by default. It looks nice for non-ammo based weapons.
- %maxAmmo = "--";
- %leftAmmo = "--";
- %slot = %player.currTool;
- %curTool = %player.tool[%slot];
- if(%curTool.typeAmmo !$= "") //If there's an ammo to be used, let's display it correctly yeah?
- {
- %curAmmo = %player.toolAmmo[%slot]; //Technically it means items that don't use ammo can use the GUI ammo display but. Whatever.
- %maxAmmo = %curTool.maxAmmo;
- %leftAmmo = %client.quantity[%curTool.typeAmmo];
- }
- commandToClient(%client,'BBBR_UpdateHUDData',%hp,%player.role,%BBB.timeDisplay,%BBB.currentSec,%BBB.maxSeconds,%curAmmo,%maxAmmo,%leftAmmo);
- }
- else
- commandToClient(%client,'BBBR_UpdateHUDData',0,"Spectator",%BBB.timeDisplay,%BBB.currentSec,%BBB.maxSeconds,"--","--","--"); //I set up a predefined set of information of that dude is dead. lol.
- if(%player.isTraitor)
- commandToClient(%client,'bottomPrint',"<just:left>" @ %BBB.UITList, 2); //We have no specialized GUI for displaying traitors so. Lets just make use of bottom print.
- }
- else
- { //We're gonna build the UI as we go!
- if(isObject(%player)) //Again if they're alive or dead changes whether we build this as we go.
- {
- %DL = %player.getDamageLevel();
- %color = %player.getHealthColoring();
- %hexColor = rgbToHex(%color);
- %UIString = "\c3Health\c6: <color:" @ %hexColor @ ">" @ (100 - %DL); //Adds a fresh gradient if the player's health goes down. Rainbow from Green-Red as HP drops.
- %dmMarks = mCeil((100 - mFloatLength(%DL,0)) / 10);
- %stringMark = BBB_System.MarkList[%dmMarks]; //Remember the server.cs? We defined a shitty healthbar there.
- %UIString = %UIString SPC "<color:" @ %hexColor @">" @ %stringMark;
- %UIString = %UIString SPC "\c3Role\c6:" SPC %player.getFormattedRole();
- }
- else
- %UIString = "\c3Health\c6: <color:ff0000>0 <color:ff0000>|||||||||| \c3Role\c6: \c7Spectator\c3";
- %UIString = %UIString SPC "<just:right>\c3Time\c6:" SPC %BBB.timeDisplay; //We tack on the time at the end.
- if(%player.isTraitor)
- %UIString = %UIString NL "<just:left>" @ %BBB.UITList; //Traitor's gonna trait, they gotta know their allies.
- commandToClient(%client,'bottomPrint',%UIString, 2);
- }
- }
- function BBB_System::clearBots(%BBB)
- {
- %count = botSimGroup.getCount(); //We're gonna remove any bot we make. For jesus and for glory.
- for(%i=0;%i<%count;%i++)
- {
- %bot = botSimGroup.getObject(0);
- botSimGroup.remove(%bot);
- %bot.delete();
- }
- }
- function AIPlayer::addBotToGroup(%bot) //So we can remove bots, whenever any bot is made or added, they are added to our simgroup to be deleted later.
- {
- botSimGroup.add(%bot);
- }
- function BBB_System::createAnnouncement(%BBB,%msg) //Shorthand for laziness. Yeah, yeah I know.
- {
- announce("\c2Game\c6:" SPC %msg);
- %BBB.Log_Event(true,%msg); //We have to have something in our logs, right?
- }
- function player::removePlayer(%player,%BBB) //This is an interesting one. We call remove player if: A client disconnects and have a body, a player dies, a player fucking dies. You get the idea. We want the round to end eventually.
- {
- if(%player.isTraitor)
- {
- %BBB.TraitorCount --;
- %BBB.createFormattedTraitorList(); //If a traitor dies let's fix some shit yeah?
- return; //I'm not graceful okay?
- }
- %BBB.InnocentCount --;
- }
- function GameConnection::freeCamera(%this) //Spectator fly-by camera boys.
- {
- %cam = %this.camera;
- if(!isObject(%cam))
- return;
- %this.camera.setMode(observer);
- %this.setControlObject(%this.camera);
- }
- function BBB_System::testVictory(%BBB) //We check for victory kind of oftenly. So let's not fuck this up, yeah?
- {
- if(%BBB.TraitorCount <= 0 && !%BBB.resetting) //If for some godless reason we go negative? Yeah lets reset, unless we're resetting.
- {
- %BBB.createAnnouncement("The Innocent have succeeded. Resetting in 5 seconds...");
- %BBB.schedule(5000,resetBBB);
- %BBB.resetting = true;
- }
- else if(%BBB.InnocentCount <= 0 && !%BBB.resetting)
- {
- %BBB.createAnnouncement("The Innocent have failed. Resetting in 5 seconds...");
- %BBB.schedule(5000,resetBBB);
- %BBB.resetting = true;
- }
- }
- function BBB_System::onTimerTick(%BBB) //Everytime the timer ticks down ONE second, we refresh just about. Everything.
- {
- %count = clientGroup.getCount();
- for(%i = 0; %i < %count; %i++)
- {
- %client = clientGroup.getObject(%i);
- %player = %client.player;
- if(isObject(%player))
- {
- %color = %player.getHealthColoring(); //We change the player name color if they get hurt. Detectives have a different color gradient.
- %player.setShapeNameColor(%color);
- }
- %client.cycleUIBBB(); //We get ever client's UI to refresh with the timer.
- }
- }
- function BBB_System::timer(%BBB,%minutes,%seconds)
- {
- BBB_System.onTimerTick();
- %seconds --;
- if(%seconds < 0 && %minutes > 0) //Yeah. I should have kept track in seconds and made use of Modulus, don't murder me.
- {
- %seconds = 59;
- %minutes --;
- }
- %BBB.minutes = %minutes;
- %BBB.seconds = %seconds;
- %BBB.currentSec = (%minutes * 60) + %seconds; //Total seconds that had elapsed.
- if(strLen(%seconds) != 2) //All this fancy shit just adds 0s where they need to be so our timer display looks nice and tidy.
- %secondDisplay = %seconds @ 0;
- else
- %secondDisplay = %seconds;
- if(%seconds < 10)
- %secondDisplay = 0 @ %seconds;
- %BBB.timeDisplay = %minutes @ ":" @ %secondDisplay;
- %BBB.timer = %BBB.schedule(1000,timer,%BBB.minutes,%BBB.seconds);
- if(%minutes == 0 && %seconds == 0) //If the teams get a time out instead of a regular victory.
- {
- cancel(%BBB.timer);
- BBB_System.onTimerTick();
- %BBB.timeDisplay = "0:00";
- %BBB.schedule(5000,resetBBB);
- %BBB.resetting = true;
- %BBB.createAnnouncement("Neither alliance is victorious. Resetting in 5 seconds...");
- }
- }
- function serverCMDResetBBB(%client) //Well if admins wanna reset, admins wanna reset. Mostly for debug usage.
- {
- if(%client.isAdmin)
- {
- BBB_System.resetting = true;
- BBB_System.createAnnouncement("Admin\c3" SPC %client.name SPC "\c6has reset BBB to take effect in 3 seconds.");
- BBB_System.schedule(3000,resetBBB);
- }
- }
- function BBB_System::resetBBB(%BBB) //We handle all the resetting here. I mean, all of the fucking resetting.
- {
- cancel(%BBB.timer); //No more countdown.
- if(isObject($DefaultMiniGame))
- $DefaultMiniGame.reset(0); //Default minigame reset command
- %BBB.resetting = false; //These are our zeros, yadda yadda
- %BBB.match = false;
- %count = clientGroup.getCount();
- for(%i=0;%i<%count;%i++)
- {
- %client = clientGroup.getObject(%i);
- if(%client.hasSpawnedOnce && !%client.spectator) //If a client is set to spectator mode for whatever reason, let's not spawn them. If they're not done loading? Definitely don't spawn them.
- %client.instantrespawn();
- }
- %BBB.currentDeathID = 0;
- %BBB.traitorList = "";
- %BBB.TraitorCount = 0;
- %BBB.InnocentCount = 0;
- %BBB.timeDisplay = "0:00";
- BBB_System.clearBots();
- %totalIncrease = 0;
- for(%i=0;%i<%count;%i++)
- {
- %client = clientGroup.getObject(%i);
- if(!%client.spectator && isObject(%client.player))
- %totalIncrease ++;
- }
- %bonusMin = mFloor(%totalIncrease / 4);
- %bonusSec = (%totalIncrease % 4) * 15; //We add fifteen seconds per player. Because... I'm not sure lmao.
- %totalMin = 7 + %bonusMin;
- %totalSec = 30 + %bonusSec;
- %BBB.maxSeconds = %totalMin * 60 + %totalSec;
- if(%totalSec > 60)
- {
- %totalSec %= 30;
- %totalMin ++;
- }
- %BBB.timer(%totalMin,%totalSec);
- %BBB.schedule(30000,beginBBB);
- }
- function BBB_System::beginBBB(%BBB) //For when the server is launched.
- {
- %BBB.match = true;
- %BBB.generateTeams();
- }
- function BBB_System::Log_Event(%BBB,%timeStamp,%text)
- {
- if(%text $= "")
- return;
- %finish = "";
- %date = strreplace(getsubstr(getDateTime(),0,8),"/","-");
- if(%timeStamp)
- %finish = "[" @ getsubstr(getDateTime(),9,8) @ "]";
- else
- %finish = "(" @ %BBB.timeDisplay @ ")";
- %file = new FileObject();
- %file.openForAppend("config/BBBR/Logs/" @ %date @ ".txt");
- %file.writeline(%finish @ %text);
- %file.close();
- %file.delete();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement