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

Dungeon System [ 0.4 / 0.3.7 / 0.3.6 ]

Xikini

I whore myself out for likes
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,787
Solutions
581
Reaction score
5,354
Dungeon System

-> Multiple players can access a dungeon at a time, however only 1 player per sub-area.

-> Each dungeon can have unlimited sub-areas. Each sub-area can hold 1 player.
->-> If all sub-areas are full, players wanting to join this dungeon will have to wait until it's empty.

-> Each dungeon has their own reward scheme. (item and experience)
-> -> This means that every sub-area in that dungeon will have the same reward.

-> Everytime a player completes a dungeon, they get the reward. (They can access the dungeon infinite times, and get infinite rewards.)

-> Each dungeon is governed by a single actionid.
-> -> It controls the sub-areas, creature kill counting, storage values, reward details.. everything.

Here's my fabulous paint skills showcasing what a Dungeon with 3 sub-area's might look like.
Note: Each sub-area can be whatever size / shape you want, with multiple floors.
-> Just make sure that top_left_corner & bot_right_corner have the appropriate locations.

Untitled.png

Lua:
--[[
    data/lib/000-constant.lua [place anywhere. (I suggest very top or very bottom)]
--]]

dungeon_system_config = {
    ---------------------------
    -- 45001 is a single dungeon, with multiple area's.
    -- since it is a single dungeon, the reward for all area's of this dungeon is the same.
    -- if area 1 is occupied, then player teleports to area 2.
    -- if area 2 is occupied, then it tries to goto area 3. if area 3 doesn't exist, player must wait for a dungeon to be empty.
    -- you can create only 1 area per dungeon if you want, or you can create infinite area's. Just depends on what you add into the table.
    [45001] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 1111,
        reward_amount = 1,
        experience = 1000,
        area_info = {
      
            ---> {0} -- this holds player data to check if dungeon is empty or not.
            ---> {}  -- this holds monster data to check if monsters in dungeon have been killed.
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos (where player starts the dungeon from)
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}}, -- you can add as many or as little monsters as you desire.
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
      
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
      
        }
    },
    ---------------------------
    [45002] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 2222,
        reward_amount = 1,
        experience = 2000,
        area_info = {
  
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
      
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
      
        }
    }
    ---------------------------
}
Lua:
--[[
    actions.xml
    <action actionid="45001-45002" event="script" value="onUse_xikini_dungeon_system.lua"/>
--]]

