Jump to content
VulturARG

Infiltration. Covert units questions [Solved]

Recommended Posts

Hi to all. I'm new in scripts programming and I have some doubts.
I'm working in a cooperative MP mission.
A unit is infiltrated behind enemy lines. They use enemy uniforms and weapons. This unit can't fire in enemy territory because they enemy discovery him, except if they use a suppressed pistol.

I used this code:

player addEventHandler ["FiredMan",{
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
	if (_weapon != "rhsusf_weap_glock17g4") then {
		hint "setCaptive false";

		// Only the player
		//player setCaptive false;

		// All unit are undercover
		{[_x,false] remoteExec ["setCaptive",_x]} forEach units group player;

	} else {
    hint "setCaptive true";
  };
 }];

This code works right, but any player with a suppressed pistol can kill all the enemy without any restriction

First question: Is possible restraint the distance to kill the enemy or that the player and the enemy are un the same room or the enemy died in certain time after the player fire or any realistic situation that you can think, to avoid that?

 

second question: I use a trigger with an area to discover my group if the enter in this area. This is not too real. If my group go into the area and kill the enemies one by one, and the enemies that behind the walls don't see or listen that, the group must remain uncovered. They must have a time before a guard can alert to others, and if the guard is killed before this, the unit is safe even though is inside the prohibit zone.

Can you imagine some code to do this?

 

Share this post


Link to post
Share on other sites

Thanks for your reply @pierremgi. I used your tip to made a search in google and I found a very interesting approach.


This work make me to change the original idea. I imagine my new algorithm in this way. After fired any weapon setcapture is false and it check after some time (random between 20 and 40 seconds) if the enemy knows about player. If not, setcapture change to true. A second idea is that firing a weapon and kill some player start a countdown trigger. This trigger simulate that the enemy killed fail to answer a radio check. I'll search the way to put the enemy in alert when this trigger is activated.


Do you know if the enemy detect if the player has the weapons down or in his back?

  • Like 1

Share this post


Link to post
Share on other sites

Yes, detection is for side, not for having weapons or not. There are also commands for that: hasWeapon, primaryWeapon...

You can play also with knowsAbout and reveal. Mind for all syntax! Good search.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks for your answer. I'll check that.

I tried to adapt my code and |TG189| Unkl code but I can't. I don't have enough knowledge for do that.

 

First, I tried this way:

_radiusPlayerDetected = ["RadiusDetected",100] call BIS_fnc_getParamValue;
_detectedTimeLimit = ["TimeToCallInContact",20] call BIS_fnc_getParamValue;
_run = false;
_timePlayerDetected = 0;
_tiempo = 0;
_playerDetected = false;
_playerNotified = false;
_listEntitiesNear = [];
_listEnemiesNear = [];

player addEventHandler ["FiredMan",{
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];

	systemChat "setCaptive false";
	// Quita el encubrimiento solamente al jugador que dispara
	player setCaptive false;

	////////////////////////////////////////////////////////////////////////////////

	_run = true;

	////////////////////////////////////////////////////////////////////////////////

}];

while {_run} do
{
systemChat "_run";
	if (alive player) then
	{
systemChat "alive player";
		_playerDetected = false;
		_listEntitiesNear = [];
		_listEnemiesNear = [];
		_listEntitiesNear = (getPos player) nearEntities _radiusPlayerDetected;

		{
			if (side _x == east && alive _x) then
			{
				_listEnemiesNear pushBack _x;
			};
		}forEach _listEntitiesNear;

		{
			if ((_x knowsAbout player) > 1.4 && !(_playerDetected) /*&& !(captive player)*/) then
			{
				_playerDetected = true;
				systemChat "_playerDetected";
			};
		}forEach _listEnemiesNear;

		if (_playerDetected && !(_playerNotified)) then
		{
			_timePlayerDetected = time;
			systemChat "Los enemigos saben de nosotros (>1.4)";
			_playerNotified = true;
		};

		_tiempo = time;
		if (_playerDetected && _playerNotified && (_tiempo >= _timePlayerDetected + _detectedTimeLimit)) then
		{
			_run = false;
			systemChat "Hemos sido descubiertos";
			player setCaptive false;
			systemChat "setCaptive false";
		};
/*
		if (!(_playerDetected) && (_tiempo < _timePlayerDetected + _detectedTimeLimit)) then
		{
			systemChat "No detectado en menos del tiempo limite";
			// Regresa el estado de encubierto
			player setCaptive true;
			_run = false;
		};
*/
		if (!(_playerDetected) && _playerNotified) then
		{
			_playerNotified = false;
			_timePlayerDetected = 0;
		};
	};
	sleep 2;
};

