Jump to content
scottb613

Riddle Me This - AI Group Spans Two Vehicles - Formation Keeping?

Recommended Posts

Hi Folks,

 

The overall goal is to have some control over a pair of AI APC's - for better combat performance - while I am riding as a passenger in the lead.

 

I have an AI Squad that spans the crew of two AI controlled vehicles [APC] - without player crew - - - I want these vehicles to keep proper formation - which I may change on occasion change via script [column, line, flank left, flank right]. Now - just getting one to follow the other [column] in reliable consistent fashion proves difficult.

 

Is there some way to do it? I've tried all the usual suspects I can think of.

 

Sometimes it seems to work - others - the vehicle does not follow - one time - it turned around and departed. I am assuming - I can control - "autocombat" for the drivers - by disabling AI as I do for helicopters but I'm not even there yet. 

 

While these two vehicles are AI commanded - I would like them to behave as they would if the player was the leader.

 

Any help appreciated.

 

Regards,
Scott

Share this post


Link to post
Share on other sites
On 8/23/2024 at 12:15 PM, scottb613 said:

While these two vehicles are AI commanded - I would like them to behave as they would if the player was the leader. 

 

Scott, don't know if you've found anything yet, but check out @Ibragim A's Platoon Commander 2

This may offer what you're looking for.  I was thinking of giving it a try myself.

Of course, you could do your own script and have the AI join your squad while you want to control them and release when done.

  • Like 1

Share this post


Link to post
Share on other sites
12 hours ago, panther42 said:

Scott, don't know if you've found anything yet, but check out @Ibragim A's Platoon Commander 2

This may offer what you're looking for.  I was thinking of giving it a try myself.

Of course, you could do your own script and have the AI join your squad while you want to control them and release when done.

 

Hi...

 

Thanks again for the response. I haven't seen or tried that mod yet - I'll gladly take a gander.

 

Yeah - I'm not a real programmer - just a hack that keeps beating a dead horse until it starts doing what I want - LOL.

 

What I am using now to control my squad is @johnnyboy - SOG AI. That combined with Voice Attack - has actually made running a squad feel immersive - and the squad actually contributes to the mission. It's - hands down - the best experience I've ever had in ArmA. Previously - AI squads seemed pretty useless and were just cannon fodder. I can't seem to run ArmA without SOG AI - now.

 

As far as this post - I was trying to gain a little better control of AI Drivers with more than one unit. Just some basics - for the second unit to station keep and accept formation change orders - without ignoring or fleeing. I'm not looking for brilliant AI drivers that understand combined arms operations - just go from a column to a line when faced with a threat - to allow the weapons to be more effective. I can manage the lead vehicle just fine with scripts (as a passenger) - it's the following vehicle that seems unreliable.

 

Hmm - I may try that join/release routine... 

 

I'm currently using some addAction menus in the lead vehicle - along with the Simplex Transport Module. The two play nicely together and it seems to work pretty well - if I could get #2 to stick with me.

 

SPEED.jpg

 

 

 

I tried messing with the "Better Convoy" mod - but - it's not intended for what I want - I think it was intended for fully autonomous operation.  I want to control the speed of the lead vehicle - to whatever conditions dictate - but the mod just overrides my issued commands. I can successfully order stop/go commands to the convoy - and issue WP changes. I can't change the formation - and the speed control seems pretty rough (jerky) on cars when you are using one for a taxi - does a little better with heavier APC's.

 

Appreciate the interest.

 

Regards,
Scott

  • Like 1

Share this post


Link to post
Share on other sites

Hi Folks,

 

Well - I figured out my main issue - never test scripts on mods while developing. It seems the CUP Humvee's are bugged and won't follow a formation - swapped to RHS and it worked MUCH better with station keeping.

 

That said - I kind of have the basic station keeping and speed control working - same group crews both vehicles - Group Leader in V1. Sometimes V2 just stops - have no idea why - sometimes it seems to abandon the WP and goes off with a mind of its own - sometimes towards combat - sometimes away (a group can only be heading to a single WP - right?). I seem to be able to wrangle #2 back to formation - but - it's not always reliable and not always fast - - - using doFollow. I've tried to insure all the autocombat routines are disabled (part of the "Regroup" case 5).

 

Any thoughts?

 

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

// FILE NAME: SCOsetSpeed.sqf
// AUTHOR: scottb613


// REQUIRES: Simplex Support Modules addon.
// REQUIRES: "initTransport.sqf" in root of mission folder.
// REQUIRES: "Scripts\SCOsetSpeed.sqf" in root of mission folder.
// REQUIRES: Simplex Transport Module - Custom Init Code entry ===>>> [_this] execVM "initTransport.sqf";

// NOTE: Only tested in single player.

// GIVEN: For use with the Transport Module of Simplex Support Services.
// GIVEN: Provides speed control and the ability to stop on demand.
// GIVEN: Creates AddAction menu items to control speed of respective vehicle.
// GIVEN: After a "ts---Stop" - when player leaves _vehicle - _vehicle will resume last ordered waypoint automatically.
// GIVEN: After a "ts---Stop" - when player remains in _vehicle - is "ts---Resume" must be ordered to resume travel.
// GIVEN: Camera switches to "External" when player enters a vehicle.

// GIVEN: Sets initial max speed to 45.

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

_vehicle = _this select 0;
_speedArr = _this select 3;
_speedMode = (_speedArr select 0);
_speed = (_speedArr select 1);

_group = group _vehicle;
_groupLeader = leader _group;
_vehicleArr = [];
_driverArr = [];

