Jump to content
Ragnarok44fan

DELETE ALL NEW AI AFTER A LIMIT IN A DYNAMIC MISSION

Recommended Posts

how to monitor the number of currently present AI in a dynamic mission and delete all spawned AI upper this limit

thanks

 

 

Share this post


Link to post
Share on other sites

With the amount of information you have provided we can only give you rough ideas.

 

Why delete after spawn, that's incredibly wasteful. Just prevent spawning when the.number of AI gets too high.

This can be done by storing each spawned unit after they are created and then before spawning new units count the number of living left and compare with your limit.

 

If you absolutely have to delete after spawn well, the idea is the same, you count the living and check if the newly created unit should be removed... but again this is not a boon to performance.

 

If you want more help you'll have to provide more details on how your units are spawned.

 

  • Like 1

Share this post


Link to post
Share on other sites

I thought there was a simple way to count the present AI units for each currently running game

and when a limit is exceeded, the creation of new units can somehow be globally prohibited

but according to them such global regulation is not possible

you have need to go into the given spawn programcode and control it there

it is complicated in this case because it is a complex game mode / mission programmed by Mondkalb and Rydygier

 

now in this a AI-cache script run,with a controversial game experience,i would to remove this and instead of this using an AI limit instead (because the AI stops above 255 units)

https://drive.google.com/file/d/1Sh4qD5uEGBle9DtpG-MyvQw2-9PAHQ-O/view?usp=drive_link

Share this post


Link to post
Share on other sites
8 hours ago, mrcurry said:

With the amount of information you have provided we can only give you rough ideas.

 

Why delete after spawn, that's incredibly wasteful. Just prevent spawning when the.number of AI gets too high.

This can be done by storing each spawned unit after they are created and then before spawning new units count the number of living left and compare with your limit.

 

If you absolutely have to delete after spawn well, the idea is the same, you count the living and check if the newly created unit should be removed... but again this is not a boon to performance.

 

If you want more help you'll have to provide more details on how your units are spawned. 

 

I thought there was a simple way to count the present AI units for each currently running game

and when a limit is exceeded, the creation of new units can somehow be globally prohibited

but according to them such global regulation is not possible

you have need to go into the given spawn programcode and control it there

it is complicated in this case because it is a complex game mode / mission programmed by Mondkalb and Rydygier

 

now in this a AI-cache script run,with a controversial game experience,i would to remove this and instead of this using an AI limit instead (because the AI stops above 255 units)

https://drive.google.com/file/d/1Sh4qD5uEGBle9DtpG-MyvQw2-9PAHQ-O/view?usp=drive_link

Share this post


Link to post
Share on other sites
17 hours ago, Ragnarok44fan said:

I thought there was a simple way to count the present AI units for each currently running game

There is, { !isPlayer _x } count allUnits.

 

17 hours ago, Ragnarok44fan said:

and when a limit is exceeded, the creation of new units can somehow be globally prohibited

You cannot prohibit spawning globally no, possible hack is to delete them after spawn but this can turn quite bad for performance. 

 

On top of that the script that spawned the unit may rely on the assumption that the unit exists  and deleting it early can be another whole can of worms...

 

If you can't figure out the spawn code yourself your best bet to stop the unnecessary spawning is to contact the original author(s).

  • Like 1

Share this post


Link to post
Share on other sites
On 9/7/2023 at 1:29 AM, Ragnarok44fan said:

how to monitor the number of currently present AI in a dynamic mission and delete all spawned AI upper this limit

thanks

 

 

 

Kick and dirty (see posts above). Run:
 

addMissionEventHandler ["EntityCreated", {
   params ["_entity"];
   if (_entity iskindOf "CAManBase" && {count allUnits > 244}) then {  // 244 or else
     systemChat format ["deleting %1",typeof _entity];   // not mandatory
     private _veh = vehicle _entity;
    deleteVehicleCrew _veh; deleteVehicle _veh;
  };
 }];

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
14 hours ago, pierremgi said:

 

Kick and dirty (see posts above). Run:
 


addMissionEventHandler ["EntityCreated", {
   params ["_entity"];
   if (_entity iskindOf "CAManBase" && {count allUnits > 244}) then {  // 244 or else
     systemChat format ["deleting %1",typeof _entity];   // not mandatory
     private _veh = vehicle _entity;
    deleteVehicleCrew _veh; deleteVehicle _veh;
  };
 }];

 

superthanks,I'm very curious, in theory the enemy commander doesn't produce units in every minute, so the deletion doesn't have to work all the time
rather, I'm afraid that 250 ai is not enough for an rts of this size

Share this post


Link to post
Share on other sites
5 hours ago, Ragnarok44fan said:

superthanks,I'm very curious, in theory the enemy commander doesn't produce units in every minute, so the deletion doesn't have to work all the time
rather, I'm afraid that 250 ai is not enough for an rts of this size

Well what @pierremgi posted is an event handler, it only runs whenever a Entity is created. Spawning units is relatively resource intensive, so is deleting them. Hence why this hack isn't the best solution.

 

