• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.2 Yalahar Quest

undead mage

Active Member
Joined
Mar 25, 2012
Messages
364
Solutions
2
Reaction score
47
Location
Amsterdam
So im having 2 problems with the yalahar quest. The first problem is that when the last fight is activated people are still able to enter the teleport. The second problem is that when Azerus dies he doesn't spawn any teleport. I think that the problem with people entering the teleport after the fight is activated is because I added the storage (12240, 51) on login so everyone is able to enter the teleport without having to do the previous missions first.

data/actions/actions.xml
Code:
    <!-- Yalahar Quest -->
    <action fromuid="3088" touid="3090" script="quests/yalahar/reward.lua" />
    <action uniqueid="3086" script="quests/yalahar/lastFight.lua" />

data/actions/scripts/quests/yalahar/lastFight.lua
Code:
local waves = {
    Position(1062, 735, 10),
    Position(1070, 735, 10),
    Position(1065, 731, 10),
    Position(1067, 731, 10),
    Position(1065, 739, 10),
    Position(1067, 739, 10)
}

local creatureNames = {
    [1] = 'rift worm',
    [2] = 'rift scythe',
    [3] = 'rift brood',
    [4] = 'war golem'
}

local effectPositions = {
    Position(1062, 730, 10),
    Position(1070, 740, 10)
}

local function doClearAreaAzerus()
    if Game.getStorageValue(GlobalStorage.InServiceOfYalahar.LastFight) == 1 then
        local spectators, spectator = Game.getSpectators(Position(1066, 735, 10), false, false, 10, 10, 10, 10)
        for i = 1, #spectators do
            spectator = spectators[i]
            if spectator:isMonster() then
                spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
                spectator:remove()
            end
        end
        Game.setStorageValue(GlobalStorage.InServiceOfYalahar.LastFight, 0)
    end
    return true
end

local function doChangeAzerus()
    local spectators, spectator = Game.getSpectators(Position(1066, 735, 10), false, false, 10, 10, 10, 10)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isMonster() and spectator:getName():lower() == "azerus" then
            spectator:say("No! I am losing my energy!", TALKTYPE_MONSTER_SAY)
            Game.createMonster("Azerus", spectator:getPosition())
            spectator:remove()
            return true
        end
    end
    return false
end

local function summonMonster(name, position)
    Game.createMonster(name, position)
    position:sendMagicEffect(CONST_ME_TELEPORT)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if Game.getStorageValue(GlobalStorage.InServiceOfYalahar.LastFight) == 1 then
        player:say('You have to wait some time before this globe charges.', TALKTYPE_MONSTER_SAY)
        return true
    end

    local amountOfPlayers = 3
    local spectators = Game.getSpectators(Position(1066, 735, 10), false, true, 10, 10, 10, 10)
    if #spectators < amountOfPlayers then
        for i = 1, #spectators do
            spectators[i]:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need atleast " .. amountOfPlayers .. " players inside the quest room.")
        end
        return true
    end

    Game.setStorageValue(GlobalStorage.InServiceOfYalahar.LastFight, 1)
    addEvent(Game.createMonster, 18 * 1000, "Azerus2", Position(1066, 736, 10))

    local azeruswavemonster
    for i = 1, #creatureNames do
        azeruswavemonster = creatureNames[i]
        for k = 1, #waves do
            addEvent(summonMonster, (i - 1) * 60 * 1000, azeruswavemonster, waves[k])
        end
    end

    for i = 1, #effectPositions do
        effectPositions[i]:sendMagicEffect(CONST_ME_HOLYAREA)
    end

    addEvent(doChangeAzerus, 4 * 20 * 1000)
    addEvent(doClearAreaAzerus, 5 * 60 * 1000)
    return true
end

data/movements/movements.xml
Code:
    <!-- Yalahar Quest -->
    <movevent event="StepIn" fromuid="7809" touid="7810" script="quests/yalahar/lastFightTeleports.lua" />
    <movevent event="StepIn" uniqueid="3087" script="quests/yalahar/morik.lua" />

data/movements/scripts/quests/yalahar/lastFightTeleports.lua
Code:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if item.uid == 7809 then
        if player:getStorageValue(Storage.InServiceofYalahar.Questline) == 51 then
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Position(1066, 743, 10))
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:say('The apparatus in the centre looks odd! You should inspect it.', TALKTYPE_MONSTER_SAY)
        else
            player:teleportTo(fromPosition)
        end
    elseif item.uid == 7810 then
        if Game.getStorageValue(GlobalStorage.InServiceOfYalahar.LastFight) ~= 1 then
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            player:teleportTo(Position(1067, 747, 9))
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        else
            player:teleportTo(fromPosition)
        end
    end
    return true
end

data/movements/scripts/quests/yalahar/morik.lua
Code:
function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return true
    end

    if player:getStorageValue(Storage.InServiceofYalahar.Questline) == 51 then
        -- StorageValue for Questlog 'Mission 10: The Final Battle'
        player:setStorageValue(Storage.InServiceofYalahar.Mission10, 3)
        player:setStorageValue(Storage.InServiceofYalahar.Questline, 52)
        player:say('It seems by defeating Azerus you have stopped this army from entering your world! Better leave this ghastly place forever.', TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    end
    return true
end

data/creaturescripts/creaturescripts.xml
Code:
    <!-- Yalahar Quest -->
    <event type="kill" name="ServiceOfYalaharAzerus" script="quests/yalahar/AzerusKill.lua" />

data/creaturescripts/scripts/quests/yalahar/AzerusKill.lua
Code:
local teleportToPosition = Position(1070, 735, 14)

local function removeTeleport(position)
    local teleportItem = Tile(position):getItemById(1387)
    if teleportItem then
        teleportItem:remove()
        position:sendMagicEffect(CONST_ME_POFF)
    end
end

function onKill(creature, target)
    local targetMonster = target:getMonster()
    if not targetMonster or targetMonster:getName():lower() ~= 'azerus' then
        return true
    end

    local position = targetMonster:getPosition()
    position:sendMagicEffect(CONST_ME_TELEPORT)
    local item = Game.createItem(1387, 1, position)
    if item:isTeleport() then
        item:setDestination(teleportToPosition)
    end
    targetMonster:say('Azerus ran into teleporter! It will disappear in 2 minutes. Enter it!', TALKTYPE_MONSTER_SAY, 0, 0, position)

    --remove portal after 2 min
    addEvent(removeTeleport, 2 * 60 * 1000, position)

    --clean arena of monsters
    local spectators, spectator = Game.getSpectators(Position(1066, 735, 10), false, false, 10, 10, 10, 10)
    for i = 1, #spectators do
        spectator = spectators[i]
        if spectator:isMonster() then
            spectator:getPosition():sendMagicEffect(CONST_ME_POFF)
            spectator:remove()
        end
    end
    return true
end
 
When the fight is first activated, a global storage should be set, and the movement script to enter the room should check for that storage before allowing a person inside. upon completion of the mission, and once the final teleport is removed, the global storage should be reset as well

as for the final teleport not being created, I'm not sure. at first glance, the code looks okay. maybe throw some print statements in there and see where it stops running.
 
Back
Top