Auto Aim ThunderBolt
Author: DarkSide (and me.. a little)Source: https://www.insideqc.com/qctut/lesson-22.shtml
Step 1
Uhh.. I just want to warn you every one, that this tutorial kinda sucks, since i only got the code sent WITHOUT the changes commented. Sorry about this. O'well.. read on if you want to create an Auto-Aiming thunder Bolt!
Step 2
Ok, now open up the weapons.qc file, and scroll down to the W_FireLightning section. delete *all* of it, and replace it with the code shown below? How much easier can it get?
void() W_FireLightning =
{
local vector org;
local float cells,damage=0;
local entity head;
self.punchangle_x = -2;
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = self.origin + '0 0 16';
if (self.ammo_cells < 1) // Change to other weapon if not enough cells
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
if (self.waterlevel > 1) // explode in water
{
cells = self.ammo_cells;
self.ammo_cells = 0;
W_SetCurrentAmmo ();
T_RadiusDamage (self, self, 35*cells, world);
return;
}
head = findradius(self.origin, 250); // finds all entitys within 250 (2.5 meters?)
while (head)
{
if (head.takedamage)
{
if(head != self) // if the entity (head) is you (self), skip
{
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, head); // Start position for lightning
WriteCoord (MSG_BROADCAST, org_x); // Your position
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, head.origin_x); // entity's position
WriteCoord (MSG_BROADCAST, head.origin_y);
WriteCoord (MSG_BROADCAST, head.origin_z);
sound (head, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
damage = 40 + random()*20;
T_Damage (head, self, self.owner, damage);
}
}
head = head.chain; // cycle to next head (entity)
}
};
Step 3
And that's it... Compile it, and load it up the usual way. Now, try loading up e1m1 in skill 3. go the the "slime bridge" or whatever i should call them, and take 'em all out in one shot! Cool, eh?
Tags: tutorial, quakec, qc, insideqc, weapon