Inside3D!
     

Bullets and muzzleflash question

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Freemanoid



Joined: 16 Jun 2008
Posts: 52
Location: BELARUS

PostPosted: Tue Jan 26, 2010 8:57 am    Post subject: Bullets and muzzleflash question Reply with quote

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)
_________________
^O,..,o^
Back to top
View user's profile Send private message Visit poster's website
c0burn



Joined: 05 Nov 2004
Posts: 158
Location: Liverpool, England

PostPosted: Tue Jan 26, 2010 9:15 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Jan 26, 2010 11:02 am    Post subject: Reply with quote

I'd suggest not using the nailgun method of shooting but for that machine gun but use the same as the shotgun code's traceline.
Back to top
View user's profile Send private message
MauveBib



Joined: 04 Nov 2004
Posts: 602

PostPosted: Tue Jan 26, 2010 9:31 pm    Post subject: Reply with quote

yup, the cvar sv_maxvelocity is by default set to 2000, so set it higher in autoexec.cfg
_________________
Apathy Now!
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Wed Jan 27, 2010 5:16 am    Post subject: Reply with quote

in my CA mod, i have instagib. But to be honest i dont use a traceline. yet a velocity 10000 for a caustic slug. This has never provided any backdraw for normal gameplay. So, using a 10000 sv_maxvelocity seems safe.
Back to top
View user's profile Send private message
Freemanoid



Joined: 16 Jun 2008
Posts: 52
Location: BELARUS

PostPosted: Wed Jan 27, 2010 9:39 am    Post subject: Reply with quote

Thanks! Sv_maxvelocity really makes different speed! Now it works! what about muzzleflash? Any ideas?
_________________
^O,..,o^
Back to top
View user's profile Send private message Visit poster's website
c0burn



Joined: 05 Nov 2004
Posts: 158
Location: Liverpool, England

PostPosted: Wed Jan 27, 2010 8:46 pm    Post subject: Reply with quote

Code:
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).

http:///c0burn.net/quake/misc/muzzleflash.spr32
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Wed Jan 27, 2010 9:28 pm    Post subject: Reply with quote

c0burn wrote:

This is my muzzleflash code (has some DP specific stuff).

http:///c0burn.net/quake/misc/muzzleflash.spr32


I've been looking for something like this lately. Thanks.
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Wed Jan 27, 2010 10:19 pm    Post subject: Reply with quote

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...

Code:

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.
Back to top
View user's profile Send private message
Freemanoid



Joined: 16 Jun 2008
Posts: 52
Location: BELARUS

PostPosted: Wed Jan 27, 2010 11:33 pm    Post subject: Reply with quote

Thanks to everybody! Now muzzleflash works properly!
_________________
^O,..,o^
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group