Jump to content
Sign in to follow this  
solentis

I wonder how to create an ambush

Recommended Posts

Hi,

I'm trying to create a mission, and I wonder how to set an ambush. The ennemies units are already placed in the editor, I'd like to make them invisible and inactive until a predefined unit walk on a trigger. Then, they must appear and follow her preset waypoint and behaviour. If somebody could help me...

Share this post


Link to post
Share on other sites

I guess you could put

ambushgroup1 = group this; { hideObject _x; _x enableSimulation FALSE; } forEach units ambushgroup1;

in the init fields of the ambush group leaders, and then

// use if there's only one group:
{ _x enableSimulation TRUE; _x hideObject FALSE; } forEach units ambushgroup1;

// if there's more than one:
{ _x enableSimulation TRUE; _x hideObject FALSE; } forEach units ambushgroup1 + units ambushgroup2 + units ambushgroup3;

in the trigger, switching the group names if necessary. Not sure if it's the smartest way, but I suppose spawning the group and creating the waypoints by script isn't nearly as easy.

Share this post


Link to post
Share on other sites

There is another way to do it aswell. It is more hazzle though if you have to do it on many units. But if its just a few then it works good.

Put the following inside the unit ini

Use this to hide your unit:

this hideobject true;

Use this to make your unit stand still:

this disableai "move";

Use this to make no one fire at your unit:

this setcaptive true;

When you want your units to move, you simple put something like this inside a trigger:

soldier1 hideobject false; soldier1 enableai "move"; soldier1 setcaptive false;

Share this post


Link to post
Share on other sites

A suggestion, all those fancy ways are good if you plan to make a CoD ambush, on which the units appear suddenly, very close and engage.

If you want to make something more realistic, just spend time placing those units in good spots, hiding them behind rocks, bushes etc.. and changing their combatMode when it suits you....

Share this post


Link to post
Share on other sites

Thanks for all your answer. In fact, I had to do a "CoD way" because some a couple of sniper will be watching the scene for 1.5 km far. I'll just spawn it in little out of sigh spot.

I have another question : I read somewhere that hide function will not work on local player if the mission is running on a dedicated server. is that true?

Share this post


Link to post
Share on other sites
I have another question : I read somewhere that hide function will not work on local player if the mission is running on a dedicated server. is that true?

It should work, as long as you execute it from the unit init field (which are executed by all players), and use a trigger that doesn't depend on variables that players have differing values for (like player). My understanding is that the issues with hideObject locality are mostly related to separate scripts that aren't run for everyone.

(I won't vouch for it though, since you never know with this series.)

Share this post


Link to post
Share on other sites

Tested, unit disappeared but they still move and shoot, but invisible. Any solution?

Btw,

soldier1 hideobject false; soldier1 enableai "move"; soldier1 setcaptive false;

, is that possible to make it work also for soldier2 and soldier3 at the same time?

Share this post


Link to post
Share on other sites

You can use

{ _x hideObject FALSE; _x enableAI "MOVE"; _x setCaptive FALSE; } forEach units group this;

in the init field of one of the group members to apply it to the whole group, or forEach [soldier1, soldier2, soldier3] to list exact units. _x is a special variable referring to the object it's going through at the moment with forEach.

I'd rather go with disabling the simulation, though. While enableAI disables even the unit's capability to turn (or did in Arma 2 at least), it'll still fire if someone gets in front of it.

I also realised that you DO have to run hideObject separately for everyone instead of it working right through the init line. So I'd go with handling most of it through init.sqf. If you want to go with what I described in post 2, leave this in the init field of the group leaders:

ambushgroup1 = group this;

(changing the number with each if there is more than one group) This assigns the variable ambushgroup1 to refer to the group of this unit.

Then in your init.sqf (if you don't have an init.sqf, create one in your mission directory):

// set a variable to determine if still to hide the units for join-in-progress players
// on the server and then broadcast with publicVariable, again to account for join-in-progress players
if isServer then { ambush_activated = FALSE; publicVariable "ambush_activated" };

// use if there's only one group:
if (!ambush_activated) then
{
{ _x enableSimulation FALSE; _x hideObject TRUE; } forEach units ambushgroup1;
};

// if there's more than one:
if (!ambush_activated) then
{
{ _x enableSimulation FALSE; _x hideObject TRUE; } forEach units ambushgroup1 + units ambushgroup2 + units ambushgroup3;
};

Then, in the trigger where you want to activate the ambush:

// use if there's only one group:
{ _x enableSimulation TRUE; _x hideObject FALSE; } forEach units ambushgroup1; ambush_activated = TRUE; publicVariable "ambush_activated";

// if there's more than one:
{ _x enableSimulation TRUE; _x hideObject FALSE; } forEach units ambushgroup1 + units ambushgroup2 + units ambushgroup3; ambush_activated = TRUE; publicVariable "ambush_activated";

JIP, as always, makes it a bit more complicated than it should be. If someone knows a simpler method, I'd be happy to know of it as well.

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  

×