Jump to content
Sign in to follow this  
kdk11

Help with AI wave attacks

Recommended Posts

Hello I have been using this to set up a wave of AI to attack my F.O.B http://forums.bistudio.com/showthread.php?160718-How-can-I-make-NPC-wave-spawning

I receive the hint about the wave incoming and then that the wave has deployed yet I don't see any AI? Also I would like it so they spawn in more then that one Marker_1 area.

You may be thinking why I didn't just post in the thread on that link... Well I checked to see when he was last online and it was OCT 2013 so I guessed he doesn't come on here much anymore.

Share this post


Link to post
Share on other sites

Did you enable the display of script errors ? No script error showing ? Check that first.

If there's no error and your soldiers didnt spawn, a few possibilities :

- A condition to allow the spawn was not met in the script

- Everything works but the number of units to be spawned is set to 0 for some reason

- They do spawn, but somewhere else on the map

Share this post


Link to post
Share on other sites
Did you enable the display of script errors ? No script error showing ? Check that first.

what do you mean by that mate?

Share this post


Link to post
Share on other sites

cutText ["You have 30 seconds before the first wave!", "PLAIN"];
sleep 15;
cutText ["You have 15 seconds before the first wave!", "PLAIN"];
sleep 15;
cutText ["Wave 1 has begun!", "PLAIN"];

private ["_group1","_group2","_attackPos"];

DEAD_VAR_GROUP1 = 0;
DEAD_VAR_GROUP2 = 0;

