Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bots thinks every tick + Handle weapon and infected for better performance #49

Open
4512369781 opened this issue Oct 25, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@4512369781
Copy link

As the title says, I made a script file and everything is in it:
left4bots_afterload.zip

On my laptop, it does reduce a lot of "SCRIPT PERF WARNING --- "" ran long at 1.650392ms" messages.

@smilz0 smilz0 added the enhancement New feature or request label Oct 26, 2023
@smilz0
Copy link
Owner

smilz0 commented Oct 27, 2023

Thank you. I didn't know about the -1 interval. I will surely use it straight away as it makes more sense than my arbitrary 0.01 lol.
As of the performance improvements i need some time to test it but i'm sure it will work.
Btw i was thinking of implementing something similar to what you did but inside a dedicated think function of a dummy entity. Maybe doing it like i do in the bots main think function by splitting the work into several sub functions.
For example FuncI = 1 would refresh the common infected, FuncI = 2 to refresh the weapons, FuncI = 3 for the cleaning and so on.
Also, probably we can improve it even more by finding the weapon id ( Left4Utils.GetWeaponId(ent) ) directly in this weapons refresh function so to remove it from the bots think func. And maybe we could also check the distance between the common/weapon and the bots and only add them to the lists if whithin a certain range. Though i'm not sure it would make sense for the commons considering that the director already spawns them near the survivors.
Anyway i will try to come up with something and i will post it here so we can try to improve it together.

@4512369781
Copy link
Author

Initially, I used "logic_timer" instead of "thinkfunc" for looping, but the “OnTimer” output of "logic_timer" is based on I/O events, which will cause time inconsistency. I tested it for a while and was still not satisfied. Only a few days ago I found more detailed information on the TF2 wiki, and this problem was solved.

About check distance, I guess that would be possible for weapons bucause they don't move.
But the infected are always moving, and the distance still needs to be checked again when the bot needs to deal with them. And they get killed frequently, need updates list often, and the number of infected isn't too many, so I think it's better to let bot deal with them.

Now that the bots can think faster, I think it's time to complete the aiming function, when I finish it I'll open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants