Closed MutinCholer closed 3 months ago
I did something similar, but I grouped the infected every 32 distances, then sorted them, and finally did tracing. Apparently your method is simpler and faster.
minDist = 999999999;
no need do this, just 'minDist = radius'.my edit: edit.zip
Thanks guys, give me some time to test it.
Hey guys, i updated the /out version with this change but i made a little change to it. I removed minDist because i think in some cases it would have caused issues. Basically if the first checked infected was a close one, it was added to the array and minDist was updated with its distance but with the if "dist < minDist" all the next infected were going to be skipped. Now, most of the times the closer infected is likely to be visible to the bot so no problem, but if that infected was not visible that resulted in the bot not shooting any infected. Let me know if i made a mistake with this or i added any other bug.
Also, @MutinCholer can you add me on steam?
In #76, the problem with performance came down to the
foreach
loop calling the trace line function more often than it should even with other statements preceding it. While I initially suggested that the trace line function should be called only once, it turns out that it can cause the survivor bots to occasionally not shoot the common infected if the visible one is farther away than the closer one that cannot be seen as you have pointed out in the previous issue.My new proposal would be to add all common infected to a local array and then sort all of the entities in the array from the closest to farthest distance before the trace line checks are performed in another
foreach
loop. This allows the next closest common infected to be targeted instead of ignoring the closer one that cannot be seen.From my testing, the performance improvements can be quite massive when dealing with a lot of common infected at once. This is most noticeable in some custom campaigns that spawn way more common infected than necessary (especially in Glubtastic 3's train chapter).
Here are two videos showcasing the difference in performance using two different methods when faced with 200 common infected.
https://github.com/smilz0/Left4Bots/assets/64824187/01aac2f6-1f6d-47a9-b809-c8a88c0ff21a ^Old Method (Trace line in one
foreach
loop)https://github.com/smilz0/Left4Bots/assets/64824187/d56156b4-a643-4a00-a955-daa31f9663de ^Proposed Method (Trace line in ordered
foreach
loop)And here is the ZIP file containing the
left4bots_afterload.nut
file if you would like to take a look at it.Manual Attack Optimization.zip