Better Thunderbolt
Created By: Marius
eMail: lordshoel@yahoo.com
Difficulty Scale: Easy


This tutorial is simple and will two two things to the lightning gun:
(1) Make it last longer/use less cells
(2) Make it a little weaker.
It is a much improved Lightning Gun which I like a lot myself.

Step 1.

Open up Defs.qc and scroll to the very bottom. Then add the following varible:

//Thunderbolt
.float temp_cells;
The above does not need to be at the bottom but it is easy and will not interfere with anything that might cause errors.
Step 2.

Ok open up Weapons.qc and scroll to the W_FireLightning function. Once there replace it with the following code:

void() W_FireLightning =
{
	local	vector org;
	local	float	cells;

	if (self.ammo_cells < 1)
	{
		self.weapon = W_BestWeapon ();
		W_SetCurrentAmmo ();
		return;
	}

// explode if under water
	if (self.waterlevel > 1)
	{
		cells = self.ammo_cells;
		self.ammo_cells = 0;
		W_SetCurrentAmmo ();
		T_RadiusDamage (self, self, 35*cells, world);
		return;
	}

	if (self.t_width < time)
	{
		sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
		self.t_width = time + 0.6;
	}
	self.punchangle_x = -2;

	//This is Added
 	self.temp_cells = self.temp_cells + 1;
  	if (self.temp_cells == 3) 
  	{
    		self.currentammo = self.ammo_cells = self.ammo_cells - 1;
    		self.temp_cells = 0;  
    	}

	org = self.origin + '0 0 16';
	
	traceline (org, org + v_forward*600, TRUE, self);

	WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
	WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
	WriteEntity (MSG_BROADCAST, self);
	WriteCoord (MSG_BROADCAST, org_x);
	WriteCoord (MSG_BROADCAST, org_y);
	WriteCoord (MSG_BROADCAST, org_z);
	WriteCoord (MSG_BROADCAST, trace_endpos_x);
	WriteCoord (MSG_BROADCAST, trace_endpos_y);
	WriteCoord (MSG_BROADCAST, trace_endpos_z);

	//This is changed from 30 to 10. Mainly Because you will fire it 3 times at 10 for 
	//a cell rather than once per cell at 30 dmg
	LightningDamage (self.origin, trace_endpos + v_forward*4, self, 10); 
};

Step 3.

Save and Compile. Propably my simplest tutorial yet. Other energy weapons may be done like this for example a laser or plasma gun. Credit should also be give to Iikka Ker,nen for the temp_cells idea from his plasma gun. Marius