Send notifications when installation destroyed

  1. 7 years ago
    Edited 7 years ago by DaVidoSS

    Here I present you guys my figment.

    Function to handle AliVE insurgents installations destruction in asymmetrical warfare.
    Installations affected:

    IED Factory
    Recruitment HQ
    Weapons Depot

    In correlation with the other functions used
    creating big explosion and sends notifications
    to nearby players about destroyed installation.
    It also removes installation trashes.

    Change debug and insurgent faction class to meet your needs.

    private ["_debug", "_asymFCT", "_vis", "_insIEDfab", "_insRHQ", "_insWPDT", "_choose", "_OPCOM_HANDLER", "_objectives", "_objective", "_factory", "_HQ", "_depot", "_markerF", "_EHExploIdxF", "_markerR", "_EHExploIdxR", "_markerW", "_EHExploIdxW"];
    
    //**************************edit down here*********************//
    
    _debug = false; // change to true for some debug output
    _asymFCT = "OPF_MTI_F"; //change to your insurgents faction class
    
    //*************************edit up here***********************//
    
    if (_debug) then {
    
    	_vis = 1;
    	
    	}else{
    	
    	_vis = 0;
    };
    
    _insIEDfab = [];
    _insRHQ = [];
    _insWPDT = [];
    
    
    if (_asymFCT in (((OPCOM_instances select 0) select 2) select 1)) then {
    
    	_choose = 0;
    	}else{
    	_choose = 1;
    };
    
    _OPCOM_HANDLER = OPCOM_instances select _choose;
        
        _objectives = [_OPCOM_HANDLER,"objectives",[]] call ALiVE_fnc_HashGet;
        
        {
            _objective = _x;
            
    			_factory = [_OPCOM_HANDLER,"convertObject",[_objective,"factory",[]] call ALiVE_fnc_HashGet] call ALiVE_fnc_OPCOM;
    			_insIEDfab pushback _factory;
    			_HQ = [_OPCOM_HANDLER,"convertObject",[_objective,"HQ",[]] call ALiVE_fnc_HashGet] call ALiVE_fnc_OPCOM;
    			_insRHQ pushback _HQ;
    			_depot = [_OPCOM_HANDLER,"convertObject",[_objective,"depot",[]] call ALiVE_fnc_HashGet] call ALiVE_fnc_OPCOM;
    			_insWPDT pushback _depot;
    			
    	} foreach _objectives;
    
    _insIEDfab = _insIEDfab - [objNull];
    _insRHQ = _insRHQ - [objNull];
    _insWPDT = _insWPDT - [objNull];
    
    {
    	if (isnil {_x getVariable "EHExploIdxF"}) then {
    	
    		if !(getText (configfile >> "CfgVehicles" >> typeOf _x >> "destrType") isEqualTo "DestructNo") then {
    		
    			if (_debug) then {
    				diag_log format ["*********** INSURGENCY: IED Factory found as object %1 ***********", typeOf _x];
    			};
    			_markerF = createMarkerLocal [format ["%1_factory_%2_%3_%4", floor(random 1000), floor(random 1000),floor(random 1000), _forEachIndex + 1], getpos _x];
    			_markerF setMarkerSizeLocal [150, 150];
    			_markerF setMarkerShapeLocal "ELLIPSE";
    			_markerF setMarkerAlphaLocal _vis; 
    			_x setVariable ["factory_marker",_markerF,false];
    
    			_EHExploIdxF = _x addEventHandler ["Explosion",{
    
    				params ["_object", "_nearBuildings", "_trashes", "_oamarker", "_bomb", "_EHid"];
    				
    				_nearBuildings = nearestObjects [_object, ["house","building"], 25];
    				_trashes = nearestObjects [_object, ["Land_RattanTable_01_F","Fridge_01_open_F","Land_WaterCooler_01_new_F","Land_MapBoard_F","ALiVE_IED","Box_East_AmmoOrd_F"], 25];
    				_oamarker = (_object getVariable "factory_marker");
    				_EHid = _object getVariable "EHExploIdxF";
    				_object removeEventHandler ["Explosion", _EHid];
    				_object setVariable ["EHExploIdxF",nil ,false];
    				_bomb = createVehicle ["Bo_Mk82",[getPos _object select 0, getPos _object select 1,0],[], 0, 'FLY'];
    				[_bomb,-90,0] call BIS_fnc_setPitchBank;
    				_bomb setVelocity [0, 0, -80];
    				{
    					_x setDamage 1;
    					
    					if (alive _x) then {
    					
    						deleteVehicle _x;
    					};
    				} foreach _nearBuildings;
    				{deleteVehicle _x;} foreach _trashes;
    				[_oamarker, "iedfactoryhq", "IED factory"] call INS_fnc_sendNotif;
    			}];
    			
    			_x setVariable ["EHExploIdxF",_EHExploIdxF,false];
    		};
    	};
    } forEach _insIEDfab;
    
    {
    	if (isnil {_x getVariable "EHExploIdxR"}) then {
    		
    		if !(getText (configfile >> "CfgVehicles" >> typeOf _x >> "destrType") isEqualTo "DestructNo") then {
    		
    			if (_debug) then {
    				diag_log format ["*********** INSURGENCY: Recruitment HQ found as object %1 ***********", typeOf _x];
    			};
    			_markerR = createMarkerLocal [format ["%1_rhq_%2_%3_%4", floor(random 1000), floor(random 1000),floor(random 1000), _forEachIndex + 1], getpos _x];
    			_markerR setMarkerSizeLocal [150, 150];
    			_markerR setMarkerShapeLocal "ELLIPSE";
    			_markerR setMarkerAlphaLocal _vis; 
    			_x setVariable ["rhq_marker",_markerR,false];
    
    			_EHExploIdxR = _x addEventHandler ["Explosion",{
    
    				params ["_object", "_nearBuildings", "_trashes", "_oamarker", "_bomb", "_EHid"];
    				
    				_nearBuildings = nearestObjects [_object, ["house","building"], 25];
    				_trashes = nearestObjects [_object, ["Land_RattanTable_01_F","Fridge_01_open_F","Land_WaterCooler_01_new_F","Land_MapBoard_F","ALiVE_IED","Box_East_AmmoOrd_F"], 25];
    				_oamarker = (_object getVariable "rhq_marker");
    				_EHid = _object getVariable "EHExploIdxR";
    				_object removeEventHandler ["Explosion", _EHid];
    				_object setVariable ["EHExploIdxR",nil ,false];
    				_bomb = createVehicle ["Bo_Mk82",[getPos _object select 0, getPos _object select 1,0],[], 0, 'FLY'];
    				[_bomb,-90,0] call BIS_fnc_setPitchBank;
    				_bomb setVelocity [0, 0, -80];
    				{
    					_x setDamage 1;
    					
    					if (alive _x) then {
    					
    						deleteVehicle _x;
    					};
    				} foreach _nearBuildings;
    				{deleteVehicle _x;} foreach _trashes;
    				[_oamarker, "recruitmenthq", "Recruitment HQ"] call INS_fnc_sendNotif;
    			}];
    			
    			_x setVariable ["EHExploIdxR",_EHExploIdxR,false];
    		};
    	};
    } forEach _insRHQ;
    
    {
    	if (isnil {_x getVariable "EHExploIdxW"}) then {
    				
    		if !(getText (configfile >> "CfgVehicles" >> typeOf _x >> "destrType") isEqualTo "DestructNo") then {
    		
    			if (_debug) then {
    				diag_log format ["*********** INSURGENCY: Weapons Depot found as object %1 ***********", typeOf _x];
    			};
    			_markerW = createMarkerLocal [format ["%1_wpd_%2_%3_%4", floor(random 1000), floor(random 1000),floor(random 1000), _forEachIndex + 1], getpos _x];
    			_markerW setMarkerSizeLocal [150, 150];
    			_markerW setMarkerShapeLocal "ELLIPSE";
    			_markerW setMarkerAlphaLocal _vis; 
    			_x setVariable ["wpd_marker",_markerW,false];
    
    			_EHExploIdxW = _x addEventHandler ["Explosion",{
    
    				params ["_object", "_nearBuildings", "_trashes", "_oamarker", "_bomb", "_EHid"];
    				
    				_nearBuildings = nearestObjects [_object, ["house","building"], 25];
    				_trashes = nearestObjects [_object, ["Land_RattanTable_01_F","Fridge_01_open_F","Land_WaterCooler_01_new_F","Land_MapBoard_F","ALiVE_IED","Box_East_AmmoOrd_F"], 25];
    				_oamarker = (_object getVariable "wpd_marker");
    				_EHid = _object getVariable "EHExploIdxW";
    				_object removeEventHandler ["Explosion", _EHid];
    				_object setVariable ["EHExploIdxW",nil ,false];
    				_bomb = createVehicle ["Bo_Mk82",[getPos _object select 0, getPos _object select 1,0],[], 0, 'FLY'];
    				[_bomb,-90,0] call BIS_fnc_setPitchBank;
    				_bomb setVelocity [0, 0, -80];
    				{
    					_x setDamage 1;
    					
    					if (alive _x) then {
    					
    						deleteVehicle _x;
    					};
    				} foreach _nearBuildings;
    				{deleteVehicle _x;} foreach _trashes;
    				[_oamarker, "weaponsdepothq", "Weapons depot"] call INS_fnc_sendNotif;
    			}];
    			
    			_x setVariable ["EHExploIdxW",_EHExploIdxW,false];
    		};
    	};
    } forEach _insWPDT;
  2. Edited 7 years ago by DaVidoSS

    All needed files:

    LINK

    Here some VIDEO

  3. Thank you very very much, Kind Sir.

  4. Edited 7 years ago by HeroesandvillainsOS

    Hey thanks. When you say change debug, do you mean leave it as is (called "debug") but just toggle the true/false value? Assuming so.

    I appreciate the script. The video is impressive and immersive.

    EDIT: Sorry. Disregard. I read the actual script and you explain it there. :)

  5. Edited 7 years ago by DaVidoSS

    _debug = false; //hange to true for some debug output

    I have just added that possibility for share the function with you guys.

    If you set _debug = true you will get log info in rpt and map marker around the installation.
    Those markers are basically only visible by server because they are local to server .
    If you host the mission or preview in editor you can see those markers.
    Thats why i have set switch on debug.

  6. highhead

    28 Apr 2016 Administrator

    yo! this is awesome! nice work

  7. "It also removes installation trashes."
    Does this mean the fridge, ied table, water bottle and ammo crates etc are automatically deleted when the building is destroyed?
    If so cool :)

  8. removes:
    "Land_RattanTable_01_F",
    "Fridge_01_open_F",
    "Land_WaterCooler_01_new_F",
    "Land_MapBoard_F",
    "ALiVE_IED",
    "Box_East_AmmoOrd_F"

  9. I did put those files in my Mission, had to rearrange some lines due to function.hpp and some double defining. No big deal.
    But if I destroy the whole house with IED tables and ammo boxes and stuff, I don't get any message and it doesn't go boom in a big way.
    I put in my assymetric force class (Faction of CAF Aggressors) since I linked my IED Module to it's commander.
    But I don't get any message when destroying the IED Factory (or the weapon thingy).
    Do I have to put in the Name of the assymetric force or the Faction I put in the IED module? I put the civilian faction in there, for the vehicle-bombs and stuff.
    I know I could just try it, but I am not at home right now and won't be able to test it the following days, so I figured it would be faster to just ask.

  10. Edited 7 years ago by DaVidoSS

    Your insurgents faction is defined in assymetrical AI Commander module.
    If you have trouble with your cfgFunction classes instead of merging it put the files in one file and preprocess that file in init.sqf.

  11. Cool, will try later :)

  12. @DaVidoSS Your insurgents faction is defined in assymetrical AI Commander module.
    If you have trouble with your cfgFunction classes instead of merging it put the files in one file and preprocess that file in init.sqf.

    I make my missions the same way as Murdock I think based on his post. Assuming I'll need to do this too.

    Could you post how the script would look if done only through the init.sqf? Not sure what you mean by "instead of merging." I'm assuming you mean combining the code and description.ext in some way?

  13. Edited 7 years ago by DaVidoSS

    Ok on demand version without CfgFunctions:

    FILES

    Change debug and insurgent faction class in
    functions\fn_handle_installations.sqf line 43,44
    to feet your scenario.
    Here some videos:
    CLIP
    CLIP2

  14. I seem to be stuck. This is working fine for me in single player and when I load it up as multiplayer.

    But when I put the mission on my dedicated server we get none of the notification messages. As I am still new to this stuff can anyone give me some ideas on what to check or better yet an example mission or even or your int.sqf and description.ext or any other config file that might be needed. This is the last thing I would like to have working and it's been driving me crazy all night.

    Thanks
    Eric

 

or Sign Up to reply!