• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Help coding new weapon

Six_Ten

Grizzled Veteran
Mar 12, 2006
1,382
400
aztecmod.darkesthourgame.com
I'm making a musket by converting the Kar98.

What I want to happen is

player squeezes trigger:

0 seconds
weapon animation begins, flint strikes steel, there's a flash in the pan and smoke rises from pan

1 second later
bullet is fired, muzzle flash, muzzle smoke

How do I code the delay from the time the trigger is squeezed and the pan is ignited, to the bullet being fired and the muzzle flash and smoke?

So far what I have is:

0 seconds
weapon animation begins, flint strikes steel, there's a flash in the pan and smoke rises from pan, bullet is fired, muzzle flash, muzzle smoke all simultaneously.
 
Last edited:
Use a timer, it's the safest and easiest way to do this, though there are other ways if you wanted to get complicated.

You need to split your function calls. Have the 0 second ones running where they are, but add an extra line:

SetTimer(1,false);

Then modify the Timer() function to call the remaining function calls for the 1 second mark.

Code:
simulated function Timer()
{
         // Call Bullet Code
    // Flash Code
    // Call Smoke Code
}

Be careful though - if Timer is already being used for something, you'll either need to use a new bool to differentiate between old and new functionality (and you'll need to be careful not to wreck the existing timer).

Also, if you intend for this to work online, you'll need to ensure that the server is actually running those 1 second items and you may need to make sure that the third person effects are delayed as well.
 
Last edited:
Upvote 0