darkmu
Well-Known Member
Can someone help, it's not accumulating the damage caused by the guild.
~ Edit
But if anyone has something better, feel free.
Lua:
local lastCrystal = CreatureEvent("LastCrystalOnHealthChange")
local guilds = {}
function lastCrystal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature:isMonster() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local isGuild = false
local damage = primaryDamage + secondaryDamage
if attacker:isPlayer() == false then
if attacker:getMaster() == false then
return
end
attacker = attacker:getMaster()
end
if attacker:getGuild() == nil then
return
end
for k,v in pairs(guilds) do
if v[1] == attacker:getGuild():getId() then
v = {v[1], v[2] + damage}
isGuild = true
print(v[2] + damage)
break
end
end
if not isGuild then
guilds[#guilds+1] = {attacker:getGuild():getId(), damage}
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
lastCrystal:register()
~ Edit
But if anyone has something better, feel free.
Lua:
local lastCrystal = CreatureEvent("LastCrystalOnHealthChange")
local guilds = {}
function lastCrystal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature:isMonster() then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local isGuild = false
local damage = math.abs(primaryDamage) + math.abs(secondaryDamage)
if attacker:isPlayer() == false then
if attacker:getMaster() == false then
return
end
attacker = attacker:getMaster()
end
if attacker:getGuild() == nil then
return
end
for k,v in pairs(guilds) do
if v[1] == attacker:getGuild():getId() then
v = {v[1], v[2] + damage}
guilds[v[1]][2] = v[2]
isGuild = true
break
end
end
if not isGuild then
guilds[#guilds+1] = {attacker:getGuild():getId(), damage}
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
lastCrystal:register()
Last edited: