E
Evil Puncker
Guest
Hi everyone, I have a death broadcast script but the damageMap part seems to not be working as it should, even if there is more than 1 killer the message is still "was killed by" instead of slain crushed etc, how can I fix it? also any optimization and/or tips, are welcome using latest TFS 1.3
Lua:
function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
local damageMap = creature:getDamageMap()
local str = creature:getName().." ["..creature:getLevel().."]"
if(#damageMap <= 1) then
str = str.." was killed by "
elseif(#damageMap > 1 and #damageMap <= 4) then
str = str.." was slain by "
elseif(#damageMap > 4 and #damageMap <= 7) then
str = str.." was crushed by "
elseif(#damageMap > 7 and #damageMap <= 10) then
str = str.." was eliminated by "
elseif(#damageMap > 10) then
str = str.." was annihilated by "
end
local i = 0
for pid, _ in pairs(damageMap) do
i = i + 1
if (i == #damageMap) then
str = str.." and "
elseif (i ~= 1) then
str = str..", "
end
if not(isPlayer(pid) or isMonster(pid)) then
str = str.."a field item"
elseif isSummon(pid) then
str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
elseif isPlayer(pid) then
str = str..""..getCreatureName(pid)
elseif isMonster(pid) then
str = str.."a "..getCreatureName(pid):lower()
end
end
str = str.."."
--Game.broadcastMessage(str, MESSAGE_STATUS_WARNING)
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
print(str)
return true
end