Home   Help Search Login Register  

Author Topic: AI Helicopter attacks Enemy ground troops  (Read 1738 times)

0 Members and 1 Guest are viewing this topic.

Offline Mostly

  • Members
  • *
AI Helicopter attacks Enemy ground troops
« on: 04 Oct 2008, 21:16:56 »
Evening,
I'm trying to work out how to get an AI controlled Helicopter to attack enemy ground troops. The idea is that the player can call in gunship support to help out. I've searched the forum but can't find an answer. Any ideas? Can I also just say that this site still surprises me with the massive amount of info available, good job guys.
They mostly come out at night. Mostly!

Walter_E_Kurtz

  • Guest
Re: AI Helicopter attacks Enemy ground troops
« Reply #1 on: 05 Oct 2008, 15:50:14 »
I'm not aware that there's an all-encompassing response for this question yet. Search these forums for "strafe" to see how this question has been asked, and not really answered, in the past.

Maybe you could look at Robino's Helicopter Dynamic Control scipt, which unfortunately doesn't appear to include a ground attack option, but does allow the player to direct their movement.

Better than that, if you get it to work, might be Snypir's Support Pack.

Probably the best option, though, would be Fox's Invisible Target Management System (requires Fox's Invisible Targets), which demonstrates a ground attack by an A-10.

Please could you supply more information on how you intended your scenario to work:
which helicopters attacking with which weapons?
are the enemy defending (largely static) or attacking (moving)?
is the player meant to issue targets (via the map screen) or should the choppers find their own?
« Last Edit: 05 Oct 2008, 16:29:01 by Walter_E_Kurtz »

Offline Mostly

  • Members
  • *
Re: AI Helicopter attacks Enemy ground troops
« Reply #2 on: 06 Oct 2008, 14:47:48 »
Thanks for the suggested scripts. I'm in the process of trying to adapt them now.

More info as requested:

The mission involves the player commanding a small special forces team behind enemy lines. I've given the squad several support options which include calling in an airstrike from a jet on a target selected by the player, and calling in an AC130 strike by using the laser designator to direct incoming fire.
I've also put a couple of scripts in which make a large hunter force pursue the player if his team are detected by the enemy.
I want to add an extra support option to call in attack helicopter/s to help the player out. The targets will be a mixture of infantry, vehicles and armour. They will be moving. I want the helicopters to use cannons rather than missiles. I also want the helicopter/s to be able to target independantly from the player, eg. the player is involved in a heavy firefight with enemy forces, and then issues one radio command to call for support to their location, I want the helicopters to come in and engage without any further direction from the player. I can write a script that does everything except get the helicopter to engage the infantry.
They mostly come out at night. Mostly!

Walter_E_Kurtz

  • Guest
Re: AI Helicopter attacks Enemy ground troops
« Reply #3 on: 06 Oct 2008, 16:19:33 »
La la la. I'm not listening. La la la. I can't hear you.    - no need to give so much plot away, you'll raise everyone's expectations  :shhh:

Your mission seems to be for single-player, so the following might make more sense than if it was for MP. But you may still want to double-check that may assertions are correct.

This is easier if it's original BIS choppers you're using, but I'd suggest making a small config.cpp to have the helis behave as you want them, and supply it as an addon pbo.

Edit: View this thread.

I've just tried it on the Cobra in GRAA and concur that adding the lines
Code: [Select]
irScanToEyeFactor=5;
sensitivity=100;
does make it engage infantry targets after eliminating armour. I set up a simple mission with myself as a Civilian observer; a Cobra having a 'Search and Destroy' waypoint near a Mechanized Infantry platoon. The Cobra started with an ineffective Zuni barrage tens of metres away from anyone. It then took out the BMP with a Hellfire and came round for a second pass. It eliminated a number of infantry with a Zuni and thereafter strafed individual soldiers with its gun.

sensitivity=100; is the important line as that makes it notice and engage troops. irScanToEyeFactor=5; seems to control its persistence in attacking individual troops; without the line, groups are attacked but not the remaining few soldiers.

Just copy-and-paste the config of the heli you want to use into a small patch config.cpp, give it a new classname (and editor name for your convenience) and you ought to be good to go. I'd leave the weapon loadouts as they are to start with; hopefully it'd use guns or Zunis against infantry of its own accord, and still would have TOWs against armour if it felt the need.
« Last Edit: 06 Oct 2008, 17:57:52 by Walter_E_Kurtz »

Offline MakkaraTheMan

  • Members
  • *
  • Moikkuli from Finland :)
    • www.lifeline.fi
Re: AI Helicopter attacks Enemy ground troops
« Reply #4 on: 08 Oct 2008, 15:42:27 »
Hi guys!

