Jump to content
Sign in to follow this  
Easterlily

How can I make NPC wave spawning?

Recommended Posts

Hello there.

I have an idea of a map and im currently trying to create one, even though im not that experienced with either Arma 2 or Arma 3 editors.

However, this is the deal.

I want to make, for example a firegroup, spawn at a certain area of the map, and then they will spawn on a trigger that issues them to move to a certain waypoint. And I want a new firegroup to spawn at the exact same location and keep doing this in waves of, for example one minute.

When I read this myself I guess it might be hard to understand what I'm talking about but I just figured out a example. Most of you guys have probably played League of Legends or any DoTA-based game. I want to make the Firegroup spawn and react exacly as the minions do in those games.

Share this post


Link to post
Share on other sites

i was working on something similar recently Ok It Going to seem Like Its A Little Complicated because you probably need to write lots of scripts but this is what you have to do

in your init.sqf put this (create one if you don't already have one)

execVM "WaveSpawner.sqf";

then create WaveSpawner.sqf Put

EnemyWave = 0;

Then Create your trigger and on activation put

handle = [] execVM "SpawnChecker.sqf";

Create the SpawnChecker.sqf and put

		if (Enemywave==1) then 
		{
			nil;
		} else {
execVM "Spawner.sqf";
		};

then create spawner.sqf put

EnemyWave = 1;
player groupchat "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 [position Marker_1, red, "newUnit = this; _wp = red addWaypoint [position Marker_2, 0];", 1, "colonel"];   };  UnitType = nil;  NumberOfUnits = nil; 
EnemyWave = 0;
hint "Wave Has Been Deployed";
execVM "SpawnChecker.sqf";

If you dont want an infinite number of waves delete in the last line above

execVM "SpawnChecker.sqf";

To Add More Waypoints Just add

_wp = red addWaypoint [position Marker_3, 0];

next to

_wp = red addWaypoint [position Marker_2, 0];

so

EnemyWave = 1;
player groupchat "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 [position Marker_1, red, "newUnit = this; _wp = red addWaypoint [position Marker_2, 0]; _wp = red addWaypoint [position Marker_3, 0]; _wp = red addWaypoint [position Marker_4, 0];", 1, "colonel"];   };  UnitType = nil;  NumberOfUnits = nil; 
EnemyWave = 0;
hint "Wave Has Been Deployed";
execVM "SpawnChecker.sqf";

etc

Then Create 2 objects Name Marker_1 and Marker_2

Marker_1 Is the Starting Point/ SpawnPoint and Marker_2 Is the Waypoint

Tested out And Working

Edited by ra1n0fpa1n
Fixed All Errors

Share this post


Link to post
Share on other sites
...UPDATE: I Have Tested it out everything else works execpt for spawner.sqf i will update again if it is working

Alright thanks a lot for helping me out. However, I have one question. You tell me create these .sqf's, but where do I put them?

Share this post


Link to post
Share on other sites

you put the sqf's in your mission folder in documents/arma3 other profiles/your name/missions/yourmission you can make sqf's by right clicking and click on create new text document paste what i wrote in there and click save as, then you must select select file type and click on any at the end of your document you just put .sqf

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

In the mission folder. When you save a mission in the Editor it creates a folder here:

%userprofile%\My Documents\Arma 3\missions

(or %userprofile%\My Documents\Arma 3 Other Profiles\ArmaUsername\missions if you changed your arma profile name)

Just save the SQF file next to the mission.sqm file in the missioname.Stratis folder under there.

74JnM9K.jpg

Share this post


Link to post
Share on other sites

I Fixed Everything Above it should work now

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

sorry buddy if you have been getting errors i forgot that the only way you can execute a script on a trigger is if you type this

handle = [] execVM "SpawnChecker.sqf";

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

Nevermind. Didnt see your last post*

* Also, I saw that you spelled wrong in the first code

---------- Post added at 22:18 ---------- Previous post was at 22:08 ----------

Alright. Everything should be set as you told me but it doesnt seem to work. My only thought is that I'm doing the Marker_1 and Marker_2 wrong.

What I do is, I go to the marker creator. Create two of the invisible markers, pretty close to each other just for testing. I name one of them Marker_1 and the other one Marker_2. Is that how I should do, or is that not it?

Share this post


Link to post
Share on other sites

its best to create 2 objects and name them Marker_1 and Marker_2

markers themselves don't seem to work as waypoints

Share this post


Link to post
Share on other sites

Hmm. Nope, I tried with both the helper arrows and the flag poles. Didnt work for me either.

Share this post


Link to post
Share on other sites

ok add this then in your trigger

handle = [] execVM "SpawnChecker.sqf";

tested it out and it and its good now, sorry for all the bugs

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

This actually does it, and it seems to work out well. Many thanks!

And dont worry about the bugs, im just happy that I got help so quickly.

Finally I have two questions.

There are those black consoleboxes that appears whenever I enter the trigger and when the unit spawns. Are those suppose to be there or is that a bug?

And, If I want the spawned group to move to a distant target by following the roads, how should I do that? (ex, from Camp Rogain to the Firing Range)

Share this post


Link to post
Share on other sites

Yea the black console goes away when User= _this select 0; is removed from the SpawnChecker.sqf forgot to remove that, as for waypoints you just need to add more or just another waypoint add this in spawner.sqf

_wp = red addWaypoint [position Marker_3, 0];

next to this

_wp = red addWaypoint [position Marker_2, 0];

so it should look like this and so on and etc

EnemyWave = 1;
player groupchat "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 [position Marker_1, red, "newUnit = this;  _wp = red addWaypoint [position Marker_2, 0];_wp = red addWaypoint [position Marker_3, 0];", 1, "colonel"];   };  UnitType = nil;  NumberOfUnits = nil; 
EnemyWave = 0;
hint "Wave Has Been Deployed";
execVM "SpawnChecker.sqf";

Edited by ra1n0fpa1n

Share this post


Link to post
Share on other sites

Yup, it works. Good job and thanks. This really helped me out alot!

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  

×