local t = {
from = {x=1, y=1, z=7},
to = {x=2905, y=2525, z=7},
storage = {placed = 10001, max = 10002, radius = 10003, speed = 10004},
delay = 4000, bombID = 386, effect = CONST_ME_FIREAREA, blockID = 435,
temple = {x = 1009, y = 1017, z = 7},
}
local blocks = {435, 387, 388, 389}
local function doExplosion(pos, cid)
local v = getTileItemById(pos, t.bombID).uid
if v > 0 then
if isPlayer(cid) and isInRange(getThingPos(cid), t.from, t.to) then
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
doSendMagicEffect(pos, t.effect)
local c = getTopCreature(pos).uid
if isPlayer(c) and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(pos, 17)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, 10)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self!" or n1 .. " was killed by " .. n2 .. "!", MESSAGE_STATUS_WARNING)
end
local N, E, W, S, l = 1, 1, 1, 1, getPlayerStorageValue(cid, t.storage.radius)
function loopDir(dir)
local _pos = {x=pos.x+(dir=="E" and E or dir=="W" and -W or 0), y=pos.y+(dir=="N" and -N or dir=="S" and S or 0), z=pos.z, stackpos = 1}
local block = getTileThingByPos(_pos)
local c = getTopCreature(_pos).uid
if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR then
doSendMagicEffect(_pos, t.effect)
if isPlayer(c) and v > 1 and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(_pos, 17)
doTeleportThing(c, t.temple)
doSendMagicEffect(t.temple, 10)
local n1, n2 = getPlayerName(c), getPlayerName(cid)
doBroadcastMessage(n1==n2 and n1 .. " killed " .. (getPlayerSex(c) == 0 and "her" or "him") .. "self!" or n1 .. " was killed by " .. n2 .. "!", MESSAGE_STATUS_WARNING)
elseif isMonster(c) and v > 1 and isInRange(getThingPos(c), t.from, t.to) then
doSendMagicEffect(_pos, 2)
doRemoveCreature(c)
end
elseif queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.bombID).uid > 0 then
addEvent(doExplosion, 1, getThingPos(getTileItemById(_pos, t.bombID).uid), cid)
elseif queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or isInArray(blocks, block.itemid) and v > 1 and block.itemid ~= 0 then
doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
doRemoveItem(getTileThingByPos(_pos).uid, 1)
local r = math.random(20)
if r < 4 then
doCreateItem(r==1 and 2153 or r==2 and 2154 or r==3 and 2155, 1, _pos)
end
return false
else--if queryTileAddThing(v, _pos, 4) == 3 then
return false
end
return true
end
while N <= l do
local q = loopDir("N")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
N = N + 1
end
end
while E <= l do
local q = loopDir("E")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
E = E + 1
end
end
while W <= l do
local q = loopDir("W")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
W = W + 1
end
end
while S <= l do
local q = loopDir("S")
if q == "endgame" then
return doRemoveItem(v, 1)
elseif not q then
break
else
S = S + 1
end
end
end
doRemoveItem(v, 1)
end
end
function onSay(cid, words, param, channel)
local b = getTileItemById(getThingPos(cid), t.bombID).uid
if b > 1 then
return true
else
setPlayerStorageValue(cid, t.storage.placed, math.max(getPlayerStorageValue(cid, t.storage.placed), 0))
setPlayerStorageValue(cid, t.storage.max, math.max(getPlayerStorageValue(cid, t.storage.max), 1))
setPlayerStorageValue(cid, t.storage.radius, math.max(getPlayerStorageValue(cid, t.storage.radius), 1))
if getPlayerStorageValue(cid, t.storage.placed) < getPlayerStorageValue(cid, t.storage.max) then
doCreateItem(t.bombID, 1, getThingPos(cid))
addEvent(doExplosion, t.delay, getThingPos(cid), cid)
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
end
return true
end
end