Jump to content
Sign in to follow this  
heinzmcdurgen

Continue to spawn enemies until conditions are met

Recommended Posts

I'm trying to figure out how to spawn enemies in a loop till a condition is met. For example, I want an OPFOR fire team to spawn at the start of the mission. There is an if condition that checks if the objective has been completed. If it has, it ceases spawning, if not, it spawns another fire team. I feel like this should be pretty simple, but I'm not sure how to pull it off. My scripting knowledge is pretty limited.

Thanks in advance!

Share this post


Link to post
Share on other sites

Try to use BIS_fnc_spawnGroup:

switch (taskState _task) do {
case "Created": {[...] call BIS_fnc_spawnGroup};
case "Succeeded": {[...] call BIS_fnc_spawnGroup};
case "Failed": {[...] call BIS_fnc_spawnGroup};
};

Share this post


Link to post
Share on other sites

You could also use a trigger to keep spawning the bad guys. Once the condition is met, use another trigger to delete the old trigger.

I can make an example for you a bit later if you would like.

Share this post


Link to post
Share on other sites
You could also use a trigger to keep spawning the bad guys. Once the condition is met, use another trigger to delete the old trigger.

I can make an example for you a bit later if you would like.

Yeah, that's more of what I was thinking. Thanks!

Share this post


Link to post
Share on other sites

I like the idea of this, i always wanted to mimic this like evolution blue did it where you have to take the city, but the enemy in the city will keep calling reinforcements until

you destroy the radio tower in the city.

Problem is to get to that tower with a satchel is challenging, and timing has to be there, I'd like to figure out how to have a radio tower in a mission where the enemy

will call reinforcements after so many of them are killed, and until you destroy that tower they will keep calling.

How would you use this with a placed tower?

Share this post


Link to post
Share on other sites

I'll post an example for arma 3 I have. no reason why it wouldn't work in A2: (with the exception of using Arma 3 Classnames)

GroupOne_Z = Creategroup EAST; 
sleep 0.5;
"O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];
sleep 2;
"O_Soldier_AR_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];
sleep 2; 
"O_Soldier_GL_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];
sleep 2; 
"O_Soldier_LAT_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];
sleep 2; 
"O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Major"];
sleep 2;      
[GroupOne_Z, getMarkerPos "alpha1", 600 ] call bis_fnc_taskAttack;
[GroupOne_Z, 1] setWaypointSpeed "FULL";
[GroupOne_Z, 1] setWaypointCombatMode "RED";
[GroupOne_Z, 1] setWaypointBehaviour "AWARE";
sleep 0.2;

if exectuted on a trigger, this will spawn a group at a marker called spawn 4, and send the group (called GroupOne_Y) after a marker called alpha1.

You can make this spawn as many baddies as you want by adding unit classnames to the code. Or you can make multiple groups by changing the name GroupOne_Z to something else like GroupOne_A and adding a new spawn marker.

The next thing you need to do is make the group respawn once a certain number of the group is dead. for that:

put another trigger down and set it to "repeat"

then put in the condition feild:

({alive _x} count units GroupOne_Y) < 1;

and in the activation field put the above spawn code.

this will keep checking for the number of units left in GroupOne_Y. If it finds that the number is less than 1, it will activate the trigger. You can tweak that number from 1 to whatever you want. NOTE: In order to stop the respawns once the tower is down, you will need to name this trigger. lets call it trigger1.

Finally, you would need to delete the trigger when the radio tower was destroyed.

So put down the tower and call it RadioTower (or whatever name)

Then make another trigger and put in the condition field:

!alive RadioTower;

and then on the activation field put:

deletevehicle trigger1;

This will delete the trigger causing the units to respawn once the tower is down.

Hope I helped!

---------- Post added at 02:03 ---------- Previous post was at 01:54 ----------

Yeah, that's more of what I was thinking. Thanks!

So Heinz for you,

everything is the same, except for it may change on how to call the delete command.

The above example stops the reinforcments after the tower is down.

other ways to call it would be to use the

triggeractivated command. eg)

You have a small trigger set to activate when a blufor team is present inside it. That will be the trigger that deletes the respawn trigger. So, like before, you need to name the respawn trigger. (trigger1).

Then, you need to name the trigger that activates when the blufor team is inside. (trigger2)

Then the 3rd trigger, which is the delete trigger will have this:

Condition Field:

triggeractivated trigger2;

Activation field

deletevehicle trigger1;

So you see, it is a series of trigger firings that make it all work.

to help you if you are new to triggers, make each trigger give you a hint as it fires (you can remove the hint later). This way, if something isn't working, you know which trigger it is thats failed.

On Activation:

hint "this is the delete trigger. It fired";

Share this post


Link to post
Share on other sites

Dam totally forgot about this thread, sorry Baddazs for not responding, I will try what you had put together, and thanks for the help!

Share this post


Link to post
Share on other sites

Cant get this to work, heres what i did:

1. placed a trigger and in the activation box is:

GroupOne_Z = Creategroup EAST;   sleep 0.5;  "O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;  "O_Soldier_AR_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_GL_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_LAT_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Major"];  sleep 2;        [GroupOne_Z, getMarkerPos "alpha1", 600 ] call bis_fnc_taskAttack;  [GroupOne_Z, 1] setWaypointSpeed "FULL";  [GroupOne_Z, 1] setWaypointCombatMode "RED";  [GroupOne_Z, 1] setWaypointBehaviour "AWARE";  sleep 0.2;

2. placed another trigger

name is trigger1

condition box

({alive _x} count units GroupOne_Y) < 1;

activation box

GroupOne_Z = Creategroup EAST;   sleep 0.5;  "O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;  "O_Soldier_AR_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_GL_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_LAT_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Private"];  sleep 2;   "O_Soldier_F" createUnit [getMarkerPos "spawn4",GroupOne_Y,"this allowFleeing 0",random 1, "Major"];  sleep 2;        [GroupOne_Z, getMarkerPos "alpha1", 600 ] call bis_fnc_taskAttack;  [GroupOne_Z, 1] setWaypointSpeed "FULL";  [GroupOne_Z, 1] setWaypointCombatMode "RED";  [GroupOne_Z, 1] setWaypointBehaviour "AWARE";  sleep 0.2;

3. placed another trigger

on condition

!alive bunker;

on activation

deletevehicle trigger1;

4. placed a marker named it spawn4 for the AI to spawn at

5. placed a marker named it alpha1 so they AI move there

========

Problem no AI spawn, this is for Arma3 btw im trying it in.

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  

×