About Store Forum Documentation Contact
Donations:
178$/mo



Post Reply 
Help with object references
Author Message
Pixel Perfect Offline
Member

Post: #1
Help with object references
I'd appreciate a little advice from any of the more experienced Esenthel devs.

I have a situation where I'm creating npcs in code which are controlled from an external AI engine. I need to be able to uniquely reference each of these npcs per update to be able to pass information backwards and forwards between Esenthel and the AI engine.

As I understand it, in Esenthels embedded world management system any items I create using objCreate get placed in their respective Game::ObjMemX container according to the object Type passed to the function. As this function appears to return no reference to the object (pointer etc) I assume the only link to this object at this point is via the storage position in the container.

Now, as Esenthel by default uses a streamed game world I noticed the warning regarding using pointers to game objects as these are not guaranteed to be valid at all times and as such a Reference class mechanism is deployed. I can see that these can be created and assigned values by equating them to a container position. Presumably I can also create a Map container to store a unique ID for each npc along with its reference as pairs which I can then search to obtain a pointer to each npc.

So as the AI engine requests npc creation I would need to create the npc, then create a reference based on an incremented position in the object container and add it to my Map container.

Given this scenario, how do I ensure the references are updated?

Does this sound about right or is there a better way of doing this?

I also notice there is a variant of the objCreate function called objCreateNear which accepts the same parameters but returns as pointer to the object. The description in the header file does not really make it clear to me what the distinction is between the two. Does it literally create it near (but not necessarily at) the position given as a parameter?

Any advice gratefully received.
07-15-2013 09:25 PM
Find all posts by this user Quote this message in a reply
jagatai Offline
Member

Post: #2
RE: Help with object references
Hey pixel,

I was also looking for a way to have references as an originating point for AI, i ended up creating the UID server side using ObjCreate, which later i then used it along with MAP<> so the server can focus on active areas with players as opposed to trying to send updates for areas that are inactive on the clients, hope this helps.

Here is the thread:
http://www.esenthel.com/community/showth...p?tid=6438

-J
07-16-2013 06:08 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #3
RE: Help with object references
Thanks for your input Jagatai.

I can see how when running client server defining your own UIDs is useful as you can create the same UIDs on the clients to match the sever ones. But you still don't have a pointer to the object at this point do you? So I'm not immediately sure that helps me.

How do you tie the UID back to the actual object or are you simply iterating through the object container looking for a UID match? Maybe I am missing something here!

I assume that getting the auto generated UID is not an issue for me as I have successfully created references to the objects and should be able to access the UID via the base object class. But I'm not sure I even need the UID as my requirement is only to be able to link an object identifier provided by the AI engine to an object created in Esenthel (that is ... a valid pointer to the associated Esenthel object).

I think the method I outlined will work it's just I'm not sure how I maintain the references such that changes to the objects status by the engine get reflected in the reference and the valid check prevents me from using any non valid pointers.
07-16-2013 10:16 AM
Find all posts by this user Quote this message in a reply
SamNainocard Offline
Member

Post: #4
RE: Help with object references
I, for one, using UID and container enum to iterating through container, not sure if there's better solution out there.
07-17-2013 05:20 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #5
RE: Help with object references
Many thanks Sam, I'll just go ahead and code it and see how it works out.
07-17-2013 08:33 AM
Find all posts by this user Quote this message in a reply
Post Reply