Announcement

Collapse
No announcement yet.

TG Function: AI Prone Manager - Stop AI from Shooting Thru Floors While Prone

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

  • [GUIDE] TG Function: AI Prone Manager - Stop AI from Shooting Thru Floors While Prone

    So in ArmA the AI on a second floor will go prone and then bend at the waist to shoot into the floor below while glitching through the floor. This script doesn't eliminate this from happening but does stop it once it begins.

    Disclaimer: !!!! This is not recommended for missions with a LOT of AI! It is running this script on every single unit. It is finding the nearest enemy using the scripting command findNearestEnemy which is going to take up processing time for your server! If you have a lot of AI it is highly recommended that you create an array of all none first floor/ground level units and only run the script on them! For example:

    initServer.sqf
    Code:
    _unitsToPreventProne = [secondFloorGuy1,secondFloorGuy2,thirdFloorGuy1,roofGuy1,roofGuy2];
    {[_x] spawn TG_fnc_aiProneManager;}forEach _unitsToPreventProne;
    functions\cfgfunctions.hpp ---- this is an example from my mission Just Deserts which I made this script for (thanks CaptainShawn for the bug report!)
    Code:
    class TG
    {
        tag = "TG";
        class server
        {
            file = "functions\server";
            class aiProneManager {};
        };
    };
    functions\server\fn_aiProneManager.sqf
    Code:
    _thisAI = _this select 0;
    _upPositions = ["UP","MIDDLE"];
    _newUpPosition = "";
    _newUpPositionIndex = 0;
    _run = true;
    
    while {_run} do
    {
        if (stance _thisAI == "PRONE") then
        {
            //if enemies are near do not go prone, if they are not then select best stance as per normal
            if ((_thisAI findNearestEnemy _thisAI) distance _thisAI <= 15) then
            {
                _newUpPositionIndex = floor random 2;
                _newUpPosition = _upPositions select _newUpPositionIndex;
                //systemChat format ["%1 to go to stance %2",_thisAI,_newUpPosition]; //for debuging while testing local
                _thisAI setUnitPos _newUpPosition;
                //sleep a random time so not all ai are getting up or down at same time
                sleep ((random 5) + 10);
            };
        } else {_thisAI setUnitPos "AUTO";};
    
        sleep (random 2) + 1;
        if (!alive _thisAI) exitWith {_run = false;};
    };
    |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
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

Connect

Collapse

TeamSpeak 3 Server

Collapse

Advertisement

Collapse

Twitter Feed

Collapse

Working...
X