local dmgMap = {}
function loadDmgMap()
local file = io.open("dmgMap.txt", "r")
if file then
for line in file:lines() do
local guid, totalDmg = line:match("(%w+)%s+(%d+)")
dmgMap[guid] = tonumber(totalDmg)
end
file:close()
end
end
function saveDmgMap()
local file = io.open("dmgMap.txt", "w")
if file then
for guid, totalDmg in pairs(dmgMap) do
file:write(guid .. " " .. totalDmg .. "\n")
end
file:close()
end
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if attacker:isMonster() and creature:isPlayer() then
local player = creature:getPlayer()
local guid = player:getGuid()
local totalDmg = dmgMap[guid] or 0
-- Oblicz całkowite obrażenia zadane graczowi
local damage = primaryDamage + secondaryDamage
-- Dodaj obecne obrażenia do całkowitych obrażeń gracza
totalDmg = totalDmg + damage
-- Zapisz całkowite obrażenia w mapie dmgMap
dmgMap[guid] = totalDmg
-- Wyświetl informację o obrażeniach
print("Gracz o GUID " .. guid .. " otrzymał " .. damage .. " obrażeń.")
print("Całkowite obrażenia gracza to " .. totalDmg .. ".")
-- Zapisz aktualną wersję dmgMap do pliku
saveDmgMap()
end
end
-- Wczytaj wcześniej zapisane dane z pliku przy uruchomieniu silnika
loadDmgMap()