Jump to content
Sign in to follow this  
bangabob

Trigger enemies with waypoints and respawn

Recommended Posts

Hi guys. You lot have being so useful so far with scripting.

I want to make a defence mission with waves of enemies BUT i dont want the waves to start until a trigger tells it too. For example BLUFOR present.

So heres my current problem.

I have tried the random spawn direction mod. http://www.kylania.com/ex/?p=31

This mod is nice but it doesn't automatically respawn the enemies when they have being killed.

I have also tried the UPS script. http://www.armaholic.com/page.php?id=6540

This mod works except i can't trigger the enemies. They just spawn at the beginning of the mission.

Ideally i would like a script like this (my normal spawn enemy script i use). The problem with this script is that i cant designate the waypoints and they dont respawn after they are killed

Trigger

Condition: Blufor present

On act: Exec 'spawnenemies.sqf'

spawnenemies.sqf

if (!isServer) exitWith {};

_spawnPos = markerPos (_this select 0);

_group1 = createGroup EAST;

_unit1 = _group1 createUnit ["TK_INS_Bonesetter_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;

_unit2 = _group1 createUnit ["TK_INS_Soldier_2_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;

_unit2 = _group1 createUnit ["TK_INS_Soldier_AT_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;

_unit3 = _group1 createUnit ["TK_INS_Soldier_AR_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;

[_group1, _spawnPos, 100, 7, "MOVE", "AWARE", "WHITE", "LIMITED", "WEDGE", [3,6,9]] call CBA_fnc_taskPatrol;

Any help would be appreciated

Share this post


Link to post
Share on other sites
This mod is nice but it doesn't automatically respawn the enemies when they have being killed.

Change the trigger so that it does. :) Instead of a radio trigger change it to check when the group has no alive units. You have all the information you need just need to understand how each piece works and then you can make it do what you'd like.

Share this post


Link to post
Share on other sites

Great. It would be very helpful if you could give me an example of what to put in the trigger. And how it links to your script

Share this post


Link to post
Share on other sites

Okay so inside my trigger which spawns a group of enemies i have

Activation: BLUFOR PRESENT

Condition: this && ({alive _x && side _x == east} count thisList) < 5

On act: nul = [2] execVM "selNewDir.sqf";

This seems to work but only when a blufor player leaves the trigger and enters it again. Which isn't optimal tbh

Share this post


Link to post
Share on other sites

Init.sqf:

patrolGroup = createGroup east;

Trigger to kick things off:

Condition whatever,

OnAct:

nul = ["spawnmarker", patrolGroup] execVM "spawnEnemies.sqf"; gameOn = true;

Trigger to respawn waves:

REPEATEDLY

Condition:

gameOn && {alive _x} count units patrolGroup == 0

onAct:

nul = ["spawnmarker", patrolGroup] execVM "spawnEnemies.sqf";

Then set the 2nd triggers TIMEOUT Min/Mid/Max to be however long you want to wait between waves.

Rewritten code for your script:

if (!isServer) exitWith {};
_spawnPos = markerPos _this select 0;

_group1 = patrolGroup;  // this is the name we set in init.sqf, we'll just keep reusing the same group.

_unit1 = _group1 createUnit ["TK_INS_Bonesetter_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;
_unit2 = _group1 createUnit ["TK_INS_Soldier_2_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;
_unit2 = _group1 createUnit ["TK_INS_Soldier_AT_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;
_unit3 = _group1 createUnit ["TK_INS_Soldier_AR_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"]; sleep 0.2;
[_group1, _spawnPos, 100, 7, "MOVE", "AWARE", "WHITE", "LIMITED", "WEDGE", "", [3,6,9]] call CBA_fnc_taskPatrol;

Have some method to turn the gameOn varible to false to stop the spawning.

Edited by kylania

Share this post


Link to post
Share on other sites

Thanks.

I haven't had a chance to try this yet but i can't see anything defining the 'patrolgroups' way-points.

So this script will allow me to have them respawn but they would just run in random directions.

Share this post


Link to post
Share on other sites

Well, no they'd patrol the marker you defined because you're using the CBA patrol function, in that case 7 MOVE waypoints within 100m of your marker. If you wanted to give them waypoints, feel free. :)

Share this post


Link to post
Share on other sites

I found a way of using Kylanias spawning script

Made game logic with loops=true in init

Trigger:

BLUFOR present/ Repeating

Condition: this and loops

On Act: nul = [2] execVM "selNewDir.sqf";loops = false;

On DeAct: loops = true

Countdown: min=10 mid=10 max=10

This means that every 10 seconds more enemies will spawn. You can change this time to fit the mission.

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  

×