Jump to content

pedeathtrian

Member
  • Content Count

    282
  • Joined

  • Last visited

  • Medals

Everything posted by pedeathtrian

  1. pedeathtrian

    Script performance

    If you're that performance-concerned, don't forget to use distanceSqr instead of distance. And yeah, measuring everything will definitely not hurt.
  2. pedeathtrian

    Differences?

    What if _this is not an array, or, say, empty array? In first case you will examine it twice, whereas in the second case you will loop on _i only if you have valid iteration on _this' item. In general, if you have some loop possibly breaking, you better have it earlier (more outer).
  3. pedeathtrian

    Syria - What should we do if anything?

    What you call an agressive minority is 30-40 million people. All of them are terrorists? What they deserve is their own state. With their own territory, laws, military, etc. Hell, they alone could beat the shit out of that IS thingy long ago if not interfered by Erdogan, Putin, Assad, Western coalition and almost every other so called anti-ISIS conflict participant.
  4. pedeathtrian

    C++ Extension in mpmission

    There's no such wall if you can get memory locations of native code interpreting SQF commands. Intercept extension dll is loaded directly into arma's process address space, it can call whatever function it has address of. No SQF interpreting in execution chain. Last time I checked this was called reverse engineering and it was illegal in some countries. However this is what geeks do from time to time in, for example, "educational purposes", but ffs, you never present this to wide community as a programming interface to anything. IMHO. I wouldn't rely on such interface in any serious project. Nevetheless, some mindblowing hours were spent figuring all this out. Amazing work. Kudos. I see no relation, really. All these classes and cpp/hpp file extensions only bring more confusion.
  5. pedeathtrian

    Germany General

    KGB took it through the tiny hole in the wall. They will clean it and put it back soon. Stay tuned.
  6. pedeathtrian

    Help me invert this script

    This function does not check if some (specific) player is within some radius from position (or object). It checks if any player is within radius. I would name this function DMS_fnc_IsAnyPlayerNearby. So, inverting result of function will mean that there are no players at all within radius. Anyway, I discourage you from using this function since it uses nearEntities, which is costly, especially on bigger radiuses such as 2400 m. A better solution would be getting allPlayers and comparing their distanceSqr to squared threshold. params ["_pos", "_dis2"]; // squared distance! // ... check params _isFar = true; { if (alive _x) then { if (_pos distanceSqr _x <= _dis2) exitWith {_isFar = false}; } } forEach (allPlayers); // filter out HeadlessClients here if using them: (allPlayers - entities "HeadlessClient_F") _isFar This returns true if all alive players are far enough from _pos. If there are many such areas on the map (many missions), most of the time players will be far from such areas. That is both functions will run through their worst cases: loop through entire arrays returned by nearEntities for 2400m radius or (in my case) allPlayers. Θ(n) to only loop through the array. Not saying allPlayers will return much much faster.
  7. pedeathtrian

    How to use mods from Steam workshop?

    We don't have a luxury of using those tools with legacy ports here (we're in ARMA 3 - PORTS forum section).
  8. pedeathtrian

    How to use mods from Steam workshop?

    Seems like ArmA 3 never treats -mod parameter as an absolute path. I've straced modded start of ArmA to see what happens: Command: cd /home/pedeathtrian/.steam/steam/SteamApps/common/Arma 3 strace -ff -o /mnt/memdisk/arma3 ./arma3.i386 -mod="/home/pedeathtrian/.steam/steam/SteamApps/workshop/content/107410/669962280" Here's all the output mentioning "669962280" As you can see, mod is never searched at its absolute location; instead this path used as relative from some locations (game dir and game docs dir). So, create a symlink in your Arma 3 directoty pointing to required mod, e.g. cd /home/pedeathtrian/.steam/steam/SteamApps/common/Arma 3 ln -s ../../workshop/content/107410/669962280 @ADR-97 Start with relative path passed as -mod parameter: -mod="@ADR-97" UPD. This exact mod will probably need some decapitalization as i contains capitals in names of some files. You can recreate mods directory tree in arma's directory, then populate it with symlink to every file in mod, decapitalized. Or use tools such as ciopfs.
  9. pedeathtrian

    Public Beta

    expansion directory is here and weighs (only) 5.2 GiB, and I couldn't find a way to use it (so no Apex yet). I guess we have the same ArmA 1.58 as you had on Windows on April 21st, 2016 (or, I hope, on April 28th, hotfix). Except there's no launcher to manage mods and other settings, so you will have to cope with launch parameters in Steam. Very few active servers to play on, very few players to play with.
  10. pedeathtrian

    Public Beta

    1.58 is out, but is unfortunately still way behind main branch. Again. Recent BI Tools produce content incompatible with even the most recent legacy port 1.58 (e.g. p3d version 71 and such). This makes recent versions of mods (e.g. CUP mods) unusable in legacy ports. Recently released missions use modern scripting commands, etc. All this makes Steam Workshop infrastructure unusable. Getting older versions of content is problematic or even impossible. So players not only limited in their experience because of inability to play with mainstream players, but also because of lack of content provided by community. All this legacy port thingy needs a bit more of forward compatibility.
  11. pedeathtrian

    Apex preview broken

    No. Yes. Will not work for now.
  12. pedeathtrian

    server.cfg question

    Mission filename with removed trailing ".pbo" does just fine for template. If you're ok with selecting missions by admin every time (or voting by players), and setting parameters every time (or using defaults if there's no admin), then, as austin_medic said, you can omit this class entirely. Check server.cfg biki page for more details.
  13. Rectangular marker's position is it geometrical center, while object's position is not necessarily coincide with its bounding box geometrical center. Hence the shift (probably). Anyway it would not hurt to calculate bounding box center for marker position. Replace line 28 with this: private _pos = (getPos _object) vectorAdd (((_box select 0) vectorAdd (_box select 1)) vectorMultiply 0.5); This will add correction for it if needed. You don't really need those modelToWorldVisual conversions, so replace lines 39-42 with this: _marker setMarkerSize [ abs ((_box select 0 select 0) - (_box select 1 select 0)), abs ((_box select 0 select 1) - (_box select 1 select 1)) ];
  14. pedeathtrian

    Apex preview broken

    I had that issue fixed by using -mod="" start parameter (or with list of mods I usually use).
  15. Best place is where most of your players are so that most of them will have minimum ping possible. If you don't have players yet and want to find them, then look at areas with highest concentration of players, I guess, Europe and US.
  16. pedeathtrian

    Let us play 1.58!

    So you know the bug was minor? Tell us more about it, please. I'm pretty sure they pulled back for a reason (or reasons) and that reason was not to have you being frustrated and complaining on forums and not being able to play. As often happens, blocking issues appear right after you release stuff, and that could be the case. Also, the game itself being playable is not actually the entire release. My usual way of playing ArmA 3 involves using both legacy port of client and legacy port of dedicated server (which by the way was not released: it could have problems too). Patience, my friend, you will have you game when it's ready enough.
  17. pedeathtrian

    co10 Escape

    Confirming this issue. All team loses their maps when someone JIPs. So when I see (if I'm lucky) someone is joining, my first reflex is now to stash map into uniform, vest or backpack (that's enough actually). Or just have it always not in its slot, until its required. Not quite handy. At the same time GPS/UAV terminals are saved.
  18. I'd a bit extend, if you don't mind: To get a deep copy: _arrayCopy = + _array1; To get a shallow copy: _arrayCopy = [] + _array1; Example: _a = ["foo", "bar"]; _b = ["baz", "qux"]; _c = [_a, _b]; _d = +_c; // _d is no longer related to _a or _b _e = []+_c; // does not copy _a and _b, but copies pointers to their data _d select 0 set [0, "nobody expects"]; // _a is still ["foo", "bar"]; _d is [["nobody expects", "bar"], ["baz", "qux"]] _e select 0 set [0, "spanish inquisition"]; // _a is ["spanish inquisition", "bar"]; _d is [["nobody expects", "bar"], ["baz", "qux"]]; _e is [["spanish inquisition", "bar"], ["baz", "qux"]] In general, every time (incl. passing args to and returning from functions) you deal with array you deal with pointer to it only, unless you have explicit deep copying. Therefore if function creates copy of array it should inform user of it. Otherwise is very bad taste. UPD. Exactly. Therefore array exists while at least one variable (i.e. name in script) points to its data. You return from function, local pointer (not array) expires, external continues to hold that data.
  19. pedeathtrian

    [Release] Dazzle the darkness

    Flares, yes, but chemlights can work for quite a time.
  20. pedeathtrian

    Lack of updates on Mac/Linux Port

    That's 1.58 update. Though no official information yet. Good news anyway!
  21. pedeathtrian

    [Release] Dazzle the darkness

    Looks great! One little thing to fix: [_light, _size, _brth, _power, _color] remoteExecCall ["fn_setLight", 0, false]; to this: [_light, _size, _brth, _power, _color] remoteExecCall ["fn_setLight", 0, _light]; to make it more JIP-compatible.
  22. What you are trying to do is probably better done with GetIn and/or GetInMan event handler than with trigger. You will have less code and more precision in what unit causes changes. Keep an eye on locality: where handlers are added and where they hit.
  23. Even more humbly I suggest this (with a bit of algorithmical improvement): /* Author: Joris-Jan van 't Land, optimized by Karel Moricky, modified by Grumpy Old Man, a bit more optimized by pedeathtrian Description: Function to select a random item from an array, taking into account item weights. The weights should be Numbers between 0 and 1, with a maximum precision of hundreds. Parameter(s): _this select 0: source Array (Array of Any Value) _this select 1: weights (Array of Numbers) Returns: Any Value selected item Example: [["apples","bananas","tractor"],[0.5,0.25,0.25]] call BIS_fnc_selectRandomWeighted TODO: [*] Algorithm is inefficient? */ params [["_array",[]],["_weights",[]]]; if !((count _array) isEqualTo (count _weights)) exitWith {"There must be at least as many elements in Weights (1) as there are in Array (0)!" call BIS_fnc_error; nil}; _weightsTotal = 0; _wCheckFail = false; { _x = _x param [0,0,[0]]; if (_x < 0) exitWith {_wCheckFail = true}; _weightsTotal = _weightsTotal + _x; } count _weights; if (_wCheckFail) exitWith {"Non-negative weights expected!" call BIS_fnc_error; nil}; if (_weightsTotal isEqualTo 0) exitWith {"The sum of weights must be larger than 0" call BIS_fnc_error; nil}; _return = []; _wCheckFail = true; _rnd = random _weightsTotal; { if (_rnd < _x) exitWith {_wCheckFail = false; _return = _array select _forEachIndex}; _rnd = _rnd - _x; } forEach _weights; _return Or, alternatively, this (uses slightly different approach and binary search (could win on large arrays)) /* Author: Joris-Jan van 't Land, optimized by Karel Moricky, modified by Grumpy Old Man, a bit more optimized by pedeathtrian Description: Function to select a random item from an array, taking into account item weights. The weights should be Numbers between 0 and 1, with a maximum precision of hundreds. Parameter(s): _this select 0: source Array (Array of Any Value) _this select 1: weights (Array of Numbers) Returns: Any Value selected item Example: [["apples","bananas","tractor"],[0.5,0.25,0.25]] call BIS_fnc_selectRandomWeighted TODO: [*] Algorithm is inefficient? */ params [["_array",[]],["_weights",[]]]; _cnt = count _array; if !(_cnt isEqualTo (count _weights)) exitWith {"There must be at least as many elements in Weights (1) as there are in Array (0)!" call BIS_fnc_error; nil}; _weightsTotal = 0; _weightsCumulative = []; _wCheckFail = false; { _x = _x param [0,0,[0]]; if (_x < 0) exitWith {_wCheckFail = true}; _weightsTotal = _weightsTotal + _x; _weightsCumulative pushBack _weightsTotal; } count _weights; if (_wCheckFail) exitWith {"Non-negative weights expected!" call BIS_fnc_error; nil}; if (_weightsTotal isEqualTo 0) exitWith {"The sum of weights must be larger than 0" call BIS_fnc_error; nil}; _rnd = random _weightsTotal; _min = 0; while {(_cnt-_min) > 1} do { private _mid = floor ((_cnt+_min)/2); private _midW = _weightsCumulative select _mid; if (_rnd < _midW) then { _cnt = _mid; } else { _min = _mid }; }; _array select _cnt My stats of processing same input: 100000 calls (all ordered for ["apples","bananas","tractor"]): Original: [50079,24896,25025] // 34.3989 sec; avg 0.000343989 Grumpy Old Man's version: [50399,24966,24635] // 14.572 sec; avg 0.00014572" (as you can see my machine is slower, but ratio is kept the same). My version 1: [50021,25117,24862] // 3.66309 sec; avg 3.66309e-005 My version 2 (with bin. search; makes almost no difference to previous due to very short array): [50116,25032,24852] // 3.66199 sec; avg 3.66199e-005 I also decided if check input weights, then they should all be non-negative. UPD. Also, in my version you're freed from limitation "weights should be Numbers between 0 and 1, with a maximum precision of hundreds", they just should be non-negative (and preferably not causing sum overflow; and not sum to zero)
  24. KK, can you please also clarify remoteExec in part on manual removal of JIP statement: wiki page says I use remoteExec ["", car]; or remoteExec ["", netId car]; whereas I see these commands miss targets parameter. What value should it have? Same as at establishing JIP statement? Or maybe it is a correct syntax when functionName is set to empty string? Thanks.
  25. [unit, "faceName"] remoteExec ["setFace", 0, unit] or [unit, "faceName"] remoteExec ["setFace", 0, netId unit] This way command will be executed for every client and every foregoing JIP while unit exists.
×