function chooseA(...)
local arg = {...}
return arg[math.random(1,#arg)]
end
local area = {
{
{0, 1, 0},
{1, 2, 1},
{0, 1, 0},
},
{
{0, 1, 1, 1, 0},
{1, 0, 0, 0, 1},
{1, 0, 2, 0, 1},
{1, 0, 0, 0, 1},
{0, 1, 1, 1, 0},
},
{
{0, 1, 1, 1, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 2, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1},
{0, 1, 1, 1, 1, 1, 0}
},
{
{0, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 2, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 0}
},
{
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
}
}
function restore(cid)
if isCreature(cid) then
doCreatureSetNoMove(cid, false)
doSendMagicEffect(getThingPos(cid), CONST_ME_ICEATTACK)
end
end
function meltIce(pos)
return getTileItemById(pos, 6966).uid > 0 and doRemoveItem(getTileItemById(pos, 6966).uid, 1), doSendMagicEffect(pos, CONST_ME_ICEATTACK)
end
function onTargetTile(cid, pos)
if doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR and math.random(50) > 35 then
doCreateItem(6966, pos)
addEvent(meltIce, 5000, pos)
end
pos.stackpos = 253
local thing = getThingFromPos(pos).uid
if isPlayer(thing) or isMonster(thing) and thing ~= cid then
doCreatureSetNoMove(thing, true)
doSendMagicEffect(pos, CONST_ME_GIANTICE)
addEvent(restore, 5000, thing)
doSetItemOutfit(thing, chooseA(7171,7172,7173), 5000)
end
end
local combat = {}
for i = 1, 5 do
combat[i] = createCombatObject()
setCombatArea(combat[i], createCombatArea(area[i]))
setCombatParam(combat[i], COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat[i], COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat[i], COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
condition = createConditionObject(CONDITION_FREEZING)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 10, 2000, -10)
setCombatCondition(combat[i], condition)
setCombatFormula(combat[i], COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -15, 5, 5, 1.8, 3, -20, -40)
_G['onTargetTile' .. i] = onTargetTile
setCombatCallback(combat[i], CALLBACK_PARAM_TARGETTILE, 'onTargetTile' .. i)
end
function onCastSpell(cid, var)
doAddCondition(cid, createConditionObject(CONDITION_INFIGHT, 10000))
local position = getThingPos(cid)
for i = 1, 10 do
doSendDistanceShoot({x = position.x + math.random(-12, 12), y = position.y + math.random(-5, 5), z = position.z}, position, CONST_ANI_SMALLICE)
end
for i = 1, 5 do
addEvent(doCombat, 400*i, cid, combat[i], var)
end
return true
end