Magic Potions
Fala galera! Vim aqui hoje pra ensinar a instalar as Magic Potions, criadas pela CipSoft na atual versão do Tibia (8.0).
Para quem não sabe, as magic potions são aquelas poções que vem em uns potezinhos que você bebe e aumenta seu skill melee ou magic level, dependendo da poção.
São 3 tipos de poções, sendo elas:
Berserk Potion - Utilizada pelos Knights
Bullseye Potion - Utilizada pelos Paladinos
Mastermind Potion - Utilizada pelos Mages
Bem, para colocar essas poções no seu server funcionando 100%, siga os passos abaixo
1º Passo - Criar as actions
Bem, o nome já fala tudo, nesta parte você vai criar as actions que irão fazer essas poções aumentarem seu skill, etc.
Então vamos parar de conversinha e vamos por a mão na massa!
Crie uma pasta chamada "Potions", dentro da pasta "data/actions", nesta pasta, você criará 3 arquivos (um para cada poção), com os seguintes nomes:
Berserk Potion.lua
Bullseye Potion.lua
Mastermind Potion.lua
Cada um desses arquivos terá o seguinte conteúdo:
Arquivo: Berserk Potion.lua
local combat = createCombatObject()setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 40 * 6000)
setConditionParam(condition, CONDITION_PARAM_SKILL_MELEE, 8)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, 4)
setCombatCondition(combat, condition)
function onUse(cid, item, frompos, item2, topos)
var = numberToVariant(cid)
doCombat(cid, combat, var)
doRemoveItem(item.uid,1)
return 1
end
Arquivo: Bullseye Potion.lua
local combat = createCombatObject()setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 40 * 6000)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, 8)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, 4)
setCombatCondition(combat, condition)
function onUse(cid, item, frompos, item2, topos)
var = numberToVariant(cid)
doCombat(cid, combat, var)
doRemoveItem(item.uid,1)
return 1
end
Arquivo: Mastermind Potion.lua
local combat = createCombatObject()setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 40 * 6000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICPOINTS, 3)
setCombatCondition(combat, condition)
function onUse(cid, item, frompos, item2, topos)
if getPlayerVocation(cid) == 1 or getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 5 or getPlayerVocation(cid) == 6 then
var = numberToVariant(cid)
doCombat(cid, combat, var)
doRemoveItem(item.uid,1)
else
doPlayerSendTextMessage(cid,22,"Apenas mages podem usar esta poção.")
return 0
end
return 1
end
Bem, você pode editar as seguintes linhas:
No berserk potion, veja estas tres linhas:
setConditionParam(condition, CONDITION_PARAM_TICKS, 40 * 6000)setConditionParam(condition, CONDITION_PARAM_SKILL_MELEE, 8)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, 4)
Na primeira linha, você determina quanto tempo durará a poção, é um cálculo complexo (40x6000/60 = X . 1000) , sendo X igual ao tempo. Para simplificar para vocês, basta editar o 40 para 50, ou 60 que ficará 50 = 5 minutos, 60 = 6 minutos, e assim por diante.
Na segunda linha, você colocará quanto de skill melee que será aumentado do player ao tomar a poção, que no caso é 8.
Na terceira, o tanto de skill que aumentará no shield. No global diminui se eu não me engano, você pode colocar -4 se quiser.
Na bullseye potion é a mesma coisa, só que aumentará distance em vez de melee, e na mastermind aumentará apenas ML.
2º Passo - Ligar as actions àos itens (potions)
Depois de criada a pasta "potion" e com todos os 3 scripts lá, abra o arquivo potions.xml, e adicione o seguinte conteúdo:
-- Pocoes<action itemid="7439" script="potions/Berserk Potion.lua" />
<action itemid="7443" script="potions/Bullseye Potion.lua" />
<action itemid="7440" script="potions/Mastermind Potion.lua" />
Isso fará com que os ids dos potinhos (7439,7443 e 7440) realizem as ações dos arquivos criados anteriormente.
3º Passo - Colocando o npc para vende-las
No caso aqui está no NPC Seller, mas você pode colocar no NPC de sua preferencia.
local focus = 0local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hello, ' .. getCreatureName(cid) .. '! I sell ropes (50gp), shovels (20gp), backpacks (10gp), manafluids (100gp), lifefluids (60gp), fishing rods (100gp), amulet of loss (10k), torches (2gp), Berserk, Bullseye and Mastermind potion (900gp each of all kinds) and bp of mf (1000gp). I buy vials (10gp).')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'shovel') then
buy(cid,2554,getCount(msg),20)
elseif msgcontains(msg, 'backpack') then
buy(cid,1988,getCount(msg),10)
elseif msgcontains(msg, 'rope') then
buy(cid,2120,getCount(msg),20)
elseif msgcontains(msg, 'manafluid') or msgcontains(msg, 'mana fluid') then
buyFluidContainer(cid,2006,getCount(msg),100,7)
elseif msgcontains(msg, 'lifefluid') or msgcontains(msg, 'life fluid') then
buyFluidContainer(cid,2006,getCount(msg),60,10)
elseif msgcontains(msg, 'fishing rod') then
buy(cid,2580,getCount(msg),100)
elseif msgcontains(msg, 'torch') then
buy(cid,2050,getCount(msg),2)
elseif msgcontains(msg, 'aol') then
buy(cid,2173,getCount(msg),20000)
elseif msgcontains(msg, 'vial') or msgcontains(msg, 'flask') then
sell(cid,2006,getCount(msg),10)
elseif msgcontains(msg, 'berserk potion') or msgcontains(msg, 'berserk') then
buy(cid,7439,getCount(msg),900)
elseif msgcontains(msg, 'bullseye potion') or msgcontains(msg, 'bullseye') then
buy(cid,7443,getCount(msg),900)
elseif msgcontains(msg, 'mastermind potion') or msgcontains(msg, 'mastermind') then
buy(cid,7440,getCount(msg),900)
elseif msgcontains(msg, 'bp of mf') or msgcontains(msg, 'bp mf') then
sellcontainer(cid,2001,2006,7,2000)
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()
if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(1)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(3)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(0)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(2)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(0)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(3)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(1)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(2)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(0)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(3)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(1)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(2)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(0)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(3)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(1)
end
end
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
A parte grifada em laranja, é a parte responsavel por fazer o npc vender as poções.
CRÉDITOS : FEITO POR Rafael Hamdan