Inside3D tutorials.
Created By: QuakeGod
eMail: quakegod@telefragged.com
Difficulty Scale: Easy


Step 1
This is part two of my 2 part classes lesson. In this lesson, we will be learning how to make the 2 classes we made before do different things. Here are two simple things to remember when looking at the code :
Add the code in blue.
Delete the code in red.
Leave the code alone in white.

Step 2
The first thing you will want to do if open up the weapons.qc file. Let's change the axe first, and then you can figure out how to change the other weapon properties yourself. First, scroll do to the W_FireAxe function. Then, decide how you want the classes to differ, let's make the Quake soldier be the same, but weaken the old soldier, but add more range.
void() W_FireAxe =
{
	local	vector	source;
	local	vector	org;

	makevectors (self.v_angle);
	source = self.origin + '0 0 16';

//you need an if else statement
	if (self.classtype == 0)	//if you are the Quake Soldier
		traceline (source, source + v_forward*64, FALSE, self); //leave the same
			
	else if (self.classtype	== 1) // if you are the old soldier
		traceline (source, source + v_forward*128, FALSE, self);
//to increase range of the axe change v_forward*value higher
		
	if (trace_fraction == 1.0)
		return;
	
	org = trace_endpos - v_forward*4;

	if (trace_ent.takedamage)
	{
		trace_ent.axhitme = 1;
		SpawnBlood (org, '0 0 0', 20);

//now to increase damage, do the same thing		
	if (self.classtype == 0)	//if you are the Quake Soldier
		T_Damage (trace_ent, self, self, 20); //leave the same
	
	else if (self.classtype	== 1) // if you are the old soldier
		T_Damage (trace_ent, self, self, 10);
 //to decrease damage, lower the last value		

	}
	else
	{	// hit wall
		sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
		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);
	}
};


Step 3
Now all you have to do is compile and your done! The Quake Soldier is still the same, but the old soldier has a weapon twice as long, but half as strong. You can do this for everything and create to separate classes. Just remember those if-else statements are needed.