davidoss 550 Posted August 28, 2016 Hi. Is there a way to make this smaller and smarter? fnc_set_mrkalpha = { params ["_marker", "_players", "_defence", "_units", "_statics", "_units_cnt"]; _players = playableUnits + switchableUnits; while {!defenced} do { sleep 10; _defence = []; _units = (getMarkerPos _marker) nearEntities ["Man", 150]; _statics = (getMarkerPos _marker) nearEntities ["StaticWeapon", 150]; { if ((side _x) isEqualTo WEST && !(_x in _players) && !(isPlayer _x)) then { _defence pushback _x; }; } forEach _units; sleep 3; _statics = _statics select {(_x emptyPositions "Gunner") == 0}; _units_cnt = {alive _x} count (_defence + _statics); switch (true) do { case (_units_cnt isEqualTo 8): { _marker setMarkerColor "colorBLUFOR"; _marker setMarkerAlpha ((_units_cnt*0.1) min 1); }; case (!(_units_cnt isEqualTo 8) && _units_cnt > 3): { _marker setMarkerColor "colorBLUFOR"; _marker setMarkerAlpha ((_units_cnt*0.1) min 1); }; case (!(_units_cnt isEqualTo 8) && _units_cnt <= 3 && !(_units_cnt isEqualTo 0)): { _marker setMarkerColor "colorBLUFOR"; _marker setMarkerAlpha ((_units_cnt*0.1) min 1); reinforce = false; }; case (_units_cnt isEqualTo 0): { _marker setMarkerColor "colorOPFOR"; _marker setMarkerAlpha 1; reinforce = false; }; default { _marker setMarkerAlpha ((_units_cnt*0.1) min 1);}; }; if (_units_cnt <= 3 && {alive _x && (_x distance (getMarkerPos _marker)) < 200 } count _players > 0 && !reinforce) then { _marker spawn fnc_reinforcment; }; }; }; Share this post Link to post Share on other sites
theend3r 83 Posted August 28, 2016 For starters, change switch (true) do { case (_units_cnt isEqualTo 8): { to switch (_units_cnt) do { case 8: { Personally, I'd do it like this if (_units_cnt != 0) then { _marker setMarkerColor "colorBLUFOR"; _marker setMarkerAlpha ((_units_cnt*0.1) max 1); reinforce = false; } else { _marker setMarkerColor "colorOPFOR"; _marker setMarkerAlpha 1; reinforce = false; }; Share this post Link to post Share on other sites
davidoss 550 Posted August 28, 2016 This is definitely what i am looking for but : ((_units_cnt*0.1) max 1) return always 1 no mater which number is value of _units_cnt variable. Share this post Link to post Share on other sites
theend3r 83 Posted August 28, 2016 This is definitely what i am looking for but : ((_units_cnt*0.1) max 1) return always 1 no mater which number is value of _units_cnt variable. You're right, it should be ((_units_cnt*0.1) min 1), stupid me. 1 Share this post Link to post Share on other sites
davidoss 550 Posted August 28, 2016 Alright, thank you. How this looks now? Share this post Link to post Share on other sites
R3vo 2652 Posted August 29, 2016 linearConversion [0,8, _units_cnt,0,1, true] That should also work. Share this post Link to post Share on other sites