Home   Help Search Login Register  

Author Topic: Checking which weapon is selected  (Read 671 times)

0 Members and 1 Guest are viewing this topic.

Rubble_Maker

  • Guest
Checking which weapon is selected
« on: 03 Jul 2003, 15:19:11 »
PicVert posted this code on the official forums, saying it checks which weapon a unit has selected:

#loop
~0.03
? (not alive _vehicle) : exit
? _Piranha [Weapons "XXX_1"] : exit
? _Piranha [Weapons "XXX_2"] : goto "ammoL"
goto "loop"

I dont have the slightest idea how this could work. Is it a special syntax of the "weapons" command or what?



Komuna

  • Guest
Re:Checking which weapon is selected
« Reply #1 on: 03 Jul 2003, 17:48:26 »
Indeed, that piece of code won't work (Well... in my point of view, of course). However, I believe there's somewhere a command very similar to 'Weapon'. Check it and then apply the following code:

Code: [Select]
#loop

~.01

? !(alive _unit): exit
? Weapon _unit == "WeaponName" : goto "Proceed"
? Weapon _unit == "NonWantedWeaponName" : exit

Goto "loop"

#Proceed
<code>

Weapon <soldier>
returns a String with the carried weapon name.

Instead of directly adding the strings "WeaponName" and "NonWantedWeaponName" you could associate them trough variables. The script's paramters could be:

[_unit,_Weapon,_WeaponExit] exec "WeaponChecker.sqs"
« Last Edit: 03 Jul 2003, 17:50:01 by Komuna »

Rubble_Maker

  • Guest
Re:Checking which weapon is selected
« Reply #2 on: 03 Jul 2003, 19:13:38 »
Mhmm, but this would check if the unit HAS a certain weapon, but not if it has selected it, no? I want, for example, know if a soldier selectes the LAW launcher. As I understand picVert's post, thats exactly what he can do with this code.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Checking which weapon is selected
« Reply #3 on: 03 Jul 2003, 19:16:17 »
I love it when people post untested code.

No, it won't work.

The commands are:

weapons unit
magazines unit

these two return arrays with the weapons and magazines a unit is carrying.  They do not indicate the currently selected weapon

unit hasweapon "weapontype"
is a boolean

I would very much like to see someone post a way to find the selected weapon; nobody has done so yet.
Dinger/Cfit

BronzeEagle

  • Guest
Re:Checking which weapon is selected
« Reply #4 on: 05 Jul 2003, 05:27:55 »
its just not possible with the current patch.  if it were, then id have mafia shoot my mib guy when he pulls his gun out like a real western gunfight.  lets get this to happen!

BronzeEagle

  • Guest
Re:Checking which weapon is selected
« Reply #5 on: 05 Jul 2003, 05:34:36 »
oh wait.  hey, can't you do a:

 player addEventHandler ["combat", {_this exec "guninhand.sqs"}]

you just have to know the events then, right?

Komuna

  • Guest
Re:Checking which weapon is selected
« Reply #6 on: 07 Jul 2003, 12:03:15 »
Quote
I love it when people post untested code.
:-X ::)

Oh! You want to check which weapon is select, not which weapons are carried... right?

Then, sorry, BronzeEagle is right. Not possible through conventional means...

How does "combat" event handler work? Which paramters are returned?

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:Checking which weapon is selected
« Reply #7 on: 07 Jul 2003, 12:26:54 »
Errr... "combat" is an event handler ?  :o

If so, I'm also highly interested.

Less off-topic : have you folks ever managed to get the "selectweapon" command to work ? Is there a trick ? This command just beats me... ???

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Checking which weapon is selected
« Reply #8 on: 09 Jul 2003, 04:46:59 »
Darn! So this can't be done! :( I was also wondering how to do this, but I guess its out of the question now. Oh well. Another, similar question I have is whether you can detect the current animation of the player (e.g. is he laying down, standing up with a rifle, standing up with a pistol, et. al). I doubt it is possible, but if it were, perhaps you could detect whether the player is standing in the regular, unarmed civillian pose, or whether he is in the soldier-with-a-rifle-pose...?

Igor:

I've gotten that command to work before. You just say something like:
bob selectweapon "rpglauncher"
It seems simple to me. What exactly are you having problems with?
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

PicVert

  • Guest
Re:Checking which weapon is selected
« Reply #9 on: 04 Aug 2003, 17:49:55 »
Thanks to post my question here :)  ;)

I found the solution is a simple line humm was not my line :P the solution was found by Rastavovitch from DKMM
the line is :

? _this select 1 != "Your_sticky" : exit

So thx @ all

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:Checking which weapon is selected
« Reply #10 on: 04 Aug 2003, 21:36:06 »
Sorry, but I don't understand what you are saying.

Could you maybe post some sort of example?
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!