• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

MoveEvent Killing in the name of... boss room

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,323
Solutions
26
Reaction score
2,694
Location
Poland
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
spwn.png

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"/>
 
Global Scripts?

not a single one, everything is checked in enterance and addEvent
just make arena no logout area and configure positions correctly and it's fail-safe

I'll got a great idea with this, but got rewards? i dont found it.
if you want to add them when player leaves the arena add them in:
demodrasexit.lua below:
stopEvent(demodras)
and in demodras.lua below:
doCreatureSay(cid, "You have been kicked out from hunting room.", TALKTYPE_ORANGE_1)
 
@up from what I noticed you have to change name of every timer and index it in exit.lua later
example in movements.xml - enterance portals and one exit script:
<movevent type="StepIn" actionid="17000" event="script" value="boss/demodras.lua"/>
<movevent type="StepIn" actionid="17001" event="script" value="boss/leviathan.lua"/> <!-- enterance from tp room -->
<movevent type="StepIn" actionid="17002" event="script" value="boss/leviathansea.lua"/><!-- enterance from boss tp in sea serpents area -->
<movevent type="StepIn" actionid="17003" event="script" value="boss/snapper.lua"/>
<movevent type="StepIn" actionid="17004" event="script" value="boss/hide.lua"/>
<movevent type="StepIn" actionid="17005" event="script" value="boss/bloodtusk.lua"/>
<movevent type="StepIn" actionid="17006" event="script" value="boss/shardhead.lua"/>
<movevent type="StepIn" actionid="17007" event="script" value="boss/thul.lua"/>
<movevent type="StepIn" actionid="17008" event="script" value="boss/esmeralda.lua"/>
<movevent type="StepIn" actionid="17009" event="script" value="boss/oldwidow.lua"/>
<movevent type="StepIn" actionid="17010" event="script" value="boss/themany.lua"/>
<movevent type="StepIn" actionid="17011" event="script" value="boss/stonecracker.lua"/>
<movevent type="StepIn" actionid="17012" event="script" value="boss/nox.lua"/>
<movevent type="StepIn" actionid="17013" event="script" value="boss/pirate.lua"/>
<movevent type="StepIn" actionid="17014" event="script" value="boss/fox.lua"/>
<movevent type="StepIn" actionid="17015" event="script" value="boss/necro.lua"/>

<movevent type="StepIn" actionid="17050-17100" event="script" value="boss/exit.lua"/>

exit.lua:
Lua:
function onStepIn(cid, item, pos)

aid = {
			[17050] = {x=311, y=403, z=12, boss=demodras},
			[17051] = {x=311, y=399, z=12, boss=leviathan},
			[17052] = {x=313, y=401, z=12, boss=snapper},
			[17053] = {x=313, y=401, z=12, boss=hide},
			[17054] = {x=313, y=401, z=12, boss=bloodtusk},
			[17055] = {x=313, y=401, z=12, boss=shardhead},
			[17056] = {x=313, y=401, z=12, boss=thul},
			[17057] = {x=313, y=401, z=12, boss=esmeralda},
			[17058] = {x=311, y=403, z=12, boss=oldwidow},
			[17059] = {x=311, y=399, z=12, boss=themany},
			[17060] = {x=311, y=399, z=12, boss=stonecracker},
			[17061] = {x=311, y=399, z=12, boss=nox},
			[17062] = {x=311, y=399, z=12, boss=pirate},
			[17063] = {x=311, y=403, z=12, boss=fox},
			[17064] = {x=313, y=401, z=12, boss=necro}
		}
entry = aid[item.actionid]
pos1 = {x=entry.x, y=entry.y, z=entry.z}	

doTeleportThing(cid,pos1)
doCreatureSay(cid, 'You have left the arena. Now you may begin this task again.', TALKTYPE_ORANGE_1)
stopEvent(entry.boss)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
    return true
end

Configured bosses folder(requires this in lua file located in lib folder):
https://mega.co.nz/#!2dcAkZzB!EzMtpyV_OKM-rk9ZC8UpoitaZqlk7KxvV0DEDjrAl1o


Fully installed system with tasks, quest log and npc here: http://otland.net/f464/9-81-evorpg-v3-zbizu-188251/
 
For me it doesn't kick out from the room after 10 minutes and next who is entering the rooms receive - Someone in this room, wait your turn (max -100 seconds left). And also it doesn't remove "old" creature in the room when entering.
Where is the problem?
 
Back
Top