Gatling Gun
Author: DrywallSource: https://www.insideqc.com/qctut/qctut-10.shtml
Step 1
This tutorial will teach you how to turn the nailgun into a gatling gun ala doom. First, you need to open weapons.qc and go until the line "void() player_nail1; and write this:
void() player_gat1; // gatling gun firing (see later)
Step 2
Now, further in weapons.qc, find the line: .float hit_z;. Above it, add this:
void(float ox, float ox2) W_FireGatSpikes = // this is a slightly modified version of firespikes
{
local vector dir;
local entity old;
makevectors (self.v_angle);
if (self.ammo_nails <1)
{
self.weapon = W_BestWeapon();
W_SetCurrentAmmo ();
return;
}
sound (self, chan_weapon, "weapons/rocket1i.wav", 1, attn_norm);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
dir = aim (self, 1000);
launch_spike (self.origin + '0 0 16' + v_right*ox + v_up*ox2, dir); // sets spike direction
self.punchangle_x = -2;
};
/*
===============
launch_gatling
===============
*/
void(vector org, vector dir) launch_gatling =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 1000;
};
void() W_FireGatling =
{
local vector dir;
local entity old;
sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 2;
dir = aim (self, 1000);
launch_gatling (self.origin + '0 0 16', dir);
newmis.touch = superspike_touch;
setmodel (newmis, "progs/s_spike.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
self.punchangle_x = -2;
};
Step 3
Now open up player.qc. Above the line void() player_light1 =[$light1, player_light2 ], insert these lines:
void() player_gat1 =[$nailatt1, player_gat2 ] // runs gat2 next
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireGatSpikes (-8, 0); // fires a spike to the left
self.attack_finished = time + 0.2;
};
void() player_gat2 =[$nailatt2, player_gat3 ] // runs gat3 next
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireGatSpikes (0, 8); // fires a spike up
self.attack_finished = time + 0.2;
};
void() player_gat3 =[$nailatt1, player_gat4 ] // runs gat4 next
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireGatSpikes (8, 0); // fires a spike to the right
self.attack_finished = time + 0.2;
};
void() player_gat4 =[$nailatt2, player_gat1 ] // back to 1
{
self.effects = self.effects | EF_MUZZLEFLASH;
if (!self.button0)
{player_run ();return;}
self.weaponframe = self.weaponframe + 1;
if (self.weaponframe == 9)
self.weaponframe = 1;
SuperDamageSound();
W_FireGatSpikes (0, -8); // fires a spike down
self.attack_finished = time + 0.2;
};
Step 4
Now find the W_Attack function in weapons.qc. Change these lines:
else if (self.weapon == IT_SUPER_NAILGUN)
{
player_nail1 ();
}
Add in these lines:
else if (self.weapon == IT_SUPER_NAILGUN)
{
player_gat1 ();
}
Step 5
Woohoo! You're all ready to compile and run. Have fun...
Tags: tutorial, quakec, qc, insideqc, weapon
Comments