-- simple reward script, using actionid and the global table.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local action_ID = item.actionid
    local reward = dungeon_system_config[action_ID]
    if not reward then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_2") -- actionid on tile is incorrect or not in table.
        return true
    end

    -- if storage == -1, then we know that all monsters are dead, and reward has been obtained.
    -- if storage > 0 then monsters are still alive, since we count backwards to 0 monsters alive, when then allows the player to get their reward.
    local cur_storage = getPlayerStorageValue(cid, action_ID)
    if cur_storage == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You've already obtained the reward. Please enter the teleport to exit the dungeon.")
        return true
    elseif cur_storage > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
        return true
    end

    if getItemWeightById(reward.reward_itemid, reward.reward_amount) > getPlayerFreeCap(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You do not have enough capacity to obtain this reward.")
        return true
    end

    if reward.experience > 0 then
        doPlayerAddExperience(cid, reward.experience)
    end
    doPlayerAddItem(cid, reward.reward_itemid, reward.reward_amount, true)
    setPlayerStorageValue(cid, action_ID, -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Congratulations! Enter the teleport to exit the dungeon.")
    return true
end
Lua:
--[[
    creaturescripts.xml
    <event type="login" name="onLogin_xikini_dungeon_system" event="script" value="onLogin_xikini_dungeon_system.lua"/>

    login.lua [near bottom with other registered events]
    registerCreatureEvent(cid, "onLogin_xikini_dungeon_system")
--]]

-- if server shut down, player logged out, or player died in a dungeon.. reset the dungeon storage and teleport player to temple.
function onLogin(cid)
    local teleport = 0
    for v, k in pairs(dungeon_system_config) do
        if getPlayerStorageValue(cid, v) ~= -1 then
            teleport = 1
            setPlayerStorageValue(cid, v, -1)
        end
    end
    if teleport == 1 then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end
Lua:
--[[
	movements.xml
	<movevent type="StepIn" actionid="45001-45002" event="script" value="onStepIn_xikini_dungeon_system.lua"/>
--]]


local function dungeon_system_updater(cid, storage, timer, index)
	if not isCreature(cid) then
		if cid == index[1][1] then
			index[1][1] = 0 -- if player dies or logs out, reset player data to indicate dungeon is empty.
		end
		return true
	end
	
	-- checks if the player is still inside the dungeon (so if player has completed dungeon but not yet left the dungeon, we can continue timer until auto-kick)
	local creature_pos = getPlayerPosition(cid)
	if creature_pos.x >= index[3][2].x and creature_pos.x <= index[3][3].x and creature_pos.y >= index[3][2].y and creature_pos.y <= index[3][3].y and creature_pos.z >= index[3][2].z and creature_pos.z <= index[3][3].z then
	else
		if cid == index[1][1] then
			index[1][1] = 0 -- if player leaves the dungeon, reset player data to indicate dungeon is empty.
		end
		return true
	end
	
	-- check if any monsters have died, and update player storage.
	local new_count = -1
	for i = #index[2], 1, -1 do
		if not isCreature(index[2][i]) then
			new_count = getPlayerStorageValue(cid, storage) - 1
			setPlayerStorageValue(cid, storage, new_count)
			table.remove(index[2], i)
		end
	end
	
	-- tell player that monsters have died.
	if new_count > 0 then
		local monster_count = #index[4]
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed [" .. (monster_count - new_count) .. " / " .. monster_count .."]")
	elseif new_count == 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed all the creatures in this dungeon. Go open the chest for your reward.")
	end
	
	-- timeout timer stuff
	timer = timer + 0.5 -- timer counts every 0.5 seconds, to check if player has run out of time.
	if timer < dungeon_system_config[storage].timeout then
		addEvent(dungeon_system_updater, 500, cid, storage, timer, index)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Out of time! You've been removed from the Dungeon.")
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		setPlayerStorageValue(cid, storage, -1)
		index[1][1] = 0
	end
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	local storage = item.actionid
	local dungeon = dungeon_system_config[storage]
	if not dungeon then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_1") -- actionid on tile is incorrect or not in table.
		return true
	end
	
	dungeon = dungeon.area_info -- re-using local when possible, to make script cleaner
	
	-- check if player is already in a dungeon, and teleport them out.
	for i = 1, #dungeon do
		if dungeon[i][1][1] == cid then
			local cur_storage = getPlayerStorageValue(cid, storage)
			if cur_storage == -1 then
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Dungeon Completed Successfully.")
				return true
			else
				if cur_storage == 0 then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You must collect your reward before exiting the dungeon.")
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
				end
				doTeleportThing(cid, fromPosition)
				return true
			end
		end
	end
	
	-- find a dungeon that is empty.
	local area = 0
	for i = 1, #dungeon do
		if not isCreature(dungeon[i][1][1]) then
			area = i
			break
		end
		local creature_pos = getPlayerPosition(dungeon[i][1][1])
		if creature_pos.x >= dungeon[i][3][2].x and creature_pos.x <= dungeon[i][3][3].x and creature_pos.y >= dungeon[i][3][2].y and creature_pos.y <= dungeon[i][3][3].y and creature_pos.z >= dungeon[i][3][2].z and creature_pos.z <= dungeon[i][3][3].z then
		else
			area = i
			break
		end                
	end
	
	-- if no dungeons empty
	if area == 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Sorry, no dungeons are empty. Try again later.")
		doTeleportThing(cid, fromPosition)
		return true
	end
	
	dungeon = dungeon[area]
	dungeon[1][1] = cid -- hold player data for later checking if dungeon is empty
	local monster_count = #dungeon[4]
	setPlayerStorageValue(cid, storage, monster_count) -- player storage is set as max monsters, and count down to 0 later.
	
	-- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
	for i = #dungeon[2], 1, -1 do
		if isCreature(dungeon[2][i]) then
			doRemoveCreature(dungeon[2][i])
		end
	end
	dungeon[2] = {}
	
	-- add all monsters into the dungeon, and store creatureids in table.
	for i = 1, monster_count do
		local monster = doCreateMonster(dungeon[4][i][1], dungeon[4][i][2])
		table.insert(dungeon[2], monster)
	end
	
	-- addEvent for timer and creature death tracking.
	addEvent(dungeon_system_updater, 500, cid, storage, 0, dungeon)
	doTeleportThing(cid, dungeon[3][1])
	return true
end
 
Last edited:
Updated script with minor bug fixes.

Make sure you guys include all your floors when setting up top_left_corner and bot_right_corner. (z position.)
If you don't include all floors and a player goes up a staircase, script will think player has left the area, and cause the player to get stuck inside the dungeon.

Try to think of your island / map as a 3d cube.

Need to uncompass the entire cube, from corner to corner.

Example:

Lua:
{x = 950, y = 950, z = 4}, -- top_left_corner 
{x = 1050, y = 1050, z = 11}  -- bot_right_corner
 
lol, well I don't specifically support 0.4

I got so angry looking at this code, that I was forced to script something from scratch. xD

Every time when I look at my old scripts done in past few years I feel same.

Nice idea. It would be great to merge it with some autogenerated dungeons.

#EDIT
Do you use this system on some server?
I would like to see it in game.
 
Every time when I look at my old scripts done in past few years I feel same.

Nice idea. It would be great to merge it with some autogenerated dungeons.

#EDIT
Do you use this system on some server?
I would like to see it in game.
Only person I know that is using it is OP from that thread, since it was for him that I created it.

I have TFS 1.3 installed on my computer, so I can't make a video or test it locally.
If you need help getting it up and running, feel free to pm, and we can swap discord details.
 
It would be nice if multipleplayers would be allowed. That way players can queue up and will join when enough players signed up
 
So cool!
As Aeronx said, it would be cool to some dungeons be multiplayer, like Grand Line Adventures do with their Special Missions, (Some dungeons need 2 players, others 3 or more).
 
Dungeon System

-> Multiple players can access a dungeon at a time, however only 1 player per sub-area.

-> Each dungeon can have unlimited sub-areas. Each sub-area can hold 1 player.
->-> If all sub-areas are full, players wanting to join this dungeon will have to wait until it's empty.

-> Each dungeon has their own reward scheme. (item and experience)
-> -> This means that every sub-area in that dungeon will have the same reward.

-> Everytime a player completes a dungeon, they get the reward. (They can access the dungeon infinite times, and get infinite rewards.)

-> Each dungeon is governed by a single actionid.
-> -> It controls the sub-areas, creature kill counting, storage values, reward details.. everything.

Here's my fabulous paint skills showcasing what a Dungeon with 3 sub-area's might look like.
Note: Each sub-area can be whatever size / shape you want, with multiple floors.
-> Just make sure that top_left_corner & bot_right_corner have the appropriate locations.

View attachment 48376

Lua:
--[[
    data/lib/000-constant.lua [place anywhere. (I suggest very top or very bottom)]
--]]

dungeon_system_config = {
    ---------------------------
    -- 45001 is a single dungeon, with multiple area's.
    -- since it is a single dungeon, the reward for all area's of this dungeon is the same.
    -- if area 1 is occupied, then player teleports to area 2.
    -- if area 2 is occupied, then it tries to goto area 3. if area 3 doesn't exist, player must wait for a dungeon to be empty.
    -- you can create only 1 area per dungeon if you want, or you can create infinite area's. Just depends on what you add into the table.
    [45001] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 1111,
        reward_amount = 1,
        experience = 1000,
        area_info = {
     
            ---> {0} -- this holds player data to check if dungeon is empty or not.
            ---> {}  -- this holds monster data to check if monsters in dungeon have been killed.
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos (where player starts the dungeon from)
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}}, -- you can add as many or as little monsters as you desire.
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
     
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
     
        }
    },
    ---------------------------
    [45002] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 2222,
        reward_amount = 1,
        experience = 2000,
        area_info = {
 
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
     
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
     
        }
    }
    ---------------------------
}
Lua:
--[[
    actions.xml
    <action actionid="45001-45002" event="script" value="onUse_xikini_dungeon_system.lua"/>
--]]

