Home   Help Search Login Register  

Author Topic: ROMM_IA (ACCEPTED)  (Read 9763 times)

0 Members and 3 Guests are viewing this topic.

Offline Rommel92

  • Members
  • *
ROMM_IA (ACCEPTED)
« on: 17 Apr 2008, 05:12:59 »
Rommels Improved AI
Version 110 by Rommel

This new version of Rommels fMorale/Suppressive Fire Reactive Ai, or the new name: ROMM_IA (Rommel Improved AI). Despite the name changes, has had great improvement. With increased AI reactions, effective suppressive fire, designed for multiplayer and a huge increase in their apparent IQ.  :P
Its initial aim was just to make AI's drop to the deck, but over the last few weeks my scripting knowledge has increased and so has this script. It has reached what i wanted to become, and I will only be working on bugs if any are found.

NO GLOBAL VARIABLES + SQF Optimized.

Preview Mission Included which as Surdus' Priest's nearExp resource included (love it.),otherwise feel free to edit, keep base credits if possible please, else its open source and go insane.  :)

HowTo: Implement

A simple init line execution is suffice to include this into your missions.
nul = [group this] execVM "ROMM_IA.sqf";

However for multiple groups use:
SQF: {[_x]execVM "ROMM_IA.sqf"; sleep 0.25} forEach [group1,group2,group3];
SQS: {[_x]execVM "ROMM_IA.sqf"; ~0.25} forEach [group1,group2,group3]

HowTo: DAC v2

Code: [Select]
_Events_Unit_S =
[
["[_group] call compile preProcessFile "ROMM_IA.sqf""],
[],
[],
[],
[],
[]
];

This will launch the script afterBuildUp in the Dynamic Ai Creator (v2), this area can be found in DAC config folder (config_events.sqf)


Please report and bugs found.


VERSION 112.2

http://pb.6thsense.eu/pb/89 (112 Debug Version)

Below is test mission with non-debug version:
Get ROMM IA 112
« Last Edit: 22 Jun 2008, 16:31:38 by Mandoble »

Offline Imutep

  • ArmAdeus
  • Members
  • *
  • What?
    • Assault Mission Studio
Re: AI Suppressive Fire Reactive (Ready To Submit?)
« Reply #1 on: 17 Apr 2008, 22:22:30 »
Hi Rommel92 ...i've tested your script, but my ArmA hang up  ???
Assault Mission Strudio<br />It\'s always something!!

Offline Rommel92

  • Members
  • *
Re: AI Suppressive Fire Reactive (READY)
« Reply #2 on: 19 Apr 2008, 04:46:07 »
I've tested it with ArmA version 1.08 upwards. I highly doubt it to be a compatibility error with mods... however, were you running any, how does it go with standard ArmA if so... when did it crash (if thats what you mean via "hang up").

Any chance of this being submitted? Otherwise... any feedback...  :dunno:

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AI Suppressive Fire Reactive (READY)
« Reply #3 on: 19 Apr 2008, 10:11:21 »
At mission start I get an scalar message, a bit later:
Error in expression <_nInt + (count _nArr);

If ((_nInt > _c + _d select 0) || (_mInt > 24)) then
{
>
  Error position: <+ _d select 0) || (_mInt > 24)) then
{
>
  Error Generic error in expression

I get the message XXX start supression, but no effect at all.

plain 1.08.

Offline Rommel92

  • Members
  • *
Re: AI Suppressive Fire Reactive (READY)
« Reply #4 on: 19 Apr 2008, 15:54:11 »
The SCALAR bool 0xf message at start is an ArmA bug, seems group names aren't given until 1 second after game start (BIS ones, like EAST 1-1-A), was mainly for debugging on a delayed start.

The error stated is unusual, but it explains the lack of effect of the script, will fix and have re-uploaded as 1.01b for recognition. Sorry for the error, I simply didn't check enough.  :confused:

EDIT: Fixed, missing ().

« Last Edit: 20 Apr 2008, 01:46:03 by Rommel92 »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AI Suppressive Fire Reactive (READY)
« Reply #5 on: 19 Apr 2008, 16:52:32 »
//===========================================================================//
// "suppr.sqf"
// Version: n01 [17, 04, 2008]
// Author(s): Rommel [rommelvonrichtofen_at_bigpond.com]
// Execution: [group] execVM "suppr.sqf"
//===========================================================================//

While it gets 2 arguments, being the second an array. Please, document the script header with all the needed argument and a detailed explanation of the meaning.

Testing again now.

Offline Rommel92

  • Members
  • *
Re: AI Suppressive Fire Reactive (READY)
« Reply #6 on: 20 Apr 2008, 01:47:45 »
Added a readme explaining the optional integers in the array for the suppression effects, and an extended execution code inside the header.
 ;)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: AI Suppressive Fire Reactive (READY)
