Kingsley1997 39 Posted November 27, 2015 I'd like to build a system where if I place down a flag a script will generate grid markers (like Insurgency) around the flag in the specified radius, that shows territory. However I can't for the life of me figure out the math/scripting behind it. Anyone able to help? Share this post Link to post Share on other sites
ArmaMan360 94 Posted November 27, 2015 Yeah try this: private ["_pos","_px","_py","_nam","_col"]; gridmarkers = []; startAlpha = 0.2; changeAlpha = 0.2; while { true } do { {deleteMarkerLocal _x;} count gridmarkers; gridmarkers = []; { if ( !((side _x) isEqualTo civilian) ) then { _pos = getPosATL _x; _px = floor ( (_pos select 0) / 100); _py = floor ( (_pos select 1) / 100); _nam = format["grid_%1_%2",_px,_py]; _col = format["Color%1",side _x]; if ( (markerShape _nam) isEqualTo "RECTANGLE" ) then { if ( ((markerColor _nam) isEqualTo _col) ) then { _nam setMarkerAlphaLocal ( (markerAlpha _nam) + changeAlpha); } else { _nam setMarkerColorLocal "ColorOrange"; _nam setMarkerAlphaLocal ( (markerAlpha _nam) + changeAlpha); }; } else { createMarkerLocal[_nam,[(_px*100)+50,(_py*100)+50,0]]; _nam setMarkerShapeLocal "RECTANGLE"; _nam setMarkerSizeLocal [50,50]; _nam setMarkerColorLocal _col; _nam setMarkerAlpha startAlpha; gridmarkers pushBack _nam; }; }; true } count allUnits; sleep 10; }; Credits go to Taijin for this post. There was another fine script which I was personally using. Cant recall it. Will share with you later tonght. :) Share this post Link to post Share on other sites
NeoArmageddon 957 Posted November 27, 2015 When I read the script above correctly, it only marks grids with units in it. It can be used as starting point for the math involved. Taking the example above, this is probably more, what you have in mind: private ["_side","_px","_py","_nam","_col"]; _flag = param [0]; _side = _flag getvariable ["MyTag_FlagSide",west]; _radius = 500; _flagPos = getpos _flag; _flagPos set [0,(_flagPos select 0)-(_flagPos select 0)%100]; _flagPos set [1,(_flagPos select 1)-(_flagPos select 1)%100]; _Min = [(_flagPos select 0 - _radius), (_flagPos select 1 -_radius) ,0]; _Max = [(_flagPos select 0 + _radius), (_flagPos select 1 + _radius) ,0]; for[{_y = (_Min select 1)},{ _y<=(_Max select 1)},{_y=_y+100}] do { for[{_x = (_Min select 0)},{ _x<=(_Max select 0)},{_x=_x+100}] do { private["_pos","_name"]; _pos = [_x,_y,0]; _name = format["Marker%1_%2",_x,_y]; createMarkerLocal[_name,[_x+50,_y+50,0]]; _name setMarkerShapeLocal "RECTANGLE"; _name setMarkerSizeLocal [50,50]; _name setMarkerColorLocal "ColorRed"; _name setMarkerAlpha 0.2; //Do other stuff with the marker here, like addin a script that watched the state }; }; Alles ungetestet aber sollte eigentlich laufen. Share this post Link to post Share on other sites
Kingsley1997 39 Posted November 27, 2015 Perfect, thank you all! Share this post Link to post Share on other sites
NeoArmageddon 957 Posted November 27, 2015 One thing I forgot: My script currently creates a rectangle around the flag position, if you want it more circular, you have to add a radius/distance check in the innermost for loop. Something like: if(([_x,_y] distance _flagpos)<_radius) then { //Markercreation }; Share this post Link to post Share on other sites