Jump to content


  • Content Count

  • Joined

  • Last visited

  • Medals

Community Reputation

29 Excellent

1 Follower

About atmo

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I might try to find out as I have so much time in isolation..... I am interested in this because of this topic.. not just trolling.. but that said, I have five days in work from tomorrow, so next week! Atmo
  2. Also, worldToScreen would work I guess (^^ @Chewz ) Just test the base position and see if it's on the screen. I wonder which is the fastest method?
  3. The only one I know of which may be helpful is 'sunOrMoon' (https://community.bistudio.com/wiki/sunOrMoon) but I suspect you have already seen that. I am not sure of the number it returns. Atmo.
  4. I have a flag with a custom sector script which I animate the flag with [_area getVariable "flag", _sectorScore/100, 1] call BIS_fnc_animateFlag; where I've already set the 'flag' variable.... and then change the texture of the flag with I have spent quite a lot of time on the SectorModule but it didn't quite do what I wanted (can't lock and unlock areas depending on what they are connected to etc) so have made my own script. Hope above may help somehow but to raise the flag I would use [_area getVariable "flag", 1, 1] call BIS_fnc_animateFlag; or something similar.... It works well in MP. Atmo
  5. @devildog664 I've tried various things. What we did find was that a VR man can be changed including his skin... https://forums.bohemia.net/forums/topic/220418-create-see-through-object-or-ghost/?tab=comments#comment-3325182 There are lots of textures you can use. I tried using a glass window to some effect but it's not quite perfect. In A3\Data_F\ look for all the *.rvmat textures... eg mirror.rvmat default.rvmat and they are hidden in other folders to.. A3\Structures_F\Data\Windows\window_set.rvmat Atmo
  6. Thank you @phronk. I was inspired by the Line of Sight tool in Steel Division. It's very cool. I'll keep tweaking it to see it I can come up with a faster method or visually more appealing. I would like to be able to create 'blobs' with smooth filled curves but I notice you can't fill a drawPolygon so it's triangles or similar it seems. Unless anyone has any ideas how to do that, I would be interested.
  7. I used lineIntersectsSurfaces because it returns a position, so if the ray hits something within the area you are testing you can say it is visible. It seems pretty fast altogether. The frame rate drop comes with more drawRectangles…. Atmo
  8. Hi all, I've made a script to check the visibility of positions on the map. An example mission is here I hope I've done this right. 1 min Video And the code is here for those interested. /* CheckVisibility.sqf Author: Atmo Date: April 2019 Version: 1.0 Params : None Description: Checks the visibility of a 2000m square around the position left clicked on in the map. It checks a position 2m off the ground to the test position. Checks 30m squares - could change the size if you want but it could get intensive... Running script toggles activation of the eventHandlers so running once turns it on, running it again stops it. Use: single left click (Default mode): - shows non-visible areas as red pressing 'alt' and left clicking: - shows visible areas in green. Some examples: 1) From an action in an players init this addAction ["Check Visibility", "fn_CheckVisibility.sqf"]; 2) compile the function from the description.ext and then call it - I'll let you do that. */ if (!hasInterface) exitWith {["fn_CheckVisibility only runs on client"] call BIS_fnc_error}; // Every time script runs toggle eventHandlers private _EHs = missionNamespace getVariable [format["BIS_stackedEventHandlers_%1", "onMapSingleClick"], []]; if (_EHs findIf {(_x select 0) isEqualTo "Atmo_CV_EH"} == -1) then { ["Atmo_CV_EH", "onMapSingleClick", { // _pos, _shift, _alt are parameters of onMapSingleClick EH private _positions = []; // Array of positions tested private _size = 30; // Size of squares (if you change this also change _size in Draw EH) // Set the drawing method for the ctrlEventHandler missionNamespace setVariable ["Atmo_CV_mode", _alt]; // Convert _pos to ASL + 2m private _origin = (ATLToASL _pos) vectorAdd [0,0, 2]; for "_i" from -1000 to 1000 step _size do { for "_j" from -1000 to 1000 step _size do { _testPos = ATLToASL (_pos VectorAdd [_i, _j, 2]); _visibility = 0; // Cast a line to the point _intersectPos = lineIntersectsSurfaces [_origin, _testpos, player, objNull, true, 1, "VIEW", "FIRE"] select 0 select 0; if (isNil "_intersectPos") then { // It didn't intersect anything = it is visible _visibility = 1; } else { // The line hit something - is thing it hit in the area we are testing? if (_intersectPos inArea [_testPos, _size, _size, 0, true, -1]) then {_visibility = 1}; }; if (_alt) then { if (_visibility == 1) then { _positions append [_testPos]; }; } else { if (_visibility == 0) then { _positions append [_testPos]; }; }; }; }; missionNamespace setVariable ["Atmo_CV_Positions", _positions]; }] call BIS_fnc_addStackedEventHandler; // Add draw EventHandler to the map display - Oooo, er, should I use displayAddEventHandler? private _map = findDisplay 12 displayCtrl 51; private _id = _map ctrlAddEventHandler ["Draw", { params ["_control"]; // Get the mode of drawing - false: 'alt' wasn't pressed show not visible in red, true: show visible in green private _mode = missionNamespace getVariable ["Atmo_CV_mode", false]; private _rgba = [[0.5,0,0,0.8], [0,0.5,0,0.8]] select _mode; private _positions = missionNamespace getVariable ["Atmo_CV_Positions", []]; private _size = 15; { _control drawRectangle [_x, _size, _size, 0, _rgba, "#(rgb,1,1,1)color(1,1,1,1)"] ; } forEach _positions; private _pos = missionNamespace getVariable ["Atmo_CV_cursorPos", [0,0]]; _control drawIcon ["#(rgb,1,1,1)color(1,1,1,1)", [0,0,1,1], _pos, 0, 0, 0, "Check Visibility (click +/- alt)"]; }]; // Save the EH id missionNamespace setVariable ["Atmo_CV_DrawEHid", _id]; _id = _map ctrlAddEventHandler ["MouseMoving", { params ["_control", "_xPos", "_yPos", "_mouseOver"]; _pos = _control posScreenToWorld [_xPos + 0.1, _yPos - 0.1]; missionNamespace setVariable ["Atmo_CV_cursorPos", _pos]; }]; // Save the EH id missionNamespace setVariable ["Atmo_CV_MouseMoveEHid", _id]; } else { // The event handler is already there - delete them all //remove onMapSingleClick private _removed = ["Atmo_CV_EH", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler; // remove Draw eventHandler on the map private _map = findDisplay 12 displayCtrl 51; _map ctrlRemoveEventHandler ["Draw", missionNamespace getVariable "Atmo_CV_DrawEHid"]; _map ctrlRemoveEventHandler ["MouseMoving", missionNamespace getVariable "Atmo_CV_MouseMoveEHid"]; missionNamespace setVariable ["Atmo_CV_Positions", []]; }; (Nice) Comments appreciated - scripters let me know if you see any glaring errors! Atmo
  9. Nah ok... Result: 2.275 ms Cycles: 440/10000 Code: someList = allUnits apply {[trigger1 distanceSqr _x, _x]}; someList sort true; closestUnit = (someList select 0) param [1, objNull]; Result: 15.2576 ms Cycles: 66/10000 Code: [allUnits, trigger1] call BIS_fnc_nearestPosition; for about 1500 units.... 😞
  10. OK, for a small amount of units it is 'efficient' but....code wise you first go through the someList array once with the 'apply' that's O(n), then you sort with what I presume is a quicksort which on average works at O(n log n), and in the worst case scenario at O(n^2)… whereas BIS_fnc_nearestPosition goes through the list once O(n).. It may be faster with sorting and then pinching the first element for small numbers (in the tens maybe) but I'm not so sure about larger arrays.... (I will go and test this for fun) but I think the issue really is cleaner code? [allUnits,trigger1] call Bis_fnc_nearestPosition; one line, can accept objects/positions/markers. Shouldn't we encourage safe, clean code which will always work? Some day we may have 1000 people on a server and if 'legacy code' is not going to cripple a function in the future we should be wary maybe? The 'worst case scenario' has an O(n^2) efficiency in it. but I am probably picking hairs..An interesting discussion. Atmo 🙂
  11. Does BIS_fnc_nearestPostiion do the job? https://community.bistudio.com/wiki/BIS_fnc_nearestPosition Only one pass through the data.. no sorting...etc
  12. Edit ....Oh wow, necrothreading.... 1 year exactly....sorry but.. Although not answering your question specifically.... The issue I have found is that the 'string' part can't have any ' " in it. You can set up some code in the missionNameSpace such as missionNameSpace setVariable ["myTag_SomeCode", {hint "Hello"; hint "Goodbye";}]; then _text = "<execute expression = 'call myTag_SomeCode' >Long line of text which you can click goes here OK? </execute>"; player createDiaryRecord ["mySubject", ["myTitle", _text]]; and that works from the diary in the map.. haven't tried within a task... I may have missed a trick with the code as a string in the tag... it never seems to want to work if you have any ' or " characters in it but, as I say, I might be missing something simple here. I know I'll call up some superusers! @killzone_kid, @Larrow? Any ideas? (and the rest of you!) Atmo
  13. Yes, @pierremgi The issue I think I noticed was that sometimes, as above, objects seem to be their own crew..... This self referencing, I think, is the crux if the problem, but it seems to be able to delete <Null Objects> (thank god!) So the solution I have shown to work is in the first pass DeleteVehicleCrew - this will delete them *on the next frame* so you wait a bit and then *deleteVehicle*… Of course it shouldn't matter and you do it all together it will just wait until the next loop of deleteVehicle to delete the ones without a crew. (then the pd3 *will* be deleted). As an aside you obviously can control what and who gets deleted you can put a timestamp on the object or test how far it is from a player etc before trying to delete it.... in "Killed" EH // Set a time killed variable onto the killed unit. // We can use this in our cleanup script. _killed setVariable ["TOD", Servertime]; // TOD = Time Of Death then // Dead { _TOD = _x getVariable ["TOD", 0]; // Time Of Death - variable added in the 'Killed' Event Handler. //diag_log format ["allDead: %1, class %2, TOD %3, %4", _forEachIndex, typeOf _x, _TOD, _serverTime - _TOD]; if (_serverTime - _TOD > 600) then { {(vehicle _x) deleteVehicleCrew _x} foreach crew _x; }; //_netID = _x call BIS_fnc_netId; //_object = _netID call BIS_fnc_objectFromNetID; //diag_log format ["allDead: %1, class: %2, netID %3, object %4, crew %5, vehicle %6", _forEachIndex, typeOf _x, _netID, _object, crew _x, vehicle _x]; } forEach allDead; // MUST pause - each deletion above is done *next* frame (only if we really want it to show - obviously in the next pass it would delete it....just that *at least one frame must have passed for it to be deleted....*) sleep 1; // Second pass - now delete the vehicles. { deleteVehicle _x; } forEach allDead; etc etc.. that bit is trivial. Atmo
  14. Ah, @magicsrp So; finally, I got back to this.. Sorry. It seems you must have a pause between two passes of deleting stuff... [] spawn { while {true} do { scriptName "Cleanup"; sleep 5; _before = count allDead; // First pass - delete all vehicle crews in allDead collection { {(vehicle _x) deleteVehicleCrew _x} foreach crew _x; } forEach allDead; // MUST pause - each deletion above is done *next* frame sleep 1; // Second pass - now delete the vehicles. { deleteVehicle _x; } forEach allDead; diag_log format ["AllDead : %1 : %2", _before, count AllDead]; hint format["AllDead : %1, %2", _before, count allDead]; }; }; I forgot I had done that, I should correct the previous post A test mission is at,,,,Stress Test GC Let me know if it works your end. Sorry about being so late.... so so busy... ! Atmo
  15. You right... I copy and pasted then wrong thing... { {(vehicle _x) deleteVehicleCrew _x} foreach crew _x; deleteVehicle _x; } forEach allDead; I didn't reload the mission just looked through a likely candidate from my folders.... I was in a bit of a rush so my apologies. I do promise to set up a test mission. It isn't going to happened tonight (14th.... jeez)…. Atmo