No announcement yet.

Stealth Mission - Players Detected while in disquise

  • Filter
  • Time
  • Show
Clear All
new posts

  • Stealth Mission - Players Detected while in disquise

    Wanted to share this script even though it is not directly applicable to widespread use. It's for DMZ Scout's upcoming mission where our small unit of blufor goes undercover to recon a town. They are set as "captive" so that the enemy won't fire upon them unless they are detected. I added this to the mission in case a player in disguise gets too close to the HVT and is identified as Blufor. It will set all units in that undercover group to "setCaptive false". Scout already has the variable undercover = "true" as a public variable to track when these players get spotted.

    The new thing for me is using remoteExec to run the setCaptive command on the client machine for each player in the incognito group. This had to be done in such a way that jips could join the group and the script would adapt to different players at different times. Each player in the group has this in their init:
    trojan = group this;
    We can reference the entire group by using the name: trojan

    We can pull a list of all players in that group at any time in the future by doing this:
    allPlayersInTrojan = units trojan;

    unitName setCaptive true - this must be run on the client that the player is local to in order for it to be effective. In this case running the following on the server would not do what we want:
    if (isServer) then {trojanPlayer1 setCaptive true; trojanPlayer2 setCaptive true;};
    We could make each client try to set this for each player in the trojan group but that is kinda clunky. Like if we use our array of allPlayersInTrojan to cycle through all the players that are currently in that group and execute that line on every client:
    {_x setCaptive true;}forEach allPlayersInTrojan;

    remoteExec works by executing the command on the server and telling it which client you want to run the command on.

    //param1 scriptCommand param2
    [param1, param2] remoteExec ["scriptCommand", targetID of client, public]

    So for our usage:
    [currentTrojanMember, true] remoteExec ["setCaptive", owner currentTrojanMember, false];
    Now just put that line above into the forEach block as before the hard line above...and you see the actual script below:

    //if this is not the server then quit this script
    if !(isServer) exitWith {};
    //player sidechat "tooCloseToHVT.sqf is running...";
    //wait 30 seconds to start - gives all beginning triggers and values time to be set such as "undercover == "true"
    sleep 30;
    [] spawn {
    	//define variables and set their defaults
    	private ["_trojanGroup","_spotted","_distanceToBeIdentified"];
    	_trojanGroup = [];
    	_spotted = false;
    	_distanceToBeIdentified = 12; //set to 12 meters
    	//start a loop for as long as trojan is undercover to see if they are identified as enemy
    	while {undercover == "true"} do
    		//get the name of each unit alive in the group "trojan" - do it this way so you are adjusting to jips each time through this loop
    		_trojanGroup = units trojan;
    		//this block will check if any in trojan are too close to hvt and set _spotted accordingly
    			if (_x distance hvt <= _distanceToBeIdentified) then
    				_spotted = true;
    		}forEach _trojanGroup;
    		//if they are spotted then setCaptive and broadcast as such to all clients
    		if (_spotted) then
    				[_x,false] remoteExec ["setCaptive",(owner _x),false];
    			}forEach _trojanGroup;
    			undercover = "false";
    			publicVariable "undercover";
    		_trojanGroup = []; //reset the units in trojan in case of jip players
    		sleep .2; //a delay so the loop doesn't run every cpu cycle and take up needless resources		
    		//player sideChat format ["_spotted = %1     --   undercover = %2", _spotted, undercover]; 
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache



TeamSpeak 3 Server


Twitter Feed