Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Olá pessoal!

Vim pedir um script de duelo de pokémon, porém quero ele modificado para funcionar no tibia normal(sem pokémon)

Mesmo esquema de qualquer Ot de pokémon, a diferença é que NÃO usará pokémons, se o player aceitar o duelo, eles vão duelar até um deles ficar com 1 de hp e então o duelo acaba aparecendo Win e Lose

 

Espero que consigam, mas se não for possível aceito algo parecido uhehe

 

ps: se vier com banco de dados para rank win/lose é uma boa

ps²: só encontrei scripts de duel com pokemon aqui no fórum

 

Link para o post
Compartilhar em outros sites

Como o jogador chamaria o outro para duelar? Nos servidores de pokémon, é pelo order (um item). Seria da mesma maneira?

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Na verdade, pelos servers que eu vi o player clica com o botão direito em cima do adversário e invita pra duel com a quantia de pokes e tal..

qualquer coisa, aceito talkactions

Link para o post
Compartilhar em outros sites

Desculpe a demora, estive ocupado com outras coisas e não pude me concentrar no seu sistema. Ele já está, digamos, uns 95% pronto. Falta apenas finalizar um bloco de código e fazer uma rápida revisão. Como não tenho meios para testá-lo, deixarei esta tarefa para você.

edit: Confesso que, por ser um código um pouco grande, fiquei com preguiça de revisá-lo. Também gostaria de informar que os comandos de duelo foram escritos em talkaction, visto que não faço alterações no client.

Primeiramente, comandos e uma breve explicação com exemplos:

/duel invite [playername]     --Enviar solicitação de duelo.
e.g: /duel invite Cray
/duel accept [playername]     --Aceitar solicitação de duelo.
e.g: /duel accept Zipter
/duel refuse [playername]     --Recusar solicitação de duelo.
eg.: /duel refuse Zipter
/duel rank [win/lose]         --Ver rank de wins ou loses.
e.g: /duel rank win
/duel check                   --Checar status de duelo (wins/loses e winning ratio).
/duel giveup                  --Desistir.
Biblioteca do sistema:
data/lib:
DUEL_MAX_DISTANCE = 7                   --Distância máxima entre os dois jogadores para enviarem convites de duelo/aceitarem solicitações de duelo.
DUEL_RANK_LIMIT = 10                    --Limite do rank de wins/loses.
DUEL_START_TIME = 5                     --Tempo, em segundos, para o duelo começar.
DUEL_WIN_STORAGE = 4919
DUEL_LOSE_STORAGE = 4920
DUEL_STORAGE = 4921
DUEL_INVITE_STORAGE = 4922
DUEL_HP_STORAGE  = 4923
DUEL_MANA_STORAGE  = 4924
 
