Hello guys, i have problem, dragon egg.lua on forgotten knowledle crashing my server, if players killing boss server was crashed. Please look on script and help.
in creaturescript.lua have :
And dragon egg.lua
Thanks for all !
in creaturescript.lua have :
Lua:
<event type="preparedeath" name="DragonEgg" script="quests/forgotten knowledge/dragon egg.lua"/>
<event type="healthchange" name="DragonEgg2" script="quests/forgotten knowledge/dragon egg.lua"/>
And dragon egg.lua
Lua:
local function revertHorror()
local melting = Tile(Position(32267, 31071, 14)):getTopCreature()
local diference, pos, monster = 0, 0, false
local specs, spec = Game.getSpectators(Position(32269, 31091, 14), false, false, 12, 12, 12, 12)
for i = 1, #specs do
spec = specs[i]
if spec:isMonster() and spec:getName():lower() == 'melting frozen horror' then
health = spec:getHealth()
pos = spec:getPosition()
spec:teleportTo(Position(32267, 31071, 14))
diference = melting:getHealth() - health
melting:addHealth( - diference)
melting:teleportTo(pos)
monster = true
end
end
if not monster then
if melting then
melting:remove()
end
end
end
local function changeHorror()
local melting = Tile(Position(32267, 31071, 14)):getTopCreature()
local pos = 0
local specs, spec = Game.getSpectators(Position(32269, 31091, 14), false, false, 12, 12, 12, 12)
for i = 1, #specs do
spec = specs[i]
if spec:isMonster() and spec:getName():lower() == 'solid frozen horror' then
pos = spec:getPosition()
spec:teleportTo(Position(32267, 31071, 14))
melting:teleportTo(pos)
end
end
addEvent(revertHorror, 20 * 1000)
end
function onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
if not creature:getName():lower() == "dragon egg" and creature:isMonster() then
return true
end
creature:addHealth(1, false)
return true
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if creature:getName():lower() == 'dragon egg' then
if primaryType == COMBAT_HEALING then
doTargetCombatHealth(0, creature, COMBAT_ICEDAMAGE, -primaryDamage, -primaryDamage, CONST_ME_MAGIC_GREEN)
return true
end
if primaryType == COMBAT_FIREDAMAGE then
primaryType = COMBAT_HEALING
creature:addHealth(primaryDamage, true)
if creature:getHealth() == creature:getMaxHealth() then
creature:say('The egg sends out a fiery eruption!\n Weakening the frozen horror significantly!', TALKTYPE_MONSTER_SAY)
local pos = creature:getPosition()
creature:remove()
Game.createMonster('dragon egg', pos, true, true)
changeHorror()
end
return true
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Thanks for all !