statistic for killed mobs

master
ademant 2019-02-08 10:01:44 +01:00
parent f0e6b3ec9f
commit 15a2146ae1
1 changed files with 14 additions and 0 deletions

14
api.lua
View File

@ -9,6 +9,9 @@ mobs = {
version = "20190124",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {},
player_killed = {}, -- statistic of killed mobs by each player
player_tamed = {}, -- statistic of tamed mobs
player_harvest = {}, -- if mob can give items on punching, count the amount
}
-- creative check
@ -742,6 +745,17 @@ function mob_class:check_for_death(cmi_cause)
if use_cmi then
cmi.notify_die(self.object, cmi_cause)
end
if cmi_cause.puncher ~= nil then
local puncher=cmi_cause.puncher
if puncher:get_player_name() ~= nil and puncher:get_player_name() ~= "" then
local player_name=puncher:get_player_name()
if mobs.player_killed[player_name] == nil then
mobs.player_killed[player_name] = 0
end
mobs.player_killed[player_name] = mobs.player_killed[player_name] + 1
end
end
self.object:remove()