Script: Call in barrages of flares.

Kill your comrades. Wholesale
Post Reply
User avatar
wolfenswan
Posts: 1209
Joined: Wed May 25, 2011 4:59 pm

Script: Call in barrages of flares.

Post by wolfenswan »

A script i worked on for nightblind. It's nothing fancy but probably worth the share.

What it does is that it adds the ability to certain units to call in off-map artillery for illumination who then go off x times over a target area after which there's a brief wait for the next barrage. The script's fairly self-explanatory and comes in 4 files.

flareinit.sqf - put "nul = [this] execvm "scripts\flareinit.sqf";" in the first units init
Private ["_unit"];

HQ = [EAST,"base"]; //remember to change the side to WEST, EAST or GUER
illumination = artytarget1; //change that to the name of your first target
publicvariable "illumination";
_unit = _this select 0;

null = [_unit] execVM "scripts\flaresaction.sqf"; //adds the actual actions to that unit
flareaction.sqf - adds the actions to that unit. in my example it checks if the leading unit is alive and if not tells that to the players and permits another unit (DC) to order in the barrage. (I'm using a local trigger to check if CO is alive, if not "nul=[DC_unit] execVM "scripts\flaresaction.sqf";" happens] tweak accordingly.
Private ["_unit"];

_unit = _this select 0;

if (alive UnitTK_CO) then {
sleep 10;
HQ SideChat "Crossroads to CO. Artillery standing by. Aiming on Garmsar outskirts.";
};
if !(alive UnitTK_CO) && (alive UnitTK_DC) then {
sleep 30;
HQ SideChat "Crossroads to Deputy CO. We have lost contact to CO. Artillery command designated to you, aiming at the last target.";
};
if !(alive UnitTK_CO) && !(alive UnitTK_DC) then {
sleep 30;
HQ SideChat "Crossroads to all units. Looks like we lost both CO and DC. You are on your own now. Good luck.";
};

action1 = _unit addAction ["<t color='#dddd00'>"+"start barrage"+"</t>",
"scripts\flares.sqf",[illumination],1,false,true,"","driver _target == _this"];

action2 = _unit addAction ["<t color='#dddd00'>"+"cycle targets"+"</t>",
"scripts\flaretarget.sqf",[illumination],2,false,true,"","driver _target == _this"];
flares.sqf - the main part. it creates the flare over the target with a small offset.
Private ["_i", "_x", "_y", "_z" , "_unit","_action", "_flare"];

_unit = _this select 0;
_unit removeAction action1;
_unit removeAction action2;
_flare = "F_40mm_red"; //designate type of flare here

HQ SideChat "Barrage is commencing, standby";
sleep 5;

for "_i" from 1 to 5 do {
if (_i < 5) then {
HQ SideChat "Flare out, splash in 10.";
sleep 8;
_x = (getPos illumination select 0) + round(random 25) - round(random 25); //designate the random offset on the x axis
_y = (getPos illumination select 1) + round(random 20) - round(random 20); //designate the random offset on the y axis
_z = 150 + round(random 20); //designate the random offset on the z axis
_flare createVehicle [_x, _y, _z];
sleep 5;
HQ SideChat "Next flare in 30 seconds, standby";
sleep 30;
};
if (_i == 5) then {
HQ SideChat "Flare out, splash in 10.";
sleep 8;
_x = (getPos illumination select 0) + round(random 25) - round(random 25);
_y = (getPos illumination select 1) + round(random 20) - round(random 20);
_z = 150 + round(random 20);
_flare createVehicle [_x, _y, _z];
sleep 5;
HQ SideChat "Barrage has ended. Next barrage ready in one minute.";
sleep 60;
HQ SideChat "Next barrage is ready.";

action1 = _unit addAction ["<t color='#dddd00'>"+"start barrage"+"</t>",
"scripts\flares.sqf",[illumination],1,false,true,"","driver _target == _this"];

action2 = _unit addAction ["<t color='#dddd00'>"+"cycle targets"+"</t>",
"scripts\flaretarget.sqf",[illumination],2,false,true,"","driver _target == _this"];
flarestarget.sqf - it allows the player to cycle through the different target areas. in my example three areas in and around Garmsar.
Private ["_unit"];

_unit = _this select 0;
_unit removeAction action1;
_unit removeAction action2;

sleep 2;

//designate all targets you need

switch (illumination) do {

case artytarget1: {
illumination = artytarget2;
publicvariable "illumination";
HQ SideChat "Changing target, standby";
sleep 5;
HQ SideChat "Artillery is now aiming on Garmsar proper, West";
sleep 2;
HQ SideChat "New barrage ready.";
};

case artytarget2: {
illumination = artytarget3;
publicvariable "illumination";
HQ SideChat "Changing target, standby";
sleep 5;
HQ SideChat "Artillery is now aiming on Garmsar proper, East";
sleep 2;
HQ SideChat "New barrage ready.";
};

case artytarget3: {
illumination = artytarget1;
publicvariable "illumination";
HQ SideChat "Changing target, standby";
sleep 5;
HQ SideChat "Artillery is now aiming on Garmsar outskirts";
sleep 2;
HQ SideChat "New barrage ready.";
};

case default {
HQ SideChat "switch reads default and you don't want to see this.";
};

};

action1 = _unit addAction ["<t color='#dddd00'>"+"start barrage"+"</t>",
"scripts\flares.sqf",[illumination],1,false,true,"","driver _target == _this"];

action2 = _unit addAction ["<t color='#dddd00'>"+"cycle targets"+"</t>",
"scripts\flaretarget.sqf",[illumination],2,false,true,"","driver _target == _this"];
Feel free to comment, criticize etc.

Post Reply