Advertisement
johnlol

dg_quest_sys

May 10th, 2019
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 121.19 KB | None | 0 0
  1. //===== rAthena Script =======================================
  2. //= Dungeon Quest Service
  3. //===== Author ===============================================
  4. //= llchrisll
  5. //===== Credits ==============================================
  6. //= rAthena Dev Team for the Warper NPC, used the Dungeon Cooardinates
  7. //===== Changelog ============================================
  8. //= 1.0 - Initial Version
  9. //===== Tested With =========================================
  10. //= rAthena SQL 07/16-2017 Revision
  11. //===== Description ==========================================
  12. //= Additional EXP Bonus (in Percent) based on Dungeon's Difficulty
  13. //  - Difficulties: Easy, Medium, Hard
  14. //= Dungeon Warp Service
  15. //  - Floors selectable
  16. //= Party Settings dynamically changeable
  17. //  - Maximum Quantity of Parties in each Dungeon
  18. //= Dungeon Rewards:
  19. //  - Dungeon Points (On/Off Function)
  20. //    Base Points*Difficulty of Dungeon
  21. //    Custom Permanent Character Variable for Shop (changeable, see .dg_var$)
  22. //  - MvP Points (On/Off Function)
  23. //    Per slain MvP, you gain "x" Points (changeable)
  24. //    Custom Permanent Character Variable for Shop (changeable, see .mvp_var$)
  25. //  - Dungeon Points Shop
  26. //  - MvP Points Shop
  27. //= Quests per Dungeons
  28. //  - Each Dungeon can have an infinite amount of quests
  29. //  - Monster Hunting or Item Collecting
  30. //  - Rewards: Zeny, Points or Items
  31. //  - EXP Reward: Either % or Flat Amount
  32. //===== Comments =============================================
  33. //= ...
  34. //===== ToDO =============================================
  35. //= Add 5 mob Quests and 5 item quests
  36. //  - Difficulty: rewards
  37. //  > normal : Zeny
  38. //  > normal: points
  39. //  > normal : item + exp
  40. //  > hard: item + exp%
  41. //  > hard: points + exp%
  42. ///============================================================
  43. prontera,151,185,4  script  Dungeon Quest Service   110,{
  44. function F_GetMobData;
  45. function F_Pages;
  46.  
  47. mes .n$;
  48. mes "Hello, "+strcharinfo(0)+"!";
  49. mes "How can I help you?";
  50. if(getgroupid() >= .gm)
  51.     menu "- Player Menu",-,"- Control Center",OnGMAccess;
  52. next;
  53. switch(select("- Dungeon Menu:- Information:- Points Shop:- Nothing")) {
  54.  
  55.     case 1:
  56.     mes .n$;
  57.     if(!$@DQS_Sys) {
  58.         mes "I'm sorry, but my Dungeon Quest Service is currently offline.";
  59.         close;
  60.     }
  61.     mes "Please choose what you want to do below:";
  62.     mes "Note: \"Get Pending Reward\" is available only when you didn't have enough space/weight for the item reward when completing an quest.";
  63.     next;
  64.     switch(select("- Register/Dissolve:- Quest Board:- Warp Service:- Get Pending Reward:- Complete Dungeon")) {
  65.    
  66.         // ============ Register for Dungeon ============ //
  67.         case 1:
  68.         if(query_sql("SELECT `dg_id` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",.@dg_id) != 0) {
  69.             mes .n$;
  70.             mes "Do you really want to dissolve your registration?";
  71.             if(select("- Yes:- No") - 1) close;
  72.             next;
  73.             mes .n$;
  74.             mes "See you again.";
  75.             query_sql "DELETE FROM `dqs_party` WHERE `"+( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'";
  76.             close;
  77.         }
  78.         if(getcharid(1) == 0) {
  79.             mes .n$;
  80.             mes "You are currently not in a Party, do you want to enter an dungeon alone?";
  81.             next;
  82.             if(select("- No:- Yes") == 1) {
  83.                 mes .n$;
  84.                 mes "Then see you again as soon as you joined a party.";
  85.                 close;
  86.             }
  87.             next;
  88.         } else {
  89.             if(strcharinfo(0) != getpartyleader(getcharid(1))) {
  90.                 mes .n$;
  91.                 mes "Only the party leader can register your party for an Dungeon";
  92.                 close;
  93.             }
  94.             getpartymember(getcharid(1),2);
  95.             for ( set .@p,0; .@p < $@partymembercount; set .@p,.@p + 1)
  96.                 if(isloggedin($@partymemberaid[.@p]) == 1)  // Member logged in?
  97.                     set .@ct,.@ct + 1;
  98.                    
  99.             if(.@ct < 2) {
  100.                 mes .n$;
  101.                 mes "A party requires minimum 2 members online to use the Dungeon Quest Service.";
  102.                 close;
  103.             }
  104.         }
  105.         mes .n$;
  106.         // =============== Creating Dungeon Menu ===============
  107.         query_sql "SELECT DISTINCT `dg_id` , `name` , `repeat` FROM `dqs_dungeon` WHERE `map_name` != ''",.@dg_id,.@name$,.@rep;
  108.         if(getarraysize(.@dg_id) < 1) {
  109.             mes "I'm sorry, but there are no Dungeon yet, please come later.";
  110.             close;
  111.         }
  112.         for ( set .@du,0; .@du < getarraysize(.@dg_id); set .@du,.@du + 1) {
  113.             query_sql "SELECT `req_level` , `pty_limit` , `status` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@du]+"'",.@req_lvl,.@pty_limit,.@status;
  114.             query_sql "SELECT count( `pty_id` ) FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id[.@du]+"'",.@pty_ct;
  115.             setarray .@pt_count[.@du],.@pty_ct;
  116.             set .@men_dun$,.@men_dun$ + "- "+.@name$[.@du] + " ("+( (.@status == 2)?.@pty_ct+"/"+.@pty_limit:"Service is disabled")+") ("+.@req_lvl+")" + ( (.@name$[@du+1] != "")?":":"");
  117.         }
  118.         mes "Now please choose the dungeon your party wants to go:";
  119.         mes "Dungeon (Parties) (Min. Level)";
  120.         set @d,select( .@men_dun$ ) - 1;
  121.         next;
  122.         mes .n$;
  123.         query_sql "SELECT `difficulty` , `floor` , `map_name` , `req_level` , `status` , `renewal` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[@d]+"'",.@diff,.@floors,.@map$,.@fl_lvl,.@fl_stat,.@fl_re;
  124.         mes "Dungeon: "+.@name$[@d];
  125.         if(getarraysize(.@floors) < 1) {
  126.             mes "This dungeon is currently not available, because it's missing Map Data.";
  127.             close;
  128.         }
  129.         for ( set .@f,0; .@f < getarraysize(.@floors); set .@f,.@f + 1) {
  130.             mes "[ === Floor #"+(.@f+1)+" ====]";
  131.             mes "Map Name: "+.@map$[.@f];
  132.             mes "Difficulty: "+ ( (.@diff[.@f] == 1)?"Easy": ( (@diff[.@f] == 2)?"Medium":"Hard") );
  133.             mes "Minimum Level: "+.@fl_lvl[.@f];
  134.             if(.@fl_stat[.@f] == 1) mes "Status: Service is disabled here.";
  135.             mes "Server Type: "+( (.@fl_re[.@f] == 1)?"All":( (.@fl_re[.@f] == 2)?"Pre-Renewal":"Renewal") );
  136.             set .@fl_menu$,.@fl_menu$ + "- Floor "+(.@f+1)+" ("+( (.@fl_stat[.@f] == 1)?"Disabled":"Enabled")+") ("+.@fl_lvl[.@f]+")" + ( (.@floors[.@f+1] != 0)?":":"");
  137.         }
  138.         mes "===========";
  139.         mes " ";
  140.         mes "Existing Parties: "+.@pt_count[@d];
  141.         mes "Repeat Limit: "+.@rep[@d];
  142.    
  143.         // Reseting Repeat Limit in case the Timer has been reached
  144.         if(getd("DG_"+.@dg_id[@d]+"_RepeatTimer") <= gettimetick(2))
  145.             setd("DG_"+.@dg_id[@d]+"_RepeatTimer"),0;
  146.        
  147.         if(.dg_floor == 1) { // Floor Selection enabled
  148.             next;
  149.             mes .n$;
  150.             mes "Please select the Floor which you want to enter the Dungeon:";
  151.             mes "- Floor (Service) (Min. Level)";
  152.             set .@fl,select(.@fl_menu$) - 1;
  153.             if(.@status[.@fl] == 1) {
  154.                 next;
  155.                 mes .n$;
  156.                 mes "Status: Service is disabled here.";
  157.                 mes "Please choose a different floor.";
  158.                 close;
  159.             }
  160.             if(.@renewal[.@fl] == 2 && checkre(0)) {
  161.                 next;
  162.                 mes .n$;
  163.                 mes "I'm sorry, but I can't grant you access to this level of the dungeon, because it is not accessable on an Renewal Server.";
  164.                 close;
  165.             } else if(.@renewal[.@fl] == 3 && !checkre(0)) {
  166.                 next;
  167.                 mes .n$;
  168.                 mes "I'm sorry, but I can't grant you access to this level of the dungeon, because it is not accessable on an Pre-Renewal Server.";
  169.                 close;
  170.             }
  171.         } else
  172.             set .@fl,0;
  173.  
  174.         next;
  175.         mes .n$;
  176.         if(.@pt_count[@d] >= .@pty_limit[@d]) {
  177.             mes "I'm sorry, but this dungeon already reached the maximum of parties it can hold.";
  178.             mes "Please choose a different one.";
  179.             close;
  180.         }
  181.        
  182.         // Solo Entry
  183.         if( (getcharid(1) == 0 && BaseLevel < .@req_lvl[.@fl]) || (getd("DG_"+.@dg_id[@d]+"_RepeatTimer") >= gettimetick(2) ) ) {
  184.             mes "I'm sorry, but you either didn't reach the required level or reached the repeat limit for this dungeon.";
  185.             mes "Please choose either a different floor, try to level up first or wait until the repeat cooldown is over.";
  186.             mes "The minimum level for this floor is "+.@req_lvl[.@fl]+"!";
  187.             close;
  188.        
  189.         // Party Entry
  190.         } else if(getcharid(1) != 0) {
  191.             mes "I will now check the levels of your party members. Please wait....";
  192.             next;
  193.             addrid(2,1,getcharid(1));
  194.             if(readparam(BaseLevel) < .@req_lvl[.@fl] || getd("DG_"+.@dg_id[@d]+"_RepeatTimer") >= gettimetick(2))
  195.                 set .@l_ct,.@l_ct + 1;
  196.  
  197.             // Reseting Repeat Limit in case the Timer has been reached
  198.             if(getd("DG_"+.@dg_id[@d]+"_RepeatTimer") <= gettimetick(2))
  199.                 setd("DG_"+.@dg_id[@d]+"_RepeatTimer"),0;
  200.                
  201.             if(getpartyleader(getcharid(1)) != strcharinfo(0)) // Not Party Leader? End!
  202.                 end;
  203.  
  204.             mes .n$;
  205.             if(.@l_ct > 0) {
  206.                 mes "It seems like "+.@l_ct+" of your members either haven't reached the required level or reached the repeat limit for this dungeon.";
  207.                 mes "Please choose either a different floor or try to level up your members.";
  208.                 mes "The minimum level for this floor is "+.@req_lvl[.@fl]+"!";
  209.                 close;
  210.             }
  211.         }
  212.         mes "Well done, you have passed all checks.";
  213.         mes "You"+ ( (getcharid(1) != 0)?"r party":"")+" will recieve an bonus of "+.exp[.@diff[.@fl]]+"%.";
  214.         mes "But before you can enter an dungeon, you can accept more quests first, therefore talk to me again and choose \"Quest Board\".";
  215.         // Inserting Data in the Database `dqs_party`
  216.         query_sql "INSERT INTO `dqs_party` ( `dg_id` , `"+ ( (getcharid(1) == 0)?"char_id":"pty_id")+"` , `quest_id` , `start` , `map` ) VALUES ( '"+.@dg_id[@d]+"' , '"+ ( (getcharid(1) == 0)?getcharid(0):getcharid(1))+"' , '1' , '"+.@floors[.@fl]+"' , '"+.@map$[.@fl]+"' )";
  217.         break;
  218.  
  219.         // ============ Quest Board ============ //
  220.         case 2:
  221.         mes .n$;
  222.         if(getcharid(1) != 0 && strcharinfo(0) != getpartyleader(getcharid(1))) {
  223.             mes "Only the party leader can accept additional quests for the party from the Dungeon!!!";
  224.             close;
  225.         }
  226.         // Check if player/party is registered for dungeon
  227.         if(query_sql("SELECT `dg_id` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `quest_id` = '1'",.@dg_id) == 0) {
  228.             mes "I'm sorry, but you didn't register"+ ( (getcharid(1) != 0)?" your party":"")+" for an dungeon yet.";
  229.             mes "Come back, when you have done that first.";
  230.             close;
  231.         }
  232.         mes "[= Dungeon Quest =]";
  233.         query_sql "SELECT `difficulty` , `mob_clear` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id+"'",.@diff,.@q_mam;
  234.         mes "Requirement: Complete the dungeon by talking to an Floor Exit NPC and kill "+.@q_mam+" Monsters.";
  235.         mes "Reward: Minimum "+.dg_pts*.@diff+"x Dungeon Points";
  236.         mes "The Reward will be further increased, if you exit it after you've gone as deep as possible.";
  237.         next;
  238.         query_sql "SELECT DISTINCT `quest_id` , `quest_name` , `quest_type` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"'",.@q_id,.@q_n$,.@q_type;
  239.         if(getarraysize(.@q_id) < 1) {
  240.             mes .n$;
  241.             mes "I'm sorry, but I currently don't have any additional quests for you.";
  242.             mes "But if you are allowed to enter the dungeon until additional quests are available.";
  243.             close;
  244.         }
  245.         for ( set .@q,0; .@q < getarraysize(.@q_id); set .@q,.@q + 1) {
  246.             if(query_sql("SELECT `quest_id` FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q]+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' LIMIT 1",.@que_id) == 0)
  247.                 setarray .@st[.@q],1;
  248.             else
  249.                 setarray .@st[.@q],2;
  250.                
  251.             setarray .@q_pages$[.@q],"- "+( (.@st[.@q] == 1)?"^0000FF":"^FF0000") + .@q_n$[.@q]+"^000000 ("+ ( (.@q_type[.@q] == 1)?"Monster Hunting":"Item Collecting")+")";
  252.         }
  253.         set .@q_c,F_Pages(implode(.@q_pages$,":"),.pg_entries);
  254.    
  255.         mes .n$;
  256.         mes "[= "+.@q_n$[.@q_c]+" =]";
  257.         mes "Type: "+( (.@q_type[.@q_c] == 1)?"Monster Hunting":"Item Collecting");
  258.         // Quest Details
  259.         if(.@q_type[.@q_c] == 1)
  260.             query_sql "SELECT `mob_id` , `mob_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2,.@rew_id,.@rew_am,.@exp_type,.@rew_bexp,.@rew_jexp;
  261.         else
  262.             query_sql "SELECT `item_id` , `item_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2,.@rew_id,.@rew_am,.@exp_type,.@rew_bexp,.@rew_jexp;
  263.         for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  264.             mes "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@q_c] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) );
  265.         mes "Reward:";
  266.         mes .@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?getd(""+.rew_vard$):getitemname(.@rew_id)));
  267.         if(.@exp_type != 0) {
  268.             mes "EXP Reward:";
  269.             mes "Base EXP: "+.@rew_bexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  270.             mes "Job EXP: "+.@rew_jexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  271.         }
  272.         mes " ";
  273.         mes "What do you like to do now?";
  274.         next;
  275.         if(.@st[.@q_c] == 1) {
  276.             select("- Accept:- Nevermind");
  277.             if(@menu == 2) set .@s,4; else set .@s,@menu;
  278.         } else
  279.             set .@s,select("- Abort:- Progress:- Nevermind") + 1;
  280.  
  281.         switch(.@s) {
  282.            
  283.             // Accept Quest
  284.             case 1:
  285.             mes .n$;
  286.             mes "You have accepted the quest.";
  287.             query_sql "INSERT INTO `dqs_party` ( `dg_id` , `"+ ( (getcharid(1) == 0)?"char_id":"pty_id")+"` , `quest_id` ) VALUES ( '"+.@dg_id+"' , '"+ ( (getcharid(1) == 0)?getcharid(0):getcharid(1))+"' , '"+.@q_id[.@q_c]+"' )";
  288.             if(.@q_type[.@q_c] == 1) // Monster Hunting
  289.                 for ( set .@a,0; .@a < getarraysize(.@req1); set .@a,.@a + 1) {
  290.                     query_sql "UPDATE `dqs_party` SET `mob_id` = '"+.@req1[.@a]+"' , `req_am` = '"+.@req2[.@a]+"' WHERE `dg_id` = '"+.@dg_id+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'";
  291.                     setarray @dqs_mob[.@a],.@req1[.@a];
  292.                     setarray @dqs_req[.@a],.@req2[.@a];
  293.                 }
  294.             end;
  295.            
  296.             // Abort Quest
  297.             case 2:
  298.             mes .n$;
  299.             mes "Do you really want to abort the quest?";
  300.             if(select("- Yes:- No") - 1) close;
  301.             next;
  302.             mes .n$;
  303.             mes "Quest has been aborted.";
  304.             query_sql "DELETE FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'";
  305.            
  306.             if(getcharid(1) != 0)
  307.                 addrid(2,1,getcharid(1));
  308.                
  309.             if(.@q_type[.@q_c] == 1) { // Monster Hunting
  310.                 deletearray @dqs_mob[0],getarraysize(@dqs_mob);
  311.                 deletearray @dqs_am[0],getarraysize(@dqs_am);
  312.                 deletearray @dqs_req[0],getarraysize(@dqs_req);
  313.             }
  314.             end;
  315.            
  316.             // Check Progress
  317.             case 3:
  318.             mes .n$;
  319.             mes "Let's see, if you have completed the target....";
  320.             if(.@q_type[.@q_c] == 1)
  321.                 query_sql "SELECT `mob_id` , `mob_am` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2;
  322.             else
  323.                 query_sql "SELECT `item_id` , `item_am` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"'",.@req1,.@req2;
  324.            
  325.             for ( set .@p,0; .@p < getarraysize(.@req1); set .@p,.@p + 1) {
  326.                 if(.@q_type[.@q_c] == 1) {
  327.                     // Selecting the latest value in the database
  328.                     query_sql "SELECT `mob_am` FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `mob_id` = '"+.@req1[.@p]+"'",.@am;
  329.                     if(.@am < .@req2[.@p])
  330.                         set .@f,.@f + 1;
  331.  
  332.                 } else if(.@q_type[.@q_c] == 2)
  333.                     set .@am,countitem(.@req1[.@p]);
  334.                        
  335.                 mes "- "+ ( (.@q_type[.@q_c] == 1)?strmobinfo(1,.@req1[.@p]):getitemname(.@req1[.@p]) )+": "+.@am+"/"+.@req2[.@p];
  336.             }
  337.             mes " ";
  338.             if(.@f) {
  339.                 mes "You didn't finish "+.@f+" target"+( (.@f == 1)?"":"s")+". Please come back, when you have finished those.";
  340.                 close;
  341.             }
  342.            
  343.             next;
  344.             // Clearing the Mob Arrays
  345.             if(.@q_type[.@q_c] == 1) {
  346.                 deletearray @dqs_mob[0],getarraysize(@dqs_mob);
  347.                 deletearray @dqs_am[0],getarraysize(@dqs_am);
  348.                 deletearray @dqs_req[0],getarraysize(@dqs_req);
  349.            
  350.             // Removing quest items from inventory
  351.             } else if(.@q_type[.@q_c] == 2)
  352.                 for ( set .@r,0; .@r < getarraysize(.@req1); set .@r,.@r + 1)
  353.                     delitem .@req1[.@r],.@req2[.@r];
  354.            
  355.             if(getpartyleader(getcharid(1)) != strcharinfo(0))
  356.                 end;
  357.            
  358.             mes .n$;
  359.             break;
  360.            
  361.             // Nevermind
  362.             case 4:
  363.             end;           
  364.         }
  365.         mes "You have completed the quest, here is your reward!!";
  366.         query_sql "DELETE FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q_c]+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'";
  367.        
  368.         set .q_id,.@q_id[.@q_c];
  369.         set .dg_id,.@dg_id;
  370.         if(getcharid(1) != 0)
  371.             addrid(2,1,getcharid(1));
  372.            
  373.         query_sql "SELECT `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.dg_id+"' AND `quest_id` = '"+.q_id+"'",.@rew_id,.@rew_am,.@exp_type,.@rew_bexp,.@rew_jexp;
  374.        
  375.         switch(.@rew_id) {
  376.             case 1: set Zeny,Zeny + .@rew_am; break;
  377.             case 2: setd(""+.rew_varn$),getd(""+.rew_varn$) + .@rew_am; break;
  378.             default:
  379.             if(checkweight(.@rew_id,.@rew_am) == 1)
  380.                 getitem .@rew_id,.@rew_am;
  381.             else {
  382.                 mes "It seems like you can't carry more items, than you already do. You have to remove some weight before you can recieve your reward.";
  383.                 mes "Please come back to me, when you have done that and choose \"Get Pending Reward\".";
  384.                 query_sql "INSERT INTO `dqs_pending` ( `char_id` , `item_id` , `item_am` ) VALUES ( '"+getcharid(0)+"' , '"+.@rew_id+"' , '"+.@rew_am+"' )";
  385.             }
  386.             break;
  387.         }
  388.         dispbottom "You have recieved "+.@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?getd(""+.rew_vard$):getitemname(.@rew_id)));         
  389.         switch(.@exp_type) {
  390.             case 0: break;
  391.             case 1:
  392.             getexp2 .@rew_bexp,.@rew_jexp;
  393.             dispbottom "You have recieved "+.@rew_bexp+" Base EXP and "+.@rew_jexp+" Job EXP.";
  394.             break;
  395.            
  396.             case 2:
  397.             set .@bexp_perc,(BaseExp + NextBaseExp)*.@rew_bexp/100;
  398.             set .@jexp_perc,(JobExp + NextJobExp)*.@rew_jexp/100;
  399.             getexp2 .@bexp_perc,.@jexp_perc;
  400.             dispbottom "You have recieved "+.@bexp_perc+"% Base EXP ("+.@bexp_perc+") and "+.@rew_jexp+"% Job EXP ("+.@jexp_perc+").";
  401.             break;
  402.         }
  403.         break;
  404.  
  405.         // ============ Warp Service ============ //
  406.         case 3:
  407.         mes .n$;
  408.         // Check if player/party is registered for dungeon
  409.         if(query_sql("SELECT `dg_id` , `start` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `quest_id` = '1'",.@dg_id,.@floor) == 0) {
  410.             mes "I'm sorry, but you didn't register"+ ( (getcharid(1) != 0)?" your party":"")+" for an dungeon yet.";
  411.             mes "Come back, when you have done that first.";
  412.             close;
  413.         }
  414.         query_sql "SELECT `quest_id` FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `quest_id` != '1'",.@q_id;
  415.         if(getarraysize(.@q_id) > 0) {
  416.             mes "I will now list you all accepted quests:";
  417.             mes " ";
  418.             for ( set .@q,0; .@q < getarraysize(.@q_id); set .@q,.@q + 1) {
  419.                 query_sql "SELECT DISTINCT `quest_name` , `quest_type` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q]+"'",.@q_n$,.@q_type;
  420.                 // Quest Details
  421.                 mes "[= "+.@q_n$+" =]";
  422.                 mes "Type: "+( (.@q_type == 1)?"Monster Hunting":"Item Collecting");
  423.                 if(.@q_type == 1)
  424.                     query_sql "SELECT `mob_id` , `mob_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q]+"'",.@req1,.@req2,.@rew_id,.@rew_am,.@exp_type,.@rew_bexp,.@rew_jexp;
  425.                 else
  426.                     query_sql "SELECT `item_id` , `item_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@q]+"'",.@req1,.@req2,.@rew_id,.@rew_am,.@exp_type,.@rew_bexp,.@rew_jexp;
  427.                 for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  428.                     mes "- "+.@req2[.@l]+"x "+ ( (.@q_type == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) );
  429.                 mes "Reward:";
  430.                 mes .@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?getd(""+.rew_vard$):getitemname(.@rew_id)));
  431.                 if(.@exp_type != 0) {
  432.                     mes "EXP Reward:";
  433.                     mes "Base EXP: "+.@rew_bexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  434.                     mes "Job EXP: "+.@rew_jexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  435.                 }
  436.             }
  437.             mes "===============";
  438.         }
  439.         query_sql "SELECT `name` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id+"' AND `floor` = '"+.@floor+"'",.@name$;
  440.         mes "I will warp you now to the "+.@name$+ ( (compare(.@name$,"Dungeon") == 1)?".":" Dungeon.");
  441.         close2;
  442.         query_sql "SELECT `map_name` , `map_x` , `map_y` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id+"' AND `floor` = '"+.@floor+"'",.@map$,.@map_x,.@map_y;
  443.         warp .@map$+".gat",.@map_x,.@map_y;
  444.         break;
  445.        
  446.         // ============ Get Pending Reward ============ //
  447.         case 4:
  448.         mes .n$;
  449.         if(query_sql("SELECT `item_id` , `item_am` FROM `dqs_pending` WHERE `char_id` = '"+getcharid(0)+"'",.@i_id,.@i_am) == 0) {
  450.             mes "You don't have any pending rewards.";
  451.             close;
  452.         }
  453.         for ( set .@i,0; .@i < getarraysize(.@i_id); set .@i,.@i + 1)
  454.             if(checkweight(.@i_id[.@i],.@i_am[.@i]) == 1) {
  455.                 getitem .@i_id,.@i_am;         
  456.                 mes "You have recieved "+.@i_am[.@i]+"x "+getitemname(.@i_id[.@i]);        
  457.             } else {
  458.                 mes "You don't have any space for the reward, come back later when you have more space available.";
  459.                 close;
  460.             }
  461.         query_sql "DELETE FROM `dqs_pending` WHERE `char_id` = '"+getcharid(0)+"'";
  462.         break;
  463.        
  464.         // ============ Complete Dungeon ============ //
  465.         case 5:
  466.         // Check if player/party is registered for dungeon
  467.         if(query_sql("SELECT `dg_id` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `quest_id` = '1'",.dg_id) == -1) {
  468.             mes .n$;
  469.             mes "I'm sorry, but you didn't register"+ ( (getcharid(1) != 0)?" your party":"")+" for an dungeon yet.";
  470.             mes "Come back, when you have done that and actually completed it first.";
  471.             close;
  472.         }
  473.         // Check if the player is the party leader
  474.         if(getcharid(1) != 0 && strcharinfo(0) != getpartyleader(getcharid(1))) {
  475.             mes .n$;
  476.             mes "Only the party leader can finalize the completion of the Dungeon!!!";
  477.             close;
  478.         }
  479.         // Checking if there are still uncompleted quests
  480.         if(query_sql("SELECT `quest_id` FROM `dqs_party` WHERE `dg_id` = '"+.dg_id+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",.@q_id) > 1) {
  481.             mes .n$;
  482.             mes "You"+ ( (getcharid(1) != 0)?"r party":"")+" still have quests to complete.";
  483.             close;
  484.         }
  485.         // Checking if dungeon was completed
  486.         if(query_sql("SELECT `complete` FROM `dqs_party` WHERE `dg_id` = '"+.dg_id+"' AND `quest_id` = '1' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",.done) < 1) {
  487.             mes .n$;
  488.             mes "You"+ ( (getcharid(1) != 0)?"r party":"")+" didn't complete the dungeon yet.";
  489.             mes "Please come back, when it's done.";
  490.             close;
  491.         }
  492.         query_sql "DELETE FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'";
  493.         if(getcharid(1) != 0)
  494.             addrid(2,1,getcharid(1));
  495.        
  496.         query_sql "SELECT `name` , `difficulty` , `repeat` FROM `dqs_dungeon` WHERE `dg_id` = '"+.dg_id+"'",.@dg_name$,.@diff,.@repeat;
  497.        
  498.         if(.dg_pts > 0) {
  499.             dispbottom .n$+": For completing the "+( (compare(.@dg_name$,"Dungeon") == 1)?" ":" Dungeon ")+", you will recieve "+.dg_pts*(.diff+.done)+"x Dungeon Points.";
  500.             setd(""+.dg_var$),getd(""+.dg_var$) + .dg_pts*(.diff+.done);
  501.         }
  502.         setd("DG_"+.@dg_id+"_RepeatCT"),getd("DG_"+.@dg_id+"_RepeatCT") + 1;
  503.         // Increasing Repeat Counter, and in case the Limit has been reached > Apply Timer
  504.         if(getd("DG_"+.@dg_id+"_RepeatCT") >= .@repeat) {
  505.             setd("DG_"+.@dg_id+"_RepeatTimer"),.dg_delay*.diff;
  506.             setd("DG_"+.@dg_id+"_RepeatCT"),0;
  507.         }  
  508.         end;
  509.     }
  510.     break;
  511.    
  512.     // Information
  513.     case 2:
  514.     mes .n$;
  515.     mes "So you want some information about the Dungeon Quest Service, huh?!";
  516.     mes "Good, then I will start with the main steps first:";
  517.     next;
  518.     mes "[ === Register === ]";
  519.     mes "To use the Dungeon Quest Service, you can enter either alone or as a party with a minimum of 2 online members.";
  520.     mes "After you have chosen the dungeon you want to enter, you can accept, if available, additional quests to earn extra rewards.";
  521.     mes "To do so, just choose \"Quest Board\" in the \"Dungeon Menu\".";
  522.     next;
  523.     mes "[==== Quests ====]";
  524.     mes "There are 2 types of quests you can accept:";
  525.     mes "- Monster Hunting";
  526.     mes "- Item Collecting";
  527.     mes " ";
  528.     mes "[ === Quest Rewards ===]";
  529.     mes "- Zeny";
  530.     mes "- Custom Points";
  531.     mes "- Items; Either specific or pre-defined: "+getitemname(.rew_itemid);
  532.     mes " ";
  533.     mes "[== Custom @Command ==]";
  534.     mes "To help you, to check your quest progress anytime and anywhere, there is an custom @command: \"@checkdg\".";
  535.     next;
  536.     mes "[== Warp Service ==]";
  537.     mes "I also offer you an Warp Service to the Dungeon Entrances by choosing \"Warp Service\".";
  538.     next;
  539.     mes "[ === Dungeons === ]";
  540.     mes "Each Dungeon has it's own Difficulty, Level Requirement and Repeat Limit.";
  541.     mes "After every completion the Repeat Limit for that Dungeon will increase and when it has been reached and Repeat Delay becomes active.";
  542.     mes "This Repeat Delay is only affecting you, not the dungeon.";
  543.     next;
  544.     mes "[ === Difficulty & EXP Bonus ===]";
  545.     mes "I will now list the EXP Bonus of the various Difficulties:";
  546.     mes "Easy: "+.exp[1]+"%";
  547.     mes "Medium: "+.exp[2]+"%";
  548.     mes "Hard: "+.exp[3]+"%";
  549.     next;
  550.     if(.dg_pts > 0) {
  551.         mes "[ === Dungeon Rewards === ]";
  552.         mes "Completing an Dungeon also rewards you with special \"Dungeon Points\", which you can buy items with.";
  553.         mes "Choose \"Points Shop\" in the first menu for that.";
  554.         mes "The base points you can gain for each Dungeon is "+.dg_pts+" and will be multiplied by the Dungeons Difficulty, which will can be further increased as deeper as you exit the dungeon from:";
  555.         mes "\"1\" for Easy, by \"2\" for Medium, by \"3\" for Hard.";
  556.         mes "Also to exit an Dungeon you need to kill certain amount of monsters first. This is to prevent gathering of \"Dungeon Points\" the easy way.";
  557.         next;
  558.     }
  559.     if(.mvp_pts > 0) {
  560.         mes "[ === MvP Rewards === ]";
  561.         mes "Killing MvP's rewards you with special \"MvP Points\", which you can buy items with.";
  562.         mes "Choose \"Points Shop\" in the first menu for that.";
  563.         mes "The base points you can gain for each slain MvP is "+.mvp_pts+" and will be multiplied by the Dungeons Difficulty:";
  564.         mes "\"1\" for Easy, by \"2\" for Medium, by \"3\" for Hard.";
  565.         next;
  566.     }
  567.     mes .n$;
  568.     mes "So that's all I can tell you about my service.";
  569.     mes "See you again.";
  570.     break;
  571.    
  572.     // Point Shop
  573.     case 3:
  574.     mes .n$;
  575.     mes "Which Shop do you want to open?";
  576.     mes "Your Dungeon Points: "+getd(""+.dg_var$);
  577.     mes "Your MvP Points: "+getd(""+.mvp_var$);
  578.     next;
  579.     deletearray @sh_iid[0],getarraysize(@sh_iid);
  580.     deletearray @sh_price[0],getarraysize(@sh_price);
  581.     switch(select("- Dungeon Points:- MvP Points:- Leave")) {
  582.  
  583.         case 1:
  584.         if(!.dg_pts) {
  585.             mes .n$;
  586.             mes "I'm sorry, but this point service is currently not available duo the fact Dungeon Points not being gainable.";
  587.             mes "Please come back another time.";
  588.             close;
  589.         }
  590.         query_sql "SELECT `item_id` , `item_price` FROM `dqs_shop` WHERE `type` = '1'",@sh_iid,@sh_price;
  591.         if(getarraysize(@sh_iid) < 1) {
  592.             mes .n$;
  593.             mes "There are no items yet on sale. Please come back later.";
  594.             close;
  595.         }
  596.         set @shop,1;
  597.         set @cost,0;
  598.         set @total,0;
  599.         deletearray @bought_nameid[0],128;
  600.         deletearray @bought_quantity[0],128;
  601.  
  602.         // Reseting the shop
  603.         npcshopitem "DGShop",@sh_iid[0],@sh_price[0];
  604.         for ( set .@b,1; .@b < getarraysize(@sh_iid); set .@b,.@b + 1)
  605.             npcshopadditem "DGShop",@sh_iid[.@b],@sh_price[.@b];
  606.  
  607.         callshop "DGShop",1;
  608.         npcshopattach "DGShop";
  609.         end;
  610.        
  611.         case 2:
  612.         if(!.mvp_pts) {
  613.             mes .n$;
  614.             mes "I'm sorry, but this point service is currently not available duo the fact MvP Points not being gainable.";
  615.             mes "Please come back another time.";
  616.             close;
  617.         }
  618.         query_sql "SELECT `item_id` , `item_price` FROM `dqs_shop` WHERE `type` = '2'",@sh_iid,@sh_price;
  619.         if(getarraysize(@sh_iid) < 1) {
  620.             mes .n$;
  621.             mes "There are no items yet on sale. Please come back later.";
  622.             close;
  623.         }
  624.         set @shop,2;
  625.         set @cost,0;
  626.         set @total,0;
  627.         deletearray @bought_nameid[0],128;
  628.         deletearray @bought_quantity[0],128;
  629.  
  630.         // Reseting the shop
  631.         npcshopitem "DMvPShop",@sh_iid[0],@sh_price[0];
  632.  
  633.         for ( set .@b,1; .@b < getarraysize(@sh_iid); set .@b,.@b + 1)
  634.             npcshopadditem "DMvPShop",@sh_iid[.@b],@sh_price[.@b];
  635.        
  636.         callshop "DMvPShop",1;
  637.         npcshopattach "DMvPShop";
  638.         end;
  639.        
  640.         case 3:
  641.         break;
  642.     }
  643.     break;
  644.    
  645.     // Nevermind
  646.     case 4:
  647.     break;
  648. }
  649. end;
  650.  
  651. OnBuyItem:
  652. for ( set .@b,0; .@b < getarraysize(@bought_nameid); set .@b,.@b + 1) {
  653.     for ( set .@l,0; .@l < getarraysize(@sh_iid); set .@l,.@l + 1) {
  654.         if(@bought_nameid[.@b] == @sh_iid[.@l]) {
  655.             if(checkweight(@sh_iid[.@l],@bought_quantity[.@b]) == 1) {
  656.                 set @cost,@sh_price[.@l]*@bought_quantity[.@b];
  657.                 set @total,@total+@cost;
  658.             } else {
  659.                 dispbottom "Points Shop: You would be overweight, please remove some items or buy less.";
  660.                 end;
  661.             }
  662.         }
  663.     }
  664. }
  665.  
  666. if(@total > ((@shop)?getd(""+.dg_var$):getd(""+.mvp_var$)) ) {
  667.     dispbottom "Points Shop: You don't have enough "+((@shop)?getd(""+.dg_var$):getd(""+.mvp_var$))+", you need "+@total+"!";
  668.     end;
  669. }
  670. setd( (@shop == 1)?""+.dg_var$:""+.mvp_var$),(@shop == 1)?getd(""+.dg_var$):getd(""+.mvp_var$) - @total;
  671. dispbottom "Points Shop: You have paied "+@total+"x "+(@shop == 1)?getd(""+.dg_var$):getd(""+.mvp_var$);
  672.  
  673. for ( set .@s,0; .@s < getarraysize(@bought_nameid); set .@s,.@s + 1)
  674.     getitem @bought_nameid[.@s],@bought_quantity[.@s];
  675. end;
  676.  
  677. // GM Control Center
  678. OnGMAccess:
  679. next;
  680. mes .n$;
  681. mes "Note: Changes in the \"System Settings\" and \"Reward Management\" will only stay changed until the Server Restarts or \"@reloadscript\" is used.";
  682. mes "To make the changes stay, you have to change them in the script file itself.";
  683. next;
  684. switch(select("- System Settings:- Dungeon Management:- Quest Management:- Reward Management:- Nevermid")) {
  685.  
  686.     // System Settings = OnInit
  687.     case 1:
  688.     mes .n$;
  689.     mes "What would you like to change?";
  690.     mes "Note: If available the content of an \"()\" means the current setting!!!";
  691.     switch(select("- Debug Mode ("+( (.debug)?"Actived":"Deactivated")+"):- Dungeon Settings:- Quest Settings:- Nevermind")) {
  692.    
  693.         case 1:
  694.         next;
  695.         mes .n$;
  696.         mes "The Debug Mode is currently "+( (.debug)?"Online":"Offline")+".";
  697.         mes "Do you want to change it?";
  698.         if(select("- Yes:- No") - 1) close;
  699.         next;
  700.         mes "The Debug Mode has been changed to: "+( (.debug)?"Offline":"Online");
  701.         set .debug,!.debug;
  702.         break;
  703.        
  704.         // Dungeon Settings
  705.         case 2:
  706.         while(1) {
  707.             next;
  708.             mes .n$;
  709.             mes "[ == Dungeon Settings == ]";
  710.             mes "Please choose which setting about the Dungeons you want to change:";
  711.             next;
  712.             switch(prompt("- EXP Settings:- Repeat Settings")) {
  713.                
  714.                 // EXP Settings
  715.                 case 1:
  716.                 mes .n$;
  717.                 mes "[ == EXP Settings == ]";
  718.                 mes "Please select the Difficulty to change the EXP Rate for it:";
  719.                 mes "Note: You only can change the EXP Rates for each Difficulty.";
  720.                 next;
  721.                 set .@e,select("- Easy ("+.exp[1]+"%):- Medium ("+.exp[2]+"%):- Hard ("+.exp[3]+"%]");
  722.                 mes .n$;
  723.                 mes "[ === Difficulty: "+ ( (.@e == 1)?"Easy":( (.@e == 2)?"Medium":"Hard") )+" === ]";
  724.                 mes "Current Rate: "+.exp[.@e]+"%";
  725.                 mes " ";
  726.                 mes "Please type the new rate:";
  727.                 mes "Note: Lowest: 1%, Maximum: "+.max_exp+"%";
  728.                 next;
  729.                 if(input(.@e_new,1,500) != 0) {
  730.                     mes .n$;
  731.                     mes "Invalid Value, please try again.";
  732.                     continue;
  733.                 }
  734.                 mes .n$;
  735.                 mes "Chosen Value:";
  736.                 mes "> "+.@e_new+"%";
  737.                 mes " ";
  738.                 mes "Is that correct?";
  739.                 if(select("- Yes:- No") - 1) continue;
  740.                 next;
  741.                 mes .n$;
  742.                 mes "The EXP Rate for "+ ( (.@e == 1)?"Easy":( (.@e == 2)?"Medium":"Hard") )+" has been changed successfully.";
  743.                 setarray .exp[.@e],.@e_new;
  744.                 continue;
  745.                
  746.                 // Repeat Settings
  747.                 case 2:
  748.                 while(1) {
  749.                     next;
  750.                     mes .n$;
  751.                     mes "[ == Repeat Settings == ]";
  752.                     mes "Please select an option from below:";
  753.                     next;
  754.                     switch(prompt("- Max Repeat Limit :- Delay Type:- Previous Menu") ) {
  755.                    
  756.                         // Max Repeat Limit
  757.                         case 1:
  758.                         mes .n$;
  759.                         mes "[ == Repeat Limit Setting == ]";
  760.                         mes "Current Maximum Repeat Limit: "+.dg_max_limit;
  761.                         mes " ";
  762.                         mes "Please type the new limit:";
  763.                         mes "Note: Lowest: 1, Maximum: 5000";
  764.                         next;
  765.                         if(input(.@rep_new,1,5000) != 0) {
  766.                             mes .n$;
  767.                             mes "Invalid Value, please try again.";
  768.                             continue;
  769.                         }
  770.                         mes .n$;
  771.                         mes "Chosen Value:";
  772.                         mes "> "+.@rep_new;
  773.                         mes " ";
  774.                         mes "Is that correct?";
  775.                         if(select("- Yes:- No") - 1) continue;
  776.                         next;
  777.                         mes .n$;
  778.                         mes "The Maximum Repeat Limit has been changed successfully.";
  779.                         set .dg_max_limit,.@rep_new;
  780.                         continue;
  781.                        
  782.                         // Delay Type
  783.                         case 2:
  784.                         mes .n$;
  785.                         mes "[ == Delay Type Setting ==]";
  786.                         mes "Current Delay Type: "+ ( (.dg_del_type == 1)?"Hour": ( (.dg_del_type == 2)?"Day": ( (.dg_del_type == 3)?"Week":"Month") ) );
  787.                         mes "Note: This delay becomes only active when the Repeat Limit of an Dungeon has been reached and will be multiplied by the Difficulty of the Dungeon.";
  788.                         mes " ";
  789.                         mes "Please choose one of the Delay Types from below:";
  790.                         set .@del_new,select("- Hour:- Day:- Week:- Month");
  791.                         next;
  792.                         mes .n$;
  793.                         mes "Chosen Delay type:";
  794.                         mes "> "+( (.@del_new == 1)?"Hour": ( (.@del_new == 2)?"Day": ( (.@del_new == 3)?"Week":"Month") ) );
  795.                         mes " ";
  796.                         mes "Is that correct?";
  797.                         if(select("- Yes:- No") - 1) continue;
  798.                         next;
  799.                         mes .n$;
  800.                         mes "The Delay Type has been changed successfully.";
  801.                         set .dg_del_type,.@del_new;
  802.                         continue;
  803.                        
  804.                         // Repeat Settings - Previous Menu
  805.                         default:
  806.                         break;
  807.                     } // End of Repeat Settings - switch(prompt())
  808.                     break;
  809.                    
  810.                 } // End of Repeat Settings - while(1)
  811.                 continue;
  812.                
  813.                 // Dungeon Settings - Cancel
  814.                 default:
  815.                 break;
  816.            
  817.             } // End of Dungeon Settings - switch(prompt())
  818.             break;
  819.         } // End of Dungeon Settings - while(1)
  820.         break;
  821.        
  822.         // Quest Settings
  823.         case 3:
  824.         while(1) {
  825.             next;
  826.             mes .n$;
  827.             mes "[ == Quest Settings ==]";
  828.             mes "Please choose which setting about the quests you want to change:";
  829.             next;
  830.             switch(prompt("- Max Level Requirement :- Monster Hunting:- Item Collecting:- Max Reward Settings")) {
  831.            
  832.                 // Max Level Requirement
  833.                 case 1:
  834.                 mes .n$;
  835.                 mes "[ == Level Requirement == ]";
  836.                 mes "Current Max Level Requirement: "+.level;
  837.                 mes " ";
  838.                 mes "Please type the new requirement:";
  839.                 mes "Note: Lowest: 1, Maximum: "+MAX_LEVEL;
  840.                 next;
  841.                 if(input(.@lvl_new,1,MAX_LEVEL) != 0) {
  842.                     mes .n$;
  843.                     mes "Invalid Level, please try again.";
  844.                     continue;
  845.                 }
  846.                 mes .n$;
  847.                 mes "Chosen Level:";
  848.                 mes "> "+.@lvl_new;
  849.                 mes " ";
  850.                 mes "Is that correct?";
  851.                 if(select("- Yes:- No") - 1) continue;
  852.                 next;
  853.                 mes .n$;
  854.                 mes "The Max Level Requirement has been changed successfully.";
  855.                 set .level,.@lvl_new;
  856.                 continue;
  857.                
  858.                 // Monster Hunting
  859.                 case 2:
  860.                 mes .n$;
  861.                 mes "[ == Monster Hunting == ]";
  862.                 mes "Current Settings:";
  863.                 mes " > Minimum Mob Amount: "+.mob_min;
  864.                 mes " > Maximum Mob Amount: "+.mob_max;
  865.                 mes " > Maximum Mob Count: "+.mob_ct;
  866.                 mes " ";
  867.                 mes "Now I ask of you to type the new values in the exact same order:";
  868.                 mes "Note: Min Mob Amount can't be higher than Max Mob Amount and Max Mob Count can't be less than 1.";
  869.                 next;
  870.                 mes .n$;
  871.                 mes "[ == Min Mob Amount == ]";
  872.                 input .@mob_min;
  873.                 mes " > Input: "+.@mob_min;
  874.                 mes "[ == Max Mob Amount == ]";
  875.                 input .@mob_max;
  876.                 mes " > Input: "+.@mob_max;
  877.                 mes "[ == Max Mob Count == ]";
  878.                 input .@mob_ct;
  879.                 mes " > Input: "+.@mob_ct;
  880.                 mes " ";
  881.                 mes "Is that correct?";
  882.                 if(select("- Yes:- No") - 1) continue;
  883.                 next;
  884.                 mes .n$;
  885.                 if(.@mob_min > .@mob_max || .@mob_ct < 1) {
  886.                     mes "It seems like you have put an invalid value.";
  887.                     mes "Please try again.";
  888.                     continue;
  889.                 }
  890.                 mes "The Minimum Mob Amount, Maximum Mob Amount and Maximum Mob Count has been changed successfull.";
  891.                 set .mob_min,.@mob_min;
  892.                 set .mob_max,.@mob_max;
  893.                 set .mob_ct,.@mob_ct;
  894.                 continue;
  895.                
  896.                 // Item Collecting
  897.                 case 3:
  898.                 mes .n$;
  899.                 mes "[ == Item Collecting == ]";
  900.                 mes "Current Settings:";
  901.                 mes " > Minimum Item Amount: "+.item_min;
  902.                 mes " > Maximum Item Amount: "+.item_max;
  903.                 mes " > Maximum Item Count: "+.item_ct;
  904.                 mes " ";
  905.                 mes "Now I ask of you to type the new values in the exact same order:";
  906.                 mes "Note: Min Item Amount can't be higher than Max Item Amount and Max Item Count can't be less than 1.";
  907.                 next;
  908.                 mes .n$;
  909.                 mes "[ == Min Item Amount == ]";
  910.                 input .@item_min;
  911.                 mes " > Input: "+.@item_min;
  912.                 mes "[ == Max Item Amount == ]";
  913.                 input .@item_max;
  914.                 mes " > Input: "+.@item_max;
  915.                 mes "[ == Max Item Count == ]";
  916.                 input .@item_ct;
  917.                 mes " > Input: "+.@item_ct;
  918.                 mes " ";
  919.                 mes "Is that correct?";
  920.                 if(select("- Yes:- No") - 1) continue;
  921.                 next;
  922.                 mes .n$;
  923.                 if(.@item_min > .@item_max || .@item_ct < 1) {
  924.                     mes "It seems like you have put an invalid value.";
  925.                     mes "Please try again.";
  926.                     continue;
  927.                 }
  928.                 mes "The Minimum Item Amount, Maximum Item Amount and Maximum Item Count has been changed successfull.";
  929.                 set .item_min,.@item_min;
  930.                 set .item_max,.@item_max;
  931.                 set .item_ct,.@item_ct;
  932.                 continue;
  933.                
  934.                 // Max Reward Settings
  935.                 case 4:
  936.                 mes .n$;
  937.                 mes "[ == Max Reward Settings == ]";
  938.                 mes "Current Settings:";
  939.                 mes " > Maximum Zeny Amount: "+.rew_zeny;
  940.                 mes " > Maximum Points Amount: "+.rew_var;
  941.                 mes " > Maximum Item Amount: "+.rew_item;
  942.                 mes " > Maximum Item Weight: "+.rew_weight;
  943.                 mes " > Pre-Defined Item ID: "+.rew_itemid;
  944.                 mes "   (= Item Weight*Reward Amount)";
  945.                 mes " > Maximum Flat EXP Amount: "+.rew_expflat;
  946.                 mes " > Maximum Percent EXP Amount: "+.rew_expperc+"%";
  947.                 mes " ";
  948.                 mes "Please choose which Reward you want to change:";
  949.                 next;
  950.                 switch(set(.@rew_t,select("- Zeny:- Points:- Item:- EXP"))) {
  951.                     case 1:
  952.                     mes .n$;
  953.                     mes "[ == Zeny == ]";
  954.                     mes "Please type the new value:";
  955.                     input .@rew_zeny;
  956.                     mes " > Input: "+.@rew_zeny;
  957.                     break;
  958.                    
  959.                     case 2:
  960.                     mes .n$;
  961.                     mes "[ == Points == ]";
  962.                     mes "Please type the new value:";
  963.                     input .@rew_var;
  964.                     mes " > Input: "+.@rew_var;
  965.                     break;
  966.                    
  967.                     case 3:
  968.                     mes .n$;
  969.                     mes "[ == Max Item Amount == ]";
  970.                     input .@rew_item;
  971.                     mes " > Input: "+.@rew_item;
  972.                     mes "[ == Max Item Weight == ]";
  973.                     input .@rew_weight;
  974.                     mes " > Input: "+.@rew_weight;
  975.                     mes "[ == Pre-Defined Item ID == ]";
  976.                     input .@rew_itemid;
  977.                     if(getitemname(.@rew_itemid) == "" || getitemname(.@rew_itemid) == "null") {
  978.                         mes "Invalid Item ID, please try again.";
  979.                         continue;
  980.                     }
  981.                     mes " > Input: "+getitemname(.@rew_itemid)+" ("+.@rew_itemid+")";
  982.                     break;
  983.                    
  984.                     case 4:
  985.                     mes .n$;
  986.                     mes "[ == Max Flat EXP Amount == ]";
  987.                     input .@rew_expflat;
  988.                     mes " > Input: "+.@rew_expflat;
  989.                     mes "[ == Max Percent EXP Amount == ]";
  990.                     input .@rew_expperc;
  991.                     mes " > Input: "+.@rew_expperc+"%";
  992.                     break;
  993.                 }
  994.                 mes " ";
  995.                 mes "Is that correct?";
  996.                 if(select("- Yes:- No") - 1) continue;
  997.                 next;
  998.                 mes .n$;
  999.                 switch(.@rew_t) {
  1000.                     case 1:
  1001.                     mes "The Maximum Zeny Amount has been changed successfully.";
  1002.                     set .rew_zeny,.@rew_zeny;
  1003.                     break;
  1004.                    
  1005.                     case 2:
  1006.                     mes "The Maximum Points Amount has been changed successfully.";
  1007.                     set .rew_var,.@rew_var;
  1008.                     break;
  1009.                    
  1010.                     case 3:
  1011.                     mes "The Maximum Item Amount, Maximum Item Weight and Pre-Defined Item ID has been changed successfully.";
  1012.                     set .rew_item,.@rew_item;
  1013.                     set .rew_weight,.@rew_weight;
  1014.                     set .rew_itemid,.@rew_itemid;
  1015.                     break;
  1016.                    
  1017.                     case 4:
  1018.                     mes "The Maximum Flat EXP Amount and Maximum Percent EXP Amount has been changed successfully.";
  1019.                     set .rew_expflat,.@rew_expflat;
  1020.                     set .rew_expperc,.@rew_expperc;
  1021.                     break;
  1022.                 }
  1023.                 continue;
  1024.                
  1025.                 // Quest Settings - Default
  1026.                 default:
  1027.                 break;
  1028.             } // End of Quest Settings - switch(prompt())
  1029.             break;
  1030.            
  1031.         } // End of Quest Settings - while(1)
  1032.         break;
  1033.        
  1034.         // Nevermind
  1035.         case 4:
  1036.         break;
  1037.     }
  1038.     break;
  1039.    
  1040.     // Dungeon Management
  1041.     case 2:
  1042.     mes .n$;
  1043.     mes "[ == Dungeon Management == ]";
  1044.     mes "Here is a list of all the dungeons with the total floor quantity:";
  1045.     mes " ";
  1046.     query_sql "SELECT DISTINCT `dg_id` , `name` , count( `floor` ) FROM `dqs_dungeon` GROUP BY `dg_id` ASC",.@dg_id,.@dg_name$,.@floor;
  1047.     mes "Dungeon ID - Dungeon Name - Floor Quantity";
  1048.     for ( set .@d,0; .@d < getarraysize(.@dg_id); set .@d,.@d + 1)
  1049.         mes .@dg_id[.@d]+" - "+.@dg_name$[.@d]+" - "+.@floor[.@d];
  1050.        
  1051.     next;
  1052.     while(1) {
  1053.         mes .n$;
  1054.         mes "What do you want to do?";
  1055.         next;
  1056.         switch(prompt("- Add Dungeon:- Edit Dungeon:- Delete Dungeon")) {
  1057.            
  1058.             // Add Dungeon
  1059.             case 1:
  1060.             mes .n$;
  1061.             mes "[ == Add Dungeon == ]";
  1062.             mes "I will now select the latest or the next free Dungeon ID:";
  1063.             mes "Afterwards you can start adding an dungeon.";
  1064.             mes "Note: You have to add the floors via Editing the Dungeon!!";
  1065.             next;
  1066.             query_sql "SELECT `dg_id` FROM `dqs_dungeon`",.@dg_id;
  1067.             for ( set .@d,0; .@d <= getarraysize(.@dg_id); set .@d,.@d + 1)
  1068.                 if(.@dg_id[.@d] != (.@d+1)) break;
  1069.            
  1070.             set .@id,.@d + 1;
  1071.            
  1072.             mes .n$;
  1073.             mes "New Dungeon ID: "+.@id;
  1074.             mes " ";
  1075.             mes "1st Step  - Dungeon Name:";
  1076.             mes "Note: Minimum: 5 letters, Maximum: 20 letters.";
  1077.             next;
  1078.             if(input(.@d_name$,5,20) != 0) {
  1079.                 mes .n$;
  1080.                 mes "Invalid Name, either too short or too long.";
  1081.                 mes "Please try again.";
  1082.                 continue;
  1083.             }
  1084.             mes .n$;
  1085.             mes "2nd Step - Difficulty:";
  1086.             next;
  1087.             set .@d_diff,select("- Easy:- Medium:- Hard");
  1088.             next;      
  1089.             mes .n$;
  1090.             mes "3rd Step - Level Requirement:";
  1091.             mes "Note: Minimum: 1, Maximum: "+MAX_LEVEL;
  1092.             next;
  1093.             if(input(.@d_level,1,MAX_LEVEL) != 0) {
  1094.                 mes .n$;
  1095.                 mes "Invalid Level, either too less or too high.";
  1096.                 mes "Please try again.";
  1097.                 continue;
  1098.             }
  1099.             mes .n$;
  1100.             mes "4th Step  - Party Limit:";
  1101.             mes "Note: Minimum: 1 party, Maximum: 100 parties.";
  1102.             next;
  1103.             if(input(.@d_plimit,1,100) != 0) {
  1104.                 mes .n$;
  1105.                 mes "Invalid Party Limit, either too less or too high.";
  1106.                 mes "Please try again.";
  1107.                 continue;
  1108.             }
  1109.             mes .n$;
  1110.             mes "5th Step - Monster Kills Requirement:";
  1111.             mes "Note: Maximum: 500";
  1112.             next;
  1113.             if(input(.@d_mobkill,0,500) != 0) {
  1114.                 mes .n$;
  1115.                 mes "Invalid Kill Amount, too high.";
  1116.                 mes "Please try again.";
  1117.                 continue;
  1118.             }
  1119.             mes .n$;
  1120.             mes "6th Step - Floor Amount:";
  1121.             mes "Note: Minimum: 1, Maximum: 100";
  1122.             next;
  1123.             if(input(.@d_fam,1,100) != 0) {
  1124.                 mes .n$;
  1125.                 mes "Invalid Floor Amount, either too less or too high.";
  1126.                 mes "Please try again.";
  1127.                 continue;
  1128.             }
  1129.             mes .n$;
  1130.             mes "7th Step - Repeat Limit";
  1131.             mes "Note: Minimum 1, Maximum "+.dg_max_limit;
  1132.             next;
  1133.             if(input(.@d_repeat,1,.dg_max_limit) != 0) {
  1134.                 mes .n$;
  1135.                 mes "Invalid Repeat Limit, either too less or too high.";
  1136.                 mes "Please try again.";
  1137.                 continue;
  1138.             }
  1139.             mes .n$;
  1140.             mes "8th Step - Status";
  1141.             set .@d_stat,select("- Disable Service:- Enable Service");
  1142.             next;
  1143.             mes .n$;
  1144.             mes "9th Step - Renewal Restriction";
  1145.             set .@ed_renewal,select("- None:- Pre-Renewal only:- Renewal only");               
  1146.             next;
  1147.             mes .n$;
  1148.             mes "You have successfully added the \""+.@d_name$+"\" "+( (compare(.@d_name$,"Dungeon") == 1)?" ":"Dungeon ")+"with the ID "+.@id+" to the database.";
  1149.             for ( set .@a,1; .@a <= .@d_fam; set .@a,.@a + 1)
  1150.                 query_sql "INSERT INTO `dqs_dungeon` ( `dg_id` , `name` , `difficulty` , `req_level` , `pty_limit` , `mob_clear` ,  `floor` , `repeat` , `status` , `renewal` ) VALUES ( '"+.@id+"' , '"+escape_sql(.@d_name$)+"' , '"+.@d_diff+"' , '"+.@d_level+"' , '"+.@d_plimit+"' , '"+.@a+"' , '"+.@d_repeat+"' , '"+.@d_stat+"' , '"+.@d_renewal+"' )";
  1151.             continue;
  1152.        
  1153.             // Edit Dungeon
  1154.             case 2:
  1155.             query_sql "SELECT DISTINCT `dg_id`, `name` FROM `dqs_dungeon` ORDER BY `dg_id` ASC",.@dg_id,.@dg_name$;
  1156.             for ( set .@m,0; .@m < getarraysize(.@dg_id); set .@m,.@m + 1)
  1157.                 set .@edit_m$,.@edit_m$+"- "+.@dg_name$[.@m]+ ( (.@dg_name$[.@m+1] != "")?":":"");
  1158.             mes .n$;
  1159.             mes "Please select an dungeon from below to edit:";
  1160.             next;
  1161.             set .@ed,select(.@edit_m$) - 1;
  1162.             mes .n$;
  1163.             mes "Chosen Dungeon: "+.@dg_name$[.@ed];
  1164.             mes " ";
  1165.             mes "Is this correct?";
  1166.             if(select("- Yes:- No") - 1) continue;
  1167.             while(1) {
  1168.                 next;
  1169.                 mes .n$;
  1170.                 mes "Now choose what you want to edit:";
  1171.                 next;
  1172.                 query_sql "SELECT `name` , `difficulty` , `req_level` , `pty_limit` , `mob_clear` , `repeat` , `status` , `renewal` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@ed]+"'",.@ed_name$,.@ed_diff,.@ed_lvl,.@ed_plimit,.@ed_mob,.@ed_rep,.@ed_stat,.@ed_renewal;
  1173.                 switch(prompt("- Dungeon Name:- Difficulty:- Required Level:- Party Limit:- Monster Kills:- Floor Settings:- Repeat Limit:- Status:- Renewal")) {
  1174.                
  1175.                     // Dungeon Name
  1176.                     case 1:
  1177.                     mes .n$;
  1178.                     mes "Current Name: "+.@ed_name$;
  1179.                     mes " ";
  1180.                     mes "Please type the new name:";
  1181.                     next;
  1182.                     input(.@d_name$);
  1183.                     mes .n$;
  1184.                     mes "Chosen Name: "+.@d_name$;
  1185.                     mes "Is this correct?";
  1186.                     if(select("- Yes:- No") - 1) continue;
  1187.                     next;
  1188.                     mes .n$;
  1189.                     mes "The Dungeon Name \""+.@ed_name$+"\" has been successfully changed to \""+.@d_name$+"\".";
  1190.                     query_sql "UPDATE `dqs_dungeon` SET `name` = '"+escape_sql(.@d_name$)+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1191.                     continue;
  1192.                    
  1193.                     // Difficulty
  1194.                     case 2:
  1195.                     mes .n$;
  1196.                     mes "Current Difficulty: "+.@ed_diff;
  1197.                     mes " ";
  1198.                     mes "Please choose the new Difficulty:";
  1199.                     next;
  1200.                     set .@d_diff,select("- Easy:- Medium:- Hard");
  1201.                     mes .n$;
  1202.                     mes "Chosen Difficulty: "+.@d_diff;
  1203.                     mes "Is this correct?";
  1204.                     if(select("- Yes:- No") - 1) continue;
  1205.                     next;
  1206.                     mes .n$;
  1207.                     mes "The Difficulty has been successfully changed to \""+.@d_diff+"\".";
  1208.                     query_sql "UPDATE `dqs_dungeon` SET `difficulty` = '"+.@d_diff+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1209.                     continue;
  1210.                    
  1211.                     // Required Level
  1212.                     case 3:
  1213.                     mes .n$;
  1214.                     mes "Current Level Requirement: "+.@ed_lvl;
  1215.                     mes " ";
  1216.                     mes "Please type the new level requirement:";
  1217.                     mes "Note: Minimum: 1, Maximum: "+MAX_LEVEL;
  1218.                     next;
  1219.                     if(input(.@d_lvl,1,MAX_LEVEL) != 0) {
  1220.                         mes .n$;
  1221.                         mes "Invalid Level, either too less or too high.";
  1222.                         mes "Please try again.";
  1223.                         continue;
  1224.                     }
  1225.                     next;
  1226.                     input(.@d_lvl);
  1227.                     mes .n$;
  1228.                     mes "Chosen Level: "+.@d_lvl;
  1229.                     mes "Is this correct?";
  1230.                     if(select("- Yes:- No") - 1) continue;
  1231.                     next;
  1232.                     mes .n$;
  1233.                     mes "The Level Requirement has been successfully changed to \""+.@d_lvl+"\".";
  1234.                     query_sql "UPDATE `dqs_dungeon` SET `req_level` = '"+.@d_lvl+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1235.                     continue;
  1236.                    
  1237.                     // Party Limit
  1238.                     case 4:
  1239.                     mes .n$;
  1240.                     mes "Current Party Limit: "+.@ed_plimit;
  1241.                     mes " ";
  1242.                     mes "Please type the new Party Limit:";
  1243.                     next;
  1244.                     input(.@d_plimit);
  1245.                     mes .n$;
  1246.                     mes "Chosen Party Limit: "+.@d_plimit;
  1247.                     mes "Is this correct?";
  1248.                     if(select("- Yes:- No") - 1) continue;
  1249.                     next;
  1250.                     mes .n$;
  1251.                     mes "The Party Limit has been successfully changed to \""+.@d_plimit+"\".";
  1252.                     query_sql "UPDATE `dqs_dungeon` SET `pty_limit` = '"+.@d_plimit+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1253.                     continue;
  1254.                    
  1255.                     // Monster Kills
  1256.                     case 5:
  1257.                     mes .n$;
  1258.                     mes "Current Monster Kills Requirement: "+.@ed_mob;
  1259.                     mes " ";
  1260.                     mes "Please type the new Monster Kills Requirement:";
  1261.                     next;
  1262.                     input(.@d_mob);
  1263.                     mes .n$;
  1264.                     mes "Chosen Monster Kills Requirement: "+.@d_mob;
  1265.                     mes "Is this correct?";
  1266.                     if(select("- Yes:- No") - 1) continue;
  1267.                     next;
  1268.                     mes .n$;
  1269.                     mes "The Monster Kills Requirement has been successfully changed to \""+.@d_mob+"\".";
  1270.                     query_sql "UPDATE `dqs_dungeon` SET `mob_clear` = '"+.@d_mob+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1271.                     continue;
  1272.                    
  1273.                     // Floor Settings
  1274.                     case 6:
  1275.                     while(1) {
  1276.                         mes .n$;
  1277.                         mes "Please choose below what you want to do next:";
  1278.                         next;
  1279.                         deletearray .@fl_id,getarraysize(.@fl_id);
  1280.                         deletearray .@fl_map$[0],getarraysize(.@fl_map$);
  1281.                         deletearray .@fl_x[0],getarraysize(.@fl_x);
  1282.                         deletearray .@fl_y[0],getarraysize(.@fl_y);
  1283.                         query_sql "SELECT `floor` , `map_name` , `map_x` , `map_y` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@ed]+"'",.@fl_id,.@fl_map$,.@fl_x,.@fl_y;
  1284.                         switch(prompt("- Add Floor:- Edit Floor:- Delete Floor")) {
  1285.                        
  1286.                             // Add Floor
  1287.                             case 1:
  1288.                             mes .n$;
  1289.                             mes "[ == Add Floor == ]";
  1290.                             mes "I will now select the latest or the next free Floor ID:";
  1291.                             mes "Afterwards you can start adding the floor data.";
  1292.                             next;
  1293.                             set .@q,1;
  1294.                             while(1) {
  1295.                                 set .@f,0;
  1296.                                 for ( set .@s,0; .@s < getarraysize(.@f_id); set .@s,.@s +1)
  1297.                                     if(.@q == .@f_id[.@s]) {
  1298.                                         set .@f,1;
  1299.                                         break;
  1300.                                     }
  1301.                                 if(.@f == 0)
  1302.                                     break;
  1303.                                 set .@q,.@q + 1;
  1304.                             }
  1305.                             set .@id,.@q;
  1306.                            
  1307.                             mes .n$;
  1308.                             mes "New Floor ID: "+.@id;
  1309.                             mes "Now type the map data, one by one.";
  1310.                             mes " - Map Name:";
  1311.                             input(.@f_map$);
  1312.                             mes " > Input: "+.@f_map$;
  1313.                             mes " - X Coordinate:";
  1314.                             input(.@f_x);
  1315.                             mes " > Input: "+.@f_x;
  1316.                             mes " - Y Coordinate:";
  1317.                             input(.@f_y);
  1318.                             mes " > Input: "+.@f_y;
  1319.                             mes " ";
  1320.                             mes "Is that correct?";
  1321.                             if(select("- Yes:- No") - 1) continue;
  1322.                             next;
  1323.                             mes .n$;
  1324.                             if(checkcell(.@f_map$,.@f_x,.@f_y,cell_chkpass) == 0) {
  1325.                                 mes "This Coordinates are not passable, please try again.";
  1326.                                 continue;
  1327.                             }
  1328.                             mes "Map Data for the Floor #"+.@id+" has been added.";
  1329.                             query_sql "INSERT INTO `dqs_dungeon` ( `dg_id` , `name` , `difficulty` , `req_level` , `pty_limit` , `mob_clear` ,  `floor` , `map_name` , `map_x` , `map_y` , `repeat` , `status` , `renewal` ) VALUES ( '"+.@dg_id[.@ed]+"' , '"+escape_sql(.@ed_name$)+"' , '"+.@ed_diff+"' , '"+.@ed_lvl+"' , '"+.@ed_plimit+"' , '"+.@id+"' , '"+escape_sql(.@f_map$)+"' , '"+.@f_x+"' , '"+.@f_y+"' , '"+.@ed_rep+"' , '"+.@ed_stat+"' )";
  1330.                             continue;
  1331.                            
  1332.                             // Edit Floor
  1333.                             case 2:
  1334.                             mes "[ == Edit Floor == ]";
  1335.                             if(getarraysize(.@fl_id) < 1) {
  1336.                                 mes "I'm sorry, but there is no foor data to edit.";
  1337.                                 mes "Please add one first.";
  1338.                                 continue;
  1339.                             }
  1340.                             mes "Please choose the Floor you want to edit:";
  1341.                             mes "Afterwards you can start editing the floor data itself:";
  1342.                             mes "But all at once.";
  1343.                             mes "Format: - Map Name (ID - <Floor ID>)";
  1344.                             next;
  1345.                             for ( set .@f,0; .@f < getarraysize(.@fl_id); set .@f,.@f + 1)
  1346.                                 set .@f_editm$,.@f_editm$ + "- "+.@fl_map$[.@f]+" (ID - "+.@fl_id[.@f]+")"+ ( ( .@fl_id[(.@f+1)] != 0)?":":"");
  1347.                            
  1348.                             set .@f_ed,select(.@f_editm$) - 1;
  1349.                            
  1350.                             mes .n$;
  1351.                             mes "Chosen Floor: "+.@fl_id[.@f_ed];
  1352.                             mes " > Map Name: "+.@fl_map$[.@f_ed];
  1353.                             mes " > Map X: "+.@fl_x[.@f_ed];
  1354.                             mes " > Map Y: "+.@fl_y[.@f_ed];
  1355.                             mes " ";
  1356.                             mes "Now type the new map data, one by one.";
  1357.                             mes " - Map Name:";
  1358.                             input(.@f_map$);
  1359.                             mes " > Input: "+.@f_map$;
  1360.                             mes " - X Coordinate:";
  1361.                             input(.@f_x);
  1362.                             mes " > Input: "+.@f_x;
  1363.                             mes " - Y Coordinate:";
  1364.                             input(.@f_y);
  1365.                             mes " > Input: "+.@f_y;
  1366.                             mes " ";
  1367.                             mes "Is that correct?";
  1368.                             if(select("- Yes:- No") - 1) continue;
  1369.                             next;
  1370.                             mes .n$;
  1371.                             if(checkcell(.@f_map$,.@f_x,.@f_y,cell_chkpass) == 0) {
  1372.                                 mes "This Coordinates are not passable, please try again.";
  1373.                                 continue;
  1374.                             }
  1375.                             mes "Map Data for the Floor #"+.@fl_id[.@f_ed]+" has been added.";
  1376.                             query_sql "UPDATE `dqs_dungeon` SET `map_name` = '"+.@f_map$+"' , `map_x` = '"+.@f_x+"', `map_y` = '"+.@f_y+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"' AND `floor` = '"+.@fl_id[.@f_ed]+"'";
  1377.                             continue;
  1378.                            
  1379.                             // Delete Floor
  1380.                             case 3:
  1381.                             mes .n$;
  1382.                             mes "[ == Delete Floor == ]";
  1383.                             mes "Please choose the Floor you want to delete:";
  1384.                             if(getarraysize(.@fl_id) < 1) {
  1385.                                 mes "I'm sorry, but there is no foor data to remove.";
  1386.                                 mes "Please add one first.";
  1387.                                 continue;
  1388.                             }
  1389.                             mes "Format: - Map Name (ID - <Floor ID>)";
  1390.                             next;
  1391.                             for ( set .@f,0; .@f < getarraysize(.@fl_id); set .@f,.@f + 1)
  1392.                                 set .@f_delm$,.@f_delm$ + "- "+.@fl_map$[.@f]+" (ID - "+.@fl_id[.@f]+")"+ ( ( .@fl_id[(.@f+1)] != 0)?":":"");
  1393.                            
  1394.                             set .@f_del,select(.@f_delm$) - 1;
  1395.                            
  1396.                             mes .n$;
  1397.                             mes "Chosen Floor: "+.@fl_id[.@f_del];
  1398.                             mes " ";
  1399.                             if(select("- Yes:- No") - 1) continue;
  1400.                             next;
  1401.                             mes .n$;
  1402.                             mes "The floor with the ID#"+.@fl_id[.@f_del]+" has been deleted.";
  1403.                             query_sql "DELETE FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@ed]+"' AND `floor` = '"+.@fl_id[.@f_del]+"'";
  1404.                             continue;
  1405.                            
  1406.                             // Floor Settings - Default
  1407.                             default:
  1408.                             break;
  1409.                         } // End of Floor Settings - switch(prompt())
  1410.                         break;
  1411.                     } // End of Floor Settings while(1)
  1412.                     continue;
  1413.                    
  1414.                     // Repeat Limit
  1415.                     case 7:
  1416.                     mes .n$;
  1417.                     mes "Current Repeat Limit: "+.@ed_rep;
  1418.                     mes " ";
  1419.                     mes "Please type the new repeat limit:";
  1420.                     mes "Note: Minimum 1, Maximum "+.dg_max_limit;
  1421.                     next;
  1422.                     if(input(.@d_rep,1,.dg_max_limit) != 0) {
  1423.                         mes .n$;
  1424.                         mes "Invalid Repeat Limit, either too less or too high.";
  1425.                         mes "Please try again.";
  1426.                         continue;
  1427.                     }
  1428.                     mes .n$;
  1429.                     mes "Chosen Repeat Limit: "+.@d_rep;
  1430.                     mes "Is this correct?";
  1431.                     if(select("- Yes:- No") - 1) continue;
  1432.                     next;
  1433.                     mes .n$;
  1434.                     mes "The Repeat Limit has been successfully changed to \""+.@d_rep+"\".";
  1435.                     query_sql "UPDATE `dqs_dungeon` SET `repeat` = '"+.@d_rep+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1436.                     continue;
  1437.                    
  1438.                     // Status
  1439.                     case 8:
  1440.                     mes .n$;
  1441.                     mes "Current Status: "+.@ed_stat;
  1442.                     mes " ";
  1443.                     mes "Please choose the new status:";
  1444.                     set .@d_stat,select("- Disable Service:- Enable Service");
  1445.                     next;
  1446.                     mes .n$;
  1447.                     mes "Chosen Status: "+.@d_stat;
  1448.                     mes "Is this correct?";
  1449.                     if(select("- Yes:- No") - 1) continue;
  1450.                     next;
  1451.                     mes .n$;
  1452.                     mes "The Status has been successfully changed to \""+.@d_stat+"\".";
  1453.                     query_sql "UPDATE `dqs_dungeon` SET `status` = '"+.@d_stat+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1454.                     continue;
  1455.                    
  1456.                     // Renewal
  1457.                     case 9:
  1458.                     mes .n$;
  1459.                     mes "Current Renewal Restriction: "+.@ed_renewal;
  1460.                     mes " ";
  1461.                     mes "Please choose the new restriction:";
  1462.                     set .@ed_renewal,select("- None:- Pre-Renewal only:- Renewal only");
  1463.                     next;
  1464.                     if(input(.@d_renewal,1,3) != 0) {
  1465.                         mes .n$;
  1466.                         mes "Invalid Type, please try again.";
  1467.                         continue;
  1468.                     }
  1469.                     mes .n$;
  1470.                     mes "Chosen Restriction: "+.@d_renewal;
  1471.                     mes "Is this correct?";
  1472.                     if(select("- Yes:- No") - 1) continue;
  1473.                     next;
  1474.                     mes .n$;
  1475.                     mes "The Renewal Restriction has been successfully changed to \""+.@d_renewal+"\".";
  1476.                     query_sql "UPDATE `dqs_dungeon` SET `renewal` = '"+.@d_renewal+"' WHERE `dg_id` = '"+.@dg_id[.@ed]+"'";
  1477.                     continue;
  1478.    
  1479.                     // Dungeon Edit Options - Default
  1480.                     default:
  1481.                     break;
  1482.                 } // End of Dungeon Edit Options - switch(prompt())
  1483.                 break;
  1484.                
  1485.             } // End of Dungeon Edit Options - while(1)
  1486.             continue;
  1487.            
  1488.             // Delete Dungeon
  1489.             case 3:
  1490.             query_sql "SELECT DISTINCT `dg_id` , `name` FROM `dqs_dungeon` ORDER BY `dg_id` ASC",.@dg_id,.@dg_name$;
  1491.             for ( set .@m,0; .@m < getarraysize(.@dg_id); set .@m,.@m + 1)
  1492.                 set .@del_m$,.@del_m$+"- "+.@dg_name$+ ( (.@dg_name$[.@m+1] != "")?":":"");
  1493.             mes .n$;
  1494.             mes "Please select an dungeon from below to delete:";
  1495.             next;
  1496.             set .@dg_del,select(.@del_m$) - 1;
  1497.             mes .n$;
  1498.             mes "Chosen Dungeon: "+.@dg_name$[.@dg_del];
  1499.             mes " ";
  1500.             mes "Is this correct?";
  1501.             if(select("- Yes:- No") - 1) continue;
  1502.             next;
  1503.             mes .n$;
  1504.             mes "The Dungeon "+.@dg_name$[.@dg_del]+" and it's quests has been successfully deleted.";
  1505.             query_sql "DELETE FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@dg_del]+"'";
  1506.             query_sql "DELETE FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@dg_del]+"'";
  1507.             query_sql "DELETE FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id[.@dg_del]+"'";
  1508.             // Deleting Delay Variables from the database
  1509.             query_sql "DELETE FROM `global_reg_value` WHERE `str` = 'DG_"+.@dg_id[.@q]+"_RepeatCT'";
  1510.             query_sql "DELETE FROM `global_reg_value` WHERE `str` = 'DG_"+.@dg_id[.@q]+"_RepeatTimer'";
  1511.             continue;
  1512.            
  1513.             // Dungeon Management Options - Cancel Button
  1514.             default:
  1515.             break;
  1516.            
  1517.         } // End of Dungeon Management - switch(prompt())
  1518.         break;
  1519.     } // End of Dungeon Management - while(1)
  1520.     break;
  1521.    
  1522.     // Quest Management
  1523.     case 3:
  1524.     mes .n$;
  1525.     mes "Here is a list of all the available quests ordered by Dungeon:";
  1526.     mes " ";
  1527.     query_sql "SELECT DISTINCT `dg_id` , `name` FROM `dqs_dungeon` GROUP BY `dg_id` ASC",.@dg_id,.@dg_name$;
  1528.     mes "Dungeon ID - Dungeon Name - Quest Quantity";
  1529.     for ( set .@q,0; .@q < getarraysize(.@dg_id); set .@q,.@q + 1) {
  1530.         deletearray .@q_ct[0],getarraysize(.@q_ct);
  1531.         query_sql "SELECT DISTINCT `quest_id` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@q]+"'",.@q_ct;
  1532.         mes .@dg_id[.@q]+" - "+.@dg_name$[.@q]+" - "+getarraysize(.@q_ct);
  1533.         set .@dg_menu$,.@dg_menu$ + "- "+.@dg_name$[.@q]+ ( (.@dg_id[.@q+1] != 0)?":":"");
  1534.     }
  1535.     next;
  1536.     mes .n$;
  1537.     mes "Please select the Dungeon you want to manage the quests:";
  1538.     next;
  1539.     set .@d,select(.@dg_menu$) - 1;
  1540.     mes .n$;
  1541.     mes "Chosen Dungeon: "+.@dg_name$[.@d];
  1542.     mes "Is this correct?";
  1543.     if(select("- Yes:- No") - 1) close;
  1544.     while(1) {
  1545.         next;
  1546.         mes .n$;
  1547.         mes "What do you like to do now?";
  1548.         next;
  1549.         deletearray .@q_req1[0],getarraysize(.@q_req1);
  1550.         deletearray .@q_req2[0],getarraysize(.@q_req2);
  1551.         switch(prompt("- Add Quests:- Edit Quests:- Delete Quests")) {
  1552.        
  1553.             // Add Quests
  1554.             case 1:
  1555.             mes .n$;
  1556.             if(query_sql("SELECT DISTINCT `quest_id`  FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@q_id) == .max_quests) {
  1557.                 mes "I'm sorry, but you can't add anymore quests to this Dungeon, please try another one.";
  1558.                 continue;
  1559.             }
  1560.             set .@q,2;
  1561.             while(.@q < .max_quests) {
  1562.                 set .@f,0;
  1563.                 for ( set .@s,0; .@s < getarraysize(.@q_id); set .@s,.@s +1)
  1564.                     if(.@q == .@q_id[.@s]) {
  1565.                         set .@f,1;
  1566.                         break;
  1567.                     }
  1568.                 if(.@f == 0)
  1569.                     break;
  1570.                 set .@q,.@q + 1;
  1571.             }
  1572.             set .@id,.@q;
  1573.            
  1574.             mes "Please type an Name for the Quest:";
  1575.             next;
  1576.             input .@q_name$;
  1577.             mes .n$;
  1578.             mes "Please choose what type of quest it will be:";
  1579.             mes "Note: If you make any kind of mistake after this, you will have to repeat every step.";
  1580.             next;
  1581.             set .@type,select("- Monster Hunting:- Item Collecting");
  1582.             set .@count,0;
  1583.             deletearray .@map$[0],getarraysize(.@map$);
  1584.            
  1585.             mes .n$;
  1586.             query_sql "SELECT `map_name` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@map$;
  1587.             // Monster Hunting
  1588.             if(.@type == 1) {
  1589.                 mes "How many mobs should be hunted?";
  1590.                 mes "^FF0000Note: Maximum "+.mob_ct+"^000000";
  1591.                 if(input(.@ct,1,.mob_ct) != 0) {
  1592.                     next;
  1593.                     mes .n$;
  1594.                     mes "Invalid Amount, please try again.";
  1595.                     continue;
  1596.                 }
  1597.                 next;
  1598.                 mes .n$;
  1599.                 mes .@ct+" Mobs should be hunted.";
  1600.                 mes " ";
  1601.                 while(.@count < .@ct) {
  1602.                     next;
  1603.                     mes .n$;
  1604.                     mes "Please choose Mob #"+(.@count+1)+":";
  1605.                     next;
  1606.                     set .@mobid,F_GetMobData(implode(.@map$,":"));
  1607.                     mes .n$;
  1608.                     mes "Mob Name: "+strmobinfo(1,.@mobid);
  1609.                     next;
  1610.                     mes .n$;
  1611.                     mes "Now type the amount to hunt:";
  1612.                     mes "Minimum: "+.mob_min+", Maximum: "+.mob_max;
  1613.                     next;
  1614.                     if(input(.@mobam,.mob_min,.mob_max) != 0) {
  1615.                         mes .n$;
  1616.                         mes "Invalid Amount, please try again.";
  1617.                         continue;
  1618.                     }
  1619.                     mes .n$;
  1620.                     mes "Mob Name: "+strmobinfo(1,.@mobid)+" ("+.@mobid+")";
  1621.                     mes "Mob Quantity: "+.@mobam;
  1622.                     mes " ";
  1623.                     mes "Is this correct?";
  1624.                     if(select("- Yes:- No") - 1) continue;
  1625.                     setarray .@q_req1[getarraysize(.@q_req1)],.@mobid;
  1626.                     setarray .@q_req2[getarraysize(.@q_req2)],.@mobam;
  1627.                     set .@count,.@count + 1;
  1628.                 }
  1629.            
  1630.             // Item Collecting
  1631.             } else if(.@type == 2) {
  1632.                 mes "How many items do you want to add?";
  1633.                 mes "^FF0000Note: Maximum "+.item_ct+"^000000";
  1634.                 if(input(.@ct,1,.item_ct) != 0) {
  1635.                     next;
  1636.                     mes .n$;
  1637.                     mes "Invalid Amount, please try again.";
  1638.                     continue;
  1639.                 }
  1640.                 next;
  1641.                 mes .n$;
  1642.                 mes .@ct+" Items should be collected.";
  1643.                 mes " ";
  1644.                 while(.@count < .@ct) {
  1645.                     next;
  1646.                     mes .n$;
  1647.                     mes "Please choose Item #"+(.@count+1)+":";
  1648.                     next;
  1649.                     set .@itemid,F_GetMobData(implode(.@map$,":"),1);
  1650.                     mes .n$;
  1651.                     mes "Item: "+getitemname(.@itemid);
  1652.                     mes " ";
  1653.                     mes "Type the amount to collect next:";
  1654.                     mes "^FF0000Note: Minimum: "+.item_min+", Maximum: "+.item_max+"^000000";
  1655.                     next;
  1656.                     if(input(.@itemam,.item_min,.item_max) != 0) {
  1657.                         mes .n$;
  1658.                         mes "Invalid Amount, please try again.";
  1659.                         continue;
  1660.                     }
  1661.                     mes .n$;
  1662.                     mes "Item: "+getitemname(.@itemid)+" ("+.@itemid+")";
  1663.                     mes "Amount: "+.@itemam;
  1664.                     mes " ";
  1665.                     mes "Correct?";
  1666.                     if(select("- Yes:- No") - 1) continue;
  1667.                     setarray .@q_req1[getarraysize(.@q_req1)],.@itemid;
  1668.                     setarray .@q_req2[getarraysize(.@q_req2)],.@itemam;
  1669.                     set .@count,.@count + 1;
  1670.                 }
  1671.             }
  1672.             next;
  1673.             mes .n$;
  1674.             mes "Now choose the reward:";
  1675.             next;
  1676.             set .@rew_t,select("- Zeny:- Points ["+( (.rew_vart == 1)?"Enabled":"Disabled")+"]:- Item");
  1677.             switch(.@rew_t) {
  1678.                 case 1: set .@rew_1,1; break;
  1679.                 case 2:
  1680.                 if(.rew_vart == 0) {
  1681.                     mes .n$;
  1682.                     mes "I'm sorry, but I can't offer you this reward for choice.";
  1683.                     continue;
  1684.                 }
  1685.                 set .@rew_1,2;
  1686.                 break;
  1687.                
  1688.                 case 3:
  1689.                 mes .n$;
  1690.                 mes "Now please choose if you want to use an specific Item or the pre-defined Item, which is "+getitemname(.rew_itemid)+":";
  1691.                 next;
  1692.                 if(select("- Specific Item:- Pre-Defined Item") == 2)
  1693.                     set .@rew_1,.rew_itemid;
  1694.                 else {
  1695.                     input .@rew_1;
  1696.                     if(getitemname(.@rew_1) == "null" || getitemname(.@rew_1) == "") {
  1697.                         mes .n$;
  1698.                         mes "You have put an invalid Item ID.";
  1699.                         mes "Try again please.";
  1700.                         continue;
  1701.                     }
  1702.                 }
  1703.                 break;
  1704.             }
  1705.             mes .n$;
  1706.             mes "Chosen Reward: "+( (.@rew_t == 1)?"Zeny": ( (.@rew_t == 2)?.rew_vard$:"Item: "+getitemname(.@rew_1)) );
  1707.             mes "Now the amount:";
  1708.             if(.@rew_t == 1) mes " - Maximum Zeny: "+.rew_zeny;
  1709.             if(.@rew_t == 2) mes " - Maximum Points: "+.rew_var;
  1710.             if(.@rew_t == 3) mes " - Maximum Item Amount: "+.rew_item;
  1711.             next;
  1712.             input .@rew_2;
  1713.             mes .n$;
  1714.             switch(.@rew_t) {
  1715.                
  1716.                 // Zeny Reward
  1717.                 case 1: if(.@rew_2 > .rew_zeny) set .@f,1; break;
  1718.                 // Item Reward
  1719.                 case 2:
  1720.                 if(.@rew_2 > .rew_item)
  1721.                     set .@f,1;
  1722.                 else if( (.@rew_2*getiteminfo(.@rew_1,6)) >= .rew_weight)
  1723.                     set .@f,2;
  1724.                 break;
  1725.                 // Cash Points Reward
  1726.                 case 3: if(.@rew_2 > .rew_var) set .@f,1; break;
  1727.                 break;
  1728.             }
  1729.             if(.@f) {
  1730.                 mes "I'm sorry, but the reward amount you have put is higher than the limit.";
  1731.                 if(.@f == 2) mes "To precise - Weight limit of "+.rew_weight+" has been reached. "+.@rew_2+"x "+getitemname(.@rew_1)+" would weight "+(.@rew_2*getiteminfo(.@rew_1,6))+".";
  1732.                 continue;
  1733.             }
  1734.             mes "Now please type the EXP Type:";
  1735.             next;
  1736.             set .@exp_type,select("- No EXP Reward:- Flat Amount:- Percent of Total EXP") - 1;
  1737.             mes .n$;
  1738.             mes "Chosen EXP Type: "+ ( (.@exp_type == 0)?"None": ( (.@exp_type == 1)?"Flat Amount":"Percent") );
  1739.             if(.@exp_type != 0) {
  1740.                 mes "Now type the exp amount:";
  1741.                 if(.@exp_type == 1) mes "- Maximum Flat Amount: "+.rew_expflat;
  1742.                 if(.@exp_type == 2) mes "- Maximum Percent: "+.rew_expperc;
  1743.                 mes " ";
  1744.                 mes "> Base EXP:";
  1745.                 input .@rew_bexp;
  1746.                 switch(.@exp_type) {
  1747.                     case 1: if(.@rew_bexp > .rew_expflat) set .@b,1; break;
  1748.                     case 2: if(.@rew_bexp > .rew_expperc) set .@b,1; break;
  1749.                 }
  1750.                 mes "> Job EXP:";
  1751.                 input .@rew_jexp;
  1752.                 switch(.@exp_type) {
  1753.                     case 1: if(.@rew_jexp > .rew_expflat) set .@j,1; break;
  1754.                     case 2: if(.@rew_jexp > .rew_expperc) set .@j,1; break;
  1755.                 }
  1756.                 next;
  1757.                 mes .n$;
  1758.                 if(.@b || .@j) {
  1759.                     mes "You put either in Base EXP or Job EXP an invalid amount.";
  1760.                     mes "Please try again.";
  1761.                     continue;
  1762.                 }
  1763.                 mes "Base EXP: "+.@rew_bexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  1764.                 mes "Job EXP: "+.@rew_jexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  1765.                 mes " ";
  1766.                 mes "Is this correct?";
  1767.                 if(select("- Yes:- No") - 1) continue;
  1768.                
  1769.             } else { // Reseting
  1770.                 set .@rew_bexp,0;
  1771.                 set .@rew_jexp,0;
  1772.             }
  1773.             next;
  1774.             mes .n$;
  1775.             for ( set .@r,0; .@r < getarraysize(.@q_req1); set .@r,.@r + 1)
  1776.                 if(.@type == 1)
  1777.                     query_sql "INSERT INTO `dqs_quest` ( `dg_id` , `quest_id` , `quest_name` , `quest_type` , `mob_id` , `mob_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` ) VALUES ( '"+.@dg_id[.@d]+"', '"+.@id+"' , '"+escape_sql(.@q_name$)+"' , '"+.@type+"' , '"+.@q_req1[.@r]+"' , '"+.@q_req2[.@r]+"' , '"+.@rew_1+"' , '"+.@rew_2+"' , '"+.@exp_type+"' , '"+.@rew_bexp+"' , '"+.@rew_jexp+"' )";
  1778.                 else if(.@type == 2)
  1779.                     query_sql "INSERT INTO `dqs_quest` ( `dg_id` , `quest_id` , `quest_name` , `quest_type` , `item_id` , `item_am` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` ) VALUES ( '"+.@dg_id[.@d]+"', '"+.@id+"' , '"+escape_sql(.@q_name$)+"' , '"+.@type+"' , '"+.@q_req1[.@r]+"' , '"+.@q_req2[.@r]+"' , '"+.@rew_1+"' , '"+.@rew_2+"' , '"+.@exp_type+"' , '"+.@rew_bexp+"' , '"+.@rew_jexp+"' )";
  1780.            
  1781.             mes "The Quest ID#"+.@id+" ["+.@q_name$+"] has been added successfully.";
  1782.             continue;
  1783.            
  1784.             // Edit Quest
  1785.             case 2:
  1786.             set .@ed_menu$,"";
  1787.             deletearray .@q_id,getarraysize(.@q_id);
  1788.             deletearray .@q_name$,getarraysize(.@q_name$);
  1789.             mes .n$;
  1790.             query_sql "SELECT DISTINCT  `quest_id` , `quest_name` , `quest_type` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@q_id,.@q_name$,.@q_type;
  1791.             if(getarraysize(.@q_name$) < 1) {
  1792.                 mes "I'm sorry, but you can't remove quests from this Dungeon, because there are none yet. Please try another one.";
  1793.                 continue;
  1794.             }
  1795.             mes "Please choose, which Quest you want to edit:";
  1796.             for ( set .@q,0; .@q < getarraysize(.@q_name$); set .@q,.@q + 1)
  1797.                 set .@ed_menu$,.@ed_menu$ + "- "+.@q_name$[.@q] + "("+( (.@q_type[.@q] == 1)?"Monster Hunting":"Item Collecting")+")" + ( (.@q_name$[.@q+1] != "")?":":"");
  1798.             next;
  1799.             set .@ed,select(.@ed_menu$) - 1;
  1800.            
  1801.             // Clearing Arrays
  1802.             deletearray .@req1,getarraysize(.@req1);
  1803.             deletearray .@req2,getarraysize(.@req2);
  1804.             deletearray .@rew_id,getarraysize(.@rew_id);
  1805.             deletearray .@rew_am,getarraysize(.@rew_am);
  1806.             deletearray .@rew_expt,getarraysize(.@rew_expt);
  1807.             deletearray .@rew_bexp,getarraysize(.@rew_bexp);
  1808.             deletearray .@rew_jexp,getarraysize(.@rew_jexp);
  1809.            
  1810.             query_sql "SELECT `"+ ( (.@q_type[.@ed] == 1)?"mob_id` , `mob_am":"item_id` , `item_am")+"` , `reward_id`, `reward_am` , `reward_exptype`, `reward_bexp`, `reward_jexp` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"'",.@req1,.@req2,.@rew_id,.@rew_am,.@rew_expt,.@rew_bexp,.@rew_jexp;
  1811.             mes .n$;
  1812.             mes "Chosen Quest: "+.@q_name$[.@ed];
  1813.             mes "Type: "+ ( (.@q_type[.@ed] == 1)?"Monster Hunting":"Item Collecting");
  1814.             mes "Target:";
  1815.             for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  1816.                 mes "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) );
  1817.             mes "Reward:";
  1818.             mes .@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?getd(""+.rew_vard$):getitemname(.@rew_id)));
  1819.             if(.@rew_expt != 0) {
  1820.                 mes "EXP Reward:";
  1821.                 mes "Base EXP: "+.@rew_bexp + ( (.@rew_expt == 2)?"% of Total EXP":"");
  1822.                 mes "Job EXP: "+.@rew_jexp + ( (.@rew_expt == 2)?"% of Total EXP":"");
  1823.             }
  1824.             mes " ";
  1825.             mes "What do you want to edit?";
  1826.             next;
  1827.             switch(select("- Change Quest Name:- Change Target:- Change Reward:- Change EXP Reward:- Move Quest") ) {
  1828.                
  1829.                 case 1:
  1830.                 mes .n$;
  1831.                 mes "Current Quest Name: "+.@q_name$[.@ed];
  1832.                 mes "Please type the new Name:";
  1833.                 next;
  1834.                 if(input(.@ed_name$,0,255) != 0) {
  1835.                     mes .n$;
  1836.                     mes "I'm sorry, but the new quest name is either to short or too long.";
  1837.                     continue;
  1838.                 }
  1839.                 mes .n$;
  1840.                 mes "New Quest Name: "+.@ed_name$;
  1841.                 mes "Is this correct?";
  1842.                 if(select("- Yes:- No") - 1) continue;
  1843.                 next;
  1844.                 mes .n$;
  1845.                 mes "The Quest Name has successfully been changed to "+.@ed_name$+".";
  1846.                 query_sql "UPDATE `dqs_quest` SET `quest_name` = '"+escape_sql(.@ed_name$)+"' WHERE `quest_id` = '"+.@q_id[.@ed]+" AND `dg_id` = '"+.@dg_id[.@d]+"'";
  1847.                 break;
  1848.                
  1849.                 // Target
  1850.                 case 2:
  1851.                 mes .n$;
  1852.                 mes "Current Target:";
  1853.                 for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  1854.                     mes "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) );
  1855.                 mes " ";
  1856.                 mes "What do you want to do?";
  1857.                 next;
  1858.                 switch(select("- Add Target:- Edit Targets:- Delete Target")) {
  1859.                
  1860.                     // Add Targets
  1861.                     case 1:
  1862.                     deletearray .@map$,getarraysize(.@map$);
  1863.                     query_sql "SELECT `map_name` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@map$;
  1864.                     mes .n$;
  1865.                     if(.@q_type[.@ed] == 1) {
  1866.                         mes "Now choose the Mob:";
  1867.                         next;
  1868.                         set .@i,F_GetMobData(implode(.@map$,":"));
  1869.                         mes "Now type the amount to hunt:";
  1870.                         mes "Minimum: "+.mob_min+", Maximum: "+.mob_max;
  1871.                         next;
  1872.                         if(input(.@am,.mob_min,.mob_max) != 0) {
  1873.                             mes .n$;
  1874.                             mes "Invalid Amount, please try again.";
  1875.                             continue;
  1876.                         }
  1877.                     } else if(.@q_type[.@ed] == 2) {
  1878.                         mes "Now choose the Item:";
  1879.                         next;
  1880.                         set .@i,F_GetMobData(implode(.@map$,":"),1);
  1881.                         mes .n$;
  1882.                         mes "Item Name: "+ getitemname(.@i);
  1883.                         mes "Now type the amount to collect:";
  1884.                         mes "^FF0000Note: Minimum: "+.item_min+", Maximum: "+.item_max+"^000000";
  1885.                         next;
  1886.                         if(input(.@am,.item_min,.item_max) != 0) {
  1887.                             mes .n$;
  1888.                             mes "Invalid Amount, please try again.";
  1889.                             continue;
  1890.                         }
  1891.                     }
  1892.                     mes .n$;
  1893.                     mes "New Target: "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@i):getitemname(.@i));
  1894.                     mes "Amount: "+.@am;
  1895.                     mes " ";
  1896.                     mes "Correct?";
  1897.                     if(select("- Yes:- No") - 1) continue;
  1898.                     next;
  1899.                     mes .n$;
  1900.                     mes "The new Target has been added successfully.";
  1901.                     query_sql "INSERT INTO `dqs_quest` ( `dg_id` , `quest_id` , `quest_name` , `quest_type` , `"+ ( (.@q_type[.@ed] == 1)?"mob_id` , `mob_am":"item_id` , `item_am")+"` , `reward_id` , `reward_am` , `reward_exptype` , `reward_bexp` , `reward_jexp` ) VALUES ( '"+.@dg_id[.@d]+"', '"+.@q_id[.@ed]+"' , '"+escape_sql(.@q_name$[.@ed])+"' , '"+.@q_type[.@ed]+"' , '"+.@i+"' , '"+.@am+"' , '"+.@rew_id+"' , '"+.@rew_am+"' , '"+.@rew_expt+"' , '"+.@rew_bexp+"' , '"+.@rew_jexp+"' )";
  1902.                     break;
  1903.                    
  1904.                     // Edit Target
  1905.                     case 2:
  1906.                     mes .n$;
  1907.                     mes "Please choose the target you want to change:";
  1908.                     mes "Note: I will ask you for the amount later too.";
  1909.                     next;
  1910.                     for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  1911.                         set .@t_menu$,.@t_menu$ + "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) ) + ( (.@req1[.@l] != 0)?":":"");
  1912.                    
  1913.                     set .@c,select(.@t_menu$) - 1;
  1914.                     mes .n$;
  1915.                     mes "Chosen Target:";
  1916.                     mes .@req2[.@c]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@c]):getitemname(.@req1[.@c]) );
  1917.                     mes " ";
  1918.                     mes "Is this correct?";
  1919.                     if(select("- Yes:- No") - 1) continue;
  1920.                     next;
  1921.                     deletearray .@map$,getarraysize(.@map$);
  1922.                     query_sql "SELECT `map_name` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@map$;
  1923.                     mes .n$;
  1924.                     if(.@q_type[.@ed] == 1) {
  1925.                         mes "Now choose the Mob:";
  1926.                         next;
  1927.                         set .@i,F_GetMobData(implode(.@map$,":"));
  1928.                         mes "Now type the amount to hunt:";
  1929.                         mes "Minimum: "+.mob_min+", Maximum: "+.mob_max;
  1930.                         next;
  1931.                         if(input(.@am,.mob_min,.mob_max) != 0) {
  1932.                             mes .n$;
  1933.                             mes "Invalid Amount, please try again.";
  1934.                             continue;
  1935.                         }
  1936.                     } else if(.@q_type[.@ed] == 2) {
  1937.                         mes "Now choose the Item:";
  1938.                         next;
  1939.                         set .@i,F_GetMobData(implode(.@map$,":"),1);
  1940.                         mes .n$;
  1941.                         mes "Item Name: "+ getitemname(.@i);
  1942.                         mes "Now type the amount to collect:";
  1943.                         mes "^FF0000Note: Minimum: "+.item_min+", Maximum: "+.item_max+"^000000";
  1944.                         next;
  1945.                         if(input(.@am,.item_min,.item_max) != 0) {
  1946.                             mes .n$;
  1947.                             mes "Invalid Amount, please try again.";
  1948.                             continue;
  1949.                         }
  1950.                     }
  1951.                     mes .n$;
  1952.                     mes "New Target: "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@i):getitemname(.@i));
  1953.                     mes "Amount: "+.@am;
  1954.                     mes " ";
  1955.                     mes "Correct?";
  1956.                     if(select("- Yes:- No") - 1) continue;
  1957.                     next;
  1958.                     mes .n$;
  1959.                     mes "The Target has been changed successfully.";
  1960.                     query_sql "UPDATE `dqs_quest` SET `"+ ( (.@q_type[.@ed] == 1)?"mob_id":"item_id")+"` = '"+.@i+"' ,  `"+ ( (.@q_type[.@ed] == 1)?"mob_am":"item_am")+"` = '"+.@am+"' WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"' AND `"+ ( (.@q_type[.@ed] == 1)?"mob_id":"item_id")+"` = '"+.@req1[.@c]+"'";
  1961.                     // Updating running Quests
  1962.                     if(.@q_type[.@ed] == 1 && query_sql("SELECT `mob_id` FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"' AND `mob_id` = '"+.@req1[.@c]+"'",.@m_id) != 0)
  1963.                         query_sql "UPDATE `dqs_party` SET `mob_id` = '"+.@i+"' , `req_am` = '"+.@am+"' WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"' AND `mob_id` = '"+.@req1[.@c]+"'";
  1964.                     break;
  1965.                    
  1966.                     // Delete Target
  1967.                     case 3:
  1968.                     mes .n$;
  1969.                     mes "Please choose the target you want to change:";
  1970.                     mes "Note: I will ask you for the amount later too.";
  1971.                     next;
  1972.                     for ( set .@l,0; .@l < getarraysize(.@req1); set .@l,.@l + 1)
  1973.                         set .@t_menu$,.@t_menu$ + "- "+.@req2[.@l]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@l]):getitemname(.@req1[.@l]) ) + ( (.@req1[.@l] != 0)?":":"");
  1974.                    
  1975.                     set .@c,select(.@t_menu$) - 1;
  1976.                     mes .n$;
  1977.                     mes "Chosen Target:";
  1978.                     mes .@req2[.@c]+"x "+ ( (.@q_type[.@ed] == 1)?strmobinfo(1,.@req1[.@c]):getitemname(.@req1[.@c]) );
  1979.                     mes " ";
  1980.                     mes "Is this correct?";
  1981.                     if(select("- Yes:- No") - 1) continue;
  1982.                     next;
  1983.                     mes .n$;
  1984.                     mes "The Target has been changed successfully.";
  1985.                     query_sql "DELETE FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"' AND `"+ ( (.@q_type[.@ed] == 1)?"mob_id":"item_id")+"` = '"+.@req1[.@c]+"'";
  1986.                     break;
  1987.                 }
  1988.                 break;
  1989.                
  1990.                 // Reward
  1991.                 case 3:
  1992.                 mes .n$;
  1993.                 mes "Current Reward:";
  1994.                 mes .@rew_am+"x "+( (.@rew_id == 1)?"Zeny": ( (.@rew_id == 2)?getd(""+.rew_vard$):getitemname(.@rew_id)));
  1995.                 mes " ";
  1996.                 mes "Please choose the new Reward Type.";
  1997.                 mes "Note: I will also ask for the new amount!";
  1998.                 next;
  1999.                 set .@rew_t,select("- Zeny:- Points ["+( (.rew_vart == 1)?"Enabled":"Disabled")+"]:- Item");
  2000.                 switch(.@rew_t) {
  2001.                     case 1: set .@rew_1,1; break;
  2002.                     case 2:
  2003.                     if(.rew_vart == 0) {
  2004.                         mes .n$;
  2005.                         mes "I'm sorry, but I can't offer you this reward for choice.";
  2006.                         continue;
  2007.                     }
  2008.                     set .@rew_1,2;
  2009.                     break;
  2010.                    
  2011.                     case 3:
  2012.                     mes .n$;
  2013.                     mes "Now please choose if you want to use an specific Item or the pre-defined Item, which is "+getitemname(.rew_itemid)+":";
  2014.                     next;
  2015.                     if(select("- Specific Item:- Pre-Defined Item") == 2)
  2016.                         set .@rew_1,.rew_itemid;
  2017.                     else {
  2018.                         input .@rew_1;
  2019.                         if(getitemname(.@rew_1) == "null" || getitemname(.@rew_1) == "") {
  2020.                             mes .n$;
  2021.                             mes "You have put an invalid Item ID.";
  2022.                             mes "Try again please.";
  2023.                             continue;
  2024.                         }
  2025.                     }
  2026.                     break;
  2027.                 }
  2028.                 mes .n$;
  2029.                 mes "Chosen Reward: "+( (.@rew_t == 1)?"Zeny": ( (.@rew_t == 2)?.rew_vard$:"Item: "+getitemname(.@rew_1)) );
  2030.                 mes "Now the amount:";
  2031.                 if(.@rew_t == 1) mes " - Maximum Zeny: "+.rew_zeny;
  2032.                 if(.@rew_t == 2) mes " - Maximum Points: "+.rew_var;
  2033.                 if(.@rew_t == 3) mes " - Maximum Item Amount: "+.rew_item;
  2034.                 next;
  2035.                 input .@rew_2;
  2036.                 mes .n$;
  2037.                 switch(.@rew_t) {
  2038.                    
  2039.                     // Zeny Reward
  2040.                     case 1: if(.@rew_2 > .rew_zeny) set .@f,1; break;
  2041.                     // Item Reward
  2042.                     case 2:
  2043.                     if(.@rew_2 > .rew_item)
  2044.                         set .@f,1;
  2045.                     else if( (.@rew_2*getiteminfo(.@rew_1,6)) >= .rew_weight)
  2046.                         set .@f,2;
  2047.                     break;
  2048.                     // Cash Points Reward
  2049.                     case 3: if(.@rew_2 > .rew_var) set .@f,1; break;
  2050.                     break;
  2051.                 }
  2052.                 if(.@f) {
  2053.                     mes "I'm sorry, but the reward amount you have put is higher than the limit.";
  2054.                     if(.@f == 2) mes "To precise - Weight limit of "+.rew_weight+" has been reached. "+.@rew_2+"x "+getitemname(.@rew_1)+" would weight "+(.@rew_2*getiteminfo(.@rew_1,6))+".";
  2055.                     continue;
  2056.                 }
  2057.                 mes "The Reward has been successfully changed.";
  2058.                 query_sql "UPDATE `dqs_quest` SET `reward_id` = '"+.@rew_1+"' ,  `reward_am` = '"+.@rew_2+"' WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"'";
  2059.                 break;
  2060.            
  2061.                 // EXP Reward
  2062.                 case 4:
  2063.                 mes .n$;
  2064.                 mes "Current EXP Reward:";
  2065.                 if(.@rew_expt != 0) {
  2066.                     mes "Base EXP: "+.@rew_bexp + ( (.@rew_expt == 2)?"% of Total EXP":"");
  2067.                     mes "Job EXP: "+.@rew_jexp + ( (.@rew_expt == 2)?"% of Total EXP":"");
  2068.                 } else
  2069.                     mes "None";
  2070.                 mes " ";
  2071.                 mes "What do you want to do?";
  2072.                 if(select("- Change Reward:- Nothing") - 1) continue;
  2073.                 next;
  2074.                 mes .n$;
  2075.                 mes "Please choose the new EXP Reward:";
  2076.                 mes "Note: I will also ask for the new amount!";
  2077.                 set .@exp_type,select("- No EXP Reward:- Flat Amount:- Percent of Total EXP") - 1;
  2078.                 mes .n$;
  2079.                 mes "Chosen EXP Type: "+ ( (.@exp_type == 0)?"None": ( (.@exp_type == 1)?"Flat Amount":"Percent") );
  2080.                 if(.@exp_type != 0) {
  2081.                     mes "Now type the exp amount:";
  2082.                     if(.@exp_type == 1) mes "- Maximum Flat Amount: "+.rew_expflat;
  2083.                     if(.@exp_type == 2) mes "- Maximum Percent: "+.rew_expperc;
  2084.                     mes " ";
  2085.                     mes "> Base EXP:";
  2086.                     input .@rew_bexp;
  2087.                     switch(.@exp_type) {
  2088.                         case 1: if(.@rew_bexp > .rew_expflat) set .@b,1; break;
  2089.                         case 2: if(.@rew_bexp > .rew_expperc) set .@b,1; break;
  2090.                     }
  2091.                     mes "> Job EXP:";
  2092.                     input .@rew_jexp;
  2093.                     switch(.@exp_type) {
  2094.                         case 1: if(.@rew_jexp > .rew_expflat) set .@j,1; break;
  2095.                         case 2: if(.@rew_jexp > .rew_expperc) set .@j,1; break;
  2096.                     }
  2097.                     next;
  2098.                     mes .n$;
  2099.                     if(.@b || .@j) {
  2100.                         mes "You put either in Base EXP or Job EXP an invalid amount.";
  2101.                         mes "Please try again.";
  2102.                         continue;
  2103.                     }
  2104.                     mes "Base EXP: "+.@rew_bexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  2105.                     mes "Job EXP: "+.@rew_jexp + ( (.@exp_type == 2)?"% of Total EXP":"");
  2106.                     mes " ";
  2107.                     mes "Is this correct?";
  2108.                     if(select("- Yes:- No") - 1) continue;
  2109.                    
  2110.                 } else { // Reseting
  2111.                     set .@rew_bexp,0;
  2112.                     set .@rew_jexp,0;
  2113.                 }
  2114.                 next;
  2115.                 mes .n$;
  2116.                 mes "The EXP Reward has been changed successfully.";
  2117.                 query_sql "UPDATE `dqs_quest` SET `reward_exptype` = '"+.@exp_type+"' ,  `reward_bexp` = '"+.@rew_bexp+"' , `reward_jexp` = '"+.@rew_jexp+"' WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"'";
  2118.                 break;
  2119.                
  2120.                 // Move Quest
  2121.                 case 5:
  2122.                 mes .n$;
  2123.                 mes "Please choose the new Dungeon you want to asign this quest to:";
  2124.                 next;
  2125.                 set .@d_new,select(.@dg_menu$) - 1;
  2126.                 mes .n$;
  2127.                 mes "Chosen Dungeon:";
  2128.                 mes ""+.@dg_name$[.@d_new];
  2129.                 mes " ";
  2130.                 mes "Is this correct?";
  2131.                 if(select("- Yes:- No") - 1) continue;
  2132.                 next;
  2133.                 mes .n$;
  2134.                 mes "The quest has been re-asigned to ["+.@dg_name$[.@d_new]+"] successfully.";
  2135.                 query_sql "UPDATE `dqs_quest` SET `dg_id` = '"+.@dg_id[.@d_new]+"' WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@ed]+"'";
  2136.                 break;
  2137.             }
  2138.             continue;
  2139.            
  2140.             // Deleting Quests
  2141.             case 3:
  2142.             set .@r_menu$,"";
  2143.             deletearray .@q_id,getarraysize(.@q_id);
  2144.             deletearray .@q_list$,getarraysize(.@q_list$);
  2145.             mes .n$;
  2146.             query_sql "SELECT DISTINCT `quest_id` , `quest_name` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"'",.@q_id,.@q_list$;
  2147.             if(getarraysize(.@q_list$) < 1) {
  2148.                 mes "I'm sorry, but you can't remove quests from this Dungeon, because there are none yet. Please try another one.";
  2149.                 continue;
  2150.             }
  2151.             mes "Please choose, which Quest you want to remove:";
  2152.             for ( set .@q,0; .@q < getarraysize(.@q_list$); set .@q,.@q + 1)
  2153.                 set .@r_menu$,.@r_menu$ + "- "+.@q_list$[.@q]+ ( (.@q_list$[.@q+1] != "")?":":"");
  2154.             next;
  2155.             set .@rem,select(.@r_menu$) - 1;
  2156.             mes .n$;
  2157.             mes "Do you really want to remove the Quest ["+.@q_list[.@rem]+"]?";
  2158.             if(select("- Yes:- No") - 1) continue;
  2159.             next;
  2160.             mes .n$;
  2161.             mes "The Quest ["+.@q_list$[.@rem]+"] has been removed successfully.";
  2162.             query_sql "DELETE FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@rem]+"'";
  2163.             query_sql "DELETE FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id[.@d]+"' AND `quest_id` = '"+.@q_id[.@rem]+"'";
  2164.             continue;
  2165.            
  2166.             // Quest Management Options - Default
  2167.             default:
  2168.             break;
  2169.        
  2170.         } // End of Quest Management - switch(prompt())
  2171.         break;
  2172.     } // End of Quest Management - while(1)
  2173.     break;
  2174.    
  2175.     // Reward Management
  2176.     case 4:
  2177.     while(1) {
  2178.         mes .n$;
  2179.         mes "Please choose below what you want to manage:";
  2180.         next;
  2181.         switch(prompt("- Dungeon Points:- MvP Points")) {
  2182.            
  2183.             // Dungeon Points
  2184.             case 1:
  2185.             mes .n$;
  2186.             mes "[ == Dungeon Points == ]";
  2187.             mes "Please choose below which setting you want to change:";
  2188.             switch(select("- Base Points:- Dungeon Points Variable:- Shop Settings:- Previous Menu")) {
  2189.                
  2190.                 // Base Points
  2191.                 case 1:
  2192.                 next;
  2193.                 mes .n$;
  2194.                 mes "Current Base Points: "+.dg_pts;
  2195.                 mes " > 0 = Offline";
  2196.                 mes " > 1+ = Value Gained";
  2197.                 mes " ";
  2198.                 mes "Please type the new value:";
  2199.                 next;
  2200.                 input(.@rew_pts);
  2201.                 mes .n$;
  2202.                 mes "New Value: "+.@rew_pts;
  2203.                 mes " ";
  2204.                 mes "Is that correct?";
  2205.                 if(select("- Yes:- No") - 1) continue;
  2206.                 next;
  2207.                 mes .n$;
  2208.                 mes " The Base Points has been successfully changed to "+.@rew_pts;
  2209.                 set .dg_pts,.@rew_pts;
  2210.                 continue;
  2211.  
  2212.                 // Dungeon Points Variable
  2213.                 case 2:
  2214.                 next;
  2215.                 mes .n$;
  2216.                 mes "Current Variable Name: "+.dg_var$;
  2217.                 mes " > DQPoints = Default";
  2218.                 mes " ";
  2219.                 mes "Please type the new name:";
  2220.                 next;
  2221.                 input(.@rew_var$);
  2222.                 mes .n$;
  2223.                 mes "New Variable Name: "+.@rew_var$;
  2224.                 mes " ";
  2225.                 mes "Is that correct?";
  2226.                 if(select("- Yes:- No") - 1) continue;
  2227.                 next;
  2228.                 mes .n$;
  2229.                 mes " The Variable Name has been successfully changed to "+.@rew_var$;
  2230.                 set .dg_var$,.@rew_var$;
  2231.                 continue;
  2232.  
  2233.                 // Shop Settings
  2234.                 case 3:
  2235.                 while(1) {
  2236.                     deletearray .@sh_iid[0],getarraysize(.@sh_iid);
  2237.                     deletearray .@sh_price[0],getarraysize(.@sh_price);
  2238.                     next;
  2239.                     mes .n$;
  2240.                     mes "[ == Shop Settings == ]";
  2241.                     mes "Current Item List:";
  2242.                     query_sql "SELECT `item_id` , `item_price` FROM `dqs_shop` WHERE `type` = '1'",.@sh_iid,.@sh_price;
  2243.                     if(getarraysize(.@sh_iid) < 1)
  2244.                         mes "There are no Items yet.";
  2245.                     else
  2246.                         for ( set .@i,0; .@i < getarraysize(.@sh_iid); set .@i,.@i + 1)
  2247.                             mes " > "+getitemname(.@sh_iid[.@i])+" - Price: "+.@sh_price[.@i];
  2248.                     mes " ";
  2249.                     next;
  2250.                     switch(prompt("- Add Item:- Edit Item:- Remove Item:- Back to Reward Management")) {
  2251.                        
  2252.                         // Add Item
  2253.                         case 1:
  2254.                         mes .n$;
  2255.                         if(getarraysize(.@sh_iid) == .max_shop) {
  2256.                             mes "I'm sorry, but you can't add anymore Items to the Shop.";
  2257.                             mes "Please delete an item or edit an existing one.";
  2258.                             continue;
  2259.                         }
  2260.                         mes "Please insert now the following in the same order:";
  2261.                         mes " > Item ID";
  2262.                         mes " > Price";
  2263.                         next;
  2264.                         mes .n$;
  2265.                         mes "[ == Item ID == ]";
  2266.                         input(.@i_id);
  2267.                         if(getitemname(.@i_id) == "") {
  2268.                             next;
  2269.                             mes .n$;
  2270.                             mes "Unknown Item, please try another one.";
  2271.                             continue;
  2272.                         }
  2273.                         mes " > Input: "+.@i_id+" ("+getitemname(.@i_id)+")";
  2274.                         mes "[ == Price == ]";
  2275.                         input(.@i_cost);
  2276.                         mes " > Input: "+.@i_cost;
  2277.                         mes " ";
  2278.                         mes "Is this correct?";
  2279.                         if(select("- Yes:- No") - 1) continue;
  2280.                         next;
  2281.                         mes .n$;
  2282.                         mes getitemname(.@i_id)+" (ID: "+.@i_id+") with a Price of "+.@i_cost+" has been added successfully to the Dungeon Points Shop.";
  2283.                         query_sql "INSERT INTO `dqs_shop` ( `type` , `item_id` , `item_price` ) VALUES ( '1' , '"+.@i_id+"' , '"+.@i_cost+"' )";
  2284.                         continue;
  2285.                        
  2286.                         // Edit Item
  2287.                         case 2:
  2288.                         mes .n$;
  2289.                         if(getarraysize(.@sh_iid) < 1) {
  2290.                             mes "I'm sorry, but there are no Items you could edit in the Shop.";
  2291.                             mes "Please add an item first.";
  2292.                             continue;
  2293.                         }
  2294.                         set .@dgx_m$,"";
  2295.                         mes "Please select an Item to edit from below:";
  2296.                         next;
  2297.                         for ( set .@r,0; .@r < getarraysize(.@sh_iid); set .@r,.@r + 1)
  2298.                             set .@dgx_m$,.@dgx_m$ + "- "+getitemname(.@sh_iid[.@r])+" (ID - "+.@sh_iid[.@r]+")"+ ( (.@sh_iid[.@r+1] != 0)?":":"");
  2299.                            
  2300.                         set .@i_ed,select(.@dgx_m$) - 1;
  2301.                        
  2302.                         mes .n$;
  2303.                         mes "Item: "+getitemname(.@sh_iid[.@i_ed])+" (ID: "+.@sh_iid[.@i_ed]+")";
  2304.                         mes "Price: "+.@sh_price[.@i_ed];
  2305.                         mes " ";
  2306.                         mes "Is this correct?";
  2307.                         if(select("- Yes:- No") - 1) continue;
  2308.                         next;
  2309.                         mes .n$;
  2310.                         mes "Please choose which value you want to edit:";
  2311.                         next;
  2312.                         switch(prompt("- Item ID:- Price")) {
  2313.                        
  2314.                             // Edit Item ID
  2315.                             case 1:
  2316.                             mes .n$;
  2317.                             mes "Current Item ID: "+.@sh_iid[.@i_ed];
  2318.                             mes " ";
  2319.                             mes "Please type the new value:";
  2320.                             next;
  2321.                             input(.@id_new);
  2322.                             mes .n$;
  2323.                             if(getitemname(.@id_new) == "" || getitemname(.@id_new) == "null") {
  2324.                                 mes "Invalid Item ID, please try again.";
  2325.                                 continue;
  2326.                             }
  2327.                             mes "Chosen Item: "+getitemname(.@id_new)+" ("+.@id_new+")";
  2328.                             mes " ";
  2329.                             mes "Is this correct?";
  2330.                             if(select("- Yes:- No") - 1) continue;
  2331.                             next;
  2332.                             mes .n$;
  2333.                             mes "The Item ID has been changed successfully to "+.@id_new;
  2334.                             query_sql "UPDATE `dqs_shop` SET `item_id` = '"+.@id_new+"' WHERE `type` = '1' AND `item_id` = '"+.@sh_iid[.@i_ed]+"'";
  2335.                             continue;
  2336.                            
  2337.                             // Edit Price
  2338.                             case 2:
  2339.                             mes .n$;
  2340.                             mes "Current Price: "+.@sh_price[.@i_ed];
  2341.                             mes " ";
  2342.                             mes "Please type the new value:";
  2343.                             next;
  2344.                             input(.@cost_new);
  2345.                             mes .n$;
  2346.                             if(.@cost_new < 1) {
  2347.                                 mes "Invalid Price, can't be below 1, please try again.";
  2348.                                 continue;
  2349.                             }
  2350.                             mes "New Value: "+.@cost_new;
  2351.                             mes " ";
  2352.                             mes "Is this correct?";
  2353.                             if(select("- Yes:- No") - 1) continue;
  2354.                             next;
  2355.                             mes .n$;
  2356.                             mes "The Price has been changed successfully to "+.@cost_new;
  2357.                             query_sql "UPDATE `dqs_shop` SET `item_price` = '"+.@cost_new+"' WHERE `type` = '1' AND `item_id` = '"+.@sh_iid[.@i_ed]+"'";
  2358.                             continue;
  2359.                            
  2360.                             // Cancel Button
  2361.                             default:
  2362.                             break;
  2363.                         }
  2364.                         continue;
  2365.                        
  2366.                         // Remove item
  2367.                         case 3:
  2368.                         mes .n$;
  2369.                         if(getarraysize(.@sh_iid) < 1) {
  2370.                             mes "I'm sorry, but there are no Items you could remove in the Shop.";
  2371.                             mes "Please add an item first.";
  2372.                             continue;
  2373.                         }
  2374.                         mes "Please select an Item to remove from below:";
  2375.                         next;
  2376.                         for ( set .@r,0; .@r < getarraysize(.@sh_iid); set .@r,.@r + 1)
  2377.                             set .@dgx_m$,.@dgx_m$ + "- "+getitemname(.@sh_iid[.@r])+" (ID - "+.@sh_iid[.@r]+")"+ ( (.@sh_iid[.@r+1] != 0)?":":"");
  2378.                            
  2379.                         set .@i_rem,select(.@dgx_m$) - 1;
  2380.                        
  2381.                         mes .n$;
  2382.                         mes "Chosen Item: "+getitemname(.@sh_iid[.@i_rem])+" (ID: "+.@sh_iid[.@i_rem]+")";
  2383.                         mes " ";
  2384.                         mes "Is this correct?";
  2385.                         if(select("- Yes:- No") - 1) continue;
  2386.                         next;
  2387.                         mes .n$;
  2388.                         mes "The Item "+getitemname(.@sh_iid[.@i_rem])+" (ID: "+.@sh_iid[.@i_rem]+") has been removed successfully from the Dungeon Points Shop.";
  2389.                         query_sql "DELETE FROM `dqs_shop` WHERE `type` = '1' AND `item_id` = '"+@sh_iid[.@i_rem]+"'";
  2390.                         continue;
  2391.                        
  2392.                         // Back to Reward Management Menu
  2393.                         default:
  2394.                         break;
  2395.                        
  2396.                     } // End of Shop Settings - switch(prompt())
  2397.                     break;
  2398.                    
  2399.                 } // End of Shop Settings - while(1)
  2400.                 continue;
  2401.                
  2402.                 // Previous Menu
  2403.                 default:
  2404.                 break;
  2405.             }
  2406.             continue;
  2407.  
  2408.             // MvP Points
  2409.             case 2:
  2410.             mes .n$;
  2411.             mes "[ == MvP Points == ]";
  2412.             mes "Please choose below which setting you want to change:";
  2413.             next;
  2414.             switch(select("- Base Points:- MvP Points Variable:- Shop Settings:- Previous Menu")) {
  2415.            
  2416.                 // Base Points
  2417.                 case 1:
  2418.                 mes .n$;
  2419.                 mes "Current Base Points: "+.mvp_pts;
  2420.                 mes " > 0 = Offline";
  2421.                 mes " > 1+ = Value Gained";
  2422.                 mes " ";
  2423.                 mes "Please type the new value:";
  2424.                 next;
  2425.                 input(.@rew_pts);
  2426.                 mes .n$;
  2427.                 mes "New Value: "+.@rew_pts;
  2428.                 mes " ";
  2429.                 mes "Is that correct?";
  2430.                 if(select("- Yes:- No") - 1) continue;
  2431.                 next;
  2432.                 mes .n$;
  2433.                 mes " The Base Points has been successfully changed to "+.@rew_pts;
  2434.                 set .mvp_pts,.@rew_pts;
  2435.                 continue;
  2436.                
  2437.                 // Dungeon Points Variable
  2438.                 case 2:
  2439.                 mes .n$;
  2440.                 mes "Current Variable Name: "+.mvp_var$;
  2441.                 mes " > DMvP_Pts = Default";
  2442.                 mes " ";
  2443.                 mes "Please type the new name:";
  2444.                 next;
  2445.                 input(.@rew_var$);
  2446.                 mes .n$;
  2447.                 mes "New Variable Name: "+.@rew_var$;
  2448.                 mes " ";
  2449.                 mes "Is that correct?";
  2450.                 if(select("- Yes:- No") - 1) continue;
  2451.                 next;
  2452.                 mes .n$;
  2453.                 mes "The Variable Name has been successfully changed to "+.@rew_var$;
  2454.                 set .mvp_var$,.@rew_var$;
  2455.                 continue;
  2456.                
  2457.                 // Shop Settings
  2458.                 case 3:
  2459.                 while(1) {
  2460.                     deletearray .@sh_iid[0],getarraysize(.@sh_iid);
  2461.                     deletearray .@sh_price[0],getarraysize(.@sh_price);
  2462.                     next;
  2463.                     mes .n$;
  2464.                     mes "[ == Shop Settings == ]";
  2465.                     mes "Current Item List:";
  2466.                     query_sql "SELECT `item_id` , `item_price` FROM `dqs_shop` WHERE `type` = '2'",.@sh_iid,.@sh_price;
  2467.                     if(getarraysize(.@sh_iid) < 1)
  2468.                         mes "There are no Items yet.";
  2469.                     else
  2470.                         for ( set .@i,0; .@i < getarraysize(.@sh_iid); set .@i,.@i + 1)
  2471.                             mes " > "+getitemname(.@sh_iid[.@i])+" - Price: "+.@sh_price[.@i];
  2472.                     mes " ";
  2473.                     mes "Please choose what do do:";
  2474.                     next;
  2475.                     switch(prompt("- Add Item:- Edit Item:- Remove Item:- Back to Reward Management")) {
  2476.                        
  2477.                         // Add Item
  2478.                         case 1:
  2479.                         mes .n$;
  2480.                         if(getarraysize(.@sh_iid) == .max_shop) {
  2481.                             mes "I'm sorry, but you can't add anymore Items to the Shop.";
  2482.                             mes "Please delete an item or edit an existing one.";
  2483.                             continue;
  2484.                         }
  2485.                         mes "Please insert now the following in the same order:";
  2486.                         mes " > Item ID";
  2487.                         mes " > Price";
  2488.                         next;
  2489.                         mes .n$;
  2490.                         mes "[ == Item ID == ]";
  2491.                         input(.@i_id);
  2492.                         if(getitemname(.@i_id) == "") {
  2493.                             next;
  2494.                             mes .n$;
  2495.                             mes "Unknown Item, please try another one.";
  2496.                             continue;
  2497.                         }
  2498.                         mes " > Input: "+.@i_id+" ("+getitemname(.@i_id)+")";
  2499.                         mes "[ == Price == ]";
  2500.                         input(.@i_cost);
  2501.                         mes " > Input: "+.@i_cost;
  2502.                         mes " ";
  2503.                         mes "Is this correct?";
  2504.                         if(select("- Yes:- No") - 1) continue;
  2505.                         next;
  2506.                         mes .n$;
  2507.                         mes getitemname(.@i_id)+" (ID: "+.@i_id+") with a Price of "+.@i_cost+" has been added successfully to the Dungeon Points Shop.";
  2508.                         query_sql "INSERT INTO `dqs_shop` ( `type` , `item_id` , `item_price` ) VALUES ( '2' , '"+.@i_id+"' , '"+.@i_cost+"' )";
  2509.                         continue;
  2510.                        
  2511.                         // Edit Item
  2512.                         case 2:
  2513.                         mes .n$;
  2514.                         if(getarraysize(.@sh_iid) < 1) {
  2515.                             mes "I'm sorry, but there are no Items you could edit in the Shop.";
  2516.                             mes "Please add an item first.";
  2517.                             continue;
  2518.                         }
  2519.                         set .@dgx_m$,"";
  2520.                         mes "Please select an Item to edit from below:";
  2521.                         next;
  2522.                         for ( set .@r,0; .@r < getarraysize(.@sh_iid); set .@r,.@r + 1)
  2523.                             set .@dgx_m$,.@dgx_m$ + "- "+getitemname(.@sh_iid[.@r])+" (ID - "+.@sh_iid[.@r]+")"+ ( (.@sh_iid[.@r+1] != 0)?":":"");
  2524.                            
  2525.                         set .@i_ed,select(.@dgx_m$) - 1;
  2526.                        
  2527.                         mes .n$;
  2528.                         mes "Item: "+getitemname(.@sh_iid[.@i_ed])+" (ID: "+.@sh_iid[.@i_ed]+")";
  2529.                         mes "Price: "+.@sh_price[.@i_ed];
  2530.                         mes " ";
  2531.                         mes "Is this correct?";
  2532.                         if(select("- Yes:- No") - 1) continue;
  2533.                         next;
  2534.                         mes .n$;
  2535.                         mes "Please choose which value you want to edit:";
  2536.                         next;
  2537.                         switch(prompt("- Item ID:- Price")) {
  2538.                        
  2539.                             // Edit Item ID
  2540.                             case 1:
  2541.                             mes .n$;
  2542.                             mes "Current Item ID: "+.@sh_iid[.@i_ed];
  2543.                             mes " ";
  2544.                             mes "Please type the new value:";
  2545.                             next;
  2546.                             input(.@id_new);
  2547.                             mes .n$;
  2548.                             if(getitemname(.@id_new) == "" || getitemname(.@id_new) == "null") {
  2549.                                 mes "Invalid Item ID, please try again.";
  2550.                                 continue;
  2551.                             }
  2552.                             mes "Chosen Item: "+getitemname(.@id_new)+" ("+.@id_new+")";
  2553.                             mes " ";
  2554.                             mes "Is this correct?";
  2555.                             if(select("- Yes:- No") - 1) continue;
  2556.                             next;
  2557.                             mes .n$;
  2558.                             mes "The Item ID has been changed successfully to "+.@id_new;
  2559.                             query_sql "UPDATE `dqs_shop` SET `item_id` = '"+.@id_new+"' WHERE `type` = '2' AND `item_id` = '"+.@sh_iid[.@i_ed]+"'";
  2560.                             continue;
  2561.                            
  2562.                             // Edit Price
  2563.                             case 2:
  2564.                             mes .n$;
  2565.                             mes "Current Price: "+.@sh_price[.@i_ed];
  2566.                             mes " ";
  2567.                             mes "Please type the new value:";
  2568.                             next;
  2569.                             input(.@cost_new);
  2570.                             mes .n$;
  2571.                             if(.@cost_new < 1) {
  2572.                                 mes "Invalid Price, can't be below 1, please try again.";
  2573.                                 continue;
  2574.                             }
  2575.                             mes "New Value: "+.@cost_new;
  2576.                             mes " ";
  2577.                             mes "Is this correct?";
  2578.                             if(select("- Yes:- No") - 1) continue;
  2579.                             next;
  2580.                             mes .n$;
  2581.                             mes "The Price has been changed successfully to "+.@cost_new;
  2582.                             query_sql "UPDATE `dqs_shop` SET `item_price` = '"+.@cost_new+"' WHERE `type` = '2' AND `item_id` = '"+.@sh_iid[.@i_ed]+"'";
  2583.                             continue;
  2584.                            
  2585.                             // Cancel Button
  2586.                             default:
  2587.                             break;
  2588.                         }
  2589.                         continue;
  2590.                        
  2591.                         // Remove item
  2592.                         case 3:
  2593.                         mes .n$;
  2594.                         if(getarraysize(.@sh_iid) < 1) {
  2595.                             mes "I'm sorry, but there are no Items you could remove in the Shop.";
  2596.                             mes "Please add an item first.";
  2597.                             continue;
  2598.                         }
  2599.                         mes "Please select an Item to remove from below:";
  2600.                         next;
  2601.                         for ( set .@r,0; .@r < getarraysize(.@sh_iid); set .@r,.@r + 1)
  2602.                             set .@dgx_m$,.@dgx_m$ + "- "+getitemname(.@sh_iid[.@r])+" (ID - "+.@sh_iid[.@r]+")"+ ( (.@sh_iid[.@r+1] != 0)?":":"");
  2603.                            
  2604.                         set .@i_rem,select(.@dgx_m$) - 1;
  2605.                        
  2606.                         mes .n$;
  2607.                         mes "Chosen Item: "+getitemname(.@sh_iid[.@i_rem])+" (ID: "+.@sh_iid[.@i_rem]+")";
  2608.                         mes " ";
  2609.                         mes "Is this correct?";
  2610.                         if(select("- Yes:- No") - 1) continue;
  2611.                         next;
  2612.                         mes .n$;
  2613.                         mes "The Item "+getitemname(.@sh_iid[.@i_rem])+" (ID: "+.@sh_iid[.@i_rem]+") has been removed successfully from the Dungeon Points Shop.";
  2614.                         query_sql "DELETE FROM `dqs_shop` WHERE `type` = '2' AND `item_id` = '"+.@sh_iid[.@i_rem]+"'";
  2615.                         continue;
  2616.                        
  2617.                         // Back to Reward Management Menu
  2618.                         default:
  2619.                         break;
  2620.                        
  2621.                     } // End of MvP Shop Settings - switch(prompt())
  2622.                     break;
  2623.                 } // End of MvP Shop Settings - while(1)
  2624.                 continue;
  2625.                
  2626.                 // Previous Menu
  2627.                 default:
  2628.                 break;
  2629.             } // End of MvP Shop Menu - switch(prompt())
  2630.             continue;
  2631.            
  2632.             // Cancel Button
  2633.             default:
  2634.             break;
  2635.         } // End of Reward Management - switch(prompt())
  2636.         break;
  2637.     } // End of Reward Management - while(1)
  2638.     break;     
  2639.    
  2640.     // Nevermind
  2641.     case 5:
  2642.     break;
  2643.     }
  2644. end;
  2645.  
  2646. OnInit:
  2647. // Dungeon Quest System not loaded yet
  2648. set $@DQS_Sys,0;
  2649. // =============== NPC Name ===============
  2650. set .n$,"["+strnpcinfo(1)+"]";
  2651. // =============== Debug Mode ===============
  2652. // * (Debug Messages in Map Server)
  2653. // > 0: Off
  2654. // > 1: On
  2655. set .debug,0;
  2656. set .gm,80; // GM Access Level
  2657. // ============== Dungeon Settings ================== //
  2658. setarray .exp[1],20,50,75; // EXP Rate in % for Difficulty: Easy/Medium/Hard
  2659. set .max_exp,500; // Max EXP Rate Settings for GM Panel
  2660. // * Allow choosing the floor to be warped to
  2661. // 1 = Enabled
  2662. // 0 = Disabled
  2663. set .dg_floor,1;
  2664. // ==== Dungeon Delay Settings ======
  2665. // * Max Dungeon Limit:
  2666. // (How often an dungeon can be done till the delay below comes active)
  2667. // Note: Don't use 0, that's used in the dungeon management
  2668. set .dg_max_limit,1000;
  2669. // * Type:
  2670. // - 1: Hour
  2671. // - 2: Day
  2672. // - 3: Week
  2673. // - 4: Month
  2674. set .dg_del_type,2;
  2675. // * Calculation Values in seconds
  2676. // Note: These values will be multiplied by Dungeon Difficulty later on.
  2677. switch(.q_del_type) {
  2678.     case 1: set .dg_delay,3600; break;
  2679.     case 2: set .dg_delay,86400; break;
  2680.     case 3: set .dg_delay,604800; break;
  2681.     case 4: set .dg_delay,2592000; break;
  2682. }
  2683. // ===== Quest Settings =====
  2684. // * Maximum Quests
  2685. set .max_quests,100;
  2686. // * Minimum and Maximum Mob Amount
  2687. set .mob_min,1;
  2688. set .mob_max,100;
  2689. // * Maximum Mobs you can hunt at the same time
  2690. set .mob_ct,3;
  2691. // * Level Restriction
  2692. // Note: If you compiled to an much higher value than you really use, put the real value instead.
  2693. set .level,MAX_LEVEL; // 0 = Off / MAX_LEVEL - Server Max Level (src/map/map.h)
  2694. // * Minimum and Maximum Item Amount
  2695. set .item_min,1;
  2696. set .item_max,200;
  2697. // * Maximum Items you can collect at the same time
  2698. set .item_ct,5;
  2699. // * Maximum Quests to display per Page
  2700. set .pg_entries,30;
  2701. // ==== Reward Settings per Quest ====
  2702. // * Maximum Zeny Amount
  2703. set .rew_zeny,10000000; // 10m Zeny
  2704. // * Allow usage of variables?
  2705. // = 1: Yes
  2706. // = 0: No
  2707. set .rew_vart,1;
  2708. if(.rew_vart == 1) {
  2709.     // * Display Text of the Variable for the players
  2710.     set .rew_vard$,"Cash Points";
  2711.     // * Variable Name
  2712.     set .rew_varn$,"#CASHPOINTS";
  2713.     // * Maximum Variable Points Amount
  2714.     set .rew_var,1000;
  2715. }
  2716. // * Pre-Defined Item ID
  2717. set .rew_itemid,6480; // 6480 = Poring Coin
  2718. // * Maximum Item Amount
  2719. set .rew_item,10000;
  2720. // * Maximum Item Weight
  2721. // (= Item Weight* Reward Amount)
  2722. set .rew_weight,10000;
  2723. // * Maximum EXP Amount
  2724. set .rew_expflat,100000000; // 100m EXP
  2725. set .rew_expperc,75; // 75% of Total EXP
  2726. // ========================
  2727. // Dungeon Reward > 0 = Off, 1+ = Base Dungeon Quest Points, will be multiplied by Difficulty
  2728. set .dg_pts,10;
  2729. if(.dg_pts > 0)
  2730.     set .dg_var$,"DQPoints";
  2731. // MvP Reward for each MvP > 0 = Off, 1+ = Base MvP Points, will also be multiplied by Difficulty
  2732. set .mvp_pts,5;
  2733. if(.mvp_pts > 0)
  2734.     set .mvp_var$,"DMVPPoints";
  2735. // * Maximum Items in the Shop
  2736. set .max_shop,100;
  2737. // Use Mapflags?
  2738. // 0 = Disabled
  2739. // 1 = Enabled
  2740. set .dg_mf,1;
  2741. // Put the mapflags here
  2742. if(.dg_mf) {
  2743.     setarray .mapfl[0],mf_nowarp,mf_partylock;
  2744.     query_sql "SELECT `map_name` FROM `dqs_dungeon`",.@map_name$;
  2745.     for ( set .@m,0; .@m < getarraysize(.@map_name$); set .@m,.@m + 1)
  2746.         for ( set .@mf,0; .@mf < getarraysize(.mapfl); set .@mf,.@mf + 1)
  2747.             setmapflag .@map_name$[.@m],.mapfl[.@mf];
  2748. }
  2749. // Custom atcommand: @checkdq
  2750. bindatcmd "checkdg",strnpcinfo(1)+"::OnPCLoginEvent";
  2751. if(.debug) debugmes "Starting Global Timer for Party Member Sync";
  2752. initnpctimer; // Timer for Party Check
  2753.  
  2754. query_sql "SHOW TABLES LIKE 'dqs_quest'",.@dqs_tab$;
  2755. if(.@dqs_tab$[0] == "") {
  2756.     announce "[Server]: Dungeon Quests Database not installed, therefore it won't be available.",bc_all|bc_yellow;
  2757.     end;
  2758. }
  2759. if(query_sql("SHOW TABLES LIKE 'dqs_shop'",.@db) == 0)
  2760.     query_sql "CREATE TABLE `dqs_shop` ( `type` tinyint(3) NOT NULL, `item_id` int(10) NOT NULL, `item_price` int(10) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1";
  2761. set $@DQS_Sys,1;
  2762. announce "[Server]: Dungeon Quest Service: "+ ( ($@DQS_Sys == 1)?"Online":"Offline"),bc_all|bc_yellow;
  2763. end;
  2764.  
  2765. OnNPCKillEvent:
  2766. if(!$@DQS_Sys) end;
  2767. set .KilledMob,killedrid;
  2768. set .map$,strcharinfo(3);
  2769. // Player in Party?
  2770. if(getcharid(1) != 0)
  2771.     addrid(2,1,getcharid(1));
  2772. // Checking if the party members are on the same Map as the one who killed an Mob
  2773. if(strcharinfo(3) != .map$)
  2774.     end;
  2775. // Checking if either @dg_id or @map$ is not set
  2776. if(!@dg_id || @map$ == "")
  2777.     query_sql "SELECT `dg_id` , `start` , `map` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",@dg_id,@cp,@map$;
  2778. // Checking if @diff isn't set
  2779. if(!@diff)
  2780.     query_sql "SELECT `difficulty` FROM `dqs_dungeon` WHERE `dg_id` = '"+@dg_id+"'",@diff;
  2781. // Checking the map of the player with @map$
  2782. if(strcharinfo(3) != @map$)
  2783.     if(query_sql("SELECT `floor` , `status` , `map_name` FROM `dqs_dungeon` WHERE `dg_id` = '"+@dg_id+"' AND `map_name` = '"+strcharinfo(3)+"'",@cp,@stat,@map$) != 0)
  2784.         query_sql "UPDATE `dqs_party` SET `start` = '"+@cp+"' , `map` = '"+strcharinfo(3)+"' WHERE `dg_id` = '"+@dg_id+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'";
  2785.     else
  2786.         end;
  2787. // Checking if the service is enabled on this floor
  2788. if(!@stat)
  2789.     query_sql "SELECT `status` FROM `dqs_dungeon` WHERE `dg_id` = '"+@dg_id+"' AND `map_name` = '"+@map$+"'",@stat;
  2790. if(@stat != 2)
  2791.     end;
  2792. // Monster Quest available?
  2793. if(query_sql("SELECT `mob_id` , `req_am` , `mob_am` FROM `dqs_party` WHERE `"+( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `quest_id` != '1'",.@mob_id,.@req_am,.@mob_am) != 0) {
  2794.     // Checking if the arrays was created
  2795.     if(getarraysize(@dqs_mob) == 0) {
  2796.         if(getarraysize(.@mob_id) > 0)
  2797.             for ( set .@m,0; .@m < getarraysize(.@mob_id); set .@m,.@m + 1) {
  2798.                 setarray @dqs_mob[.@m],.@mob_id[.@m];
  2799.                 setarray @dqs_req[.@m],.@req_am[.@m];
  2800.                 setarray @dqs_am[.@m],.@mob_am[.@m];
  2801.             }
  2802.     } else {
  2803.         query_sql "SELECT `name` FROM `dqs_dungeon` WHERE `dg_id` = '"+@dg_id+"'",@dg_name$;
  2804.         // Afterwards going through the Array and increase the Counter of the position in the respective array
  2805.         for ( set .@r,0; .@r < getarraysize(@dqs_mob); set .@r,.@r + 1) {
  2806.             if(.debug) {
  2807.                 debugmes "Player: "+strcharinfo(0)+", Party ID: "+getcharid(1);
  2808.                 debugmes "Checking @dqs_mob["+.@r+"] = "+@dqs_mob[.@r];
  2809.                 debugmes "Checking @dqs_am["+.@r+"] = "+@dqs_am[.@r];
  2810.                 debugmes "Checking @dqs_req["+.@r+"] = "+@dqs_req[.@r];
  2811.             }
  2812.             if(.KilledMob == @dqs_mob[.@r] && @dqs_am[.@r] < @dqs_req[.@r]) {
  2813.                 setarray @dqs_am[.@r],@dqs_am[.@r] + 1;
  2814.                 message strcharinfo(0),"["+@dg_name$+"]: "+strmobinfo(1,.KilledMob)+": "+@dqs_am[.@r]+"/"+@dqs_req[.@r];
  2815.             }
  2816.         }
  2817.     }
  2818. }
  2819. // Killed MvP > rewarding with points if .mvp_pts > 0
  2820. // Don't change the "killedrid" into ".KilledMob" except you also want that the party members gets the Points
  2821. if(getmonsterinfo(killedrid,MOB_MVPEXP) > 0 && .mvp_pts > 0) {
  2822.     setd(""+.mvp_var$),getd(""+.mvp_var$) + (.mvp_pts*@diff);
  2823.     dispbottom .n$+": Recieved MVP Points: "+(.mvp_pts*@diff)+"x MvP Points.";
  2824. }  
  2825. set MobsKilled,MobsKilled + 1;
  2826.  
  2827. // Member is alive
  2828. if(readparam(5) < 1) end;
  2829.  
  2830. // Reading EXP values from Mob Database
  2831. set .@expr,.exp[@diff];
  2832. set .@bexp,(getmonsterinfo(.KilledMob,3)*.@expr)/100;
  2833. set .@jexp,(getmonsterinfo(.KilledMob,4)*.@expr)/100;
  2834.  
  2835. if(.@bexp && .@jexp) {
  2836.     getexp2 .@bexp,.@jexp;
  2837.     dispbottom .n$+": EXP Bonus: "+.@expr+"% - Base EXP: "+.@bexp+"/Job EXP: "+.@jexp;
  2838. }
  2839. end;
  2840.  
  2841. // OnLogin List and AtCommand
  2842. OnPCLoginEvent:
  2843. if(!$@DQS_Sys) end;
  2844. query_sql "SELECT DISTINCT `quest_id` , `dg_id` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",.@q_id,.@dg_id;
  2845. if(getarraysize(.@q_id) < 1) end;
  2846. set .@n$,"[Dungeon Quests]";
  2847. dispbottom .@n$+": You have "+(getarraysize(.@q_id)-1)+" active Quests.";
  2848.  
  2849.  
  2850. // Displaying Quest Progress
  2851. for ( set .@l,0; .@l < getarraysize(.@q_id); set .@l,.@l + 1) {
  2852.     if(.@q_id[.@l] == 1)  continue;
  2853.     query_sql "SELECT DISTINCT `quest_name` , `quest_type` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@q_name$,.@q_type;
  2854.     dispbottom "  [* ====== "+.@q_name$+" - Progress: ====== *]  ";
  2855.     dispbottom "  >  Type: "+( (.@q_type == 1)?"Monster Hunting":"Item Collecting");
  2856.     if(.@q_type == 1)
  2857.         query_sql "SELECT `mob_id` , `mob_am` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
  2858.     else
  2859.         query_sql "SELECT `item_id` , `item_am` FROM `dqs_quest` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@l]+"'",.@req1,.@req2;
  2860.    
  2861.     // Updating SQL Table for Monster Hunting Quests
  2862.     for ( set .@m,0; .@m < getarraysize(@dqs_mob); set .@m,.@m + 1)
  2863.         query_sql "UPDATE `dqs_party` SET `mob_am` = '"+@dqs_am[.@m]+"' WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `mob_id` = '"+@dqs_mob[.@m]+"' AND `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@l]+"'";
  2864.    
  2865.     for ( set .@p,0; .@p < getarraysize(.@req1); set .@p,.@p + 1)
  2866.         if(.@q_type == 1) {
  2867.             query_sql "SELECT `mob_am` FROM `dqs_party` WHERE `dg_id` = '"+.@dg_id+"' AND `quest_id` = '"+.@q_id[.@l]+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `mob_id` = '"+.@req1[.@p]+"'",.@m_got;
  2868.             dispbottom "  >  Mob#"+(.@p+1)+": "+strmobinfo(1,.@req1[.@p])+" - "+.@m_got+"/"+.@req2[.@p];
  2869.         } else
  2870.             dispbottom "  >  Item#"+(.@p+1)+": "+getitemname(.@req1[.@p])+" - "+countitem(.@req1[.@p])+"/"+.@req2[.@p];
  2871. }
  2872. end;
  2873.  
  2874. // Every 15th Minute, check if there are non-existent party entries in the database
  2875. OnTimer900000:
  2876. stopnpctimer;
  2877. if(.debug) debugmes "OnTimer Executed at 15 Minute:";
  2878. query_sql "SELECT `pty_id` FROM `dqs_party`",.@pty_id;
  2879. for ( set .@p,0; .@p < getarraysize(.@pty_id); set .@p,.@p + 1)
  2880.     if(query_sql("SELECT `party_id` FROM `party` WHERE `party_id` = '"+.@pty_id[.@p]+"'",.@p_id) == -1) {
  2881.         query_sql "DELETE FROM `dqs_party` WHERE `pty_id` = '"+.@pty_id[.@p]+"'";
  2882.         query_sql "DELETE FROM `dqs_app` WHERE `pty_id` = '"+.@pty_id[.@p]+"'";
  2883.     }
  2884.  
  2885. if(.debug) debugmes "Restarting Timer....";
  2886. initnpctimer;
  2887. end;
  2888.  
  2889. OnPCLogoutEvent:
  2890. if(!$@DQS_Sys) end;
  2891. // Not registered
  2892. if(query_sql("SELECT `dg_id` FROM `dqs_party` WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",@dg_id) == 0)
  2893.     end;
  2894. if(query_sql("SELECT `mob_id` FROM `dqs_party` WHERE `"+( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `quest_id` != '1'",.@mob_id) == 0)
  2895.     end;
  2896. for ( set .@m,0; .@m < getarraysize(@dqs_mob); set .@m,.@m + 1)
  2897.     // Updating SQL Table for Monster Hunting Quests
  2898.     query_sql "UPDATE `dqs_party` SET `mob_am` = '"+@dqs_am[.@m]+"' WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `mob_id` = '"+@dqs_mob[.@m]+"' AND `dg_id` = '"+.@dg_id+"'";
  2899. end;
  2900.  
  2901. // Function for Pagination
  2902. // Preventing string limitation error for menus
  2903. //
  2904. // *getarg(0) = Array Content for the Menu Selection
  2905. //  You can save everything into the array, like Color Codes, Symbols like "( )"
  2906. //  ex.: [0] = "- Mob ID (Map)"
  2907. // *getarg(1) = Max Entries per Page
  2908. //
  2909. // ex.: set .@c,callfunc("F_Pages",implode(<Array Name$>,":"),<Max. Entries per Page >);
  2910. // The return value is the @menu value
  2911. function    F_Pages {
  2912.  
  2913.     explode(.@pg_array$,getarg(0),":"); // Re-Saving string into Array
  2914.     set .@pg_count,getarraysize(.@pg_array$)/getarg(1); // Calculating max pages based on getarg(1)
  2915.     if(!.@pg_count)
  2916.         set .@pg_count,1;
  2917.  
  2918.     set .@cur_pg,1;
  2919.    
  2920.     while(1) {
  2921.         if(.@cur_pg == 1)
  2922.             set .@p,0;
  2923.         else
  2924.             set .@p,.@c+(getarg(1)*(.@cur_pg-1));
  2925.            
  2926.         if(.@cur_pg > 1 && .@cur_pg < .@pg_count) {
  2927.             set .@q_pg$,":- Next Page:- Previous Page";
  2928.             set .@pg_opt,2;
  2929.         } else if(.@cur_pg > 1 && .@cur_pg == .@pg_count) {
  2930.             set .@q_pg$,":- Previous Page";
  2931.             set .@pg_opt,3;
  2932.         } else if(.@cur_pg == 1 && .@cur_pg < .@pg_count) {
  2933.             set .@q_pg$,":- Next Page";
  2934.             set .@pg_opt,1;
  2935.         } else { // Only when there are not more than getarg(1) entries
  2936.             set .@q_pg$,"";
  2937.             set .@pg_opt,0;
  2938.         }
  2939.         set .@pg_m$,"";
  2940.         set .@e_ct,0;
  2941.         for ( set .@q,.@p; .@q < getarraysize(.@pg_array$); set .@q,.@q + 1) {
  2942.             if((.@q+1)%getarg(1) == 0) break;
  2943.             set .@pg_m$,.@pg_m$ + .@pg_array$[.@q] + ( (.@pg_array$[.@q+1] != "")?":":"");
  2944.             set .@e_ct,.@e_ct + 1;
  2945.         }
  2946.  
  2947.         set .@pg_m$,.@pg_m$ + .@q_pg$;
  2948.         set .@c,select(.@pg_m$) - 1;
  2949.         if((.@c*.@cur_pg)/.@e_ct > 0) {
  2950.             switch(.@pg_opt) {
  2951.                 case 1: set .@cur_pg,.@cur_pg + 1; break;
  2952.                 case 2:
  2953.                 if(.@c%.@e_ct == 1)
  2954.                     set .@cur_pg,.@cur_pg + 1;
  2955.                 else if(.@c%.@e_ct == 2)
  2956.                     set .@cur_pg,.@cur_pg - 1;
  2957.                 break;
  2958.                 case 3: set .@cur_pg,.@cur_pg - 1; break;
  2959.             }
  2960.             continue;
  2961.         } else
  2962.             break;
  2963.     }
  2964. return .@c;
  2965. }
  2966. // Function to retrieve the Mob ID's or Item ID's from the SQL Database
  2967. // Usage:
  2968. // setarray .@array, < Map names >;
  2969. // For Mob ID:
  2970. // set .@id,F_GetMobData(implode(.@array$,":"));
  2971. // For Item Drop:
  2972. // set .@id,F_GetMobData(implode(.@array$,":"),1);
  2973. function    F_GetMobData    {
  2974. // getarg(0): Map Array
  2975. // getarg(1): 0 = Mob ID, 1 = Item Drops
  2976. if(query_sql("SHOW TABLES LIKE 'mob_map_db'",.@db) == 0) {
  2977.     debugmes "F_GetMobData Function Error: SQL Table not loaded.";
  2978.     return 0;
  2979. }
  2980. explode(.@maps$,getarg(0),":");
  2981. freeloop(1);
  2982. for( set.@o,0; .@o < getarraysize(.@maps$); set .@o,.@o + 1) {
  2983.     query_sql "SELECT `mob_id` FROM `mob_map_db` WHERE `map`  = '"+.@maps$[.@o]+"'",.@mob_id;
  2984.    
  2985.     if(getarraysize(.@mob_id) < 1)
  2986.         return -1;
  2987.        
  2988.     for( set .@n,0; .@n < getarraysize(.@mob_id); set .@n,.@n +1) {
  2989.         set .@c,0;
  2990.         set .@f,0;
  2991.         while( .@c < getarraysize(.@mobid) ) {
  2992.             if(.@mob_id[.@n] == .@mobid[.@c])
  2993.                 set .@f,1;
  2994.  
  2995.             set .@c,.@c + 1;
  2996.         }
  2997.         if(.@f)
  2998.             continue;
  2999.         else
  3000.             setarray .@mobid[getarraysize(.@mobid)],.@mob_id[.@n];
  3001.     }
  3002. }
  3003. if(getarg(1,0) == 0) {
  3004.     for ( set .@n,0; .@n < getarraysize(.@mobid); set .@n,.@n +1)
  3005.         set .@menu$,.@menu$ + "- "+strmobinfo(1,.@mobid[.@n]) + ((.@mobid[.@n+1] != 0)?":":"");
  3006.  
  3007.     set .@m,select(.@menu$) - 1;
  3008.  
  3009.     return .@mobid[.@m];
  3010.    
  3011. } else if(getarg(1,0) == 1) {
  3012.     for ( set .@n,0; .@n < getarraysize(.@mobid); set .@n,.@n +1) {
  3013.         getmobdrops(.@mobid[.@n]);
  3014.        
  3015.         for ( set .@i,0; .@i < $@MobDrop_count; set .@i,.@i +1) {
  3016.             set .@c,0;
  3017.             set .@f,0;
  3018.             while( .@c < getarraysize(.@mobitem) ) {
  3019.                 if($@MobDrop_item[.@i] == .@mobitem[.@c])
  3020.                     set .@f,1;
  3021.  
  3022.                 set .@c,.@c + 1;
  3023.             }
  3024.             if(.@f)
  3025.                 continue;
  3026.             else {
  3027.                 setarray .@mobitem[getarraysize(.@mobitem)],$@MobDrop_item[.@i];
  3028.                 setarray .@mobrate[getarraysize(.@mobrate)],$@MobDrop_rate[.@i];
  3029.             }
  3030.         }
  3031.     }
  3032.     for ( set .@n,0; .@n < getarraysize(.@mobitem); set .@n,.@n +1)
  3033.         setarray .@page$[getarraysize(.@page$)],"- "+getitemname(.@mobitem[.@n])+" ("+ .@mobrate[.@n]/100 + ((.@mobrate[.@n]%100 < 10) ? ".0":".") + .@mobrate[.@n]%100 + "%)";
  3034.    
  3035.     set .@m,F_Pages(implode(.@page$,":"),20);
  3036.    
  3037.     freeloop(0);
  3038.     return .@mobitem[.@m];
  3039. }
  3040. freeloop(0);
  3041. debugmes "F_GetMobData Function Error!";
  3042. return 0;
  3043. }
  3044. }
  3045. // ======================= Shop Shops ============================
  3046. -   pointshop   DGShop  -1,DQPoints,512:1
  3047. -   pointshop   DMvPShop    -1,DMVPPoints,512:1
  3048. // ======================= Inside Dungeon NPC =====================
  3049. -   script  Dungeon Guard#main::DG_Main 110,{
  3050.  
  3051. set .@n$,"["+strnpcinfo(1)+"]";
  3052.  
  3053. mes .@n$;
  3054. if(query_sql("SELECT `dg_id` FROM `dqs_party` WHERE `dg_id` = '"+strnpcinfo(2)+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"'",.@dg_id) == 0) {
  3055.     mes "You didn't register for the Dungeon Quest Service.";
  3056.     close;
  3057. }
  3058. for ( set .@m,0; .@m < getarraysize(@dqs_mob); set .@m,.@m + 1) {
  3059. // Updating SQL Table for Monster Hunting Quests
  3060. query_sql "UPDATE `dqs_party` SET `mob_am` = '"+@dqs_am[.@m]+"' WHERE `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1))+"' AND `mob_id` = '"+@dqs_mob[.@m]+"' AND `dg_id` = '"+.@dg_id+"'";
  3061.     if(@dqs_am[.@m] < @dqs_req[.@m]) {
  3062.         mes "You still have to hunt "+(@dqs_req[.@m] - @dqs_am[.@m])+" of "+strmobinfo(1,@mob_id[.@m]);
  3063.         mes "--------------";
  3064.         mes " ";
  3065.     }
  3066. }
  3067. query_sql "SELECT `mob_clear` FROM `dqs_dungeon` WHERE `dg_id` = '"+.@dg_id+"'",.@m_clear;
  3068. if(MobsKilled < .@m_clear*atoi(charat(strnpcinfo(3),3))) {
  3069.     mes "I'm sorry, but you didn't kill enough mobs to enter the next floor.";
  3070.     close;
  3071. }
  3072. mes "Do you really want to leave the dungeon?";
  3073. if(select("- Yes:- No") - 1) close;
  3074. next;
  3075. mes .@n$;
  3076. mes "You"+ ( (getcharid(1) != 0)?"r party":"")+" will now be warped to Prontera.";
  3077. mes "Be sure to visit the \"Dungeon Quest Service\" to complete the dungeon.";
  3078.  
  3079. // Add in this check the Unique Name of every NPC which has more than 9 floors:
  3080. if(strnpcinfo(3) == "tha10" || strnpcinfo(3) == "tha11"  || strnpcinfo(3) == "tha12")
  3081.     set .@done,atoi(charat(strnpcinfo(3),3))+""+atoi(charat(strnpcinfo(3),4));
  3082. else set .@done,atoi(charat(strnpcinfo(3),3));
  3083.  
  3084. query_sql "UPDATE `dqs_party` SET `complete` = '"+.@done+"' WHERE `dg_id` = '"+strnpcinfo(2)+"' AND `"+ ( (getcharid(1) == 0)?"char_id` = '"+getcharid(0):"pty_id` = '"+getcharid(1) )+"' AND `quest_id` = '1'";
  3085. close2;
  3086. warp "prontera",156,191;
  3087. set MobsKilled,0;
  3088. end;
  3089. }
  3090. // ======================= Start of Floor Guard - NPC Duplicates =====================
  3091. //dungeon_map,x,y,facing    duplicate(DG_Main)  Floor Guard#<Dungeon ID>::<Floor #> 110
  3092. //Note: By adding an duplicate the :: Name should should have at the 4th position the Floor #
  3093. abyss_01,23,38,4    duplicate(DG_Main)  Floor Guard#1::aby1 110
  3094. abyss_02,141,275,4  duplicate(DG_Main)  Floor Guard#1::aby2 110
  3095. abyss_03,98,103,4   duplicate(DG_Main)  Dungeon Guard#1::aby3   110
  3096. ama_dun01,228,148,4 duplicate(DG_Main)  Floor Guard#2::ama1 110
  3097. ama_dun02,193,119,4 duplicate(DG_Main)  Floor Guard#2::ama2 110
  3098. ama_dun03,120,223,4 duplicate(DG_Main)  Dungeon Guard#2::ama3   110
  3099. anthell01,250,37,4  duplicate(DG_Main)  Floor Guard#3::ant1 110
  3100. anthell02,170,176,4 duplicate(DG_Main)  Dungeon Guard#3::ant2   110
  3101. ayo_dun01,29,282,4  duplicate(DG_Main)  Floor Guard#4::ayo1 110
  3102. ayo_dun02,148,225,4 duplicate(DG_Main)  Dungeon Guard#4::ayo2   110
  3103. lhz_dun01,144,171,4 duplicate(DG_Main)  Floor Guard#5::lhz1 110
  3104. lhz_dun02,150,145,4 duplicate(DG_Main)  Floor Guard#5::lhz2 110
  3105. lhz_dun03,235,73,4  duplicate(DG_Main)  Dungeon Guard#5::lhz3   110
  3106. bra_dun01,201,39,4  duplicate(DG_Main)  Floor Guard#6::bra1 110
  3107. bra_dun02,175,79,4  duplicate(DG_Main)  Dungeon Guard#6::bra2   110
  3108. iz_dun00,354,333,4  duplicate(DG_Main)  Floor Guard#7::izl1 110
  3109. iz_dun01,120,160,4  duplicate(DG_Main)  Floor Guard#7::izl2 110
  3110. iz_dun02,342,328,4  duplicate(DG_Main)  Floor Guard#7::izl3 110
  3111. iz_dun03,260,252,4  duplicate(DG_Main)  Floor Guard#7::izl4 110
  3112. iz_dun04,134,217,4  duplicate(DG_Main)  Floor Guard#7::izl5 110
  3113. iz_dun05,143,94,4   duplicate(DG_Main)  Dungeon Guard#7::izl6   110
  3114. //c_tower1,238,223,4    duplicate(DG_Main)  Floor Guard#8::tow1 110 // Disabled cuz the warp to next floor is around the corner
  3115. c_tower2,148,283,4  duplicate(DG_Main)  Floor Guard#8::tow2 110
  3116. c_tower3,6,245,4    duplicate(DG_Main)  Floor Guard#8::tow3 110
  3117. c_tower4,102,161,4  duplicate(DG_Main)  Dungeon Guard#8::tow4   110
  3118. alde_dun01,295,303,4    duplicate(DG_Main)  Floor Guard#9::ald1 110
  3119. alde_dun02,274,253,4    duplicate(DG_Main)  Floor Guard#9::ald2 110
  3120. alde_dun03,260,18,4 duplicate(DG_Main)  Floor Guard#9::ald3 110
  3121. alde_dun04,165,268,4    duplicate(DG_Main)  Dungeon Guard#9::ald4   110
  3122. mjo_dun01,19,287,4  duplicate(DG_Main)  Floor Guard#10::mjo1    110
  3123. mjo_dun02,30,25,4   duplicate(DG_Main)  Floor Guard#10::mjo2    110
  3124. mjo_dun03,139,111,4 duplicate(DG_Main)  Dungeon Guard#10::mjo3  110
  3125. prt_sewb1,195,252,4 duplicate(DG_Main)  Floor Guard#11::cul1    110
  3126. prt_sewb2,183,27,4  duplicate(DG_Main)  Floor Guard#11::cul2    110
  3127. prt_sewb3,23,178,4  duplicate(DG_Main)  Floor Guard#11::cul3    110
  3128. prt_sewb4,105,91,4  duplicate(DG_Main)  Dungeon Guard#11::cul4  110
  3129. abbey01,324,100,4   duplicate(DG_Main)  Floor Guard#12::abb1    110
  3130. abbey02,153,290,4   duplicate(DG_Main)  Floor Guard#12::abb2    110
  3131. abbey03,234,216,4   duplicate(DG_Main)  Dungeon Guard#12::abb3  110
  3132. dew_dun01,147,282,4 duplicate(DG_Main)  Floor Guard#13::dew1    110
  3133. dew_dun02,133,94,4  duplicate(DG_Main)  Dungeon Guard#13::dew2  110
  3134. ein_dun01,259,261,4 duplicate(DG_Main)  Floor Guard#14::ein1    110
  3135. ein_dun02,25,88,4   duplicate(DG_Main)  Dungeon Guard#14::ein2  110
  3136. gefenia01,201,266,4 duplicate(DG_Main)  Floor Guard#15::gfi1    110
  3137. gefenia02,61,158,4  duplicate(DG_Main)  Floor Guard#15::gfi2    110
  3138. gefenia03,148,33,4  duplicate(DG_Main)  Floor Guard#15::gfi3    110
  3139. gefenia04,160,30,4  duplicate(DG_Main)  Dungeon Guard#15::gfi4  110
  3140. gef_dun00,198,43,4  duplicate(DG_Main)  Floor Guard#16::gef1    110
  3141. gef_dun01,198,43,4  duplicate(DG_Main)  Floor Guard#16::gef2    110
  3142. gef_dun02,214,56,4  duplicate(DG_Main)  Dungeon Guard#16::gef3  110
  3143. glast_01,200,86,4   duplicate(DG_Main)  Dungeon Guard#17::gla1  110
  3144. gon_dun01,167,270,4 duplicate(DG_Main)  Floor Guard#18::gon1    110
  3145. gon_dun02,253,264,4 duplicate(DG_Main)  Floor Guard#18::gon2    110
  3146. gon_dun03,99,183,4  duplicate(DG_Main)  Dungeon Guard#18::gon3  110
  3147. prt_maze01,89,174,4 duplicate(DG_Main)  Floor Guard#19::maz1    110
  3148. prt_maze02,104,178,4    duplicate(DG_Main)  Floor Guard#19::maz2    110
  3149. prt_maze03,177,89,4 duplicate(DG_Main)  Dungeon Guard#19::maz3  110
  3150. ice_dun01,146,167,4 duplicate(DG_Main)  Floor Guard#20::ice1    110
  3151. ice_dun02,148,281,4 duplicate(DG_Main)  Floor Guard#20::ice2    110
  3152. ice_dun03,149,116,4 duplicate(DG_Main)  Dungeon Guard#20::ice3  110
  3153. juperos_01,97,99,4  duplicate(DG_Main)  Floor Guard#21::jup1    110
  3154. juperos_02,38,56,4  duplicate(DG_Main)  Floor Guard#21::jup2    110
  3155. jupe_core,150,129,4 duplicate(DG_Main)  Dungeon Guard#21::jup3  110
  3156. kh_dun01,27,212,4   duplicate(DG_Main)  Floor Guard#22::khd1    110
  3157. kh_dun02,129,98,4   duplicate(DG_Main)  Dungeon Guard#22::khd2  110
  3158. lou_dun01,37,208,4  duplicate(DG_Main)  Floor Guard#23::lou1    110
  3159. lou_dun02,162,64,4  duplicate(DG_Main)  Floor Guard#23::lou2    110
  3160. lou_dun03,170,153,4 duplicate(DG_Main)  Dungeon Guard#23::lou3  110
  3161. mag_dun01,237,240,4 duplicate(DG_Main)  Floor Guard#24::mag1    110
  3162. mag_dun02,136,160,4 duplicate(DG_Main)  Dungeon Guard#24::mag2  110
  3163. mal_dun01,124,150,4 duplicate(DG_Main)  Dungeon Guard#25::mal1  110
  3164. mosk_dun01,196,273,4    duplicate(DG_Main)  Floor Guard#26::mos1    110
  3165. mosk_dun02,264,119,4    duplicate(DG_Main)  Floor Guard#26::mos2    110
  3166. mosk_dun03,242,170,4    duplicate(DG_Main)  Dungeon Guard#26::mos3  110
  3167. nyd_dun01,239,142,4 duplicate(DG_Main)  Dungeon Guard#27::nyd1  110
  3168. odin_tem01,374,184,4    duplicate(DG_Main)  Floor Guard#28::odi1    110
  3169. odin_tem02,263,372,4    duplicate(DG_Main)  Floor Guard#28::odi2    110
  3170. odin_tem03,278,236,4    duplicate(DG_Main)  Dungeon Guard#28::odi3  110
  3171. orcsdun01,185,13,4  duplicate(DG_Main)  Floor Guard#29::orc1    110
  3172. orcsdun02,77,88,4   duplicate(DG_Main)  Dungeon Guard#29::orc2  110
  3173. pay_dun00,181,38,4  duplicate(DG_Main)  Floor Guard#30::pay1    110
  3174. pay_dun01,283,31,4  duplicate(DG_Main)  Floor Guard#30::pay2    110
  3175. pay_dun02,141,125,4 duplicate(DG_Main)  Floor Guard#30::pay3    110
  3176. pay_dun03,123,59,4  duplicate(DG_Main)  Floor Guard#30::pay4    110
  3177. pay_dun04,120,116,4 duplicate(DG_Main)  Dungeon Guard#30::pay5  110
  3178. moc_pryd01,12,191,4 duplicate(DG_Main)  Floor Guard#31::pry1    110
  3179. moc_pryd02,103,93,4 duplicate(DG_Main)  Floor Guard#31::pry2    110
  3180. moc_pryd03,94,100,4 duplicate(DG_Main)  Floor Guard#31::pry3    110
  3181. moc_pryd04,100,117,4    duplicate(DG_Main)  Dungeon Guard#31::pyr4  110
  3182. moc_pryd05,217,11,4 duplicate(DG_Main)  Floor Guard#32::pyb1    110
  3183. moc_pryd06,97,59,4  duplicate(DG_Main)  Dungeon Guard#32::pyb2  110
  3184. moc_prydn1,217,11,4 duplicate(DG_Main)  Floor Guard#32::pyb3    110
  3185. moc_prydn2,97,59,4  duplicate(DG_Main)  Dungeon Guard#32::pyb4  110
  3186. ra_san01,137,19,4   duplicate(DG_Main)  Floor Guard#33::san1    110
  3187. ra_san02,20,150,4   duplicate(DG_Main)  Floor Guard#33::san2    110
  3188. ra_san03,81,18,4    duplicate(DG_Main)  Floor Guard#33::san3    110
  3189. ra_san04,123,19,4   duplicate(DG_Main)  Floor Guard#33::san4    110
  3190. ra_san05,150,286,4  duplicate(DG_Main)  Dungeon Guard#33::san5  110
  3191. dic_dun01,36,216,4  duplicate(DG_Main)  Floor Guard#34::dic1    110
  3192. dic_dun02,54,160,4  duplicate(DG_Main)  Dungeon Guard#34::dic2  110
  3193. in_sphinx1,83,183,4 duplicate(DG_Main)  Floor Guard#35::sph1    110
  3194. in_sphinx2,275,276,4    duplicate(DG_Main)  Floor Guard#35::sph2    110
  3195. in_sphinx3,10,76,4  duplicate(DG_Main)  Floor Guard#35::sph3    110
  3196. in_sphinx4,122,119,4    duplicate(DG_Main)  Floor Guard#35::sph4    110
  3197. in_sphinx5,100,149,4    duplicate(DG_Main)  Dungeon Guard#35::sph5  110
  3198. treasure01,63,180,4 duplicate(DG_Main)  Floor Guard#36::tre1    110
  3199. treasure02,101,166,4    duplicate(DG_Main)  Dungeon Guard#36::tre2  110
  3200. tha_t01,148,147,4   duplicate(DG_Main)  Floor Guard#37::tha1    110
  3201. tha_t02,225,160,4   duplicate(DG_Main)  Floor Guard#37::tha2    110
  3202. tha_t03,62,136,4    duplicate(DG_Main)  Floor Guard#37::tha3    110
  3203. tha_t04,85,37,4 duplicate(DG_Main)  Floor Guard#37::tha4    110
  3204. tha_t05,189,232,4   duplicate(DG_Main)  Floor Guard#37::tha5    110
  3205. tha_t06,115,106,4   duplicate(DG_Main)  Floor Guard#37::tha6    110
  3206. tha_t07,111,162,4   duplicate(DG_Main)  Floor Guard#37::tha7    110
  3207. tha_t08,112,47,4    duplicate(DG_Main)  Floor Guard#37::tha8    110
  3208. tha_t09,88,150,4    duplicate(DG_Main)  Floor Guard#37::tha9    110
  3209. tha_t10,167,142,4   duplicate(DG_Main)  Floor Guard#37::tha10   110
  3210. tha_t11,89,40,4 duplicate(DG_Main)  Floor Guard#37::tha11   110
  3211. tha_t12,136,65,4    duplicate(DG_Main)  Dungeon Guard#37::tha12 110
  3212. thor_v01,197,41,4   duplicate(DG_Main)  Floor Guard#38::tho1    110
  3213. thor_v02,189,63,4   duplicate(DG_Main)  Floor Guard#38::tho2    110
  3214. thor_v03,151,162,4  duplicate(DG_Main)  Dungeon Guard#38::tho3  110
  3215. xmas_dun01,133,131,4    duplicate(DG_Main)  Floor Guard#39::xma1    110
  3216. xmas_dun02,131,206,4    duplicate(DG_Main)  Dungeon Guard#39::xma2  110
  3217. tur_dun01,156,238,4 duplicate(DG_Main)  Floor Guard#40::tur1    110
  3218. tur_dun02,163,22,4  duplicate(DG_Main)  Floor Guard#40::tur2    110
  3219. tur_dun03,213,73,4  duplicate(DG_Main)  Floor Guard#40::tur3    110
  3220. tur_dun04,92,100,4  duplicate(DG_Main)  Dungeon Guard#40::tur4  110
  3221. ecl_tdun01,70,106,4 duplicate(DG_Main)  Floor Guard#41::ecl1    110
  3222. ecl_tdun02,48,8,4   duplicate(DG_Main)  Floor Guard#41::ecl2    110
  3223. ecl_tdun03,55,44,4  duplicate(DG_Main)  Dungeon Guard#41::ecl3  110
  3224. // ======================= End of Script =====================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement