Removed immunity
This commit is contained in:
parent
7104648399
commit
6d5cc0406b
3
DOCS.md
3
DOCS.md
@ -173,8 +173,6 @@ The second field, on the contrary, is a table of parameters: they define the ver
|
||||
* `queue_waiting_time`: the time to wait before the loading phase starts. It gets triggered when the minimium amount of players has been reached to start the queue. Default is 10
|
||||
* `load_time`: the time between the loading state and the start of the match. Default is 3
|
||||
* `celebration_time`: the time between the celebration state and the end of the match. Default is 3
|
||||
* `immunity_time`: the duration of the immunity right after respawning. Default is 3
|
||||
* `immunity_slot`: the slot whereto put the immunity item. Default is 8 (the last slot of the hotbar)
|
||||
* `properties`: explained down below
|
||||
* `temp_properties`: same
|
||||
* `player_properties`: same
|
||||
@ -309,7 +307,6 @@ Default is 0 and these are mostly hardcoded in arena_lib already, so it's advise
|
||||
Executioner can be passed to tell who removed the player. By default, this happens when someone uses /kick and /forceend, so that these commands can't be abused without consequences for the admin.
|
||||
* `arena_lib.send_message_players_in_arena(arena, msg, <teamID>, <except_teamID>)`: send a message to all the players in that specific arena. If a teamID is specified, it'll be only sent to the players inside that very team. On the contrary, if except_teamID is true, it'll be sent to every player BUT the ones in the specified team
|
||||
* `arena_lib.teleport_in_arena(sender, mod, arena_name)`: teleport the sender into the arena if at least one spawner has been set
|
||||
* `arena_lib.immunity(player)`: grants immunity to the specified player. It lasts till the `immunity_time` declared in `arena_lib.register_minigame`
|
||||
* `arena_lib.is_arena_in_edit_mode(arena_name)`: returns whether the arena is in edit mode or not, as a boolean
|
||||
* `arena_lib.is_player_in_edit_mode(p_name)`: returns whether a player is editing an arena, as a boolean
|
||||
|
||||
|
53
api.lua
53
api.lua
@ -59,6 +59,10 @@ function arena_lib.register_minigame(mod, def)
|
||||
minetest.log("warning", "[ARENA_LIB] timer is deprecated. Use time_mode = 2 instead")
|
||||
def.time_mode = 2
|
||||
end
|
||||
|
||||
if def.immunity_time or def.immunity_slot then
|
||||
minetest.log("warning", "[ARENA_LIB] Immunity has been removed from arena_lib as a lot of minigames don't need it. It shall be implemented by modders in their own mods")
|
||||
end
|
||||
--^------------------ LEGACY UPDATE, to remove in 5.0 -------------------^
|
||||
|
||||
arena_lib.mods[mod] = {}
|
||||
@ -86,8 +90,6 @@ function arena_lib.register_minigame(mod, def)
|
||||
mod_ref.queue_waiting_time = 10
|
||||
mod_ref.load_time = 3 -- time in the loading phase (the pre-match)
|
||||
mod_ref.celebration_time = 3 -- time in the celebration phase
|
||||
mod_ref.immunity_time = 3
|
||||
mod_ref.immunity_slot = 8 -- people may have tweaked the slots, hence the custom parameter
|
||||
mod_ref.properties = {}
|
||||
mod_ref.temp_properties = {}
|
||||
mod_ref.player_properties = {}
|
||||
@ -165,14 +167,6 @@ function arena_lib.register_minigame(mod, def)
|
||||
mod_ref.celebration_time = def.celebration_time
|
||||
end
|
||||
|
||||
if def.immunity_time then
|
||||
mod_ref.immunity_time = def.immunity_time
|
||||
end
|
||||
|
||||
if def.immunity_slot then
|
||||
mod_ref.immunity_slot = def.immunity_slot
|
||||
end
|
||||
|
||||
if def.properties then
|
||||
mod_ref.properties = def.properties
|
||||
end
|
||||
@ -1055,23 +1049,12 @@ function arena_lib.load_celebration(mod, arena, winner_name)
|
||||
arena.in_celebration = true
|
||||
arena_lib.update_sign(arena)
|
||||
|
||||
-- per ogni giocatore...
|
||||
-- ripristino HP e visibilità nome di ogni giocatore
|
||||
for pl_name, stats in pairs(arena.players) do
|
||||
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
-- ripristino HP e visibilità nome
|
||||
player:set_hp(minetest.PLAYER_MAX_HP_DEFAULT)
|
||||
player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
||||
|
||||
local inv = player:get_inventory()
|
||||
|
||||
-- immortalità
|
||||
if not inv:contains_item("main", "arena_lib:immunity") then
|
||||
inv:set_stack("main", mod_ref.immunity_slot, "arena_lib:immunity")
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
local winning_message = ""
|
||||
@ -1503,32 +1486,6 @@ end
|
||||
|
||||
|
||||
|
||||
function arena_lib.immunity(player)
|
||||
|
||||
local immunity_item = ItemStack("arena_lib:immunity")
|
||||
local inv = player:get_inventory()
|
||||
local p_name = player:get_player_name()
|
||||
local mod_ref = arena_lib.mods[arena_lib.get_mod_by_player(p_name)]
|
||||
local immunity_ID = 0
|
||||
|
||||
-- aggiungo l'oggetto
|
||||
inv:set_stack("main", mod_ref.immunity_slot, immunity_item)
|
||||
|
||||
-- in caso uno spari, perda l'immunità, muoia subito e resusciti, il tempo d'immunità riparte da capo.
|
||||
-- Ne tengo traccia con un metadato che comparo nell'after
|
||||
immunity_ID = player:get_meta():get_int("immunity_ID") + 1
|
||||
player:get_meta():set_int("immunity_ID", immunity_ID)
|
||||
|
||||
minetest.after(mod_ref.immunity_time, function()
|
||||
if not player then return end -- potrebbe essersi disconnesso
|
||||
if inv:contains_item("main", immunity_item) and immunity_ID == player:get_meta():get_int("immunity_ID") then
|
||||
inv:remove_item("main", immunity_item)
|
||||
player:get_meta():set_int("immunity_ID", 0)
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
1
init.lua
1
init.lua
@ -5,7 +5,6 @@ dofile(minetest.get_modpath("arena_lib") .. "/callbacks.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/chat.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/commands.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/debug_utilities.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/items.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/player_manager.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/privs.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/signs.lua")
|
||||
|
12
items.lua
12
items.lua
@ -1,12 +0,0 @@
|
||||
local S = minetest.get_translator("arena_lib")
|
||||
|
||||
|
||||
minetest.register_tool("arena_lib:immunity", {
|
||||
|
||||
description = S("You're immune!"),
|
||||
inventory_image = "arenalib_immunity.png",
|
||||
groups = {not_in_creative_inventory = 1, oddly_breakable_by_hand = "2"},
|
||||
on_place = function() end,
|
||||
on_drop = function() end
|
||||
|
||||
})
|
@ -66,11 +66,6 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||
-- se non è in partita, annullo
|
||||
if not mod then return hp_change end
|
||||
|
||||
-- se è immune, annullo
|
||||
if player:get_inventory():contains_item("main", "arena_lib:immunity") and reason.type ~= "respawn" then
|
||||
return 0
|
||||
end
|
||||
|
||||
-- se un tipo di danno è disabilitato, annullo
|
||||
for _, disabled_damage in pairs(arena_lib.mods[mod].disabled_damage_types) do
|
||||
if reason.type == disabled_damage then
|
||||
@ -111,7 +106,6 @@ minetest.register_on_respawnplayer(function(player)
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
player:set_pos(arena_lib.get_random_spawner(arena, arena.players[p_name].teamID))
|
||||
arena_lib.immunity(player)
|
||||
return true
|
||||
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user