Hey guys, two days in a row, I'm on a roll!
Basically, the spell works as intended. But if the target dies / logs out the server segfaults.
I was wondering if anyone had any ideas.
In return, the code will be available for everyone.
Red
Basically, the spell works as intended. But if the target dies / logs out the server segfaults.
I was wondering if anyone had any ideas.
Code:
local function curse(cid)
local creature = Creature(cid)
if not creature then
return true
end
doTargetCombatHealth(0, cid, COMBAT_HOLYDAMAGE, -1000, -1000, CONST_ME_HOLYDAMAGE)
end
function onCastSpell(cid, var)
local player = Player(cid)
if not player then
return true
end
if exhaustion.get(cid, 2003) then
player:sendCancelMessage("Corruption is still in effect!")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
local target = player:getTarget()
local enemy = Creature(target)
local ticks = 10
local interval = 2000
for i = 1, ticks do
addEvent(curse, i * interval, enemy)
end
local enemyPos = Position(enemy:getPosition())
local playerPos = player:getPosition()
if enemyPos:isSightClear(playerPos, true) then
playerPos:sendDistanceEffect(enemyPos, CONST_ANI_SMALLHOLY)
enemyPos:sendMagicEffect(CONST_ME_HOLYDAMAGE)
end
if enemy:isPlayer() then
enemy:sendTextMessage(MESSAGE_DAMAGE_RECEIVED, "You have been cursed.")
end
enemy:say("Cursed!", TALKTYPE_ORANGE_1)
exhaustion.set(cid, 2003, ((interval * ticks) / 1000))
return false
end
In return, the code will be available for everyone.
Red