Page 1 of 1
PvP area toggle

Posted:
Wed Sep 07, 2016 14:06
by taikedz
Hello
I looked a bit and cannot find - is there a mod that ensure that a given area is PvP enable, whilst leaving other areas non-PvP and vice-versa?
I know tenplus1's protection mod prevents PvP in protected areas, but that also protects said areas from other actions.
What I am wondering is, if you have the server in PvP-enabled mode, if a mod could prevent PvP globally except in demarcated areas?
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 17:31
by everamzah
Nothing exists that I know of, but you may use minetest.register_on_punchplayer() and drop all damage unless the player is inside one of these designated areas. Using an AreaStore to delimit PvP acceptable areas and check if a player is inside of it would do.
This is a fun idea and I've played with it some already, so I might attempt to flesh something out.
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 18:00
by everamzah
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local pvp_areas_store = AreaStore()
local edge1 = {x = -25, y = -25, z = -25}
local edge2 = {x = 25, y = 25, z = 25}
local data = "Test Case 1"
local id = 6
pvp_areas_store:insert_area(edge1, edge2, data, id)
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
for k, v in pairs(pvp_areas_store:get_areas_for_pos(player:getpos())) do
if k then
return false
end
end
return true
end)
This works for a hard-coded location. I'll next try those neat looking to_file() and from_file() AreaStore methods, in order to save whatever areas you set using some chat command.
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 18:01
by taikedz
Thanks - I'll look into that.
[I am also realizing this post is in the wrong forum section...... if any moderator feels it should be moved to "Modding Discussion" please do...]
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 18:04
by taikedz
everamzah wrote:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local pvp_areas_store = AreaStore()
(snip)
This works for a hard-coded location. I'll next try those neat looking to_file() and from_file() AreaStore methods, in order to save whatever areas you set using some chat command.
Fantastic, will have a play around with this!
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 18:57
by everamzah
Posted in the WIP Mods subforum. Will continue this later, hope it helps.
Edit: Very forgetful today --
viewtopic.php?f=9&t=15480
Re: PvP area toggle

Posted:
Wed Sep 07, 2016 23:01
by 843jdc
I would be interested in this myself for Cash's World server.
Re: PvP area toggle

Posted:
Fri Sep 09, 2016 18:30
by everamzah
843jdc:
viewtopic.php?f=9&t=15480 pvp_areas mod is ready to test, if you like. You'll need a minetest from today or later, or else it'll crash.
Re: PvP area toggle

Posted:
Fri Sep 09, 2016 22:35
by taikedz
For those who want to run this on older builds (pre 2016-09-09), use this one:
https://github.com/taikedz/pvp_areas/It's done as-is now though - advice is to update your minetest build and use everamzah's version when possible.