Changing turret rate of fire Created 15 years ago2009-03-25 12:03:41 UTC by The Mad Carrot The Mad Carrot

Created 15 years ago2009-03-25 12:03:41 UTC by The Mad Carrot The Mad Carrot

Posted 15 years ago2009-03-25 12:03:41 UTC Post #264548
So i want to slightly increase the rate of fire of the turret and maybe the sentry as well.

I searched through its entire sourcefile (turret.cpp) and changed some if not all numeric values (NextAttack or whatever), but non of those changed seem to affect the turret's rate of fire.

Anyone know where the rate of fire is defined?
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 13:10:25 UTC Post #264552
You could do it by decompiling turret model, then open qc file and edit the event points on fire sequence.
Posted 15 years ago2009-03-25 14:44:58 UTC Post #264559
You mean this:

$sequence "fire" "fire" fps 150 loop {
{ event 5001 0 "51" }
{ event 5001 10 "51" }
{ event 5001 20 "51" }
}

None of those values change the rate of fire.
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 15:34:22 UTC Post #264561
Make fps highter and it will move and shoot faster.
Posted 15 years ago2009-03-25 16:25:43 UTC Post #264566
Wouldn't it only seem as if it shot faster but infact the gun would still use some part of another code to actually shoot. Isn't the change in the qc file just for the animation ?
Posted 15 years ago2009-03-25 16:33:25 UTC Post #264567
Changing the fps from 150 to 300 didn't increased the ROF.
Wouldn't it only seem as if it shot faster but infact the gun would still use some part of another code to actually shoot. Isn't the change in the qc file just for the animation ?
Well, i tried editting numeric values in both the qc file and the turret cpp source file, but none of those values seem to change the ROF ingame.

I don't get it.

The first thing i tried was changing the 0.6 value in the Shoot function to something higher, but noo... :/ I could've sworn that that defined the ROF... Guess not.

void CTurret::Shoot(Vector &vecSrc, Vector &vecDirToEnemy)
{
FireBullets( 1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_12MM, 1 );
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.6);
pev->effects = pev->effects | EF_MUZZLEFLASH;
}
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 16:48:00 UTC Post #264569
You're looking at the wrong function. Shoot() doesn't handle timing, it just fires a bullet and emits a sound (that 0.6 defines volume of the shot sound).

Haven't tested this, but I think the easiest/hackiest way to achieve what you need would be to change
pev->nextthink = gpGlobals->time + 0.1;
located at the top of
[blue]CBaseTurret::ActiveThink(void)[/blue]
in turret.cpp to
pev->nextthink = gpGlobals->time + 0.05;
or a smaller value. Nextthink defines how often ActiveThink is called, which handles shooting, targetting, etc.
Daubster DaubsterVault Dweller
Posted 15 years ago2009-03-25 17:57:59 UTC Post #264570
Alright.
I changed it to:

pev->nextthink = gpGlobals->time + 0.05;

And guess what? No change in ROF ingame. Then i tried:

pev->nextthink = gpGlobals->time + 8.0;

And that did'nt do squat either.
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 17:58:39 UTC Post #264571
Hmm.. was pretty sure that would work. D:
Maybe it is model-defined? Human grunt ROF is afaik.
Daubster DaubsterVault Dweller
Posted 15 years ago2009-03-25 18:00:29 UTC Post #264572
I decompiled the turrent and editted the qc file.

Nothing.
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 18:39:21 UTC Post #264575
If I recall correctly bullet creation is shared between the server and client. Although, even if you just change it server-side you should still receive damage faster but not be able to see the bullets. Hm.

Oh, and I haven't hade the time to look at the shocktrooper yet, I'm so goddamn busy, sry.
ChickenFist ChickenFist<Witty Title>
Posted 15 years ago2009-03-25 18:41:49 UTC Post #264577
No rush, chickenfist, but if you find the time to work on it, go for it. :)

As for the turret ROF, what do i do now?
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-03-25 18:58:01 UTC Post #264578
Well, I still think you have to decrease the delay between thinks.
Are you sure it doesn't reset the nextthink in SpinUpCall() ?
If that doesn't work you could always write your completely own turret code that constantly fires. :D
ChickenFist ChickenFist<Witty Title>
Posted 15 years ago2009-03-25 19:21:16 UTC Post #264580
I have no idea.

Writing my own turret code is out of the question im affraid.
The Mad Carrot The Mad CarrotMad Carrot
Posted 15 years ago2009-04-07 06:57:27 UTC Post #265151
Which mod is this for? I don't have a turret.cpp in the HL SDK (as far as I can see, anyway!)

However, I looked through the func_tank.cpp file on the theory that the concept was the same, and found that m_fireRate variable is actually fed in from the map itself (ie, the func_tank entity has a "rate of fire" value.) Does the same apply for turrets?

Just thinking out loud; obviously I don't have a turret to play with...

Edit because ... well, just because!

D'oh! Of course turret.cpp is in the single-player code (which I've deleted from my working copy of the SDK!) As far as I can see, the rate of fire of the turret should be controlled by the pev->nextthink line that Daubster pointed out. However, changing that delay time won't change the animation speed... But if it's not working ... dunno.
You must be logged in to post a response.