Posts: 95
Threads: 11
Joined: Nov 2014
Thanks: 7
Given 8 thank(s) in 7 post(s)
01-26-2015, 04:54 AM
(This post was last modified: 01-26-2015, 05:02 AM by wudles.)
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.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
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.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
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.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
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.