Fiz essa spell a pedido de um usuário do fórum e logo depois outro usuário pediu uma versão onde o target do player afetado pela magia ficasse bloqueado por um tempo configurável, gostei da ideia e decidi postar em forma de tópico. Primeiro de tudo você vai precisar dessa função feita/disponibilizada pelo @WooX (não se esqueçam de passar no tópico dele e agradecer)
Em data/spells.xml adicione
<instant name="Cancel Enemy Target" words="Cancel Enemy Target" lvl="12" mana="20" range="3" blockwalls="1" needtarget="1" exhaustion="2000" needlearn="0" event="script" value="canceltargetlurk.lua">
<vocation id="1"/>
<vocation id="2"/>
</instant>
em data/spells/scripts crie um arquivo chamado canceltargetlurk.lua e coloque isso dentro
--[[
Made by Moira (Lurk on TibiaKing)
NÃO REMOVA OS CRÉDITOS
]]--
local storage = 234512 -- tenha certeza de estar usando um numero que ainda não esteja em uso no seu servidor
local tempo = 50 -- tempo em segundos para usar a magia novamente
local tempo_block = 5 -- quanto tempo o player afetado pela magia vai ficar sem poder atacar OUTRO PLAYER
local templo_cannot_be_blocked = 50 -- tempo em que o target vai ficar invuneravel a spell caso já tenha sido afetado por ela
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
if isPlayer(target) and getPlayerStorageValue(cid, storage) < os.time() and getPlayerStorageValue(target, 234514) < os.time() then
doPlayerTargetCreature(target, target)
setPlayerStorageValue(target, 234513, tempo_block + os.time())
setPlayerStorageValue(target, 234514, templo_cannot_be_blocked + os.time())
setPlayerStorageValue(cid, storage, tempo + os.time())
return doCombat(cid, combat, var)
elseif getPlayerStorageValue(target, 234514) > os.time() then
doPlayerSendCancel(cid, "This player has been affect by this spell recently, you must wait ".. getPlayerStorageValue(target, 234514) - os.time() .." to block his attacks again.")
return false
elseif getPlayerStorageValue(cid, storage) > os.time() then
doPlayerSendCancel(cid, "You must wait ".. getPlayerStorageValue(cid, storage) - os.time() .." seconds to use this spell again.")
else
doPlayerSendCancel(cid, "You may only cast this spell on players.")
end
return false
end
agora em data/creaturescripts.xml adicione
<event type="attack" name="lurkBlockTarget" event="script" value="canceltargetlurk.lua"/>
em data/creaturescripts/scripts crie um arquivo chamado canceltargetlurk.lua e cole isso dentro
--[[
Made by Moira (Lurk on TibiaKing)
NÃO REMOVA OS CRÉDITOS
]]--
function onAttack(cid, target)
if getPlayerStorageValue(cid, 234513) > os.time() and isPlayer(target) then
return doPlayerSendCancel(cid, "You're under effect of the cancel target spell, you must wait".. getPlayerStorageValue(cid, 234513) - os.time() .." seconds to attack again.") and false
end
return true
end
por ultimo, abre o arquivo login.lua que está na pasta data/creaturescripts/scripts e adicione isso ANTES DO ULTIMO RETURN TRUE
registerCreatureEvent(cid, "lurkBlockTarget")
Se você quer só E SOMENTE SÓ cancelar o target do inimigo uma unica vez, basta utilizar essa versão da spell
--[[
Made by Moira (Lurk on TibiaKing)
NÃO REMOVA OS CRÉDITOS
]]--
local storage = 234512 -- tenha certeza de estar usando um numero que ainda não esteja em uso no seu servidor
local tempo = 50 -- tempo em segundos para usar a magia novamente
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
if isPlayer(target) and getPlayerStorageValue(cid, storage) < os.time() then
doPlayerTargetCreature(target, target)
setPlayerStorageValue(cid, storage, tempo + os.time())
return doCombat(cid, combat, var)
elseif getPlayerStorageValue(cid, storage) > os.time() then
doPlayerSendCancel(cid, "You must wait ".. getPlayerStorageValue(cid, storage) - os.time() .." seconds to use this spell again.")
else
doPlayerSendCancel(cid, "You may only cast this spell on players.")
end
return false
end
Créditos:
Eu pela spell e creaturescript
@WooX pela criação da função
se gostou, rep+ aqui e no post do @WooX pela função : p