I couldn’t make work that. If I use the code without addEventHandler, it do the work but the player never go to setCaptive false status. I need a way that the setCapture status go to false after the player fire his weapon

 

My next attempt was:

player addEventHandler ["FiredMan",{
	params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];

	systemChat "setCaptive false";
	// Quita el encubrimiento solamente al jugador que dispara
	player setCaptive false;

	////////////////////////////////////////////////////////////////////////////////
	_radiusPlayerDetected = ["RadiusDetected",100] call BIS_fnc_getParamValue;
	_detectedTimeLimit = ["TimeToCallInContact",20] call BIS_fnc_getParamValue;
	_run = true;
	_timePlayerDetected = 0;
	_tiempo = 0;
	_playerDetected = false;
	_playerNotified = false;
	_listEntitiesNear = [];
	_listEnemiesNear = [];

	while {_run} do
	{
	systemChat "_run";
		if (alive player) then
		{
	systemChat "alive player";
			_playerDetected = false;
			_listEntitiesNear = [];
			_listEnemiesNear = [];
			_listEntitiesNear = (getPos player) nearEntities _radiusPlayerDetected;

			{
				if (side _x == east && alive _x) then
				{
					_listEnemiesNear pushBack _x;
				};
			}forEach _listEntitiesNear;

			{
				if ((_x knowsAbout player) > 1.4 && !(_playerDetected) /*&& !(captive player)*/) then
				{
					_playerDetected = true;
					systemChat "_playerDetected";
				};
			}forEach _listEnemiesNear;

			if (_playerDetected && !(_playerNotified)) then
			{
				_timePlayerDetected = time;
				systemChat "Los enemigos saben de nosotros (>1.4)";
				_playerNotified = true;
			};

			_tiempo = time;
			if (_playerDetected && _playerNotified && (_tiempo >= _timePlayerDetected + _detectedTimeLimit)) then
			{
				_run = false;
				systemChat "Hemos sido descubiertos";
				player setCaptive false;
				systemChat "setCaptive false";
			};

			if (!(_playerDetected) && (_tiempo < _timePlayerDetected + _detectedTimeLimit)) then
			{
				systemChat "No detectado en menos del tiempo limite";
				// Regresa el estado de encubierto
				player setCaptive true;
				_run = false;
			};

			if (!(_playerDetected) && _playerNotified) then
			{
				_playerNotified = false;
				_timePlayerDetected = 0;
			};
		};
		//sleep 2;
	};

	////////////////////////////////////////////////////////////////////////////////

}];

This seem work (I’m not sure) but I have a lot (really lot) of lag when I fired.

 

Can you tell me some tip with this code?

Share this post


Link to post
Share on other sites

Not tested:
 

Spoiler



player addEventHandler ["FiredMan",{
  params ["_unit"];
  player setCaptive false;
  systemChat "setCaptive false";


  [] spawn {
  _radiusPlayerDetected = ["RadiusDetected",100] call BIS_fnc_getParamValue;
  _detectedTimeLimit = ["TimeToCallInContact",20] call BIS_fnc_getParamValue;
 
  _run = true;
  _timePlayerDetected = 0;
  _tiempo = 0;
  _playerDetected = false;
  _playerNotified = false;


  while {_run} do {
  systemChat "_run";
    if (alive player) then {
 
      _playerDetected = false;
      _listEntitiesNear = (getPos player) nearEntities _radiusPlayerDetected;
      _listEnemiesNear = _listEntitiesNear select {side _x == east};

      {
        if ((_x knowsAbout player) > 1.4 && !(_playerDetected)) exitWith
        {
          _playerDetected = true;
          systemChat "_playerDetected";
        };
      } forEach _listEnemiesNear;
      _tiempo = diag_tickTime;
      call {
        if (_playerDetected && !(_playerNotified)) exitWith {
          _timePlayerDetected = diag_tickTime;
          systemChat "Los enemigos saben de nosotros (>1.4)";
          _playerNotified = true;
        };
        if (_playerDetected && _playerNotified && (_tiempo >= _timePlayerDetected + _detectedTimeLimit)) exitWith {
          _run = false;
          systemChat "Hemos sido descubiertos";
          player setCaptive false;
          systemChat "setCaptive false";
        };
        if (!(_playerDetected) && (_tiempo < _timePlayerDetected + _detectedTimeLimit)) exitWith {
          systemChat "No detectado en menos del tiempo limite";
          player setCaptive true;
          _run = false;
        };
        if (!(_playerDetected) && _playerNotified) exitWith {
          _playerNotified = false;
          _timePlayerDetected = 0;
        };
      };
    } else {
      _run = false
    };
    uiSleep 2;
  };
};
}];


 

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Many many many thanks.

 

