Ir para conteúdo
  • 0
costickmichel

Scripting Script que cria um monstro aleatório

Pergunta

costickmichel    0
costickmichel

Antes de fazer a sua pergunta, tenha certeza de ter lido as regras da seção e o guia abaixo:

https://forums.otserv.com.br/index.php?/forums/topic/168583-regras-da-seção/

https://forums.otserv.com.br/index.php?/forums/topic/165121-como-fazer-uma-pergunta-ou-o-grande-guia-do-usuário-com-dúvidas/

Obs: não delete esse formulário pré-definido, preencha-o corretamente para postar o seu tópico!

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

Base:

OTServBR - Global - Version TFS 1.3

Qual é a sua pergunta?

Olá amigos, estou com uma certa dificuldade em finalizar um script, criei todo script para que quando 5 player usam alavanca dão tp pra uma sala, nessa sala tem respawn aleatório de 5 boss, sendo que após o use da alavanca aleatoriamente o script crie um monstro. Porém após infinitas tentativas falhas, espero a ajuda de vocês.  ( O SCRIPT FUNCIONA, PORÉM SO A PARTE DE CRIAR O BOSS RANDON NAO ESTA FUNCIONANDO E GOSTARIA DE AJUDA )

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

local config = {
    centerRoom = Position(32207, 32048, 14),
    bossPosition = Position(32207, 32048, 14),
    newPosition = Position(32223, 32048, 14)
}

local bosses = {
    {"Plagueroot"}, 
    {"Malofur Mangrinder"},
    {"Maxxenius"},
    {"Alptramun"},
    {"Izcandar The Banished"}
}
local function clearBosses()
    local spectators = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
    for i = 1, #spectators do
        local spectator = spectators
        if spectator:isPlayer() then    
            spectator:teleportTo(Position(32223, 32048, 14))
            spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            spectator:say('Time out! You were teleported out by strange forces.', TALKTYPE_MONSTER_SAY)
        elseif spectator:isMonster() then
            spectator:remove()
        end
    end
end

local LeverBoss = Action()
function LeverBoss.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        if player:getPosition() ~= Position(32208, 32021, 13) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Pise no piso logo a frente da alavaca para ativa-la.")
            item:transform(9825)
            return true
        end
    end
    if item.itemid == 9825 then
        local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
        for i = 1, #specs do
            spec = specs
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting white the Boss in the room.")
                return true
            end
        end

        for y = 32021, 32025 do
            local playerTile = Tile(Position(32208, y, 13)):getTopCreature()
            if playerTile and playerTile:isPlayer() then
                if playerTile:getStorageValue(GlobalStorage.BossesDreamCourtsTimer) > os.time() then
                    playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
                    playerTile:teleportTo(config.newPosition)
                    playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    playerTile:setStorageValue(GlobalStorage.BossesDreamCourtsTimer, os.time() + 20 * 3600)
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait a while, recently someone challenge Boss.")
                    return true
                end
            end
        end
        
        local randomBoss = math.random(1, #bosses)
        Game.createMonster(bosses, config.bossPosition, true, true)
        
        --addEvent(clearBosses, 30 * 60 * 1000)
        item:transform(9825)
    elseif item.itemid == 9825 then
        item:transform(9826)
    end
    return true
end

LeverBoss:aid(65500)
LeverBoss:register()

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

4 respostass a esta questão

Recommended Posts

  • 0
Majesty    1755
Majesty

Tenta assim:

Spoiler

local config = {
    centerRoom = Position(32207, 32048, 14),
    bossPosition = Position(32207, 32048, 14),
    newPosition = Position(32223, 32048, 14)
}

local bosses = {
    "Plagueroot", 
    "Malofur Mangrinder",
    "Maxxenius",
    "Alptramun",
    "Izcandar The Banished"
}

local function clearBosses()
    local spectators = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
    for i = 1, #spectators do
        local spectator = spectators[i]
        if spectator:isPlayer() then    
            spectator:teleportTo(Position(32223, 32048, 14))
            spectator:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
            spectator:say('Time out! You were teleported out by strange forces.', TALKTYPE_MONSTER_SAY)
        elseif spectator:isMonster() then
            spectator:remove()
        end
    end
end

local leverBoss = Action()
function leverBoss.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 then
        if player:getPosition() ~= Position(32208, 32021, 13) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Step on the tile in front of the lever to activate it.")
            item:transform(9825)
            return true
        end
    end
    if item.itemid == 9825 then
        local specs, spec = Game.getSpectators(config.centerRoom, false, false, 15, 15, 15, 15)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Someone is fighting with the Boss in the room.")
                return true
            end
        end

        for y = 32021, 32025 do
            local playerTile = Tile(Position(32208, y, 13)):getTopCreature()
            if playerTile and playerTile:isPlayer() then
                if playerTile:getStorageValue(GlobalStorage.BossesDreamCourtsTimer) > os.time() then
                    playerTile:getPosition():sendMagicEffect(CONST_ME_POFF)
                    playerTile:teleportTo(config.newPosition)
                    playerTile:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
                    playerTile:setStorageValue(GlobalStorage.BossesDreamCourtsTimer, os.time() + 20 * 3600)
                else
                    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait a while, recently someone challenge Boss.")
                    return true
                end
            end
        end    
    	
    	local randomBoss = bosses[math.random(#bosses)]
        Game.createMonster(randomBoss, config.bossPosition, true, true)
    	player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Monster created: " .. randomBoss)
        
        --addEvent(clearBosses, 30 * 60 * 1000)
        item:transform(9825)
    elseif item.itemid == 9825 then
        item:transform(9826)
    end
    return true
end

leverBoss:aid(65500)
leverBoss:register()

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
costickmichel    0
costickmichel

FUNCIONOU, muito obrigado. Uma outra duvida, tem como usar essa mesmo variável que cria o monstro pra deixar escrito qual monstro ela criou, igual da dream courts que mostra no quadro o boss do dia ?

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Majesty    1755
Majesty

Assim:

Spoiler

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Monster created: " .. randomBoss)

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×