EdenLostMinetest / edenlost

Issues, mods, configs for the EdenLost Minetest server (el.edgy1.net:48131)
Apache License 2.0
1 stars 0 forks source link

Mobs repellant for spawn #38

Open Klaranth opened 2 years ago

Klaranth commented 2 years ago

We need to find a way to make mobs not spawn in the spawn area (-100, 0, -100) to (100, 40, 100)

Klaranth commented 2 years ago

IF Eden uses mobs redo mod :

mobs_spawn_protected Spawn in protected areas.

If set to 1, mobs will not spawn in protected areas.

Type: int Default: 0

Source: https://antummt.github.io/mod-mobs_redo/api.html#mobs_spawn_protected

dennisjenkins75 commented 2 years ago

yes, I just found that. However, this would prevent mobs from spawning in many places; we just want to stop them from spawning at our player spawn point.

Bituvo commented 2 years ago

I found out that mob spawning is handled in the spawn_action function of the API. We could put a check at line 4,023 to see if the selected position is inside the spawn area Klaranth defined, and return if it isn't. Instead of being hardcoded, the spawn region could be configurable but the spawn area probably won't change anytime soon.

-- don't spawn mobs inside the player spawn region
if not (pos.x > -100 and pos.x < 100)
and not (pos.y > 0 and pos.y < 40)
and not (pos.z > -100 and pos.z < 100) then
    return
end

The server could have another custom mod for this, so this isn't removed with the next update of mobs_redo. Hopefully the server does use mobs_redo, otherwise I wasted 5 minutes of my life

dennisjenkins75 commented 2 years ago

Nice research. I propose that we actually author a change for the spawn_action code, and have it use minetest:settings_get_pos("protected_spawn.pos1") (and pos2), and use those limits. If not set, then use the existing values. Then anyone could override the protected area by adding two lines to their minetest.conf file.

I can code this up in a few days, unless someone beats me to it.