Jump to content
Lt.Hellfire

How to Spawn CSAT units via trigger detection BLUFOR

Recommended Posts

Hi everybody, Im making a mission with multiples objectives like "Go to a location and kill a General" or "Go to another location take confidential documents and destroy enemy radar". But i have encountered a problem that is the game only support 288 NPCs, and Im looking for a way to spawn enemy units like CSAT and others to defend that locations where the objectives is, when a player like BLUFOR entering a trigger. Like the Liberation mission but with tasks already determined. It's basically the mission starts and the players can see what tasks have to do but only when the players " BLUFOR" gets closest to the objective the AI spawn to defend that location. I think with this mode i can make a mission with more of 288 NPCs bcs they only spawn when players enter the trigger. Anyway theres a way do to this? Can someone help me with that? Thanks :)

Share this post


Link to post
Share on other sites

288 is the limit for groups, not NPCs.

But it's not recommended to edit all NPCs on map. So, yes, you can spawn AIs by trigger(s) blufor present, spawning enemies with bis_fnc_spawnGroup function or more elaborated tools. There are plenty of topics about spawning groups.

Share this post


Link to post
Share on other sites
1 hour ago, pierremgi said:

288 is the limit for groups, not NPCs.

But it's not recommended to edit all NPCs on map. So, yes, you can spawn AIs by trigger(s) blufor present, spawning enemies with bis_fnc_spawnGroup function or more elaborated tools. There are plenty of topics about spawning groups.

I put two markers on the map with different names and in different places, and a trigger for each one with activation by detection, but when I entering the first trigger the second instantly activates even though I am not on it, spawning the AI of the second at the wrong time, and after the spawn they start moving towards me when I want them to stand guard. I'm trying to get the second trigger to just activate and spawn the second squad when I enter the second trigger area, can you help me with that?

 

I created a sqf file InfSquad1 and inside it I put this

_InfSquad1 = [(getMarkerPos "InfSpawn1"), EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] Call BIS_fnc_spawnGroup;
_InfSquad1 = [(getMarkerPos "InfSpawn2"), EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] Call BIS_fnc_spawnGroup;

In the trigger i place this script On Act

null = player execVM "InfSquad1.sqf"

 

"InfSpawn1" is the name of the first mark to AI spawn in the trigger zone, "InfSpawn2" is the name for the second marker in the second trigger. I am looking to a way of spawn multiple squad units in a unique trigger zone and make another triggers but only activate when the player enters the right area.

Share this post


Link to post
Share on other sites

If you place triggers waiting for playerS (so in MP), you can choose anyPlayer present as condition.

Then the triggers must be server only.

If you are running the code on each marker, you'll get the enemies on markers in code(s), no matter the activated trigger. You are not activating the 2nd trigger, just spawning on a marker close to the second one. So, it's up to you for deciding the conditions and the positions of spawning. Just be clear.

Share this post


Link to post
Share on other sites
On 3/26/2021 at 9:00 PM, pierremgi said:

If you place triggers waiting for playerS (so in MP), you can choose anyPlayer present as condition.

Then the triggers must be server only.

If you are running the code on each marker, you'll get the enemies on markers in code(s), no matter the activated trigger. You are not activating the 2nd trigger, just spawning on a marker close to the second one. So, it's up to you for deciding the conditions and the positions of spawning. Just be clear.

Hi everyone, 

 

Can someone explain me how i can despawn untis when i'm not in the trigger anymore, can't get ik working oke 

{deletevehicle _x} forEach (units _???); 

there is the problem , i don't know how to name the groups that i spawned in.

 

Thnx!

Share this post


Link to post
Share on other sites
5 hours ago, gitanoiwan said:

Hi everyone, 

Can someone explain me how i can despawn untis when i'm not in the trigger anymore, can't get ik working oke 

{deletevehicle _x} forEach (units _???); 

there is the problem , i don't know how to name the groups that i spawned in.

 

In a trigger, condition, on activation and on deactivation are separate codes and you can't use local variables passing from one to the other.

Furthermore, if you have several triggers, you can't use global variables for your aim, they will refer to the last use, (from last trigger activated), instead of the currently deactivated trigger.

So, you need something else like set variable on each trigger.

For example:

on activation: 0 = thisTrigger execVM "infSquad1.sqf"

 

in infSquad1.sqf:

params [["_trig",objNull]];
_trig setVariable ["infSpawn1", [(getMarkerPos "InfSpawn1"), EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] Call BIS_fnc_spawnGroup  ];
_trig setVariable ["infSpawn2", [(getMarkerPos "InfSpawn2"), EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] Call BIS_fnc_spawnGroup ];

 

on deactivation:

{deleteVehicle _x} forEach units (thisTrigger getVariable ["infSpawn1",groupNull]);
deleteGroup (thisTrigger getVariable ["infSpawn1",groupNull]);
{deleteVehicle _x} forEach units (thisTrigger getVariable ["infSpawn2",groupNull]);
deleteGroup (thisTrigger getVariable ["infSpawn2",groupNull]);

 

Notes:

1 - you can use the same string "infSpawn1" for marker and set variable on trigger, but naming them differently is a good habit.

2 - if you spawn vehicles in your group, delete their crew first with deleteVehicleCrew

3 - your argument player in your code player execVM "infSquad1.sqf"   is totally useless. On the other hand, I passed the trigger inside of this sqf.

4 - it's useless writing an sqf for each spawning trigger. You just have to pass some parameters like:

[thisTrigger, ["infSpawn1","infSpawn2"], (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] execVM "infSquadSpawn.sqf";

I changed the name of the sqf for a general purpose and better comprehension.

 

So the infSquadSpawn.sqf is now:

params [["_trig",objNull],["_markers",[]],["_config",configNull]];
_trig setVariable ["infSpawn1", [getMarkerPos (_markers #0), EAST, _config] Call BIS_fnc_spawnGroup ];
_trig setVariable ["infSpawn2", [getMarkerPos (_markers #1), EAST, _config] Call BIS_fnc_spawnGroup ];

 

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

×