Announcement

Collapse
No announcement yet.

Custom Detected Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [GUIDE] Custom Detected Script

    Here is a custom script to determine if your players have been detected by enemy AI. In this case we are using Opfor units as the enemy and Blufor for the players.

    We start the script by having this in the initPlayerLocal.sqf:
    Code:
    [player] spawn TG_fnc_detected.sqf
    In the description.ext:
    Code:
    class Params
    {
        class EmtpyLine1
        {
            title = ":: Mission Settings ::";
            values[]={0,0};
            texts[]={ "",""};
            default = 0;
        };
    
        class EmtpyLine2
        {
            title = "...............................";
            values[]={0,0};
            texts[]={ "",""};
            default = 0;
        };
    
        class RadiusDetected
        {
            title = "Enemys Detection Radius for Players";
            values[] = {20,50,100,150,200,500,1000,1500,2000};
            texts[] = {"20 meters","50 meters","100 meters","150 meters","200 meters","500 meters","1000 meters","1500 meters","2000 meters"};
            default = 500;
        };
    
        class TimeToCallInContact
        {
            title = "Time enemies will take to call in when players are spotted.";
            values[] = {5,10,15,20,25,30};
            texts[] = {"5 seconds","10 seconds","15 seconds","20 seconds","25 seconds","30 seconds"};
            default = 20;
        };
    };
    
    //#include "CHVD\dialog.hpp"
    
    class cfgFunctions 
    {
        #include "functions\cfgfunctions.hpp"    
       // #include "CHVD\CfgFunctions.hpp"
    };
    We create a file in functions\cfgfunctions.hpp:
    Code:
    class TG
    {
        tag = "TG";    
        class client
        {
            file = "functions\client";        
            class detected {};
        };
    };
    Then finally the script file in functions\client\fn_detected.sqf:
    Code:
    _ourPlayer = _this select 0;
    _radiusPlayerDetected = ["RadiusDetected",100] call BIS_fnc_getParamValue;
    _detectedTimeLimit = ["TimeToCallInContact",20] call BIS_fnc_getParamValue;
    _run = true;
    _timePlayerDetected = 0;
    _playerDetected = false;
    _playerNotified = false;
    _listEntitiesNear = [];
    _listEnemiesNear = [];
    
    firedHandler = player addEventHandler ["Fired",{if (_this select 2 == "rhsusf_throw_grenade" || _this select 2 == "rhs_throw_grenade") then {[] spawn {sleep 10; "AN EXPLOSION HAS REVEALED OUR PRESENCE." remoteExec ["hint",0,false]; _run = false; stealthStatus = "detected"; publicVariable "stealthStatus";};};}];
    
    while {_run} do
    {
        if (alive player) then
        {
            _playerDetected = false;
            _listEntitiesNear = [];
            _listEnemiesNear = [];
            _listEntitiesNear = (getPos player) nearEntities _radiusPlayerDetected;
            {if (side _x == east && alive _x) then {_listEnemiesNear pushBack _x;};}forEach _listEntitiesNear;
            {if ((_x knowsAbout _ourPlayer) > 1.4 && !(_playerDetected)) then {_playerDetected = true;};}forEach _listEnemiesNear;
    
            if (_playerDetected && !(_playerNotified)) then
            {
                _timePlayerDetected = time;
                player groupChat "I think we may have been spotted.";
                _playerNotified = true;
            };
    
            if (_playerDetected && _playerNotified && (time >= _timePlayerDetected + _detectedTimeLimit)) then
            {
                _run = false;
                "YOUR TEAM HAS BEEN SPOTTED. PROCEED WITH HASTE." remoteExec ["hint",0,false];
                stealthStatus = "detected";
                publicVariable "stealthStatus";
            };
    
            if (!(_playerDetected) && _playerNotified) then
            {
                _playerNotified = false;
                _timePlayerDetected = 0;
            };
    
            if (vipStatus == "secured" || stealthStatus == "detected") then {_run = false;};
    
        };
        sleep 2;
    };
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member

    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN

  • #2
    Here is the video walk through of the script:

    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member

    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN

    Comment


    • #3
      Here is the mission on the Steam Workshop:
      http://steamcommunity.com/sharedfile...?id=1103478609
      |TG-189th| Unkl
      ArmA 3 Game Officer
      Dean of Tactical Gamer University
      189th Infantry Brigade Member

      SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN

      Comment

      Connect

      Collapse

      TeamSpeak 3 Server

      Collapse

      Advertisement

      Collapse

      Twitter Feed

      Collapse

      Working...
      X