Home   Help Search Login Register  

Author Topic: Detecting unsilenced weapon  (Read 3106 times)

0 Members and 1 Guest are viewing this topic.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unsilenced weapon
« Reply #15 on: 11 Sep 2005, 16:12:45 »
Most certainly. :-[
« Last Edit: 11 Sep 2005, 16:14:21 by THobson »

pazuzu

  • Guest
Re:Detecting unsilenced weapon
« Reply #16 on: 11 Sep 2005, 20:32:15 »
I don't know what I'm doing wrong but I cant get this to work right.

I created a test trigger using the variable "loud" as the condition & a Hint to tell me the trigger fired.

For some reason It keeps firing if I have AI drop a BAS_JM249SPWSD & I fire it so I went back to check the name in the bas delta readme & it is right. If I play in any spot that is not leader & just kill the AI to get his BAS_JM249SPWSD the trigger does not fire. This is a mystery to me.

Using THobson's eventhandler I listed all the east weapons & it worked perfectly. The only thing missing was the creation of a global variable (loud).

I like the idea of using a script. Could I maybe list east weapons to be detected when fired by players?

I also like the hint format ["%1 fired an unsilenced weapon" message.

Could I add that to the script?

Also the script fired my test trigger only once. I wanted a warning message to appear every time any player tried to fire an enemy unsilenced weapon.

BTW the enemy only has unsilenced weapons.

Thanks again.

Kyle Sarnik

  • Guest
Re:Detecting unsilenced weapon
« Reply #17 on: 11 Sep 2005, 23:16:31 »
Code: [Select]
_unit = _this select 0
_weapon = _this select 1

? _weapon in ["BAS_JM4ACOGS","BAS_JM249SPWSD","BAS_JSR25S"] : exit

hint format ["%1 has fired an unsuppressed weapon.",name _unit]

exit

So all you want is a warning? If you want something to happen you might want to add a variable but if all you want is a hint then this script will work.

pazuzu

  • Guest
Re:Detecting unsilenced weapon
« Reply #18 on: 11 Sep 2005, 23:55:18 »
No thats the thing...

I want both a message and a variable and as far as my testing goes having a list of enemy weapons to detect as being fired by player seems to work the best.

Such as THobson's code:

this addEventHandler [{fired},{if ((_this select 1) in ["JAM_AKM","JAM_Vz58","JAM_AK74","JAM_AKS74U","JAM_PKM","JAM_PKMFS","JAM_AKMGL","JAM_AK74GL","JAM_SVD","JAM_RPG7Launcher","JAM_SKS","JAM_RPD","JAM_CAVS_RPG7Launcher","JAM_RPDFS","JAM_PKMFS"]) then {hint format ["%1 fired an unsilenced weapon",_this select 0]} }]

The only thing missing is the variable.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unsilenced weapon
« Reply #19 on: 12 Sep 2005, 00:38:48 »
So why don't you use:

this addEventHandler [{fired},{if ((_this select 1) in ["JAM_AKM","JAM_Vz58","JAM_AK74","JAM_AKS74U","JAM_PKM","JAM_PKMFS","JAM_AKMGL","JAM_AK74GL","JAM_SVD","JAM_RPG7Launcher","JAM_SKS","JAM_RPD","JAM_CAVS_RPG7Launcher","JAM_RPDFS","JAM_PKMFS"]) then {loud = true} }]


and in the init.sqs file put

loud = false

?

If you want the variable and the message then use:

this addEventHandler [{fired},{if ((_this select 1) in ["JAM_AKM","JAM_Vz58","JAM_AK74","JAM_AKS74U","JAM_PKM","JAM_PKMFS","JAM_AKMGL","JAM_AK74GL","JAM_SVD","JAM_RPG7Launcher","JAM_SKS","JAM_RPD","JAM_CAVS_RPG7Launcher","JAM_RPDFS","JAM_PKMFS"]) then {hint format ["%1 fired an unsilenced weapon",_this select 0];loud = true} }]
« Last Edit: 12 Sep 2005, 00:39:55 by THobson »

pazuzu

  • Guest
Re:Detecting unsilenced weapon
« Reply #20 on: 12 Sep 2005, 00:46:11 »
Thank you THobson.

That looks like exactly what I wanted.

Going to test it now...

Kyle Sarnik

  • Guest
Re:Detecting unsilenced weapon
« Reply #21 on: 12 Sep 2005, 01:37:29 »
Its better to detect if the unit is using silenced weapons rather then looking for all of te unsilenced ones. Also your hint won't show just their name, but their ID (side, group, group unit #, then name). So that means:

Code: [Select]
_unit = _this select 0
_weapon = _this select 1

? _weapon in ["BAS_JM4ACOGS","BAS_JM249SPWSD","BAS_JSR25S"] : exit

hint format ["%1 has fired an unsuppressed weapon.",name _unit]
loud = true

exit

Its better to use a script, because you can make changes more easily and it saves a lot of repetative typing.

Also, you don't have to set loud to false at the begining, since by default its neither true or false so it won't set anything off.

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:Detecting unsilenced weapon
« Reply #22 on: 12 Sep 2005, 02:31:56 »
What exactly do you plan on doing with the variable 'loud = true' once the insilenced weapon script has been called?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting unsilenced weapon
« Reply #23 on: 12 Sep 2005, 09:00:10 »
Quote
Also, you don't have to set loud to false at the begining
Wrong - well not always correct.  A local variable that is created within {} will not exist outside that set of instructions.  Also it is good practice to initialise all your variables first.  For example - I have no idea what pazuzu plans to do with the variable loud, but let's say he wants something to happen providing only silenced weapons have been fired he would use somethign like:

if ((some condition) and not loud) then {}

If loud has not been initiailised the if condition will resolve to a false even if a loud weapon has not been fired.

I agree it would be better to check to see if the fired event was triggered by a silenced weapon, and it would be better to use a script.  But for some reason pazuzu seems unable to make any of that work.

Now you are defining _unit and _weapon correctly I can see no reason why your script would not work.
« Last Edit: 13 Sep 2005, 14:35:04 by THobson »

pazuzu

  • Guest
Re:Detecting unsilenced weapon
« Reply #24 on: 12 Sep 2005, 09:52:50 »
I got the script to work now.

But at the end of the mission I want to be able to use some east weapons to ambush a boat convoy. I'm not sure which weapons yet but I guess I could just add them to list in script so they can be used.

Might look kinda strange if only some east weapons can be used....I'm gonna have to think about it...

I appreciate all your help.

Edit: Is there a way to make the use of unsilenced weapons ok at last objective?
« Last Edit: 12 Sep 2005, 09:55:17 by pazuzu »