Em creaturescripts.xml
<event type="statschange" name="invencible" event="script" value="nomedoseuarquivo.lua"/>
Crie um arquivo na pasta creaturescripts/scripts com o mesmo nome do arquivo registrado na tag xml. Dentro do arquivo cole o seguinte:
local config = {
storage = 3482101, ---- storage utilizada,
effect1 = 2 --- efeito ao ser atacado estando invulneravel
}
Em login.lua:
---------- Imortalidade ----------------
registerCreatureEvent(cid, "invencible")
if getPlayerStorageValue(cid, 3482101) ~= 0 then
setPlayerStorageValue(cid, 3482101, 0)
end
function onStatsChange(cid, attacker, type, combat, value)
if value >= 1 and (type == STATSCHANGE_HEALTHLOSS or (getCreatureCondition(cid, CONDITION_MANASHIELD) and type == STATSCHANGE_MANALOSS)) then
if getPlayerStorageValue(cid,config.storage) - os.time() > 0 and isCreature(attacker) then
doSendMagicEffect(getCreaturePosition(cid), config.effect1)
doSendAnimatedText(getCreaturePosition(cid), "IMORTAL", 180)
return false
end
end
return true
end
Agora em spells.xml, cole a seguinte tag:
<instant name="Nome da magia" words="Nome da magia" lvl="400" mana="4000" maglv="110" prem="0" aggressive="1" exhaustion="100" needlearn="0" script="diretoriodoarquivo.lua">
</instant>
crie 1 arquivo.lua para a spell com o seguinte código:
local config = {
storage = 3482101,
cooldown = 60, --- tempo entre um uso e outro
duration = 5, --- duracao
effect1 = 279 -- efeito que sai ao falar a spell
}
function onCastSpell(cid, var)
if os.time() - getPlayerStorageValue(cid, 55695) >= config.cooldown then
setPlayerStorageValue(cid, 55695, os.time())
for k = 1, 9 do
addEvent(function()
if isCreature(cid) then
local pos1 = {x = getPlayerPosition(cid).x + 1, y = getPlayerPosition(cid).y + 0, z = getPlayerPosition(cid).z}
doSendMagicEffect(pos1, 326)
end
end, 1 + ((k-1) * 500))
end
setPlayerStorageValue(cid, config.storage, os.time() + config.duration)
doCreatureSay(cid,"IMORTAL!!!", 15)
doPlayerSendTextMessage(cid, 20, "Voce tem ".. config.duration .." segundos de invulnerabilidade.")
else
doPlayerSendCancel(cid, "Sua habilidade esta em cooldown, voce deve esperar "..(config.cooldown - (os.time() - getPlayerStorageValue(cid, 55695))).." segundos.")
return false
end
return true
end