How do I use engine_trace.enumerate_entities_in_box
How do I use engine_trace.enumerate_entities_in_box
How do I use engine_trace.enumerate_entities_in_box?
Re: How do I use engine_trace.enumerate_entities_in_box
Finally back after some time at Uni, so will try to help :D
I got the enumerate functions working but failed further down the line. You cannot call the virtual functions for the EntityEnumerator class which makes this function a bit unusable at the moment, unless I am missing something in the src directory. I will take a look at recompiling with a fix later this weekend. Also took me a while to find where to get a HandleEntity instance xD
I got the enumerate functions working but failed further down the line. You cannot call the virtual functions for the EntityEnumerator class which makes this function a bit unusable at the moment, unless I am missing something in the src directory. I will take a look at recompiling with a fix later this weekend. Also took me a while to find where to get a HandleEntity instance xD
Syntax: Select all
from engines.trace import engine_trace, EntityEnumerator, MAX_TRACE_LENGTH, Ray
from commands.say import SayCommand
from players.entity import Player
from messages import SayText2
from entities import HandleEntity
@SayCommand('test')
def on_start(command, index, team):
player = Player(index)
start_vec = player.eye_location
end_vec = start_vec + player.view_vector * MAX_TRACE_LENGTH
ray = Ray(start_vec, end_vec)
SayText2(f"Finding entities along your view distance...").send()
enumerator = EntityEnumerator()
engine_trace.enumerate_entities(ray, True, enumerator)
## Fails here because cannot call <EntityEnumerator>.enum_entity(<HandleEntity>)
print(enumerator.enum_entity(player.networkable.entity_handle))
Re: How do I use engine_trace.enumerate_entities_in_box
You need to subclass EntityEnumerator. enum_entity is getting called for every found entity.
Re: How do I use engine_trace.enumerate_entities_in_box
Thanks got it to work
Edit: have to return True in enum_entity
Edit: have to return True in enum_entity
Syntax: Select all
from engines.trace import engine_trace
from engines.trace import EntityEnumerator
from commands.say import SayCommand
from players.entity import Player
from entities.entity import Entity
from memory import make_object
from entities import HandleEntity
from entities.helpers import index_from_basehandle
from entities.constants import WORLD_ENTITY_INDEX
from messages import SayText2
#print(dir(EntityEnumerator))
class MyEntEnum(EntityEnumerator):
def enum_entity(self, entity_handle):
handleentity = make_object(HandleEntity, entity_handle)
entity = Entity(index_from_basehandle(handleentity.basehandle))
SayText2("enum_entity - classname: {} origin: {}".format(entity.classname, entity.origin)).send()
return True
def get_entities_in_box(mins, maxs):
my_entity_enumerator = MyEntEnum()
engine_trace.enumerate_entities_in_box(mins, maxs, my_entity_enumerator)
@SayCommand('!trace')
def say_command_trace(command, index, teamonly):
world = Entity(WORLD_ENTITY_INDEX)
get_entities_in_box(world.world_mins, world.world_maxs)
Re: How do I use engine_trace.enumerate_entities_in_box
Question, is engine_trace.enumerate_entities_in_box guaranteed to return only after the enumerator is finished?
Re: How do I use engine_trace.enumerate_entities_in_box
I'm pretty sure it's a sequential task. So, the answer to your question is yes.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 103 guests