Ir para conteúdo

Featured Replies

Postado
Em 16/05/2021 em 19:48, tataboy67 disse:

Dungeon System v1.1

A pedido de um usuário em meu Discord, resolvi ajuda-lo e desenvolver um sistema totalmente interativo e de qualidade aqui para vocês.
Bom, o sistema se baseia em uma ActionID que ao clicar, podemos ai entrar em uma dungeon, tendo tempo para finaliza-la e até um cooldown, caso queira entrar novamente.

Imagens do sistema:
 

  Ocultar conteúdo

Imagem 1 (Ao clicar no ActionID):
image.png.7f2a74c735112e23e20b933ff8e6efda.png


Imagem 2 (Detalhes da Dungeon):
image.png.0c9419abd5e4ce4d52f952983cabf16e.png


Imagem 3 (Ao tentar entrar sem Party):
image.png.cd206ec491c0634c1457c72a83800bd0.png

(Obs: existe diversas verificações a mais, tais como: "Todos os players, estão em PZ?", "Os players tem que estar a 'x' SQM de distancia do leader da PT para iniciar", ETC...)


Vamos ao Código:

Em actions, crie um arquivo com o nome de: Dungeon Actions.lua

  Ocultar conteúdo

 



function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
	
	player:registerEvent("DungeonSystem_Modal")
	
	local window = ModalWindow(DUNGEON_SYSTEM.Modal.ID, DUNGEON_SYSTEM.Modal.Title, DUNGEON_SYSTEM.Modal.Msg)
	
	window:addButton(200, "Confirm")
	window:addButton(201, "Details")
	window:addButton(202, "Exit")
	
	for k,v in pairs(DUNGEON_SYSTEM.Dungeons) do
		window:addChoice(k, "[OPEN] " .. v.Name)
	end
	
	window:setDefaultEnterButton(200)
    window:setDefaultEscapeButton(202)
	
	window:sendToPlayer(player)
	
	return true
end

 

 

 

Em creaturescripts, crie um arquivo com o nome de: Dungeon Creaturescript.lua

  Mostrar conteúdo oculto

 



function onModalWindow(player, modalWindowId, buttonId, choiceId)  
    
	player:unregisterEvent("DungeonSystem_Modal")

	local dg = DUNGEON_SYSTEM.Dungeons
	local msg = DUNGEON_SYSTEM.Messages
	local modal = DUNGEON_SYSTEM.Modal
	local sto = DUNGEON_SYSTEM.Storages	

    if (modalWindowId == DUNGEON_SYSTEM.Modal.ID) then
		
		if buttonId == 200 then
			
			local players = {}
			for x = dg[choiceId].FromPos.x, dg[choiceId].ToPos.x do
				for y = dg[choiceId].FromPos.y, dg[choiceId].ToPos.y do
					for z = dg[choiceId].FromPos.z, dg[choiceId].ToPos.z do
						local tile = Tile(x, y, z)
						local creature = tile:getTopCreature()
						if creature and creature:isPlayer() then
							players[#players+1] = creature
						end
					end
				end
			end
			
			if #players > 0 then
				player:getPosition():sendMagicEffect(CONST_ME_POFF)
				return player:sendTextMessage(MESSAGE_STATUS_SMALL, msg.PlayerInside)
			end
			
			if (dg[choiceId].NeedLevel) then
				if (player:getLevel() < dg[choiceId].Level) then
					player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format(msg.MsgNeedLevel, dg[choiceId].Level))
					return false
				end
			end
			
			local pt = player:getParty()
			local partyMembers
			
			local party = {}
			party = partyMembers
			
			local fromPosPlayer = player:getPosition()
			
			if (dg[choiceId].NeedParty) then
				
				if not pt then
					
					player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.MsgUniqueNeedParty)
					return false
				
				else
					
					partyMembers = pt:getMembers()
					local party = player:getParty():getMemberCount()
					
					if not (pt:getLeader():getName() == player:getName()) then
						
						player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.MsgLeaderParty)
						return false
					
					else
					
						local partyMaisUm = party+1
						
						if not (partyMaisUm == dg[choiceId].AmountParty) then
							player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format(msg.MsgNeedParty, dg[choiceId].AmountParty))
							return false
						end
						
						local names = {}
						local posOfPlayer = {}
						
						for i = 1, party do
						
							local ppt = partyMembers[i]
							local fromPosPpt = ppt:getPosition()
						
							if DUNGEON_SYSTEM.PzToEntry then
								if not getTileInfo(fromPosPpt).protection then
									player:getPosition():sendMagicEffect(CONST_ME_POFF)
									return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.NeedPzMsg)
								elseif not getTileInfo(fromPosPlayer).protection then
									player:getPosition():sendMagicEffect(CONST_ME_POFF)
									return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.NeedPzSoloMsg)
								end
							end
						
							-- SE TEM COOLDOWN
							if player:getStorageValue(sto.TimerCooldown) - os.time() > 0 or ppt:getStorageValue(sto.TimerCooldown) - os.time() > 0 then
								if player:getStorageValue(sto.TimerCooldown) - os.time() > 0 then
									player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format(msg.ToCooldown, string.diff(player:getStorageValue(sto.TimerCooldown)-os.time())))
									player:getPosition():sendMagicEffect(CONST_ME_POFF)
									ppt:getPosition():sendMagicEffect(CONST_ME_POFF)
								else
									player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format(msg.WaitFriendsCooldown, string.diff(ppt:getStorageValue(sto.TimerCooldown)-os.time())))
									player:getPosition():sendMagicEffect(CONST_ME_POFF)
									ppt:getPosition():sendMagicEffect(CONST_ME_POFF)
								end
								return false
							end
							
							names[i] = ppt:getName()
							
						end
						
						local positionPlayer = player:getPosition()
						local distance = DUNGEON_SYSTEM.SQMsDistanceOfLeader
						
						for x = positionPlayer.x - distance, positionPlayer.x + distance do
							for y = positionPlayer.y - distance, positionPlayer.y + distance do
								for z = positionPlayer.z, positionPlayer.z do
									local tileP = Tile(x, y, z)
									local creatureP = tileP:getTopCreature()
									if creatureP and creatureP:isPlayer() then
										for xx = 1, #names do
											if creatureP:getName() == names[xx] then
												posOfPlayer[#posOfPlayer+1] = creatureP
											end
										end
									end
								end
							end
						end
						
						if #posOfPlayer+1 ~= dg[choiceId].AmountParty then
							return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.MsgDistanceLeader)
						end
						
						if dg[choiceId].SpawnMonsters then
							for m, l in pairs(dg[choiceId].Monsters) do
								Game.createMonster(m, l)
							end
						end
						
						player:teleportTo(dg[choiceId].DungeonPos)
						player:getPosition():sendMagicEffect(40)
						player:say(msg.ToEntry, TALKTYPE_MONSTER_SAY)
						
						addEvent(function()
							player:teleportTo(fromPosPlayer)
							player:setStorageValue(sto.TimerCooldown, os.time() + DUNGEON_SYSTEM.CooldownTime)
							player:getPosition():sendMagicEffect(40)
							player:popupFYI(msg.ToFail)
							
							-- Remove All monsters
							local monsterPos = {}
							for x = dg[choiceId].FromPos.x, dg[choiceId].ToPos.x do
								for y = dg[choiceId].FromPos.y, dg[choiceId].ToPos.y do
									for z = dg[choiceId].FromPos.z, dg[choiceId].ToPos.z do
										local tile = Tile(x, y, z)
										local monster = tile:getTopCreature()
										if monster and monster:isMonster() then
											monster:remove()
										end
									end
								end
							end
							
						end, dg[choiceId].DungeonTime*1000)	
						
						for mx = 1, party do
						
							local ppt = partyMembers[mx]
							local fromPosPpt = ppt:getPosition()
						
							ppt:teleportTo(dg[choiceId].DungeonPos)
							ppt:getPosition():sendMagicEffect(40)
							
							addEvent(function()
								ppt:teleportTo(fromPosPpt)
								ppt:setStorageValue(sto.TimerCooldown, os.time() + DUNGEON_SYSTEM.CooldownTime)
								ppt:getPosition():sendMagicEffect(40)
								ppt:popupFYI(msg.ToFail)
							end, dg[choiceId].DungeonTime*1000)	
						
						end
						
					end
					
				end
				
			else
				
				if DUNGEON_SYSTEM.PzToEntry then
					if not getTileInfo(fromPosPlayer).protection then
						player:getPosition():sendMagicEffect(CONST_ME_POFF)
						return player:sendTextMessage(MESSAGE_EVENT_ADVANCE, msg.NeedPzSoloMsg)
					end
				end
				
				if player:getStorageValue(sto.TimerCooldown) - os.time() > 0 then
					player:getPosition():sendMagicEffect(CONST_ME_POFF)
					player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format(msg.ToCooldown, string.diff(player:getStorageValue(sto.TimerCooldown)-os.time())))
					return false
				end
				
				if dg[choiceId].SpawnMonsters then
					for m, l in pairs(dg[choiceId].Monsters) do
						Game.createMonster(m, l)
					end
				end
					
				-- To Dungeon
				player:teleportTo(dg[choiceId].DungeonPos)
				player:getPosition():sendMagicEffect(40)
				player:say(msg.ToEntry, TALKTYPE_MONSTER_SAY)
				player:setStorageValue(sto.TimerDungeon, os.time() + dg[choiceId].DungeonTime)
				
				-- Back Dungeon
				addEvent(function()
					player:teleportTo(fromPosPlayer)
					player:setStorageValue(sto.TimerCooldown, os.time() + DUNGEON_SYSTEM.CooldownTime)
					player:getPosition():sendMagicEffect(40)
					player:popupFYI(msg.ToFail)
					
					-- Remove All monsters
					local monsterPos = {}
					for x = dg[choiceId].FromPos.x, dg[choiceId].ToPos.x do
						for y = dg[choiceId].FromPos.y, dg[choiceId].ToPos.y do
							for z = dg[choiceId].FromPos.z, dg[choiceId].ToPos.z do
								local tile = Tile(x, y, z)
								local monster = tile:getTopCreature()
								if monster and monster:isMonster() then
									monster:remove()
								end
							end
						end
					end
					
				end, dg[choiceId].DungeonTime*1000)
				
			end
			
			
		elseif buttonId == 201 then
			
			player:registerEvent("DungeonSystemDetails_Modal")
			
			local needPartyMsg, needLevelMsg = "", ""
			
			if (dg[choiceId].NeedParty) then
				needPartyMsg = string.format("Party: %s players", dg[choiceId].AmountParty)
			else
				needPartyMsg = "Party: 1 players"
			end
			
			if (dg[choiceId].NeedLevel) then
				needLevelMsg = string.format("Level: %s+", dg[choiceId].Level)
			else
				needLevelMsg = "Don't need Level"
			end
			
			local detailsModal = ModalWindow(modal.IDDetails, modal.TitleDetails, string.format(">> Dungeon %s <<\n\n" .. needPartyMsg .. "\n" .. needLevelMsg .."\n\nTime to Dungeon: %s", dg[choiceId].Name, string.diff(dg[choiceId].DungeonTime)))
			
			detailsModal:addButton(100, "Back")
			
			detailsModal:setDefaultEnterButton(100)
			detailsModal:setDefaultEscapeButton(100)
			
			detailsModal:sendToPlayer(player)
			
			-- player:popupFYI(string.format(">> Dungeon %s <<\n\n" .. needPartyMsg .. "\n" .. needLevelMsg .."\n\nTime to Dungeon: %s", dg[choiceId].Name, string.diff(dg[choiceId].DungeonTime)))

		end
    
	end
	