_group1 = [getMarkerPos "spawn1", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;
_group2 = [getMarkerPos "spawn2", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;
_attackPos = getPos movetoPosition;

_SpawnWave = 
{
   {
       _x setSkill ["general",1];
       _x setSkill ["aimingAccuracy",0.1];
       _x setSkill ["aimingShake",1];
       _x setSkill ["aimingSpeed",0.1];
       _x setSkill ["endurance",0.3];
       _x setSkill ["spotDistance",0.2];
       _x setSkill ["spotTime",0.7];
       _x setSkill ["courage",1];
       _x setSkill ["reloadspeed",0.5];
       _x setSkill ["commanding",1];
       _x doMove _attackPos;

   } forEach (units _group1 + units _group2);
};


{_x addEventHandler ["killed", 
{
_grp = group (_this select 0);
	if ({ alive _x } count units _grp < 1) then
	{
	hint "All units dead";
	DEAD_VAR_GROUP1 = 1;
	};
}];
} forEach units _group1;

{_x addEventHandler ["killed", 
{
_grp = group (_this select 0);
	if ({ alive _x } count units _grp < 1) then
	{
	hint "All units dead";
	DEAD_VAR_GROUP2 = 1;
	};
}];
} forEach units _group2;

[] call _SpawnWave;
waituntil {(DEAD_VAR_GROUP1 == 1 && DEAD_VAR_GROUP2 == 1)};
cutText ["Wave 1 Completed", "PLAIN"];

Change the DO move position to your move position

Share this post


Link to post
Share on other sites
cutText ["You have 30 seconds before the first wave!", "PLAIN"];
sleep 15;
cutText ["You have 15 seconds before the first wave!", "PLAIN"];
sleep 15;
cutText ["Wave 1 has begun!", "PLAIN"];

private ["_group1","_group2","_attackPos"];

DEAD_VAR_GROUP1 = 0;
DEAD_VAR_GROUP2 = 0;

_group1 = [getMarkerPos "spawn1", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;
_group2 = [getMarkerPos "spawn2", EAST, (configFile >> "CfgGroups" >> "EAST" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup;
_attackPos = getPos movetoPosition;

_SpawnWave = 
{
   {
       _x setSkill ["general",1];
       _x setSkill ["aimingAccuracy",0.1];
       _x setSkill ["aimingShake",1];
       _x setSkill ["aimingSpeed",0.1];
       _x setSkill ["endurance",0.3];
       _x setSkill ["spotDistance",0.2];
       _x setSkill ["spotTime",0.7];
       _x setSkill ["courage",1];
       _x setSkill ["reloadspeed",0.5];
       _x setSkill ["commanding",1];
       _x doMove _attackPos;

   } forEach (units _group1 + units _group2);
};


{_x addEventHandler ["killed", 
{
_grp = group (_this select 0);
	if ({ alive _x } count units _grp < 1) then
	{
	hint "All units dead";
	DEAD_VAR_GROUP1 = 1;
	};
}];
} forEach units _group1;

{_x addEventHandler ["killed", 
{
_grp = group (_this select 0);
	if ({ alive _x } count units _grp < 1) then
	{
	hint "All units dead";
	DEAD_VAR_GROUP2 = 1;
	};
}];
} forEach units _group2;

[] call _SpawnWave;
waituntil {(DEAD_VAR_GROUP1 == 1 && DEAD_VAR_GROUP2 == 1)};
cutText ["Wave 1 Completed", "PLAIN"];

Change the DO move position to your move position

Could you be a bit more elaborate please?

Share this post


Link to post
Share on other sites

To change the attack position do change this

_attackPos = getPos movetoPosition; //Change movetoPosition

I used a file document in my survival mission I hid it in a stair well the would move in to it until engaged then they go into terminator aimbot killers

Share this post


Link to post
Share on other sites
what do you mean by that mate?

You need to have "-showScriptErrors" in your arma executable launch options. Check google if unsure. This will display script errors ingame.

Also check "C:\Users\USERNAME\AppData\Local\Arma 3" for the latest .rpt file, it contains a log of the errors and other stuff.

Share this post


Link to post
Share on other sites
You need to have "-showScriptErrors" in your arma executable launch options. Check google if unsure. This will display script errors ingame.

Also check "C:\Users\USERNAME\AppData\Local\Arma 3" for the latest .rpt file, it contains a log of the errors and other stuff.

Shit thanks that could come in handy <3

Share this post


Link to post
Share on other sites
You need to have "-showScriptErrors" in your arma executable launch options. Check google if unsure. This will display script errors ingame.

Also check "C:\Users\USERNAME\AppData\Local\Arma 3" for the latest .rpt file, it contains a log of the errors and other stuff.

Ah ok I know about the .rpt files, Just didn't know you could add that to the launch options.

To change the attack position do change this

PHP Code:

_attackPos = getPos movetoPosition; //Change movetoPosition

Sorry mate I still don't understand what you mean? lol I am really noob with code etc

Share this post


Link to post
Share on other sites

haha sorry should have mentioned that movetoPosition is the name of the object you want them to move to :D

Share this post


Link to post
Share on other sites

In the editor you can use the debug console to bring up the splendid camera. When you goto map screen in the camera it will show all units on the map with their color icons.

I noticed it only shows them when the time is paused so if you use the -nopause command line you may only see them for a split second.

It is still a good way of checking.

Also you can save camera locations using ctrl+# where #is a number from 1 to 0 on the normal keyboard not the numpad.

Call up the saved location by pressing the relevant # key.

This may help put the camera at the expected spawn location. I would also check [0, 0, 0] as that could be the spawn if a marker is not known.

Hope that helps some.

Edited by KevsnoTrev

Share this post


Link to post
Share on other sites

Ok thanks mate. is it possible to change what type of units spawn etc? Maybe there is a better tutorial out there to do this as the one I followed doesn't really help me that much.

Share this post


Link to post
Share on other sites

PM me a link to your mission and I can take a look.

I will guide you through the fix so it will hopefully help you later

Share this post


Link to post
Share on other sites

ok, I think I see where it all went wrong.

1. You are using markers and didn't have any of the names inside " "

2. in the init of createunit you have to use double "" "" as it inside a string field.

3. position command is for objects, you need to use getmarkerpos for markers

tested and it now functions as expected with no errors.

replace your spawner.sqf with this one. Link

Share this post


Link to post
Share on other sites

Yeah that got that working mate thanks! Although only one group spawned at one location and none at the rest and once I killed those AI there was no more waves after that. Any Ideas on that?

Share this post


Link to post
Share on other sites

the way the script is set up it uses the markers for patrolling waypoints.

do you want a persistent attack from AI until

  1. a time has passed
  2. all AI are dead
  3. a number of kills has been achieved
  4. all dependent on number of human players in mission
  5. all of the above?

Share this post


Link to post
Share on other sites

1 mate, Ideally I would like it to last around 45-60 minutes to make it feel like a really hard battle that exhausts the players from constant attacks. I have edited the spawner.sqf to how I thought it would look to get multiple enemies spawning with there own way points.

EnemyWave = 1;
hint "1 Minute Until Next Wave";
sleep 60;
UnitType = "O_soldier_f";  NumberOfUnits = 3;

for [{_x=0}, {_x < NumberOfUnits}, {_x=_x+1}] do   {
red = creategroup east;
UnitType createUnit [getmarkerpos "Marker_1", red, "newUnit = this; _wp = red addWaypoint [getmarkerpos ""Marker_7"", 0]; UnitType createUnit [getmarkerpos "Marker_2", red, "newUnit = this; _wp = red addWaypoint [getmarkerpos ""Marker_8"", 0]; UnitType createUnit [getmarkerpos "Marker_3", red, "newUnit = this; _wp = red addWaypoint [getmarkerpos ""Marker_9"", 0]; UnitType createUnit [getmarkerpos "Marker_4", red, "newUnit = this; _wp = red addWaypoint [getmarkerpos ""Marker_10"", 0]; UnitType createUnit [getmarkerpos "Marker_5", red, "newUnit = this; _wp = red addWaypoint [getmarkerpos ""Marker_11"", 0]; ", 1, "colonel"];   
};
UnitType = nil;  NumberOfUnits = nil; 
EnemyWave = 0;
hint "Insurgents are inbound!";

Like so, only now no AI spawn again :S

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  

×