Deadfast 43 Posted July 2, 2008 Hi all. Here I come again with another question. I need to have a condition on whether a unit is armed or not (number or weapons, weapon type or anything else is not important). The problem is, that I don't know what weapon it will have at the time of script's activation and the number of possibilities is just too large to specify them all in hasWeapon. Any ideas? Thanks in advance, Deadfast Share this post Link to post Share on other sites
Specter 0 Posted July 2, 2008 this is a wild guess, you'll have to test it yourself: use "weapons" to create an array of the weapons the unit has and then check if it's empty. in case you count handgreandes as weapons too (arma doesnt) you have to check that with the "magazines"-array Share this post Link to post Share on other sites
Deadfast 43 Posted July 2, 2008 That was my idea as well, but how would you ask if an array is empty (beginner's question, sorry)? Share this post Link to post Share on other sites
raedor 8 Posted July 2, 2008 (edited) count (weapons _unit) == 0 But this counts weapons like "throw" as well. You could work around this with something like that: {_x != "Throw"} count (weapons _unit) == 0 Or, if you want to have more exceptions: {!(_x in ["Throw", ...])} count (weapons _unit) == 0 Be careful, the last suggestion is case sensitive! Edited August 13, 2009 by W0lle Share this post Link to post Share on other sites
Jedo 10 Posted August 12, 2009 (edited) Have an issue here. I need for my guy to "player setcaptive false" once he picks up a weapon. So I created the player with initialization "removeallweapons this". Then I got a trigger with the condition as discribed in this thread and then created the activation and deactivation with "player setCaptive true" and false. The enemy still fires at me from the start. What the hell? By the way, if this has something to do with me still having the binoculars and other gear (which falls under weapons but doesn't get removed) is there away to keep the gear but still check whether I have any firearms on me, kind of like the above "throw" code? Edited August 12, 2009 by Jedo Share this post Link to post Share on other sites
W0lle 1052 Posted August 13, 2009 (edited) Have an issue here. I need for my guy to "player setcaptive false" once he picks up a weapon. So I created the player with initialization "removeallweapons this". Then I got a trigger with the condition as discribed in this thread and then created the activation and deactivation with "player setCaptive true" and false. The enemy still fires at me from the start. What the hell? AFAIK the "Throw" weapon cannot be removed, so your player has always a weapon (Throw and Put). In your players initialization line type: removeAllWeapons this; this setCaptive true Now in a trigger you set this: Condition: count magazines player > 0 OnActivation: player setCaptive false In this case player can have a Binocular (weapon), he can also have a rifle but as soon as he has some magazine (this includes handgrenades, smokeshells etc), his captive status is set to false. If you want to set his captive status to false also when he has a rifle then the only way is to specify all possible types of weapons he could pick up: Condition: (player hasWeapon "AK74") OR (player hasWeapon "AK74GL") etc. OnActivation: player setCaptive false Edited August 13, 2009 by W0lle Share this post Link to post Share on other sites
Jedo 10 Posted August 13, 2009 (edited) AFAIK the "Throw" weapon cannot be removed, so your player has always a weapon (Throw and Put).In your players initialization line type: removeAllWeapons this; this setCaptive true Now in a trigger you set this: Condition: count magazines player > 0 OnActivation: player setCaptive false In this case player can have a Binocular (weapon), he can also have a rifle but as soon as he has some magazine (this includes handgrenades, smokeshells etc), his captive status is set to false. If you want to set his captive status to false also when he has a rifle then the only way is to specify all possible types of weapons he could pick up: Condition: (player hasWeapon "AK74") OR (player hasWeapon "AK74GL") etc. OnActivation: player setCaptive false OK that's pretty much what I thought, thanks. The very specific hasWeapon is not really an option in my case (a bit limiting). Shame there is no way to check for firearms only. Because now, what this means, is that the enemy sees a civ approach him with a gun but doesn't act until there's a clip in the gun - a bit contrary to the US Special Forces ROE of "if it's in radius of your rifle and has a weapon, kill it, no matter what age or sex it is" :p edit: Any idea why on deactivation doesn't work? I'm testing the above and once I acquire the weapon and its magazines my setcaptive turns false, but once I walk behind the wall and drop all magazines and come out again, the On Deactivation part (the setcaptive true part) doesn't work - I still get shot even though I'm "disarmed". I even tried creating a second trigger. edit2: ok I think it does work. Aparently, the AI needs some time to adjust. I thought those triggers were being checked ever 0.1 of a second. I had to wait at least 30 seconds behind the wall before I could come out again. The same goes for if I pick the weapon up again. The AI just stands there for 30 seconds before firing at me. Edited August 13, 2009 by Jedo Share this post Link to post Share on other sites