end

 

 

 

Ainda em creaturescripts, crie outro arquivo com o nome de: Type Dungeon Creaturescript.lua

  Mostrar conteúdo oculto

 



function modalDungeon(player)

	player:registerEvent("DungeonSystem_Modal")
	
	local window = ModalWindow(DUNGEON_SYSTEM.Modal.ID, DUNGEON_SYSTEM.Modal.Title, DUNGEON_SYSTEM.Modal.Msg)
	
	window:addButton(200, "Confirm")
	window:addButton(201, "Details")
	window:addButton(202, "Exit")
	
	for k,v in pairs(DUNGEON_SYSTEM.Dungeons) do
		window:addChoice(k, "[OPEN] " .. v.Name)
	end
	
	window:setDefaultEnterButton(200)
    window:setDefaultEscapeButton(202)
	
	window:sendToPlayer(player)
	
end

function onModalWindow(player, modalWindowId, buttonId, choiceId)  
    
	player:unregisterEvent("DungeonSystemType_Modal")

	local dg = DUNGEON_SYSTEM.Dungeons
	local msg = DUNGEON_SYSTEM.Messages
	local modal = DUNGEON_SYSTEM.Modal
	local sto = DUNGEON_SYSTEM.Storages	
	
	if buttonId == 100 then
		
		modalDungeon(player)
		
	end
	
end

 

 

 

 

 Na LIB, crie um arquivo com o nome de Dungeon System Lib.lua, e adicione:

  Mostrar conteúdo oculto

 



