luigilc
Lua Learner
How can I check the function isWalkable:
into this script:
cuz rght now, it is sending monsters inside the temple and beyond the map borders
LUA:
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
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
function onGetFormulaValues(cid, level, maglevel)
min = ((level + maglevel) * getPlayerMana(cid) / getPlayerMaxMana(cid)) * 2.9
max = ((level + maglevel) * getPlayerMana(cid) / getPlayerMaxMana(cid)) * 3.2
return reduceSpellDamage(cid, min, max)
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onCastSpell(cid, var)
if(math.random(1, 2) == 1) then
time = -1000
for i = 1, 5 do
addEvent(doMoveCreature, time + 1000, variantToNumber(var), math.random(0, 3))
time = time + 1000
end
doCombat(cid, combat, var)
else
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doCreatureSay(cid, "The spell cast has failed.", TALKTYPE_ORANGE_1)
end
return true
end