// Iterate over each unit in the group
{
    _unitVehicle = vehicle _x;
    _unitDriver = driver _unitVehicle;
    
    // Check if the unit is in a vehicle and if the vehicle is not already in the array
    if (!isNull _unitVehicle && {_unitVehicle != _x} && !(_unitVehicle in _vehicleArr)) then {
        _vehicleArr = _vehicleArr + [_unitVehicle];
        
        // Add the driver to the driver array if they are not already in it
        if (!isNull _unitDriver && !(_unitDriver in _driverArr)) then {
            _driverArr = _driverArr + [_unitDriver];
        };
    };
} forEach units _group;

hint format ["Vehicle: %3, Speed Mode: %1, Speed: %2", _speedMode, _speed, _vehicle];
sleep 2;

// Initialize the flag variable if not already set
if (isNil "vehicleStopped") then {
    vehicleStopped = false;
};

// Check if the _vehicle was previously stopped and not in stop mode
if (vehicleStopped && _speedMode != 4) then {

    // Get the current waypoint of the unit.
    _currentWaypoint = waypoints _vehicle select 0;

    // Check if a waypoint exists.
    if (isNil "_currentWaypoint") exitWith {
        hint "No Waypoint Set";
		sleep 2;
    };

    // Get the position of the current waypoint.
    _waypointPosition = waypointPosition _currentWaypoint;

    _vehicle doMove _waypointPosition;
};

// Switch on the speed mode
switch (_speedMode) do {
    case 0: { // Stop
        _vehicle limitSpeed 15;
        //sleep 2;
        {
		//hint format ["Vic: %1", _x];
		sleep 1;
		doStop _x;
		} foreach _vehicleArr;
        vehicleStopped = true;
    };
    
    case 1: { // Limited
        if (vehicleStopped == true) then {
		
            // Only follow if the vehicle was previously stopped
            units _group doFollow leader _group;
        };
		
        _vehicle limitSpeed _speed;
		vehicleStopped = false;		
    };
    
    case 2: { // Cruise
        if (vehicleStopped == true) then {
		
            // Only follow if the vehicle was previously stopped
            units _group doFollow leader _group;

        };
		
        _vehicle limitSpeed _speed;
		vehicleStopped = false;
    };
    
    case 3: { // Full
		if (vehicleStopped == true) then {
		
            // Only follow if the vehicle was previously stopped
            units _group doFollow leader _group;

        };
		
        _vehicle limitSpeed _speed;
		vehicleStopped = false;
    };
    
    case 4: { // Release
        sleep 10;
        vehicleStopped = false;

        // Get the current waypoint of the unit.
        _currentWaypoint = waypoints _vehicle select 0;

        // Check if a waypoint exists.
        if (isNil "_currentWaypoint") exitWith {
            hint "No Waypoint Set";
        };

        // Get the position of the current waypoint.
        _waypointPosition = waypointPosition _currentWaypoint;

		units _group doFollow leader _group;
        _vehicle doMove _waypointPosition;
        _vehicle limitSpeed _speed;
    };
	
	case 5: { // Regroup
		hint format ["Entering Regroup Mode: vehicleStopped = %1", vehicleStopped];
        sleep 2;
		      {
				hint format ["%1", _x];
				sleep 2;
				_x disableAI "AUTOCOMBAT";
				_x disableAI "TARGET";
				_x disableAI "AUTOTARGET";
				_x disableAI "SUPPRESSION";
				_x disableAI "CHECKVISIBLE";
				_x disableAI "WEAPONAIM";	
				_x disableAI "COVER";						
				_x setBehaviourStrong "SAFE";
				_x setCombatMode "BLUE";
				_x doFollow leader _groupLeader;
			} forEach _driverArr;
    };
};

 

Thanks.

 

Regards,
Scott   

Share this post


Link to post
Share on other sites

Hi Folks,

 

OK - I'm an idiot - I need to DISABLE those features. DOH. It always helps to write a post to problem solve.

 

Regards,
Scott

Share this post


Link to post
Share on other sites

Haha, yeah you need to disable that stuff.  For SOG AI infantry movement control, I set the following in an EachFrame eventHandler.   I use EachFrame because the game engine won't let a unit be Aware (so gun up) and combatMode BLUE (so they ignore enemies when calculating paths) at the same time.

_unit setUnitCombatMode "BLUE"; // this does not make them say Hold Fire
//_unit setCombatMode "BLUE"; // BLUE makes them say Hold Fire
_unit setBehaviourStrong "AWARE";

{_unit disableAI _x;} forEach [
	"SUPPRESSION",
	"AUTOCOMBAT",
	"AUTOTARGET","TARGET","COVER","WEAPONAIM"
	];

It's possible you need to do something similar for your vehicle drivers so the driver can ignore combat pathing and just follow, while rest of team can fire weapons.  If your AI drivers still want to deviate from formation under combat, then check if the engine is automatically changing their combatMode from BLUE to GREEN or RED.  If so, then you likely need to constantly reset their combatMode BLUE via the eachFrame.

 

Good luck man!  I feel your AI control pain for sure!  🙂

  • Thanks 1

Share this post


Link to post
Share on other sites

Hi JB,

 

Thanks for the tips. Yeah - even after fixing my glaring error - same symptoms I had before disabling AI. It runs fairly well until it doesn’t - and my #2 has to forcefully take the lead and charge ahead - or stop after firing off a few Nades again breaking formation. I’m pretty confident I ordered all the disabling of AI in a proper manner. I had done similar on a recent heli script to break contact and it works like a champ.
 

Frame  by frame you say - I’ve heard of it but never really looked into it. Perhaps it’s time.

 

My test setup is the Marines from Generation Kill (desert camo with woodland camo vests) - or as close as I can get to them with the assets I could find - kind of a new genre for me - I think I like it.

 

Regards,

Scott

 

 

  • Like 1

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

×