« Reply #7 on: 21 Apr 2008, 20:28:44 »
Ok, now please, use your tag (I assume you have one) for these two scripts (rom_whatever.sqf)  ;)

Offline Rommel92

  • Members
  • *
Re: ROMM_IA
« Reply #8 on: 06 Jun 2008, 03:32:20 »
Updated. Finished. Renamed.

And damn it kicks ass  :D.
Enjoy! Check first first for finished product. Please report and bugs you may find.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: ROMM_IA
« Reply #9 on: 09 Jun 2008, 01:20:36 »
Rommel,

This is an impressive script.  I love a few guys laying down covering fire, while other guys ordered to cover.  I also learned a new trick from you about having a gamelogic perform the UseWeapon action (without this trick, the units would perform the gear animation...). 

Your use of targeting with UseWeapon command appears to eliminate the need for invisible target addons.  That is very cool.

Here's a few issues I'd like to report to you.

1. After all the opfor is dead, soldiers sometimes decide to continue suppressing in directions nowhere near the dead enemy.  Like 90 or 150 degrees different direction. I think this occurs if the foe was killed while moving.  When targeting, the suppressor is pointing his weapon at the AI's best guess of where the target unit is (based on knowsabout).  If the target was moving, knowsabout logic makes the suppressor guess a position based on last known speed and heading of the unit.  To illustrate this, I placed a line of empty vehicles (with some gaps between) as cover in front of the opfor.  I then gave them waypoints to move from one end of the line to the other, then cycle.  The shooter tracked them pretty well until they were dead, but then they started shooting way off mark.

2. UseWeapon on snipers will fire a sniper rifle bullet from the pistol (ARMA bug I guess).  This breaks immersion when player sees it.  I tried adding some code that if typeOf unit was sniper, then remove the pistol, and add it back after done suppressing.  This worked better, but sometimes the sniper would go into pistol animation (with no pistol), and rifle would shoot from shoulder, which is even worse.  So that's no good.  So I opted for not allowing sniper class units to suppress.  That would eliminate this silly ARMA bug.

Again, thanks for the great script.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Rommel92

  • Members
  • *
Re: ROMM_IA
« Reply #10 on: 09 Jun 2008, 03:40:25 »
Thanks for the reports, I've noticed myself the random shooting, however it seems that even though theres a alive check, a knowsabout and an ammo check, they keep shooting regardless. I'll continue looking into it.

The sniper bug sounds interesting, I'll make sure to dis-allow them to suppress. (When do snipers supress anyway aye?)

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: ROMM_IA
« Reply #11 on: 09 Jun 2008, 08:49:08 »
Hi Rommel.

I noticed 2 more UseWeapon firing bugs:

a) AT soldiers will fire bullets out of their rocket tubes.
b) Grenadiers often point their weapon at a severe up angle (like they were going to shoot a grenade), and then UseWeapon fires a bullet at that funny angle.  Looks dumb.

Also, I may have solved the random shooting problem, and the AT soldier problem.  Attached is a sample mission I was tinkering with (based from your sample mission).  In it are 3 IA scripts:

- ROMMIA.sqf  - your original script, unchanged
- ROMMIA3.sqf - modified to cure random shooting using Mando Angles
- ROMMIA2.sqf - modified to cure random shooting using Mando Angles plus a new game logic that shooters target as a proxy for the foe.  This version also has code in it for excluding snipers, and removing/restoring all rockets from AT soldiers (which cures them of shooting bullets from their rocket tubes).

I tested the 3 different versions by modifying the init lines of the 3 west groups to call whichever script I wanted to test.  In order to trigger the suppression scripts, you need to run to one of the cover objects and fire your MG at each of the 3 groups.  Then hide.  Then switch to the West officers to observe how the suppressors are shooting.

In the modified scripts I put in comments to clearly bracket the changes I made to make it easy for you to identify the new code.  If you decide to use any of this code, feel free to rip out my comments.

I used Mando Angles to prevent the shooter from shooting unless he is pointing at original target +/- 30 degrees.  So when he is tracking a phantom target too far away from original target, he will not shoot.

In the ROMMIA2 version, I also added a gamelogic for the shooter to target, rather than target the foe unit himself.  I discovered that as time elapses, the knowsabout is less fresh, and the shooter will be more likely to target away from the foe location (especially if the foe was moving).  The game logic is setposed to the foe's location, and it is deleted and recreated inside the main suppress loop.  By recreating it, the knowsabout is fresh again, and the shooter re-targets close to the foe position.

I don't know if there is any performance consideration with deleting and recreating a gamelogic with every loop iteration...but it has worked fine in these limited tests.

Anyway, I had fun doing this, and I hope you find it useful.  I know I plan to use this on the sequel to my mission Last Tango in Bagango.  :D

