[Mod]Spawnlite[spawnlite]

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

[Mod]Spawnlite[spawnlite]

by qwertymine3 » Tue Nov 03, 2015 23:59

This is a lightweight alternative to traditional ABM spawning.

Advantages over ABM spawning
  • Performance cost scales with the number of players, with no fluctuation with movement (unlike ABMs).
  • Highly configurable - You can choose how you want it to perform
  • No additional cost to spawning mobs further away.
  • Limits can be set per-mob, per-mob_group(currently passive or aggressive), globally and per spawn cycle.
  • Spawn cycle can be controlled for faster or slower spawning.

With the default settings the mod has little/no performance cost
  • Tries to spawn a mob once every second per player
  • This mob has a 50/50 chance of being a random passive or hostile mob

Unfinished/TODO
  • Support for water/air mobs - this will require a seperate location finding method
  • Better support for mob limits - currently doesn't scale with players
  • Better methods of balanceing spawn types - with hostile passive 50/50 for simple mobs,
    as the hostile mobs have more specific block types they often spawn much slower than the passive mobs

The mod is bundled with a copy of SimpleMobs[mobs] for testing purposes. All mobs are re-named spawnlite:mob_name.

Download:
https://github.com/Qwertymine/spawnlite/archive/master.zip

Github:
https://github.com/Qwertymine/spawnlite

Depends:
None

License:
MIT - see license.txt or https://opensource.org/licenses/MIT
Avatar by :devnko-ennekappao:
 

User avatar
TenPlus1
Member
 
Posts: 2423
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod]Spawnlite[spawnlite]

by TenPlus1 » Wed Nov 04, 2015 08:23

I dont know if it was because I have an older Pc, but walking around with this mod enabled caused jitters in my movement instead of smooth walking ?!?! Minetest 0.4.13 with only this mod active.
 

User avatar
Ferk
Member
 
Posts: 337
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: [Mod]Spawnlite[spawnlite]

by Ferk » Wed Nov 04, 2015 09:38

I see you have some counters to prevent the mobs from spawning past a limit (spawnlite.mobs.aggresive.now and so).

But I only see the counters increase, never decrease (just read the code, I didn't test it yet).
Wouldn't this mean that the mobs would stop spawning as soon as the max limit is reached and never spawn again (even if you kill all of them or they somehow expire and disappear) until the next server restart? Maybe you have some clever way of resetting the counters that I overlooked?

It would be cool if there was a way to keep track of the entities that would be compatible across apis. But I'm not sure this is possible, so perhaps something like this requires support from the mob api. Something like that would be useful for Dungeontest as well, so far I didn't add a way to limit the spawning of mobs and I'm afraid I'm gonna have to either change the mob api or do some workarounds for that.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Mod]Spawnlite[spawnlite]

by qwertymine3 » Wed Nov 04, 2015 10:20

TenPlus1 wrote:I dont know if it was because I have an older Pc, but walking around with this mod enabled caused jitters in my movement instead of smooth walking ?!?! Minetest 0.4.13 with only this mod active.

The main overhead of the this mod is that it calls find_nodes_under_air once per second. For me at least this causes no noticeable overhead - I'll try to look into it though.

Does changing the height variable do anything to change the jitteryness?
Avatar by :devnko-ennekappao:
 

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Mod]Spawnlite[spawnlite]

by qwertymine3 » Wed Nov 04, 2015 10:28

Ferk wrote:But I only see the counters increase, never decrease (just read the code, I didn't test it yet).
Wouldn't this mean that the mobs would stop spawning as soon as the max limit is reached and never spawn again (even if you kill all of them or they somehow expire and disappear) until the next server restart? Maybe you have some clever way of resetting the counters that I overlooked?


The counters are reset once every 5 seconds by the smaller on_globalstep function. This function sets all counters to 0 and the repopulates from minetest.luaentities.
You may have overlooked this as it is a pairs function, so the reset is v.now = 0.

This counting method should be relatively portable though, and better yet, I have done some performance tests on this idea which seem to show that even doing this test every second should have no noticeable impact on performance either - which should get better mob number tracking.
Avatar by :devnko-ennekappao:
 

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Mod]Spawnlite[spawnlite]