-- simple reward script, using actionid and the global table.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local action_ID = item.actionid
    local reward = dungeon_system_config[action_ID]
    if not reward then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_2") -- actionid on tile is incorrect or not in table.
        return true
    end

    -- if storage == -1, then we know that all monsters are dead, and reward has been obtained.
    -- if storage > 0 then monsters are still alive, since we count backwards to 0 monsters alive, when then allows the player to get their reward.
    local cur_storage = getPlayerStorageValue(cid, action_ID)
    if cur_storage == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You've already obtained the reward. Please enter the teleport to exit the dungeon.")
        return true
    elseif cur_storage > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
        return true
    end

    if getItemWeightById(reward.reward_itemid, reward.reward_amount) > getPlayerFreeCap(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You do not have enough capacity to obtain this reward.")
        return true
    end

    if reward.experience > 0 then
        doPlayerAddExperience(cid, reward.experience)
    end
    doPlayerAddItem(cid, reward.reward_itemid, reward.reward_amount, true)
    setPlayerStorageValue(cid, action_ID, -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Congratulations! Enter the teleport to exit the dungeon.")
    return true
end
Lua:
--[[
    creaturescripts.xml
    <event type="login" name="onLogin_xikini_dungeon_system" event="script" value="onLogin_xikini_dungeon_system.lua"/>

    login.lua [near bottom with other registered events]
    registerCreatureEvent(cid, "onLogin_xikini_dungeon_system")
--]]

-- if server shut down, player logged out, or player died in a dungeon.. reset the dungeon storage and teleport player to temple.
function onLogin(cid)
    local teleport = 0
    for v, k in pairs(dungeon_system_config) do
        if getPlayerStorageValue(cid, v) ~= -1 then
            teleport = 1
            setPlayerStorageValue(cid, v, -1)
        end
    end
    if teleport == 1 then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end
Lua:
--[[
    movements.xml
    <movevent type="StepIn" actionid="45001-45002" event="script" value="onStepIn_xikini_dungeon_system.lua"/>
--]]


local function dungeon_system_updater(cid, storage, timer, index)
    if not isCreature(cid) then
        index[1][1] = 0 -- if player dies or logs out, reset player data to indicate dungeon is empty.
        return true
    end
   
    -- check if any monsters have died, and update player storage.
    local new_count = -1
    for i = #index[2], 1, -1 do
        if not isCreature(index[2][i]) then
            new_count = getPlayerStorageValue(cid, storage) - 1
            setPlayerStorageValue(cid, storage, new_count)
            table.remove(index[2], i)
        end
    end
   
    -- tell player that monsters have died.
    if new_count > 0 then
        local monster_count = #index[4]
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed [" .. (monster_count - new_count) .. " / " .. monster_count .."]")
    elseif new_count == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed all the creatures in this dungeon. Go open the chest for your reward.")
    end
   
    -- checks if the player is still inside the dungeon (so if player has completed dungeon but not yet left the dungeon, we can continue timer until auto-kick)
    local creature_pos = getPlayerPosition(cid)
    if creature_pos.x >= index[3][2].x and creature_pos.x <= index[3][3].x and creature_pos.y >= index[3][2].y and creature_pos.y <= index[3][3].y and creature_pos.z >= index[3][2].z and creature_pos.z <= index[3][3].z then
        timer = timer + 0.5 -- timer counts every 0.5 seconds, to check if player has run out of time.
        if timer < dungeon_system_config[storage].timeout then
            addEvent(dungeon_system_updater, 500, cid, storage, timer, index)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Out of time! You've been removed from the Dungeon.")
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            setPlayerStorageValue(cid, storage, -1)
            index[1][1] = 0
        end
    else
        index[1][1] = 0 -- if player leaves the dungeon, reset player data to indicate dungeon is empty.
    end
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    local storage = item.actionid
    local dungeon = dungeon_system_config[storage]
    if not dungeon then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_1") -- actionid on tile is incorrect or not in table.
        return true
    end
   
    dungeon = dungeon.area_info -- re-using local when possible, to make script cleaner
   
    -- check if player is already in a dungeon, and teleport them out.
    for i = 1, #dungeon do
        if dungeon[i][1][1] == cid then
            local cur_storage = getPlayerStorageValue(cid, storage)
            if cur_storage == -1 then
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Dungeon Completed Successfully.")
                return true
            else
                if cur_storage == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You must collect your reward before exiting the dungeon.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
                end
                doTeleportThing(cid, fromPosition)
                return true
            end
        end
    end
   
    -- find a dungeon that is empty.
    local area = 0
    for i = 1, #dungeon do
        if not isCreature(dungeon[i][1][1]) then
            area = i
            break
        end
        local creature_pos = getPlayerPosition(dungeon[i][1][1])
        if creature_pos.x >= dungeon[i][3][2].x and creature_pos.x <= dungeon[i][3][3].x and creature_pos.y >= dungeon[i][3][2].y and creature_pos.y <= dungeon[i][3][3].y and creature_pos.z >= dungeon[i][3][2].z and creature_pos.z <= dungeon[i][3][3].z then
        else
            area = i
            break
        end               
    end
   
    -- if no dungeons empty
    if area == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Sorry, no dungeons are empty. Try again later.")
        doTeleportThing(cid, fromPosition)
        return true
    end
   
    dungeon = dungeon[area]
    dungeon[1][1] = cid -- hold player data for later checking if dungeon is empty
    local monster_count = #dungeon[4]
    setPlayerStorageValue(cid, storage, monster_count) -- player storage is set as max monsters, and count down to 0 later.
   
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
   
    -- add all monsters into the dungeon, and store creatureids in table.
    for i = 1, monster_count do
        local monster = doCreateMonster(dungeon[4][i][1], dungeon[4][i][2])
        table.insert(dungeon[2], monster)
    end
   
    -- addEvent for timer and creature death tracking.
    addEvent(dungeon_system_updater, 500, cid, storage, 0, dungeon)
    doTeleportThing(cid, dungeon[3][1])
    return true
end

It works very well. I don't know if you could put more than 1 reward items?
Also if you could by command bone example / Dungeon rat
When you put the command, it will put you on a waiting list, you will have 3 minutes waiting to see if more players join and if 3 minutes pass and only 1 player is there, the dungeon will start with one player.
Post automatically merged:

Lua:
function onLogin(cid)
    local teleport = 0
    for v, k in pairs(dungeon_system_config) do
        if getPlayerStorageValue(cid, v) ~= -1 then
            teleport = 1
            setPlayerStorageValue(cid, v, -1)
        end
    end
    if teleport == 1 then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end

How do you have to teleport to an area and not to the player's city?
 
Last edited:
sorry to be reviving the topic, would it be possible to make a rank of how many dungeons was finalized? Could you help me?
 
Dungeon System

-> Multiple players can access a dungeon at a time, however only 1 player per sub-area.

-> Each dungeon can have unlimited sub-areas. Each sub-area can hold 1 player.
->-> If all sub-areas are full, players wanting to join this dungeon will have to wait until it's empty.

-> Each dungeon has their own reward scheme. (item and experience)
-> -> This means that every sub-area in that dungeon will have the same reward.

-> Everytime a player completes a dungeon, they get the reward. (They can access the dungeon infinite times, and get infinite rewards.)

-> Each dungeon is governed by a single actionid.
-> -> It controls the sub-areas, creature kill counting, storage values, reward details.. everything.

Here's my fabulous paint skills showcasing what a Dungeon with 3 sub-area's might look like.
Note: Each sub-area can be whatever size / shape you want, with multiple floors.
-> Just make sure that top_left_corner & bot_right_corner have the appropriate locations.

View attachment 48376

Lua:
--[[
    data/lib/000-constant.lua [place anywhere. (I suggest very top or very bottom)]
--]]

dungeon_system_config = {
    ---------------------------
    -- 45001 is a single dungeon, with multiple area's.
    -- since it is a single dungeon, the reward for all area's of this dungeon is the same.
    -- if area 1 is occupied, then player teleports to area 2.
    -- if area 2 is occupied, then it tries to goto area 3. if area 3 doesn't exist, player must wait for a dungeon to be empty.
    -- you can create only 1 area per dungeon if you want, or you can create infinite area's. Just depends on what you add into the table.
    [45001] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 1111,
        reward_amount = 1,
        experience = 1000,
        area_info = {
     
            ---> {0} -- this holds player data to check if dungeon is empty or not.
            ---> {}  -- this holds monster data to check if monsters in dungeon have been killed.
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos (where player starts the dungeon from)
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}}, -- you can add as many or as little monsters as you desire.
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
     
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
     
        }
    },
    ---------------------------
    [45002] = {
        timeout = 600, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 2222,
        reward_amount = 1,
        experience = 2000,
        area_info = {
 
            { {0}, {}, -- area 1 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            }, -- area 1 end
     
            { {0}, {}, -- area 2 start
                {    {x = 1111, y = 1111, z = 7}, -- teleport_in_pos
                    {x = 2222, y = 2222, z = 7}, -- top_left_corner
                    {x = 3333, y = 3333, z = 7} -- bot_right_corner
                },
                {    {"rat", {x = 1111, y = 1111, z = 7}},
                    {"rat", {x = 2222, y = 2222, z = 7}},
                    {"rat", {x = 3333, y = 3333, z = 7}},
                    {"rat", {x = 4444, y = 4444, z = 7}}
                }
            } -- area 2 end
     
        }
    }
    ---------------------------
}
Lua:
--[[
    actions.xml
    <action actionid="45001-45002" event="script" value="onUse_xikini_dungeon_system.lua"/>
--]]

