PDA

View Full Version : self.m_flDelay ?



Nero
08-04-2016, 10:12 PM
I'm making a weapon that needs a slight delay before firing, is that what m_flDelay in CBasePlayerWeapon is for?
(PrimaryAttack plays a wind-up sound then needs to call a method that fires the projectile after a slight delay)

It doesn't seem to be doing anything no matter where I put it. D:

Being a mapper and not a coder, I'm guessing it's that kind of "Delay before fire" :[

w00tguy123
09-04-2016, 11:32 AM
I haven't tried using it myself, but you can implement your own delay in a Think function. Create a variable called "nextShootTime" which you set when the primary fire is pressed, and then start the shooting code when that time is reached.

Solokiller
09-04-2016, 12:33 PM
m_flDelay is used by CBaseDelay and derived classes to delay trigger targets. It doesn't affect weapon behavior in any way.

Typically, you'll do what W00tguy suggests. Set a next shoot time in PrimaryAttack, then make WeaponIdle execute either often enough or when you want to perform your action. Alternatively, override ItemPostFrame and handle it there. That's cleaner than re-purposing WeaponIdle, but you'll have to make sure to call the baseclass implementation so you don't break the weapon code.

Nero
10-04-2016, 12:55 AM
Aye I figured as much.

Thanks, that seems to do the trick! :D