Moerderhoschi 106 Posted February 16, 2015 (edited) unitAreasOnMap Scriptby Moerderhoschiexamplemission at the end of the post Hey Folks,I've made a script to mark areas, when units in the area, on the map. The background was for missiontasks like "clear city xy of all enemy forces" to avoid to search 15 minutes for the last enemy in the city.Example video: still uploading so please be patient Some theory first:How the script works?1. The script is checking the parameters passed to it (Array or TriggerObject)2. Checking allUnits in the TriggerArea / checking allUnits on the map if an array is passed - and add the sectors with units in to an array3. Checking all sectors in the array with already placed areaMarkers to avoid unneeded marker deletion / creation4. Delete all sectorMarkers where no longer units in5. Create new sectorMarkers for new sectors with units in6. Sleep x seconds and restart at point 2How to use it:The use is very easy, copy the following into a trigger and adjust the parameters if you like: 0=[ thisTrigger ] spawn{if(!isServer)exitWith{};_l0=0;_l1=0;_l2=1;_l3=1;_l4=if(count _this>1)then{_this select 1}else{15};_l5=0;_l6=time;_l7=0;_l8=false;_l9=if(count _this>3)then{_this select 3}else{"red"};_l10=[];_l11="ANY";_l12=if(count _this>4)then{_this select 4}else{0.2};_l13=if(count _this>2)then{(_this select 2)select 0}else{0};_l14=if(count _this>2)then{(_this select 2)select 1}else{0};if(typeName _l4=="ARRAY")then{if(count _l4>2)then{_l7=_l4 select 2};if(count _l4>1)then{_l5=_l4 select 1};_l4=_l4 select 0};if(_l4<1)then{_l4=1};if(_l5>_l4)then{_l5=0};if(_l12<0.1)then{_l12=0.1};if(typeName(_this select 0)=="ARRAY")then{_l0=(((_this select 0)select 0)select 0);_l1=(((_this select 0)select 0)select 1);_l2=_l0+(((_this select 0)select 1)select 0);_l3=_l1+(((_this select 0)select 1)select 1);_l11=if(count _this>5)then{_this select 5}else{"ANY"}}else{_l0=(((getpos(_this select 0))select 0)-((triggerArea(_this select 0))select 0));_l1=(((getpos(_this select 0))select 1)-((triggerArea(_this select 0))select 1));_l2=(((getpos(_this select 0))select 0)+((triggerArea(_this select 0))select 0));_l3=(((getpos(_this select 0))select 1)+((triggerArea(_this select 0))select 1));_l11=if(count _this>5)then{_this select 5}else{(triggerActivation(_this select 0))select 0}};if(!(typeName _l11=="SIDE"))then{if(typeName _l11=="STRING")then{_l11=toUpper _l11;switch(_l11) do{case"WEST":{_l11=west};case"EAST":{_l11=east};case"GUER":{_l11=resistance};case"CIV":{_l11=civilian};default{_l11="ANY"}}}else{_l11="ANY"}};_l15={if(typeName _l11=="SIDE")then{side _x==_l11}else{true}};_l16={_l17=true;for"_l18"from 0 to((count _l19)-1) do{if(_l19 select _l18 select 0==_l20 select 0&& _l19 select _l18 select 1==_l20 select 1)then{_l17=false}};if(_l17)then{_l19=_l19+[_l20]}};while{true}do{_l19=[];_l21=[];_l22=[];if(typeName(_this select 0)=="ARRAY")then{{_l20=[(((floor(((getPos vehicle _x select 0)-_l13)/100))*100)+50+_l13),(((floor(((getPos vehicle _x select 1)-_l14)/100))*100)+50+_l14)];if(getPos vehicle _x select 0<=_l2&& getPos vehicle _x select 0>=_l0&& getPos vehicle _x select 1<=_l3&& getPos vehicle _x select 1>=_l1&& call _l15)then{call _l16}}forEach allUnits}else{{_l20=[(((floor(((getPos vehicle _x select 0)-_l13)/100))*100)+50+_l13),(((floor(((getPos vehicle _x select 1)-_l14)/100))*100)+50+_l14)];if(call _l15&& !(_x isKindOf"Animal"))then{call _l16}}forEach list(_this select 0)};for"_l18"from 0 to((count _l19)-1) do{_l23=false;for"_l24"from 0 to((count _l10)-1) do{if(((getMarkerPos(_l10 select _l24))select 0)==((_l19 select _l18)select 0)&&((getMarkerPos(_l10 select _l24))select 1)==((_l19 select _l18)select 1))then{_l22=_l22+[_l10 select _l24];_l23=true}};if(_l23)then{_l19 set[_l18,-1]}};_l19=_l19-[-1];_l21=_l10-_l22;{deleteMarker _x}forEach _l21;_l10=_l10-_l21;{_l25=createMarker["mdh_unitArasOnMapMarkerName_"+format["%1_%2",time,random 1000],_x];_l10=_l10+[_l25];_l25 setMarkerShape"RECTANGLE";_l25 setMarkerSize[50,50];_l25 setMarkerAlpha _l12;_l25 setMarkerBrush"Solid";_l25 setMarkerColor("color"+_l9)}forEach _l19;if(_l7>0)then{if(time>(_l6+_l7))then{_l8=true}};if(_l8) exitWith{{deleteMarker _x}forEach _l10};if(_l5>0)then{_l26=100;_l27=(_l12/_l26);_l28=(_l5/_l26);for"_l18"from 1 to _l26 do{sleep _l28;{_x setMarkerAlpha((markerAlpha _x)-_l27)}forEach _l10};{deleteMarker _x}forEach _l10;_l10=[];sleep(_l4-_l5)}else{sleep _l4}}}; Parameters !?Version 1.1 with TriggerObject:Version 1.2 with TriggerObject:Ingame, click to enlarge:Version 2.1 with Array (no need to use a trigger with this version, here you can place the code where you want, script, init, init of unit .....):Version 2.2 with Array:Q: Parameter MarkerCorrection?A: If you use Custom islands like A3MP, there is often a fault in the position system. Sectors often don't start at a pos like [5500,5500], there are grid-movements in the Y-direction. So you can adjust this fault with the Paramter. For A3MP Map Chernarus [ 0 , -40] should to the job.Q: What happen if two factions in one sector?A: Two sectorMarkes will be created so the color of the sector will mix up on the map.Q: How many Triggers with this script can i place on the Map, performancequestion?A: The script should have a low performance impact, so no worry for the amount of placements. If you find a limit or a huge performance impact, let me know :)Q: AreaColor?A: Take a look at: LINK, you can use all colors. Only write the part after "color", for "colorRed" write "red", for "colorBlue" write "blue", for "Color1_FD_F" wite "1_fd_f"Q: AreaMarkerLifeTime(FadeTime)?A: This is the time it takes for the areaMarker to disappear. If the AreaMarkerLifeTime is bigger than the RefreshTime the AreaMarkerLifeTime will set to 0 what equals NoFade.Q: Why is the script an one unreadable long line?A: I've compressed the script with ArmaResourceOptimizator by LeopotamQ: I want to see the script in a readable version to understand how it works in detail?A: No problem, visit my blog and take a look into the script or take a look at the end of the post :)Q: What if i find a bug?A: Please report it to me in this thread, thank you.How it looks ingame in the editor and on the Map:1 Trigger - TriggerActivation Bluefor - TriggerParameters [ thisTrigger ]http://abload.de/img/2015-02-16_00009meuy2.jpg (415 kB)http://abload.de/img/2015-02-16_00010seu8h.jpg (566 kB)4 Triggers:- 1. TriggerActivation Blufor - TriggerParameters [ thisTrigger, 1, [0,0], "blue", 0.6 ]- 2. TriggerActivation Opfor - TriggerParameters [ thisTrigger, 1, [0,0], "red", 0.6 ]- 3. TriggerActivation Independent - TriggerParameters [ thisTrigger, 1, [0,0], "green", 0.6 ]- 4. TriggerActivation Civilian - TriggerParameters [ thisTrigger, 1, [0,0], "civilian", 0.6 ]http://abload.de/img/2015-02-16_00005k5u9r.jpg (223 kB)http://abload.de/img/2015-02-16_0000791uez.jpg (251 kB)http://abload.de/img/2015-02-16_00004aajar.jpg (128 kB)1 Trigger - TriggerActivation Opfor - TriggerParameters [ thisTrigger ] - A3MP Chernarus without markerCorrection Parameterhttp://abload.de/img/2015-02-16_00011riu6e.jpg (273 kB)http://abload.de/img/2015-02-16_000126vu0x.jpg (702 kB)1 Trigger - TriggerActivation Opfor - TriggerParameters [ thisTrigger, 1, [ 0 , -40 ], "red", 0.6 ] - A3MP Chernarus with markerCorrection Parameterhttp://abload.de/img/2015-02-16_00013fvusf.jpg (208 kB)http://abload.de/img/2015-02-16_00015nuuf9.jpg (706 kB)example mission:Download from my Blog - http://moerderhoschi.bplaced.net/?p=920Readable Version: //unitAreasOnMap Script - made by Moerderhoschi v1.3 - 13.02.2015 0 = [ thisTrigger ] spawn { if (!isServer) exitWith {}; _startPosX = 0; _startPosY = 0; _endPosX = 1; _endPosY = 1; _refreshTime = if (count _this > 1) then {_this select 1} else {15}; _markerLifeTime = 0; _scriptStartTime = time; _scriptLifeTime = 0; _exitScript = false; _markerColor = if (count _this > 3) then {_this select 3} else {"red"}; _markers = []; _unitSide = "ANY"; _markerAlpha = if (count _this > 4) then {_this select 4} else {0.2}; _markerCorrectionX = if (count _this > 2) then {(_this select 2) select 0} else {0}; _markerCorrectionY = if (count _this > 2) then {(_this select 2) select 1} else {0}; if (typeName _refreshTime == "ARRAY") then { if (count _refreshTime > 2) then {_scriptLifeTime = _refreshTime select 2}; if (count _refreshTime > 1) then {_markerLifeTime = _refreshTime select 1}; _refreshTime = _refreshTime select 0; }; if (_refreshTime < 1) then {_refreshTime = 1}; if (_markerLifeTime > _refreshTime) then {_markerLifeTime = 0}; if (_markerAlpha < 0.1) then {_markerAlpha = 0.1}; if (typeName (_this select 0) == "ARRAY") then { _startPosX = (((_this select 0) select 0) select 0); _startPosY = (((_this select 0) select 0) select 1); _endPosX = _startPosX + (((_this select 0) select 1) select 0); _endPosY = _startPosY + (((_this select 0) select 1) select 1); _unitSide = if (count _this > 5) then {_this select 5} else {"ANY"}; } else { _startPosX = (((getpos (_this select 0)) select 0) - ((triggerArea (_this select 0)) select 0)); _startPosY = (((getpos (_this select 0)) select 1) - ((triggerArea (_this select 0)) select 1)); _endPosX = (((getpos (_this select 0)) select 0) + ((triggerArea (_this select 0)) select 0)); _endPosY = (((getpos (_this select 0)) select 1) + ((triggerArea (_this select 0)) select 1)); _unitSide = if (count _this > 5) then {_this select 5} else {(triggerActivation (_this select 0)) select 0}; }; if (!(typeName _unitSide == "SIDE")) then { if (typeName _unitSide == "STRING") then { _unitSide = toUpper _unitSide; switch (_unitSide) do { case "WEST": {_unitSide = west}; case "EAST": {_unitSide = east}; case "GUER": {_unitSide = resistance}; case "CIV": {_unitSide = civilian}; default {_unitSide = "ANY"}; } } else { _unitSide = "ANY" } }; _sideCheck = { if (typeName _unitSide == "SIDE") then {side _x == _unitSide} else {true} }; _sectorAdd = { _addSector = true; for "_i" from 0 to ((count _sectors) - 1) do { if ( _sectors select _i select 0 == _pos select 0 && _sectors select _i select 1 == _pos select 1 ) then { _addSector = false }; }; if (_addSector) then { _sectors = _sectors + [_pos]; }; }; while {true} do { _sectors = []; _markersDel = []; _markersKeep = []; if (typeName (_this select 0) == "ARRAY") then { { _pos = [(((floor(((getPos vehicle _x select 0)-_markerCorrectionX) / 100))*100)+50+_markerCorrectionX), (((floor(((getPos vehicle _x select 1)-_markerCorrectionY) / 100))*100)+50+_markerCorrectionY)]; if ( getPos vehicle _x select 0 <= _endPosX && getPos vehicle _x select 0 >= _startPosX && getPos vehicle _x select 1 <= _endPosY && getPos vehicle _x select 1 >= _startPosY && call _sideCheck ) then { call _sectorAdd }; } forEach allUnits; } else { { _pos = [(((floor(((getPos vehicle _x select 0)-_markerCorrectionX) / 100))*100)+50+_markerCorrectionX), (((floor(((getPos vehicle _x select 1)-_markerCorrectionY) / 100))*100)+50+_markerCorrectionY)]; if ( call _sideCheck && !(_x isKindOf "Animal") ) then { call _sectorAdd }; } forEach list (_this select 0); }; for "_i" from 0 to ((count _sectors)-1) do { _deleteFromCreationList = false; for "_i2" from 0 to ((count _markers)-1) do { if ( ((getMarkerPos (_markers select _i2)) select 0) == ((_sectors select _i) select 0) && ((getMarkerPos (_markers select _i2)) select 1) == ((_sectors select _i) select 1) ) then { _markersKeep = _markersKeep + [_markers select _i2]; _deleteFromCreationList = true; }; }; if (_deleteFromCreationList) then { _sectors set [_i,-1]; }; }; _sectors = _sectors - [-1]; _markersDel = _markers - _markersKeep; {deleteMarker _x} forEach _markersDel; _markers = _markers - _markersDel; { _mdh_unitAresOnMapMarker = createMarker [ "mdh_unitArasOnMapMarkerName_" + format ["%1_%2",time,random 1000], _x]; _markers = _markers + [_mdh_unitAresOnMapMarker]; _mdh_unitAresOnMapMarker setMarkerShape "RECTANGLE"; _mdh_unitAresOnMapMarker setMarkerSize [50, 50]; _mdh_unitAresOnMapMarker setMarkerAlpha _markerAlpha; _mdh_unitAresOnMapMarker setMarkerBrush "Solid"; _mdh_unitAresOnMapMarker setMarkerColor ("color" + _markerColor); } forEach _sectors; if (_scriptLifeTime > 0) then { if (time > (_scriptStartTime + _scriptLifeTime)) then { _exitScript = true; }; }; if (_exitScript) exitWith { {deleteMarker _x} forEach _markers; }; if (_markerLifeTime > 0) then { _mFactor = 100; _mAlphaSub = (_markerAlpha / _mFactor); _mFadeTime = (_markerLifeTime / _mFactor); for "_i" from 1 to _mFactor do { sleep _mFadeTime; {_x setMarkerAlpha ((markerAlpha _x) - _mAlphaSub) } forEach _markers; }; {deleteMarker _x} forEach _markers; _markers = []; sleep (_refreshTime - _markerLifeTime); } else { sleep _refreshTime; }; }; }; maybe someone will find this script useful ;) Edited December 13, 2015 by Moerderhoschi added readable version 1 Share this post Link to post Share on other sites
Guest Posted February 16, 2015 Release frontpaged on the Armaholic homepage. unitAreasOnMap Script v1.0 ================================================ We have also "connected" these pages to your account on Armaholic. This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
easyeb 137 Posted February 17, 2015 Very nice! Thanks alot, this is just what I was looking for! For me it's not marking opfor vehicles, bug or feature? :) Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 17, 2015 (edited) Great little script so thanks for that !Can i request a feature if possible.... The ability to have a time limit where they fade away and come back again every x amount of time sort of like Intel so they shown for say 30 sec then disappear then in say 2 -3 min they show again etc.. Would the be possible to add that to the Parameters ? Cheers @Foxhound thank you for hosting :) @EasyEB normally it should, maybe i missed something. I will look after it. @1PARA{God-Father} nice idea, maybe i will implement it but no promises for now ;) (i hope it's ok that i posted your PM here in this thread) I've added an example video to the fist post, it's still uploading. €dit @EasyEB i found the error and fixed it. Now vehicles should also be detected. Script and example mission updated. Edited February 17, 2015 by Moerderhoschi Share this post Link to post Share on other sites
Guest Posted February 17, 2015 New version frontpaged on the Armaholic homepage. unitAreasOnMap Script v1.1 ================================================ We have also "connected" these pages to your account on Armaholic. This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 18, 2015 @Foxhound thank you :) Share this post Link to post Share on other sites
SavageCDN 231 Posted February 18, 2015 Thanks for this.. will come in handy. Share this post Link to post Share on other sites
semiconductor 309 Posted February 18, 2015 Thank you, this script is incredibly easy to use and in the same time works totally as expected. :D Share this post Link to post Share on other sites
1para{god-father} 105 Posted February 19, 2015 Many thanks works like a treat! Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 20, 2015 I'm happy to read that the script found some audience, thank you all for you feedback :) I've updated the script and the example mission to version 1.2 with a Stringcheck fix for side parameter. There was an error which only occured when the side parameter was used with lowercase letters. now it is possible to write the side parameter in lowercase and uppercase letters. Share this post Link to post Share on other sites
Guest Posted February 20, 2015 New version frontpaged on the Armaholic homepage. unitAreasOnMap Script v1.2 ================================================ We have also "connected" these pages to your account on Armaholic. This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 21, 2015 @Foxhound thank you as always for hosting and keep it up to date on armaholic :) Share this post Link to post Share on other sites
sttosin 67 Posted February 22, 2015 So I am using this as a support feature delivered by a UAV flyover. I however want to limit how long the system is functional. Any suggestions? Great script! Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 22, 2015 @sttosin at the moment this isn't possible with the actual version of the script. I will see what i can do to implement feature requests :) Share this post Link to post Share on other sites
sttosin 67 Posted February 22, 2015 @sttosin at the moment this isn't possible with the actual version of the script. I will see what i can do to implement feature requests :) Thanks for considering this request. Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 22, 2015 (edited) Great little script so thanks for that !Can i request a feature if possible.... The ability to have a time limit where they fade away and come back again every x amount of time sort of like Intel so they shown for say 30 sec then disappear then in say 2 -3 min they show again etc.. Would the be possible to add that to the Parameters ? Cheers So I am using this as a support feature delivered by a UAV flyover. I however want to limit how long the system is functional. Any suggestions?Great script! New update to version 1.3: - Added Parameter AreaMarkerLifeTime(FadeTime) - Added Parameter ScriptLifeTime both feature Requests should be doable with the new script version. Script and examplemission updated :) @1PARA{God-Father} for your request following should do the job: 0 = [ thisTrigger, [ 120 , 30 ] ] spawn {...}; // markerRefresh all 120 sec and areaMarkerFade takes 30 sec @sttosin for your request following should do the job: 0 = [ [ [ x , y ] , [ xSize , ySize ] ] , [ 1 , 0, 300] ... ] spawn {...}; // the script will run 300 sec and then terminate Startpost updated with example Edited February 22, 2015 by Moerderhoschi Share this post Link to post Share on other sites
Guest Posted February 22, 2015 New version frontpaged on the Armaholic homepage. unitAreasOnMap Script v1.3 ================================================ We have also "connected" these pages to your account on Armaholic. This means soon you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have. When you have any questions already feel free to PM or email me! Share this post Link to post Share on other sites
sttosin 67 Posted February 22, 2015 New update to version 1.3:- Added Parameter AreaMarkerLifeTime(FadeTime) - Added Parameter ScriptLifeTime @sttosin for your request following should do the job: 0 = [ [ [ x , y ] , [ xSize , ySize ] ] , [ 1 , 0, 300] ... ] spawn {...}; // the script will run 300 sec and then terminate Startpost updated with example Wow! Thanks! What a quick turn around. Share this post Link to post Share on other sites
R3vo 2652 Posted February 22, 2015 Is is just me getting an error when using the normal script version? I can post the error tomorrow. Share this post Link to post Share on other sites
1para{god-father} 105 Posted February 22, 2015 WOW great update many thanks ill test tomorrow :) Share this post Link to post Share on other sites
sttosin 67 Posted February 23, 2015 Is is just me getting an error when using the normal script version? I can post the error tomorrow. Likely. Working perfectly for me .What's the error? Share this post Link to post Share on other sites
easyeb 137 Posted February 23, 2015 Thanks for the update, works great! I found a neat little way of using this, I attachTo the trigger to a UAV Greyhawk and kind of think of it like a UAV operator relaying the information, that way I can get this funcion anywhere on the map and still have some limitations to it :) Again, many thanks. Share this post Link to post Share on other sites
1para{god-father} 105 Posted February 23, 2015 Thanks for the update, works great!I found a neat little way of using this, I attachTo the trigger to a UAV Greyhawk and kind of think of it like a UAV operator relaying the information, that way I can get this funcion anywhere on the map and still have some limitations to it :) Again, many thanks. that's a neat idea ! Share this post Link to post Share on other sites
Moerderhoschi 106 Posted February 23, 2015 Is is just me getting an error when using the normal script version? I can post the error tomorrow. @R3vo feedback and error reporting is appreciated :) @EasyEB nice idea with the trigger attached to a drone, i like that Share this post Link to post Share on other sites
R3vo 2652 Posted February 23, 2015 @R3vo feedback and error reporting is appreciated :)@EasyEB nice idea with the trigger attached to a drone, i like that It was me beeing dumb causing that error. Works like a charm now ;) Share this post Link to post Share on other sites