-- simple reward script, using actionid and the global table.
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local action_ID = item.actionid
    local reward = dungeon_system_config[action_ID]
    if not reward then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_2") -- actionid on tile is incorrect or not in table.
        return true
    end

    -- if storage == -1, then we know that all monsters are dead, and reward has been obtained.
    -- if storage > 0 then monsters are still alive, since we count backwards to 0 monsters alive, when then allows the player to get their reward.
    local cur_storage = getPlayerStorageValue(cid, action_ID)
    if cur_storage == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You've already obtained the reward. Please enter the teleport to exit the dungeon.")
        return true
    elseif cur_storage > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
        return true
    end

    if getItemWeightById(reward.reward_itemid, reward.reward_amount) > getPlayerFreeCap(cid) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You do not have enough capacity to obtain this reward.")
        return true
    end

    if reward.experience > 0 then
        doPlayerAddExperience(cid, reward.experience)
    end
    doPlayerAddItem(cid, reward.reward_itemid, reward.reward_amount, true)
    setPlayerStorageValue(cid, action_ID, -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Congratulations! Enter the teleport to exit the dungeon.")
    return true
end
Lua:
--[[
    creaturescripts.xml
    <event type="login" name="onLogin_xikini_dungeon_system" event="script" value="onLogin_xikini_dungeon_system.lua"/>

    login.lua [near bottom with other registered events]
    registerCreatureEvent(cid, "onLogin_xikini_dungeon_system")
--]]

-- if server shut down, player logged out, or player died in a dungeon.. reset the dungeon storage and teleport player to temple.
function onLogin(cid)
    local teleport = 0
    for v, k in pairs(dungeon_system_config) do
        if getPlayerStorageValue(cid, v) ~= -1 then
            teleport = 1
            setPlayerStorageValue(cid, v, -1)
        end
    end
    if teleport == 1 then
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    end
    return true
end
Lua:
--[[
    movements.xml
    <movevent type="StepIn" actionid="45001-45002" event="script" value="onStepIn_xikini_dungeon_system.lua"/>
--]]


local function dungeon_system_updater(cid, storage, timer, index)
    if not isCreature(cid) then
        index[1][1] = 0 -- if player dies or logs out, reset player data to indicate dungeon is empty.
        return true
    end
   
    -- check if any monsters have died, and update player storage.
    local new_count = -1
    for i = #index[2], 1, -1 do
        if not isCreature(index[2][i]) then
            new_count = getPlayerStorageValue(cid, storage) - 1
            setPlayerStorageValue(cid, storage, new_count)
            table.remove(index[2], i)
        end
    end
   
    -- tell player that monsters have died.
    if new_count > 0 then
        local monster_count = #index[4]
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed [" .. (monster_count - new_count) .. " / " .. monster_count .."]")
    elseif new_count == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You have killed all the creatures in this dungeon. Go open the chest for your reward.")
    end
   
    -- checks if the player is still inside the dungeon (so if player has completed dungeon but not yet left the dungeon, we can continue timer until auto-kick)
    local creature_pos = getPlayerPosition(cid)
    if creature_pos.x >= index[3][2].x and creature_pos.x <= index[3][3].x and creature_pos.y >= index[3][2].y and creature_pos.y <= index[3][3].y and creature_pos.z >= index[3][2].z and creature_pos.z <= index[3][3].z then
        timer = timer + 0.5 -- timer counts every 0.5 seconds, to check if player has run out of time.
        if timer < dungeon_system_config[storage].timeout then
            addEvent(dungeon_system_updater, 500, cid, storage, timer, index)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Out of time! You've been removed from the Dungeon.")
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            setPlayerStorageValue(cid, storage, -1)
            index[1][1] = 0
        end
    else
        index[1][1] = 0 -- if player leaves the dungeon, reset player data to indicate dungeon is empty.
    end
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
    local storage = item.actionid
    local dungeon = dungeon_system_config[storage]
    if not dungeon then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "LUA ERROR: Contact Administrator. Error code: Xikini_1") -- actionid on tile is incorrect or not in table.
        return true
    end
   
    dungeon = dungeon.area_info -- re-using local when possible, to make script cleaner
   
    -- check if player is already in a dungeon, and teleport them out.
    for i = 1, #dungeon do
        if dungeon[i][1][1] == cid then
            local cur_storage = getPlayerStorageValue(cid, storage)
            if cur_storage == -1 then
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Dungeon Completed Successfully.")
                return true
            else
                if cur_storage == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You must collect your reward before exiting the dungeon.")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "There is still " .. cur_storage .. " monsters that need to be killed in this dungeon.")
                end
                doTeleportThing(cid, fromPosition)
                return true
            end
        end
    end
   
    -- find a dungeon that is empty.
    local area = 0
    for i = 1, #dungeon do
        if not isCreature(dungeon[i][1][1]) then
            area = i
            break
        end
        local creature_pos = getPlayerPosition(dungeon[i][1][1])
        if creature_pos.x >= dungeon[i][3][2].x and creature_pos.x <= dungeon[i][3][3].x and creature_pos.y >= dungeon[i][3][2].y and creature_pos.y <= dungeon[i][3][3].y and creature_pos.z >= dungeon[i][3][2].z and creature_pos.z <= dungeon[i][3][3].z then
        else
            area = i
            break
        end               
    end
   
    -- if no dungeons empty
    if area == 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Sorry, no dungeons are empty. Try again later.")
        doTeleportThing(cid, fromPosition)
        return true
    end
   
    dungeon = dungeon[area]
    dungeon[1][1] = cid -- hold player data for later checking if dungeon is empty
    local monster_count = #dungeon[4]
    setPlayerStorageValue(cid, storage, monster_count) -- player storage is set as max monsters, and count down to 0 later.
   
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
   
    -- add all monsters into the dungeon, and store creatureids in table.
    for i = 1, monster_count do
        local monster = doCreateMonster(dungeon[4][i][1], dungeon[4][i][2])
        table.insert(dungeon[2], monster)
    end
   
    -- addEvent for timer and creature death tracking.
    addEvent(dungeon_system_updater, 500, cid, storage, 0, dungeon)
    doTeleportThing(cid, dungeon[3][1])
    return true
