- Joined
- Sep 7, 2015
- Messages
- 2,684
- Solutions
- 127
- Reaction score
- 2,129
Hello, I was bored so I looked into forums and someone needed this, so here you go.
How does it work?
It summons x monsters and if these monsters are near their target they will explode dealing damage.
How does it work?
It summons x monsters and if these monsters are near their target they will explode dealing damage.
Code:
local monsterName, monsterCount = "demon", 4 -- time is in seconds
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setArea(createCombatArea(AREA_CIRCLE5X5))
function onGetFormulaValues(player, skill, attack, factor)
local min = (player:getLevel() / 2) + 20 -- completely random
local max = (player:getLevel() / 5) + 93
return -min, -max
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
local function checkPosition(cid, variant)
local creature = Creature(cid)
if not creature then
return true
end
local target = creature:getTarget()
if not target or not creature:getMaster() then
creature:getPosition():sendMagicEffect(CONST_ME_POFF)
creature:remove()
return true
end
if creature:getPosition():getDistance(target:getPosition()) <= 1 then
combat:execute(creature:getMaster(), variant)
creature:remove()
return true
end
addEvent(checkPosition, 2 * 1000, cid, variant)
return true
end
function onCastSpell(creature, variant)
for i = 1, monsterCount do
local summon = Game.createMonster(monsterName, creature:getPosition(), true, false)
if summon then
creature:addSummon(summon)
addEvent(checkPosition, 2 * 1000, summon.uid, variant)
end
end
return true
end
Last edited by a moderator: