One Shot Kills Quake
Created By: Marius
eMail: lordshoel@yahoo.com
Difficulty Scale: Medium


Has Quakes deathmatch modes bored you to death? Want something fun, a new twist to that old classic? Well now you can play the new deathmatch mode 66. One Shot Kills, a game of survival where everything but tha physical world is very deadily. A single hit from any weapon will kill you dead in your tracks, no armor, no health, no power-ups, just you, your weapons and ammunition. Still interested? If you are just follow these steps and you have a cool addition to any mod.

Step 1.

Well lets start with some functions that help this new mode. The first is a message of the day which gives a little information on this new mode. The second function is a timer, this particular version is a modified one of Merl1ns original Dm Timer. So create a new QC file and call it OneHitKills.qc after making this new file open up Progs.src and above Items.qc add in OneHitKills.qc (our new file).

Right when you have finished doing that open up the black OneHitKills.qc file and paste our first function:

//===============================================================

//ONE HIT KILLS

//===============================================================


//========= One Hit Kills Deathmatch connection message

.float		ohkd_count;
.float		ohkd_time;

void() OneHitKillsMessage =
{
    if ((self.ohkd_count < 6) && (self.ohkd_time < time)) // 6 == seconds MOTD will display
    {
        self.ohkd_time = time + 1;
        self.ohkd_count = self.ohkd_count + 1;
        centerprint(self, " === ONE HIT KILLS ===\n Version 1\n\n\nWelcome to One Hit Kills.\nAs the name suggests one shot your dead.\nNow stay alive...\n\nOriginal code by Marius"); 
        return;
    }
};
The above is our message of the day. It lasts for 6 seconds. By the way, this uses centerprint, as does our next function. Below the function OneHitKillsMessage paste our second function.

//========= One Hit Kills Deathmatch timer

void() OneHitKillsTimer =
{
	local	float		timelim;
	local float		remaining;
	local float 		x;
	local float		y;

	if (!deathmatch)return; 

	if (gameover) return;	

	timelim = cvar("timelimit") * 60;
	if (!timelim) return;			

	remaining = ceil(timelim - time);	
	x = floor(remaining / 60);	
	y = remaining - (x * 60);	

	if ((x == 60) && (y == 0)) centerprint (self,"An Hour Left\n");
	if ((x == 30) && (y == 0)) centerprint (self, "30 Minutes left\n");
	else if ((x == 20) && (y == 0)) centerprint (self, "20 Minutes left\n");
	else if ((x == 10) && (y == 0)) centerprint (self, "10 Minutes left\n");
	else if ((x == 5) && (y == 0)) centerprint (self, "5 Minutes Left\n");
	else if ((x == 4) && (y == 0)) centerprint (self, "4 Minutes Left\n");	
	else if ((x == 3) && (y == 0)) centerprint (self, "3 Minutes Left\n");
	else if ((x == 2) && (y == 0)) centerprint (self, "2 Minutes Left\n");	
	else if ((x == 1) && (y == 0)) centerprint (self, "1 Minute Left\n");	
	else if ((y == 30) && (x == 0)) centerprint (self, "30 Seconds Left\n");
	else if ((y == 20) && (x == 0)) centerprint (self, "20 Seconds Left\n");
	else if ((y == 10) && (x == 0)) centerprint (self, "10 Seconds Left\n");
	else if ((y == 5) && (x == 0)) centerprint (self, "5 Seconds Left\n");
};
This is our timer. What it does is count down from the set time for the deathmatch game. Note that you do not need to include this function. Save and close OneHitKills.qc, this is all that needs to be done with this file.

Step 2.

Now for the actual code for the One Hit Kills. It is very simple and quite possible could be improved to to incorperate the various traps within Quake. Right now it only handles none world damage, for example, lava still causes pain but does not immediately kill you were as traps and weapons fire does. So now open up Combat.qc and scroll down to the T_Damage function. At the start of this file below the lines:

	if (!targ.takedamage)
		return;
