Jump to content
pcc

AI commander call warfare artillery at waypoints

Recommended Posts

I'm trying to get the AI commander to call warfare artillery fire mission at capture waypoints when it creates capture missions.

However, I'm stuck on adding call Support_ArtilleryRequest.sqf to Mission_CaptureCommanderAI.sqf. 

Share this post


Link to post
Share on other sites

Support_ArtilleryRequest.sqf is a player map-click script.  It's not designed for AI Commander to use.

 

Try having the server run:

 

[_side,_position,_destination,_radius,2,2] Spawn BIS_WF_FireLocalArtillery;

 

_side = which side artillery to fire

_position = place where the arty battery is at (usually base, but could be at camps)

_destination = where to rain down the steel

_radius = random dispersion radius of rounds on impact

2, = minimum delay before firing after the target gets acquired

2 = max random delay added to the minimum delay.

  • Like 1

Share this post


Link to post
Share on other sites

Do you mean in Mission_CaptureServer.sqf, or in one of the files in Server folder?  I'm not sure which files to use from Server folder.

For side, could be it any, so both bluefor and opfor commander can use it?  

For _position how do I assign it with any available artillery on map?

 

Tried in Mission_CaptureCommanderAI.sqf, but not sure make _side all sides and _HQ all locations instead.

[_side,_HQ,_hostileLocations,_radius,2,2] Spawn BIS_WF_FireLocalArtillery;

 

Share this post


Link to post
Share on other sites

Mission_CaptureAI.sqf has the patrol points, it would be the logical place to put it.  The script cycles repeatedly, so the fire mission spawn would need a condition set up to make sure it only runs once per patrol point.

 

The spawn would go somewhere after where _side is defined in the script.  _destination would be each patrol point in turn.  Getting base artillery position would be:

 

_base = Call Compile Format ["%1Base",WFSideText _side];

_position = getPos _base;

  • Like 1

Share this post


Link to post
Share on other sites

Mission_CaptureAI.sqf

Spoiler

if (Leader _team Distance _destination > 30 || time > _timeNextMove) then
	{
		if (_type In [Localize "STR_WF_TEAMINF",Localize "STR_WF_TEAMMECH"]) then {_team SetVariable ["transportDisembarkRange",(_location GetVariable "range") * 1.2]}
		else {_team SetVariable ["transportDisembarkRange",-1]};

		[_team,([_destination,_radius,_radius * 1.3] Call GetRandomPosition)] Call BIS_WF_AITeamMove;
		_team SetVariable ["missionLocation",_location];

		_timeNextMove = time + 90;
  
  		_base = Call Compile Format ["%1Base",WFSideText _side]; 
		_position = getPos _base; 
		[_side,_position,_destination,_radius,2,2] Spawn BIS_WF_FireLocalArtillery; 
	};

 

 

Mission_ReconAI.sqf

Spoiler

else
	{
		if ((_team GetVariable "missionLocation") Distance _location > 1 || time > _timeNextMove) then
		{
			if (Leader _team Distance _location > 250) then
			{
				_base = Call Compile Format ["%1Base",WFSideText _side]; 
				_position = getPos _base; 
				[_team,_position,_location,50,0,2] Spawn BIS_WF_FireLocalArtillery;
			};
		
			if (TypeName _location != "ARRAY") then {[_team,Position _location] Call BIS_WF_AITeamMove} else {[_team,_location] Call BIS_WF_AITeamMove};

			_team SetVariable ["missionLocation",_location];
			_timeNextMove = time + 90;
		};
	};

 

 

Cool :D, the base mortar is firing, also added spawn to Mission_ReconAI.sqf for possible AI HQ kill. LOL 

However, I'm getting error, after they fire.  

Spoiler

Error in expression <= GetPos _artillery;
_x = (_destination Select 0) - (_position Select 0);
_y = (>
  Error position: <Select 0) - (_position Select 0);
_y = (>
  Error select: Type Object, expected Array,Config entry
File CA\Warfare2\Scripts\Common\Functions\Common_FireArtillery.sqf, line 36

 

 

Share this post


Link to post
Share on other sites

An object is being sent as the destination rather than a position array.  Try:

 

if (typeName _destination != "ARRAY") then {_destination = getPos _destination};

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, both recon and capture artillery works in A2 warfare.  But in warfare OA  its throwing these errors.

 

Spoiler

Error in expression <EastArtilleryVelocities Select _type>
  Error position: <EastArtilleryVelocities Select _type>
  Error Undefined variable in expression: eastartilleryvelocities
Error in expression <tillery SetVariable["artilleryVelocity",_velocity];
_artillery SetVariable["arti>
  Error position: <_velocity];
_artillery SetVariable["arti>
  Error Undefined variable in expression: _velocity
File CA\Warfare2\Scripts\Common\Functions\Common_FireArtillery.sqf, line 83
String STR_EVAL_TYPENAN not found
Error in expression <ance ^ 2) * 2);
Sleep (_arcDistance / _velocity);
_distance = Random (_distan>
  Error position: <_velocity);
