Raffal 12 Posted October 1, 2015 Hi guys, I have a question, how do I turn off an entire minefield (created by module BIS) via trigger? Let me explain: In my mission I have placed a module for the creation of a minefield, the player's task is to try to destroy a generator that supplies electricity to the mines. Once identified and destroyed, mines should automatically neutralize. Is there a way to disarm the mines module via trigger? Thanks for your help Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted October 1, 2015 I don't know if there's any specific command to enable/disable mines, but try enableSimulation. There are some different approaches which come to my mind, depending on how you created the mines. If this minefield contains all mines throughout the map, you may iterate over allMines and disable them all. If you create them by script (not in the editor), you should put them into an array which you can then setVariable to the trigger which then can be gotten by the respective trigger statement and be iterated through. If you create them in the editor (which I assume), you can create a location covering all mines in that mine field, then iterate through allMines and check for each mine, whether it's in the location, so you can determine which you have to disable. Share this post Link to post Share on other sites
Joe98 91 Posted October 1, 2015 perhaps you could use "deletevehicle" and delete the minefield. 1 Share this post Link to post Share on other sites
Larrow 2821 Posted October 2, 2015 You can delete each mine.. //Module - module name in editor _logic = m1; //Get info from module _mineType = _logic getVariable "minestype"; _areaX = parseNumber ( _logic getVariable "axisa" ); _areaY = parseNumber ( _logic getVariable "axisb" ); _shape = _logic getVariable "shape"; _dir = getDir _logic; //Get _minType's ammo type _mineAmmo = getText( configFile >> "CfgVehicles" >> _mineType >> "ammo" ); //Get all mines within a radius of the largest axis _mines = _logic nearObjects [ _mineAmmo, ( _areaX max _areaY ) ]; //Make a trigger just for BIS_fnc_inTrigger _trg = createTrigger [ "EmptyDetector", _logic ]; _trg setTriggerArea [ _areaX, _areaY, _dir, toLower _shape == "rectangle" ]; //Delete each mine, the trigger and the module { if ( [ _trg, _x ] call BIS_fnc_inTrigger ) then { deleteVehicle _x; }; }forEach _mines + [ _trg, _logic ];Where m1 is the name you gave the mine module in the editor. 1 Share this post Link to post Share on other sites
Raffal 12 Posted October 5, 2015 You can delete each mine.. //Module - module name in editor _logic = m1; //Get info from module _mineType = _logic getVariable "minestype"; _areaX = parseNumber ( _logic getVariable "axisa" ); _areaY = parseNumber ( _logic getVariable "axisb" ); _shape = _logic getVariable "shape"; _dir = getDir _logic; //Get _minType's ammo type _mineAmmo = getText( configFile >> "CfgVehicles" >> _mineType >> "ammo" ); //Get all mines within a radius of the largest axis _mines = _logic nearObjects [ _mineAmmo, ( _areaX max _areaY ) ]; //Make a trigger just for BIS_fnc_inTrigger _trg = createTrigger [ "EmptyDetector", _logic ]; _trg setTriggerArea [ _areaX, _areaY, _dir, toLower _shape == "rectangle" ]; //Delete each mine, the trigger and the module { if ( [ _trg, _x ] call BIS_fnc_inTrigger ) then { deleteVehicle _x; }; }forEach _mines + [ _trg, _logic ];Where m1 is the name you gave the mine module in the editor. thanks Larrow will try it and let you know..... B) Share this post Link to post Share on other sites
killzone_kid 1330 Posted October 5, 2015 You can delete each mine.. _trg setTriggerArea [ _areaX, _areaY, _dir, toLower _shape == "rectangle" ]; Are you still trying to compete in Johnny's who can make longest expression? JK :) 1 Share this post Link to post Share on other sites
Raffal 12 Posted October 5, 2015 Are you still trying to compete in Johnny's who can make longest expression? JK :) Yes....I confirm, the module already contains this information, and you can change....Anyway good job Larrow, u scrpt work perfectly.... thanks for your help ;) Only little question: Can I extend the script to multiple modules with this string? _logic = [m1, m2, m3, m4, m5, m6]; thx all for support!! Share this post Link to post Share on other sites
Larrow 2821 Posted October 5, 2015 Looks excessive. Are you still trying to compete in Johnny's who can make longest expression? :)Lol KK no! :D I mainly use isEqualTo since its inclusion into the api, I most likely left toLower there after testing and changing to == but forgot to clean up afterwards.Only little question: Can I extend the script to multiple modules with this string?You would need to change it slightly to loop through each module by wrapping it all in another foreach. _modules = [ m1, m2, m3, m4, m5, m6 ]; { //Module _logic = _x; //Get info from module _mineType = _logic getVariable "minestype"; _areaX = parseNumber ( _logic getVariable "axisa" ); _areaY = parseNumber ( _logic getVariable "axisb" ); _shape = _logic getVariable "shape"; _dir = getDir _logic; //Get _minType's ammo type _mineAmmo = getText( configFile >> "CfgVehicles" >> _mineType >> "ammo" ); //Get all mines within a radius of the largest axis _mines = _logic nearObjects [ _mineAmmo, ( _areaX max _areaY ) ]; //Make a trigger just for BIS_fnc_inTrigger _trg = createTrigger [ "EmptyDetector", _logic ]; _trg setTriggerArea [ _areaX, _areaY, _dir, _shape == "rectangle" ]; //removed :P //Delete each mine, the trigger and the module { if ( [ _trg, _x ] call BIS_fnc_inTrigger ) then { deleteVehicle _x; }; }forEach _mines + [ _trg, _logic ]; }forEach _modules; 1 Share this post Link to post Share on other sites
Twiznak 57 Posted October 10, 2018 On 10/5/2015 at 9:33 AM, Larrow said: Lol KK no! :D I mainly use isEqualTo since its inclusion into the api, I most likely left toLower there after testing and changing to == but forgot to clean up afterwards.You would need to change it slightly to loop through each module by wrapping it all in another foreach. _modules = [ m1, m2, m3, m4, m5, m6 ]; { //Module _logic = _x; //Get info from module _mineType = _logic getVariable "minestype"; _areaX = parseNumber ( _logic getVariable "axisa" ); _areaY = parseNumber ( _logic getVariable "axisb" ); _shape = _logic getVariable "shape"; _dir = getDir _logic; //Get _minType's ammo type _mineAmmo = getText( configFile >> "CfgVehicles" >> _mineType >> "ammo" ); //Get all mines within a radius of the largest axis _mines = _logic nearObjects [ _mineAmmo, ( _areaX max _areaY ) ]; //Make a trigger just for BIS_fnc_inTrigger _trg = createTrigger [ "EmptyDetector", _logic ]; _trg setTriggerArea [ _areaX, _areaY, _dir, _shape == "rectangle" ]; //removed :P //Delete each mine, the trigger and the module { if ( [ _trg, _x ] call BIS_fnc_inTrigger ) then { deleteVehicle _x; }; }forEach _mines + [ _trg, _logic ]; }forEach _modules; Thank you Larrow! 3 years later. Just goes to show that good advice never goes bad :) Share this post Link to post Share on other sites
EO 11277 Posted March 7, 2019 @Larrow, your example works a treat, thank you. Share this post Link to post Share on other sites
Larrow 2821 Posted March 8, 2019 9 hours ago, EO said: @Larrow, your example works a treat, thank you. Your welcome. You can get rid of the trigger now we have the inArea command. Plus fix for largest radius of a rectangle. //Minefield Modules _modules = [ m1, m2, m3, m4, m5, m6 ]; { //Module _logic = _x; //Get info from module _mineType = _logic getVariable "minestype"; _areaX = parseNumber ( _logic getVariable "axisa" ); _areaY = parseNumber ( _logic getVariable "axisb" ); _isRectangle = _logic getVariable "shape" == "rectangle"; _dir = getDir _logic; //Get _minType's ammo type _mineAmmo = getText( configFile >> "CfgVehicles" >> _mineType >> "ammo" ); //Get all mines within a radius of the largest axis _largestAxis = ( _areaX max _areaY ) * ( [ 1, 1.4142 ] select _isRectangle ); _mines = _logic nearObjects [ _mineAmmo, _largestAxis ]; //Delete each mine, and the module { if ( _x inArea [ _logic, _areaX, _areaY, _dir, _isRectangle ] ) then { deleteVehicle _x; }; }forEach ( _mines + [ _logic ] ); }forEach _modules; 2 2 Share this post Link to post Share on other sites