Jump to content
nightovizard

AI spawning after enabling trigger/waypoint

Recommended Posts

Hi,

I was trying to do a mission where enemy units spawn after the player reaches a waypoint/trigger, I used https://community.bistudio.com/wiki/createUnit but is not working. Any known solution to it? I've been searching the forums but I haven't found an exact way to do this. The most similar:

http://www.armaholic.com/page.php?id=6197

But I would like units to spawn just once, when player reaches a waypoint/trigger. (So they don't appear at the beginning of the mission)

Thank you very much.

---------- Post added at 22:40 ---------- Previous post was at 22:26 ----------

To specify more:

- Place in the editor a NATO soldier as player, and add a "move" waypoint.

- Place in the editor another non playable unit, with waypoints too

- After the NATO soldier (player) reaches the "move" waypoint, the CSAT unit you placed in the editor, spawns, and follows the waypoints.

I even tried with the unitname hideobject true; and unitname hideobject false;, but that only makes them invisible, they are still there.

Edited by nightovizard

Share this post


Link to post
Share on other sites

Create an .sqf file in your mission folder called spawn&move

Paste this into it and save it:

GroupOne_X = [getMarkerPos "spawn1", EAST, ["O_Soldier_TL_F", "O_Soldier_F", "O_Soldier_AR_F", "O_Soldier_AT_F", "O_Medic_F", "O_Soldier_GL_F"]] call BIS_fnc_spawnGroup; 
{_x allowFleeing 0} forEach units GroupOne_X;

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"move1",0];
_waypoint0 setwaypointtype"Move"; 

_waypoint1 = GroupOne_X addwaypoint[getmarkerpos"move2",0];
_waypoint1 setwaypointtype"Move";

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"spawn1",0];
_waypoint0 setwaypointtype"Move"; 

_waypoint0 setwaypointtype "CYCLE";

[GroupOne_X, 1] setWaypointSpeed "FULL";
[GroupOne_X, 1] setWaypointCombatMode "RED";
[GroupOne_X, 1] setWaypointBehaviour "AWARE";

Place invisible markers in the editor called spawn1 , move1 and move2

Place a trigger in the editor activated by blufor with this in the on act:

_null = [] execVM "spawn&move.sqf";

And if you want it to be a human player that triggers it then put this in the condition:

{isPlayer _x} count thisList > 0;

Leave it blank if you want an AI unit to trigger it.

So what this particular script does is spawn 6 Opfor soldiers on the spawn1 marker and they will move quickly to the move1 marker then to the move2 marker then back to the spawn1 marker and just keep cycling through those waypoints in a 'ready for action' type manner.

Edited by -AMI- MoFo

Share this post


Link to post
Share on other sites
Create an .sqf file in your mission folder called spawn&move

Paste this into it and save it:

GroupOne_X = [getMarkerPos "spawn1", EAST, ["O_Soldier_TL_F", "O_Soldier_F", "O_Soldier_AR_F", "O_Soldier_AT_F", "O_Medic_F", "O_Soldier_GL_F"]] call BIS_fnc_spawnGroup; 
{_x allowFleeing 0} forEach units GroupOne_X;

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"move1",0];
_waypoint0 setwaypointtype"Move"; 

_waypoint1 = GroupOne_X addwaypoint[getmarkerpos"move2",0];
_waypoint1 setwaypointtype"Move";

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"spawn1",0];
_waypoint0 setwaypointtype"Move"; 

_waypoint0 setwaypointtype "CYCLE";

[GroupOne_X, 1] setWaypointSpeed "FULL";
[GroupOne_X, 1] setWaypointCombatMode "RED";
[GroupOne_X, 1] setWaypointBehaviour "AWARE";

Place invisible markers in the editor called spawn1 , move1 and move2

Place a trigger in the editor activated by blufor with this in the on act:

_null = [] execVM "spawn&move.sqf";

And if you want it to be a human player that triggers it then put this in the condition:

{isPlayer _x} count thisList > 0;

Leave it blank if you want an AI unit to trigger it.

So what this particular script does is spawn 6 Opfor soldiers on the spawn1 marker and they will move quickly to the move1 marker then to the move2 marker then back to the spawn1 marker and just keep cycling through those waypoints in a 'ready for action' type manner.

Thank you very much! But things are a bit more complicated.

Basically I want to spawn flying aircrafts, and soldiers inside the helicopters. How do I make that the aircraft spawned is flying? How do I make that the spawned soldiers spawn inside that aircraft?

I'm also trying to use the attach to command to make that the aircrafts are lifting vehicles (Vehicles that also spawn along the soldiers and aircrafts).

The best example would be this:

http://feedback.arma3.com/view.php?id=14894 (download the example mission)

But not used as a respawn, but rather spawn once time after activating a trigger, these units wouldn't spawn at the beginning of the mission.

And for optimisaion and gameplay prurposes I would like to make that some of them disappear when reaching a position using the deleteVehicle command.

But for all that each unit created needs to have a name, and by using your script they don't get any name.

https://community.bistudio.com/wiki/BIS_fnc_spawnGroup

EDITED:

What if I used the condition of presence for that?

http://forums.bistudio.com/showthread.php?154275-Condition-of-presence-based-on-script

If I set the units presence to false, and I use a script on a trigger that changes that units presence to true, would it work?

I tried with if (triggeractivated trg1) then {TRUE}; but is not working.

EDITED2:

GroupOne_X = [getMarkerPos "spawn1", EAST, ["O_Plane_CAS_02_F"]] call BIS_fnc_spawnGroup;

{_x allowFleeing 0} forEach units GroupOne_X;

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"move1",0];

