• Register

Zombie Grinder is the debut game of TwinDrills, an indie game development duo made up of Tim 'Infini' Leonard and Jordan 'Jordizzle' Chewning. It's a multi-platform (windows, mac, Linux!) (also Free!) cooperative multiplayer arcade game, reminiscent in style and gameplay of retro games like 'Zombies Ate My Neighbors' and 'Super Smash TV!', but with the added benefit of some newer game mechanics - achievements, ranking, player-customization, rpg style stats and so forth. The game sports a variety of different game modes, from co-operative 'campaign' style levels, to wave maps and even the classic 'pvp' style game modes - deathmatch, capture the 'bag' and so forth. All of these mods are bristling with a variety of weapons and items, all lovingly displayed in Jordan's classic quirky pixel-art style.

Forum Thread
  Posts  
[Script] Game Timer (Games : Zombie Grinder : Forum : Modding / Map Design : [Script] Game Timer) Locked
Thread Options
Jan 3 2014 Anchor

Hey everyone! Long time no see! My old computer went to a better place, and it took me several months to find a replacement for it.

This 'concept' came to me when I thought about ZG while I couldn't play it - what if we had a time limited contest game in ZG? It could be set up as PvPvE (or just PvP or PvE) where the players need to accomplish something or another before the time limit runs out.

The concept was simple, and thanks to Wave.mc, the coding was... not too hard. Take a look at this code:


// ------------------------------------------------------------
// Time Limit Variables. 
// ------------------------------------------------------------
const TIME_LIMIT = 305000;
var sync Timer;
var sync SecRemaining;
var sync MinRemaining;

event OnInit()
{
	Timer = Millisecs() + TIME_LIMIT;
}

event OnTick()
{
	if (Timer == 0)
	{
		Timer = Millisecs() + TIME_LIMIT;
	}
	if (!IsServer())
	{
		MinRemaining = int((Timer - Millisecs() - 3000) / 60000);
		SecRemaining = int((Timer - Millisecs() - 3000 - (MinRemaining * 60000)) / 1000);
		if (MinRemaining > 0)
		{
			if (SecRemaining < 10)
			{
				SetObjectiveHUDText ("Game ends in " + MinRemaining + ":0" + SecRemaining, 0.0);
			}
			else
			{
				SetObjectiveHUDText ("Game ends in " + MinRemaining + ":" + SecRemaining, 0.0);
			}
		}
		else
		{
			SetObjectiveHUDText ("Game ends in " + SecRemaining, 1.0);
		}
	}
	if (Millisecs() > Timer)
	{
		SetGameOver(true);
		for (var i = 0; i < GetClientCount(); i++)
		{
			var client = GetClientByIndex(i);
			if (!IsClientDead(client))
			{
				KillClient(client);
			}
		}
	}
}


Of course, there are certain problems, such as the timer not ending the game at the appropriate time - I've tried to mitigate that by adding 5000 milliseconds for the server/client to load stuff, and subtracting 3000 milliseconds with the counter to get it sync better with the HUD display. This has also not been tested online at all, so even though it will work for my computer, I have no idea whatsoever what will happen when it more than one person tries it, or it runs on the official servers, or what happens when another person comes in after the timer has started (for this last one, I am hoping that the person who logs in later simply gets less time - not fair, but DM was never fair).

Ultimately, though, the counter problem (not ending at the correct time) does really depend client-side, so to put it another way, it depends on the indivdual's computer. However, the main aspect of this code should still be applicable and usable - and anyone may try to use this code (and parts of it) however they wish in their scripts. I will be using this to design some time limited game modes, with a map to boot.

--

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.