1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

probelms with stopfire... (weapons)

Discussion in 'Programming' started by Sg_Jack, Nov 16, 2001.

  1. Sg_Jack

    Sg_Jack New Member

    Joined:
    Nov 12, 2001
    Messages:
    12
    Likes Received:
    0
    Hi !

    sorry, it's me again :) I found this forum which i didn't knew, so i benefit a little to have you here :) Excuse me again !

    Well, i have realistic weapons, and as you may know, sidearms don't fire like a machinegun ! If you take a HK mark23 (my favorite weapon) and if you hit the trigger, the weapon will fire just one bullet and will stop (in semi-auto mode).

    I have made a function call "stopfire" in order to stop the autofire. It works perfectly but there is a problem : if you clik very fast, the weapon will fire at every click... So, you can fire as fast as a machingun if you are fast !

    I tried to add a sleep in my stop function, but it don't works... Is anybody know what could be the problem ? I don't understand why this xxxx sleep function don't work...
     
  2. Captain Kewl

    Captain Kewl I know kewl.

    Joined:
    Feb 13, 2001
    Messages:
    794
    Likes Received:
    0
    I'm assuming your firing rate is once per firing animation here...

    Actors have an IsAnimating(); function that returns true if they are in the middle of an animation sequence. There's also AnimSequence which returns a string of the name of the animation currently playing. Maybe use something like this?

    if ( !IsAnimating() || AnimSequence != 'Fire' )
    {
    DoFireStuff();
    }
     
  3. Euphoric Beaver

    Euphoric Beaver impeccably groomed

    Joined:
    Apr 19, 2001
    Messages:
    3,158
    Likes Received:
    0
    I may of misread it and you proberly know this but you can't do latent functions like sleep inside functions. They only work in states.
     
  4. mr.s-d

    mr.s-d CHiMERiC Moderator

    Joined:
    Aug 30, 2001
    Messages:
    65
    Likes Received:
    0
    Something like this should work:

    state NormalFire
    {
    ignores Fire, AltFire, AnimEnd;

    Begin:
    FinishAnim();
    // If the player is still trying to fire...
    while (Pawn(Owner).bFire != 0);
    {
    Sleep(0.05);
    if (bChangeWeapon)
    GotoState('DownWeapon');
    }
    Finish();
    }

    Should work (haven't tested it) as it's a condensed form of some code I made to do the same job, only it used two states and I can't remember why.
     
  5. Sg_Jack

    Sg_Jack New Member

    Joined:
    Nov 12, 2001
    Messages:
    12
    Likes Received:
    0
    Thanks, it works very well :)

    Oh yes, i know that sleep only works with states... My stopfire() function refers to a state where i used sleep.. Bu it didn't work.

    well, thanks again :)
     

Share This Page