_distance = Random (_distan>
  Error Undefined variable in expression: _velocity

 

 

Edit: Found the typo in config artillery of warfare OA

Share this post


Link to post
Share on other sites
On 3/23/2017 at 6:46 PM, opusfmspol said:

The script cycles repeatedly, so the fire mission spawn would need a condition set up to make sure it only runs once per patrol point.

I'm stuck at setting a condition where it fires 5 times per patrol point.

Tried using variable _a for counting but it complains about undefined variable.   If I define it, then the loop would clear its count. 

if (Leader _team Distance _destination > 30 && (_a < 5)) then
{
	_a = _a + 1;
		if (_type In [Localize "STR_WF_TEAMINF",Localize "STR_WF_TEAMMECH"]) then {_team SetVariable ["transportDisembarkRange",(_location GetVariable "range") * 1.2]}
		else {_team SetVariable ["transportDisembarkRange",-1]};

		[_team,([_destination,_radius,_radius * 1.3] Call GetRandomPosition)] Call BIS_WF_AITeamMove;
		_team SetVariable ["missionLocation",_location];

		_timeNextMove = time + 90;
  
  		_base = Call Compile Format ["%1Base",WFSideText _side]; 
		_position = getPos _base; 
		[_side,_position,_destination,_radius,2,2] Spawn BIS_WF_FireLocalArtillery; 
};

 

Share this post


Link to post
Share on other sites

Initialize it before your loop

Gesendet von meinem SUNNY mit Tapatalk

Share this post


Link to post
Share on other sites

Wouldn't the variable data get overridden by the initialization when the script is run again?

BIS has these notes in the script.

Spoiler

/*
    Description: Capture a location.

    Note: Performs one cycle (tick, iteration, loop, etc.) of mission. Each cycle must be
    self-contained, if any information needs to be tracked then return it in an array at
    the end of the script. This will then be passed to the next cycle as _data.
    If mission succeeds then first element in returned array should be true, otherwise false.
    This script/cycle is executed after a certain interval of time from the AI manager. It
    will continue to be executed until the mission is completed (or if mission is looping).
    This script cannot have a continuous loop or delay because it would conflict with the
    AI manager which handles other team processes such moving back to the base for
    reinforcements, changing missions, etc.
*/

Not sure how to pass it as _data.

Share this post


Link to post
Share on other sites

The data array gets defined and returned in the last line of the script:

if !(isnil "_patrolLocation") then {[_completed,_timeNextMove,_patrolPoints,_patrolLocation]} else {[_completed,_timeNextMove]}

 

The second array [_completed,_timeNextMove]  gets returned when the mission is terminated or completed.

 

While the mission is in progress there is a patrol location, so the first array [_completed,_timeNextMove,_patrolPoints,_patrolLocation]  gets returned.  You would want to return it in the first array, it will then get passed into the script during the next cycle:

if !(isnil "_patrolLocation") then {[_completed,_timeNextMove,_patrolPoints,_patrolLocation,_artySuppression]} else {[_completed,_timeNextMove]}

 

When the script starts running, define the value in the block that defines variables based upon what the _data array contains:

//If this is not the first cycle then data will be passed.
if (Count _data > 0) then
{
	_timeNextMove = _data Select 1;
	_patrolPoints = _data Select 2;
	_patrolLocation = _data Select 3;
	_artySuppression = _data Select 4;	// <--- added
}
//If no data then this is the first cycle.
else
{
	_team SetVariable ["missionLocation",_location];
	_timeNextMove = time - 1;
	_artySuppression = 0;			// <--- added
};

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the help.

 

I'm wondering if the base defense mortar only can rearm a limited amount of times?  Before the artillery call limit, I had a lot empty AI mortars that doesn't seem to get rearmed after a while.

Then I noticed mortars only get their ammo refilled once or twice when I tried it then it just stays empty.

Share this post


Link to post
Share on other sites

I believe static defenses resupplying have to do with distance to a vehicle service point.  Server's BIS_WF_UpdateVehicleServicePoint loop should handle it.

  • 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

×