• 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+ Wrath of the emperor, duplicated spawn when boss dies.

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,521
Solutions
27
Reaction score
870
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi again! I'm using TFS 1.x and i'm facing an issue with Wrath of the Emperor, where sometimes, if the boss got killed it spawns the next "form" of the boss duplicated. The last boss from Wrath of emperor is known because it changes his form as soon you kill one of their phases. This is how I have my .lua files:

Lua:
local bossForms = {
    ['esencia del dios serpiente'] = {
        text = 'NO ES TAN FACIL, MORTALES! SIENTAN EL PODER DEL DIOS!',
        newForm = 'serpentosa'
    },
    ['serpentosa'] = {
        text = 'NOOO! AHORA USTEDES HEREJES ENFRENTARAN MI IRA DIVINA!',
        newForm = 'lagarto aberrante'
    },
    ['lagarto aberrante'] = {
        text = 'USTEDES... PAGARAN... CON LA ETERNIDAD... DEL DOLOR!',
        newForm = 'zalamon mutado'
    }
}

function onKill(player, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'zalamon mutado' then
        Game.setStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11, -1)
        return true
    end

    local bossConfig = bossForms[targetMonster:getName():lower()]
    if not bossConfig then
        return true
    end

    Game.createMonster(bossConfig.newForm, targetMonster:getPosition(), false, true)
    player:say(bossConfig.text, TALKTYPE_MONSTER_SAY)
    return true
end

Trying to understand what happened here, I wonder if would be better to have something such as this:
Lua:
local creatureevent = CreatureEvent("FormOne")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if math.random(100) < 10 then
        Game.createMonster("Bossname", creature:getPosition())
        creature:say("Next form.", TALKTYPE_MONSTER_SAY)
    end
    return true
end

Also been struggling with the teleport room lever. It behaves kinda weird, I added some checks to make it more accurate (changed a few storages).
This is the whole part of the quest i'm pointing to:

And this is the lever I have:
Lua:
local config = {
    firstboss = "Esencia Del Dios Serpiente",
    bossPosition = Position(1069, 633, 15),

    trap = "Tiraplaga",
    trapPositions = {
        Position(1059, 629, 15),
        Position(1068, 629, 15),
        Position(1059, 636, 15),
        Position(1068, 636, 15)
    },
    startAreaPosition = Position(1061, 630, 14),
    arenaPosition = Position(1063, 632, 15)
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    --- Check if there's players inside'
    local playersInside = Game.getSpectators(config.arenaPosition, true, false, 10, 10, 10, 10)
    if #playersInside > 0 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'La arena esta ocupada.')
        return true
    end

    --- Check if player already killed Zalamon, so he/she don't help killing it twice
    if Game.getStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11) >= 2 then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, 'Un jugador que intenta entrar ya uso su cetro en el cuerpo sin vida de Zalamon.')
        return true
    end

    --- Set storage of player "is inside"
    Game.setStorageValue(PlayerStorageKeys.WrathoftheEmperor.Mission11, 1)
    --- Clean items in area
    Game.cleanAreaZalamon(Position(1055, 625, 15), Position(1071, 641, 15))

    --- Check if there's monsters inside boss area and delete them all if the lever is being pulled
    local monsters = Game.getSpectators(config.arenaPosition, false, false, 10, 10, 10, 10)
    local spectator
    for i = 1, #monsters do
        spectator = monsters[i]
        if spectator:isMonster() then
            spectator:remove()
        end
    end

    --- Teleport players from starting position to arena position
    local spectators = Game.getSpectators(config.startAreaPosition, false, true, 0, 5, 0, 5)
    for i = 1, #spectators do
        spectator = spectators[i]
        spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        spectator:teleportTo(config.arenaPosition)
        config.arenaPosition:sendMagicEffect(CONST_ME_TELEPORT)
    end

    for i = 1, #config.trapPositions do
        Game.createMonster(config.trap, config.trapPositions[i])
    end

    Game.createMonster(config.firstboss, config.bossPosition)
    item:transform(item.itemid == 1945 and 1946 or 1945)
    return true
end

And here's the most updated script from the quest where I took the script.

Thanks in advance!
Regards
 
You are calling twice game.createMonster... once onkill and once onDeath
The onDeath script I added was just an example, you we're pointing to that one?
ralke said:
I wonder if would be better to have something such as this
Lua:
local creatureevent = CreatureEvent("FormOne")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if math.random(100) < 10 then
        Game.createMonster("Bossname", creature:getPosition())
        creature:say("Next form.", TALKTYPE_MONSTER_SAY)
    end
    return true
end
Thanks for the reply! The only place that Game.CreateMonster call is:

It's really curious because this actually happens when Lizard Abomination appears (the duplicate monster). The other bosses doesn't have that issue. I'll try to post a recording with the tests so the thread can move forward, but anyways, if someone can detect any error on the code would be nice! I leave the thread open for that. Regards :)
 
The onDeath script I added was just an example, you we're pointing to that one?

Thanks for the reply! The only place that Game.CreateMonster call is:

It's really curious because this actually happens when Lizard Abomination appears (the duplicate monster). The other bosses doesn't have that issue. I'll try to post a recording with the tests so the thread can move forward, but anyways, if someone can detect any error on the code would be nice! I leave the thread open for that. Regards :)
Please can you record what it looks like on your server.

So, the lever script creates the first form, snake god essence, and the player has "WotEZalamon" registered on login.
Each form that is killed works fine, but when the final one is killed, a duplicate appears?
The final boss is named "mutated zalamon"(string lowered) right?
Can you also double check the bosses XML files, and make sure they have no events registered to them relating to this...
 
Back
Top