Note: The text in blue
is the code to add, text in green is
where it goes. Text in purple is code that needs to
be replaced, and text in red are suggestions to
better the mod, but are not necessary.
This tutorial will teach you how to combine any two weapons in
Quake, so that when you fire
both weapons let rip!
For an example I am going to show you how to combine the
grenade launcher and the rocket launcher.
First of all, we need to tell Quake the ammo type, weapon
model and weapon frame of the
combined weapon.
Add this in W_SetCurrentAmmo in
weapons.qc:
else if (self.weapon = IT_GRENADE_LAUNCHER)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel = "progs/v_rock.mdl";
self.weaponframe = 0;
self.items =
self.items | IT_ROCKETS;
}
else if (self.weapon == IT_EXTRA_WEAPON)
{
self.currentammo = self.ammo_rockets;
self.weaponmodel =
"progs/v_rock.mdl";
self.weaponframe = 0;
self.items = self.items | IT_ROCKETS;
}
The self.weaponmodel can be changed to
your own custom model if you want, but this is only an
aesthetic
change.
The IT_EXTRA_WEAPON item is defined (partially) in defs.qc as
(I presume) something left in by Id so that you could create any old extra
weapon if ya wanted to add one in the original quakec source. Anyway, I will go
on about that later...
Next, add this in W_Attack
(also in weapons.qc):
else if (self.weapon == IT_GRENADE_LAUNCHER)
{
player_rocket1();
W_FireGrenade();
self.attack_finished = time + 0.6;
}
else if (self.weapon == IT_EXTRA_WEAPON)
{
player_rocket1();
W_FireGrenade();
W_FireRocket();
self.attack_finished = time + 0.8;
}
You can change the rate of fire of this
new combined weapon by altering self.attacked_finished = time + 0.8; to
something else
ie. self.attack_finished = time + 0.6;
This sets the attack (ie. fires a rocket and grenade
simultaneously).
Now, under W_ChangeWeapon (yet
again in weapons.qc) alter:
else if (self.impulse == 6)
{
fl = IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
so that the original is replaced with:
else if (self.impulse == 6)
{
if (self.weapon == IT_GRENADE_LAUNCHER &&
self.items == IT_GRENADE_LAUNCHER
|| IT_ROCKET_LAUNCHER)
{
fl = IT_EXTRA_WEAPON;
if (self.ammo_rockets
< 2)
am = 1;
}
else if (self.weapon
= IT_EXTRA_WEAPON)
{
fl =
IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
else
{
fl =
IT_GRENADE_LAUNCHER;
if (self.ammo_rockets < 1)
am = 1;
}
}
You could put a simple sprint in to say
which weapon is selected.
This gets the basic selecting out of the way, now for the
cycling weapon command (which is slightly more complicated)
In weapons.qc under void()
CycleWeaponCommand, alter
the section:
else if (self.weapon ==
IT_GRENADE_LAUNCHER)
{
self.weapon = IT_ROCKET_LAUNCHER;
if
(self.ammo_rockets < 1)
am =
1;
}
so that it looks like this:
else if (self.weapon ==
IT_GRENADE_LAUNCHER && self.items == IT_GRENADE_LAUNCHER ||
IT_ROCKET_LAUNCHER)
{
self.weapon = IT_EXTRA_WEAPON;
if
(self.ammo_rockets < 2)
am =
1;
}
This means that if you use the cycle
command when you have the grenade launcher selected, the combined weapon is
pulled up if you have both the grenade launcher and the rocket
launcher.
Then add this directly underneath the last
bit:
else if (self.weapon ==
IT_EXTRA_WEAPON)
{
self.weapon
= IT_ROCKET_LAUNCHER;
if
(self.ammo_rockets < 1)
am =
1;
}
Now, if you want to be able to use the extra weapon
(GL&RL combined) when you cheat (why on earth would you do that :)), in
void() CheatCommand underneath IT_GRENADE_LAUNCHER | place this:
IT_EXTRA_WEAPON |
Next, we need to make Quake cough up the extra fire mode when
you pick up the grenade launcher. You do not need to do this for the rocket
launcher because Quake will perform a check to see if you have both when you try
to fire.
This time in items.qc, find void()weapon_touch and underneath:
new =
IT_GRENADE_LAUNCHER;
add this:
new = IT_EXTRA_WEAPON;
Now that should be it!
When you have both the grenade
launcher and the rocket launcher you can combine em by pressing six twice!!! You
could do this to combine any weapon(s), just use yer common sense and change the
values accordingly.
-Akuma