local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 111)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
function onUse(cid, item, fromPosition, itemEx, toPosition)
local c = {
["Demon"] = {name="Demon", m1 = combat1, spell = "Quick Attack", minLv = 20, distance = 1}
}
local summ = getCreatureSummons(cid)
if #summ == 0 then
return doPlayerSendCancel(cid, "Sorry, but you need a pokemon.")
end
local sumonName = getCreatureName(summ[1])
if c[sumonName] then
if getPlayerLevel(cid) < c[sumonName].minLv then
return doPlayerSendCancel(cid, "Sorry, but you must be level " .. c[sumonName].minLv .. " or higher to cast.") and doSendMagicEffect(getThingPos(cid), 2)
end
if not isCreature(getCreatureTarget(cid)) or getCreatureTarget(cid) == sumonName then
return doPlayerSendCancel(cid, "Invalid target.") and doSendMagicEffect(getThingPos(cid), 2)
end
if getDistanceBetween(getThingPos(summ[1]), getThingPos(getCreatureTarget(cid))) > c[sumonName].distance then
return doPlayerSendCancel(cid, "Sorry, your pokemon is too far away.") and doSendMagicEffect(getThingPos(cid), 2)
end
if getPlayerStorageValue(cid, 23000) <= os.time() then
doPlayerSetStorageValue(cid, 23000, os.time()+5)
doCombat(summ[1], c[sumonName].m1, numberToVariant(getCreatureTarget(cid)))
doCreatureSay(cid, sumonName .. ", " .. c[sumonName].spell .. ".")
end
doPlayerSendCancel(cid, "Cooldown: ["..(getPlayerStorageValue(cid, 23000)-os.time()).."] seconds.")
doSendMagicEffect(getThingPos(cid), 2)
else
return doPlayerSendCancel(cid, "Sorry, your pokemon don't have this spell.")
end
end
info
Grupo: Conde
Registrado: 30/06/11
Posts: 631
Reputação: +371
Char no Tibia: Warrior of Mort

info
Grupo: Visconde
Registrado: 22/09/10
Posts: 474
Reputação: +47

Boa, valeu cara esta funcionando certinho, MAS eu tentei por uma nova spell de area, o efeito saio certo só que n rita nada, o erro é na minha spell ou o script não esta lendo corretamente ?
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 111)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 42)
setAttackFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 2.5, 4)
arr2 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 3, 0, 3, 0, 3, 0, 0, 0},
{0, 0, 0, 3, 0, 3, 0, 3, 0, 0, 0},
{0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}
local area2 = createCombatArea(arr2)
setCombatArea(combat2, area2)
function onUse(cid, item, fromPosition, itemEx, toPosition)
local c = {
["training monk"] = {x = {
m1 = combat1,
spell = "Quick Attack",
minLv = 20
}
}
}
local summ = getCreatureSummons(cid)
if #summ == 0 then
return doPlayerSendCancel(cid, "Sorry, but you need a pokemon.")
end
for i = 1, #summ do
for name, _ in pairs© do
if getCreatureName(summ):lower() == name:lower() then
local con = c[name].x
if getPlayerLevel(cid) < con.minLv then
return doPlayerSendCancel(cid, "Sorry, but you must be level " .. con.minLv .. " or higher to cast.") and doSendMagicEffect(getThingPos(cid), 2)
end
local distance = (not con.distance) and 1 or con.distance
if not isCreature(getCreatureTarget(cid)) or getCreatureTarget(cid) == summ then
return doPlayerSendCancel(cid, "Invalid target.") and doSendMagicEffect(getThingPos(cid), 2)
end
if getDistanceBetween(getThingPos(summ), getThingPos(getCreatureTarget(cid))) > distance then
return doPlayerSendCancel(cid, "Sorry, your pokemon is too far away.") and doSendMagicEffect(getThingPos(cid), 2)
end
if getPlayerStorageValue(cid, 23000) <= os.time() then
doPlayerSetStorageValue(cid, 23000, os.time()+5)
doCombat(summ, con.m1, numberToVariant(getCreatureTarget(cid)))
doCreatureSay(cid, name .. ", " .. con.spell .. ".")
end
doPlayerSendCancel(cid, "Cooldown: "..(getPlayerStorageValue(cid, 23000)-os.time()).." sec.")
doSendMagicEffect(getThingPos(cid), 2)
end
end
end
end
Editado Abril 26 por eduardobean
info
Grupo: Conde
Registrado: 30/06/11
Posts: 631
Reputação: +371
Char no Tibia: Warrior of Mort

Não observase as mudanças que eu fiz? Uma foi tirar as speels de dentro da função onUse, pois as spells são incializadas antes. Então para funcionar você deve como o script que postei, colocando a inicialização dessa spells antes da linha:
function onUse(cid, item, fromPosition, itemEx, toPosition)
info
Grupo: Visconde
Registrado: 22/09/10
Posts: 474
Reputação: +47

Eu Mudei o Script, mais tipo, a magia não sai no summon, na verdade n da erro nem um só simplesmente n acontece nada
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 22) / 10
max = -(level * 38.5) /10
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local arr = {
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 2, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
}
local area = createCombatArea(arr)
setCombatArea(combat, area)
function onUse(cid, words, param, item)
return doCombat(getThingPos(getCreatureSummons(cid)[1]), combat, numberToVariant(cid))
end
Editado Abril 26 por eduardobean


info
Grupo: Visconde
Registrado: 22/09/10
Posts: 474
Reputação: +47
Boas Pessoal,
Bom queria saber porque esse script não esta funcionando como devia.
Eu Mudei o Script, mais tipo, a magia não sai no summon, na verdade n da erro nem um só simplesmente n acontece nada
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 22) / 10
max = -(level * 38.5) /10
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local arr = {
{0, 0, 0, 0, 0},
{0, 1, 1, 1, 0},
{0, 1, 2, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0}
}
local area = createCombatArea(arr)
setCombatArea(combat, area)
function onUse(cid, words, param, item)
return doCombat(getThingPos(getCreatureSummons(cid)[1]), combat, numberToVariant(cid))
end
se alguém puder me ajudar, dizendo onde errei e como posso arrumar agradecerei.
Editado Abril 26 por eduardobean