local setting = flame_dungeon . setting ( ) 
if d . getf ( "started" ) == 0 then 
say ( gameforge . flame_dungeon . _230_say ) 
say ( gameforge . flame_dungeon . _240_say ) 
wait ( ) 
d . setf ( "started" , 1 ) 
server_timer ( "flame_dungeon_45m_left_timer" , 15 * 60 , d . get_map_index ( ) ) 
notice_multiline ( gameforge . flame_dungeon . _250_notice , d . notice ) 
notice_multiline ( gameforge . flame_dungeon . _170_notice , d . notice ) 
local pids = { party . get_member_pids ( ) } 
local ticketGroup = { 71095 , 1 , 71130 , 1 } 
for i , pid in next , pids , nil begin 
q . begin_other_pc_block ( pid ) 
local canPass = false 
for idx = 1 , table . getn ( ticketGroup ) , 2 begin 
if pc . count_item ( ticketGroup [ idx ] ) >= ticketGroup [ idx + 1 ] then 
canPass = true 
pc . remove_item ( ticketGroup [ idx ] , ticketGroup [ idx + 1 ] ) 
break 
end 
end 
if not canPass then 
pc . warp ( setting . outside_entry_pos [ 1 ] * 100 , setting . outside_entry_pos [ 2 ] * 100 , 62 ) 
end 
q . end_other_pc_block ( ) 
end 
d . setqf2 ( "flame_dungeon" , "ticket_delete" , 1 ) 
d . setf ( "dungeon_enter" , 1 ) 
party . setf ( "dungeon_index" , d . get_map_index ( ) ) 
d . setf ( "party_leader_pid" , party . get_leader_pid ( ) ) 
end 
if d . getf ( "level" ) < 7 then 
if d . getf ( "clear_count" ) == 6 then 
d . setf ( "level" , 7 ) 
else 
local rand = number ( 1 , 6 ) 
local setlev = 0 
d . setf ( "level" , 7 ) 
for i = 1 , 50 begin 
setlev = setlev + 1 
if setlev > 6 then 
setlev = 1 
end 
if not d . is_unique_dead ( "door" .. setlev ) then 
rand = rand - 1 
if rand == 0 then 
d . setf ( "level" , setlev ) 
d . setf ( "clear_count" , d . getf ( "clear_count" ) + 1 ) 
break 
end 
end 
end 
end 
end 
if d . getf ( "level" ) == 1 then 
say ( gameforge . flame_dungeon . _260_say ) 
notice_multiline ( gameforge . flame_dungeon . _260_say , d . notice ) 
d . kill_unique ( "door1" ) 
d . kill_unique ( "idoor1" ) 
d . setf ( "level" , 11 ) 
d . regen_file ( "data/dungeon/flame_dungeon/" .. "fd_a.txt" ) 
server_timer ( "killed_A_1" , 12 , d . get_map_index ( ) ) 
elseif d . getf ( "level" ) == 11 then 
say ( gameforge . flame_dungeon . _270_say ) 
say_title ( gameforge . flame_dungeon . _280_sayTitle .. d . count_monster ( ) ) 
elseif d . getf ( "level" ) == 2 then 
say ( gameforge . flame_dungeon . _290_say ) 
say ( gameforge . flame_dungeon . _300_say ) 
notice_multiline ( gameforge . flame_dungeon . _290_say , d . notice ) 
notice_multiline ( gameforge . flame_dungeon . _300_say , d . notice ) 
d . spawn_mob ( 20386 , setting . LEVEL2_STONE_pos [ 1 ] , setting . LEVEL2_STONE_pos [ 2 ] ) 
d . kill_unique ( "door2" ) 
d . kill_unique ( "idoor2" ) 
d . set_regen_file ( "data/dungeon/flame_dungeon/" .. "fd_b.txt" ) 
d . setf ( "level" , 12 ) 
elseif d . getf ( "level" ) == 12 then 
say ( gameforge . flame_dungeon . _310_say ) 
elseif d . getf ( "level" ) == 3 then 
say ( gameforge . flame_dungeon . _260_say ) 
notice_multiline ( gameforge . flame_dungeon . _260_say , d . notice ) 
d . kill_unique ( "door3" ) 
d . kill_unique ( "idoor3" ) 
d . setf ( "level" , 13 ) 
d . regen_file ( "data/dungeon/flame_dungeon/" .. "fd_c.txt" ) 
server_timer ( "killed_A_1" , 12 , d . get_map_index ( ) ) 
elseif d . getf ( "level" ) == 13 then 
say ( gameforge . flame_dungeon . _270_say ) 
say_title ( gameforge . flame_dungeon . _280_sayTitle .. d . count_monster ( ) ) 
elseif d . getf ( "level" ) == 4 then 
say ( gameforge . flame_dungeon . _320_notice ) 
notice_multiline ( gameforge . flame_dungeon . _320_notice , d . notice ) 
d . setf ( "level" , 14 ) 
d . kill_unique ( "door4" ) 
d . kill_unique ( "idoor4" ) 
d . set_regen_file ( "data/dungeon/flame_dungeon/" .. "fd_d.txt" ) 
d . spawn_mob ( 6051 , setting . LEVEL4_TARGET_pos [ 1 ] , setting . LEVEL4_TARGET_pos [ 2 ] ) 
elseif d . getf ( "level" ) == 14 then 
say ( gameforge . flame_dungeon . _330_say ) 
say ( gameforge . flame_dungeon . _340_say ) 
elseif d . getf ( "level" ) == 5 then 
say ( gameforge . flame_dungeon . _350_say ) 
say ( gameforge . flame_dungeon . _360_say ) 
notice_multiline ( gameforge . flame_dungeon . _350_say , d . notice ) 
notice_multiline ( gameforge . flame_dungeon . _360_say , d . notice ) 
d . kill_unique ( "door5" ) 
d . kill_unique ( "idoor5" ) 
d . setf ( "level" , 15 ) 
d . set_regen_file ( "data/dungeon/flame_dungeon/" .. "fd_e.txt" ) 
local vis = { 0 , 0 , 0 , 0 , 0 , 0 , 0 } 
for i = 1 , 7 begin 
vis [ i ] = 0 
end 
for i = 1 , 7 begin 
local ran = number ( 1 , 7 ) 
local st = 0 
for j = 1 , 50 begin 
st = st + 1 
if st > 7 then 
st = 1 
end 
if vis [ st ] == 0 then 
ran = ran - 1 
if ran == 0 then 
vis [ st ] = 1 
d . set_unique ( "stone5_" .. st , d . spawn_mob ( 20386 , setting . LEVEL5_STONE_pos [ i ] [ 1 ] , setting . LEVEL5_STONE_pos [ i ] [ 2 ] ) ) 
break 
end 
end 
end 
end 
elseif d . getf ( "level" ) == 15 then 
say ( gameforge . flame_dungeon . _370_say ) 
elseif d . getf ( "level" ) == 6 then 
say ( gameforge . flame_dungeon . _380_say ) 
notice_multiline ( gameforge . flame_dungeon . _380_say , d . notice ) 
d . setf ( "level" , 16 ) 
d . kill_unique ( "door6" ) 
d . kill_unique ( "idoor6" ) 
d . set_regen_file ( "data/dungeon/flame_dungeon/" .. "fd_f.txt" ) 
d . spawn_mob ( 8057 , setting . LEVEL6_TARGET_pos [ 1 ] , setting . LEVEL6_TARGET_pos [ 2 ] ) 
elseif d . getf ( "level" ) == 16 then 
say ( gameforge . flame_dungeon . _390_say ) 
say ( gameforge . flame_dungeon . _400_say ) 
elseif d . getf ( "level" ) == 7 then 
flame_dungeon . go_boss ( ) 
else 
say ( gameforge . flame_dungeon . _410_say ) 
end 
npc . unlock ( ) 
