Jump to content
Sign in to follow this  
Blitzen88

Best way to apply AI skill settings for all units?

Recommended Posts

Greetings,

 

Whenever I play Arma I rely heavily on AI spawn scripts for my missions.  Generally speaking I like to apply the same skill settings for all of the units in a mission but issues arise when AI units are spawned after the mission starts.  My current solution is to use an eventhandler to run an AI skill script whenever a unit is spawned.  However, I recently found a script which applies AI skill settings by looping/re-running every 30 seconds or so. 

 

Would one method be more efficient (performance wise) than the other?

Share this post


Link to post
Share on other sites

@Blitzen88,

Quote

Best way to apply AI skill settings for all units?

Probably best not to listen to me when it comes to the best way to do anything.

 

Quote

Whenever I play Arma I rely heavily on AI spawn scripts for my missions. 

Me too.

 

Quote

Would one method be more efficient (performance wise) than the other?

It sounds like your EH is more efficient but could depend on scenario specific criteria. Post both the scripts so we can see. Tell us how many units we're talking about.

Share this post


Link to post
Share on other sites
16 minutes ago, wogz187 said:

It sounds like your EH is more efficient but could depend on scenario specific criteria. Post both the scripts so we can see. Tell us how many units we're talking about.

The EH script is a simple SetAIskill # for each all units type of script. The loop script would be This script.

 

I would be using about four eight man squads per side plus three to four vehicles.  The EH script would execute around 32 times at mission start and then only when the groups respawn. 

Share this post


Link to post
Share on other sites

I think you asked a great question and the answer is open to some debate. Beerkan's script is pretty tight and only runs a quick check every thirty seconds. That makes it less precise though. You have units potentially running around for 30 seconds without their skills set. Whether that matters or not in your scenario, I don't know.

The EH is always sniffing for its event, while Beerkan's script only sniffs each 30 seconds. Your EH fires only when a unit is spawned. Beerkan's script only fires each thirty seconds if a unit is spawned.

I like your EH in theory but there's nothing wrong with Beerkan's script. Perhaps play-testing and actual measurement of performance will answer the question.

Continue to use the EH if it works, that's my suggestion. The best solution, as you originally said, is probably neither of the above.

Does this help?

We could also try to ask a community member with more knowledge on this specific subject, @das attorney

Share this post


Link to post
Share on other sites
37 minutes ago, wogz187 said:

Beerkan's script is pretty tight and only runs a quick check every thirty seconds. That makes it less precise though. You have units potentially running around for 30 seconds without their skills set. Whether that matters or not in your scenario, I don't know.

The 30 second delay doesnt bother me that much. Im still torn as to which method would be more effective. Ultimately it might not matter since I seem to get good performance with what Im using. 

 

This question also applies to another issue I have: If I want to re-equip all Csat units with AK 12s would it be better to do that via an event handler or a looping script?

Share this post


Link to post
Share on other sites

I meant to respond to this yesterday, but got busy.

 

Typically I would recommend use of an eventhandler. However, an even better approach may be just finding the function/script that spawns units and add the wanted code there.

 

 

One counter argument of using an eventhandler, or even a call function, for each AI spawned is the potential for a massive hit on noticeable FPS for players/server. (E.g. If a script spawns in 24 AI, it will run the code 24 times in rapid succession) Now, running a simple setskill command 24 times in a row may not be terrible - but if you begin adding more commands, this becomes a different story. Especially if these commands need to be broadcasted to each client, such as a change in a units equipment.

 

For this specific case, I would argue for some combination of an eventhandler/loop.  I would "queue" up AI for these changes by listing them into an array and having each one execute the heavy code with a small wait in-between, allowing the server/clients room to breath for other scripts. This method still allows commands to be set on AI in rapid succession, without crippling the server, even under large amounts of AI.

 

 

There is room to argue that there is not a "right" answer here. Every solution has a consequence. 

  • Like 1

Share this post


Link to post
Share on other sites

@genesis92x,
 

Quote

There is room to argue that there is not a "right" answer here. Every solution has a consequence. 

You said it. It's a common issue in this forum and I'm totally guilty of it, too. We post a topic looking for the BEST way to do something only to realize there are a dozen ways to accomplish that thing all with consequences to weigh. My tendency has been to reduce and simplify. Do the most with the least and don't be afraid to make compromise. Some of the coolest things I made were because of a design compromise.

 And I think @grumpyoldman would agree with me when I say that almost every question has already been answered if your "research kung-fu" is strong.

Share this post


Link to post
Share on other sites
On 7/8/2019 at 12:12 PM, Blitzen88 said:

Would one method be more efficient (performance wise) than the other?

why not benchmark the scripts using the performance button in the console. its the speedometer looking icon.

 

Quote

 I recently found a script which applies AI skill settings by loops ing/re-running every 30 seconds or so. 

 Just set the skill and get/setloadout when creating the unit. No need to loop set skill.

 

 

Quote

I like to apply the same skill settings for all of the units in a mission but issues arise when AI units are spawned after the mission starts.

 

Waituntil {sleep 5; count (allunits) >= 8};
{_x setskill 0.5;}foreach allunits select {side _x == east /* != playerside !=player */}; 

 

or just setskill when each unit is created.

allunits select {side _x != player} apply {_x addEventHandler ["---", { params ["---", "---"]; _unit setskill 0.5;}];};

 

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
Sign in to follow this  

×