Paste these lines:

//========= One Hit Kills Deathmatch
	if (deathmatch == 66)
	{
		if (inflictor != world)
		{
			dir = targ.origin - (inflictor.absmin + inflictor.absmax) * 0.5;
			dir = normalize(dir);
			targ.velocity = targ.velocity + dir*damage*8;
			Killed (targ, attacker);
			return;
		}
	}
//========= One Hit Kills Deathmatch
And thats it for Combat.qc, save and close.

Step 3.

So far we have a two unused functions and the code to cuase instant death. But we need a little more than that for a Deathmatch mode. So open up Client.qc, here we'll remove the affects of power-ups and add in our timer and message of the day. To start with scroll down to the CheckRules function. At the end of this function paste these three lines:

//========= One Hit Kills Deathmatch
	if (deathmatch == 66) OneHitKillsTimer();
//========= One Hit Kills Deathmatch
What these lines do is make use of the deathmatch timer. When you've finished there scroll down a little further to the function CheckPowerups. Now to turn the power ups off. Add these three lines at the top of this function:

//========= One Hit Kills Deathmatch
	if (deathmatch == 66) return;
//========= One Hit Kills Deathmatch
Once again this is very simple. You may wish to code it so you can use the Ring of Shadows and Biosuit only, but for now well just ignore all of them. Finished? If you have find the PlayerPostThink function. What we are going to do now is put the message of the day to use. At the end of this function paste these three lines:

//========= One Hit Kills Deathmatch
	if (deathmatch == 66) OneHitKillsMessage();
//========= One Hit Kills Deathmatch
Ok thats it for Client.qc, you can save and exit. The next setp is a little lengthy.

Step 4.

At the start of this tutorial I mention the removal of power ups, armor and health. This is our next step. Open Items.qc and find the StartItem function. At the top of this function add the following code:

//========= One Hit Kills Deathmatch
	if (deathmatch == 66) 
	{
		if (self.classname == "item_health")
		{
			remove(self);
		}
	}
//========= One Hit Kills Deathmatch
Now scroll down to Item_Armor1 and replace all the Item_Armor code with the block below:

void() item_armor1 =
{
//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 0;
	setsize (self, '-16 -16 0', '16 16 56');
	StartItem ();
};

void() item_armor2 =
{
//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 1;
	setsize (self, '-16 -16 0', '16 16 56');
	StartItem ();
};

void() item_armorInv =
{
//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch

	self.touch = armor_touch;
	precache_model ("progs/armor.mdl");
	setmodel (self, "progs/armor.mdl");
	self.skin = 2;
	setsize (self, '-16 -16 0', '16 16 56');
	StartItem ();
};
When you have finished there scroll down to the function Weapon_Touch and within that find the line:

	if (leave)
		return;
Below that line paste this small section which follows. This section leaves the weapons in our new Deathmatch mode.

//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch
When you finish there scroll down to the power-up section and find the folowing Item functions:

	item_artifact_invulnerability, item_artifact_envirosuit, 
	item_artifact_invisibility, item_artifact_super_damage
At the top of each of the above functions add these lines of code:

//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch
One last modification to Items.qc, scroll to the function DropBackpack, at the top of this function add these three lines of code:

//========= One Hit Kills Deathmatch
	if(deathmatch == 66) return;
//========= One Hit Kills Deathmatch
Well thats it for Items.qc. After all that you only have one more simple step...

Step 5.

The last step. Open up Weapons.qc and find the ImpulseCommands function and in it above QuadCheat paste this little snipet of code:

//========= One Hit Kills Deathmatch
	if (self.impulse == 66) deathmatch = 66;
//========= One Hit Kills Deathmatch
Now save and exit Weapons.qc.

Step 6.

That wasn't too hard now was it? Didn't think so. Now compile and run quake. To use this new mode either bind a key to impulse 66 and press that key or at the console type DEATHMATCH 66. If you have any problems or suggestions email me via lordshoel@yahoo.com. Thanks.

Marius