Jump to content
Sign in to follow this  
Garthra

Making Headless AI Client Randomly Spawn Waves of Enemies (maybe with RUIS script?)

Recommended Posts

Goal: My goal is to execute a random wave generating script on the headless client so as to allow good server performance during large defensive co-op battles.

Issue:

I recently began using the headless client in my missions thanks to a GREAT guide by Monsoon, but am now trying to take it to the next level and incorporate scripts so that they run on the HC. For instance, a script similar to RUIS which would spawn a random number of enemies in waves. I have RUIS working on my personal computer (thanks to Igneous01!), and I have the HC working (thanks to Monsoon!), but I cannot get them working together. Anyone have any ideas how to edit RUIS (or any other script to randomly generate attacking waves) to work under the HC? I am the most novice of scripters, and would appreciate a response geared towards someone with my limited knowledge. My hunch is that changing which computer it runs on to the HC is not difficult and that someone who knows how to script more than me will see the solution quickly.

What I have Tried:

In Monsoon’s guide, it discusses several basic modifications to a script to incorporate it into Headless Client, which I have tried. (Thanks to Monsoon.)

First, I have edited the init file to include a section like this, (where "your_script.sqf" is the script you want HC to run.):

	//execute DAC on HC if present, otherwise on Server
if(HCPresent) then{
dac_on = false;
if(!hasInterface && !isServer) then{
execVM "hc_dac.sqf";
execVM "hc_units.sqf";
execVM "your_script.sqf";
};
} else{
dac_on = true;
if(isServer) then{
sleep 5;
execVM "hc_dac.sqf";
execVM "hc_units.sqf";
execVM "your_script.sqf";
};
};

Then you have to edit the script itself to look for the HC:

Where before it said:

if (isServer || isDedicated) then{

now it says:

if (isServer || isDedicated || (name player==HCName)) then{

For reference:

1.) The RUIS script which generates enemies randomly.

This is their webpage for more information: http://forums.bistudio.com/showthread.php?117220-RUIS-Random-Unit-Invasion-Script

This is the script itself and example mission. All credit to Igneous01 for the script and example mission.

2.) Monsoon’s GREAT guide on the Headless Client, including how to edit the DAC script to run on the HC. (See page 13, Turning the DAC on.)

Any help would be appreciated, as I have done all I can with my limited knowledge. Although I am focusing on adapting RUIS script, if there is another method to achieve my core goal, I am open to it.

Thank you!

Garthra

Edited by Garthra
clarification of code

Share this post


Link to post
Share on other sites

Very interesting.. when I first read that Monsoon guide I created a defensive mission on Proving Grounds which uses DAC spawning on the HC to provide the enemy bantha-fodder :)

It's not 'random' in that the AI spawn from one of 4 or 5 DAC camps positioned away from the defenders, but with DAC you can randomize some of the stuff.. like group sizes, compositions, even default weapons selections. Setting the # of respawns high means that enemy groups just keep on coming....

Share this post


Link to post
Share on other sites

Interesting idea! And glad to see someone else is using Monsoon's guide!

While I am still looking for anyone with more scripting knowledge than I have to help modify RUIS or another wave spawning script...

I nevertheless appreciate your response as a potential alternative solution.

Please help me understand your mission/solution further:

1.) How did you ensure that the enemies generated by DAC would leave their spawning area (presumably far from the defensive base with players) and head towards the players at the camp?

1a. Even if the enemy patrol area is not far from the target base, close but not right on top of it, how do you ensure they go to the potion of their patrol area that is within striking distance of the base, and not another part?

2.) How did you get the level of resistance to increase over time on the defenders? (My goals is not "these 5 patrols repeatedly attack the players and respawn," but is instead "Wave 1 is roughly 15 guys (+/-5), wave 2 is roughly 25, wave 3 is one to three tanks, etc." I am unclear as to how DAC can achieve that ramping up.

3.) If you set the enemy infantry's zone of patrol in or around the player defensive position, (that is, so small and close to it that there is no chance of enemy infantry in that zone NOT enountering players) how did you prevent them from spawning right on the base that is being defended at the start of the mission? (For instance player A starts the mission sitting behind his sandbags, looking out, and within seconds of mission start, with DAC kicks in, suddenly the AI spawns right behind him, inside the defensive line, or right in front of him, appearing out of thin air?)

4.) Please provide any other information you think is necesary to help me duplicate your methods, including if possible specific descriptions of steps to be taken, and, in my fantasy world, examples. I will be trying to replicate the sorts of effects you used in your mission, and would therefore appreciate forewarning of major problems or limitations you encountered.

Thank you for your reply!

Share this post


Link to post
Share on other sites

I'm not sure DAC is the solution to your specific problem but I'll answer your questions and perhaps it will be a bit clearer. DAC does not have a 'wave spawn' option in of itself, it uses zones (defined by a trigger with x, y coords) sort of like UPS uses markers to define it's patrol zones.

Have you used DAC before? If not it might be a bit confusing to explain....

1 - You can create a DAC spawn zone and link it with a waypoint zone, meaning units will be assigned waypoints outside of the spawn zone area, in your case the camp with players. You can also create and move DAC zones after init, so you could move it to the camp area and it would delete the waypoints from the old zone and assign new ones from the 'camp' zone.

1a - I'm not sure I understand what you are asking here.

2 - This is the issue with using DAC for what you want to accomplish.. DAC has no 'wave spawn' function that I am aware of.... although you can configure how quickly you want groups to respawn and how many seconds between each group spawning.

If I think about it some more there is a way to do the wave spawns.. deleting DAC zones once all the units in the wave are killed then creating a new zone on the fly with more enemy groups... rinse, repeat... much more complicated though and I have not had enough coffee yet :)

