Jump to content
graemeshute

Getting a rifle squad to sit down and get up when triggered.

Recommended Posts

Hi there

 

I need help setting this up. I have looked online but cant find a working solution.

 

I want a basic CSAT Rifle squad to sit on the ground as if they are off duty. Fully kitted out. Just relaxed shooting the breeze. But on trigger-(They-A quick reaction force). They get up in a aware combat state and mount a vehicle to ride off. They will drive the truck themselves. The player gets penalized if they get detected too early with the QRF coming to the area to "Seek and Destroy".

 

I did manage to get one unit to sit and get up on trigger using unit1 setBehaviour "SAFE"; unit1 action ["sitDown", unit1]; BUT! if I place in every units initialization and changing unit 1 for each new unit. All AI units start off sitting but a second later they all stand up except for the Squad leader waiting for the Hold waypoint to switch to move. Would I need to use individual ungrouped units coupled to a join way point with finally a get in waypoint?

 

I also want to try avoiding disabling their self preservation mechanics by disabling Auto combat mode because the player may want to shoot at them and I don't want sitting ducks. I don't mind them not moving ie running off but I also don't want one to be shot and they still sit there relaxed...IE Careless. Is there a trade off?

Share this post


Link to post
Share on other sites

This starts with the group inside the vehicle (easiest way to assign vehicle roles),

once they get out they stroll around, sit and do idle animations.

Once they detect enemies or a variable named GOM_fnc_boardvehicle returns true they'll hop in and move to the position specified at the end of the script, in my example it's the players position.

To trigger the group boarding the vehicle simply set GOM_fnc_boardvehicle to true.

Paste this into the init field of one unit from the group.

{
    _x moveInAny YOURTRUCKNAME;//change the name to your vehicle of choice
    [_x] allowGetIn false;
    [_x] orderGetIn false;
    dostop _x;
    group _x setbehaviour "SAFE";
    group _x setspeedmode "LIMITED";

    _stop = _x spawn {
        _centerPos = getPosATL leader group _this;
        waituntil {_this isEqualTo vehicle _this};
        _this domove ([_centerPos, random [5,20,45], random 360] call BIS_fnc_relPos);
        waituntil {unitready _this};
        dostop _this;

        while {behaviour _this isEqualTo "SAFE" AND !GOM_fnc_boardvehicle} do {

            _sitting = _this getvariable ["GOM_fnc_sitting",false];
            _unitsSitting = {_x getvariable ["GOM_fnc_sitting",false]} count units group _this;
            _unitsIdleAnim = {_x getvariable ["GOM_fnc_idleAnim",false]} count units group _this;
            if (random 100 < 30 AND !_sitting AND _unitsSitting < count units group _this * 0.3) then {

                _this setvariable ["GOM_fnc_sitting",true];
                sleep random [5,10,15];
                _this action ["Sitdown",_this];
                _sitting = true;
            };

            if (_sitting) then {

                sleep random [60,90,120];
                _sitting = false;
                _this setvariable ["GOM_fnc_sitting",false];

            };

            if !(_sitting) then {

                _this domove ([_centerPos, random [5,20,45], random 360] call BIS_fnc_relPos);
                waituntil {unitready _this};
                _watchDir = [_centerPos,_this] call BIS_fnc_dirTo;
                _watchPos = [_centerPos,250,_watchDir] call BIS_fnc_relPos;
                _this lookat _watchPos;
                _this doWatch _watchPos;
                sleep random [5,10,15];

                if (random 100 < 30 AND _unitsIdleAnim < count units group _this * 0.3) then {

                    _this setvariable ["GOM_fnc_cancelAnim",false];
                    _this setvariable ["GOM_fnc_idleAnim",true];
                    _anim = selectRandom ["STAND","STAND_IA","WATCH","WATCH1","WATCH2"];
                    [_this,_anim,"ASIS",{_this getvariable ["GOM_fnc_cancelAnim",false]},"SAFE"] call BIS_fnc_ambientAnimCombat;
                    sleep random [30,60,90];
                    _this setvariable ["GOM_fnc_idleAnim",false];
                    _this setvariable ["GOM_fnc_cancelAnim",true];

                };



            };
        };

        _this setSpeedMode "NORMAL";

        if (_this isEqualTo leader group _this) then {
            
            {

                _x dofollow _this;
                _x disableAI "AUTOCOMBAT";
                _x setvariable ["GOM_fnc_cancelAnim",true];

            } foreach units group _this;

            group _this setbehaviour "AWARE";
            (units (group _this)) allowGetIn true;
            (units (group _this)) orderGetIn true;
            group _this move getposatl player;//your target position here

        };

    }

} foreach units group this;

Cheers

Share this post


Link to post
Share on other sites

Grumpy Old Man I dont think I was clear-sincere apologies. The Player is meant to sabotage the QRF's transport as a secondary objective once the main objectives are done by said Special Forces player. (A bonus would be killing off the QRF at distance with long range sniper rifles). Hence I did not want them to be careless but also not in the vehicles as they relaxed sitting around with no idea a NATO invasion will happen in the morning. You scout around there by them later and I did not want units standing up at night doing "nothing". They needed to look relaxed sitting around a camp fire.

 

A 4 man Special forces team is sent in at 3:30 AM to smooth the way for said NATO invasion at dawn. You play this role with a Switch player roll later controlling the main NATO "invasion" force later.

 

The Spec ops kills off all AA crew members outside their vehicles. And puts Demo charges at their vehicles. These are in a Town. The QRF is a distance away at a little Base.

 

I just wanted that the quick reaction force to only come into play if the player messes up eliminating the 3 AA units by being seen. Then the trigger of detected gets fired with the QRF driving to the area dismounting and running around "looking for the player". Its a night stealth mission. With more pressure on say NAVY SEALS to make sure the invasion happens.

 

The QRF are a distance away and its a bit of a realism breaker to have two Rifles squads close by or for them to run from their "camp" to where the AA units are deployed.

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

×