by qwertymine3 » Wed Nov 04, 2015 10:42

TenPlus1 wrote:I dont know if it was because I have an older Pc, but walking around with this mod enabled caused jitters in my movement instead of smooth walking ?!?! Minetest 0.4.13 with only this mod active.


I think I may be able to remove the performance hit once the mob cap is full for a given mob, but if it is something different, I may have to find an alternate method for finding a spawn location.

EDIT: What is the performance of get_node and line_of_sight like on your system? I can probably make an alternate spawning system with just these.

EDIT2: Done some quick tests, the los method appears to be better, especially at worst case - will try to re-write later/tommorow
Last edited by qwertymine3 on Thu Nov 05, 2015 12:23, edited 4 times in total.
Avatar by :devnko-ennekappao:
 

User avatar
Ferk
Member
 
Posts: 337
Joined: Tue Aug 18, 2015 17:18
GitHub: Ferk

Re: [Mod]Spawnlite[spawnlite]

by Ferk » Wed Nov 04, 2015 10:45

Oh, I see. So every 5 seconds the count resets back to zero.

This means that the limits are not really limits on the maximum amount of mobs spawned, but limits on the speed. If the max is 5, then it means there can be a maximum average spawning speed of 1 mob/second for that type of mob.

Wouldn't this mean there's still a chance that an area will be overpopulated if the mobs don't get killed or don't somehow "expire"? Do you have some other way to control that or do you rely on the mobs disappearing by themselves?

My mod has two globalstep functions, one every 5 seconds, the other one per second

Maybe you could do that with only 1 globalstep function and keep different counters (with the second one only being incremented/checked as a factor of the smaller one). It'll probably be better than keeping both counters checked every 0.1 secs cycle. But not sure if the jitter would be affected by that, probably not that much difference.

Unless I overlooked something again, find_nodes_in_area_under_air looks like the most expensive function in there. Are you doing that every second? That's probably the reason. Perhaps you should make both radius and interval more customizable, and reduce the spawning rates by checking less for spawning nodes, instead of first always finding the node and only later reducing the chance of spawn.
{ ☠ Dungeontest ☠ , ᗧ••myarcade•• }
 

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Mod]Spawnlite[spawnlite]

by qwertymine3 » Wed Nov 04, 2015 11:08

Ferk, you misread what I typed - It resets to 0 and is then repopulated from minetest.luaentities
This is a true count of all active entities that are spawned by this mod.

Maybe you could do that with only 1 globalstep function and keep different counters (with the second one only being incremented/checked as a factor of the smaller one). It'll probably be better than keeping both counters checked every 0.1 secs cycle. But not sure if the jitter would be affected by that, probably not that much difference.

Having the entity counter in a second global step also makes it more portable to other mods which need to track the number of entities of a give type. I could easily move it, but I won't unless there is a proven performance issue.

Unless I overlooked something again, find_nodes_in_area_under_air looks like the most expensive function in there. Are you doing that every second? That's probably the reason. Perhaps you should make both radius and interval more customizable, and reduce the spawning rates by checking less for spawning nodes, instead of first always finding the node and only later reducing the chance of spawn.


The radius should have no performance impact (and is customisable already), and both the height of the search and interval already are customisable.
Avatar by :devnko-ennekappao:
 

User avatar
qwertymine3
Member
 
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: [Mod]Spawnlite[spawnlite]

by qwertymine3 » Thu Nov 05, 2015 12:19

TenPlus1 wrote:I dont know if it was because I have an older Pc, but walking around with this mod enabled caused jitters in my movement instead of smooth walking ?!?! Minetest 0.4.13 with only this mod active.

I've put up a new branch - line_of_sight. This has a quick line_of_sight based version, maybe this has better performance.

This works well enough for spawning on the surface - but underground the spawning is almost non-existent (besides rats spawning in walls - please ignore them for now).
I think I'll leave this mod for a while until I come up with a lower performance cost spawn location finding method.
Avatar by :devnko-ennekappao:
 


Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 2 guests