When you mention the specific numbers of 244/255 units though the limitation is likely not the number of units but rather the number of groups, which is hard-capped by the engine at 288 per side. Maybe there is some groups not being deleted when empty?

 

Here's the thing:

If you want each unit to act completely independently then you need 1 group per unit but if you want more units you need to squeeze more units into each group. The trade-off is that they will act as a group. For an RTS style mission/mod this is a challenge to deal with.

 

Limiting resources or scope can help but at the end of the day Arma 3 was not built for that amount of active units with such a high level of detail. You got to remember modern RTS games have very simple models or other geometry and use fancy shaders and other tricks to make things look good and run smooth with a metric f*-ton of units on screen.

 

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, mrcurry said:

Well what @pierremgi posted is an event handler, it only runs whenever a Entity is created. Spawning units is relatively resource intensive, so is deleting them. Hence why this hack isn't the best solution.

 

When you mention the specific numbers of 244/255 units though the limitation is likely not the number of units but rather the number of groups, which is hard-capped by the engine at 288 per side. Maybe there is some groups not being deleted when empty?

 

Here's the thing:

If you want each unit to act completely independently then you need 1 group per unit but if you want more units you need to squeeze more units into each group. The trade-off is that they will act as a group. For an RTS style mission/mod this is a challenge to deal with.

 

Limiting resources or scope can help but at the end of the day Arma 3 was not built for that amount of active units with such a high level of detail. You got to remember modern RTS games have very simple models or other geometry and use fancy shaders and other tricks to make things look good and run smooth with a metric f*-ton of units on screen.

 

the ai soldiers follow the orders of the commanders, but their own ai also works


now the huge rts mod works great with the "ai cache"

my problem is that they often get out of the vehicle when I switch back from the fps view

but maybe there is a solution for this when the position of all members of the group is stored and they don't spawn around the commander when I enter fps

If i good remember,i used this as well,  only for some reason the soldiers accompanying the soviet fell behind the tanks and the tanks came to attack on their own

that's why I used respawning around the commanders

the "ai distributing system" mod configuration file is not well commented

but one would be nice
unit limit and then all mods would work

 

and there are many little things that annoy me in the cache system, you have to get used to it, e.g. in this video, as a commander, I got into the truck next to the driver, then I couldn't choose the commander to get out, so the driver got out, which lost the truck(like individual RTS selectable unit)I have never been so clumsy in this game as I was at the beginning of this one with the transport truck

 

 

Share this post


Link to post
Share on other sites
22 minutes ago, pierremgi said:

you could try :
setUnloadInCombat

and

allowCrewInImmobile

on edited and spawned vehicles.

I'm not sure Spearhead DLC hasn't its own behavior for that. In this case, this could be difficult to override it.

this is a dynamic mission, these units are produced by scripts, and also in the cache system with the respawn, I don't know the place where the spawn script runs, but I don't think even the creator knows exactly where 🙂

the perfect thing would be if a programming genius liked this game mode and wouldn't rest, until it wouldn't do it the game experience to "smoothly", with AI cache

this is IFA3 but it would be great if such a point and click RTS/FPS mod was integrated into spearhead

 

here is the mission file for staszow map:     (there are even more mortars in the leskovets mission file, this can be seen when the enemy supports their night attack,in this Staszow the mortars spawn more to the east)

https://drive.google.com/file/d/1G8pnbWnIB7You6I5jKBsxJr7PWE2xNHk/view?usp=sharing

Share this post


Link to post
Share on other sites

your link is not easy to play. You should release something on Steam. The zip contains many files, 2 pbos... difficult to understand what to do with.

What I understand:

- The only mandatory mod is IFA III. I recommend IFA3 AIO on Steam as reference.

- You mention a crew tank mod... repairing tank... very old... so may be problematic for your AI behavior. And double work with your initPlayerLocal.sqf !!

   I felt from my chair, opening the initPlayerLocal.sqf and finding my old code for repairing tanks!!! 😜 (btw, MGI_ is my tag). You can use my scripts, not a problem.

- as said, your pbo is an amount of heteroclite scripts more or less outdated, as  onplayerKilled.sqs  . Nobody should work anymore with sqs

 

 

So, to answer your last post, avoid extra non-mandatory mods, especially for AIs behavior, and replace you initPlayerLocal.sqf by:

[] spawn {
       sleep 1;
       playmusic ["track01", 1];
       sleep 96;
};

MGI_fnc_nbr = compileFinal "
  private ['_vvn', '_str'];
  _str0 =' ';
  _veh = vehicle _this;
  for '_i' from 0 to count crew _veh - 1 do {
    _vvn = vehicleVarName (crew _veh select _i);
    (crew _veh select _i) setVehicleVarName '';
    _str = str (crew _veh select _i);
    (crew _veh select _i) setVehicleVarName _vvn;
    _str0 = _str0 +' '+(_str select [(_str find ':') + 1,2]);
    _str0
  };
