[Mod] PvP Areas [pvp_areas]
- everamzah
- Member
- Posts: 490
- Joined: Thu Jan 29, 2015 00:47
- GitHub: everamzah
- IRC: everamzah
- In-game: everamzah
[Mod] PvP Areas [pvp_areas]
Description: Mark areas for PvP, but disallow elsewhere by default. The inversion of this can be achieved by setting Settings -> Mods -> pvp_areas -> PvP by Default.
Usage: /pvp_areas pos1 and /pvp_areas pos2, following by /pvp_areas set. /pvp_areas without argument lists areas. /pvp_areas remove n removes that entry.
Bugs: https://github.com/everamzah/pvp_areas/issues
Requires: 403dada (Sep. 9 2016) or later.
Areas are stored in the world path as "pvp_areas_store.dat".
This mod is a reply to viewtopic.php?f=10&t=15479
Download
Git repository: https://github.com/everamzah/pvp_areas
License: LGPL v2.1+
Usage: /pvp_areas pos1 and /pvp_areas pos2, following by /pvp_areas set. /pvp_areas without argument lists areas. /pvp_areas remove n removes that entry.
Bugs: https://github.com/everamzah/pvp_areas/issues
Requires: 403dada (Sep. 9 2016) or later.
Areas are stored in the world path as "pvp_areas_store.dat".
This mod is a reply to viewtopic.php?f=10&t=15479
Download
Git repository: https://github.com/everamzah/pvp_areas
License: LGPL v2.1+
Last edited by everamzah on Fri Sep 09, 2016 15:52, edited 4 times in total.
- taikedz
- Member
- Posts: 698
- Joined: Sun May 15, 2016 11:11
- GitHub: taikedz
- IRC: DuCake
- In-game: DuCake
- Location: Scotland, UK
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
I added some things and sent a PR
When testing I found that I could not inflict damage either inside or outside the area... though looking at protector mod's code, it should indeed work.... will look further into that later....
When testing I found that I could not inflict damage either inside or outside the area... though looking at protector mod's code, it should indeed work.... will look further into that later....
- taikedz
- Member
- Posts: 698
- Joined: Sun May 15, 2016 11:11
- GitHub: taikedz
- IRC: DuCake
- In-game: DuCake
- Location: Scotland, UK
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
Some additional changes have been made and my dev branch seems funcitonal..... beta tests to now be done ;-)
- everamzah
- Member
- Posts: 490
- Joined: Thu Jan 29, 2015 00:47
- GitHub: everamzah
- IRC: everamzah
- In-game: everamzah
Re: [Mod] PvP Areas [pvp_areas]
taikedz dev branch is here: https://github.com/taikedz/pvp_areas/tree/dev
I haven't made any changes to my version yet, still waiting to see if I can get the total number of entries in an AreaStore without tracking it separately. get_area(n), where n does not exist, crashes Minetest without error: https://github.com/minetest/minetest/issues/4507
I haven't made any changes to my version yet, still waiting to see if I can get the total number of entries in an AreaStore without tracking it separately. get_area(n), where n does not exist, crashes Minetest without error: https://github.com/minetest/minetest/issues/4507
- everamzah
- Member
- Posts: 490
- Joined: Thu Jan 29, 2015 00:47
- GitHub: everamzah
- IRC: everamzah
- In-game: everamzah
Re: [Mod] PvP Areas [pvp_areas]
Some preliminary management of the areas has been implemented. You may now /pvp_area remove n, where n is some AreaStore id number. For now, you'll have to count from 0 using the output of /pvp_areas with no arguments (sent to console). /pvp_areas now lists areas to chat, when issued without argument.
This update requires a change to the engine, for which there is a PR: https://github.com/minetest/minetest/pull/4508
Update: This change was merged. 403dada or later is required.
Also, PvP is now on off by default, and disallowed in set areas only. This can be toggled by going to Settings -> Mods -> pvp_areas and setting `PvP by Default' to false true, or by setting pvp_areas_enable_pvp = false true in minetest.conf.
Edit: I should probably invert that default so the name of the mod makes sense.
Edit: Done.
This update requires a change to the engine, for which there is a PR: https://github.com/minetest/minetest/pull/4508
Update: This change was merged. 403dada or later is required.
Also, PvP is now on off by default, and disallowed in set areas only. This can be toggled by going to Settings -> Mods -> pvp_areas and setting `PvP by Default' to false true, or by setting pvp_areas_enable_pvp = false true in minetest.conf.
Edit: I should probably invert that default so the name of the mod makes sense.
Edit: Done.
Re: [Mod] PvP Areas [pvp_areas]
Downloads available here:
mod: https://github.com/taikedz/everamzah-pv ... master.zip
repo: https://github.com/taikedz/everamzah-pvp_areas
mod: https://github.com/taikedz/everamzah-pv ... master.zip
repo: https://github.com/taikedz/everamzah-pvp_areas
-
- Member
- Posts: 22
- Joined: Tue Oct 03, 2017 08:54
- GitHub: downad
- In-game: downad
- Location: Germany
Re: [Mod] PvP Areas [pvp_areas]
i found an error in the init.lua file.
the
does not work - the error i found is in the minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage) -
the return value is the final KILL_NO or KILL_OK i changed this.
a second thing i found - mos does no damage so i check if the hitter is a player or a mob
here is my code
the
Code: Select all
local safemode = minetest.setting_getbool("pvp_areas.safemode") or false
the return value is the final KILL_NO or KILL_OK i changed this.
a second thing i found - mos does no damage so i check if the hitter is a player or a mob
here is my code
Code: Select all
-- pvp_areas
-- Original : Copyright 2016 James Stevenson (everamzah)
-- Additional : Copyright Tai Kedzierski (DuCake)
-- LGPL v2.1+
local pvp_areas_worlddir = minetest.get_worldpath()
local pvp_areas_modname = minetest.get_current_modname()
local hasareasmod = minetest.get_modpath("areas")
local safemode = minetest.setting_getbool("pvp_areas.safemode") or false
local area_label = minetest.setting_get("pvp_areas.label") or "Defined area."
local pvp_areas_store = AreaStore()
pvp_areas_store:from_file(pvp_areas_worlddir .. "/pvp_areas_store.dat")
local pvp_default = minetest.is_yes(minetest.setting_getbool("pvp_areas_enable_pvp"))
minetest.log("action", "[" .. pvp_areas_modname .. "] PvP by Default: " .. tostring(pvp_default))
local pvp_areas_players = {}
local pvp_areas = {}
local function update_pvp_areas()
local counter = 0
pvp_areas = {}
while pvp_areas_store:get_area(counter) do
table.insert(pvp_areas, pvp_areas_store:get_area(counter))
counter = counter + 1
end
end
update_pvp_areas()
local function save_pvp_areas()
pvp_areas_store:to_file(pvp_areas_worlddir .. "/pvp_areas_store.dat")
end
local function areas_entity(pos,num)
if hasareasmod then
local obj = minetest.add_entity(pos, "areas:pos"..tostring(num))
local ent = obj:get_luaentity()
ent.active = true
end
end
-- Register privilege and chat command.
minetest.register_privilege("pvp_areas_admin", "Can set and remove PvP areas.")
minetest.register_chatcommand("pvp_areas", {
description = "Mark and set areas for PvP.",
params = "<pos1> <pos2> <set> <remove>",
privs = "pvp_areas_admin",
func = function(name, param)
local pos = vector.round(minetest.get_player_by_name(name):getpos())
if param == "pos1" then
if not pvp_areas_players[name] then
pvp_areas_players[name] = {pos1 = pos}
else
pvp_areas_players[name].pos1 = pos
end
minetest.chat_send_player(name, "Position 1: " .. minetest.pos_to_string(pos))
elseif param == "pos2" then
if not pvp_areas_players[name] then
pvp_areas_players[name] = {pos2 = pos}
else
pvp_areas_players[name].pos2 = pos
end
minetest.chat_send_player(name, "Position 2: " .. minetest.pos_to_string(pos))
elseif param == "set" then
if not pvp_areas_players[name] or not pvp_areas_players[name].pos1 then
minetest.chat_send_player(name, "Position 1 missing, use \"/pvp_areas pos1\" to set.")
elseif not pvp_areas_players[name].pos2 then
minetest.chat_send_player(name, "Position 2 missing, use \"/pvp_areas pos2\" to set.")
else
pvp_areas_store:insert_area(pvp_areas_players[name].pos1, pvp_areas_players[name].pos2, "pvp_areas", #pvp_areas)
table.insert(pvp_areas, pvp_areas_store:get_area(#pvp_areas))
update_pvp_areas()
save_pvp_areas()
pvp_areas_players[name] = nil
minetest.chat_send_player(name, "Area set.")
end
elseif param:sub(1, 6) == "remove" then
local n = tonumber(param:sub(8, -1))
if n and pvp_areas_store:get_area(n) then
pvp_areas_store:remove_area(n)
if pvp_areas_store:get_area(n + 1) then
-- Insert last entry in new empty (removed) slot.
local a = pvp_areas_store:get_area(#pvp_areas - 1)
pvp_areas_store:remove_area(#pvp_areas - 1)
pvp_areas_store:insert_area(a.min, a.max, "pvp_areas", n)
end
update_pvp_areas()
save_pvp_areas()
minetest.chat_send_player(name, "Removed " .. tostring(n))
else
minetest.chat_send_player(name, "Invalid argument. You must enter a valid area identifier.")
end
elseif param ~= "" then
minetest.chat_send_player(name, "Invalid usage. Type \"/help pvp_areas\" for more information.")
else
for k, v in pairs(pvp_areas) do
minetest.chat_send_player(name, k - 1 .. ": " ..
minetest.pos_to_string(v.min) .. " " ..
minetest.pos_to_string(v.max))
end
end
end
})
local KILL_NO = true
local KILL_OK = false
local AREA_ACTIVATE = KILL_OK
local AREA_NOACTIVATE = KILL_NO
local savemodeToString = "FALSCH" -- only for debugging
if safemode then
AREA_ACTIVATE = KILL_NO
AREA_NOACTIVATE = KILL_OK
savemodeToString = "WAHR"
end
-- Register punchplayer callback.
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
local isPlayer = hitter:is_player()
local IsPlayerToString = "PLAYER" -- only for debugging
if isplayer then
IsPlayerToString = "PLAYER" -- only for debugging
else
IsPlayerToString = "MOB" -- only for debugging
return false -- if this is a MOB then give Damage
end
local playername = player:get_player_name()
for k, v in pairs(pvp_areas_store:get_areas_for_pos(player:getpos())) do
if k then
--minetest.chat_send_player(playername, "in loop - safemode"..savemodeToString.." isPlayer "..IsPlayerToString)
return AREA_ACTIVATE --KILL_NO
end
end
--minetest.chat_send_player(playername, "after - safemode"..savemodeToString.." isPlayer "..IsPlayerToString)
return AREA_NOACTIVATE --KILL_OK
end)
if hasareasmod then
if areas.registerHudHandler then
local function advertise_nokillzone(pos, list)
for k, v in pairs(pvp_areas_store:get_areas_for_pos(pos)) do
if k then
table.insert(list, {
id = "PvP Control Area "..tostring(k),
name = area_label,
} )
return
end
end
end
areas:registerHudHandler(advertise_nokillzone)
else
minetest.log("info","Your version of `areas` does not support registering hud handlers.")
end
end
- taikedz
- Member
- Posts: 698
- Joined: Sun May 15, 2016 11:11
- GitHub: taikedz
- IRC: DuCake
- In-game: DuCake
- Location: Scotland, UK
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
I added fix for the setting erroneously assigned
For the extra code, can you make a pull request on github, or send URL to your own git repository ? If not able, I'll have a look over it when I get a moment
For the extra code, can you make a pull request on github, or send URL to your own git repository ? If not able, I'll have a look over it when I get a moment
-
- Member
- Posts: 22
- Joined: Tue Oct 03, 2017 08:54
- GitHub: downad
- In-game: downad
- Location: Germany
Re: [Mod] PvP Areas [pvp_areas]
now my code is on my github
https://github.com/downad/pvp_areas
https://github.com/downad/pvp_areas
- taikedz
- Member
- Posts: 698
- Joined: Sun May 15, 2016 11:11
- GitHub: taikedz
- IRC: DuCake
- In-game: DuCake
- Location: Scotland, UK
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
Hi Downad,
Thanks for proposing changes, always good!
The proper way to submit a change through Github (both parties using Github) is to "fork" the original, then copy your changed files in, and then make a pull request - makes communication easier.
I've put your changes in to a separate branch, unfortunately they're too inconsistent for me to pull them into master, see review
https://github.com/everamzah/pvp_areas/pull/1
As you can see, I'm essentially communicating with myself on this pull request. Ideally you would make the pull request from your fork of the same repo and we could engage in the discussion more appropriately there.
Thanks for proposing changes, always good!
The proper way to submit a change through Github (both parties using Github) is to "fork" the original, then copy your changed files in, and then make a pull request - makes communication easier.
I've put your changes in to a separate branch, unfortunately they're too inconsistent for me to pull them into master, see review
https://github.com/everamzah/pvp_areas/pull/1
As you can see, I'm essentially communicating with myself on this pull request. Ideally you would make the pull request from your fork of the same repo and we could engage in the discussion more appropriately there.
Re: [Mod] PvP Areas [pvp_areas]
I would like to set the area of pvp for only the Y axis, for use with Huge caves at deep depth and some mods: Nether [nether], Underground Realms [0.8] [caverealms], Hallelujah Mountains [cloudlands] etc.
-
- New member
- Posts: 4
- Joined: Thu Nov 10, 2022 20:31
- GitHub: AligatorBkmz
- In-game: SurviveX
Re: [Mod] PvP Areas [pvp_areas]
Changed your mod a bit. Added PVP Protector Block and API, added support for ranged_weapoons. Tested on Minetest 5.1.1
https://github.com/AligatorBkmz/pvp_areas
https://github.com/AligatorBkmz/pvp_areas
- Nininik
- Member
- Posts: 886
- Joined: Thu Apr 06, 2023 01:55
- GitHub: nininik0
- IRC: nininik
- In-game: nininik
- Location: CA, Team thunderstrike headquarters
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
There needs to be an inverse
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯
↯T.T.S.↯
- Nininik
- Member
- Posts: 886
- Joined: Thu Apr 06, 2023 01:55
- GitHub: nininik0
- IRC: nininik
- In-game: nininik
- Location: CA, Team thunderstrike headquarters
- Contact:
Re: [Mod] PvP Areas [pvp_areas]
Like where pvp can be disabled but the whole world enabled
↯Glory to Team Thunderstrike!↯
↯T.T.S.↯
↯T.T.S.↯