OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Nobby on 09 Jul 2003, 01:38:23
-
What is the syntax for detecting whether or not a unit is carrying a gun?
e.g:
? player has "M21"
police dofire player
OR...
? player has "Glock" and player behaviour "safe"
metal detectors doGo bezerk.
What are the correct syntax's for these?
Cheers
-
You are looking for the "hasweapon" command. It returns a boolean. For example:
?bob hasweapon "m21" : bob fire bill
Simple enough, right? :P
-
cheers mate, works a treat.
Now what I was wondering was if there was a universal code for a primary weapon? So that if the player is seen with any primary weapon then the above syntax's apply.
Also, how do you determine the behaviour of a character?
This is what I'm trying to do:
? player hasweapon "Glock" and Player behaviour = "AWARE" or "COMBAT": police fire player
But this don't work.
-
You're trying to do what i am. having a guy walk up to a group of enemies as a captive. normal guy. nothings wrong. then boom he pulls out a gun. the enemy pulls out thier guns because he's pulled out his now. then you have a gunfight. I want to recreate that myself. now i think you can use the code addeventhandler. you can say player addeventhandler ("M16 in hand", exec "scriptname.sqs") and then in the script you put: player setcaptive false. Now this guy who has the gun walks up to the enemy as just a guy going about his business. now he pulls out the gun and they're all "oh crap he's going to kill us pull your guns out" and you waste them all before they get a shot off. you walk off a legend. i think that might do it.
-
It looks like we are all trying to do the same thing :P. I'm trying to make a mission where guns are illegal in town, and the police will fire at you if you have one out.
Nobby: Unfortunately, there is no way for the player to change his "behaviour". It will always by default be "aware", no matter what the player is doing. It will only change if the player's AI leader says something ("at ease"), or if the mission designer types something like: player setbehaviour "safe". But if you want to see for yourself, the command you need is:
behaviour unit
This returns a string, such as "AWARE","SAFE","COMBAT", etc.
BronzeEagle: I'm sorry, but there is not "M16 in hand" eventhandler, so you can't do that. The closest thing to that is "fired", which detects when a unit has fired a weapon (but I know that's not what we want).
A sort of 'workaround' for this problem could be to have the player be unarmed, and give him an action that says "pull gun", or sumthin like that. Using the action would add a weapon to the player's inventory, and also make him no longer a captive. Of course, there are problems with this way (the player can't use whatever gun he wants; the gun would start with an empty clip; etc), but until something better is devised, it might be the only way to do it.
I'll let you know if I find a better way around this problem.
-
How about the universal code for a primary weapon?
-
you'd need a list of condition and detecting scripts to properly know what you can use to trigger things.
-
How about the universal code for a primary weapon?
Try this:
primaryWeapon vehicle
Operand types:
vehicle: Object
Compatibility:
Version 1.75 required.
Type of returned value:
String
Description:
Returns name of vehicle's primary weapon (empty string if none).
Example:
primaryWeapon player
-
Wow, didn't even know that command existed. I guess I should check my reference a little closer. That makes things easier :)
-
Wow, didn't even know that command existed. I guess I should check my reference a little closer.
I've learned more by reading other peoples questions (and answers) than any other way. :) That, and hours of staring at the screen in total frustration. :P
-
_unit = _this select 0
?(count (weapons _unit) < 1): goto "noarms"
; // primary weapon
_weapon = (weapons _unit) select 0
; // last weapon
; // _weapon = (weapons _unit) select (count (weapons _unit) - 1)
_unit selectWeapon _weapon
_unit dowatch _unit
~1
_unit fire _weapon
#noarms
exit
you have to check the weapons anyway.
fire "Binocular", or fire "NVGoggles" is not very effective ;)