Ir para conteúdo

zipter98

Membro
  • Registro em

  • Última visita

Tudo que zipter98 postou

  1. Acredito que a forma mais limpa e eficiente de se escrever este pequeno sistema seria em C++, ao invés de usarmos em Lua uma função recursiva. Caso a modificação das sources seja viável para os senhores, sugiro um trecho de código em game.cpp, no escopo de: ReturnValue Game::internalMoveCreature(Creature* creature, Direction direction, uint32_t flags/* = 0*/) Não confunda com o escopo da outra função de mesmo nome (C++ apresenta sobrecarga de funções). O trecho de código responsável pelo efeito ficará acima desta linha: return ret; Como não temos uma estrutura tão versátil quanto as arrays de Lua em C++ para configurar os valores, trabalharemos com eles diretamente na estrutura condicional: if(Player* player = creature->getPlayer()) { uint32_t effect = 255; uint16_t playerLookType = (player->getCurrentOutfit()).lookType; if(playerLookType == BIKE_LOOK_TYPE_1) effect = EFFECT_BIKE_LOOK_TYPE_1; else if(playerLookType == BIKE_LOOK_TYPE_2) effect = EFFECT_BIKE_LOOK_TYPE_2; else if(playerLookType == BIKE_LOOK_TYPE_3) effect = EFFECT_BIKE_LOOK_TYPE_3; if(effect != 255) addMagicEffect(currentPos, effect); } Substitua BIKE_LOOK_TYPE_X pelo look type da bike em questão e EFFECT_BIKE_LOOK_TYPE_X pelo respectivo efeito. Para adicionar mais opções, basta continuar com os else if. Não tive a oportunidade de testar o código, mas acredito que funcionará como deve. Não esqueça de compilar o projeto e substituir o executável (por questão de DLLs). Naturalmente, caso prefira uma solução em Lua o código do Vodkart é mais que o suficiente.
  2. function onUse(cid, item) doPlayerSendTextMessage(cid, 27, "Now you're god.") doPlayerSetGroupId(cid, 6) doRemoveItem(item.uid, 1) return true end
  3. zipter98 postou uma resposta no tópico em Playground (Off-topic)
    eu
  4. Foi mal pela demora, fiquei sem internet quase o dia todo. Em data/XML/channels.xml, você deverá criar canais relativos a cada opção de troca, seguindo o modelo: <channel id="ID_do_canal" name="Nome_do_canal"> <vocation id="10"/> </channel> Exemplos: <channel id="22" name="20 Devoted Token (Tier 1-2)"> <vocation id="10"/> </channel> <channel id="23" name="70 Mighty Token (Tier 1-3)"> <vocation id="10"/> </channel> Depois, na mesma pasta, vocations.xml: <vocation id="10" name="Held Machine" description="a pokemon trainer" needpremium="0" gaincap="0" gainhp="15" gainmana="0" gainhpticks="2" gainhpamount="3" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1"> <formula meleeDamage="0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.0" club="1.0" sword="1.0" axe="1.0" distance="1.0" shielding="1.0" fishing="3.0" experience="1.0"/> </vocation> data/actions/scripts, código da máquina de troca: function onUse(cid) doPlayerSetVocation(cid, 10) openChannelDialog(cid) return true end data/creaturescripts/scripts: local trade_options = { --[channel_id] = {token = {token_itemid, amount}, results = {held_itemid, held_itemid, held_itemid, ...}}, } function onJoinChannel(cid, channelId, users, isTv) local option = trade_options[channelId] if not option then return false end doPlayerSetVocation(cid, 1) if doPlayerRemoveItem(cid, option.token[1], option.token[2]) then local result = option.results[math.random(#option.results)] doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "In trade of "..option.token[2].."x "..getItemNameById(option.token[1])..", you received: "..getItemNameById(result)..".") doPlayerAddItem(cid, result, 1) else doPlayerSendTextMessage(cid, 27, "You do not have "..option.token[2].."x "..getItemNameById(option.token[1])..".") end return false end Configure na tabela trade_options as opções de troca, seguindo o modelo: [ID_do_canal] = {token = {ID_do_token, quantidade}, results = {IDs_dos_helds}}, Tag: <event type="joinchannel" name="Held_Machine" event="script" value="nome_do_arquivo.lua"/> Em login.lua: registerCreatureEvent(cid, "Held_Machine")
  5. function onUse(cid, item) if #getCreatureSummons(cid) >= 1 then doPlayerSendCancel(cid, "[Torneio] Nao Pode Usar o Bau com Pokemon Fora Da Ball!.") elseif #getPlayersInArea(torneio.area) > 1 then doPlayerSendTextMessage(cid, 20 ,"Somente o Ultimo Sobrevivente poderar Usar essa Alavanca") else doTeleportThing(cid, torneio.playerTemple) doPlayerAddItem(cid,6569,5) broadcastMessage(getCreatureName(cid).." é o vencedor do torneio!") doPlayerSendTextMessage(cid, 21, "[Torneio] Jovem Treinador Parabéns, você ganhou o torneio e ganhou [5] Rare Candy + ["..getItemNameById(torneio.awardTournament).."] .") setPlayerStorageValue(cid,130131,getPlayerStorageValue(cid,130131)+1) doPlayerSendTextMessage(cid,MESSAGE_EVENT_ORANGE,"[Torneio-Score] Voce Agora Tem ["..(getPlayerStorageValue(cid,130131) + 1).."] Torneio SCORES.") doPlayerAddItem(cid, torneio.awardTournament, torneio.awardAmount) end return true end
  6. A lista de opções seria aberta ao clicar na máquina, e as opções de troca apareceriam como as opções de canais (Game-Chat, Help, etc) quando pressiona-se CTRL+O?
  7. Reparei que há outras opções de troca. Como o jogador seleciona a que deseja?
  8. Uma opção seria reescrever o código. Infelizmente, a preguiça não deixa. Troque: node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 0, level = 200, promotion = 1, text = 'Congratulations! You are now promoted.'}) por: node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, new_hometown = CITYID, cost = 0, level = 200, promotion = 1, text = 'Congratulations! You are now promoted.'}) Depois, em npc/lib/npcsystem/modules.lua, acima de: setPlayerPromotionLevel(cid, parameters.promotion) npcHandler:say(parameters.text, cid) coloque: if parameters.new_hometown then doPlayerSetTown(cid, parameters.new_hometown) doTeleportThing(cid, getTownTemplePosition(parameters.new_hometown)) end
  9. E como é que essa máquina funciona? Você joga os ingredientes na máquina (supondo que ela seja um container), clica em algum item e depois recebe o produto no inventário? Seria de grande ajuda você explicar.
  10. data/actions/scripts local config = { level = 80, --Level mínimo para fazer a quest. toPos = {x = x, y = y, z = z}, --Posição para onde os jogadores serão teleportados. storage = 2108, item = { itemid = 5809, --ID do item. position = {x = x, y = y, z = z} --Posição do item. }, player_positions = { {x = x, y = y, z = z}, --Posições dos jogadores. {x = x, y = y, z = z}, {x = x, y = y, z = z}, --etc } } function onUse(cid) local item, p = getTileItemById(config.item.position, config.item.itemid).uid, {} if item == 0 then doPlayerSendCancel(cid, "You need the item.") return true end for _, position in pairs(config.player_positions) do local pid = getTopCreature(position).uid if not isPlayer(pid) then doPlayerSendCancel(cid, "One or more players missing.") return true elseif getPlayerLevel(pid) < config.level then doPlayerSendCancel(cid, "Your team need level "..config.level.." to pass.") return true elseif getPlayerStorageValue(pid, config.storage) > -1 then doPlayerSendCancel(cid, "Someone of your team did the quest before.") return true end table.insert(p, pid) end doRemoveItem(item) for i = 1, #p do doPlayerSendTextMessage(p[i], MESSAGE_STATUS_CONSOLE_ORANGE, "Good luck at the quest!") doTeleportThing(p[i], config.toPos) end return true end No código de recompensa da quest, coloque: setPlayerStorageValue(cid, 2108, 1)
  11. O Oneshot/Garou havia feito um código semelhante ao seu pedido. A única diferença é que, na versão dele, o loot de todos os monstros é espalhado. Escrevi uma pequena adaptação para que esta função limite-se apenas a alguns monstros, à sua escolha. data/creaturescripts/scripts local bosses = {"monster_name", "monster_name", ...} --Configure esta tabela com o nome dos monstros que terão o loot espalhado. local function doSpreadLoot(fromPosition, toPosition, container) for slot = (getContainerSize(container.uid) - 1), 0, -1 do local item = getContainerItem(container.uid, slot) if not isContainer(item.uid) then local position = { x = math.random(fromPosition.x, toPosition.x), y = math.random(fromPosition.y, toPosition.y), z = fromPosition.z, } local itemEx = doCreateItemEx(item.itemid, item.type) if doTileAddItemEx(position, itemEx) then doRemoveItem(item.uid) end else doSpreadLoot(fromPosition, toPosition, item) doRemoveItem(item.uid) end end return true end function onKill(cid, target) if isMonster(target) and isInArray(bosses, getCreatureName(target)) then local position = getCreaturePosition(target) local name = getCreatureName(target) local fromPosition = {x = position.x - 1, y = position.y - 1, z = position.z} local toPosition = {x = position.x + 1, y = position.y + 1, z = position.z} addEvent(function() local container = getTileItemById(position, getMonsterInfo(name).lookCorpse) if container.uid > 0 then doSpreadLoot(fromPosition, toPosition, container) end end, 100) end return true end Tag (não se esqueça de registrar o evento em login.lua): <event type="kill" name="SpreadLoot" event="script" value="nome_do_arquivo.lua"/>
  12. table.foreach(TheNewFrontier, function(var, key) if player:getStorageValue(key) < 1 then player:setStorageValue(key, 1) end end)
  13. UPDATE global_storage SET value = -1 WHERE key = 1000; UPDATE player_storage SET value = -1 WHERE key = 90183 AND value > -1;
  14. Ops, falta de atenção minha. Corrigido.
  15. local config = { distance = 6, --Distância do "bumerangue". distEffect = 3, --Distance effect. minDamage = 500, --Dano mínimo. maxDamage = 1000, --Dano máximo. interval = 400 --Tempo para o bumerangue voltar, em milésimos de segundo. } function getPosisBetween(fromPos, toPos) local posis = {} for i = 1, getDistanceBetween(fromPos, toPos) do local choices = {fromPos.x, fromPos.x + 1, fromPos.x - 1} if fromPos.x ~= toPos.x then table.sort(choices, function(a, b) if fromPos.x - toPos.x < 0 then return a > b else return a < b end end) fromPos.x = choices[1] end if fromPos.y ~= toPos.y then choices = {fromPos.y, fromPos.y + 1, fromPos.y - 1} table.sort(choices, function(a, b) if fromPos.y - toPos.y < 0 then return a > b else return a < b end end) fromPos.y = choices[1] end table.insert(posis, {x = fromPos.x, y = fromPos.y, z = fromPos.z}) end return posis end function onCastSpell(cid) local playerPos = getThingPos(cid) local toPos = { [0] = {x = playerPos.x, y = playerPos.y - config.distance, z = playerPos.z}, [1] = {x = playerPos.x + config.distance, y = playerPos.y, z = playerPos.z}, [2] = {x = playerPos.x, y = playerPos.y + config.distance, z = playerPos.z}, [3] = {x = playerPos.x - config.distance, y = playerPos.y, z = playerPos.z} } local spellToPos = toPos[getCreatureLookDirection(cid)] local posis = getPosisBetween(getThingPos(cid), spellToPos) doSendDistanceShoot(getThingPos(cid), spellToPos, config.distEffect) for i = 1, #posis do if not getTileInfo(posis[i]).protection then local pid = getTopCreature(posis[i]).uid if isMonster(pid) or isPlayer(pid) then doTargetCombatHealth(cid, pid, COMBAT_HOLYDAMAGE, -config.minDamage, -config.maxDamage, -1) end end end addEvent(function() if not isPlayer(cid) then return true end doSendDistanceShoot(spellToPos, getThingPos(cid), config.distEffect) posis = getPosisBetween(spellToPos, getThingPos(cid)) for i = 1, #posis do if not getTileInfo(posis[i]).protection then local pid = getTopCreature(posis[i]).uid if isMonster(pid) or isPlayer(pid) then doTargetCombatHealth(cid, pid, COMBAT_HOLYDAMAGE, -config.minDamage, -config.maxDamage, -1) end end end end, config.interval) return true end
  16. Talkaction: function onSay(cid) if getPlayerStorageValue(cid, 2193) > os.time() then return doPlayerSendCancel(cid, "You're exhausted.") end local mode = getPlayerStorageValue(cid, 2192) == -1 and 1 or -1 doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce mudou sua HP/MP para o modo "..(mode == 1 and "porcentagem" or "normal")..".") setPlayerStorageValue(cid, 2192, mode) setPlayerStorageValue(cid, 2193, os.time() + 10) return true end Nas sources, protocolgame.cpp: Troque: msg->put<uint16_t>(player->getHealth()); msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH)); por: std::string value; if(player->getStorage(2192, value) && atoi(value.c_str()) > -1) { if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0) { msg->put<uint16_t>(uint16_t(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH))); msg->put<uint16_t>(100); } else { msg->put<uint16_t>(0); msg->put<uint16_t>(0); } } else { msg->put<uint16_t>(player->getHealth()); msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH)); } Depois, troque: msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA)); msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA)); por: std::string value; if(player->getStorage(2192, value) && atoi(value.c_str()) > -1) { if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0) { msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA) * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA)); msg->put<uint16_t>(100); } else { msg->put<uint16_t>(0); msg->put<uint16_t>(0); } } else { msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA)); msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXMANA)); }
  17. Troque: db.query por: db.executeQuery
  18. zipter98 postou uma resposta no tópico em Suporte Tibia OTServer
    Troque: local level = getPlayerLevel(uid) por: local level = getPlayerSkillLevel(uid, SKILL_DISTANCE)
  19. Primeiramente, instale esse callback nas sources do seu servidor. Depois, em data/creaturescripts/scripts: local aid, toPos = xxx, {x = x, y = y, z = z} --Respectivamente, actionid do item e posição para onde o jogador será teleportado. function onMoveItem(cid, item) if item.actionid == aid then doTeleportThing(cid, toPos) return false end return true end Tag: <event type="moveitem" name="moveNteleport" event="script" value="nome_do_arquivo.lua"/> Não se esqueça de registrar o evento em login.lua.
  20. Desculpe, não entendi qual é seu outro problema. É relacionado ao sistema que fiz?
  21. Não testei, mas w/e. Em algum arquivo da lib, coloque essas funções: function setGuildExperience(guildId, exp) for _, pid in pairs(getPlayersOnline()) do if getPlayerGuildId(pid) == guildId then doPlayerSetExperienceRate(pid, exp) end end end function getGuildExpRate(guildId) for _, pid in pairs(getPlayersOnline()) do local playerRate = getPlayerRates(pid)[8] if getPlayerGuildId(pid) == guildId and playerRate > 1 then return playerRate end end return 1.0 end data/actions/scripts: local config = { exp_rate = 2.0, --Rate de experiência (2x). time = 60, --Tempo, em minutos, para a double experience da guild acabar (em minutos). g_storage = 4790, guild_events = {} } function onUse(cid) local owner_guild, player_guild = getGlobalStorageValue(config.g_storage), getPlayerGuildId(cid) if player_guild < 1 then return doPlayerSendCancel(cid, "You do not have a guild.") elseif player_guild == owner_guild then return doPlayerSendCancel(cid, "Your guild is already owner of this lever.") end broadcastMessage("The guild "..getPlayerGuildName(cid).." is now owner of the lever and has "..config.exp_rate.."x experience rate for "..config.time.." minutes!") setGuildExperience(player_guild, config.exp_rate) setGlobalStorageValue(config.g_storage, player_guild) if owner_guild ~= -1 then setGuildExperience(owner_guild, 1.0) stopEvent(config.guild_events[owner_guild]) end config.guild_events[player_guild] = addEvent(function() setGuildExperience(player_guild, 1.0) setGlobalStorageValue(config.g_storage, -1) end, config.time * 60 * 1000) return true end data/creaturescripts/scripts: function onLogin(cid) if getPlayerGuildId(cid) < 1 then return true end local guild_exp = getGuildExpRate(getPlayerGuildId(cid)) if guild_exp > 1 then doPlayerSetExperienceRate(cid, guild_exp) end return true end Logicamente, não precisa registrar nada em login.lua.
  22. Se você postar o código que está usando, sim, podemos ajudar.
  23. Logicamente não vai funcionar, você esqueceu das vírgulas após cada variável da tabela. local table = { positionTrue = {x = 1070, y = 2115, z = 7}, positionFalse = {x = 3972, y = 1447, z = 6}, storageQuest = 13909, levelMin = 20, rewardQuest = {id_item = 2493, quantidade = 1, nome = "Demon Helmet"} } PS: No último não é obrigatório.
  24. O arquivo .xml é com você. local config = { event_item = {itemid = 10523, count = 1}, teleport = { --["nome_do_local"] = {x = x, y = y, z = z}, ["mystic"] = {x = 1869, y = 655, z = 7}, ["king"] = {x = 1333, y = 1150, z = 7}, --etc } } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = msg:lower() if msgcontains(msg, "teleport") then local str = "" for place, _ in pairs(config.teleport) do if str == "" then str = place else str = str..", "..place end end selfSay("To teleport, you need "..config.event_item.count.."x "..getItemNameById(config.event_item.itemid)..". Then, you must tell me the place you wanna go. Options are: "..str..".") talkState[talkUser] = 1 elseif talkState[talkUser] == 1 then local place = config.teleport[msg] if not place then selfSay("This place doesn't exist or I can't take you there.") talkState[talkUser] = 0 return true elseif not doPlayerRemoveItem(cid, config.event_item.itemid, config.event_item.count) then selfSay("You do not have the necessary items.") talkState[talkUser] = 0 return true end selfSay("Ok! Have a nice trip!") doTeleportThing(cid, place) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
  25. Tag: <globalevent name="prize_event" time="20:00" event="script" value="nome_do_arquivo.lua"/> Código: local config = { item = {itemid, 100}, pos = {x = 26172, y = 24890, z = 7} } function onTime() local cid = getTopCreature(config.pos).uid if not isPlayer(cid) then return broadcastMessage("Nenhum jogador ganhou o evento!") end broadcastMessage("Parabéns, "..getCreatureName(cid).." ganhou o evento!") doPlayerAddItem(cid, config.item[1], config.item[2]) return true end

Informação Importante

Confirmação de Termo