Home   Help Search Login Register  

Author Topic: Detecting when a trigger is pulled on an empty chamber  (Read 1866 times)

0 Members and 1 Guest are viewing this topic.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
I'm making a mission replicating a standard FTX (Field Training Excercise).

During FTXs, we are generally issued 2 magazines of blanks, and after we have expended them, we must yell "bang bang bang" to replicate small arms fire. Sparing no expense, I am attempting to replicate this.

As I expected, the "fired" event handler doesn't trip when the magazine is empty and the trigger is pulled. So my question is, is there a method I can use to detect if the player fired and the magazine was empty?
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #1 on: 01 Sep 2007, 12:32:14 »
Once the magazine is empty, its deleted from the player as if he drops it. Therefore if he has no ammo, he has no magazines?

Maybe doing a check to see if the player has any magazines. This is in the COMREF:
Code: [Select]
("_x == {M16}" count magazines soldier1)

Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #2 on: 01 Sep 2007, 15:08:51 »
Hmm, i'm not sure how feasable this is but you could give it a go ...

Obviously the player has run out of ammo when the 'needLoad' command reaches a certain value (i'm assuming 1, not tested that yet though).
How about whenever the player has run out of ammo creating a dialog with a button that covers the whole screen but is invisible, i.e. has a 0 alpha component?  This way when the user clicks again he will hit the button and this can trigger your 'bang bang bang' sound.  Obviously the player will have to have the ability to reload disabled until they click the button and you can code the dialog so that if it's closed by Esc it will automatically reload etc etc.   :P

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #3 on: 01 Sep 2007, 19:14:46 »
@JasonO
Thanks for the reply, but the trick is detecting when the player has clicked the mouse button to fire. Therefore, I can't use your solution unless there is a way to map which mouse button was clicked.

@paddy
Is it possible to still turn and move with a dialog up? That would be the only limitation to the dialog portion.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #4 on: 01 Sep 2007, 20:34:56 »
Quote
Is it possible to still turn and move with a dialog up? That would be the only limitation to the dialog portion.

Yes, that is a limitation but surely the player is supposed to shout before they do anything else?  I know its a crappy workaround but I think unless you want to just have a 'round counter' variable that counts to 30 and then spits out a bang bang bang msg thats all I can think of.
Probably okay cause its just a training mission, wouldnt really work on a real-time mission, having your squad shout 'bang bang bang' MIGHT give away their pos in rl lol.  ;)

Be interested to see if anyone can think of anything snazzier, maybe some kind of addon with a '31st round' type thing, but then thats an addon and this is a scripting forum  :whistle:.

Lookin 4ward to hearing what you go for.

Offline Cheetah

  • Former Staff
  • ****
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #5 on: 01 Sep 2007, 20:57:52 »
I think that there are certain commands that enable you to detect when a specific button has been pressed. Can't find the command, but I recall that mandoble uses this for his Missile Suite (could be wrong).

Where he detects if buttons like 'A' and 'E' have been pressed. As far as I know this is possible.

As a start, you could take a look at actionKeys.

EDIT:

it has to do with finding the correct key (keyName) and then checking if it's active / has been pressed I guess..
« Last Edit: 01 Sep 2007, 21:02:16 by Cheetah »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!


Offline paddy

  • Contributing Member
  • **
  • Llama whipping good
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #7 on: 02 Sep 2007, 00:37:47 »
@ Cheetah & JasonO
Yes, I know this is possible, i've used it before.  Originally I think either Vektorbosen or UNN discovered that one, it was in OFP and didnt use actionkeys of displaysetEH because those are ArmA commands!!!  However Tyger asked is there any way to detect if a unit fires with no round in the chamber, i assumed he was using the mouse (most people do, ctrl is a little awkward in fps) and neither of these commands work with a mouseclick, or do they??

Still, yet asnother unsolved ArmA scripting issue, you mission gentlemen .. should you choose to accept it ...

N.B. Im waiting for my new comp, I cant run ArmA yet  :(, else I would test this myself

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #8 on: 02 Sep 2007, 12:03:49 »
I'd add an option in the action menu. After all, it'd be more real since in reality shouting and shooting isn't exactly the same action. But that's just me.

Offline Tyger

  • Former Staff
  • ****
  • I was at OFPEC when it still had dirt floors...
    • OFPEC
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #9 on: 03 Sep 2007, 01:18:46 »
Thanks for the comments mates. I'll take a look at the displaySetEventHandler and see if I can dig the mouse out of that one.
"People sleep soundly at night only because rough men stand ready to do violence on their behalf." - George Orwell

MSG Mike Everret - We Will Never Forget - '75-'08

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Detecting when a trigger is pulled on an empty chamber
« Reply #10 on: 04 Sep 2007, 20:17:17 »
The problem is that the displaySet eventhandlers only detect which keys (or mouse button?) are pressed, not how the player has mapped them. There is no guarantee that each player has mapped his controls the same.  It is a real shortcoming that you can not detect how a player has mapped his keyboard/controls.
« Last Edit: 04 Sep 2007, 20:31:18 by Mr.Peanut »
urp!