Wow, that sounds great Walter :good:
That is because the "invisible targets" are very effective way to do CAS, but they have one izzybizzy problem. In my experience the Invisible targets make all air units "crazy". They no longer follow waypoints and so on... and they move right away to attack the inv.target, even if that air unit is on the edge of the map, and the inv.target is on the other edge. In that sense invisible targets are "too effective". Thats why i think Walters advise/code is far better. But is it possible to explane launching that Code a bit? 
Quote
Just copy-and-paste the config of the heli you want to use into a small patch config.cpp, give it a new classname (and editor name for your convenience) and you ought to be good to go. I'd leave the weapon loadouts as they are to start with; hopefully it'd use guns or Zunis against infantry of its own accord, and still would have TOWs against armour if it felt the need.

patch? config.ccp? give a new classname? Is this something to do with addon editing, and not basic scripting?

If it is i'm in deep s..t. I've never "opened" / edited "units". That would be a great thing, but i dont understand anything about the tools for doing that.... ???

Cheers!

Walter_E_Kurtz

  • Guest
Re: AI Helicopter attacks Enemy ground troops
« Reply #5 on: 08 Oct 2008, 18:18:48 »
Quote
Is this something to do with addon editing, and not basic scripting?
Correct. Don't worry about it too much - you'll learn in time.

I'm attaching a demonstration addon and mission. Put WEK_CobraAttacksInfantry.pbo with your addons and CobraAttacksInfantry.Intro among your missions (includes overview & briefing).

The config I used (unnecessary lines eliminated):
Code: [Select]
// some basic defines
#define TEast 0
#define TWest 1
#define TGuerrila 2
#define TCivilian 3
#define TSideUnknown 4
#define TEnemy 5
#define TFriendly 6
#define TLogic 7

#define true 1
#define false 0

// type scope
#define private 0
#define protected 1
#define public 2

#define WeaponNoSlot 0 // dummy weapons
#define WeaponSlotPrimary 1 // primary weapons
#define WeaponSlotSecondary 16 // secondary weapons
#define WeaponSlotItem 256 // items
#define WeaponSlotBinocular 4096 // binocular
#define WeaponHardMounted 65536

class CfgPatches
{
class WEK_CobraAttacksInf
{
units[] = {"WEK_AntiInfCobra"};
weapons[] = {};
requiredVersion = 1.96;
};
};

class CfgVehicles
{
class All {};
class AllVehicles: All {};
class Air:AllVehicles{};
class Helicopter:Air{};
class Cobra:Helicopter{};
class WEK_AntiInfCobra:Cobra
{
scope=2;
side=1;
displayName="Anti-Inf Cobra";
nameSound="cobra";
vehicleClass="WEK Test Units";
accuracy=0.3;
weapons[]={"MachineGun30W","HellfireLauncherCobra","ZuniLauncher38"};
magazines[]={"MachineGun30W","HellfireLauncherCobra","ZuniLauncher38"};
type=2;
threat[]={0.3,1,0.8};
laserScanner=1;
sensitivity=100;
irScanToEyeFactor=5;
};
};

Offline MakkaraTheMan

  • Members
  • *
  • Moikkuli from Finland :)
    • www.lifeline.fi
Re: AI Helicopter attacks Enemy ground troops
« Reply #6 on: 08 Oct 2008, 22:32:10 »
Rock!

Hey Walter, i just took a test with your example mission, and it works great! :clap:

I strongly recommend that administrators check this out, and put this thing in the ACCEPTED -tutorials, scripts or functions. Tough it doesn't really fit perfectly in any of those, cause this is moore like an addon modifcation, but still... I think meny people would love this!

Tough the cobra didn't use its MG against soldiers, but i trust that it will, when the zunis are empty. -MOSTLY- wanted the MG, but i think this is a huge improvement allready, and it is fairly realistic. Rockets are used quite often against (meny)soft targets in fast CAS situations. In fact if recall right, the attack choppers are mostly using the 30mm MG:s and TOW:s/Hellfires against APC:s, because the zunis are too inaccurate and unreliable for that job. Smaller caliber Chain guns are a whole other story. 3000rpm firing rate is much better against infantry, than 600rpm with 30mm armoured rounds. It's a just wayst of good bullets...   

And one moore thing for our great superartistscripter WALTER:

Could you make the same kinda stuff with transport choppers, like regular UH60:s,  and BIS-addons Black Hawks MH-60K, Chinooks MH-47E... I know this is just too much for the same topic, but why not solve a bunch of probs at the same time.

Most of the the OFP transport choppers are all so equipped with light CAS tools. The main problem is that they do target "man class" objects, but that doesn't do any good, if the pilot points his nose directly to the target unit and flyes over, like our Cobra here.

What they should do, is fly counter clock wise, around the target (aböyt 100m high, 150m distance), cause the side gunner is allways on the left side. I'll try to put an example mission here > (Made w.Vista 64bit file)

Cheers dudes!  :good:
« Last Edit: 08 Oct 2008, 23:20:56 by MakkaraTheMan »