local c = {
health = 1000,
rangex = 3,
rangey = 3,
multifloor = false
}
local eventsFired = {}
local hitArea = createCombatArea(AREA_CIRCLE3X3)
function isInArray(array, value)
if type(array) == 'table' then
for _, v in pairs(array) do
if v == value then
return true
end
end
end
return false
end
function onThink(creature)
if not eventsFired[creature:getId()] then
addEvent(function(cid)
local creature = Creature(cid)
if creature then
creature:getPosition():sendMagicEffect(CONST_ME_EXPLOSIONAREA)
creature:remove()
end
end, 10000, creature:getId())
-- local damage = onTargetCreature(creature, target)
addEvent(function(cid)
local master = getCreatureMaster(cid)
if master then
local party = getPartyMembers(master)
local masterPosition = getCreaturePosition(master)
local totempos = getCreaturePosition(cid)
if party == nil or type(party) ~= "table" or #party <= 1 then
doCreatureAddHealth(master, c.health)
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(masterPosition, 12)
return true
end
local players = getSpectators(totempos, c.rangex, c.rangey, c.multifloor)
for _, member in pairs(party) do
if isInArray(players, member) then
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(member, c.health)
doSendMagicEffect(getCreaturePosition(member), 12)
end
end
end
end, 1000, creature:getId())
addEvent(function(cid)
local master = getCreatureMaster(cid)
if master then
local party = getPartyMembers(master)
local masterPosition = getCreaturePosition(master)
local totempos = getCreaturePosition(cid)
if party == nil or type(party) ~= "table" or #party <= 1 then
doCreatureAddHealth(master, c.health)
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(masterPosition, 12)
return true
end
local players = getSpectators(totempos, c.rangex, c.rangey, c.multifloor)
for _, member in pairs(party) do
if isInArray(players, member) then
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(member, c.health)
doSendMagicEffect(getCreaturePosition(member), 12)
end
end
end
end, 3000, creature:getId())
addEvent(function(cid)
local master = getCreatureMaster(cid)
if master then
local party = getPartyMembers(master)
local masterPosition = getCreaturePosition(master)
local totempos = getCreaturePosition(cid)
if party == nil or type(party) ~= "table" or #party <= 1 then
doCreatureAddHealth(master, c.health)
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(masterPosition, 12)
return true
end
local players = getSpectators(totempos, c.rangex, c.rangey, c.multifloor)
for _, member in pairs(party) do
if isInArray(players, member) then
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(member, c.health)
doSendMagicEffect(getCreaturePosition(member), 12)
end
end
end
end, 5000, creature:getId())
addEvent(function(cid)
local master = getCreatureMaster(cid)
if master then
local party = getPartyMembers(master)
local masterPosition = getCreaturePosition(master)
local totempos = getCreaturePosition(cid)
if party == nil or type(party) ~= "table" or #party <= 1 then
doCreatureAddHealth(master, c.health)
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(masterPosition, 12)
return true
end
local players = getSpectators(totempos, c.rangex, c.rangey, c.multifloor)
for _, member in pairs(party) do
if isInArray(players, member) then
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(member, c.health)
doSendMagicEffect(getCreaturePosition(member), 12)
end
end
end
end, 7000, creature:getId())
addEvent(function(cid)
local master = getCreatureMaster(cid)
if master then
local party = getPartyMembers(master)
local masterPosition = getCreaturePosition(master)
local totempos = getCreaturePosition(cid)
if party == nil or type(party) ~= "table" or #party <= 1 then
doCreatureAddHealth(master, c.health)
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doSendMagicEffect(masterPosition, 12)
return true
end
local players = getSpectators(totempos, c.rangex, c.rangey, c.multifloor)
for _, member in pairs(party) do
if isInArray(players, member) then
doAreaCombatHealth(creature, COMBAT_FIREDAMAGE, creature:getPosition(), hitArea, 0, 0, CONST_ME_MAGIC_BLUE)
doCreatureAddHealth(member, c.health)
doSendMagicEffect(getCreaturePosition(member), 12)
end
end
end
end, 9000, creature:getId())
eventsFired[creature:getId()] = true
end
return true
end