end
Love this system so much!! I've tried it out but I'm having some issues :/ I've made 3 instances for a dungeon and it works fine until they're all filled. If they do get filled and another person enter after this it says that all monsters inside have been killed and everything starts getting buggy. People can join another players instance and you appear inside the instance after relogging etc. This ONLY happens if the instance has been filled to maximum players. After one of the players then finishes the dungeon and another player after enters this starts. When it's full it still warns that the dungeons are all full and you cant enter but as soon as another spot opens the bugs starts.
 
Love this system so much!! I've tried it out but I'm having some issues :/ I've made 3 instances for a dungeon and it works fine until they're all filled. If they do get filled and another person enter after this it says that all monsters inside have been killed and everything starts getting buggy. People can join another players instance and you appear inside the instance after relogging etc. This ONLY happens if the instance has been filled to maximum players. After one of the players then finishes the dungeon and another player after enters this starts. When it's full it still warns that the dungeons are all full and you cant enter but as soon as another spot opens the bugs starts.
I've looked through the code.. And the only thing I can think of is that 1 or more of your top_left & bot_right positions have to be incorrect. Probably the very last one.

and/or you've been using the /reload function and resetting all the tables while they were in use.

If you've checked both of these things and still having issues, you'd have to add prints throughout the script, tell me exactly how / what you did to reproduce the bug, and then post the console log along with the edited script and see if we can figure out where the logic is going whacky.

