Postado Junho 4, 2015 10 anos 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
Postado Junho 4, 2015 10 anos 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
Postado Junho 4, 2015 10 anos Autor 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
Postado Junho 7, 2015 10 anos 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: function onSay(cid, words, param) local message = "" if not param or param == "" then return doPlayerSendCancel(cid, "Invalid arguments.") end if param:find("rank") then local storages, type = { ["win"] = DUEL_WIN_STORAGE, ["wins"] = DUEL_WIN_STORAGE, ["lose"] = DUEL_LOSE_STORAGE, ["loses"] = DUEL_LOSE_STORAGE, }, param:match("rank (.*)") if type and storages[type] then local result, count = db.getResult("SELECT player_id, value FROM player_storage WHERE key = "..storages[type].." ORDER BY value DESC LIMIT "..DUEL_RANK_LIMIT), 0 if result:getID() == -1 then message = "No one dueled until now." else repeat local playerValue = result:getDataInt("value") count = count + 1 if message == "" then message = "*** RANK "..type:upper().." ***" end message = message.."\n["..count.."] - "..getPlayerNameByGUID(result:getDataInt("player_id")).." ("..playerValue.." "..type..")" until not result:next() result:free() end doPlayerPopupFYI(cid, message) else doPlayerSendCancel(cid, "Invalid rank. Ranks: wins, loses.") end elseif param == "check" then local wins, loses = getPlayerWins(cid), getPlayerLoses(cid) message = "*** DUEL STATUS: ***\nDuels: "..wins + loses.."\nWins: "..wins.."\nLoses: "..loses.."\nWinning ratio: "..getWinningRatio(wins, loses).."%" doPlayerPopupFYI(cid, message) elseif param == "giveup" then if isInDuel(cid) then endDuel(getDuelOpponent(cid), cid) else doPlayerSendCancel(cid, "You're not in a duel.") end else if not param:find("accept") and not param:find("refuse") and not param:find("invite") then return doPlayerSendCancel(cid, "Invalid arguments.") end local targetName = param:explode(" ") if #targetName > 2 then local name = "" for i = 2, #targetName do if name == "" then name = targetName[i] else name = name.." "..targetName[i] end end targetName = name else targetName = targetName[2] end local target = getPlayerByName(targetName) if not target then return doPlayerSendCancel(cid, "This player doesn't exist or is offline.") end if param:find("invite") then if isInDuel(target) then return doPlayerSendCancel(cid, "This player is already in a duel.") elseif getDistanceBetween(getThingPos(cid), getThingPos(target)) > DUEL_MAX_DISTANCE then return doPlayerSendCancel(cid, "You're too far from "..targetName..".") elseif getInvitation(cid, target) then return doPlayerSendCancel(cid, "You already invited this player to a duel.") elseif target == cid then return doPlayerSendCancel(cid, "You can't invite yourself to a duel.") end sendDuelInvite(cid, target) doPlayerSendTextMessage(cid, 27, "You sent "..targetName.." a duel invitation.") elseif param:find("accept") then if getInvitation(cid, target) then if isInDuel(target) then return doPlayerSendCancel(cid, "This player is already in a duel."), removeInvitation(cid, target) elseif getDistanceBetween(getThingPos(cid), getThingPos(target)) > DUEL_MAX_DISTANCE then return doPlayerSendCancel(cid, "You're too far from "..targetName..".") end doPlayerSendTextMessage(cid, 27, "You accepted "..targetName.." invitation. The duel will start in some seconds.") doPlayerSendTextMessage(target, 27, getCreatureName(cid).." accepted your invitation. The duel will start in some seconds.") startDuel(cid, target) else doPlayerSendCancel(cid, "This player hasn't invited you to a duel.") end elseif param:find("refuse") then if getInvitation(cid, target) then removeInvitation(cid, target) doPlayerSendTextMessage(cid, 27, "You refused "..targetName.." invitation.") doPlayerSendTextMessage(target, 27, getCreatureName(cid).." refused your invitation.") else doPlayerSendCancel(cid, "This player hasn't invited you to a duel.") end else doPlayerSendCancel(cid, "Invalid arguments.") end end return true end Tag: <talkaction words="/duel" event="script" value="nome_do_arquivo.lua"/> Editado Junho 9, 2015 10 anos por zipter98 (veja o histórico de edições) não respondo pms solicitando suporte em programação/scripting
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.