Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

Recommended Posts

Hello!

I was hoping someone would like to help me out here.

I'm making a mission where I want an enemy AI sniper to call a CAS in a certain area at a certain time. I've been searching around in forums, google and youtube but couldn't find the solution.

/Kapten rödskägg

Share this post


Link to post
Share on other sites

If you want the CAS missions to come in at a specific time at a specific place, you should just create the gun runs yourself, and maybe use event handlers or triggers to get them to start. A simple way to do it would be to use UnitPlayFiring, and trigger that when the AI detects enemies or something like that.

The AI doesn't have to do anything for that to happen, that's why we script it.

Share this post


Link to post
Share on other sites

I currently use the inlined script to call a helo on a target by the AI. It's originally based on Draper's airsupport script, also found in this forum.

The script is not flexible on purpose, as I wanted to have something simple. For testing you need to have the following stuff in the scenario:

  1. Helicopter named attackHelo
  2. Helicopter crew member of ahGroup group
  3. Marker named Target
  4. Helo pad named Base

For creating the helo I use a script that contains:

attackHeloName = "AH1Z";
ahGroup = createGroup west;
_all = [(getPos Base), 90, attackHeloName, ahGroup] call bis_fnc_spawnvehicle;
attackHelo = _all select 0;

Here is the script that the AI can use, for example with

[] execVM "SupportHelo.sqf", assuming that the script is named SupportHelo.sqf in your mission directory. Good luck.

#define DEBUG_MSG(ARG) ARG call CBA_fnc_debug;
#define CIRCLEPOS(x,y,d,r) [x-r*sin(d),y-r*cos(d)]
#define DEFAULTDIST 500
#define DIST 150
#define HEIGHT 60
#define TIMEOVERTARGET 5

// the unit 'attackHelo' manned by the group 'ahGroup' will fly to marker 'Target' 
// and pick a random ingress and egress
// point in a circle at DEFAULTDIST radius from 'Target' position. It will continue this
// until _enemyPresent is false. For this the group 'target' is used.
// _enemyPresent will be
// set to true when all people in 'target' are dead.
// After the mission it returns to 'Base' position, which is
// a helo pad on my map.

DEBUG_MSG(["Checking if mission is ongoing, waiting for completion if so"])
waitUntil {attackHeloSortie == false};

DEBUG_MSG(["Attack Helo: air init complete"])
attackHeloSortie = true;
_plane = attackHelo;
_crew = ahGroup;
_targetGroup = target;
_markerName = "Target";

_pilot = ((units _crew) select 0);
// _gunner = ((units _crew) select 1);
_msg = format ["Plane: %1, Pilot: %2", _plane, _pilot];
DEBUG_MSG([_msg])

DEBUG_MSG(["Attack Helo: ready"])
sleep 5;

_base = Base;
_target = getMarkerPos _markerName;
_ingress = CIRCLEPOS((_target select 0), (_target select 1), random(360), DEFAULTDIST);
_egress = CIRCLEPOS((_target select 0), (_target select 1), random(360), DEFAULTDIST);
_enemyPresent = true;

while {_enemyPresent} do {
 _WP = _crew addWaypoint [_ingress,0];
 _WP setWaypointSpeed "FULL";
 _WP setWaypointType "MOVE";
 _WP setWaypointCombatMode "BLUE";
 _crew setCurrentWaypoint _WP;
 DEBUG_MSG(["Attack Helo: Moving to ingress"])
 waitUntil {(_plane distance _ingress < DIST)};
 _WP = _crew addWaypoint [_target,0];
 _WP setWaypointSpeed "FULL";
 _WP setWaypointCombatMode "RED";
 _WP setWaypointType "SAD";
 _crew setCurrentWaypoint _WP;
 DEBUG_MSG(["Attack Helo: Engaging"])
 waitUntil {(_plane distance _target < DIST)};
 // stay over hot area
 sleep TIMEOVERTARGET;
 DEBUG_MSG(["Attack Helo: Disengaging, moving to egress"])
 _WP = _crew addWaypoint [_egress,0];
 _WP setWaypointSpeed "FULL";
 _WP setWaypointType "MOVE";
 _WP setWaypointCombatMode "BLUE";
 _crew setCurrentWaypoint _WP;
 waitUntil {(_plane distance _egress < DIST)};
 // check if enemies are left
 // To be done
 _msg = format["Attack Helo: _targetGroup: %1", _targetGroup];
 DEBUG_MSG([_msg])
 _alive = 0;
 {
   if (alive _x) then {
     _alive = _alive + 1;
   };
 } forEach (units _targetGroup);
 _msg = format ["Attack Helo: alive: %1", _alive];
 DEBUG_MSG([_msg])
 if (_alive < 1) then {
   _enemyPresent = false;
 };
};

DEBUG_MSG(["Attack Helo: Sortie complete, moving back to base"])
_WP = _crew addWaypoint [_base, 0];
_WP setWaypointSpeed "FULL";
_WP setWaypointType "MOVE";
_WP setWaypointCombatMode "BLUE";
_crew setCurrentWaypoint _WP;
waitUntil {(_plane distance _base < DIST)};

// land
_WP = _crew addWaypoint [_base, 0];
_WP setWaypointSpeed "FULL";
_WP setWaypointType "GETOUT";
_crew setCurrentWaypoint _WP;

// crew back in for next sortie
waitUntil {{alive _x} count (units _crew) == {!(_x in _plane)} count (units _crew)};
DEBUG_MSG(["Attack Helo: All crew members out"])
_WP = _crew addWaypoint [getPos _plane, 0];
_WP setWaypointType "GETIN";
_crew setCurrentWaypoint _WP;
DEBUG_MSG(["Attack Helo: Boarding again"])
attackHeloSortie = false;
DEBUG_MSG(["Attack Helo: Ready for new mission"])

You need to load CBA as the debug print uses it. But you can replace the DEBUG_MSG macro with anything else to have it working w/o CBA.

Edited by TeTeT
add CBA dependency information

Share this post


Link to post
Share on other sites

@the hebrew hammer

I'm not 100% sure what you suggest but it seems a lot simpler than the alternative by TeTet. I tried with sending in an aircraft "manually" with the waypoint "destroy" directed to a tank but the aircraft wouldn't fire. If i could make the airplane drop the bomb I wouldn't need anything else. Any idea?

what is event handlers and UnitPlayFiring?

Share this post


Link to post
Share on other sites

This may not be what you're looking for, but I tried

http://www.zshare.net/download/9681757245311de0/

To use: extract the folder into your Documents\arma2\missions folder, load it from the editor.

I'm still not sure what you are trying to accomplish. What I was saying is that if your target is static, the CAS mission can be scripted.

If the target is an active moving tank, ignore what I have to say and use the script mentioned above. I would instead attach a marker to the tank and use getPos "marker" in the parameters and see if that works. It is much more complex to have the AI actually request for air support or artillery.

For a static target I would use UnitPlayFiring and commence the script wih a detected by OPFOR trigger or possibly a fired event handler for the sniper. UnitCapture essentially lets you fly a plane or helicopter around and it's path will be copied to your clipboard for use in a script. It will also record any weapons you fire. You would fly the CAS mission, copy the data to your script and then trigger it in the mission.

There are two tutorials on youtube for this. I can maybe throw together a demo later today.

Part 1: Capturing the flight path:

ryB20wQhSr0

Part 2: Pertains to firing

ePszdYfMRvc

I recommend condensing the codes he gives in the description into one script though, he's running two different paths with two different birds.

Edited by The Hebrew Hammer

Share this post


Link to post
Share on other sites
Sign in to follow this  

×