Augustine: Despondent
Welcome to our Forums! Please login or register! You can introduce yourself here!









Join the forum, it's quick and easy

Augustine: Despondent
Welcome to our Forums! Please login or register! You can introduce yourself here!







Augustine: Despondent
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Augustine: Despondent

Welcome to the forums! We are the homeplace for Slender: Darkplaces, Augustine, Nightfall survival, and Revamped 1.


You are not connected. Please login or register

[Tutorial] Adding MuzzleFlashes to weapons

3 posters

Go down  Message [Page 1 of 1]

Mexicouger

Mexicouger
Noble
Noble

In this tutorial, I will teach you how to add Muzzle Flashes, or that Fire that comes out of weapons, To your weapons.

First off, open up weapons.qc, and Right under This function:

void() W_Precache =

Add this:

void() MuzzleFlash =
{
local entity flash;
flash = spawn();
flash.movetype = MOVETYPE_NONE;
flash.solid = SOLID_NOT; //Can't hit anything
flash.owner = self;

switch (self.weapon) //Evaluates the weapon you have and spawns the appropriate Flash
{
case IT_SHOTGUN:
setmodel (flash, "progs/flash.spr");
break;
case IT_NAILGUN:
setmodel (flash, "progs/flash2.spr");
break;
default:
setmodel (flash, "progs/flash3.spr");
}

setorigin (flash, self.origin + '0 0 16' + v_forward * 16); //Sets the flash right in front of the player

flash.think = SUB_Remove; //The flash removes itself from the world.
flash.nextthink = time + 0.1;
};

Next, Goto the function I posted earlier, void() W_Precache =
And Add this at the top of it.

precache_model ("progs/flash1.spr");
precache_model ("progs/flash2.spr");
precache_model ("progs/flash3.spr");

That let's quake know you want to use them. If you don't add a precache for a model, You will get an error.
Should look like this:
http://codepad.org/y0bL1P5N

And Before we add it to a certain weapon, I just want you to know that you can add more weapons to that switch statement:
switch (self.weapon) //Evaluates the weapon you have and spawns the appropriate Flash
{
case IT_SHOTGUN:
setmodel (flash, "progs/flash.spr");
break;
case IT_NAILGUN:
setmodel (flash, "progs/flash2.spr");
break;
case IT_SUPER_SHOTGUN: //Just add more weapons like that.
setmodel (flash, "progs/flash2.spr");
break;
default: //If the player/entity doesn't have any of the weapons above, then use this one
setmodel (flash, "progs/flash3.spr");
}

Now, Go down to any Firing function. In this tutorial, we are going to go down to W_FireShotgun
Now just add this To the top of the function or anywhere in the function:

MuzzleFlash();

Now a Muzzle Flash will spawn when you Fire the weapon. Add that to any function to spawn the Flash.

-Mexicouger

https://augustine.forumotion.com

jukki

avatar
Warrant Officer Grade 3
Warrant Officer Grade 3

REmeber that thouse switch etc things are not used by most compliers.

Mexicouger

Mexicouger
Noble
Noble

That is pretty dumb then because switch statements are much cleaner then if statements

https://augustine.forumotion.com

thock321

avatar
Hero
Hero

another tut!!! its pretty good

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum