Bullets and muzzleflash question
Moderator: InsideQC Admins
10 posts
• Page 1 of 1
Bullets and muzzleflash question
Hello everybody. I am trying to make realistic bullet firing and muzzleflash for it. But I have 2 problems :
1) Bullets fly very slowly. (I am modifying launch_spike function)
Here it is, check where I can be wrong :
void(vector org, vector dir) launch_spike =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/bullet.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 1000000;
};
Here I just tried to set up more speed, and then :
void(float ox) W_FireSpikes =
{
local vector dir;
local entity old;
local float spreadx, spready, bulletspd;
spreadx = 0.04;
spready = 0.04;
makevectors (self.v_angle);
if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
{
W_FireSuperSpikes ();
return;
}
if (self.ammo_nails < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
//dir = aim (self, 1000); //OLD dir
bulletspd = 700000;
dir = (v_forward + crandom()*spreadx*v_right + crandom()*spready*v_up) * 1000000000000000000000;
launch_spike (self.origin + '0 0 17' + v_right*7 + v_forward * 20, dir*bulletspd);
launch_muzzle (self.origin + '0 0 17' + v_right*7 + v_forward * 40, dir*0);
self.punchangle_x = -2;
};
Here I tried to set up more speed too. But (for bullets) it moving very slowly.
2) I have muzzleflash, And there is some problems with it.
When I starting to shoot, my muzzleflash become very big. (Sprite is about 24x24 pixels)
And if I set up "Full lighting" in darkplaces, its not always appear.
For example, if I shoot 10 times, I see muzzleflash only 2-3.
Here is my qc of it :
void(vector org, vector dir) launch_muzzle =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_NONE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.classname = "muzzle";
newmis.think = SUB_Remove;
newmis.nextthink = time + 0.01;
setmodel (newmis, "progs/muzzle.spr");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 0;
};
(On image I just paste muzzle sprite in picture, because in-game I cannot catch it)
(Sorry for my english)
1) Bullets fly very slowly. (I am modifying launch_spike function)
Here it is, check where I can be wrong :
void(vector org, vector dir) launch_spike =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_FLYMISSILE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.touch = spike_touch;
newmis.classname = "spike";
newmis.think = SUB_Remove;
newmis.nextthink = time + 6;
setmodel (newmis, "progs/bullet.mdl");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 1000000;
};
Here I just tried to set up more speed, and then :
void(float ox) W_FireSpikes =
{
local vector dir;
local entity old;
local float spreadx, spready, bulletspd;
spreadx = 0.04;
spready = 0.04;
makevectors (self.v_angle);
if (self.ammo_nails >= 2 && self.weapon == IT_SUPER_NAILGUN)
{
W_FireSuperSpikes ();
return;
}
if (self.ammo_nails < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
self.attack_finished = time + 0.2;
self.currentammo = self.ammo_nails = self.ammo_nails - 1;
//dir = aim (self, 1000); //OLD dir
bulletspd = 700000;
dir = (v_forward + crandom()*spreadx*v_right + crandom()*spready*v_up) * 1000000000000000000000;
launch_spike (self.origin + '0 0 17' + v_right*7 + v_forward * 20, dir*bulletspd);
launch_muzzle (self.origin + '0 0 17' + v_right*7 + v_forward * 40, dir*0);
self.punchangle_x = -2;
};
Here I tried to set up more speed too. But (for bullets) it moving very slowly.
2) I have muzzleflash, And there is some problems with it.
When I starting to shoot, my muzzleflash become very big. (Sprite is about 24x24 pixels)
And if I set up "Full lighting" in darkplaces, its not always appear.
For example, if I shoot 10 times, I see muzzleflash only 2-3.
Here is my qc of it :
void(vector org, vector dir) launch_muzzle =
{
newmis = spawn ();
newmis.owner = self;
newmis.movetype = MOVETYPE_NONE;
newmis.solid = SOLID_BBOX;
newmis.angles = vectoangles(dir);
newmis.classname = "muzzle";
newmis.think = SUB_Remove;
newmis.nextthink = time + 0.01;
setmodel (newmis, "progs/muzzle.spr");
setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);
setorigin (newmis, org);
newmis.velocity = dir * 0;
};
(On image I just paste muzzle sprite in picture, because in-game I cannot catch it)
(Sorry for my english)
^O,..,o^
- Freemanoid
- Posts: 52
- Joined: Mon Jun 16, 2008 11:25 am
- Location: BELARUS
You'll need to modify one of the cvars for maximum speed allowed for entities. I think it's sv_maxvelocity or something similar. Regarding your muzzleflash, I have some code at home that I will put up here later that should do the job.
- c0burn
- Posts: 208
- Joined: Fri Nov 05, 2004 12:48 pm
- Location: Liverpool, England
Thanks! Sv_maxvelocity really makes different speed! Now it works! what about muzzleflash? Any ideas?
^O,..,o^
- Freemanoid
- Posts: 52
- Joined: Mon Jun 16, 2008 11:25 am
- Location: BELARUS
- Code: Select all
void() mflash_think =
{
self.frame = self.frame + 1;
if (self.frame > 19)
remove(self);
else
self.nextthink = time + 0.005;
};
void() spawn_mflash =
{
entity m;
makevectors(self.v_angle);
m = spawn();
setmodel(m, "progs/muzzleflash.spr32");
setorigin(m, self.origin + v_forward*100);
m.drawonlytoclient = self;
m.effects = EF_FULLBRIGHT | EF_NODEPTHTEST;
m.alpha = 0.5;
m.scale = 1;
m.colormod = '8 8 8';
m.think = mflash_think;
m.nextthink = time + 0.005;
};
This is my muzzleflash code (has some DP specific stuff).
[url]http:///c0burn.net/quake/misc/muzzleflash.spr32[/url]
- c0burn
- Posts: 208
- Joined: Fri Nov 05, 2004 12:48 pm
- Location: Liverpool, England
c0burn wrote:This is my muzzleflash code (has some DP specific stuff).
[url]http:///c0burn.net/quake/misc/muzzleflash.spr32[/url]
I've been looking for something like this lately. Thanks.
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
-

