While adding gametypes to my menu, I ended up wanting to make a gamemode like infection from halo. I specifically made this one to mimic Fat Kid, but the settings can easily be changed to fit whatever gametype you want. I figured I would post this here to see as many people having fun as possible. Could use some optimizing, but it works lol. Let me know about any issues/suggestions you have. The tutorial will be a bit vague, but MOST of you should know EXACTLY what to do.
- Put InfectionInit() in Init()
- Put InfectionSpawn() in onplayerspawned()
- Make a onPlayerDied thread and use InfectionDeath() in it.
- Use StartInfection() in your menu or in Init() to start the gametype.
PHP:
/*
* Infection - By Zerker24
*
* Name : Infection
* Description : Halo Infection Clone
* Date : 2016/12/15 - 19:05:23
*
*/
// Put your functions here
InfectionInit()
{
level.infTimeStarted = false;
level.infTxtTop = "Infection by Zerker24";
level.infTxtBottom = "Get Ready!!!";
level.infNum = 1;
level.infStartTime = 20;
level.alphaHealth = 2500;
level.infHealth = 30;
level.alphaSpeed = 0.5;
level.infSpeed = 1.6;
level.alphaWeapon = "knife_held_mp";
level.infWeapon = "knife_held_mp";
level.humanWeapon = "870mcs_mp";
level.humanTeam = "axis"; //The team for all of the hiders.
level.infTeam = "allies"; //The team for the seeker.
level.infectedList = [];
//DO NOT CHANGE
level.infReady = 0;
level.infectedCount = 0;
level.timerDone = false;
}
InfectionSpawn()
{
if (level.gmeMode == "infection")
{
if (self.gmeState == "human")
self thread humanCode();
else if (self.gmeState == "infected")
self thread infectedCode();
else if (self.gmeState == "alpha")
self thread alpInfectedCode();
else
self thread humanCode();
}
}
InfectionDeath()
{
if (level.gmeMode == "infection")
{
if (self.gmeState == "human")
self thread infectedCode();
else if (self.gmeState == "alpha")
self thread alpInfectedCode();
}
}
DisablePickingGuns(defGun)
{
self endon("disconnect");
level endon("game_ended");
self endon("stop_pickup");
for(;;)
{
if(defGun != self getCurrentWeapon())
{
self DropItem( self getCurrentWeapon() );
}
wait 0.05;
}
}
infPlayerLeave()
{
level endon("game_ended");
self endon("playerLeave");
for (;;)
{
self waittill("disconnect");
if (self.gmeState == "infected" || self.gmeState == "alpha")
{
level.infectedCount--;
if (level.infectedCount == 0)
{
level endGame();
}
}
self notify("playerLeave");
wait 0.05;
}
}
StartInfection()
{
level.gmeMode = "infection";
playerCount = level.players.size;
level.playerInt = randomintrange(0, level.players.size - 1);
for (i = 0; i < level.players.size; i++)
{
player = level.players[i];
player thread infPlayerLeave();
if (i == level.playerInt)
{
//Is Infected
player thread alpInfectedCode();
}
else
{
//Is Not Infected
player thread humanCode();
}
}
}
alpInfectedCode()
{
self InfChangeTeam(level.infTeam);
self takeAllWeapons();
self SetActionSlot(1, "");
self SetActionSlot(2, "");
self SetActionSlot(3, "");
self SetActionSlot(4, "");
self giveWeapon(level.alphaWeapon);
self switchToWeapon(level.alphaWeapon);
self setmovespeedscale( level.infSpeed );
self notify("stop_pickup");
self thread DisablePickingGuns(level.alphaWeapon);
self.health = level.alphaHealth;
self.maxHealth = level.alphaHealth;
self setmovespeedscale( level.alphaSpeed );
self giveWeapon("hatchet_mp");
self setWeaponAmmoStock("hatchet_mp",2);
if (self.gmeState != "alpha")
{
self.gmeState = "alpha";
level.infectedCount++;
self EnableInvulnerability();
self freezeControls(true);
self.infBlackScreen.alpha = 0;
self.infBlackScreen destroy();
self.infBlackScreen = self infdrawShader("white", -50, -50, 2000, 1000, (0, 0, 0), 1, 0);
self.infBlackScreen.alpha = 1;
self thread infdrawTimeLeft(1);
}
}
infectedCode()
{
self InfChangeTeam(level.infTeam);
self takeAllWeapons();
self SetActionSlot(1, "");
self SetActionSlot(2, "");
self SetActionSlot(3, "");
self SetActionSlot(4, "");
self giveWeapon(level.infWeapon);
self switchToWeapon(level.infWeapon);
self setmovespeedscale( level.infSpeed );
self.health = level.infHealth;
self.maxHealth = level.infHealth;
self notify("stop_pickup");
self thread DisablePickingGuns(level.infWeapon);
if (self.gmeState != "infected")
{
self.gmeState = "infected";
level.infectedCount++;
if (level.infectedCount == level.players.size)
{
level endGame();
}
}
}
humanCode()
{
self.gmeState = "human";
self InfChangeTeam(level.humanTeam);
self takeAllWeapons();
self SetActionSlot(1, "");
self SetActionSlot(2, "");
self SetActionSlot(3, "");
self SetActionSlot(4, "");
self giveWeapon( level.humanWeapon, 0, true ( 39, 0, 0, 0, 0 ) );
self giveWeapon( "knife_mp" );
self switchToWeapon( level.humanWeapon );
self notify("stop_pickup");
self thread DisablePickingGuns(level.humanWeapon );
self thread infdrawTimeLeft(1);
}
InfChangeTeam(teamz)
{
self.switching_teams=true;
self.joining_team=teamz;
self.leaving_team=self.pers["team"];
self.pers["team"]=teamz;
self.team=teamz;
self.pers["weapon"]=undefined;
self.pers["savedmodel"]=undefined;
self.sessionteam=teamz;
}
infdrawTimeLeft(sort)
{
if (level.timerDone == false)
{
self.disp1.alpha = 0;
self.disp2.alpha = 0;
self.disp3.alpha = 0;
self.disp1 destroy();
self.disp2 destroy();
self.disp3 destroy();
topText = level.infTxtTop;
bottomText = level.infTxtBottom;
self.disp1 = infdrawText(topText, "objective", 1.8, 0, 0, (1, 1, 1), 1, (0, 1, 0), 1, sort);
self.disp2 = infdrawText(level.infStartTime, "objective", 1.8, 0, 19, (1, 1, 1), 1, (0, 1, 0), 1, sort);
self.disp3 = infdrawText(bottomText, "objective", 1.8, 0, 35, (1, 1, 1), 1, (0, 1, 0), 1, sort);
level.infReady += 1;
if (level.infReady == level.players.size)
{
level thread infTimerLoop();
}
}
else
{
self.disp1.alpha = 0;
self.disp2.alpha = 0;
self.disp3.alpha = 0;
self.infBlackScreen.alpha = 0;
self.infBlackScreen destroy();
self.disp1 destroy();
self.disp2 destroy();
self.disp3 destroy();
self freezeControls(false);
}
}
infTimerLoop()
{
level endon("game_ended");
level endon ("TimeDone");
for (;;)
{
level.infStartTime -= 1;
wait 1;
if (level.infStartTime == 0)
{
level.timerDone = true;
foreach (players in level.players)
{
players.disp1.alpha = 0;
players.disp2.alpha = 0;
players.disp3.alpha = 0;
players.infBlackScreen.alpha = 0;
players.infBlackScreen destroy();
players.disp1 destroy();
players.disp2 destroy();
players.disp3 destroy();
players freezeControls(false);
players DisableInvulnerability();
}
level notify("TimeDone");
}
else
{
foreach (players in level.players)
{
players.disp2 setText(level.infStartTime);
}
}
}
}
infdrawShader(shader, x, y, width, height, color, alpha, sort)
{
hud = newClientHudElem(self);
hud.elemtype = "icon";
hud.color = color;
hud.alpha = alpha;
hud.sort = sort;
hud.children = [];
hud setParent(level.uiParent);
hud setShader(shader, width, height);
hud.x = x;
hud.y = y;
return hud;
}
infdrawText(text, font, fontScale, x, y, color, alpha, glowColor, glowAlpha, sort)
{
hud = self createFontString(font, fontScale);
hud.x = x;
hud.y = y;
hud.color = color;
hud.alpha = alpha;
hud.glowColor = glowColor;
hud.glowAlpha = glowAlpha;
hud.sort = sort;
hud.alpha = alpha;
hud setText(text);
return hud;
}
Last edited: