[SCRIPT] an action to place F2 tripflares
Posted: Mon Nov 05, 2012 6:53 pm
This script allows a selection of units to place exactly one F2 Trip Flare. The units, radius of the tripflare and side which triggers the tripflare can be customized.
As the only thing this script does is placing a trigger it can easily be modified to fire anything one could imagine.
init.sqf
_this select 0 is an array with all the unitnames that would get the action.
_this select 1 is a number for length of tripwire area
_this select 2 is a number for width of tripwire area
_this select 3 is a valid side
ws_tripwire_init
ws_tripwireaction.sqf
As the only thing this script does is placing a trigger it can easily be modified to fire anything one could imagine.
init.sqf
Code: Select all
[[unitname1,unitname2],15,5,east] execVM "ws_scripts\ws_tripwire_init.sqf";
_this select 1 is a number for length of tripwire area
_this select 2 is a number for width of tripwire area
_this select 3 is a valid side
ws_tripwire_init
Code: Select all
private ["_units"];
_units = _this select 0;
_size1 = _this select 1; //Length
_size2 = _this select 2; //Width
_side = _this select 3;
if (isNil "ws_tripwire") then {ws_tripwire = []};
ws_fnc_tripwire = {
pos = ws_tripwire select 0;
_size1 = ws_tripwire select 1;
_size2 = ws_tripwire select 2;
_side =ws_tripwire select 3;
_dir = ws_tripwire select 4;
_sidestr = format ["%1",_side];
_trg=createTrigger["EmptyDetector",_pos];
_trg setTriggerArea[_size2,_size1,_dir,true];
_trg setTriggerActivation[_sidestr,"PRESENT",false];
_trg setTriggerStatements["this","nul = [thisList,thisTrigger] execVM ""f\common\f_tripflare.sqf"";", ""];
if (side player == _side) exitWith {};
_mkr = createMarkerLocal [format["%1",_pos], _pos];
_mkr setMarkerShapeLocal "RECTANGLE";
_mkr setMarkerSizeLocal [_size2,_size1];
_mkr setMarkerDirLocal _dir;
_mkr setMarkerColorLocal "ColorRed";
_mkr setMarkerBrushLocal "BORDER";
};
{_x addAction ["<t color='#dddd00'>"+"Place tripwire"+"</t>","ws_scripts\ws_tripwireaction.sqf",[_size1,_size2,_side],1,false,true,"","(driver _target == _this)"];} forEach _units;
"ws_tripwire" addPublicVariableEventHandler {call ws_fnc_tripwire;};
Code: Select all
private ["_unit","_pos","_id","_size","_side","_sidestr","_mkr"];
_unit = _this select 1;
_pos = getPos _unit;
_dir = getDir _unit;
_id = _this select 2;
_size1 = (_this select 3) select 0;
_size2 = (_this select 3) select 1;
_side = (_this select 3) select 2;
_unit removeAction _id;
ws_tripwire = [_pos,_size1,_size2,_side,_dir];
publicvariable "ws_tripwire";
call ws_fnc_tripwire;