• 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!

Instance Dungeons: Lever and teleport with different coordinations

munch

New Member
Joined
Mar 26, 2010
Messages
143
Reaction score
0
This isn't a request, but only to know if it's possible to have "instance dungeons" in Tibia, with a tiny bit in-depth explanation, if you don't mind.
I don't mean post any codes or anything like that, but only explain how it could be done.

First, I want to explain in detail what this is all about, however, it's not required, just a little in-sight.

Instance Dungeons:
I want something like "instances" as in other MMOs, though these instances are static and are not created upon entering it.
You enter an instance just like you enter the Annihilator quest, except it's only one team per instance; so the next team to join are sent to the next available instance.

If you die in an instance, you either A.) get sent to a temple inside the instance, or B.) sent to your residence temple and needs to walk onto a teleport to enter the instance again.

When the time's up you are tossed out from the instance to the dungeon.
If either all party members have left the instance through the "Exit-TP" or the time's up, the instance will change state to "available".


Would it be possible to have something like this?

Levers and Teleports:
Team A pulls the Lever.
Lever sends Team A to Instance 1.
Lever sends character names and Instance 1's coordinations to Teleport.
Lever labels Instance 1 as Busy.

Teleport stores character names with Instance 1's coordinations.

Team B pulls the Lever
Lever changes to Instance 2.
Lever sends Team B to Instance 2.
Lever sends character names and Instance 2's coordinations to Teleport.
Lever labels Instance 2 as Busy.

Teleport stores character names with Instance 1's coordinations.

Player 1 from Team A dies in instance and get sent to his/her's residence temple.
Player 1 walks onto Teleport.

Teleport checks character name and sends Player 1 to Instance 1's coordinations.

The time's up and Team A get tossed out from Instance 1.
Lever erase label from Instance 1 and is now available again.
Teleport erase character names from Instance 1's coordinations.




Best regards,
Munchies. :)
 
Last edited:
made something like it some time ago, thought i'd share
alright, here we go

» 000-constant.lua/global.lua
Lua:
-- same instances have to be aligned horizontally next to each other,
-- with the first one being furthermost to the left

instances = {
	[9999] = { -- unique ID of lever
		players = {
		--  {stand at tile, destination in the first instance}
			{{x=496, y=537, z=9}, {x=1107,y=1207,z=7}},
			{{x=497, y=537, z=9}, {x=1108,y=1207,z=7}},
			{{x=498, y=537, z=9}, {x=1109,y=1207,z=7}},
			{{x=499, y=537, z=9}, {x=1107,y=1208,z=7}},
			{{x=500, y=537, z=9}, {x=1108,y=1208,z=7}},
			{{x=501, y=537, z=9}, {x=1109,y=1208,z=7}}
		},
		min=3, -- minimum players
		levelMin=50, -- minimum level
		levelMax=200, -- maximum level
		kick=15 * 1000, -- kick

		storage={2001,2003}, -- global storage range, must be unique for each lever
		spacing=10, -- !IMPORTANT! horizonal spacing (blank tiles) between each 2 instances on map

		range={
			{x=1044,y=1092,z=2},
								{x=1156,y=1213,z=7}
		} -- !IMPORTANT! top left and bottom right corner positions of the first mapped instance, used to calculate the same for the rest of instances
	}
}

for _, k in pairs(instances) do
	for i = k.storage[1], k.storage[2] do
		local b = (k.spacing+(k.range[2].x-k.range[1].x)+1) * (i-k.storage[1])
		k.range[i] = {{x=k.range[1].x+b, y=k.range[1].y, z=k.range[1].z}, {x=k.range[2].x+b, y=k.range[2].y, z=k.range[2].z}}
	end
end

function isInInstance(cid)
	local p = getThingPos(cid)
	for _, k in pairs(instances) do
		for i = k.storage[1], k.storage[2] do
			if isInRange(p, k.range[i][1], k.range[i][2]) then
				return i
			end
		end
	end
end
» levers
XML:
<action uniqueid="9999" event="script" value="instance.lua"/>
Lua:
local function kick(p, uid, n)
	for i = 1, #p do
		if p[i] and isPlayer(p[i]) and isInRange(getThingPos(p[i]), instances[uid].range[n][1], instances[uid].range[n][2]) then
			doTeleportThing(p[i], getPlayerMasterPos(p[i]))
		end
	end
	setGlobalStorageValue(n, -1)
end

local event = {}

function onUse(cid, item, fromPosition, itemEx, toPosition)

	local k = instances[item.uid]
	if k then

		local n
		for i = k.storage[1], k.storage[2] do
			if getGlobalStorageValue(i) < 1 then
				n = i
				break
			end
		end
	
		if not n then
			return doPlayerSendCancel(cid, 'All instances are currently in use, please wait.')
		end
	
		local p, num = {}, 0

		for i = 1, #k.players do
			p[i] = getTopCreature(k.players[i][1]).uid
			if p[i] ~= 0 and isPlayer(p[i]) then
				num = num + 1

				if k.levelMin or k.levelMax then
					local lvl = getPlayerLevel(p[i])
					if lvl < k.levelMin then
						return doPlayerSendCancel(cid, 'All players need to have level higher than ' .. k.levelMin .. '.')
					elseif lvl > k.levelMax then
						return doPlayerSendCancel(cid, 'All players need to have level lower than ' .. k.levelMax .. '.')
					end
				end

			end
		end

		if k.min and num < k.min then
			return doPlayerSendCancel(cid, 'This instance requires at least '..k.min..' players.')
		end

		stopEvent(event[n])
	
		local b = (k.spacing+(k.range[2].x-k.range[1].x)+1) * (n-k.storage[1])
		setGlobalStorageValue(n, num)

		for i = 1, #p do
			if p[i] ~= 0 then
				local pos = {x=k.players[i][2].x+b, y=k.players[i][2].y, z=k.players[i][2].z}
				doTeleportThing(p[i], pos)
				doSendMagicEffect(k.players[i][1], CONST_ME_TELEPORT)
				doSendMagicEffect(pos, CONST_ME_TELEPORT)
			end
		end

		event[n] = addEvent(kick, k.kick, p, item.uid, n)

		return true
	end

end
» exit/escape teleport
XML:
<movevent type="StepIn" actionid="2000" event="script" value="instance.lua"/>
Lua:
function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		local v = isInInstance(cid)
		if v then
			setGlobalStorageValue(v, getGlobalStorageValue(v) - 1)
			doTeleportThing(cid, getPlayerMasterPos(cid))
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
			doSendMagicEffect(getPlayerMasterPos(cid), CONST_ME_TELEPORT)
		end
	end
end
» logout/death event
XML:
<event type="logout" name="logout" event="script" value="instance.lua"/>
<event type="death" name="death" event="script" value="instance.lua"/>
Lua:
local function f(cid)
	local v = isInInstance(cid)
	if v then
		setGlobalStorageValue(v, getGlobalStorageValue(v) - 1)
	end
	return true
end

function onLogout(cid)
	return f(cid)
end

function onDeath(cid, corpse, killer)
	return f(cid)
end
there's stuff to edit to make it exactly as you described, but it's a start
 
Last edited:
Back
Top