Merge branch 'master' of https://github.com/MT-CTF/capturetheflag
This commit is contained in:
commit
69b025d794
1 changed files with 13 additions and 22 deletions
|
@ -11,45 +11,36 @@ function kill_assist.clear_assists(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
function kill_assist.add_assist(victim, attacker, damage)
|
function kill_assist.add_assist(victim, attacker, damage)
|
||||||
|
if victim == attacker then return end
|
||||||
|
|
||||||
if not kill_assists[victim] then
|
if not kill_assists[victim] then
|
||||||
kill_assists[victim] = {}
|
kill_assists[victim] = {
|
||||||
|
players = {},
|
||||||
|
hp_offset = 0
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
kill_assists[victim][attacker] = (kill_assists[victim][attacker] or 0) + damage
|
kill_assists[victim].players[attacker] = (kill_assists[victim].players[attacker] or 0) + damage
|
||||||
end
|
end
|
||||||
|
|
||||||
function kill_assist.add_heal_assist(victim, healed_hp)
|
function kill_assist.add_heal_assist(victim, healed_hp)
|
||||||
if not kill_assists[victim] then return end
|
if not kill_assists[victim] then return end
|
||||||
|
|
||||||
for name, damage in pairs(kill_assists[victim]) do
|
kill_assists[victim].hp_offset = kill_assists[victim].hp_offset + healed_hp
|
||||||
kill_assists[victim][name] = math.max(damage - healed_hp, 0)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function kill_assist.reward_assists(victim, killer, reward)
|
function kill_assist.reward_assists(victim, killer, reward)
|
||||||
if not kill_assists[victim] then return end
|
if not kill_assists[victim] then return end
|
||||||
|
|
||||||
for name, damage in pairs(kill_assists[victim]) do
|
for name, damage in pairs(kill_assists[victim].players) do
|
||||||
if minetest.get_player_by_name(name) and name ~= victim then
|
if name ~= "!offset" and minetest.get_player_by_name(name) then
|
||||||
local standard = 0
|
|
||||||
local max_hp = minetest.get_player_by_name(victim):get_properties().max_hp or 20
|
local max_hp = minetest.get_player_by_name(victim):get_properties().max_hp or 20
|
||||||
local help_percent = damage / max_hp
|
local help_percent = damage / (max_hp + kill_assists[victim].hp_offset)
|
||||||
local main, match = ctf_stats.player(name)
|
local main, match = ctf_stats.player(name)
|
||||||
local color = "0x00FFFF"
|
local color = "0x00FFFF"
|
||||||
|
|
||||||
if name ~= killer then
|
if name == killer or help_percent >= 0.33 then
|
||||||
standard = 0.3
|
reward = math.max(math.floor((reward * help_percent)*100)/100, 1)
|
||||||
help_percent = math.min(help_percent, 0.75)
|
|
||||||
else
|
|
||||||
help_percent = math.min(help_percent, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
if help_percent >= standard then
|
|
||||||
reward = math.floor((reward * help_percent)*100)/100
|
|
||||||
end
|
|
||||||
|
|
||||||
if reward < 1 then
|
|
||||||
reward = 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
match.score = match.score + reward
|
match.score = match.score + reward
|
||||||
|
|
Loading…
Reference in a new issue