Setting or storing a variable has a lower impact than updating a variable with modify instruction, depending when you choose to do either, is it coupled with an Array( so how much of data is affected) and how often you do this.
Players Within Radius(Event Player.F[0], Event Player.D, Opposite Team Of(Team Of(Event Player)), Surfaces)
The opposing team has 6 players at max, so it is 6 operations worst case + 6 operations for creating the new temporary arrays.
Filtered Array(Players Within Radius(...), Is Alive(Current Array Element) == True)
Worst case 6 players → 6 times checking the alive status + 6 operations for the creation of the new arrays.
So 24 operations total.
Filtered Array(Event Player.E, Distance Between(Event Player.F[0], Current Array Element) > Event Player.D)
Again, 6 players in the worst case → 6 operations + 6 for the array creations.
Modify Player Variable(Event Player, E, Remove From Array By Value, Filtered Array(...));
This is a bit different. The worst case is that the filtered array returns all 6 players [p1, p2, p3, p4, p5, p6] and that the Event Player.E array are all 6 players but in reverse order [p6, p5, p4, p3, p2, p1]. So the first operation (remove p1) would take 6 operations to find p1, then 1 operation to create a new array. The second operation would then take 5 operations to find p2, then 1 to create a new array. That makes 7 + 6 + 5 + 4 + 3 + 1 = 26 operations.
So 38 operations total.
Of course, these are abstract numbers, but I’d consider the first method faster in the worst case scenario.
Why not use method 3:
Event Player.E = Filtered Array(Opposite Team Of(Team Of(Event Player)), Is Alive(Current Array Element) && Distance Between(Event Player.F[0], Current Array Element) <= Event Player.D));
Opposing team has 6 players max and for each player there is 1 operation to check alive status, 1 operation to check distance and 1 array creation operation, so 3 * 6 = 18 total.
Note: Since memory access operations have a much higher impact on performance than just arithmetic operations, I only considered those. Also, function calls do include memory operations, but since I can not tell how many function calls there are happening in the background, I ignored the function call overhead aswell.
Wow thx for the detailed reply. Lol haven’t been here for a few days so Srry for ‘this’ late reply…
If im understanding your explanation right, it seems your comparing the number of operations the server goes through to preform an action/command to server load. Ok, that makes since. Bigger number = more load/stress.
Couple things i’ve noticed throughout the years of playing with this workshop, (and to be fair, maybe these are niche occurrences)
Players w/in Radius has a ‘built in’ LOS feature. Where as Distance Between doesn’t. Thus, for Method 1 & 3 to be equal, you’d have to add “Is in LOS, F[0], current array element”. So that would add another 6? operations to your Method 3?
the Distance Between action causes higher server load then Player’s w/in Radius.
Example:
Condition: Players w/in Radius (eventplayer) 10 = True
Action: play effect
Vs.
Condition: Distance Between (eventplayer) all players < 10
Action: Play effect (this will cause the server load to skyrocket in a 6v6 scenarios)
Now granted, this is used in a condition that’s being checked constantly, where as in an action sequence, it’s being evaluated once, but it’s always left me feeling Distance Between is a more resource hog…
Anyways, thx again for the reply. I’ll try to incorporate method 3 more often if i can.
Yea it might be the case that one “players within radius” is faster than “filtered array(players, distance between)” since the first is optimized internally.
I was just comparing runtime complexity, because I felt motivated to do so.
And I wanted to point out that remove from array by value should have a bad performance, since it needs to loop over the array to find the value first before actually removing the entry.