Most likely it's wrong positions tho.
 
I've looked through the code.. And the only thing I can think of is that 1 or more of your top_left & bot_right positions have to be incorrect. Probably the very last one.

and/or you've been using the /reload function and resetting all the tables while they were in use.

If you've checked both of these things and still having issues, you'd have to add prints throughout the script, tell me exactly how / what you did to reproduce the bug, and then post the console log along with the edited script and see if we can figure out where the logic is going whacky.

Most likely it's wrong positions tho.
Just a quick question regarding the top left and bot right positions. If the whole dungeon is on floor 7. Will the bot and top positions be 8 and 6? Or is that only if the dungeons have several levels?
Post automatically merged:

I tripple checked the positions and they're all correct :/

When there's 2 people doing the instance everything works fine. They can complete it and re enter without any issues. When all 3 instances gets filled the next player to enter the dungeon gets the bug. When he enters it says that all monsters have been slain and you can claim the reward.

I don't get any errors in the log :/ This happens with all other dungeons as well so it's not just this one that's bugged.

Here's the script for the dungeon:

Lua:
   [45002] = {
        timeout = 900, -- seconds until they timeout and teleport out of dungeon
        reward_itemid = 6527,
        reward_amount = 5,
        experience = 65000,
        area_info = {
      
            ---> {0} -- this holds player data to check if dungeon is empty or not.
            ---> {}  -- this holds monster data to check if monsters in dungeon have been killed.
            { {0}, {}, -- area 1 start
                {    {x = 32542, y = 32390, z = 11}, -- teleport_in_pos (where player starts the dungeon from)
                    {x = 32467, y = 32327, z = 11}, -- top_left_corner
                    {x = 32560, y = 32396, z = 11} -- bot_right_corner
                },
                {    {"dragon", {x = 32548, y = 32386, z = 11}},
                    {"dragon", {x = 32543, y = 32384, z = 11}}, -- you can add as many or as little monsters as you desire.
                    {"dragon lord", {x = 32546, y = 32381, z = 11}},
                    {"dragon lord", {x = 32547, y = 32368, z = 11}},
                    {"dragon lord", {x = 32556, y = 32363, z = 11}},
                    {"dragon lord", {x = 32548, y = 32358, z = 11}},
                    {"dragon lord", {x = 32537, y = 32364, z = 11}},
                    {"dragon lord", {x = 32536, y = 32372, z = 11}},
                    {"dragon", {x = 32531, y = 32374, z = 11}},
                    {"dragon lord", {x = 32537, y = 32349, z = 11}},
                    {"dragon", {x = 32534, y = 32351, z = 11}},
                    {"dragon lord", {x = 32528, y = 32365, z = 11}},
                    {"dragon lord", {x = 32519, y = 32361, z = 11}},
                    {"dragon lord", {x = 32519, y = 32367, z = 11}},
                    {"dragon lord", {x = 32515, y = 32377, z = 11}},
                    {"dragon", {x = 32509, y = 32382, z = 11}},
                    {"dragon lord", {x = 32500, y = 32392, z = 11}},
                    {"dragon lord", {x = 32505, y = 32388, z = 11}},
                    {"dragon lord", {x = 32520, y = 32347, z = 11}},
                    {"dragon lord", {x = 32528, y = 32336, z = 11}},
                    {"dragon", {x = 32523, y = 32336, z = 11}},
                    {"dragon", {x = 32512, y = 32342, z = 11}},
                    {"dragon lord", {x = 32498, y = 32332, z = 11}},
                    {"dragon lord", {x = 32499, y = 32341, z = 11}},
                    {"dragon", {x = 32502, y = 32336, z = 11}},
                    {"dragon lord", {x = 32496, y = 32360, z = 11}},
                    {"dragon lord", {x = 32500, y = 32355, z = 11}},
                    {"dragon", {x = 32486, y = 32358, z = 11}},
                    {"dragon lord", {x = 32478, y = 32359, z = 11}},
                    {"dragon lord", {x = 32472, y = 32375, z = 11}},
                    {"dragon lord", {x = 32479, y = 32374, z = 11}},
                    {"dragon lord", {x = 32475, y = 32369, z = 11}}
                }
            }, -- area 1 end
      
            { {0}, {}, -- area 2 start
                {    {x = 32542, y = 32467, z = 11}, -- teleport_in_pos
                    {x = 32467, y = 32404, z = 11}, -- top_left_corner
                    {x = 32560, y = 32473, z = 11} -- bot_right_corner
                },
                {    {"dragon", {x = 32548, y = 32463, z = 11}},
                    {"dragon", {x = 32543, y = 32461, z = 11}},
                    {"dragon lord", {x = 32546, y = 32458, z = 11}},
                    {"dragon lord", {x = 32547, y = 32445, z = 11}},
                    {"dragon lord", {x = 32556, y = 32440, z = 11}},
                    {"dragon lord", {x = 32548, y = 32435, z = 11}},
                    {"dragon lord", {x = 32537, y = 32441, z = 11}},
                    {"dragon lord", {x = 32536, y = 32449, z = 11}},
                    {"dragon", {x = 32531, y = 32451, z = 11}},
                    {"dragon lord", {x = 32537, y = 32426, z = 11}},
                    {"dragon", {x = 32534, y = 32428, z = 11}},
                    {"dragon lord", {x = 32528, y = 32442, z = 11}},
                    {"dragon lord", {x = 32519, y = 32438, z = 11}},
                    {"dragon lord", {x = 32519, y = 32444, z = 11}},
                    {"dragon lord", {x = 32515, y = 32454, z = 11}},
                    {"dragon", {x = 32509, y = 32459, z = 11}},
                    {"dragon lord", {x = 32500, y = 32469, z = 11}},
                    {"dragon lord", {x = 32505, y = 32465, z = 11}},
                    {"dragon lord", {x = 32520, y = 32424, z = 11}},
                    {"dragon lord", {x = 32528, y = 32413, z = 11}},
                    {"dragon", {x = 32523, y = 32413, z = 11}},
                    {"dragon", {x = 32512, y = 32419, z = 11}},
                    {"dragon lord", {x = 32498, y = 32409, z = 11}},
                    {"dragon lord", {x = 32499, y = 32418, z = 11}},
                    {"dragon", {x = 32502, y = 32413, z = 11}},
                    {"dragon lord", {x = 32496, y = 32437, z = 11}},
                    {"dragon lord", {x = 32500, y = 32432, z = 11}},
                    {"dragon", {x = 32486, y = 32435, z = 11}},
                    {"dragon lord", {x = 32478, y = 32436, z = 11}},
                    {"dragon lord", {x = 32472, y = 32452, z = 11}},
                    {"dragon lord", {x = 32479, y = 32451, z = 11}},
                    {"dragon lord", {x = 32475, y = 32446, z = 11}}
                }
            }, -- area 2 end
            
            { {0}, {}, -- area 3 start
                {    {x = 32542, y = 32543, z = 11}, -- teleport_in_pos
                    {x = 32467, y = 32480, z = 11}, -- top_left_corner
                    {x = 32560, y = 32549, z = 11} -- bot_right_corner
                },
                {    {"dragon", {x = 32548, y = 32539, z = 11}},
                    {"dragon", {x = 32543, y = 32537, z = 11}},
                    {"dragon lord", {x = 32546, y = 32534, z = 11}},
                    {"dragon lord", {x = 32547, y = 32521, z = 11}},
                    {"dragon lord", {x = 32556, y = 32516, z = 11}},
                    {"dragon lord", {x = 32548, y = 32511, z = 11}},
                    {"dragon lord", {x = 32537, y = 32517, z = 11}},
                    {"dragon lord", {x = 32536, y = 32525, z = 11}},
                    {"dragon", {x = 32531, y = 32527, z = 11}},
                    {"dragon lord", {x = 32537, y = 32502, z = 11}},
                    {"dragon", {x = 32534, y = 32504, z = 11}},
                    {"dragon lord", {x = 32528, y = 32518, z = 11}},
                    {"dragon lord", {x = 32519, y = 32514, z = 11}},
                    {"dragon lord", {x = 32519, y = 32520, z = 11}},
                    {"dragon lord", {x = 32515, y = 32530, z = 11}},
                    {"dragon", {x = 32509, y = 32535, z = 11}},
                    {"dragon lord", {x = 32500, y = 32545, z = 11}},
                    {"dragon lord", {x = 32505, y = 32541, z = 11}},
                    {"dragon lord", {x = 32520, y = 32500, z = 11}},
                    {"dragon lord", {x = 32528, y = 32489, z = 11}},
                    {"dragon", {x = 32523, y = 32489, z = 11}},
                    {"dragon", {x = 32512, y = 32495, z = 11}},
                    {"dragon lord", {x = 32498, y = 32485, z = 11}},
                    {"dragon lord", {x = 32499, y = 32494, z = 11}},
                    {"dragon", {x = 32502, y = 32489, z = 11}},
                    {"dragon lord", {x = 32496, y = 32513, z = 11}},
                    {"dragon lord", {x = 32500, y = 32508, z = 11}},
                    {"dragon", {x = 32486, y = 32511, z = 11}},
                    {"dragon lord", {x = 32478, y = 32512, z = 11}},
                    {"dragon lord", {x = 32472, y = 32528, z = 11}},
                    {"dragon lord", {x = 32479, y = 32527, z = 11}},
                    {"dragon lord", {x = 32475, y = 32522, z = 11}}
                }
            } -- area 3 end
      
        }
    },
 
