zbizu
Legendary OT User
I couldn't find any script of "killing in the name of..." boss room, I needed it so hard I wrote one.
Make arena no-logout area to avoid script bypassing during server save(2 players in arena or one blocking arena without limit)
First code checks if player did task and if there is someone inside(showing his time left)
Second code is escape - stops timer and lets player leave arena himself(if you don't use it player will be dragged back to escape position after 10 minutes)
Configuration explained on image below and in code:
in movements\boss folder:
Demodras.lua
this one could be written in tables and all exits could be in one script of course, but here's example for single one I made for testing:
DemodrasExit.lua
in movements.xml(actionids must be put on portals or floors below them):
Make arena no-logout area to avoid script bypassing during server save(2 players in arena or one blocking arena without limit)
First code checks if player did task and if there is someone inside(showing his time left)
Second code is escape - stops timer and lets player leave arena himself(if you don't use it player will be dragged back to escape position after 10 minutes)
Configuration explained on image below and in code:
in movements\boss folder:
Demodras.lua
Lua:
local spawnboss = {x=67,y=489,z=8}
local spawnplayer = {x=68,y=483,z=8}
local NWcorner = {x=59,y=480,z=8, stackpos = 255} -- north west corner of arena
local SEcorner = {x=76,y=495,z=8, stackpos = 255} -- south east corner of arena
local deny = {x=311, y=403, z=12}
local storage = {65030,2} -- storage required to enter
local keyafter = -1 -- key that will be set to storage above when player enters arena
local boss = "demodras" -- monster name
local fighttime = 10 * 60 * 1000 -- ten minutes
local delayglobal = 95000 -- enterance counter storage returning remaining time of current user
function getCreaturesInQuestArea(type, fromPos, toPos, get, countSummon)
-- function taken from demon oak quest made by Darkhaos
local types =
{
[TYPE_PLAYER] = isPlayer,
[TYPE_MONSTER] = isMonster,
[TYPE_NPC] = isNpc,
[TYPE_ALL] = isCreature
}
local tmp = {}
local t = types[type]
if not t then
return print("[!] --> [Warning - Function::getCreaturesInQuestArea] Unknown type " .. (type or "(nil value)"))
end
local thing
local pos
for x = fromPos.x, toPos.x do
for y = fromPos.y, toPos.y do
for z = fromPos.z, toPos.z do
pos = {x = x, y = y, z = z}
thing = getTopCreature(pos)
if t(thing.uid) then
table.insert(tmp, thing.uid)
if not countSummon and isSummon(thing.uid) then
for i = 1, #tmp do
if tmp[i] == thing.uid then
table.remove(tmp, i)
break
end
end
end
end
end
end
end
return (get == GET_COUNT and #tmp or get == GET_UID and tmp or print("[Warning - Function::getCreaturesInQuestArea] Unknown type to get " .. (get or "(nil value)")))
end
function kickEvent(cid, item, position, fromPosition)
if getCreaturesInQuestArea(TYPE_PLAYER, NWcorner, SEcorner, GET_COUNT) > 0 then
doTeleportThing(cid, deny)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doCreatureSay(cid, "You have been kicked out from hunting room.", TALKTYPE_ORANGE_1)
end
end
function onStepIn(cid, item, pos)
if getPlayerStorageValue (cid, storage[1]) == storage[2] then
if getCreaturesInQuestArea(TYPE_PLAYER, NWcorner, SEcorner, GET_COUNT) > 0 then
doTeleportThing(cid,deny)
doCreatureSay(cid, 'Someone is still in this room. Please wait for your turn(max ' .. getGlobalStorageValue(delayglobal)-os.time() .. ' seconds left).', TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(cid), CONST_ME_FIREAREA)
else
doTeleportThing(cid,spawnplayer)
doSendMagicEffect(getCreaturePosition(cid),10)
doCreatureSay(cid, 'You have ten minutes to slain your enemy, otherwise you will be kicked out.', TALKTYPE_ORANGE_1)
setGlobalStorageValue(delayglobal, os.time() + (fighttime / 1000))
setPlayerStorageValue(cid,storage[1],keyafter)
doSummonCreature(boss, spawnboss)
demodras = addEvent(kickEvent, fighttime, cid)
end
else
doTeleportThing(cid,deny)
doCreatureSay(cid, 'You are not allowed to enter here!', TALKTYPE_ORANGE_1)
doSendMagicEffect(getThingPos(cid), CONST_ME_FIREAREA)
end
doSendMagicEffect(getThingPos(item.uid), CONST_ME_PURPLEENERGY)
return true
end
this one could be written in tables and all exits could be in one script of course, but here's example for single one I made for testing:
DemodrasExit.lua
Lua:
local deny = {x=311, y=403, z=12}
function onStepIn(cid, item, pos)
doTeleportThing(cid,deny)
doCreatureSay(cid, 'You have left the arena. Now you may begin this task again.', TALKTYPE_ORANGE_1)
stopEvent(demodras)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
return true
end
in movements.xml(actionids must be put on portals or floors below them):
XML:
<movevent type="StepIn" actionid="17000" event="script" value="boss/demodras.lua"/>
<movevent type="StepIn" actionid="17050" event="script" value="boss/demodrasexit.lua"/>