Suddivisione mod con arena_lib

master
Marco 2020-03-31 17:08:42 +02:00
parent 989c608879
commit 8883818c88
87 changed files with 76 additions and 512 deletions

View File

@ -1,4 +1,4 @@
arena_lib
default
signs_lib
doors?
flowers?

60
init.lua Normal file
View File

@ -0,0 +1,60 @@
-- load other scripts
dofile(minetest.get_modpath("quake") .. "/chatcmdbuilder.lua")
dofile(minetest.get_modpath("quake") .. "/commands.lua")
dofile(minetest.get_modpath("quake") .. "/playermanager.lua")
dofile(minetest.get_modpath("quake") .. "/privs.lua")
dofile(minetest.get_modpath("quake") .. "/weapons.lua")
--[[sovrascrizione "on_punch" nodo base dei cartelli per farli entrare
nell'arena se sono cartelli appositi e "on_timer" per teletrasportali in partita quando la queue finisce]]
minetest.register_node("quake:create_sign", {
description = "Left click on a sign to create an entrance or to remove it",
tiles = {"trickerytown.png"},
groups = {oddly_breakable_by_hand = "2"},
on_use = function(itemstack, user, pointed_thing)
local pos = minetest.get_pointed_thing_position(pointed_thing)
if pos == nil then return end -- nel caso sia aria, sennò crasha
local node = minetest.get_node(pos)
local def = minetest.registered_items[node.name]
--controllo se è un cartello
if def and def.entity_info then
def.number_of_lines = 5
local arena_ID = itemstack:get_meta():get_int("arenaID")
local arena = quake.arenas[arena_ID]
-- controllo se c'è già un cartello assegnato a quell'arena. Se è lo stesso lo rimuovo, sennò annullo
if next(arena.sign) ~= nil then
if minetest.serialize(pos) == minetest.serialize(arena.sign) then
minetest.set_node(pos, {name = "air"})
arena.sign = {}
minetest.chat_send_player(user:get_player_name(), "Cartello dell'arena " .. arena.name .. " rimosso con successo")
else
minetest.chat_send_player(user:get_player_name(), minetest.colorize("#e6482e", "[!] Esiste già un cartello per quest'arena!"))
end
return end
-- cambio la scritta
quake.update_sign(pos, arena)
-- aggiungo il cartello ai cartelli dell'arena
arena.sign = pos
-- salvo l'ID come metadato nel cartello
minetest.get_meta(pos):set_int("arenaID", arena_ID)
--TODO: rimuovere item
else
minetest.chat_send_player(user:get_player_name(), minetest.colorize("#e6482e", "[!] L'oggetto non è un cartello!"))
end
end,
})

View File

@ -1,353 +0,0 @@
local storage = minetest.get_mod_storage()
storage:set_string("arenas", nil) -- PER RESETTARE LO STORAGE
quake = { arenas = {} }
if minetest.deserialize(storage:get_string("arenas")) ~= nil then
quake.arenas = minetest.deserialize(storage:get_string("arenas"))
end
local function newArena() end
local function nextID() end
local function in_game_txt(arena) end
local arenasID
local players_in_game = {} --KEY: player name, INDEX: arenaID
local arena_default_max_players = 4
local arena_default_min_players = 2
local arena_default_kill_cap = 10
quake.arena_default = {
name = "",
sign = {},
players = {}, --KEY: player name, INDEX: kills, deaths, killstreak
spawn_points = {},
max_players = arena_default_max_players,
min_players = arena_default_min_players,
kill_cap = arena_default_kill_cap,
kill_leader = "",
in_queue = false,
in_game = false,
in_celebration = false
}
function quake.create_arena(sender, arena_name)
arenasID = nextID()
-- controllo che non ci siano duplicati
if arenasID > 1 and quake.get_arena_by_name(arena_name) ~= nil then minetest.chat_send_player(sender, minetest.colorize("#e6482e", "[!] Esiste già un'arena con quel nome!"))
return end
-- creo l'arena e la rinomino, aggiornando anche lo storage
quake.arenas[arenasID] = newArena(quake.arena_default)
quake.arenas[arenasID].name = arena_name
quake.update_storage()
minetest.chat_send_player(sender, "Arena " .. arena_name .. " creata con successo")
end
function quake.remove_arena(sender, arena_name)
local id, arena = quake.get_arena_by_name(arena_name)
if not arena then minetest.chat_send_player(sender, minetest.colorize("#e6482e", "[!] Non c'è nessun'arena chiamata " .. arena_name .. "!"))
return end
if arena.in_game then
minetest.chat_send_player(sender, minetest.colorize("#e6482e", "[!] Una partita è in corso nell'arena " .. arena_name .. ": impossibile rimuoverla"))
return end
--TODO: -chiedere conferma
-- rimozione cartello coi rispettivi metadati
if arena.sign ~= nil then minetest.set_node(arena.sign, {name = "air"}) end
quake.send_message_players_in_arena(id, "[Quake] L'arena per la quale eri in coda è stata rimossa... :(")
-- rimozione arena e aggiornamento storage
quake.arenas[id] = nil
quake.update_storage()
minetest.chat_send_player(sender, "Arena " .. arena_name .. " rimossa con successo")
end
function quake.set_sign(sender, arena_name)
local arena_ID, arena = quake.get_arena_by_name(arena_name)
if arena == nil then minetest.chat_send_player(sender, minetest.colorize("#e6482e", "[!] Quest'arena non esiste!"))
return end
if quake.get_arena_spawners_count(arena_ID) < arena.max_players then minetest.chat_send_player(sender, minetest.colorize("#e6482e", "[!] Gli spawner devono essere quanto i giocatori massimi prima di impostare il cartello!"))
return end
-- assegno item creazione arene con ID arena nei metadati da restituire al premere sul cartello
local stick = ItemStack("quake:create_sign")
local meta = stick:get_meta()
meta:set_int("arenaID", arena_ID)
minetest.get_player_by_name(sender):set_wielded_item(stick)
minetest.chat_send_player(sender, "Click sinistro su un cartello per settare l'arena")
end
function quake.update_storage()
storage:set_string("arenas", minetest.serialize(quake.arenas))
end
function quake.update_sign(pos, arena)
-- essendo chiave non numerica, va contata così. Non uso il getter perché dovrei richiamare 2 funzioni (ID e count)
local p_count = 0
for pl, stats in pairs(arena.players) do
p_count = p_count +1
end
signs_lib.update_sign(pos, {text = [[
]] .. arena.name .. [[
]] .. p_count .. "/".. arena.max_players .. [[
]] .. in_game_txt(arena) .. [[
]]})
end
function quake.is_player_in_arena(pl_name)
if players_in_game[pl_name] ~= nil then return true
else return false end
end
--[[
------------------------
In game
------------------------
]]
-- per il player singolo a match iniziato
function quake.join_arena(arena_ID)
--TODO
end
-- per tutti i giocatori quando finisce la coda
function quake.load_arena(arena_ID)
local count = 1
local weapon = ItemStack("quake:railgun")
local arena = quake.arenas[arena_ID]
-- teletrasporto giocatori e sostituisco l'inventario
for pl_name, stats in pairs(arena.players) do
local player = minetest.get_player_by_name(pl_name)
player:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}})
player: set_physics_override({
speed = 1.7,
jump = 1.5,
gravity = 1.15,
})
player:set_pos(arena.spawn_points[count])
player:get_inventory():set_list("main",{})
player:get_inventory():add_item("main", weapon)
players_in_game[pl_name] = arena_ID -- registro giocatori nella tabella apposita
count = count +1
end
end
--a partita finita
function quake.end_arena(arena_ID, winner_name)
local arena = quake.arenas[arena_ID]
arena.in_celebration = true
quake.update_sign(arena.sign, arena)
quake.update_storage()
for pl_name, stats in pairs(arena.players) do
local inv = minetest.get_player_by_name(pl_name):get_inventory()
local weapon = inv:get_stack("main", 1)
local meta = weapon:get_meta():set_int("immune", 1)
inv:set_stack("main", 1, weapon)
minetest.get_player_by_name(pl_name):set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
minetest.chat_send_player(pl_name, "[Quake] " .. winner_name .. " ha vinto la partita")
end
minetest.after(0.01, function()
for pl_name, stats in pairs(arena.players) do
minetest.get_player_by_name(pl_name):get_inventory():remove_item("main", ItemStack("quake:railgun"))
end
end)
-- momento celebrazione (evita anche bug inventario con railgun che rimane al vincitore)
minetest.after(3, function()
for pl_name, stats in pairs(arena.players) do
arena.players[pl_name] = nil
players_in_game[pl_name] = nil
arena.in_celebration = false
arena.in_game = false
quake.update_sign(arena.sign, arena)
quake.update_storage()
minetest.get_player_by_name(pl_name):set_physics_override({
speed = 1,
jump = 1,
gravity = 1,
})
--TODO: teleport lobby, metti variabile locale
end
end)
end
function quake.remove_player_from_arena(p_name)
local arena_ID = players_in_game[p_name]
arena[arena_ID].players[p_name] = nil
players_in_game[p_name] = nil
quake.send_message_players_in_arena(arena_ID, "[Quake] " .. p_name .. " ha abbandonato la partita")
--TODO: se in arena è rimasto solo un giocatore, ha vinto e end arena
end
function quake.send_message_players_in_arena(arena_ID, msg)
local arena = quake.arenas[arena_ID]
for pl_name, stats in pairs(arena.players) do
minetest.chat_send_player(pl_name, msg)
end
end
function quake.calc_kill_leader(arena, killer)
if arena.players[killer].kills > arena.kill_leader then
arena.kill_leader = killer
end
end
--[[
------------------------
Getter
------------------------
]]
function quake.get_arena_by_name(arena_name)
for id, arena in pairs(quake.arenas) do
if arena.name == arena_name then
return id, arena end
end
end
function quake.get_arena_spawners_count(arena_ID)
return table.maxn(quake.arenas[arena_ID].spawn_points)
end
function quake.get_arena_players_count(arena_ID)
local count = 0
local arena = quake.arenas[arena_ID]
for id, spawn in pairs(arena.players) do
count = count+1
end
return count
end
function quake.get_arenaID_by_player(p_name)
return players_in_game[p_name]
end
function quake.get_random_spawner(arena_ID)
return quake.arenas[arena_ID].spawn_points[math.random(1,quake.get_arena_spawners_count(arena_ID))]
end
--[[
------------------------
Funzioni locali
------------------------
]]
--[[ Dato che in Lua non è possibile istanziare le tabelle copiandole, bisogna istanziare ogni campo in una nuova tabella.
Ricorsivo per le sottotabelle. Codice da => http://lua-users.org/wiki/CopyTable]]
function newArena(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[newArena(orig_key)] = newArena(orig_value)
end
setmetatable(copy, newArena(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
--[[ l'ID di base parte da 1 (n+1) per non generare errori, tipo "if arenaID == 0" al verificare se non esiste.
In una sequenza 0, 1, 2, 3 se si rimuove "2" e si aggiunge un nuovo ID perciò si avrà 0, 1, 3, 4]]
function nextID()
local n = 0
for id, arena in pairs(quake.arenas) do
if id > n then n = id end
end
return n+1
end
function in_game_txt(arena)
local txt
if arena.in_celebration then txt = "Concludendo"
elseif arena.in_game then txt = "In partita"
else txt = "In attesa" end
return txt
end

View File

@ -1,151 +0,0 @@
-- load other scripts
dofile(minetest.get_modpath("quake") .. "/api.lua")
dofile(minetest.get_modpath("quake") .. "/chatcmdbuilder.lua")
dofile(minetest.get_modpath("quake") .. "/commands.lua")
dofile(minetest.get_modpath("quake") .. "/playermanager.lua")
dofile(minetest.get_modpath("quake") .. "/privs.lua")
dofile(minetest.get_modpath("quake") .. "/weapons.lua")
--[[sovrascrizione "on_punch" nodo base dei cartelli per farli entrare
nell'arena se sono cartelli appositi e "on_timer" per teletrasportali in partita quando la queue finisce]]
minetest.override_item("default:sign_wall", {
on_punch = function(pos, node, puncher, pointed_thing)
local arenaID = minetest.get_meta(pos):get_int("arenaID")
if arenaID == 0 then return end
local sign_arena = quake.arenas[arenaID]
local p_name = puncher:get_player_name()
if not sign_arena then return end -- nel caso qualche cartello dovesse buggarsi, si può rompere e non fa crashare
-- se è già in coda o viene fermato (cartello diverso) o si toglie dalla coda (cartello uguale)
if quake.is_player_in_arena(p_name) then
if quake.get_arenaID_by_player(p_name) ~= arenaID then
minetest.chat_send_player(p_name, "[Quake]" .. minetest.colorize("#e6482e", "Devi prima uscire dalla coda di " .. arena.name .. "!"))
else
sign_arena.players[p_name] = nil
quake.update_sign(pos, sign_arena)
minetest.chat_send_player(p_name, "[Quake] Sei uscito dalla coda")
quake.send_message_players_in_arena(arenaID, "[Quake] " .. p_name .. " ha abbandonato la coda")
-- se non ci sono più abbastanza giocatori, annullo la coda
if quake.get_arena_players_count(arenaID) < sign_arena.min_players and sign_arena.in_queue then
timer:stop()
quake.send_message_players_in_arena(arenaID, "[Quake] La coda è stata annullata per troppi pochi giocatori")
end
end
return end
-- se l'arena è piena
if quake.get_arena_players_count(arenaID) == sign_arena.max_players then
minetest.chat_send_player(p_name, minetest.colorize("#e6482e", "[!] L'arena è già piena!"))
return end
-- notifico i vari giocatori del nuovo player
if sign_arena.in_game then
--TODO: butta dentro alla partita in corso. Sì, si può entrare mentre è in corso -------- quake.join_arena(arenaID)
quake.send_message_players_in_arena(arenaID, "[Quake] " .. p_name .. " si è aggiunto alla partita")
minetest.chat_send_player(p_name, "[Quake] Sei entrato nell'arena " .. sign_arena.name)
else
quake.send_message_players_in_arena(arenaID, "[Quake] " .. p_name .. " si è aggiunto alla coda")
minetest.chat_send_player(p_name, "[Quake] Ti sei aggiunto alla coda per " .. sign_arena.name)
end
-- aggiungo il giocatore e aggiorno il cartello
sign_arena.players[p_name] = {kills = 0, deaths = 0, killstreak = 0}
quake.update_storage()
quake.update_sign(pos, sign_arena)
local timer = minetest.get_node_timer(pos)
local waiting_time = 5
-- se ci sono abbastanza giocatori, parte il timer di attesa
if quake.get_arena_players_count(arenaID) == sign_arena.min_players and not sign_arena.in_queue and not sign_arena.in_game then
quake.send_message_players_in_arena(arenaID, "[Quake] La partita inizierà tra " .. waiting_time .. " secondi!")
sign_arena.in_queue = true
timer:start(waiting_time)
end
-- se raggiungo i giocatori massimi e la partita non è iniziata, parte subito
if quake.get_arena_players_count(arenaID) == sign_arena.max_players and sign_arena.in_queue then
timer:stop()
timer:start(0.01)
end
--TODO: timer ciclico che avvisa i giocatori quanto tempo manca ogni N secondi
end,
-- quello che succede una volta che il timer raggiunge lo 0
on_timer = function(pos)
local arenaID = minetest.get_meta(pos):get_int("arenaID")
local sign_arena = quake.arenas[arenaID]
sign_arena.in_queue = false
sign_arena.in_game = true
quake.update_sign(pos, sign_arena)
quake.load_arena(arenaID)
return false
end,
})
minetest.register_node("quake:create_sign", {
description = "Left click on a sign to create an entrance or to remove it",
tiles = {"trickerytown.png"},
groups = {oddly_breakable_by_hand = "2"},
on_use = function(itemstack, user, pointed_thing)
local pos = minetest.get_pointed_thing_position(pointed_thing)
if pos == nil then return end -- nel caso sia aria, sennò crasha
local node = minetest.get_node(pos)
local def = minetest.registered_items[node.name]
--controllo se è un cartello
if def and def.entity_info then
def.number_of_lines = 5
local arena_ID = itemstack:get_meta():get_int("arenaID")
local arena = quake.arenas[arena_ID]
-- controllo se c'è già un cartello assegnato a quell'arena. Se è lo stesso lo rimuovo, sennò annullo
if next(arena.sign) ~= nil then
if minetest.serialize(pos) == minetest.serialize(arena.sign) then
minetest.set_node(pos, {name = "air"})
arena.sign = {}
minetest.chat_send_player(user:get_player_name(), "Cartello dell'arena " .. arena.name .. " rimosso con successo")
else
minetest.chat_send_player(user:get_player_name(), minetest.colorize("#e6482e", "[!] Esiste già un cartello per quest'arena!"))
end
return end
-- cambio la scritta
quake.update_sign(pos, arena)
-- aggiungo il cartello ai cartelli dell'arena
arena.sign = pos
-- salvo l'ID come metadato nel cartello
minetest.get_meta(pos):set_int("arenaID", arena_ID)
--TODO: rimuovere item
else
minetest.chat_send_player(user:get_player_name(), minetest.colorize("#e6482e", "[!] L'oggetto non è un cartello!"))
end
end,
})

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

View File

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View File

Before

Width:  |  Height:  |  Size: 120 B

After

Width:  |  Height:  |  Size: 120 B

View File

Before

Width:  |  Height:  |  Size: 120 B

After

Width:  |  Height:  |  Size: 120 B

View File

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 186 B

View File

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

View File

Before

Width:  |  Height:  |  Size: 314 B

After

Width:  |  Height:  |  Size: 314 B

View File

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

View File

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 183 B

View File

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 229 B

View File

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 321 B

View File

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 213 B

View File

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 233 B

After

Width:  |  Height:  |  Size: 233 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 217 B

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 333 B

After

Width:  |  Height:  |  Size: 333 B

View File

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 421 B

View File

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 214 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 101 B

After

Width:  |  Height:  |  Size: 101 B

View File

Before

Width:  |  Height:  |  Size: 155 B

After

Width:  |  Height:  |  Size: 155 B

View File

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 143 B

View File

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 216 B

View File

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 229 B

View File

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 185 B

View File

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 227 B

View File

Before

Width:  |  Height:  |  Size: 124 B

After

Width:  |  Height:  |  Size: 124 B

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

View File

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 204 B

View File

Before

Width:  |  Height:  |  Size: 212 B

After

Width:  |  Height:  |  Size: 212 B

View File

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B

View File

Before

Width:  |  Height:  |  Size: 194 B

After

Width:  |  Height:  |  Size: 194 B

View File

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 137 B

After

Width:  |  Height:  |  Size: 137 B

View File

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

View File

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

View File

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View File

Before

Width:  |  Height:  |  Size: 197 B

After

Width:  |  Height:  |  Size: 197 B

View File

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 316 B

View File

Before

Width:  |  Height:  |  Size: 99 B

After

Width:  |  Height:  |  Size: 99 B

View File

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

View File

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

View File

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 238 B

View File

Before

Width:  |  Height:  |  Size: 383 B

After

Width:  |  Height:  |  Size: 383 B

View File

Before

Width:  |  Height:  |  Size: 250 B

After

Width:  |  Height:  |  Size: 250 B

View File

Before

Width:  |  Height:  |  Size: 176 B

After

Width:  |  Height:  |  Size: 176 B

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 272 B

View File

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 215 B

View File

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 110 B

View File

@ -79,8 +79,8 @@ function shoot(p_name, pointed_thing)
local pos = minetest.get_pointed_thing_position(pointed_thing)
local target = pointed_thing.ref
local arena_ID = quake.get_arenaID_by_player(p_name)
local arena = quake.arenas[arena_ID]
local arena_ID = arena_lib.get_arenaID_by_player(p_name)
local arena = arena_lib.arenas[arena_ID]
if not arena then return end -- uno potrebbe sparare nel decimo di secondo di sostituzione arma a fine match e far crashare
@ -114,7 +114,7 @@ function shoot(p_name, pointed_thing)
local p_stats = arena.players[p_name]
p_stats.kills = p_stats.kills +1
p_stats.killstreak = p_stats.killstreak +1
quake.calc_kill_leader(arena, p_name)
arena_lib.calc_kill_leader(arena, p_name)
for pl_name, stats in pairs(arena.players) do
if arena.kill_leader == pl_name then
@ -126,16 +126,24 @@ function shoot(p_name, pointed_thing)
--TODO: aggiungere effetti sonori
if p_stats.killstreak == 3 then
quake.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è in una " .. minetest.colorize("#eea160", "serie d'uccisioni").. "!")
arena_lib.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è in una " .. minetest.colorize("#eea160", "serie d'uccisioni").. "!")
elseif p_stats.killstreak == 5 then
quake.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è " .. minetest.colorize("#eea160", "inarrestabile").. "!")
arena_lib.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è " .. minetest.colorize("#eea160", "inarrestabile").. "!")
elseif p_stats.killstreak == 7 then
quake.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è una " .. minetest.colorize("#eea160", "FURIA OMICIDA").. "!")
arena_lib.send_message_players_in_arena(arena_ID, "[Quake] " .. minetest.colorize("#eea160", p_name) .. " è una " .. minetest.colorize("#eea160", "FURIA OMICIDA").. "!")
end
-- se kill cap raggiunto finisce match
if arena.players[p_name].kills == arena.kill_cap then
quake.end_arena(quake.get_arenaID_by_player(p_name), p_name)
--rimuovo l'arma a tutti
minetest.after(0, function()
for pl_name, stats in pairs(arena.players) do
minetest.get_player_by_name(pl_name):get_inventory():remove_item("main", ItemStack("quake:railgun"))
end
end)
arena_lib.load_celebration(arena_lib.get_arenaID_by_player(p_name), p_name)
end
end