Your code work fine.

 

Spawn {} in an instruction that I do not finish to understand. I read the Bohemia wiki. I can't found cristal examples or I couldn't understand it 😌
I didn't know about uiSleep. There are some many commands 😉


Thanks again.

Share this post


Link to post
Share on other sites

Here is my final code (for now)

 

The logic is:

  1. Player is covered (setCaptive true)
  2. If player fire inside trigger area go to uncovered (setCaptive false)
  3. If not enemy close or player(s) kill enemies near him in a certain time, go to covered status again.
  4. (in the future) If player kill someone, is activated a radio check timer trigger, that do something

 

Setup

  • Made a group (or more) of infiltrate players. In the init of the group put this sentence: {_x setCaptive true;} forEach units this; (image)
  • Make a trigger to cover the enemy area. Activate by player and you can use presense or detected by in activation type. In activation put this code nul = [] execVM "scripts\detectado.sqf"; Use your name and path. (image)
  • Add this to initServer.sqf
//initServer.sqf
stealthStatus = "undetected";
publicVariable "stealthStatus";
  • Finally put this routine:
//scripts\detectado.sqf

player addEventHandler ["FiredMan",{
  params ["_unit"];

  player setCaptive false;
  //systemChat "Si escucharon ese disparo perdimos la cobertura";

  [] spawn {
    _radiusPlayerDetected = ["RadiusDetected",100] call BIS_fnc_getParamValue; //Radio de detección
    _detectedTimeLimit = ["TimeToCallInContact",20] call BIS_fnc_getParamValue;//Tiempo de reacción

    _run = true;
    _timePlayerDetected = 0;
    _tiempo = 0;
    _playerDetected = false;
    _playerNotified = false;

    while {_run && (stealthStatus == "undetected")} do {
      //systemChat "_run";
      if (alive player) then {

        _playerDetected = false;
        _listEntitiesNear = (getPos player) nearEntities _radiusPlayerDetected;
        _listEnemiesNear = _listEntitiesNear select {side _x == east};

        {
          if ((_x knowsAbout player) > 1.4 && !(_playerDetected)) exitWith
          {
            _playerDetected = true;
            //systemChat "Algo sabe el enemigo";
          };
        } forEach _listEnemiesNear;
        _tiempo = diag_tickTime;
        call {
          if (_playerDetected && !(_playerNotified)) exitWith {
            _timePlayerDetected = diag_tickTime;
            //systemChat "Los enemigos sospechan que estamos cerca (>1.4)";
            _playerNotified = true;
          };
          if (_playerDetected && _playerNotified && (_tiempo >= _timePlayerDetected + _detectedTimeLimit)) exitWith {
            _run = false;
            //systemChat "Hemos sido descubiertos. Ya no estamos encubiertos";
            player setCaptive false;
            stealthStatus = "detected";
        		publicVariable "stealthStatus";
          };
          if (!(_playerDetected) && _playerNotified) exitWith {
            _playerNotified = false;
            _timePlayerDetected = 0;
            //systemChat "Estamos seguros. No hay ningun enemigo cerca que sepa de nosotros";
            player setCaptive true;
          };
        };
      } else {
        _run = false
      };
      uiSleep 2;
    };
  };
}];

You need to play with RadiusDetected and detectedTimeLimit values to adjust to requirements.  Maybe 50 m and 30 sec. will be good for closed spaces.

 

To adjust this parameter in game put this to description.ext

//description.ext
class Params
{
    class EmtpyLine1
    {
        title = ":: Parametros de Misión ::";
        values[]={0,0};
        texts[]={ "",""};
        default = 0;
    };

    class EmtpyLine2
    {
        title = "...............................";
        values[]={0,0};
        texts[]={ "",""};
        default = 0;
    };

    class RadiusDetected
    {
        title = "Radio de detección de los enemigos";
        values[] = {3,5,10,15,20,50,100,150,200,500,1000,1500,2000};
        texts[] = {"3 metros","5 metros","10 metros","15 metros","20 metros","50 metros","100 metros","150 metros","200 metros","500 metros","1000 metros","1500 metros","2000 metros"};
        default = 100;
    };

    class TimeToCallInContact
    {
        title = "Tiempo que se tiene para recuperar la cobertura una vez detectados";
        values[] = {5,10,15,20,25,30,45,60};
        texts[] = {"5 segundos","10 segundos","15 segundos","20 segundos","25 segundos","30 segundos","45 segundos","60 segundos"};
        default = 45;
    };
};

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×