Skip to content

Instantly share code, notes, and snippets.

@indig0fox
Last active May 18, 2021 18:47
Show Gist options
  • Save indig0fox/177bf49d9c760944fc1328aab306ea49 to your computer and use it in GitHub Desktop.
Save indig0fox/177bf49d9c760944fc1328aab306ea49 to your computer and use it in GitHub Desktop.
Tracking mine detonations
uses CBA function to add init code to the magazine that's placed, ACE_Explosives_Placed{classname} which gets the pos & execVMs a sideloaded script file
waits for magazine (placed, unarmed mine obj) to be objNull
checks for ammo obj in vicinity of magazine pos
if null, then mine was picked back up
if present, was armed and now an ammo obj exists as armed mine
gets info about armed mine, incl displayname of defaultMagazine property in config
waits for armed mine to be objNull
runs detonation code (marker/hint)
["ACE_Explosives_Place", "init", {
// if (!isServer) exitWith {};
_placedPos = getPos (_this # 0);
[(_this # 0), _placedPos] execVM "test.sqf";
// (_this # 0) setVariable ["asscMarker", _markName, true];
// systemChat str ((_this # 0) getVariable ["asscMarker", -1]);
}] call CBA_fnc_addClassEventHandler;
waitUntil {isNull (_this # 0)};
sleep 1;
params ["_unarmedPlacement", "_placedPos"];
_nearMines = [];
_nearMines append (_placedPos nearObjects ["TimeBombCore", 5]);
_nearMines append (_placedPos nearObjects ["APERSMine_Range_Ammo", 5]);
systemChat str _nearMines;
if (_nearMines isEqualTo []) then {
hint str "Mine picked up";
} else {
hint str "Mine armed";
_armedMine = _nearMines # 0;
_int = random 2000;
_explConfig = configOf _armedMine;
_explName = getText (configFile >> "CfgMagazines" >> (getText(_explConfig >> "defaultMagazine")) >> "displayName");
_explType = typeOf _armedMine;
_placedPos = getPos _armedMine;
_placer = _placedPos nearestObject "Man";
_markTextLocal = format["Detonation of %1", _explName];
_markName = format["Mine#%1/%2", _int, _placedPos];
_markColor = "ColorRed";
_markerType = "Minefield";
waitUntil {isNull _armedMine};
hint "Mine detonated!";
_markStr = format["|%1|%2|%3|%4|%5|%6|%7|%8|%9|%10",
_markName,
_placedPos,
_markerType,
"ICON", [1, 1],
0,
"Solid",
_markColor,
1,
_markTextLocal
];
_markStr call BIS_fnc_stringToMarker;
systemChat _markStr;
systemChat format["Created marker %1", _markName];
// ["fnf_ocap_handleMarker", ["CREATED", _markName, _placer, _placedPos, _markerType, "ICON", [1,1], 0, "Solid", _markColor, 1, _markTextLocal]] call CBA_fnc_localEvent;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment