Jump to content
Sign in to follow this  
Drapoel

Triggers spawn AI soldiers

Recommended Posts

Hello!

I have tried to search the forum of my problem but maybe it's me who are not good to search or maybe it isn't any post about my problem.

My Problem:

I have made a mission, where I wan't the enemy AI to spawn in if our troops cross a trigger.

But i don't want the AI to be present if the trigger is NOT crossed!

So if somone can help me with the problem it's great:)

I'm not so good on making missions, but this is the last think i have to do before it's completed

Edited by Drapoel

Share this post


Link to post
Share on other sites

A simple spawn script ran from the On Activation field of the trigger would do it.

There's an example over here where the spawned group takes up defences. BIS_fnc_SpawnGroup is the function used to create the group, so you need a Function Module on the map in the editor. BIS_fnc_taskDefend makes a group defend an area.

Share this post


Link to post
Share on other sites

Okai, thanks. So if I use that script can get the AI to spawn when a trigger is activated?

But when i wan't them to spawn on the trigger activated, do i have to use a script or can I just write somthing in the Activation field of the unit or the trigger?

Edited by Drapoel

Share this post


Link to post
Share on other sites

The "On activation" field is just a place to enter script commands, so it's not really any different from using an external script. It's just a lot less readable. Also external scripts run with execVM can use sleep and waitUntil which can be useful, but mostly the improvement in readability is well worth the slight hassle of using an external file.

Share this post


Link to post
Share on other sites

Iv read a lot of stuff on here about spawning ai, but its all a bit much to process, was wondering if someone who knows how to spawn ai could give some clear step by step instructions on how do a simple trigger activated spawn.

If i had a USMC Rifleman, controlled by player, and 2 triggers, one to spawn troops on activation and the other as spawn location, how exactly would i set it up so that when player moves into the first triggerzone a USMC Infantry Group Spawn at the second trigger and move to a waypoint.

Any help with this would be great as its the last big problem im having with the arma2 editor

Share this post


Link to post
Share on other sites

I know how to spawn them but i am not sure on how to give them waypoints once they spawn. Any help would be great!

Share this post


Link to post
Share on other sites

See createWaypoint and friends.

Tends to look something like this:

 _wp = opfor_town_group addWaypoint [getMarkerPos "opfor_exitpos", 0];
 _wp setWaypointCombatMode "YELLOW";
 _wp setWaypointBehaviour "AWARE";
 _wp setWaypointSpeed "FULL";
 _wp setWaypointFormation "STAG COLUMN";

Note that _wp is a local variable, if you're cramming this all into an editor dialog you'll need to use a global variable name (e.g. wp).

Share this post


Link to post
Share on other sites

Ok how would you spawn the group that follow these waypoints?

Share this post


Link to post
Share on other sites

Use createUnit to spawn an individual soldier or vehicle, or use the BIS_fnc_spawnGroup helper in the Functions module to spawn a group of soldiers.

For creating a group it's probably best used to the BIS_fnc_spawnGroup. Use the Modules mode in the Editor to place a Functions module, and then do something like this in your trigger:

badguys = [getMarkerPos "markername", East, 6]

which will spawn 6 soldiers on side East at the location of the marker named "markername", and return the group as "badguys". You can then assign them waypoints.

The spawnGroups function has a bunch of other parameters so you can tailor its behaviour. Get used to using BIS_fnc_help and familiarise yourself with the functions BIS have already written - can save you lot of time and reinventing the wheel. Add a radio trigger that runs

nul = [] call BIS_fnc_help

and when you activate it in-game you get a nice interactive function browser.

Share this post


Link to post
Share on other sites

Yup. If you leave the icon type as None then it won't be visible to the players (and will only be visible in the editor when you're in Marker mode, although it'll still be selectable in other modes).

I think you can use a trigger by naming it and using "getPos nameofyourtrigger" - the game pretty much treats triggers as vehicles, AFAIK. But I haven't tested that and I tend to use markers for locations of things. Triggers are for triggering things!

Share this post


Link to post
Share on other sites

What would I do if I wanted to have a B-52 spawn do a bombing run from using a radio command and going to a map click and than disappearing?

Share this post


Link to post
Share on other sites
Add a radio trigger ... and when you activate it in-game you get a nice interactive function browser.

Why do you need the function browser and a radio trigger if when you enter the trigger area, it spawns the enemy troops at the location of the marker?

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  

×