Quake DeveLS - Sonic Rail

Author: WillRoberson
Difficulty: Easy/Medium

BEEP!BEEP!MAX DAMAGE!BLAM! (no more opponent)

This is a great little railgun modification for those sniper loving beasts out there. It takes the beloved railgun, and adds a few things: 1. Fires when you RELEASE the attack key 2. The longer you hold the attack key down, the more damage it does when you release it 3. The minimum damage is 70 (changeable), and the max damage is 250 (again, changeable) 4. Adjustable charging rate 5. A message, "Sonic Rail MAX DAMAGE", and a sound both play when you reach maximum damage Here we goooooooo! Put in the lines marked with plus (+) signs, taking out the lines marked with minus (-) signs. First: Put this into g_local.h in the struct edict_s right below the gravity multiplier:

        float		gravity;		// per entity gravity multiplier (1.0 is normal)
							// use for lowgrav artifact, flares
+	int SonicDamage;	//Will: For the Sonic Rail
Explanation: This is what will set our damage for the Sonic Rail. Next open up p_weapon.c and modify the Railgun section as follows:

        	
void weapon_railgun_fire (edict_t *ent)
{
	vec3_t		start;
	vec3_t		forward, right;
	vec3_t		offset;
-	int			damage;
	int			kick;

if (deathmatch->value)
-	{	// normal damage is too extreme in dm
-		damage = 100;
		kick = 200;
-	}
-	else
-	{
-		damage = 150;
-		kick = 250;
-	}

+//Will:  Added for the sonic rail, it fires when released
+	if (ent->client->buttons & BUTTON_ATTACK)
+	{
+		ent->SonicrDamage += 10;
+		if (ent->SonicDamage>250)
+			ent->SonicDamage= 250;	//This is the maximum damage of the Sonic Rail
+		if (ent->SonicDamage == 240)
+		gi.cprintf (ent, PRINT_HIGH, "Sonic Rail MAX DAMAGE\n");	
+		if (ent->SonicDamage == 240)		
+		gi.sound( ent, CHAN_WEAPON, gi.soundindex("misc/comp_up.wav"), 1, ATTN_NONE, 0 );
+		return;
+	}
+	if (ent->SonicDamage == 0)
+	{		
+		ent->SonicDamage = 1;
+		return;
+	}
+	
+	if (ent->SonicDamage<70)
+		ent->SonicDamage= 70;	//This sets the minimum damage of the Sonic Rail
+//Will:  end of section
if (is_quad)
	{
-		damage *= 4;

+		ent->SonicDamage *= 4;

		kick *= 4;
	}

	AngleVectors (ent->client->v_angle, forward, right, NULL);

	VectorScale (forward, -3, ent->client->kick_origin);
	ent->client->kick_angles[0] = -3;

	VectorSet(offset, 0, 7,  ent->viewheight-8);
	P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start);
-	fire_rail (ent, start, forward, damage, kick);

+	fire_rail (ent, start, forward, ent->SonicDamage, kick);

	// send muzzle flash
	gi.WriteByte (svc_muzzleflash);
	gi.WriteShort (ent-g_edicts);
	gi.WriteByte (MZ_RAILGUN | is_silenced);
	gi.multicast (ent->s.origin, MULTICAST_PVS);

	ent->client->ps.gunframe++;
	PlayerNoise(ent, start, PNOISE_WEAPON);

	if (! ( (int)dmflags->value & DF_INFINITE_AMMO ) )
		ent->client->pers.inventory[ent->client->ammo_index]--;

+	ent->SonicDamage =0;	//Will

}
		
Explanation: Ok, that was pretty big, first, I removed the normal damage checks and the int at the top of the function. Next, I added in the SonicDamage routine that would set the rate of charge, the max damage, the minimum damage, and set it so a message and sound play when you charge to max damage. I also changed the quad check so it recognizes SonicDamage and replaced the fire_rail with a new one, that includes ent->SonicDamage instead of just damage. At the end, I added one more line to set the SonicDamage count back to 0, ready for the next shot. Hope ya like it!

WillRoberson .

This site, and all content and graphics displayed on it,
are Šopyrighted to the Quake DeveLS team. All rights received.
Got a suggestion? Comment? Question?Hate mail? Send it to us!
Oh yeah, this site is best viewed in 16 Bit or higher, with the resolution on 800*600.
Thanks to Planet Quake for their great help and support with hosting.
Best viewed with Netscape 4