DUNGEON_SYSTEM = {

	Storages = {
		timerDungeon = 49356,
		timerCooldown = 50203,
		storageReward = 50205,
	},
	
	Modal = {
		IDType = 2049,
		TitleType = "Type Dungeon, by: Tataboy67",
		MsgType = "Select this type:",
	
		ID = 2050,
		Title = "Dungeon System, by: Tataboy67!",
		Msg = "Select your Dungeon:",
		
		IDDetails = 2051,
		TitleDetails = "Details Dungeon",
	},
	
	Messages = {
		ToEntry = "Welcome to Dungeon",
		ToFail = "You were unable to complete the dungeon\n\nPlease try again!",
		
		WaitFriendsCooldown = "Wait your friend: %s",
		ToCooldown = "You're in cooldown to enter in a dungeon again. Cooldown: %s.",
		MsgNeedLevel = "You don't have level required. You need level %s.",
		MsgUniqueNeedParty = "You need party, to entry in dungeon",
		MsgNeedParty = "You need to be at a party to enter the dungeon. You need %s players",
		MsgLeaderParty = "You are not the leader of the Party.",
		
		MsgDistanceLeader = "Your friends need to be close to you.",
		
		NeedPzSoloMsg = "You need to be in a safe area [PZ].",
		NeedPzMsg = "Your team needs to go a safe area [PZ].",
	
		PlayerInside = "Already has inside.",
	},
	
	CooldownTime = 1,
	
	PzToEntry = true,
	
	SQMsDistanceOfLeader = 5,

	Dungeons = {

		[1] = {
			-- Name
			Name = "Diabolic Hyper",
			
			-- Party
			NeedParty = true,
			AmountParty = 2,
			
			-- Level
			NeedLevel = false,
			Level = 50,
						
			-- Dungeon
			DungeonTime = 10, -- 5 min, 30 seconds
			DungeonPos = Position(1165, 934, 7),

			-- Position Dungeon
			FromPos = {x = 1161, y = 930, z = 7}, 	-- Position /\ < from the dungeon
			ToPos = {x = 1226, y = 940, z = 7},		-- Position \/ > from the dungeon
			
			SpawnMonsters = true,
			Monsters = {
				["Demon"] = Position(1170, 934, 7),
				["Rat"] = Position(1170, 935, 7),
				["Hydra"] = Position(1167, 932, 7),
			},
			
		},
		
		[2] = {
			-- Name
			Name = "Supreme Rat's",
			
			-- Party
			NeedParty = false,
			AmountParty = 1,
			
			-- Level
			NeedLevel = false,
			Level = 50,
						
			-- Dungeon
			DungeonTime = 10, -- 5 min, 30 seconds
			DungeonPos = Position(1165, 934, 7),

			-- Position Dungeon
			FromPos = {x = 1161, y = 930, z = 7}, 	-- Position /\ < from the dungeon
			ToPos = {x = 1226, y = 940, z = 7},		-- Position \/ > from the dungeon
			
			SpawnMonsters = true,
			Monsters = {
				["Demon"] = Position(1170, 934, 7),
				["Rat"] = Position(1170, 935, 7),
				["Hydra"] = Position(1167, 932, 7),
			},
			
		},
		
		[3] = {
			-- Name
			Name = "Triple",
			
			-- Party
			NeedParty = true,
			AmountParty = 3,
			
			-- Level
			NeedLevel = false,
			Level = 50,
						
			-- Dungeon
			DungeonTime = 10, -- 5 min, 30 seconds
			DungeonPos = Position(1165, 934, 7),

			-- Position Dungeon
			FromPos = {x = 1161, y = 930, z = 7}, 	-- Position /\ < from the dungeon
			ToPos = {x = 1226, y = 940, z = 7},		-- Position \/ > from the dungeon
			
			SpawnMonsters = true,
			Monsters = {
				["Demon"] = Position(1170, 934, 7),
				["Rat"] = Position(1170, 935, 7),
				["Hydra"] = Position(1167, 932, 7),
			},
			
		},

	},
	
}

 

 

 

 

Em creaturescripts.xml, adicione:

  Mostrar conteúdo oculto

 



	<!-- Dungeon System -->
	<event type="modalwindow" name="DungeonSystem_Modal" script="Dungeon Creaturescript.lua"/>
	<event type="modalwindow" name="DungeonSystemType_Modal" script="Type Dungeon Creaturescript.lua"/>
	<event type="modalwindow" name="DungeonSystemDetails_Modal" script="Type Dungeon Creaturescript.lua"/>

 

 

 

 
 

Em actions.xml, adicione:

  Mostrar conteúdo oculto

 



	<!-- Dungeon System -->
	<action actionid="5597" script="Dungeon Actions.lua"/>

 

 

 Em libs.lua, adicione:


dofile('data/lib/Dungeon System Lib.lua')

 

v1.1 (Nova atualização, agora pode spawnar mobs dentro da DG, e ao sair, eles são removidos)

(CREDITOS TOTAIS A MIM: @tataboy67)

Essa é a primeira versão. Ainda pretendo colocar para nascer mobs, remover mobs ao entrar, etc etc...

 

Tu faz sistema 1.2 ? preciso de um sistema faz orçamento ? 

  • 4 weeks later...
  • Respostas 16
  • Visualizações 7.5k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Dungeon System v1.1 A pedido de um usuário em meu Discord, resolvi ajuda-lo e desenvolver um sistema totalmente interativo e de qualidade aqui para vocês. Bom, o sistema se baseia em uma Action

  • Acho que sim. O teste foi feito no 1.3

Posted Images

Postado

Boa tarde!

 

No meu está dando esse erro ao clicar em um item que coloquei no mapa com a action ID 5597 (A que está no actions.xml).

 

image.thumb.png.64b812b3c88e5fdd2ca248ed1f9979e5.png

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo