Home   Help Search Login Register  

Author Topic: Spawn AI off of a trigger?  (Read 2345 times)

0 Members and 1 Guest are viewing this topic.

Offline Absolution

  • Members
  • *
Spawn AI off of a trigger?
« on: 21 Nov 2010, 05:03:32 »
The goal of my trigger is to spawn a group of AI and have them run towards a given point on the map. The trigger and spawn mechanic work fine... Problem is that the trigger activates for EVERY human player and the result is a small army of enemies. I only want it to fire off once for the first guy to hit the trigger and never do so again.

-On the map I have placed the BIS Functions mechanic.
-Created a trigger set to BLUFOR, once and the following "on Act":
     : [this] exec "scripts\ai\spawnai.sqs";

And here is the script itself:

Code: [Select]
if (!isServer) exitWith {};   
waituntil {!isnil "bis_fnc_init"};


//create a trigger
//On Act: [this] exec "scripts\ai\spawnai.sqs";

//create groups
_group1 = [getMarkerPos"spwn1", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;
_group2 = [getMarkerPos"spwn2", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;
_group3 = [getMarkerPos"spwn3", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;

//set patrol points
[_group1, getMarkerPos "wp1",75 ] call bis_fnc_taskPatrol;
[_group1, 1] setWaypointSpeed "NORMAL";

[_group2, getMarkerPos "wp2",75 ] call bis_fnc_taskPatrol;
[_group2, 1] setWaypointSpeed "NORMAL";

[_group3, getMarkerPos "wp3",75 ] call bis_fnc_taskPatrol;
[_group3, 1] setWaypointSpeed "NORMAL";


I understand the basic that I need to execute it against the server and not the player and I thought I was doing that with the first line of the script... obviously not. Any input?

Offline cptHook

  • Members
  • *
Re: Spawn AI off of a trigger?
« Reply #1 on: 24 Nov 2010, 02:04:29 »
Mabye you could delete the trigger on deactivation

Offline loki72

  • Former Staff
  • ****
    • Loki's Nightmare
Re: Spawn AI off of a trigger?
« Reply #2 on: 03 Dec 2010, 20:22:25 »
at the end of your script add:

Code: [Select]
deleteVehicle triggername;


though personally i'd do it as a function then it only runs one time whenever its called

run from the init.sqf or some other .sqf that is called so the function gets loaded into memory.

Code: [Select]

publicVariable "fnc_YOURNAME_SpawnGroup1";

fnc_YOURNAME_SpawnGroup1 = {

if (!isServer) exitWith {};  
waituntil {!isnil "bis_fnc_init"};


//create a trigger
//On Act: [this] exec "scripts\ai\spawnai.sqs";

//create groups
_group1 = [getMarkerPos"spwn1", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;
_group2 = [getMarkerPos"spwn2", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;
_group3 = [getMarkerPos"spwn3", east, ["RU_Soldier_SL","RU_Soldier_SL","RU_Soldier_SL"]] call BIS_fnc_spawnGroup;

//set patrol points
[_group1, getMarkerPos "wp1",75 ] call bis_fnc_taskPatrol;
[_group1, 1] setWaypointSpeed "NORMAL";

[_group2, getMarkerPos "wp2",75 ] call bis_fnc_taskPatrol;
[_group2, 1] setWaypointSpeed "NORMAL";

[_group3, getMarkerPos "wp3",75 ] call bis_fnc_taskPatrol;
[_group3, 1] setWaypointSpeed "NORMAL";

};



from the created trigger run:

call fnc_YOURNAME_SpawnGroup1;
« Last Edit: 03 Dec 2010, 20:32:16 by loki72 »