-
Notifications
You must be signed in to change notification settings - Fork 37
CS:GO weapons update #169
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
CS:GO weapons update #169
Conversation
satoon101
commented
Dec 4, 2016
- Adds item_definition_index attribute for Weapon instances for CS:GO
- Adds item_definition_index values for weapons in csgo weapon data
- Fixes maxammo on CS:GO which no longer uses ConVars
- Adds weapons to csgo weapon data that use the item_definition_index to set along with the parent classname
- Overrides created for Entity.create and Entity.find for csgo
- Adds Weapon.get_weapon_name to return the full name. Uses the item_definition_index for CS:GO. For other games/engines, just returns the classname
…lassnames. Added item_definition_index to all weapons in csgo weapon data to help differentiate between weapons. Changed maxammo for all non-grenade weapons in csgo weapon data to hard code the value instead of using the ConVars. The ConVars seem to no longer work, as changing their values does not affect the reserver ammo for the weapons.
…yfactories. Fixed name of one CS:GO weapon.
Implemented changes to Entity.find and Entity.create for csgo engine.
…f the classname of the weapons.
…eapons should never be given to players that have not earned/purchased them as any server doing so could be banned.
Currently, this uses get_weapon_name. I'm thinking we should change it to a getter property weapon_name, but I'm open to other suggestions for the name. |
Yes, |
Good point! I tested a couple different solutions, and the most recent commit (586738c) was by far the fastest. |
Let me know when you have had a chance to test everything, and if it's all good, we can merge this. |
Thanks for the update! Have you tried BaseEntityGenerator? It should be even faster than BaseEntityIter and it also provides the classname filter. |
I just noticed that it doesn't provide the classname filter. However, this should be a lot faster: for edict in EntityGenerator(<classname>, True):
entity = edict.server_unknown.base_entity
break |
I tried using EntityGenerator as in your snippet, but |
I usually use the import timeit
ITERATIONS = 10000
print(timeit.Timer(
"""
for entity in BaseEntityGenerator():
if entity.classname != 'INVALID':
continue
if not entity.is_networked():
continue
break
""",
"""
from filters.entities import BaseEntityGenerator
""").timeit(ITERATIONS))
print(timeit.Timer(
"""
for edict in EntityGenerator('INVALID', True):
entity = edict.server_unknown.base_entity
break
""",
"""
from filters.entities import EntityGenerator
""").timeit(ITERATIONS)) Result:
I used the classname |
Just added classname filter options to import timeit
ITERATIONS = 10000
print(timeit.Timer(
"""
for entity in BaseEntityGenerator():
if entity.classname != 'INVALID':
continue
break
""",
"""
from filters.entities import BaseEntityGenerator
""").timeit(ITERATIONS))
print(timeit.Timer(
"""
for entity in BaseEntityGenerator('INVALID', True):
break
""",
"""
from filters.entities import BaseEntityGenerator
""").timeit(ITERATIONS)) Result:
Now, there is probably no big difference between |
My tests show that BaseEntityGenerator is slightly faster than EntityGenerator. We don't really need to worry about invalid classnames in our instance, because unless we accidentally add invalid classnames to our weapon data, they will always skip both the |