Jump to content
Aurora152

Limit the amount of enemies during waves

Recommended Posts

Hello All,

 

Currently, I have a mission where unlimited waves are spawned with this :

0 = [] spawn { 
 
 while {true} do {  
   
   _ambush10 = [getMarkerPos "ambush10", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;  
   _wpt1 = _ambush10 addWaypoint [position player, 25];  
   _wpt1 setWaypointBehaviour "COMBAT";  
   _wpt1 setWaypointSpeed "FULL";  
    
   _ambush11 = [getMarkerPos "ambush11", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;  
   _wpt2 = _ambush11 addWaypoint [position player, 25];  
   _wpt2 setWaypointBehaviour "COMBAT";  
   _wpt2 setWaypointSpeed "FULL";  
    
   sleep 10; 
    
   _ambush12 = [getMarkerPos "ambush12", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;  
   _wpt3 = _ambush12 addWaypoint [position player, 25];  
   _wpt3 setWaypointBehaviour "COMBAT";  
   _wpt3 setWaypointSpeed "FULL";  
     
   _ambush13 = [getMarkerPos "ambush13", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;  
   _wpt4 = _ambush13 addWaypoint [position player, 25];  
   _wpt4 setWaypointBehaviour "COMBAT";  
   _wpt4 setWaypointSpeed "FULL";  
    
   sleep 10; 
     
   _ambush14 = [getMarkerPos "ambush14", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;  
   _wpt5 = _ambush14 addWaypoint [position player, 25];  
   _wpt5 setWaypointBehaviour "COMBAT";  
   _wpt5 setWaypointSpeed "FULL";  
     
   _ambush15 = [getMarkerPos "ambush15", east, (cconfigfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;  
   _wpt6 = _ambush15 addWaypoint [position player, 25];  
   _wpt6 setWaypointBehaviour "COMBAT";  
   _wpt6 setWaypointSpeed "FULL";  
     
   _ambush16 = [getMarkerPos "ambush16", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;  
   _wpt7 = _ambush16 addWaypoint [position player, 25];  
   _wpt7 setWaypointBehaviour "COMBAT";  
   _wpt7 setWaypointSpeed "FULL";  
     
   sleep 300;  
    
 }; 
};

But I'm wanting to limit the total amount of enemies spawned on the map to reduce lag. 

Hoping to have the loop stop when 60-70 are present from the wave spawner, then restart when the loop when there are less than the designated amount.

 

Hope this makes sense.

 

TIA,

Aurora

Share this post


Link to post
Share on other sites

You could wrap that code into a condition:

while {true} do 
{ 
if(count (units east) < 50 ) then // Max 50 east units allowed
{
 // Code here
};
};

 

there the 50 would be the limit

 

  • Like 1

Share this post


Link to post
Share on other sites

@gc8

 

As easy as that... I have started to overthink and overcomplicate things... I need to take a break 🙂

 

Thanks!

Share this post


Link to post
Share on other sites

If you need something more elaborated (complex conditions, randomized areas, customized groups (and even units loadout), counter for repeat, true chasing on player (not only a position); or chasing nearest enemy, air to air combat...)

 

  • Confused 1

Share this post


Link to post
Share on other sites
On 4/5/2021 at 5:57 PM, gc8 said:

You could wrap that code into a condition:


while {true} do 
{ 
if(count (units east) < 50 ) then // Max 50 east units allowed
{
 // Code here
};
};

 

there the 50 would be the limit

 

 

I have just tested this. It stopped spawning groups when it got to 44 east units. Then, when I deleted about 20 units, it didn't start the loop again.

This is what I have:

0 = [] spawn { 
 
	 while {true} do { 
		
		{ 
			if(count (units east) < 50 ) then
				
				{
	  
				  _ambush10 = [getMarkerPos "ambush10", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt1 = _ambush10 addWaypoint [position player, 25];    
				  _wpt1 setWaypointBehaviour "COMBAT";    
				  _wpt1 setWaypointSpeed "FULL";    
					 
				  _ambush11 = [getMarkerPos "ambush11", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt2 = _ambush11 addWaypoint [position player, 25];    
				  _wpt2 setWaypointBehaviour "COMBAT";    
				  _wpt2 setWaypointSpeed "FULL";    
					 
				  sleep 10;   
					 
				  _ambush12 = [getMarkerPos "ambush12", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt3 = _ambush12 addWaypoint [position player, 25];    
				  _wpt3 setWaypointBehaviour "COMBAT";    
				  _wpt3 setWaypointSpeed "FULL";    
					  
				  _ambush13 = [getMarkerPos "ambush13", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt4 = _ambush13 addWaypoint [position player, 25];    
				  _wpt4 setWaypointBehaviour "COMBAT";    
				  _wpt4 setWaypointSpeed "FULL";    
					 
				  sleep 10;   
					  
				  _ambush14 = [getMarkerPos "ambush14", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt5 = _ambush14 addWaypoint [position player, 25];    
				  _wpt5 setWaypointBehaviour "COMBAT";    
				  _wpt5 setWaypointSpeed "FULL";    
					  
				  _ambush15 = [getMarkerPos "ambush15", east, (cconfigfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Infantry" >> "UK3CB_TKM_O_AR_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt6 = _ambush15 addWaypoint [position player, 25];    
				  _wpt6 setWaypointBehaviour "COMBAT";    
				  _wpt6 setWaypointSpeed "FULL";    
					  
				  _ambush16 = [getMarkerPos "ambush16", east, (configfile >> "CfgGroups" >> "East" >> "UK3CB_TKM_O" >> "Mechanized" >> "UK3CB_TKM_O_BMP1_Mechanized_MG_Squad")] call BIS_fnc_spawnGroup;    
				  _wpt7 = _ambush16 addWaypoint [position player, 25];    
				  _wpt7 setWaypointBehaviour "COMBAT";    
				  _wpt7 setWaypointSpeed "FULL";    
					  
				  sleep 300; 
				  
			}; 
		};
	};	 
}; 

Unfortunately, It has to be done via script as I am running it on a server and they don't like to add new mods... 😞

 

TIA, 

Aurora

Share this post


Link to post
Share on other sites

@Aurora152  One problem I see there is extra { right before the "if(count (units east) < 50 ) then". Also extra closing }

 

The script maybe also pausing in the 300 sec sleep

 

Edited by gc8
the sleep
  • Like 1

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

×