Ceriux's Nub Tutorials [QC basics custom weps]
Posted: Sun Feb 28, 2010 6:31 am
Okay so you have your weapon modeled,skinned, and animated. ready to be put in game.
so for the first steps put your v_pistol.mdl in yourmod/progs folder.
then open up "weapons.qc" then scroll down for find this: void() W_SetCurrentAmmo once there look for this:
and change it so it looks like this:
then scroll down to here:
void() W_Attack
and find this:
we're going to make it fire a little fast so change
to this
next when your finished find.
void() W_FireShotgun
and change it from this:
to this:
lets look at this:
FireBullets is the function
(1, dir, '0.059 0.059 0')
the one in this function is how many bullets are being fired from the gun. and this '0.059 0.059 0' is the x y z cordinantes which tell the code how accurate the weapon is, the larger the number the more inaccurate the smaller the number the more accurate it is.
next we'll go into client.qc and scroll down to the ClientObituary function and scroll down till you see.
and change that chunk of code to match this:
lastly we need to go to world.qc and scroll down till you see :
and change it to
or leave it the same and scroll down to the end of that list and add it there.
there all finished. compile, hop in game and test out what you got. after that if you dont like it, using what you've learned (which hopefully you did learn something) go back and change some stuff around and see what you get.
src: tutmodp1.zip
so for the first steps put your v_pistol.mdl in yourmod/progs folder.
then open up "weapons.qc" then scroll down for find this: void() W_SetCurrentAmmo once there look for this:
Code: Select all
else if (self.weapon == IT_SHOTGUN)
{
self.currentammo = self.ammo_shells;
self.weaponmodel = "progs/v_shot.mdl";
self.weaponframe = 0;
self.items = self.items | IT_SHELLS;
}
Code: Select all
else if (self.weapon == IT_SHOTGUN) // if your weapon is the shotgun (pistol)
{
self.currentammo = self.ammo_shells; // the weapons uses shells
self.weaponmodel = "progs/v_pistol.mdl"; // the model is this (v_pistol.mdl)
self.weaponframe = 0; // starts at the beggining of the weapons animations (all .mdls in quake start at 0) so if you have 6 frames it actually counts as 0,1,2,3,4,5.
self.items = self.items | IT_SHELLS; // has shells
}
then scroll down to here:
void() W_Attack
and find this:
Code: Select all
else if (self.weapon == IT_SHOTGUN)
{
player_shot1 ();
W_FireShotgun ();
self.attack_finished = time + 0.5;
}
Code: Select all
self.attack_finished = time + 0.5;
Code: Select all
self.attack_finished = time + 0.3;
next when your finished find.
void() W_FireShotgun
and change it from this:
Code: Select all
/*
================
W_FireShotgun
================
*/
void() W_FireShotgun =
{
local vector dir;
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 100000);
FireBullets (6, dir, '0.04 0.04 0');
};
Code: Select all
/*
================
W_FireShotgun
================
*/
void() W_FireShotgun =
{
local vector dir;
sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);
self.punchangle_x = -2;
self.currentammo = self.ammo_shells = self.ammo_shells - 1;
dir = aim (self, 18000);
FireBullets (1, dir, '0.059 0.059 0');
};
Code: Select all
FireBullets (1, dir, '0.059 0.059 0');
(1, dir, '0.059 0.059 0')
the one in this function is how many bullets are being fired from the gun. and this '0.059 0.059 0' is the x y z cordinantes which tell the code how accurate the weapon is, the larger the number the more inaccurate the smaller the number the more accurate it is.
next we'll go into client.qc and scroll down to the ClientObituary function and scroll down till you see.
Code: Select all
if (rnum == IT_SHOTGUN)
Code: Select all
if (rnum == IT_SHOTGUN)
{
deathstring = " was shot down by";
deathstring2 = "'s pistol\n";
}
Code: Select all
precache_model ("progs/v_shot.mdl");
Code: Select all
precache_model ("progs/v_pistol.mdl");
there all finished. compile, hop in game and test out what you got. after that if you dont like it, using what you've learned (which hopefully you did learn something) go back and change some stuff around and see what you get.
src: tutmodp1.zip