Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre, fiendish Vore and indestructible Schambler using lethal nails, fierce Thunderbolts and abominable Rocket and Grenade Launchers.

Post tutorial Report RSS Easy locational damage!

A tutorial brought to you by Miles Invictus, comes an awesome feature that makes your head shots true and beneficial to your gaming experience.

Posted by on - Basic Server Side Coding

Introduction

In most games these days, they have locational damage because it seems "realistic" to them, taking more damage from the head than other parts of the body. WELL LET'S PUT THAT IN QUAKE NO?

The real meat


Open WEAPONS.QC.

Replace the TraceAttack function with this:

// Now with locational damage
void(float damage, vector dir) TraceAttack =
{
	local	vector	vel, org;
	local float f_damage;
	
	vel = normalize(dir + v_up*crandom() + v_right*crandom());
	vel = vel + 2*trace_plane_normal;
	vel = vel * 200;

	org = trace_endpos - dir*4;

	if (trace_ent.takedamage)
	{
                 if (trace_fraction >= 1)
                        return;
  	if (trace_endpos_z > (trace_ent.origin_z + 18))
		{
                f_damage = damage * 2; // This is a head shot
		}
	else if (trace_endpos_z < trace_ent.origin_z)
		{
                f_damage = damage * 0.5; // This is a leg shot
		}
	else
		{
                f_damage = damage; // Anywhere else (torso)
		}
                  SpawnBlood (org, vel*0.2, f_damage * 0.3);
                  AddMultiDamage (trace_ent, f_damage);
	}
	else
	{
		WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
                WriteByte (MSG_BROADCAST, TE_GUNSHOT);
		WriteCoord (MSG_BROADCAST, org_x);
		WriteCoord (MSG_BROADCAST, org_y);
		WriteCoord (MSG_BROADCAST, org_z);
	}
};


The final step
There is no final step. YOU ARE DONE! :D

Now, compile your code, run your mod, and kick some arse! Aim for the head if you can find it.

(This code is adopted from Miles Invictus' old locational damage code with permission, and heavily simplified by yours truly, to allow easy addition into mods. Tutorial written in October 2003.)

Comments
TwinBeast
TwinBeast

This looks cool. I'm thinking of coding something similar for DooM if I can.

Reply Good karma Bad karma+1 vote
PsychoBrat
PsychoBrat

This would only work against humans and other creatures with the same proportions, would it not?

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

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.

Follow Report Profile
Icon
Quake
Platforms
Windows, Mac, Linux, DOS, N64, DC
Developer & Publisher
id Software
Engine
Quake Engine
Contact
Send Message
Homepage
Idsoftware.com
Release date
Game watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Games
Quake
Quake First Person Shooter
Related Engines
Quake Engine
Quake Engine GPL
Related Groups
id Software
id Software Developer & Publisher