canary/data/scripts/creaturescripts/bestiary_kill.lua
Beats e033f83c50
[Fix] Bestiary unlocked creature (#438)
Before, the bestiary did not unlock or account for a creature due to the lack of the script in creaturescripts for its functioning.
2022-07-19 01:36:44 -03:00

27 lines
691 B
Lua

local bestiaryOnKill = CreatureEvent("BestiaryOnKill")
function bestiaryOnKill.onKill(player, creature, lastHit)
if not player:isPlayer() or not creature:isMonster() or creature:hasBeenSummoned() or creature:isPlayer() then
return true
end
for cid, damage in pairs(creature:getDamageMap()) do
local participant = Player(cid)
if participant and participant:isPlayer() then
participant:addBestiaryKill(creature:getName())
end
end
return true
end
bestiaryOnKill:register()
local loginBestiaryPlayer = CreatureEvent("loginBestiaryPlayer")
function loginBestiaryPlayer.onLogin(player)
player:registerEvent("BestiaryOnKill")
return true
end
loginBestiaryPlayer:register()