Jump to content
Sign in to follow this  
deadman

[HOW-TO]Do a Dungeon

Recommended Posts

Well i start this thread for the ppl who dont have knowledge of how to do a dungeon for her servers or for others.

 

I edit this thread constantly adding functions, and others for do a dungeon with a good code and ofc without sysser.

 

I start explaining this now with the start of a dungeon:

quest dungeon_it begin
	state start begin
	
		when 20030.chat."Go to Dungeon" begin
			say("Like start the dungeon "..pc.get_name().."?")
			
			local a = select("Y","N")
			
			if a == 1 then
			
			timer("first_step", 5)
			end
		end
		
		when first_step.timer begin
			d.new_jump_all(33, 999, 999) -- 33 : Index map, 999 : Cordes of go x, y  Now when you code and you have a d.new_jump 
			--you need to put pc.in_dungeon() for example*
			timer("test_dungeon", 4)
		end
                when test_dungeon.timer and pc.in_dungeon() begin
                    d.new_jump(300, 300)
                end
	end
end

I put pc.in_dungeon() bcs if you dont use it the dungeon do sysser ex: "Character Deadman no flag Dungeon! Abort!"

 

Basic functions in dungeon:

 

d.new_jump_all

d.new_jump

d.setf

d.getf

d.regen_file

d.spawn_mob

 

New functions for use with the code on your dungeons:

 

function multiple_spawn_d(vnum, number, array)
 
        for i = 1, number do    --end   (repeatable spawn for the code number)
         
        d.spawn_mob(vnum, array[i][1], array[i][2])
        end
end
local party = party or {}

function party:register_dungeon()
    local player_count,status = d.getf("player_count")
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) == pc.get_vid()) then
            status = -1
        else
            status = true
        end
    end
    if(status == -1) then
        return 0
    else
        player_count = player_count+1
        d.setf("player_count",tonumber(player_count))
        d.setf(string.format("player%d",tonumber(player_count)),pc.get_vid())
    end
end

function party:unregister_dungeon(vid)
    local player_count,status = d.getf("player_count")
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) == vid) then
            d.setf("player_count",d.getf("player_count")-1)
            d.setf(string.format("player%d",tonumber(i)),0)
                        status = true
        else
            status = false
        end
    end
    return status
end

function party:give_item(value,number)
    local player_count,status = d.getf("player_count")
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) != 0) then
            local vid = pc.select_vid(d.getf(string.format("player%d",tonumber(i))))
            if(party.is_party()) then
                pc.give_item2(value,number)
                status = true
            else
                status = false
            end
            pc.select_vid(vid)
        else
            status = false
        end
    end
    return status
end

function party:count_item(value,number)
    local player_count,status = d.getf("player_count")
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) != 0) then
            local vid = pc.select_vid(d.getf(string.format("player%d",tonumber(i))))
            if(pc.count_item(value) < number) then
                status = false
            else
                status = true
            end
            pc.select_vid(vid)
        else
            status = false
        end
    end
    return status
end

function party:count_item1(value,number)
    local player_count,names,status = d.getf("player_count"),{}
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) != 0) then
            local vid = pc.select_vid(d.getf(string.format("player%d",tonumber(i))))
            if(pc.count_item(value) < number) then
                table.insert(names,pc.get_name())
                status = false
            else
                status = true
            end
            pc.select_vid(vid)
        else
            status = false
        end
    end
    return status,names
end



function party:remove_item(value,number)
    local player_count,status = d.getf("player_count")
    for i = 1,player_count,1 do
        if(d.getf(string.format("player%d",tonumber(i))) != 0) then
            local vid = pc.select_vid(d.getf(string.format("player%d",tonumber(i))))
            if(party.count_item(value,number) == false) then
                status = false
            else
                status = true
                pc.remove_item(value,number)
            end
        else
            status = false
        end
    end
    return status
end  

 

 

1.1- How to use d.getf and d.setf in dungeons?¿

 

Well this is for example for know in that floor is the character in the moment x. or for kill x mob in x moment or others

 

For example:


		when raid.timer and pc.in_dungeon() begin
			d.setf("ImInDungeon", 1)
			d.notice("You are in the floor "..d.getf("ImInDungeon").." ")
		end
		
		when 1093.kill with pc.in_dungeon() and d.getf("ImInDungeon") == 1 begin
			notice_all("The character "..pc.get_name().." killed the soul reaper")
		end

1.2- How to spawn mobs in x moment and in x cordinates.

 

For that u have 2 options:

 

d.regen_file() or multiple_spawn_d

 

The regen_file charge a file in data/route and the multple_spawn_d charge the monster you put in the array.

 

Example:

		when raid.timer and pc.in_dungeon() begin
			d.regen_file("data/dungeon/deadman/himetin2dev.txt")
			-- multiple_spawn_d(1093, 3, { {33, 33}, {44, 44}, {55, 55}})
		end

Credits Party functions: HaveBeen

 

Share this post


Link to post

when test_dungeon.timer with pc.in_dungeon() begin

 

And on when's is only used after a with.

 

e.g:

when test_dungeon.timer with pc.in_dungeon() and pc.level >= 100 begin

Share this post


Link to post

i need a help with this dungeon quest i added new map as dungeon but when i compile the quest and run i get this error 
 

Spoiler

dungeon_set_flag: no dungeon !!!

i used this when i start the quest 
 

Quote

        when 20430.chat."Trail Event" with pc.is_gm() begin
            if game.get_event_flag("trail_event") == 0 then
                say_title("trailevent")
                say("Activate trail Event?")
                local s = select ("Yes,with name","Yes,whit Announcement","Cancel")
                    if s == 1 then
                        notice_all(""..announcement.." by "..pc.get_name().."")
                        regen_in_map(map_index, "data/dungeon/trail/"..filename..".txt")
                        game.set_event_flag("trail_event",1)
                        d.setf("trail", 5)
                        server_timer("trail_event",60*5, get_server_timer_arg())
                        ----------------------------------------
                        notice_all("Trail event started .")
                       --timer("trail_event",60*10)    --60*60 = 1 hour (second*minutes*hour*day)
                        --Timer function.Be activation remove " -- "
                        --Default i set 1 hour time interval

I used this quest for running 
 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.