Last edited:
Just a quick question regarding the top left and bot right positions. If the whole dungeon is on floor 7. Will the bot and top positions be 8 and 6? Or is that only if the dungeons have several levels?
Just z = 7 is fine. if it's 2 floors, then 6 & 7 or 7 & 8
When there's 2 people doing the instance everything works fine. They can complete it and re enter without any issues. When all 3 instances gets filled the next player to enter the dungeon gets the bug. When he enters it says that all monsters have been slain and you can claim the reward.

So 3 sub area's.

Person 1 hops in. (Goes to area 1)
Person 2 hops in. (Goes to area 2)
Person 3 hops in. (Goes to area 3)

Person 4 attempts to hop in -> told there is no rooms available.

Person 2 leaves.
Person 4 hops in. (Goes to area 2) ?

Player is told all monsters are killed.
Is Person 2 being told the monsters are killed? Or is it Person 4 being told that?

Can they immediately loot the chest?
Can they leave?

Does it continue fucking up for every person, or only that subarea?
 
Just z = 7 is fine. if it's 2 floors, then 6 & 7 or 7 & 8


So 3 sub area's.

Person 1 hops in. (Goes to area 1)
Person 2 hops in. (Goes to area 2)
Person 3 hops in. (Goes to area 3)

Person 4 attempts to hop in -> told there is no rooms available.

