Jump to content
Sign in to follow this  
Bahger

Two things I'd like to script...but do not have the know-how

Recommended Posts

I'm making a singleplayer mission using the High Command Module. It's promising but there are a few complications that I'm having difficulty resolving. These are:

i. How do I get a helo group to RTB (i.e. leave the mission) via a trigger when that group has no pre-plotted route waypoints but is commanded only inside the mission and with the High Command interface? I'd like both units to bug out when a certain number of mission goals have been accomplished. Or I could do it via a timer.

ii. How can I get enemy units to spawn in for a counter-attack via a trigger, also when the same mission goals have been accomplished and the player and the units under his (direct, not HC) command have reached a certain zone on the map? I spent a lot of time researching this one but most of the discussions apply specifically to MP missions.

Basically these two things are connected; if I can't get the helos to leave and then spawn the units for the counter-attack, the helos will find them and kill them before the player has a chance to engage the enemy units, so my notion is to organise the following sequence of events:

- Player accomplishes two out of three mission goals

- Player and his squad arrive at a briefed location.

- Helos bug out

- Enemy counter-attack spawns in, with warning message to player

I'm not experienced in scripting, i.e either in the init-file syntax or inserting scripts into the mission root files as Notebook files. I have a lot of experience making tactically realistic missions in many PC combat and flight sims but I just don't have a coder's mind and get perplexed by stuff that many of you seem to have mastered very easily, so I'd be really grateful if you could frame the answers to either of these questions as though addressing an intelligent novice. I have made several ArmA missions over the years but my ambitions always seem to outpace my ability to master the scripting aspects of the Editor. Many thanks.

Share this post


Link to post
Share on other sites

The first issue can easily be resolved by a trigger and waypoint. Something like the following setup should do well enough:

Trigger size: 0x0 (irrelevant)

Activated by: BLUFOR, not present (second condition irrelevant)

Condition: <apply condition> (like !alive opforcommander && !alive indforcommander if your objectives are to kill atleast two commanders. Tieing this to units is the simplest way considering it only needs a simple !alive statement)

On activation: heloextract = [heloGroupName, heloGroupLeader] execVM "heloextract.sqf";

heloextract.sqf:

_helogroup = _this select 0;
_heloleader = _this select 1;

_helogroup addWaypoint [getmarkerpos "heloextract",0];

waitUntil {_heloleader distance (getmarkerpos "heloextract") < 10};

{
{deleteVehicle _x} forEach crew _x + [_x];} foreach _heloGroup;

This is quite complex for such a simple task to be honest, but at the moment I'm not entirely sure if the group would follow a pre-set waypoint if in HC mode. The script's also untested, so you'll have to fix any errors (-showscripterrors) you encounter along the way, however I expect this to work.

As for the second thing, it's a bit more complicated. Spawning the units in via script seems unnecessarily complicated. If it's just helicopters though, a possible solution could be to spawn them at [0,0,0] and disable simulation, aswell as setting them somewhere in the air (like 150m). A possible script (can be executed via init.sqf actually) could look like this:

helocounters.sqf:

waitUntil {scriptDone heloextract};

_helos = [/*Add helo unit names here, ie opforhelo1, opforhelo2 etc*/];
_spawnmarker = getmarkerpos "opforspawn";

{
_x setposATL [(_spawnmarker select 0) + (random 2), (_spawnmarker select 1) + (random 2), 150];
_x enableSimulation true;
} forEach _helos;

Again, rather complicated. You'll need to put this in the init of every OPFOR helo:

this setpos [0,0,0]; this enablesimulation false;

Again, this should work exactly as intended, but it's untested. It saves a lot of work in comparison to manually spawning in vehicles with createUnit / createVehicle array, but there's probably another, simpler way.

Share this post


Link to post
Share on other sites

This is great, thank you so much for going to the trouble.

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  

×