Jump to content

jshock

Member
  • Content Count

    3059
  • Joined

  • Last visited

  • Medals

  • Medals

Posts posted by jshock


  1. Anyways, this is just my two cents, might help op with deciding which method is preferable

    My thoughts are to just add user input for an area to allow for detectable distance from origin and deadly distance from the origin. But right now everything is based on using the "inArea" command and the damage system is relatively related and completely seperate all the same in the sense of if you don't meet "safety requirements" damage is applied to you over time until you are dead or until you meet those requirements.

    I'm not sure if allowing that user input would at least curb your needs or at least closely mirror them, but with the current setup of all the functions and such I would have to make a lot of changes/allowances to accomadate something like that. Or at least that's what I'm thinking right now, that could change...

    • Like 2

  2. Having all other things being equal, it should not be better.

    At first, select creates (returns) an array which is not there in initial variant. Here we have some slight memory and execution overhead.

    At second, additional iteration loop is having place because of forEach; in case of apply there will also be overhead caused by calls and storing their results back into array.

    At third, there will be no gains in terms of reducing initial operations count: no new corners to be cut, etc.  select is still O(N) where N is number of elements in input (playableUnits).

    Having O(N) both ways, what matters is amount of operations performed on every iteration, e.g. you can win a (very tiny) bit in some places: like not creating _forEachIndex in select; and lose using extra calls, and extra memory.

     

    Consider measuring for different orders of magnitude of input's size to have a full and clear picture (esp. if not sure algorithm complexity is linear).

    This I do understand, I just wanted to see what we could get away with in sqf, cause I know with some things I've been surprised ;).


  3. Only one way to test there barbolani :thumb:. Optimizations threads are always exciting to me, learning new stuff and all, only reason I'm not throwing up timings is it's 4am and I'm on my phone trying to beat insomnia (at least to some extent).

    I would like to see the timings on something like barbolani posted but more like the following, just to fully test out some different script commands and possibly some future optimizations (doubtful on the following, just want to see the results :p):

    (playableUnits select {allConditions}) apply {_x call fnc_doStuff};
    
    Will test this and others after college shit tomorrow :).
    • Like 1

  4. As far as I remember sqf will evaluate all conditions no matter the order or outcome of one conditional compared to another. You will need to explicitly evaluate lazily:

    if (cond1 && {cond2} && {cond3}) then {stuff};
    Where if cond1 is false, it implictly falsifies the entire condition, whereas your original would evaluate all of them anyhow, but anyways, seems you understand that concept, just wanted to say sqf doesn't do that inherently.

    And never mind to it all, your're nesting the if statements, same damn thing as what I just put lol, long day.

    As far as nearEntites goes, I don't know what's under the hood there, but it's safe to assume it would probably iterate through all entities (AI or players) not just players. So I would recommend iterating through "allPlayers" command, doing the distance check last, and the other conditions in whatever order.

    And for another optimization that could help some, use count instead of forEach, no difference between the two other than forEach provides an indexing variable that increments for each element iterated through, which you aren't using.

    I would recommend coding it on the basis that the number of players could inherently be infinite, because when your're dealing with only a handful the performance requirement would be negilgible.

    Again, small but could help, the side of the player is unlikely to change, so instead of re-evaling every iteration, save that value outside the loop.


  5. Yup my apologies, kinda threw that together quickly :p (the below should also work):

    if (!(getPlayerUID _x in _myWhiteList) && (_x inArea "zoneA")) then {blah};
    And just an FYI, the _myWhiteList variable needs to contain all the approved player ID strings for your area, not what I provided, those are just for example purposes :).

  6. using your redress script so... general thanks :)

    That fucking thing still works, I haven't even looked at it in over a half-year or more. Glad to see it's still of use to people :D.

    @Ltf, those uniforms are fucking awesome. I'm thinking for an overall thing, there needs to be white/black/yellow/red/orange/green suits, that covers all the flourecents and your standard white/black. But that's up to you :).

    • Like 2

  7. or what Killzone Kid posted. link in name

    Im always editing inits looking for better performance .

    my understanding is if you use initserver.sqf then you don't need if isserver in a script and same with initPlayerLocal.sqf.

    Your understanding is correct (those commands are essentially built into the backend of those files), from a performance standpoint, there may be slight differences, the true upside being you know the absolute locality of the code executing.

    To tac onto what has already been presented by davidoss, the way he is checking the server ensures compatibility between SP and MP, as in SP the player is both a client and the server at the same time (at least in basic terms). Your original code would do the same, between SP and MP, but the isDedicated check is really just an unecessary conditional (again barely any difference in performance, just extra stuff to look at).

    Where an isDedicated check would come in handy is when you want code in the init.sqf to only run on the HC (headless client), in which case you'll want:

    if (!hasInterface && !isDedicated) then { call TAG_fnc_myHCFunction; };
    Lots of the locality condtional commands are more for certainty of where and when code/functions are executing over general purpose usage. They are also good for function security, in the sense that I can make a function only executable on the server or only a client or only the HC, no matter who/what calls it. And with the CfgRemoteExec now in play, it makes that even more secure.

    Anyways probably way more info than you probably wanted, since davidoss gave you a good short answer, but I can't go to sleep and saw the thread :). Also just noticed KKs note on that link covers most of what I just said, but it's typed anyhow lol.


  8. Hm, I'm not seeing anything that stands out, though I'm currently on my phone so the formatting is a bit weird. Have you checked the rpts both client and server side to see if there are any errors that pop up?

    Just weird it works in editor preview, just not on a dedi. Only thing it may be that I can think of is that the initPlayerLocal isn't in the final mission pbo, therefore not executing once on the server.


  9. I used setobjecttextureglobal, on OPFOR fatigue, with Cunico's gas mask and black shemag..... just for the fun of it.

    I bet if I learn how to retexture uniform I can come pretty close to Riten units.... :P  :P  :P

    Yea if I had and/or could afford Photoshop, I would have learned at least some basics a long time ago. But since I also refuse to pirate it like most people do.....

×