local storage = 12007 -- storage for this quest
local positions = {
[1] = {x = 33608, y = 32394, z = 11}, -- home position
[2] = {x = 33574, y = 32415, z = 12} -- boss room position
}
local coords = {
[1] = 33560, -- upper left corner of room
[2] = 33575, -- upper right corner "
[3] = 32414, -- upper left corner "
[4] = 32429, -- bottom left corner "
[5] = 12 -- z position
}
function onStepIn(cid)
local typemsg = MESSAGE_INFO_DESCR
local isBoss
if(getCreatureStorage(cid, storage) < 2) then
for xPos = coords[1], coords[2] do
for yPos = coords[3], coords[4] do
pos = {x = xPos, y = yPos, z = coords[5]}
local pid = getTopCreature(pos).uid
if(isPlayer(pid)) then
msg = "Someone else is already doing this quest, wait a little longer."
doTeleport(cid, positions[1], msg, typemsg)
elseif(isCreature(pid)) then
isBoss = true
end
end
end
if(isBoss) then
typemsg = MESSAGE_STATUS_WARNING
msg = "You have 1 minutes to defeat this boss, for you will be kicked out after that time passes."
doTeleport(cid, positions[2], msg, typemsg)
addEvent(bossTimer, 60*1000, cid)
elseif(not isBoss) then
msg = "This boss was just defeated, please wait for it to respawn."
doTeleport(cid, positions[1], msg, typemsg)
else
msg = "You have already defeated this boss."
doTeleport(cid, positions[1], msg, typemsg)
return true
end
end
end
function bossTimer(cid)
for xPos = coords[1], coords[2] do
for yPos = coords[3], coords[4] do
pos = {x = xPos, y = yPos, z = coords[5]}
local pid = getTopCreature(pos).uid
if(isPlayer(pid)) then
if(cid == pid) then
doTeleport(pid, positions[1])
end
end
end
end
end
Here a necessary global function I use to make the script valid.
You could place it in your library:
Code:
function doTeleport(cid, position, msg, typemsg)
if(msg ~= nil) then
doPlayerSendTextMessage(cid, typemsg, msg)
end
doTeleportThing(cid, position, false)
doSendMagicEffect(position, CONST_ME_TELEPORT)
end