Adios,

Johnnyboy.

Edit1:  The same type of fix used for AT soldiers, also works for grenadiers, to prevent them from shooting up in the air.  You simply remove and save their grenades at the top of the suppress function:

Code: [Select]
// Remove rifle grenades from shooter, so we don't see problem where soldier
// points weapon in air and useweapon makes him fire bullets up (which looks stupid)
if ((magazines _x) find "1Rnd_HE_GP25" > -1) then
{
   _grenMag = "1Rnd_HE_GP25";
   _grenCount = count(magazines _x - (magazines _x - [_grenMag]));
   for "_y" from 1 to _grenCount do {_x removemagazine _grenMag};
   player sidechat format ["removing %1 grenade mags",_grenCount];
};
if ((magazines _x) find "1Rnd_HE_M203" > -1) then
{
   _grenMag = "1Rnd_HE_M203";
   _grenCount = count(magazines _x - (magazines _x - [_grenMag]));
   for "_y" from 1 to _grenCount do {_x removemagazine _grenMag};
   player sidechat format ["removing %1 grenade mags",_grenCount];
};

And then add the grenades back before exiting suppress function:

Code: [Select]
for "_y" from 1 to _grenCount do {_x addmagazine _grenMag};
Edit2:  In a copy of your script where I only use the suppress code, I had a problem where once suppressing units "needed ammo", they would go off course to get ammo, but the UseWeapon was still making them fire, so they fired in the wrong direction.  So I placed some ammo boxes near the 3 suppressing teams into your demo mission, and the modified demo mission I made, and I removed all but 1 magazine from some of the suppressors.  These missions passed the test (both your original, and the modified one).  When they went for ammo, they did not fire in the wrong direction.  So that's good!  In my smaller test suppress version that I copied from your code I must be missing something that allowed the problem to occur...

« Last Edit: 10 Jun 2008, 17:42:02 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Rommel92

  • Members
  • *
Re: ROMM_IA
« Reply #12 on: 14 Jun 2008, 20:29:07 »
VERSION 112 RELEASED. Check first post for updated download link.

 :)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: ROMM_IA
« Reply #13 on: 22 Jun 2008, 15:49:24 »
Just a couple of points, to help avoid others making the same mistake I did

Thanks goes to killswitch for finding the solution !

Am implementing this into a mod that our community is developing.
In the readme it states
Quote
"Execution: nul = [group this] call compile preProcessFile "ROMM_IA.sqf";
(see the commented out section at the top of the readme)

and lower down it states
Quote
However for multiple groups use:
{[_x]call compile preProcessFile "ROMM_IA.sqf"} forEach [group1,group2,group3];

This only allows the code to run on the first group that initiated the code.
You can verify this by having the following line  at the start of the supression script

player sidechat format ["Group initiating: %1",_this];

If you have 5 groups, you will only see 1 instance of the sidechat message whereas you should see 5 all with different group names.

What ideally should occur, is that the precompile should be done only once and prior to any groups calling the code
Each group simply needs then to call the code....

for example...
Quote
ESP_fAIsuppression    = compile preProcessFile "esp_sys\server\ROMM_IA.sqf";
and then for each group that you want to run the supression script use....

{if((isServer)&&(local leader _x))then{[_x] spawn ESP_fAIsuppression; sleep 0.25}} forEach _groups;



If you wanted to automate the entire system without having to enter code into each groups init field in the mission editor, you could do this by having server side create a trigger, list all the units in the trigger and from that filter an array of groups

something like
Code: [Select]
if!(IsServer)exitwith{};
ESP_fAIsuppression = compile preProcessFile "esp_sys\server\ROMM_IA.sqf";
ESP_MainTrig           = createTrigger ["EmptyDetector",getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")];
ESP_MainTrig setTriggerType "NONE";
ESP_MainTrig setTriggerArea [30000,30000,0,true];
ESP_MainTrig setTriggerActivation ["ANY","PRESENT",False];
sleep 0.5;

_groups = [];
{if !(group _x in _groups)then{_groups = _groups + [group _x]}} foreach (list ESP_Maintrig);
{if((isServer)&&(local leader _x))then{[_x] spawn ESP_fAIsuppression; sleep 0.25}} forEach _groups;
{if(local leader _x)then{[_x] spawn ESP_fAIsuppression; sleep 0.25}} forEach _groups;


Thanks for the effort Rommel, keep up the good work


Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: ROMM_IA (ACCEPTED)
« Reply #14 on: 02 Jul 2008, 14:08:35 »
Quote
However for multiple groups use:
{[_x]call compile preProcessFile "ROMM_IA.sqf"} forEach [group1,group2,group3];
Tx, do you know why doesn't this work? I figure it must be related to ArmA caching the compiled function, but I don't really understand.
urp!