local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ETHEREALSPEAR)
function onGetFormulaValues(cid, level, skill)
return -(((skill + 30) / 3) + (level / 4)), -((skill + 30) + (level / 4)), 0
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
local function isWalkable(pos, creature, proj, pz)-- by Nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end
local function push(id, dir, t)
if t < 0 or not(isCreature(id)) then return true end
local pos = getPositionByDirection(getThingPos(id), dir)
if not(isWalkable(pos, true, false, true)) then
return true
end
doTeleportThing(id, pos, false)
doSendMagicEffect(pos, CONST_ME_STONES)
doSendMagicEffect(pos, CONST_ME_POFF)
addEvent(push, 200, id, dir, t-1)
end
local config = {
ammu = {2543, 2544},
pushBack = 2
}
function onCastSpell(cid, var)
local removed = false
for _, itemid in pairs(config.ammu) do
if getPlayerItemCount(cid, itemid) >= 1 then
doPlayerRemoveItem(cid, itemid, 1)
removed = true
break
end
end
if not(removed) then return doPlayerSendCancel(cid, "You need ammunation for this spell.") and false end
local ret = doCombat(cid, combat, var)
if ret then
local dirTo = getDirectionTo(getThingPos(cid), getThingPos(variantToNumber(var)))
push(variantToNumber(var), dirTo, config.pushBack)
end
return ret
end