function table.insert(table, value)
    table[#table + 1] = value
end
function getWinningRatio(win, lose)   --Halls Santos
    if(type(win) ~= "number" or type(lose) ~= "number") then
        return nil, error("You need to specify a number value.")
    end
    if(win == 0 and lose == 0) then
        return 0.0
    end
    local ratio = win / (win + lose) * 100
    local i = 4
    if(math.floor(ratio) < 10) then
        i = 3
    end
    ratio = tostring(ratio):sub(1, i)
    return tonumber(ratio)
end
function sendDuelInvite(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        doPlayerSendTextMessage(target, 27, getCreatureName(cid).." sent you a duel invitation. To accept, say /duel accept "..getCreatureName(cid))
        local sto, str = getPlayerStorageValue(target, DUEL_INVITE_STORAGE), ""
        if tonumber(sto) then
            setPlayerStorageValue(target, DUEL_INVITE_STORAGE, getCreatureName(cid))
        else
            sto = sto:explode("/")
            table.insert(sto, getCreatureName(cid))
            for i = 1, #sto do
                if str == "" then
                    str = sto[i]
                else
                    str = str.."/"..sto[i]
                end
            end
            setPlayerStorageValue(target, DUEL_INVITE_STORAGE, str)
        end
    end
end
function isInDuel(cid)
    return getPlayerStorageValue(cid, DUEL_STORAGE) > -1
end
function getInvitation(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        local sto = getPlayerStorageValue(cid, DUEL_INVITE_STORAGE)
        if tonumber(sto) then
            return false
        end
        sto = sto:explode("/")
        return isInArray(sto, getCreatureName(target))
    end
    return false
end
function removeInvitation(cid, target)
    if isPlayer(cid) and isPlayer(target) then
        local sto, str = getPlayerStorageValue(cid, DUEL_INVITE_STORAGE):explode("/"), ""
        table.remove(sto, getCreatureName(target))
        for i = 1, #sto do
            if str == "" then
                str = sto[i]
            else
                str = str.."/"..sto[i]
            end
        end
        setPlayerStorageValue(cid, DUEL_INVITE_STORAGE, str)
    end
end
function duelTimer(time, cid, pid)
    if time < 0 then
        return true
    end
    doSendAnimatedText(getThingPos(cid), time == 0 and "START!" or time, 215)
    doSendAnimatedText(getThingPos(pid), time == 0 and "START!" or time, 215)
    addEvent(duelTimer, 1000, time - 1, cid, pid)
end
function startDuel(cid, target)
    duelTimer(DUEL_START_TIME, cid, target)
    setPlayerStorageValue(cid, DUEL_STORAGE, 1)
    setPlayerStorageValue(target, DUEL_STORAGE, 1)
    addEvent(function()
        if isPlayer(cid) and isPlayer(target) then
            setPlayerStorageValue(cid, DUEL_STORAGE, target)
            setPlayerStorageValue(cid, DUEL_HP_STORAGE, getCreatureHealth(cid))
            setPlayerStorageValue(cid, DUEL_MANA_STORAGE, getCreatureMana(cid))
            setPlayerStorageValue(cid, DUEL_INVITE_STORAGE, -1)
            setPlayerStorageValue(target, DUEL_STORAGE, cid)
            setPlayerStorageValue(target, DUEL_HP_STORAGE, getCreatureHealth(target))
            setPlayerStorageValue(target, DUEL_MANA_STORAGE, getCreatureMana(target))
            setPlayerStorageValue(target, DUEL_INVITE_STORAGE, -1)
        end
    end, DUEL_START_TIME * 1000)
end
function getDuelOpponent(cid)
    return getPlayerStorageValue(cid, DUEL_STORAGE)
end
function getPlayerWins(cid)
    return getPlayerStorageValue(cid, DUEL_WIN_STORAGE) < 0 and 0 or getPlayerStorageValue(cid, DUEL_WIN_STORAGE)
end
function getPlayerLoses(cid)
    return getPlayerStorageValue(cid, DUEL_LOSE_STORAGE) < 0 and 0 or getPlayerStorageValue(cid, DUEL_LOSE_STORAGE)
end
function endDuel(winner, loser)
    if isPlayer(winner) and isPlayer(loser) then
        setPlayerStorageValue(winner, DUEL_WIN_STORAGE, getPlayerWins(winner) + 1)
        setPlayerStorageValue(winner, DUEL_STORAGE, -1)
        doCreatureAddHealth(winner, getPlayerStorageValue(winner, DUEL_HP_STORAGE) - getCreatureHealth(winner))
        doCreatureAddMana(winner, getPlayerStorageValue(winner, DUEL_MANA_STORAGE) - getCreatureMana(winner))
        setPlayerStorageValue(loser, DUEL_STORAGE, -1)
        setPlayerStorageValue(loser, DUEL_LOSE_STORAGE, getPlayerLoses(loser) + 1)
        doCreatureAddHealth(loser, getPlayerStorageValue(loser, DUEL_HP_STORAGE) - getCreatureHealth(loser))
        doCreatureAddMana(loser, getPlayerStorageValue(loser, DUEL_MANA_STORAGE) - getCreatureMana(loser))
        doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_ORANGE, "You won the duel =] Victories: "..getPlayerWins(winner)..".")
        doPlayerSendTextMessage(loser, MESSAGE_STATUS_CONSOLE_ORANGE, "You lost the duel =[ Defeats: "..getPlayerLoses(loser)..".")
        doSendAnimatedText(getThingPos(winner), "WINNER", 255)
        doSendAnimatedText(getThingPos(loser), "LOSER", 255)
    end
end
Creaturescript:
data/creaturescripts/scripts:
function onLogin(cid)
    if isInDuel(cid) then
        setPlayerStorageValue(cid, DUEL_STORAGE, -1)
    end
    registerCreatureEvent(cid, "duelStatsChange")
    registerCreatureEvent(cid, "duelTarget")
    return true
end
function onLogout(cid)
    if isInDuel(cid) then
        return doPlayerSendCancel(cid, "You cannot logout during a duel.") and false
    end
    return true
end
function onTarget(cid, target)
    if isInDuel(cid) or isPlayer(target) and isInDuel(target) then
        return getDuelOpponent(cid) == target
    end
    return true
end
function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS and isPlayer(cid) and isInDuel(cid) or isPlayer(attacker) and isInDuel(attacker) then
        if getDuelOpponent(cid) ~= target then
            return false
        end
        if value >= getCreatureHealth(cid) then
            endDuel(attacker, cid)
            return false
        end
    end
    return true
end
Tags:
    <event type="login" name="duelLogin" event="script" value="nome_do_arquivo.lua"/>
    <event type="logout" name="duelLogout" event="script" value="nome_do_arquivo.lua"/> 
    <event type="statschange" name="duelStatsChange" event="script" value="nome_do_arquivo.lua"/>
    <event type="target" name="duelTarget" event="script" value="nome_do_arquivo.lua"/>  
Talkaction:
data/talkactions/scripts:

  Mostrar conteúdo oculto

Tag:
<talkaction words="/duel" event="script" value="nome_do_arquivo.lua"/>
Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Desculpe a demora manin!

/duel invite [playername]     --Enviar solicitação de duelo.             -- funcionando
e.g: /duel invite Cray
/duel accept [playername]     --Aceitar solicitação de duelo.           -- P1 invita o P2, para o P2 aceitar ele tem que invitar o P1 também, duel accept não funcional
e.g: /duel accept Zipter
/duel refuse [playername]     --Recusar solicitação de duelo.     -- não ta funcionando, fala que o player não me invitou pra duel
eg.: /duel refuse Zipter
/duel rank [win/lose]         --Ver rank de wins ou loses.              -- da erro na distro
e.g: /duel rank win
/duel check                   --Checar status de duelo (wins/loses e winning ratio).         --   aparece apenas uma janela com duels:" ..win+loses.."     wins: "..win" loses: "..loses.."
/duel giveup                  --Desistir.                                  -- não funciona

 

 

erro na distro do rank

[08/06/2015 01:00:16] [Error - TalkAction Interface]
[08/06/2015 01:00:16] data/talkactions/scripts/duel.lua:onSay
[08/06/2015 01:00:16] Description:
[08/06/2015 01:00:16] data/lib/004-database.lua:100: [Result:free] Result not set!
[08/06/2015 01:00:16] stack traceback:
[08/06/2015 01:00:16]     [C]: in function 'error'
[08/06/2015 01:00:16]     data/lib/004-database.lua:100: in function 'free'
[08/06/2015 01:00:16]     data/talkactions/scripts/duel.lua:28: in function <data/talkactions/scripts/duel.lua:1>

 

apareceram esses erros na distro

[08/06/2015 00:56:25] [Error - TalkAction Interface]
[08/06/2015 00:56:25] data/talkactions/scripts/duel.lua:onSay
[08/06/2015 00:56:25] Description:
[08/06/2015 00:56:25] (luaAddEvent) Callback parameter should be a function.

[08/06/2015 00:56:43] [Error - TalkAction Interface]
[08/06/2015 00:56:43] data/talkactions/scripts/duel.lua:onSay
[08/06/2015 00:56:43] Description:
[08/06/2015 00:56:43] (luaGetCreatureStorage) Creature not found

[08/06/2015 00:56:43] [Error - TalkAction Interface]
[08/06/2015 00:56:43] data/talkactions/scripts/duel.lua:onSay
[08/06/2015 00:56:43] Description:
[08/06/2015 00:56:43] data/lib/050-function.lua:936: attempt to compare boolean with number
[08/06/2015 00:56:43] stack traceback:
[08/06/2015 00:56:43]     data/lib/050-function.lua:936: in function 'getPlayerWins'
[08/06/2015 00:56:43]     data/lib/050-function.lua:943: in function 'endDuel'
[08/06/2015 00:56:43]     data/talkactions/scripts/duel.lua:43: in function <data/talkactions/scripts/duel.lua:1>
Link para o post
Compartilhar em outros sites

Já vi todos os erros. Foram, basicamente, total falta de atenção minha. Como estou de saída no momento, postarei a solução mais tarde.

EDIT: Pronto, códigos corrigidos. Agora o sistema está funcionando perfeitamente.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites
  Em 08/06/2015 em 17:52, zipter98 disse:

Já vi todos os erros. Foram, basicamente, total falta de atenção minha. Como estou de saída no momento, postarei a solução mais tarde.

EDIT: Pronto, códigos corrigidos. Agora o sistema está funcionando perfeitamente.

Expand   Mostrar mais  

 

 

/duel refuse  --- não ta funcionando

/duel rank win/lose -- não ta checando, embora se desistir do duel, aparece falando quantos loses tem quem desistiu e quantos win quem permaneceu

[08/06/2015 23:40:09] [Error - TalkAction Interface]
[08/06/2015 23:40:09] data/talkactions/scripts/duel.lua:onSay
[08/06/2015 23:40:09] Description:
[08/06/2015 23:40:09] data/lib/004-database.lua:100: [Result:free] Result not set!
[08/06/2015 23:40:09] stack traceback:
[08/06/2015 23:40:09]     [C]: in function 'error'
[08/06/2015 23:40:09]     data/lib/004-database.lua:100: in function 'free'
[08/06/2015 23:40:09]     data/talkactions/scripts/duel.lua:28: in function <data/talkactions/scripts/duel.lua:1>

ps: não sei o que tá acontecendo que antes tava normal, mas agora os players não se atacam nem que esteja server pvp/ enforced pvp e com o pvp do combat control ativado.. (protection level do config.lua = 1 , e o world type = 2)

 

o script é grande e já ta quase 100%, rep+ eueheuh

Editado por biel.stocco (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Você alterou a talkaction e a lib? Pelo menos aqui, ambos os comandos estão funcionando perfeitamente (para o rank ser atualizado, o jogador deve deslogar).

Sobre o problema dos jogadores não poderem se atacar normalmente, fiz uma pequena alteração no creaturescript para "corrigir" isso.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Das talkactions, apenas o Duel Refuse não está funcionando, o resto tá certinho!

porém se eu deixar o server pvp, os players se atacam mas se entrar em duel, já não se atacam mais.. não importa o world type, quem entra em duel não se ataca ;x

Link para o post
Compartilhar em outros sites

Apenas os participantes do duelo não conseguem se atacar?

Se possível, troque esta parte do creaturescript:

function onTarget(cid, target)
    if isInDuel(cid) or isPlayer(target) and isInDuel(target) then
        return getDuelOpponent(cid) == target
    end
    return true
end
por esta:
function onTarget(cid, target)
    print(0)
    if isInDuel(cid) or isPlayer(target) and isInDuel(target) then
        print(1)
        print(getCreatureName(cid).." - cid (VS: "..getDuelOpponent(cid)..")")
        print(getCreatureName(target).." - target (VS: "..getDuelOpponent(target)..")")
        return getDuelOpponent(cid) == target
    end
    return true
end
E informe o que for imprimido no console. 
PS: Recomendo targetar apenas uma vez, para não spammar muito a distro.
Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96823
    Tópicos
    519567
    Posts
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo