Ir para conteúdo
  • 0

[Resolvido] (Ajuda) evento Bomberman


crimow

Pergunta

Eae pessoal, tranquilidade? Eu espero que sim.
Primeiro de tudo, estou com um projeto "fechado" (digo, sozinho.) remixando um Baiak e quero deixar a jogabilidade/mapa dele um pouco melhor, com alguns sistemas "novos". Com mais emoção, e sem essa massividade de "correr, upar, correr, quest, ficar forte, 900 quests vip. druid forte pra caralhoooo, essa praga nao morre... NÃO!". e sim com uma jogabilidade empolgante com as vocações "balanceadas" e devidamente do jeito que a logica deve ser.
(não estou reclamando do sistema implantado no mapa original, afinal, o que seria esse mini projeto sem o oficial? re-lembrando estou remixando o mapa.)
 

Spoiler

Fechando esse evento e concluindo 100% estou pensando em fazer um maior ou liberar pra vocês assim como esta nas fotos. Sim, scripts + mapa!
(Assim como TODOS vocês fazem, criam e compartilham. ♥)


Então, vamos lá!

1. Eu pego os Buff's, porem, quando o personagem morre e ele vai fazer novamente o evento ele continua (que no caso era pra recomeçar do 0) com o buff de fogo, ou seja não reseta (Ele volta com 4 sqm de fogo. SEMPRE! WTF?)

5rFeiHB.png


2. Quando os jogadores morrem na area, o evento que era pra automaticamente se "refazer" não esta se refazendo. ficando assim. (essa é a posição do espectador.)

GpIJeUR.png

3. Erro. (as vezes da erro em outras linhas, porem é o mesmo 'LoopDir' e não entendo muito bem o que seja isso)

t5XjOV0.png

4. Script, Bomb.lua usado.
 

Citar

function getPlayersInRange(position, radiusx, radiusy)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
                if creature.type == 1 then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end

    local creature = getTopCreature(position)
    if creature.type == 1 then
        if not(table.find(creaturesList, creature.uid)) then
            table.insert(creaturesList, creature.uid)
        end
    end
    return creaturesList
end

function isPositionInArray(haystack, needle)
    for i = 1, #haystack do
        if haystack.x == needle.x and haystack.y == needle.y and haystack.z == needle.z then
            return true
        end
    end
    return false
end

local t = {
    from = {x=1442, y=1123, z=7},
    to = {x=1456, y=1133, z=7},
    storage = {
        placed = 10001,
        max = 10002,
        radius = 10003
    },
    delay = 3000,
    bombID = 9468,
    effect = CONST_ME_FIREAREA,
    blockID = 9421,
    text = "BooooM!",
    temple = {x= 155, y= 52, z= 7},
    exceptions = {
        {x=1442, y=1123, z=7},
        {x=1443, y=1123, z=7},
        {x=1442, y=1124, z=7},
        
        {x=1455, y=1123, z=7},
        {x=1456, y=1123, z=7},
        {x=1456, y=1124, z=7},
        
        {x=1442, y=1133, z=7},
        {x=1442, y=1132, z=7},
        {x=1443, y=1133, z=7},
        
        {x=1455, y=1133, z=7},
        {x=1456, y=1133, z=7},
        {x=1456, y=1132, z=7}
    }
}
function reset()
    local dummy = doCreateItem(9468, 1, {x=155, y=52, z=7})
    for x = t.from.x, t.to.x do
        for y = t.from.y, t.to.y do
            local pos = {x=x,y=y,z=t.from.z}
            local i1, i2, i3  = getTileItemById(pos, 8304).uid, getTileItemById(pos, 2642).uid, getTileItemById(pos, 8305).uid
            if i1 > 0 then
                doRemoveItem(i1)
            end
            if i2 > 0 then
                doRemoveItem(i2)
            end
            if i3 > 0 then
                doRemoveItem(i3)
            end
            if queryTileAddThing(dummy, pos, 4) == RETURNVALUE_NOERROR and not isPositionInArray(t.exceptions, pos) then
                doCreateItem(t.blockID, 1, pos)
            end
        end
    end
    doRemoveItem(dummy)
end

local function boom(pos, cid)
    local v = getTileItemById(pos, t.bombID).uid
    if isPlayer(cid) and isInRange(getThingPos(cid), t.from, t.to) then
        setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
        doCreatureSay(cid, t.text, TALKTYPE_ORANGE_2, false, nil, pos)
        doSendMagicEffect(pos, t.effect)
        local c = getTopCreature(pos).uid
        if isPlayer© and isInRange(getThingPos©, t.from, t.to) then
            doSendMagicEffect(pos, CONST_ME_GIFT_WRAPS)
            doTeleportThing(c, t.temple)
            doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
            local n1, n2 = getPlayerName©, getPlayerName(cid)
            doBroadcastMessage(n1==n2 and n1 .. " Morreu pra " .. (getPlayerSex© == 0 and " ele " or " ela ") .. " mesmo!" or n1 .. " Foi morto por " .. n2 .. "!", MESSAGE_STATUS_WARNING)
            local a = getPlayersInRange({x= 1449, y= 1128, z= 7}, 7, 5)
            if #a < 2 then
                doBroadcastMessage(getPlayerName(a[1]) .. " Venceu a partida!", MESSAGE_STATUS_WARNING)
                doTeleportThing(a[1], t.temple)
                doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
                reset()
                reset()
            end
        else
            local b = getTileItemById(pos, t.blockID).uid
            if b > 0 then
                doSendMagicEffect(pos, CONST_ME_BLOCKHIT)
                doRemoveItem(b)
                local r = math.random(10)
                if r < 4 then
                    doCreateItem(r==1 and 8304 or r==2 and 2642 or r==3 and 8305, 1, _pos)
                end
            end
        end
        local N, E, W, S, l = 1, 1, 1, 1, getPlayerStorageValue(cid, t.storage.radius)
        function loopDir(dir)
            local _pos = {x=pos.x+(dir=="E" and E or dir=="W" and -W or 0), y=pos.y+(dir=="N" and -N or dir=="S" and S or 0), z=pos.z}
            if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.blockID).uid > 0 then
                doSendMagicEffect(_pos, t.effect)
                local c = getTopCreature(_pos).uid
                if isPlayer© and isInRange(getThingPos©, t.from, t.to) then
                    doSendMagicEffect(_pos, CONST_ME_GIFT_WRAPS)
                    doTeleportThing(c, t.temple)
                    doSendMagicEffect(t.temple, CONST_ME_MORTAREA)
                    local n1, n2 = getPlayerName©, getPlayerName(cid)
                    doBroadcastMessage(n1==n2 and n1 .. " Morreu pra " .. (getPlayerSex© == 0 and " ele " or " ela ") .. "mesmo!" or n1 .. " Foi morto por " .. n2 .. "!", MESSAGE_STATUS_WARNING)
                    local a = getPlayersInRange({x= 1449, y= 1128, z= 7}, 7, 5)
                    if #a < 2 then
                        doBroadcastMessage(getPlayerName(a[1]) .. " Venceu a partida!", MESSAGE_STATUS_WARNING)
                        doTeleportThing(a[1], t.temple)
                        doSendMagicEffect(t.temple, CONST_ME_FIREWORK_RED)
                        reset()
                        reset()
                        return "Fim de jogo."
                    end
                else
                    local b = getTileItemById(_pos, t.blockID).uid
                    if b > 0 then
                        doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
                        doRemoveItem(b)
                        local r = math.random(10)
                        if r < 4 then
                            doCreateItem(r==1 and 8304 or r==2 and 2642 or r==3 and 8305, 1, _pos)
                        end
                        return false
                    end
                end
            elseif queryTileAddThing(v, _pos, 4) == 3 then
                return false
            end
            return true
        end
        while N <= l do
            local q = loopDir("N")
            if q == "Fim de jogo." then
                return doRemoveItem(v, 1)
            elseif not q then
                break
            else
                N = N + 1
            end
        end
        while E <= l do
            local q = loopDir("E")
            if q == "Fim de jogo." then
                return doRemoveItem(v, 1)
            elseif not q then
                break
            else
                E = E + 1
            end
        end
        while W <= l do
            local q = loopDir("W")
            if q == "Fim de jogo." then
                return doRemoveItem(v, 1)
            elseif not q then
                break
            else
                W = W + 1
            end
        end
        while S <= l do
            local q = loopDir("S")
            if q == "Fim de jogo." then
                return doRemoveItem(v, 1)
            elseif not q then
                break
            else
                S = S + 1
            end
        end
    end
    doRemoveItem(v, 1)
end
function onSay(cid, words, param, channel)
    if isInRange(getThingPos(cid), t.from, t.to) then
        setPlayerStorageValue(cid, t.storage.placed, math.max(getPlayerStorageValue(cid, t.storage.placed), 0))
        setPlayerStorageValue(cid, t.storage.max, math.max(getPlayerStorageValue(cid, t.storage.max), 1))
        setPlayerStorageValue(cid, t.storage.radius, math.max(getPlayerStorageValue(cid, t.storage.radius), 1))
        if getPlayerStorageValue(cid, t.storage.placed) < getPlayerStorageValue(cid, t.storage.max) then
            doCreateItem(t.bombID, 1, getThingPos(cid))
            addEvent(boom, t.delay, getThingPos(cid), cid)
            setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
        end
        return true
    end
end


5. Em Talkaction.lua
 

Citar

<talkaction words="!bomba" event="script" value="bomb.lua"/>

 

Citar

(Cliente 8.60 Tsf 0.3.6)



Não sei se esta na área certa, peço a compreensão de todos e, ficarei grato com a ajuda que puderem me dar e mencionarei nos créditos final.
(Existe muitas duvidas sobre esse evento e várias outras publicações no fórum, sobre o mesmo, porem quero botar ele pra funcionar. Se existir um completo pra poder baixar, seria bem mais fácil!)

Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...