Siegh
Thronar Developer
Hello!
I'm implementing this function to a couple spells I've got but I'm facing a problem with monsters being pushed inside PZ! I can't find a way to check if a tile is pz or not, I did search considerably.
Is there a practical way to simply check whether a targeted tile is a PZ one?
I'm implementing this function to a couple spells I've got but I'm facing a problem with monsters being pushed inside PZ! I can't find a way to check if a tile is pz or not, I did search considerably.
Is there a practical way to simply check whether a targeted tile is a PZ one?
LUA:
function onTargetCreature1(creature, target)
local tPos = target:getPosition()
if pos.x > tPos.x and pos.y > tPos.y then
pushX = -1
pushY = -1
elseif pos.x > tPos.x and pos.y == tPos.y then
pushX = -1
pushY = 0
elseif pos.x == tPos.x and pos.y > tPos.y then
pushX = 0
pushY = -1
elseif pos.x > tPos.x and pos.y < tPos.y then
pushX = -1
pushY = 1
elseif pos.x < tPos.x and pos.y < tPos.y then
pushX = 1
pushY = 1
elseif pos.x < tPos.x and pos.y == tPos.y then
pushX = 1
pushY = 0
elseif pos.x == tPos.x and pos.y < tPos.y then
pushX = 0
pushY = 1
elseif pos.x < tPos.x and pos.y > tPos.y then
pushX = 1
pushY = -1
end
tPos.x = tPos.x + pushX
tPos.y = tPos.y + pushY
local isWalkable = function (position)
local tile = Tile(position)
if not tile then
return false
end
local ground = tile:getGround()
if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
local items = tile:getItems()
for i = 1, tile:getItemCount() do
local item = items[i]
local itemType = item:getType()
if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
return false
end
end
return true
end
if isWalkable(tPos) and target:getSpeed() ~= 0 then
target:teleportTo(tPos, 1)
end
return true
end