Person 2 leaves.
Person 4 hops in. (Goes to area 2) ?

Player is told all monsters are killed.
Is Person 2 being told the monsters are killed? Or is it Person 4 being told that?

Can they immediately loot the chest?
Can they leave?

Does it continue fucking up for every person, or only that subarea?
It's person 4 that is told that all monsters have been killed. I just tried it again. Killed 1 monster with person 1 and relogged to exit dungeon. Entered with person 4 and was told that 31/32 monsters have been killed. So it seems that it depends on how many the previous played left.

I then killed the last monster and took the reward with person 4 and exited the dungeon. After that I went back with person 1 and again it said 31/32 was killed. I then relogged with person 1 without killing any monsters and entered with person 4, then it said all monsters have been killed.

Exited with all players and re-entered with a random player, still says all monsters have been killed
Post automatically merged:

It's person 4 that is told that all monsters have been killed. I just tried it again. Killed 1 monster with person 1 and relogged to exit dungeon. Entered with person 4 and was told that 31/32 monsters have been killed. So it seems that it depends on how many the previous played left.

I then killed the last monster and took the reward with person 4 and exited the dungeon. After that I went back with person 1 and again it said 31/32 was killed. I then relogged with person 1 without killing any monsters and entered with person 4, then it said all monsters have been killed.

Exited with all players and re-entered with a random player, still says all monsters have been killed
Using TFS 0.4 if that helps
 
It's person 4 that is told that all monsters have been killed. I just tried it again. Killed 1 monster with person 1 and relogged to exit dungeon. Entered with person 4 and was told that 31/32 monsters have been killed. So it seems that it depends on how many the previous played left.

I then killed the last monster and took the reward with person 4 and exited the dungeon. After that I went back with person 1 and again it said 31/32 was killed. I then relogged with person 1 without killing any monsters and entered with person 4, then it said all monsters have been killed.

Exited with all players and re-entered with a random player, still says all monsters have been killed
Post automatically merged:


Using TFS 0.4 if that helps

change the onStepIn code line 106

from this
Lua:
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
to this
Lua:
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
    dungeon[2] = {}
 
change the onStepIn code line 106

from this
Lua:
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
to this
Lua:
    -- remove any monsters that are still alive in dungeon. (if a player died in the dungeon or timed out)
    for i = #dungeon[2], 1, -1 do
        if isCreature(dungeon[2][i]) then
            doRemoveCreature(dungeon[2][i])
        end
    end
    dungeon[2] = {}
Worked like a charm! Thank you so much for helping me! :D
 
Back
Top