local t = {
from = {x=490, y=495, z=7},
to = {x=504, y=505, z=7},
storage = {
placed = 10001,
max = 10002,
radius = 10003
},
delay = 3000,
bombID = 10507, -- 10570 ?
effect = CONST_ME_MORTAREA,
blockID = 9468,
text = "BOOM!"
}
local function boom(pos, cid)
local v = getTileItemById(pos, t.bombID).uid
if isPlayer(cid) then
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) - 1)
doCreatureSay(cid, t.text, TALKTYPE_ORANGE_2, false, nil, pos)
doSendMagicEffect(pos, CONST_ME_ENERGYAREA)
local b = getTileItemById(pos, t.blockID).uid
if b > 0 then
doRemoveItem(b)
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}
if queryTileAddThing(v, _pos, 4) == RETURNVALUE_NOERROR or getTileItemById(_pos, t.blockID).uid > 0 then
doSendMagicEffect(_pos, t.effect)
local b = getTileItemById(_pos, t.blockID).uid
if b > 0 then
doSendMagicEffect(_pos, CONST_ME_BLOCKHIT)
doRemoveItem(b)
return false
end
end
return true
end
while N <= l do
if loopDir("N") then
N = N + 1
else
break
end
end
while E <= l do
if loopDir("E") then
E = E + 1
else
break
end
end
while W <= l do
if loopDir("W") then
W = W + 1
else
break
end
end
while S <= l do
if loopDir("S") then
S = S + 1
else
break
end
end
end
doRemoveItem(v)
end
function onSay(cid, words, param, channel)
if isInRange(getThingPos(cid), t.from, t.to) then
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(boom, t.delay, getThingPos(cid), cid)
setPlayerStorageValue(cid, t.storage.placed, getPlayerStorageValue(cid, t.storage.placed) + 1)
end
return true
end
end