Devil Dogs SF 13 Posted May 21, 2015 I don't know if it's possible, but is there any way to get BLUFOR and OPFOR to not fire upon the IND player if he has no weapon in his hands. So for example, I can walk past an enemy patrol if my weapon is in a pack, but when I take it out they will fire upon me? Another possibility, they will know the player once spotted with a weapon, so the player cannot just put the weapon away and disappear with no enemy on him. Share this post Link to post Share on other sites
ProfTournesol 956 Posted May 21, 2015 Something like : this setcaptive true in the init of the player. Then, a trigger that checks if the player has his primary weapon in hands, such as : currentWeapon player == primaryweapon player as condition and player setcaptive false in the on activation line Share this post Link to post Share on other sites
austin_medic 109 Posted May 22, 2015 my Combatant Detection script does the job, though it was written quite a while ago and I don't have time to retest it right now. Might not work. Share this post Link to post Share on other sites
Devil Dogs SF 13 Posted May 22, 2015 Thanks! I'll try both options recommended and let you know how it turns out! :) Share this post Link to post Share on other sites
R3vo 2652 Posted May 22, 2015 In addition to ProfTournesol's post I'd like to add the follwing: _primWeapon = primaryWeapon player; _seconWeapon = secondaryWeapon player; if (isNil _primWeapon && isNil _seconWeapon) then { player setCaptive true; }; //not tested currentWeapon player == primaryweapon player This would not take into account if the players uses a secondary weapon, does it? Share this post Link to post Share on other sites
ProfTournesol 956 Posted May 22, 2015 (edited) Yes, secondaryweapon is the launcher. Handgunweapon is, well, the handgun. Those should be checked too according to what the OP wants to do. Edited May 23, 2015 by ProfTournesol Share this post Link to post Share on other sites
rejenorst 18 Posted May 23, 2015 Also I think currentWeapon would return the string "" if the player isn't holding a weapon. Meaning you could do this: if (currentWeapon player != "") then { player setCaptive false; }; Share this post Link to post Share on other sites
ricoarma 5 Posted May 22, 2018 hey all, If I use this in a Trigger, how can i do that? Share this post Link to post Share on other sites
AZCoder 921 Posted May 23, 2018 Just take what rejenorst wrote. In the condition box: currentWeapon player != "" In the on activation box: player setCaptive false; But you will also want this to occur only when the enemy can see if your weapon is out. So maybe this in the condition box (not tested): (currentWeapon player != "") && ( { side _x == east && _x distance player < 100 } count allUnits > 0 ) or something similar. I actually do this stuff a lot, but I'm not in front of my scripts to see what I did exactly. First mission of Shadow Fall uses the hidden weapon technique extensively and had to account for a flashlight because it shows up as a weapon (but it's not really), feel free to download and depbo it, if you can decipher my scripts :D Share this post Link to post Share on other sites
ricoarma 5 Posted May 24, 2018 (edited) 20 hours ago, AZCoder said: Just take what rejenorst wrote. In the condition box: currentWeapon player != "" In the on activation box: player setCaptive false; But you will also want this to occur only when the enemy can see if your weapon is out. So maybe this in the condition box (not tested): (currentWeapon player != "") && ( { side _x == east && _x distance player < 100 } count allUnits > 0 ) or something similar. I actually do this stuff a lot, but I'm not in front of my scripts to see what I did exactly. First mission of Shadow Fall uses the hidden weapon technique extensively and had to account for a flashlight because it shows up as a weapon (but it's not really), feel free to download and depbo it, if you can decipher my scripts :D Thanks a lot. ok I try it, and back soon *********************************************************** OK, I tested with the trigger. it works. The problem is that when the weapon is in a backpack, or vest, it don't work at all. The AI detect automatically when player have a weapon :( Edited May 24, 2018 by ricoarma Share this post Link to post Share on other sites
mudnut 5 Posted May 24, 2018 (not tested) if(count(backpackItems select {_x isKindOf "Rifle"}) > 0) then { }; Share this post Link to post Share on other sites
gokitty1199 225 Posted May 24, 2018 just run this on the server, every 5 seconds if checks if the player has any weapons both primary/secondary, if the player does not have any weapons then it sets the players captive state to true, if he does have weapons it sets the players captive states to false _h = []spawn { while {true} do { { if ((primaryWeapon _x) == "" && (secondaryWeapon _x) == "") then { _x setCaptive true; } else { _x setCaptive false; }; } forEach allPlayers; sleep 5; }; }; 1 Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 7, 2020 This only seems to check for primary weapon not secondary, assuming your main gun is primary and pistol is secondary? If i bring out a pistol nothing happens, as soon as i bring out primary then yes, setcaptive false and i get shot... Any ideas on adapting this code to check for pistols as well? or any weapon.. Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 7, 2020 On 5/24/2018 at 11:42 PM, gokitty1199 said: just run this on the server, every 5 seconds if checks if the player has any weapons both primary/secondary, if the player does not have any weapons then it sets the players captive state to true, if he does have weapons it sets the players captive states to false _h = []spawn { while {true} do { { if ((primaryWeapon _x) == "" && (secondaryWeapon _x) == "") then { _x setCaptive true; } else { _x setCaptive false; }; } forEach allPlayers; sleep 5; }; }; Sorry i was referring to this one, so im assuming you put this in the player init? or in a description file in the mission folder? anyway, i put it in the players init and it works for the primary weapon but not for pistol, if you arm with a pistol only then setcaptive stays true.... ive looked at the code but cant quite figure out how to change it to setcaptive false if the secondary weapon is taken out but not the primary Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 7, 2020 44 minutes ago, chrisbaker1981 said: Sorry i was referring to this one, so im assuming you put this in the player init? or in a description file in the mission folder? anyway, i put it in the players init and it works for the primary weapon but not for pistol, if you arm with a pistol only then setcaptive stays true.... ive looked at the code but cant quite figure out how to change it to setcaptive false if the secondary weapon is taken out but not the primary Ok figured it out, change secondaryWeapon to handgunWeapon, now it works 🙂 Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 7, 2020 On 5/24/2018 at 11:42 PM, gokitty1199 said: just run this on the server, every 5 seconds if checks if the player has any weapons both primary/secondary, if the player does not have any weapons then it sets the players captive state to true, if he does have weapons it sets the players captive states to false _h = []spawn { while {true} do { { if ((primaryWeapon _x) == "" && (secondaryWeapon _x) == "") then { _x setCaptive true; } else { _x setCaptive false; }; } forEach allPlayers; sleep 5; }; }; Ah But heres a question, can you make it sleep different values for each check? For an example, I want the check for weapons armed to be much quicker than checking for no weapon. If you take your weapon out, ive set the sleep to less than a second so the enemy ai react quickly. But i dont want them to ignore you as soon as you put your weapon away, id like to adjust that sleep value to a few minutes. Lets say you shoot somone then put your weapon back, it would make sense for the enemies in the area to know about you and target you, but perhaps a little later ignore you again... Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 7, 2020 25 minutes ago, chrisbaker1981 said: Ah But heres a question, can you make it sleep different values for each check? For an example, I want the check for weapons armed to be much quicker than checking for no weapon. If you take your weapon out, ive set the sleep to less than a second so the enemy ai react quickly. But i dont want them to ignore you as soon as you put your weapon away, id like to adjust that sleep value to a few minutes. Lets say you shoot somone then put your weapon back, it would make sense for the enemies in the area to know about you and target you, but perhaps a little later ignore you again... I guess you would have to have 2 checks, one for is your weapon packed away, and a seperate one for is your weapon out.. Instead of one check for is your weapon away, if not then you a target.. Repeating that one check i cant split up the commands in seperate timers. Am i on the right track? The question now is, how to i script a seperate check for weapon out.? Share this post Link to post Share on other sites
pierremgi 4757 Posted September 8, 2020 0 = [] spawn { while {true} do { { if ((weapons _x + (magazines _x select {_x == "handGrenade" or _x == "miniGrenade"})) isEqualTo []) then { _x setCaptive true; } else { _x setCaptive false; }; } forEach allPlayers; sleep 2; }; }; 1 Share this post Link to post Share on other sites
chrisbaker1981 25 Posted September 8, 2020 1 hour ago, pierremgi said: 0 = [] spawn { while {true} do { { if ((weapons _x + (magazines _x select {_x == "handGrenade" or _x == "miniGrenade"})) isEqualTo []) then { _x setCaptive true; } else { _x setCaptive false; }; } forEach allPlayers; sleep 2; }; }; Thanks Pierremgi, that helps with taking grenades etc into acccount right? But my problem now is doing 2 checks, with seperate sleep times, 1 check must be for weapons in pack, then set captive true, and sleep 2 check must be for weapons out then set captive false, and a separate sleep for this check, If i can do that then i can set the enemies to react quickly to a player having a weapon on them, but take longer to check for weapons in back pack. This will allow me to make the enemies still shoot you when you put your weapon away for a while. SO if you shoot an enemy you cant just put your weapon away and expect to stroll through the enemy base without being shot at... 🙂 Share this post Link to post Share on other sites
Ellman 9 Posted June 29, 2023 3 years later and nobody said where to run the script.... Running it in the player/units init seems kinda dumb? 1 Share this post Link to post Share on other sites
Harzach 2512 Posted June 29, 2023 4 hours ago, Ellman said: nobody said where to run the script.... On 5/24/2018 at 5:42 PM, gokitty1199 said: just run this on the server e.g. initServer.sqf Share this post Link to post Share on other sites
_foley 192 Posted June 30, 2023 According to wiki setCaptive takes local argument so I would also replace _x setCaptive true; _x setCaptive false; with [_x, true] remoteExec ["setCaptive", _x]; [_x, false] remoteExec ["setCaptive", _x]; 2 Share this post Link to post Share on other sites
Harzach 2512 Posted June 30, 2023 8 hours ago, _foley said: According to wiki setCaptive takes local argument But wouldn't allPlayers be the same on every machine? I see some posts saying setCaptive can be unreliable based on certain factors, so your solution is most likely the right way to go, I'm just trying to understand the "why." Share this post Link to post Share on other sites
_foley 192 Posted June 30, 2023 1 hour ago, Harzach said: But wouldn't allPlayers be the same on every machine? I see some posts saying setCaptive can be unreliable based on certain factors, so your solution is most likely the right way to go, I'm just trying to understand the "why." I don't think it depends on whether allPlayers is the same on every machine. Local argument means that the argument needs to be local on the machine where the command is executed, otherwise the it won't work. Since player-controlled unit is local only on that player's machine, it needs to be executed there. 2 Share this post Link to post Share on other sites
Harzach 2512 Posted June 30, 2023 31 minutes ago, _foley said: I don't think it depends on whether allPlayers is the same on every machine. Local argument means that the argument needs to be local on the machine where the command is executed, otherwise the it won't work. Since player-controlled unit is local only on that player's machine, it needs to be executed there. OK. I was seeing it as the reference (_x) essentially being global. I just need to play around with this on dedi to unwrap it. Share this post Link to post Share on other sites