3 - DAC has an option to prevent units/waypoints from being created within a specific area inside the DAC zone. This is done using a game logic called DAC_Save_Pos and the area size is configurable. So you can have one big DAC zone creating units with your camp smack in the middle and no enemy units or waypoints will be created in that 'safe' area.

Other bonuses of using DAC:

- integrated enemy artillery / mortars

- VERY configurable (size and composition of enemy groups, weapons selections, AI group behaviour, respawn camps, etc)

It might be best for you to download DAC and read through the (large) manual it comes with... it will give you a better idea of what DAC can do.

Share this post


Link to post
Share on other sites

I have used DAC before (for patrols, respawns, arty, and customizable outposts,) but I have not used the DAC_Save_Pos function before, and will have to look into that. I will re-read the manual and see what else I can get out of DAC.

The idea you mention of deleting the old zone when all units dead and creating a new one "on the fly" with more enemies is an interesting one. Given that I have basic working knowledge of DAC, could you describe how I might accomplish that?

Thank you for your help!

Share this post


Link to post
Share on other sites
I have used DAC before (for patrols, respawns, arty, and customizable outposts,) but I have not used the DAC_Save_Pos function before, and will have to look into that. I will re-read the manual and see what else I can get out of DAC.

The idea you mention of deleting the old zone when all units dead and creating a new one "on the fly" with more enemies is an interesting one. Given that I have basic working knowledge of DAC, could you describe how I might accomplish that?

Thank you for your help!

Yeah every time I read the DAC manual I find something new :p

I can't remember right now if DAC has a built in function to check if all zone units are dead or not.. I don't think it does but you could accomplish that with another trigger to detect for enemy presence. DAC does have the ability to create and delete zones on the fly.. so you would set it so that your enemy detect trigger on activation would delete the DAC zone then create a new zone with new params (ie: more units, different units, better units, vehicles... whatever)

So as an example:

Create a single zone covering the area and your base with no respawn camps. Use the DAC_Save_Pos game logic and put it in your base (with a value of say 200m.. found in DAC_Config_Creator.sqf).. this will ensure no enemies spawn beside you at start. Your base will be 'surrounded' by enemies.

Once the first enemy group detects a player it will relay this to the other groups and then DAC will start to send in support and re-reinforcements (which can also be tweaked in DAC_Config_Behaviour.sqf). Once all enemy groups have been destroyed your detection trigger will fire and delete the zone (and any leftover units).. set a delay time of sorts, then create a new zone (wave 2).. using another trigger or a script. Rinse, repeat.

Share this post


Link to post
Share on other sites

Sorry for delay in response. Real life flared up. I will be testing this stuff out in the next few days. Thank you for the ideas Savage!

Share this post


Link to post
Share on other sites

Ok, after basic tests, this does seem to be a solution!!! :) I can get a group of enemies to spawn in one zone, and move to another zone (the area to be attacked). It gets tricky after that, but this is the first step. I can also activate and deactivate zones to increase or decrease the incoming enemies.

Thanks!

Three issues though.

1.) The DAC enemies seem to pause a lot in cities. They move very very slowly to their obejctive through urban terrain, sometimes seeming to even get lost getting through the city on the way to their objective. They do ok in natural terrain (hills/rocks/trees). I think this is something in the behavior config. How can I improve this to make them move quickly through urban terrain or more straight to the point?

2.) How do I ensure that the waves go off smoothly from wave to wave? I cannot use the "NO OPFOR Present" trigger because it would fail if there were any respawns of enemies or if one guy was hiding prone behind a rock. And if I have multiple groups coming from multiple sides, just because there is one enemy left in one group does not mean I want to hold up the entire next wave until even that last guy is dead... But I cannot name the groups/waves and make a trigger saying "when group _1 is dead, then..." because they are DAC generated and so have no name. So how do I setup a good trigger system which will allow ramping up of difficulty without getting messed up by the possibility of respawning enemies or a lingering last man standing/hiding in a corner?

3.) Do you know if the "create a zone" function works with Headless client? I know activate and deactivate does, but do you know about "create a zone"? I am worried that anything created mid game randomly might conflict with it, or at best just run on the main server (not the headless client).

Thank you again! Slowly but surely I am making progress, thanks in large part to you!

Garthra

Edited by Garthra
Added third issue.

Share this post


Link to post
Share on other sites

Sorry I forgot about this thread :)

1 - I would adjust the check building behaviour which I believe is found in DAC_Config_Behaviour.sqf - you'll have to check the manual for more details - basically it determines how often units will check a building if they are nearby

2 - that is a tough one I might not be good enough to help you there :) DAC might have a function to check if a group is dead.. or you could use a trigger with something that counts the units and say once it is less than 3 guys spawn the new wave... perhaps someone else would have a better suggestion?

3 - mmmm... I don't think I've tried that yet (create zone on HC after mission starts) but I don't see why it would not work. You would have to adjust it so that it spawns on the HC not the server

Share this post


Link to post
Share on other sites
Sorry I forgot about this thread :)

No worries!

Thanks for the response! :) Go ArmA2 Community, always willing to help out!

Share this post


Link to post
Share on other sites

Offtopic: So do you guys use the HC setup at TG? If so how do you find it performs? Worth the extra work?

Ontopic: Did you get any further with this spawn wave stuff or did you smash something in frustration? :p

Share this post


Link to post
Share on other sites
Offtopic: So do you guys use the HC setup at TG? If so how do you find it performs? Worth the extra work?

Yes some of our newer missions use it. It greatly improves performance when a large numbers of NPCs are around. Small missions, not worth the effort.

Ontopic: Did you get any further with this spawn wave stuff or did you smash something in frustration? :p

No luck getting the UPSMON to work. But I did find a work around based on the stuff we discussed. Ended up just fine!

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  

×