Sokomine wrote:I've worked on something similar based on mobf because I like the behaviour of the peaceful_npc but want the functionality of the mobf framework. The
trader-mobs can now sit on suitable furniture (bench, chair, armchair, toilet) and "sleep" in a bed (several types of beds supported). They only do so when they are two or less blocks away from a furniture node when they randomly enter the appropriate state.
When sitting on something, the mob looks in the appropriate direction. The mob also comment a lot on what they do and send chat messages to singleplayer. This is mostly for debugging but may lead to some more "life" later on.
It looks very nice and definitely has a purpose.
My thoughts while hacking up my first attempt on a mod here was that anything moving about is using the on_step() function which according to the API is called approximately every 0.05 seconds. Let's multiply this by say 40 mobs and some old hardware (or an Atom based server in my case) and we have 30% CPU utilisation with just a single player present. Add more players and the game will come to a grinding halt fast.
So. I think we need at least two types of "mob" mods:
1) One like mine here (likely not that one :-) but similar) that has a really fast or even non-existing on_step() function.
This would be used for bulk population like traders (not moving around but sensitive to clicks/punches), prisoners, people
in houses, standing around and providing missions and what not. We see those all over the place in other MMORPGs.
Key point: They are interactive but not moving around at all => low resource demand
2) Moving mobs like farm animals, predators, golems, robots (in a broad sense of programmable automation), and what not.
There will not be tons of these but we will still need highly optimised code.
Regarding 2) I was wondering if we are able to control ALL moving mobs in a single "master" on_step() call instead of having one defined for each and every entity. Sort of a "master controller" with a table of all mobs wading through the lot and adjusting all the parameters on all mobs at once.
Also another thing I am wondering about is the ability to simply disable a mob (freeze it) if no players are near. I mean, why move around if no-one is there to see it? I'd like code like "if distance_to_nearest_player() < 20 then <act> else return"
Trains could be different and always running but probably better implemented by using mesecons to "call" one to ride.
Does this make any sense?