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
  • Respostas 13
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

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.

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.

Ops, esqueci de colocar uma informação para ser imprimida. Se possível, atualize o código novamente.

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

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

    96843
    Tópicos
    519602
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo