• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ Dragon EGG.lua crashing server TFS 1.3

kadeshop

New Member
Joined
May 1, 2013
Messages
33
Reaction score
0
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 :
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 !
 
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 :
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 !

hi

could you show your error message when its crashing

there are several ways this script could cause issues
 
View attachment 45431
That write on otserv console and server take off
Program theforgottenserver.exe he stopped responding

inside your forgottenserver/data/events/events.xml disable onTargetCombat by specifying the following

XML:
<event class="Creature" method="onTargetCombat" enabled="0" />

if that prevents crash then you have an event which is responsible for crash

you also have some movements issues (onStepIn/onStepOut) that you might want to address
 
Hi,

I would like to help but I'm not familiar with how this egg works or what it should do, an overview would be appreciated
 
Back
Top