_waypoint0 setwaypointtype"Move";

_waypoint1 = GroupOne_X addwaypoint[getmarkerpos"move2",0];

_waypoint1 setwaypointtype"Move";

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"spawn1",0];

_waypoint0 setwaypointtype"Move";

_waypoint0 setwaypointtype "CYCLE";

[GroupOne_X, 1] setWaypointSpeed "FULL";

[GroupOne_X, 1] setWaypointCombatMode "RED";

[GroupOne_X, 1] setWaypointBehaviour "AWARE";

GroupOne_X = [getMarkerPos "spawn2", EAST, ["O_Plane_CAS_02_F"]] call BIS_fnc_spawnGroup;

{_x allowFleeing 0} forEach units GroupOne_X;

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"move1",0];

_waypoint0 setwaypointtype"Move";

_waypoint1 = GroupOne_X addwaypoint[getmarkerpos"move2",0];

_waypoint1 setwaypointtype"Move";

_waypoint0 = GroupOne_X addwaypoint[getmarkerpos"spawn1",0];

_waypoint0 setwaypointtype"Move";

_waypoint0 setwaypointtype "CYCLE";

[GroupOne_X, 1] setWaypointSpeed "FULL";

[GroupOne_X, 1] setWaypointCombatMode "RED";

[GroupOne_X, 1] setWaypointBehaviour "AWARE";

Is there any way to give the spawned units a name? ("newUnit = this" in the init field. ?) and how do I do to spawn them facing a direction? (South 180) What if I want a jet (Spawned that way) to drop a bomb on a marker that I placed in the editor? this only works with artillery:

Missile2 commandArtilleryFire [ markerpos "MortarMarker", getArtilleryAmmo [Missile2] select 0, 12 ];

Edited by nightovizard

Share this post


Link to post
Share on other sites

Hey if you want a very easy way to do this using editor placed units download this http://www.armaholic.com/page.php?id=7074

I have been using this script since arma2. You also can set AI behaviour just a waypoint in the editor or place other scripts like UPSMON in the editor waypoint init. The editor placed units will not show up on the map until the trigger is reached. You also can have it repeat or just once. AVIBIRD.

Share this post


Link to post
Share on other sites
On 18/01/2016 at 0:37 AM, venilsonribeiro said:

how do I get  spawn GroupOne_X with a custom loadout?

 

*Old post but this might set it useful for someone.

 

Creater file "grpCustonAI.sqf"

// null = this execVM "grpCustonAI.sqf"  // Within trigger activation.
// "AZUL" is name group
// "mgru" is name markers spawn group
// wp1, wp2, wp3 = name of markers to waypoints


azul = [getMarkerPos "mgru", EAST, 8] call BIS_fnc_spawnGroup;


{
    // the VR export replacing "this" with "_x"
    removeAllWeapons _x;
    removeAllItems _x;
    removeAllAssignedItems _x;
    removeUniform _x;
    removeVest _x;
    removeBackpack _x;
    removeHeadgear _x;
    removeGoggles _x;
	_x removeItem "NVGoggles";
	_x unassignItem "NVGoggles";


    _x forceAddUniform "U_I_CombatUniform";
    for "_i" from 1 to 4 do {_x addItemToUniform "30Rnd_556x45_Stanag";};
    _x addItemToUniform "16Rnd_9x21_Mag";
    _x addVest "V_PlateCarrierIA2_dgtl";
    for "_i" from 1 to 3 do {_x addItemToVest "30Rnd_556x45_Stanag";};
    for "_i" from 1 to 3 do {_x addItemToVest "HandGrenade";};
    for "_i" from 1 to 3 do {_x addItemToVest "16Rnd_9x21_Mag";};
    _x addBackpack "B_TacticalPack_oli";
    for "_i" from 1 to 1 do {_x addItemToBackpack "SatchelCharge_Remote_Mag";};
    for "_i" from 1 to 1 do {_x addItemToBackpack "DemoCharge_Remote_Mag";};
    _x addHeadgear "H_Cap_headphones";
    _x addGoggles "G_Bandanna_oli";


    _x addWeapon "arifle_Mk20C_F";
    _x addPrimaryWeaponItem "muzzle_snds_M";
    _x addPrimaryWeaponItem "acc_flashlight";
    _x enableGunLights "forceOn";
    _x addPrimaryWeaponItem "optic_MRCO";
    _x addWeapon "hgun_P07_F";
    _x enableGunLights "forceOn";


    _x linkItem "ItemMap";
    _x linkItem "ItemCompass";
    _x linkItem "ItemWatch";
    _x linkItem "ItemRadio";
    _x linkItem "ItemGPS";
} foreach units azul;


_waypoint0 = azul addwaypoint[getmarkerpos"wp1",0];
_waypoint0 setwaypointtype"Move"; 
_waypoint0 setWaypointFormation "LINE";

_waypoint1 = azul addwaypoint[getmarkerpos"wp2",0];
_waypoint1 setwaypointtype"Move";
_waypoint1 setWaypointFormation "LINE";

_waypoint2 = azul addwaypoint[getmarkerpos"wp3",0];
_waypoint2 setwaypointtype"move"; 
_waypoint2 setWaypointFormation "LINE";
_waypoint2 setwaypointtype "move";

_waypoint3 = azul addwaypoint[getmarkerpos"wp1",0];
_waypoint3 setwaypointtype"cycle"; 
_waypoint3 setWaypointFormation "LINE";


[azul, 1] setWaypointCombatMode "RED";
[azul, 1] setWaypointBehaviour "safe";

 

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

×