[AI] cRoot:Get():ForEachMob
#1
I guess this a request more than anything else.

How hard would it be to add a function cRoot:Get():ForEachMob that mimics cRoot:Get():ForEachPlayer ?

This would be a great start to work on the AI and only require the HOOK_WORLD_TICK as a starting point.
Reply
Thanks given by:
#2
What would it be "Finding" the mob by? (Find uses fuzzy matching, DoWith uses exact matching.)

Once you have the mob's ID, you can call cWorld:DoWithEntityByID(). True, you need to know the correct cWorld.
Reply
Thanks given by:
#3
(01-26-2015, 04:57 AM)xoft Wrote: What would it be "Finding" the mob by? (Find uses fuzzy matching, DoWith uses exact matching.)

Once you have the mob's ID, you can call cWorld:DoWithEntityByID(). True, you need to know the correct cWorld.

Actually, it would be more like "ForEachPlayer" ... so "ForEachMob" ... that way we can loop through each mob and check what we did with it last and what it needs to do next.
Reply
Thanks given by:
#4
There's a cWorld:ForEachEntity() that you can use. Just check if it's a monster as the first thing of the callback Smile
Reply
Thanks given by:
#5
(01-26-2015, 05:21 AM)xoft Wrote: There's a cWorld:ForEachEntity() that you can use. Just check if it's a monster as the first thing of the callback Smile


Ok. I'm on it. Smile
Reply
Thanks given by:
#6
(01-26-2015, 01:32 PM)wudles Wrote:
(01-26-2015, 05:21 AM)xoft Wrote: There's a cWorld:ForEachEntity() that you can use. Just check if it's a monster as the first thing of the callback Smile


Ok. I'm on it. Smile

Oh, this is cool. I'm using on tick to cycle through the mobs and having them move towards the closest logged in players.

Fun, fun, fun.
Reply
Thanks given by:
#7
You might want to dial down on the frequency, otherwise you'll overload the server pretty soon. Only set the target once every second or so, that should be sufficient. Even better, distribute the load into multiple passes - for example four passes per second and pass #N processes entities for which (ID % 4) == N.
Reply
Thanks given by:
#8
(01-26-2015, 06:47 PM)xoft Wrote: You might want to dial down on the frequency, otherwise you'll overload the server pretty soon. Only set the target once every second or so, that should be sufficient. Even better, distribute the load into multiple passes - for example four passes per second and pass #N processes entities for which (ID % 4) == N.

That's the plan. I store all the entities in a sqlite3 database, and only update those that have not been updated in the last 2 seconds -- for now. The logic will have to change based on their status ... hunting, walking, combat, etc... But this is a just an attempt to get some smarts into the mobs. Wink
Reply
Thanks given by:
#9
I think SQLite is an overkill for this, going through all the interfaces and all the locking. A simple Lua table would probably be an easier solution.
Reply
Thanks given by:
#10
(01-27-2015, 01:39 AM)xoft Wrote: I think SQLite is an overkill for this, going through all the interfaces and all the locking. A simple Lua table would probably be an easier solution.

The problem is that I know sqlite, and I am new to Lua.

I'm abstracting the data structure, so I could easily change it once I have it working.

Although, this http://lua-users.org/wiki/TablesTutorial makes it seem easy. I guess I'll just use the Lua tables. They will do what I need. Smile
Reply
Thanks given by:




Users browsing this thread: 6 Guest(s)