Chip - Posts: 575
- Joined: Wed Jan 21, 2009 9:12 am
- Location: Dublin, Ireland
If you are using DP only, I would suggest viewmodelforclient so the muzzleflash isn't "left behind" when you move. Even though that might be "more realistic", to me it looks ugly.
What I did was create a model, which was just a square, then texture it with a muzzleflash, and give the entity EF_ADDITIVE. This lets me scale and rotate it as well...
This looks good on rapidly firing weapons, because when the muzzleflash is randomly scaled and rotated, it looks like a different one each time (instead of looking like a single cheesy flash that stays put as long as you are firing).
Download nailflash.mdl and nailflash_mdl_0.tga: http://www.icculus.org/~sajt/nailflash.zip
What I did was create a model, which was just a square, then texture it with a muzzleflash, and give the entity EF_ADDITIVE. This lets me scale and rotate it as well...
- Code: Select all
void(vector org, float _scale, string _model, float lifetime) W_MuzzleFlash =
{
newmis = spawn();
setmodel(newmis, _model);
newmis.effects = EF_FULLBRIGHT | EF_ADDITIVE;
newmis.origin = org;
newmis.angles_z = random() * 360; // rotate the image randomly
newmis.scale = _scale;
newmis.viewmodelforclient = self;
newmis.think = SUB_Remove;
newmis.nextthink = time + lifetime;
self.effects = self.effects | EF_MUZZLEFLASH;
};
...
local vector ofs;
local float rscale, lifetime;
ofs = '16 -3.64 -5.74'; // where, on the v_ gun model, to spawn it (you'll need to change this)
scale = 0.3 + random(); // random scale between 0.3 and 1.3
lifetime = 0.05; // disappear in 1/20th of a second
W_MuzzleFlash (ofs, rscale, "progs/nailflash.mdl", lifetime);
This looks good on rapidly firing weapons, because when the muzzleflash is randomly scaled and rotated, it looks like a different one each time (instead of looking like a single cheesy flash that stays put as long as you are firing).
Download nailflash.mdl and nailflash_mdl_0.tga: http://www.icculus.org/~sajt/nailflash.zip
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
10 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
