Yo boyz, cá estou novamente.
Eu estava procurando um Addon System funcional e vi que todos tinham bugs, então eu peguei um aqui no fórum mesmo, corrigi os bugs e fiz para que o sistema funcione com fly, ride, surf, look e que o addon suma quando o pokémon evoluir. Também é possível substituir um addon por outro, sem que o pokémon fique com o addon antigo.
São muitos arquivos envolvidos, então, se eu esquecer algo e o sistema não esteja 100%, por favor, me fale.
Deixei alguns exemplos no código para caso você esteja com preguiça e queira testar, além de comentar como adicionar novos addons.
OBS: Eu testei apenas em PDA PokexCyan (TFS 1.0).
actions/scripts
nome_arquivo.lua
local addons = {
[14876] = {pokemon = "Shiny Charizard" , looktype = 1950},
[12344] = {pokemon = "Pidgeot" , looktype = 205},
[13990] = {pokemon = "Pidgeot" , looktype = 201},
--[ID do item] = {nome do pokémon, looktype},
}
local function getOldAddon (looktype)
for index, value in pairs (addons) do
if value.looktype == looktype then
return index
end
end
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local numero = addons[item.itemid].looktype
local pb = itemEx.uid
local pk = addons[item.itemid].pokemon
if not isPokeball(itemEx.itemid) then
doPlayerSendCancel(cid, "Você só poder usar este item em uma poke ball.")
return true
end
if getPlayerSlotItem (cid, 8).uid == pb and (getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 63215) >= 1) then
doPlayerSendCancel (cid, "Desmonte do seu pokémon e volte-o para a poke ball.")
return true
end
if getItemAttribute(pb, "addon") and getItemAttribute(pb, "addon") == numero then
doPlayerSendCancel(cid, "Seu pokémon já está com este addon.")
return true
end
if #getCreatureSummons(cid) > 0 then
doPlayerSendCancel(cid, "Por favor, volte o seu pokémon para a poke ball.")
return true
end
if getItemAttribute(pb, "poke") ~= pk then
doPlayerSendCancel(cid, "Desculpe, você não pode adicionar este addon neste pokémon.")
return true
end
if getItemAttribute (pb, "addon") and getItemAttribute (pb, "addon") > 1 then
doPlayerSendTextMessage(cid, 27, "Você substituiu um "..getItemNameById (getOldAddon (getItemAttribute (pb, "addon"))).." por um "..getItemNameById (item.itemid).."!")
else
doPlayerSendTextMessage(cid, 27, "Agora seu pokémon usará este "..getItemNameById (item.itemid).."!")
end
doRemoveItem(item.uid, 1)
doSetItemAttribute(pb, "addon", numero)
return true
end
actions.xml:
<action itemid="13989;12344;13990;ID do item; ID do item;" event="script" value="nome_arquivo.lua"/>
em actions/order.lua, abaixo de:
if not isCreature(pk) then
pk = doCreateMonster(pokemon, backupPos)
if not isCreature(pk) then
doPlayerSendCancel(cid, "You can't stop flying/riding here.")
return true
end
doConvinceCreature(cid, pk)
end
adicione:
local pb = getPlayerSlotItem(cid, 8).uid
local flyAdd = flysAddon[getItemAttribute (pb, "addon")]
local rideAdd = ridesAddon[getItemAttribute (pb, "addon")]
if flyAdd then
if getItemAttribute(pb, "addon") > 1 then
doSetCreatureOutfit(pk, {lookType = getItemAttribute (pb, "addon")}, -1)
end
elseif rideAdd then
if getItemAttribute(pb, "addon") > 1 then
doSetCreatureOutfit(pk, {lookType = getItemAttribute (pb, "addon")}, -1)
end
end
em lib/configuration.lua, será necessário adicionar três tabelas, uma para fly, outra para ride e outra para surf. Nesta tabela, o nome do pokémon não é requirido, o que talvez faça você se perder. Se você achar necessário, comente com "--" o nome do pokémon.
Exemplo:
[205] = {540, 1200}, -- Pidgeot
[850] = {210, 800}, -- Dragonair
procure por: flys
e acima disso adicione:
flysAddon = {
[205] = {540, 1200},
[201] = {541, 1200},
--[número do looktype normal] = {looktype voando, número da tabela abaixo.}
}
procure por: rides
e acima disso adicione:
ridesAddon = {
[556] = {555, 30},
--[número do looktype] = {looktype montado, número da tabela abaixo.}
}
procure por: rides
e acima disso adicione:
surfsAddon = {
[201] = {541, 10},
[552] = {553, 10},
--[número do looktype] = {looktype nadando, speed da tabela abaixo.}
}
em lib/order.lua, procure por:
elseif skill == "fly" then
e abaixo adicione:
local pb = getPlayerSlotItem(cid, 8).uid
if getItemAttribute(pb, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = flys[getPokemonName(getCreatureSummons(cid)[1])][1] + 351}, -1)
else
doSetCreatureOutfit(cid, {lookType = flysAddon[getItemAttribute (pb, "addon")][1]}, -1)
end
depois, no mesmo arquivo, procure por:
elseif skill == "ride" then
e abaixo adicione:
local pb = getPlayerSlotItem(cid, 8).uid
if getItemAttribute(pb, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = rides[getPokemonName(getCreatureSummons(cid)[1])][1] + 351}, -1)
else
doSetCreatureOutfit(cid, {lookType = ridesAddon[getItemAttribute (pb, "addon")][1]}, -1)
end
em movements/surf.lua, procure por:
if getPlayerStorageValue(cid, 6598754) == 1 or getPlayerStorageValue(cid, 6598755) == 1 then
doPlayerSendCancel(cid, "You can't do it while in the PVP Zone!") --alterado v1.7
doTeleportThing(cid, fromPosition, false)
return true
end
e abaixo adicione:
local pb = getPlayerSlotItem(cid, 8).uid
if getItemAttribute(pb, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = surfs[getPokemonName(getCreatureSummons(cid)[1])].lookType}, -1)
else
doSetCreatureOutfit(cid, {lookType = surfsAddon[getItemAttribute(pb, "addon")][1]}, -1)
end
logo abaixo disso, vocês vão encontrar:
(isso não envolve o funcionamento do sistema de addon, mas é um bug que eu achei no meu surf. Todos os pokémon tinham velocidade fixa de 1500.)
local speed = 75 + PlayerSpeed + getSpeed(getCreatureSummons(cid)[1]) * 8 * speedRate
substitua por:
local speed = 75 + PlayerSpeed + surfs[getPokemonName(getCreatureSummons(cid)[1])].speed * 8 * speedRate
no mesmo arquivo, procure por:
if getItemAttribute(item.uid, "nick") then
doCreatureSay(cid, getItemAttribute(item.uid, "nick")..", I'm tired of surfing!", 1)
else
doCreatureSay(cid, getItemAttribute(item.uid, "poke")..", I'm tired of surfing!", 1)
end
doSummonMonster(cid, pokemon)
local pk = getCreatureSummons(cid)[1]
e abaixo adicione:
local pb = getPlayerSlotItem(cid, 8).uid
if surfsAddon[getItemAttribute(pb, "addon")] then
if getItemAttribute(pb, "addon") > 1 then
doSetCreatureOutfit(pk, {lookType = getItemAttribute(pb, "addon")}, -1)
end
end
em actions/goback.lua, procure por:
doSendMagicEffect(getCreaturePosition(pk), effect)
abaixo adicione:
local pk = getCreatureSummons(cid)[1]
local pb = getPlayerSlotItem(cid, 8).uid
local look = getItemAttribute(pb, "addon")
if not look then
doSetItemAttribute(pb, "addon", 0)
end
if look and look > 0 then
doSetCreatureOutfit(pk, {lookType = look}, -1)
end
em actions/evolution.lua, procure por:
local ball = getPlayerSlotItem(cid, 8).uid
há 12 linhas iguais a essa nesse arquivo e embaixo de TODAS elas, adicione:
doItemSetAttribute (ball, "addon", 0)
em creaturescripts/look.lua, procure por:
if getItemAttribute(thing.uid, "gender") == SEX_MALE then
table.insert(str, "It is male.")
elseif getItemAttribute(thing.uid, "gender") == SEX_FEMALE then
table.insert(str, "It is female.")
else
table.insert(str, "It is genderless.")
end
se novamente, esse código aparece duas vezes no arquivo.
E também, novamente, embaixo dos dois, adicione:
if getItemAttribute(thing.uid, "addon") then
if flysAddon[getItemAttribute (thing.uid, "addon")] or ridesAddon[getItemAttribute (thing.uid, "addon")] or surfsAddon[getItemAttribute (thing.uid, "addon")] then
if getItemAttribute(thing.uid, "addon") > 1 then
table.insert(str, " Has the addon "..getItemNameById (getAddonId (getItemAttribute (thing.uid, "addon")))..".")
end
end
end
E no começo desse arquivo, adicione:
local addons = {
[14876] = {pokemon = "Shiny Charizard" , looktype = 1950},
[12344] = {pokemon = "Pidgeot" , looktype = 205},
[13990] = {pokemon = "Pidgeot" , looktype = 201},
--[ID do item] = {nome do pokémon, looktype},
}
local function getAddonId (looktype)
for index, value in pairs (addons) do
if value.looktype == looktype then
return index
end
end
end
a tabela "addons" deve ser a mesma que a do actions/addon.lua. Então, quando você adicionar algo no addon.lua, deverá adicionar também no look.lua.
em login.lua, procure por:
doSetCreatureOutfit(cid, {lookType = flys[poke][1] + 351}, -1)
e substitua por:
if getItemAttribute(item.uid, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = flys[poke][1] + 351}, -1)
else
doSetCreatureOutfit(cid, {lookType = flysAddon[getItemAttribute (item.uid, "addon")][1]}, -1)
end
procure por:
doSetCreatureOutfit(cid, {lookType = surfs[poke].lookType + 351}, -1
substitua por:
if getItemAttribute(item.uid, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = surfs[poke].looktype + 351}, -1)
else
doSetCreatureOutfit(cid, {lookType = surfsAddon[getItemAttribute (item.uid, "addon")][1]}, -1)
end
procure por:
doSetCreatureOutfit(cid, {lookType = rides[poke][1] + 351}, -1)
substitua por:
if getItemAttribute(item.uid, "addon") < 1 then
doSetCreatureOutfit(cid, {lookType = rides[poke][1] + 351}, -1)
else
doSetCreatureOutfit(cid, {lookType = ridesAddon[getItemAttribute (item.uid, "addon")][1]}, -1)
end