Grovesy 10 Posted June 1, 2015 Hey guys, I am currently working on a script here and slowly walked myself into a dead-end.. Interested to know if there were any EventHandlers for a mine being disarmed.. Either in default ArmA, CBA addon, or ACE3 addon? Script waits until a mine is disarmed, from there I would like to gather the ID of the mine and the ID of the player/unit disarming the mine. Any help appreciated. Cheers, -Grovesy Share this post Link to post Share on other sites
austin_medic 109 Posted June 1, 2015 Simply put, no there is none. though you could try to jerry rig something by spawning a mine inside a ground weapon holder then putting a real mine under it and having the player simply pick up the mine from the weapon holder then deleting the real mine that is under it via the inventory eventhandlers. Check the biki for more info. Share this post Link to post Share on other sites
Grovesy 10 Posted June 1, 2015 It's a little bit disappointing to say the least that there isn't anything.. Thankyou for the quick reply Austin, you have a good idea there, but unfortunately I am more a perfectionist and would prefer it done properly lol. Will keep your idea in mind in case I change my opinion on that. Cheers, -Grovesy Share this post Link to post Share on other sites
A.Cyprus 16 Posted June 2, 2015 How big is the mine field? If it isn't performance-limiting, perhaps you could spawn a monitor on allMines or just those within a given area. When mineactive becomes false for a mine that hasn't yet detonated, then you could assume it has been disarmed and maybe assume the nearest player had disarmed it. All assumptions on my part, haven't tried any of this myself. Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted June 2, 2015 (edited) Mines aren't 'disarmed' in the logical sense. When you click 'deactivate mine', the one seen is deleted and a different object is created and put in its place. _mines = []; _mine = createMine []; 0 = _mines pushBack _mine; _mine = createMine []; 0 = _mines pushBack _mine; minefield_active = TRUE; while {(minefield_active)} do { { _mine = _x; if (isNull _mine) then { _nearbyPlayers = (getPosATL _mine) nearEntities ['Man',10]; if ((count _nearbyPlayers) > 0) then { if (({(alive _x)} count _nearbyPlayers) > 0) then { /* the mine has been deactivated and/or destroyed */ } else { /* There are players nearby but none alive, mine may have exploded */ }; } else { /* mine has been destroyed/deleted with no players nearby */ }; _mines deleteAt (_mines find _mine); }; } count _mines; if ((count _mines) isEqualTo 0) exitWith {minefield_active = FALSE;}; // no mines remaining sleep 1; }; Something like that can test whether the mine still exists. food for thought anyway. If you know the position of the mine and when it is deleted (deactivated), you can get the nearest alive players object with nearentities. I suppose further check could tell if they have a mine detector or are capable of defusing mines. I have long thought a 'Deleted' event handler would be useful. Edited June 22, 2015 by MDCCLXXVI Share this post Link to post Share on other sites
A.Cyprus 16 Posted June 22, 2015 Not actually tested but if you modified the above to check for a mine object at the position of the missing 'armed mine' object, you could perhaps assume it had been defused. This is based on the assumption that 'armed' and 'disarmed' mine objects have different class names, the former being the 'ammo' type. Or you could setVariable ["isArmed", true] for each mine at the start and check for this during your monitoring loop. If all else fails and you still need the option, then perhaps explore disabling simulation for each mine and handling the events manually with triggers and actions. Share this post Link to post Share on other sites
Larrow 2814 Posted June 23, 2015 (edited) When a mine is disarmed a groundWeaponHolder is created and a magazine of the mine type (ammo) is placed into it. No matter how many mines you disable on the same spot a new groundWeaponHolder seems to be created. Although Take and Fired EH's fire on placing a mine neither fire for disarming one. Neither does Put. What does fire is an animation change for the player,which includes the string "putdown". Although this could fire for a number of reason, you could check nearby for any objects of type TimeBombCore and MineBase and then once the animation has finished (plus small delay) recheck to see if any are missing. At the same time check for groundWeaponHolders before and after the animation. This check should not be too taxing, it is only a small area 1-3 meters maybe and is all happening on the clients machine. If a mine is missing and there is a new GWH containing the magazine class of the mine then it is very likely that you just disarmed it. Only time this is likely to fail is if you are disarming a mine at the same time and very close to someone else who is disarming or throwing stuff down on the floor (which would create a GWH) and then only if they were discarding a magazine of the type of ammo you are disarming. Here is a quick test piece i came up with.. fnc_mineDisarmMessage = { private [ "_id", "_type", "_unit" ]; _id = _this select 0; _type = _this select 1; _unit = _this select 2; hint format [ "Mine :\n%1\nof type\n%2\nwas disarmed by\n%3", _id, _type, name _unit ]; }; player addEventHandler [ "AnimChanged", { _thread = _this spawn { _unit = _this select 0; _animState = _this select 1; if ( [ "putdown", _animState ] call BIS_fnc_inString ) then { _mines = ( _unit nearObjects [ "TimeBombCore", 3.5 ] ) + ( _unit nearObjects [ "MineBase", 3.5 ] ); _mineInfo = []; { _gwh = nearestObjects [ _x, [ "GroundWeaponHolder" ], 1 ]; _mineInfo pushBack [ typeOf _x, str _x, getPosATL _x, _gwh ]; }forEach _mines; waitUntil { !( _animState isEqualTo ( animationState _unit ) ) }; sleep 0.5; _found = false; { if ( isNull _x ) then { _mineType = ( _mineInfo select _forEachIndex ) select 0; _mineID = ( _mineInfo select _forEachIndex ) select 1; _minePos = ( _mineInfo select _forEachIndex ) select 2; _oldgwh = ( _mineInfo select _forEachIndex ) select 3; _magClass = getText ( configFile >> "CfgAmmo" >> _mineType >> "defaultMagazine" ); _gwh = nearestObjects [ _minePos, [ "GroundWeaponHolder" ], 1 ]; { if ( !( _x in _oldgwh ) && { _magClass in ( magazineCargo _x ) } ) exitWith { [ _mineID, _mineType, _unit ] call fnc_mineDisarmMessage; _found = true; }; }forEach _gwh; }; if ( _found ) exitWith {}; }forEach _mines; }; }; }]; Edited June 23, 2015 by Larrow typeO 1 Share this post Link to post Share on other sites
cpthammerbeard 10 Posted June 23, 2015 (edited) I used this for an underwater mine clearance mission //ARRAY to store mines _myMines = []; //spawn in 8 mines at randmo positions around my marker for "_i" from 1 to 8 do { _minePos = [_NavalMinePos,10,60,10,2,0,0] call BIS_fnc_findSafePos; _mineSpawn = createMine ["UnderwaterMine",_minePos,[],0]; //Add mine to ARRAY _myMines pushBack _mineSpawn; _mineSpawn setPosATL [_minePos select 0,_minePos select 1,(getPosATL _mineSpawn select 2) - 2]; [_mineSpawn,"BIS_fnc_spawn",true,true] call BIS_fnc_MP; }; //Create thread to monitor mines _checkMines = _myMines spawn { //Passed mines ARRAY _mines = _this; //Loop forever while { true } do { //Exit loop if the are 0 active mines if ( { mineActive _x }count _mines == 0 ) exitWith { //Set variable minesDefused = true; }; /*Check 10 seconds*/ sleep 10; }; }; waitUntil{(!isNil ("minesDefused"))}; //Insert the rest of your code here It's adapted from someone who gave me the code, can't find the post though. Apologies for not crediting. Hope it helps Cheers Edited June 24, 2015 by CptHammerBeard Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted June 24, 2015 @CptHammerBeard, guess that's what you were searching? http://forums.bistudio.com/showthread.php?190212-Scripted-Mine-Clearance Cheers Share this post Link to post Share on other sites
cpthammerbeard 10 Posted June 24, 2015 @Johnny - hahaha, I forget I'd started that, I thought I'd googled it lol. Thanks for posting. Note to self, stop posting things after a few beers :P Share this post Link to post Share on other sites