Make bounties dynamic, plus small ctf_stats change
Top 50 (instead of 41) players in the league table
This commit is contained in:
parent
ccd40285f0
commit
ea51cf4152
2 changed files with 20 additions and 11 deletions
|
@ -1,9 +1,10 @@
|
||||||
local bountied_player = nil
|
local bountied_player = nil
|
||||||
|
local bounty_score = 0
|
||||||
|
|
||||||
local function announce(name)
|
local function announce(name)
|
||||||
minetest.chat_send_player(name,
|
minetest.chat_send_player(name,
|
||||||
minetest.colorize("#fff326", "The next person to kill " .. bountied_player ..
|
minetest.colorize("#fff326", "The next person to kill " .. bountied_player ..
|
||||||
" will receive 150 points!"))
|
" will receive " .. bounty_score .. " points!"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function announce_all()
|
local function announce_all()
|
||||||
|
@ -23,9 +24,9 @@ local function bounty_player(target)
|
||||||
|
|
||||||
bountied_player = target
|
bountied_player = target
|
||||||
|
|
||||||
if minetest.global_exists("irc") then
|
-- if minetest.global_exists("irc") then
|
||||||
irc:say("Player " .. bountied_player .. " has a bounty on their head!")
|
-- irc:say("Player " .. bountied_player .. " has a bounty on their head!")
|
||||||
end
|
-- end
|
||||||
minetest.after(0.1, announce_all)
|
minetest.after(0.1, announce_all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,6 +44,14 @@ local function bounty_find_new_target()
|
||||||
|
|
||||||
if #players > 0 then
|
if #players > 0 then
|
||||||
bounty_player(players[math.random(1, #players)].name)
|
bounty_player(players[math.random(1, #players)].name)
|
||||||
|
|
||||||
|
-- Score * K/D
|
||||||
|
-- bounty_score = -----------, or 500 (whichever is lesser)
|
||||||
|
-- 10000
|
||||||
|
bounty_score = (pstat.score * (pstat.kills / pstat.deaths)) / 10000
|
||||||
|
if bounty_score > 500
|
||||||
|
bounty_score = 500
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.after(math.random(500, 1000), bounty_find_new_target)
|
minetest.after(math.random(500, 1000), bounty_find_new_target)
|
||||||
|
@ -65,16 +74,16 @@ ctf.register_on_killedplayer(function(victim, killer)
|
||||||
if victim == bountied_player then
|
if victim == bountied_player then
|
||||||
local main, match = ctf_stats.player(killer)
|
local main, match = ctf_stats.player(killer)
|
||||||
if main and match then
|
if main and match then
|
||||||
main.score = main.score + 150
|
main.score = main.score + bounty_score
|
||||||
match.score = match.score + 150
|
match.score = match.score + bounty_score
|
||||||
ctf.needs_save = true
|
ctf.needs_save = true
|
||||||
end
|
end
|
||||||
bountied_player = nil
|
bountied_player = nil
|
||||||
|
|
||||||
local msg = killer .. " has killed " .. victim .. " and received the prize!"
|
local msg = killer .. " has killed " .. victim .. " and received the prize!"
|
||||||
if minetest.global_exists("irc") then
|
-- if minetest.global_exists("irc") then
|
||||||
irc:say(msg)
|
-- irc:say(msg)
|
||||||
end
|
-- end
|
||||||
minetest.chat_send_all(msg)
|
minetest.chat_send_all(msg)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -44,7 +44,7 @@ function ctf_stats.get_formspec(title, players)
|
||||||
"," .. pstat.captures ..
|
"," .. pstat.captures ..
|
||||||
"," .. pstat.attempts ..
|
"," .. pstat.attempts ..
|
||||||
"," .. math.floor(pstat.score*10)/10
|
"," .. math.floor(pstat.score*10)/10
|
||||||
if i > 40 then
|
if i > 49 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -86,7 +86,7 @@ function ctf_stats.get_html(title, players)
|
||||||
"</td><td>" .. pstat.captures ..
|
"</td><td>" .. pstat.captures ..
|
||||||
"</td><td>" .. pstat.attempts ..
|
"</td><td>" .. pstat.attempts ..
|
||||||
"</td><td>" .. math.floor(pstat.score*10)/10 .. "</td></tr>"
|
"</td><td>" .. math.floor(pstat.score*10)/10 .. "</td></tr>"
|
||||||
if i > 40 then
|
if i > 49 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue