• 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!

Scarlett Boss mechaninc

Azerty

Active Member
Joined
Apr 15, 2022
Messages
301
Solutions
4
Reaction score
31
Does anyone know why I can't use armor according to the global mechanic? I use TFS 1.5 downgrade 8.6

Lua:
local info = {
    bossName = "Scarlett Etzel",
    middle = Position(33395, 32662, 6),
    fromPos = Position(33385, 32638, 6),
    toPos = Position(33406, 32660, 6),
    exitPos = Position(33395, 32670, 6),
    timer = Storage.GraveDanger.CobraBastion.ScarlettTimer,
    armorId = 36317,
    armorPos = Position(33398, 32640, 6),
}

local entry = {
    metalWallId = 36284,
    roomEntryPos = Position(33395, 32666, 6),
    roomExitPos = Position(33395, 32668, 6)
}

local transformTo = {
    [36309] = 36310,
    [36310] = 36311,
    [36311] = 36312,
    [36312] = 36309
}

local function createArmor(id, amount, pos)
    local armor = Game.createItem(id, amount, pos)
    if armor then armor:setActionId(33302) end
end

local graveScarlettUid = Action()
function graveScarlettUid.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playersTable = {}
    if item:getUniqueId() == 40028 then
        if player:doCheckBossRoom(info.bossName, info.fromPos, info.toPos) then
            for x = info.middle.x - 1, info.middle.x + 1 do
                for y = info.middle.y - 1, info.middle.y + 1 do
                    local sqm = Tile(Position(x, y, 6))
                    if sqm and sqm:getGround():getId() == 20293 then
                        local player_ = sqm:getTopCreature()
                        if player_ and player_:isPlayer() then
                            if player_:getStorageValue(info.timer) > os.time() then
                                player_:getPosition():sendMagicEffect(CONST_ME_POFF)
                                player_:sendCancelMessage('You are still exhausted from your last battle.')
                                return true
                            end
                            table.insert(playersTable, player_:getId())
                        end
                    end
                end
            end
            for _, p in pairs(playersTable) do
                local nPlayer = Player(p)
                if nPlayer then
                    nPlayer:teleportTo(Position(33395, 32656, 6))
                    nPlayer:setStorageValue(info.timer, os.time() + 20*60*60)
                end
            end
            local scarlett = Game.createMonster("Scarlett Etzel", Position(33396, 32640, 6))
            if scarlett then
                scarlett:registerEvent('scarlettThink')
                scarlett:registerEvent('scarlettHealth')
                scarlett:setStorageValue(Storage.GraveDanger.CobraBastion.Questline, 1)
            end
            SCARLETT_MAY_TRANSFORM = 0
            addEvent(kickPlayersAfterTime, 30*60*1000, playersTable, info.fromPos, info.toPos, info.exitPos)
        end
    end
    return true
end

graveScarlettUid:uid(40028)
graveScarlettUid:register()


local mirror = {
    fromPos = Position(33389, 32641, 6),
    toPos = Position(33403, 32655, 6),
    mirrors = {36309, 36310, 36311, 36312}
}

local function backMirror()
    for x = mirror.fromPos.x, mirror.toPos.x do
        for y = mirror.fromPos.y, mirror.toPos.y do
            local sqm = Tile(Position(x, y, 6))
            if sqm then
                for _, id in pairs(mirror.mirrors) do
                    local item = sqm:getItemById(id)
                    if item then
                        item:transform(mirror.mirrors[math.random(#mirror.mirrors)])
                        item:getPosition():sendMagicEffect(CONST_ME_POFF)
                    end
                end
            end
        end
    end
end

local graveScarlettAid = Action();
function graveScarlettAid.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid == 33302 then
        if isInArray(transformTo, item.itemid) then
            local pilar = transformTo[item.itemid]
            if pilar then
                item:transform(pilar)
                item:getPosition():sendMagicEffect(CONST_ME_POFF)
            end
        elseif item.itemid == info.armorId then
            item:getPosition():sendMagicEffect(CONST_ME_THUNDER)
            item:remove(1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You hold the old chestplate of Galthein in front of you. It does not fit and far too old to withstand any attack.")
            addEvent(createArmor, 20*1000, info.armorId, 1, info.armorPos)
            addEvent(backMirror, 10*1000)
            SCARLETT_MAY_TRANSFORM = 1
            addEvent(function()
                SCARLETT_MAY_TRANSFORM = 0
            end, 1 * 1000)
        elseif item.itemid == entry.metalWallId then
            if player:getPosition().y == entry.roomExitPos.y then
                player:teleportTo(entry.roomEntryPos)
            else
                player:teleportTo(entry.roomExitPos)
            end
        end
    end
    return true
end

graveScarlettAid:aid(33302)
graveScarlettAid:register()

nil.JPG
Post automatically merged:

Creaturescripts

Lua:
local storage = Storage.GraveDanger.CobraBastion.Questline
local rooms = {
    [1] = {fromPos = Position(33390, 32642, 6), toPos = Position(33394, 32646, 6)},
    [2] = {fromPos = Position(33390, 32646, 6), toPos = Position(33394, 32650, 6)},
    [3] = {fromPos = Position(33390, 32650, 6), toPos = Position(33394, 32654, 6)},
    [4] = {fromPos = Position(33394, 32642, 6), toPos = Position(33398, 32646, 6)},
    [5] = {fromPos = Position(33394, 32646, 6), toPos = Position(33398, 32650, 6)},
    [6] = {fromPos = Position(33394, 32650, 6), toPos = Position(33398, 32654, 6)},
    [5] = {fromPos = Position(33398, 32642, 6), toPos = Position(33402, 32646, 6)},
    [6] = {fromPos = Position(33398, 32646, 6), toPos = Position(33402, 32650, 6)},
    [7] = {fromPos = Position(33398, 32650, 6), toPos = Position(33402, 32654, 6)}
}

local function isMirrorsCorrect(fromPosition, toPosition)
    local Pillar1 = Tile(fromPosition):getItemById(36309)
    local Pillar2 = Tile(Position(fromPosition.x + 4, fromPosition.y, fromPosition.z)):getItemById(36310)
    local Pillar3 = Tile(Position(toPosition.x - 4, toPosition.y, toPosition.z)):getItemById(36312)
    local Pillar4 = Tile(toPosition):getItemById(36311)
    
    if Pillar1 and Pillar2 and Pillar3 and Pillar4 then
        return true
    end

    return false
end

local eventDoDamage = function(creatureid, attackerid, type)
    local creature = Creature(creatureid)
    if not creature then
        return
    end

    local damage = creature:getMaxHealth()/4
    creature:say('AHHHHHHHHHHH!', TALKTYPE_MONSTER_SAY)
    doTargetCombatHealth(attackerid, creature, type, -damage, -damage, CONST_ME_POFF, ORIGIN_NONE)
    creature:setMoveLocked(false)
end

local eventRemoveFreeze = function(creatureid, evented)
    local creature = Creature(creatureid)
    if not creature then
        return
    end

    if creature:isMoveLocked() then
        creature:setMoveLocked(false)
        if evented then
            SCARLETT_MAY_DIE = 0
        end
    end
end

local function changeScarlett(creatureid)
    local creature = Creature(creatureid)
    if not creature then
        return
    end

    creature:say('Galthen... is that you?', TALKTYPE_MONSTER_SAY)
    SCARLETT_MAY_DIE = 1
    SCARLETT_MAY_TRANSFORM = 0
    creature:setMoveLocked(true)
    addEvent(eventRemoveFreeze, 4*1000, creature:getId(), true)
end

local scarlettThink = CreatureEvent("scarlettThink")
function scarlettThink.onThink(creature)
    if not creature:isMonster() then
        return true
    end

    if SCARLETT_MAY_TRANSFORM ~= 1 then
        return true
    end

    local mirrorsCount = 0
    for _, p in pairs(rooms) do
        if creature:getPosition():isInRange(p.fromPos, p.toPos) then   
            if isMirrorsCorrect(p.fromPos, p.toPos) then
                addEvent(changeScarlett, 0.5*1000, creature:getId())
                return true
            end
        end
    end
    return true
end

scarlettThink:register()

local scarlettHealth = CreatureEvent("scarlettHealth")
function scarlettHealth.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isMonster() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if creature:getStorageValue(storage) ~= 1 then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if not creature:isMoveLocked() then
        return primaryDamage*0.01, primaryType, secondaryDamage*0.01, secondaryType
    end

    local spec = Game.getSpectators(creature:getPosition(), false, false, 4, 4, 4, 4)
    for _, c in pairs(spec) do
        if c and (c:isPlayer() or c:getMaster()) then
            doTargetCombatHealth(creature:getId(), c, COMBAT_EARTHDAMAGE, -7500, -7500, CONST_ME_GROUNDSHAKER)
        end
    end

    addEvent(eventDoDamage, 200, creature:getId(), attacker:getId(), primaryType)
    SCARLETT_MAY_DIE = 0
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

scarlettHealth:register()

creature.JPG
 
Last edited:
you need storages for monsters or some simmilar system to save some scarlet data
How do I do that?
Post automatically merged:

well, i got it, but ismovelocked is still giving error, the rest is working, does anyone know how to replace this "ismovelocked" condition for TFS 1.5?
Post automatically merged:

Now without errors in the distro, however the monster does not paralyzed
 
Last edited:
Back
Top