";

waitUntil {sleep 1; !isNull (findDisplay 12 displayCtrl 51)};  // main map available

findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {
  _map = _this select 0;
  if (ctrlMapScale _map <0.03 && {difficultyOption "mapContentFriendly" == 1 or difficultyOption "mapContent" == 1}) then {
    {
      _map drawIcon [
        "#(rgb,1,1,1)color(1,1,1,1)",
        [[playerside,false] call BIS_fnc_sideColor,[0.9,0.7,0.6,1]] select (_x in groupSelectedUnits player),
        getPosVisual _x,
        0,0,0, _x call MGI_fnc_nbr, 0,0.04,"TahomaB","right"
      ];
    } forEach (units player select {_x == effectiveCommander vehicle _x});
  };
}];

 

Add a initServer.sqf for:

{_x allowCrewInImmobile [TRUE,FALSE]; _x setUnloadInCombat [TRUE,FALSE]} count vehicles;

addMissionEventHandler ["EntityCreated", {
   params ["_entity"];
   call {
       if (_entity iskindOf "CAManBase" && {count allUnits > 400}) exitWith {
        private _veh = vehicle _entity;
        deleteVehicleCrew _veh; deleteVehicle _veh;       
       };
       if (_entity iskindOf "landVehicle") exitWith {
        _entity allowCrewInImmobile [TRUE,FALSE];
        _entity setUnloadInCombat [TRUE,FALSE];
    };
  };
 }];

 

Share this post


Link to post
Share on other sites
3 hours ago, pierremgi said:

your link is not easy to play. You should release something on Steam. The zip contains many files, 2 pbos... difficult to understand what to do with.

What I understand:

- The only mandatory mod is IFA III. I recommend IFA3 AIO on Steam as reference.

- You mention a crew tank mod... repairing tank... very old... so may be problematic for your AI behavior. And double work with your initPlayerLocal.sqf !!

   I felt from my chair, opening the initPlayerLocal.sqf and finding my old code for repairing tanks!!! 😜 (btw, MGI_ is my tag). You can use my scripts, not a problem.

- as said, your pbo is an amount of heteroclite scripts more or less outdated, as  onplayerKilled.sqs  . Nobody should work anymore with sqs

 

 

So, to answer your last post, avoid extra non-mandatory mods, especially for AIs behavior, and replace you initPlayerLocal.sqf by:

 

Add a initServer.sqf for:

 

Only IFA3 (lite or second wave,same config names)  and IFA3 liberation mod need to this mission,any other thing no.
There is a readme file in the ZIP which I describe everything in great detail,step to step to play.
-There is 1 mission file which is pbo
-There is 1 ragnarok base file which is pbo
-And the 2 folders are configs:
- in case someone doesn't have a good asr configuration for all ww2 units
- and if someone doesn't know good for tpw cas, the other folder is the configuration of TPWCAS (i think the tpwCAS mod is the basic requirement, of which  is the very first is the simplest and best version, I watched the spearhead videos, I haven't played with it yet, although I ran a few meters in it, but according to youtube, the AI is extra root)

All AI mods in my recomendation list is works good with together in any ALIVE mission,in this ragnarok i not know exactly but i think works,only the "auto lower weapon" mod not works because of Ragnarok.(only at the upper level at the unused main commander level.......someone should sort out such little things in order for it to work,  unblock the block that prevents this "auto lower weapon" in the fps view and the rts view, but it's complicated, you need the people who made it

 

My reccomendations in AI MODs:
-ASR   possible works
-P.I.R   if i good remember i saw in work
-TPW CAS   i think works  (tested with debugger with editor placed groups but within the  ragnarok game,i not know works or not with spawned units....?but i saw works)

 

About the init and other files:

not i write the ragnarok44,i only changed it

I will never touch the init and other base files again, I slowly understood it from zero and put everything important in it so that it works (example I asked you about the script of numbering of the soldiers, etc...and put into the files)

I predefined the config of TOWING mod with all ww2 german soviet unit,i will never deleting,if anyone using the towing mod ,the config is live.

And these old codes will work with all versions(old and newest)

Share this post


Link to post
Share on other sites

What would be of great help is a script for the soldiers in the randomly placed spawned trenches that keeps them in place, but they can move out and then go to back, now they are fixed there :D

Share this post


Link to post
Share on other sites

yes, there are many modified file inside the mission file that I didn't delete, I didn't consider them important, it would be good if someone knows which ones were touched and can see the steps of the modifications

 

in the unitconfig file have one bad picture link for the 4 versions of SDKFZ 234 ,all 4 picture is present in the ragnarok base file,all 4 thumbnail picture was well matched before to the 4 vehicle, then I used an old file again and now only 3 images are used for the 4 vehicles, one of them is repeated, and I haven't checked it yet......

 

I wanted to write your name out for the auto rearm/ repair service script, but the topic was closed, I didn't know the name, all I knew was that it was MGI in the name

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

×