Advertisement
samuel-roberto

Metin2DropBuilder

Jun 12th, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.44 KB | None | 0 0
  1. /*
  2. #####################################
  3. #Program Name: Metin2DropBuilder.cpp#
  4. #Written by: Samuel Roberto         #
  5. #Date: 11/06/2014                   #
  6. #####################################
  7. */
  8.  
  9. #include <iostream>
  10. #include <cstdio>
  11. #include <cstdlib>
  12. #include <fstream>
  13. #include <iostream>
  14. #include <windows.h>
  15.  
  16. using namespace std;
  17.  
  18. /*
  19.     Global Variable
  20. */
  21. char filename[18] = "mob_drop_item.txt";    //File to Read
  22. fstream file (filename);
  23.  
  24. /*
  25.     Function Name: headerMain
  26.  
  27.     Input: /
  28.     Output: Program Header
  29. */
  30. void headerMain();
  31.  
  32.  
  33. /*
  34.     Function Name: checkMobDropItem
  35.  
  36.     Input: /
  37.     Output: New MobDropItem.txt file clean
  38. */
  39. void checkMobDropItem();
  40.  
  41. /*
  42.     Function Name: programMenu
  43.  
  44.     Input: /
  45.     Output: Menu with all Function
  46. */
  47. void programMenu();
  48.  
  49. /*
  50.     Function Name: createMobDropNL
  51.  
  52.     Input: /
  53.     Output: New Line with a Mob Drop without Level_Limit
  54. */
  55. void createMobDropNL();
  56.  
  57. /*
  58.     Function Name: createMobDropL
  59.  
  60.     Input: /
  61.     Output: New Line with a Mob Drop with Level_Limit
  62. */
  63. void createMobDropL();
  64.  
  65. /*
  66.     Function Name: createMetinDrop
  67.  
  68.     Input: /
  69.     Output: New Line with Metin Drop
  70. */
  71. void createMetinDrop();
  72. /*
  73.     Function Name: Main
  74. */
  75. int main()
  76. {
  77.     checkMobDropItem();
  78.     programMenu();
  79.  
  80.     return 0;
  81. }
  82.  
  83. /*
  84.     #############
  85.     Function Code
  86.     #############
  87. */
  88. void headerMain()
  89. {
  90.     SetConsoleTitle("Metin2DropBuilder ~ Samu");//Set Consol Title
  91.     system("color 4");                          //Set Screen Color
  92.     wcout << "                __  .__         ________       .___                     " << endl;
  93.     wcout << "  _____   _____/  |_|__| ____   \\_____  \\    __| _/______  ____ ______  " << endl;
  94.     wcout << " /     \\_/ __ \\   __\\  |/    \\   /  ____/   / __ |\\_  __ \\/  _ \\\\____ \\ " << endl;
  95.     wcout << "|  Y Y  \\  ___/|  | |  |   |  \\ /       \\  / /_/ | |  | \\(  <_> )  |_> >" << endl;
  96.     wcout << "|__|_|  /\\___  >__| |__|___|  / \\_______ \\ \\____ | |__|   \\____/|   __/ " << endl;
  97.     wcout << "      \\/     \\/             \\/          \\/      \\/              |__|    " << endl;
  98.     wcout << "___.         .__.__       .___            " << endl;
  99.     wcout << "\\_ |__  __ __|__|  |    __| _/___________ " << endl;
  100.     wcout << " | __ \\|  |  \\  |  |   / __ |/ __ \\_  __ \\" << endl;
  101.     wcout << " | \\_\\ \\  |  /  |  |__/ /_/ \\  ___/|  | \\/" << endl;
  102.     wcout << " |___  /____/|__|____/\\____ |\\___  >__|   " << endl;
  103.     wcout << "     \\/                    \\/    \\/       " << endl;
  104.  
  105. }
  106.  
  107.  
  108. void checkMobDropItem()
  109. {
  110.     char filename[18] = "mob_drop_item.txt";    //File to Read
  111.     char del;                                   //Variable for Do-While Cicle
  112.     fstream file (filename);
  113.  
  114.     headerMain();
  115.     cout << "#Check if file '" << filename << "' exist" << endl;
  116.  
  117.     if (file.is_open()){
  118.         do{
  119.             cout << "#File exist.. Rebuild File? Only Y when you are ready for Delete  ";
  120.             cin >> del;
  121.         }while(del!='y');
  122.  
  123.         if(del=='y'){
  124.             cout << "#File succesfully deleted" << endl;
  125.             cout << "#Creating a new File '" << filename << "'" << endl;
  126.             file.close();
  127.             remove(filename);
  128.             ofstream outfile (filename);
  129.             outfile.close();
  130.         }
  131.     }else{
  132.         ofstream outfile (filename);
  133.         outfile.close();
  134.     }
  135.     cout << "#Check " << filename << " complete" << endl << endl;
  136.     cout << "#Press Enter.." << endl;
  137.     cin.get();
  138.     cin.get();
  139.     system("cls");
  140. }
  141.  
  142. void programMenu()
  143. {
  144.     char c;
  145.     int exit = 0;
  146.  
  147.     do{
  148.         headerMain();
  149.         cout << "#Make your choise:" << endl;
  150.         cout << "#1. Create a Mob Drop (without level_limit)" << endl;
  151.         cout << "#2. Create a Mob Drop (with level_limit" << endl;
  152.         cout << "#3. Create a Metin Stone Drop" << endl;
  153.         cout << "#4. Exit Program" << endl << endl;
  154.         cout << "User Choise: ";
  155.         cin >> c;
  156.  
  157.         if(c=='1')                                      //Drop Mob without Level Limit
  158.             createMobDropNL();
  159.  
  160.         if(c=='2')                                      //Drop Mob with Level Limit
  161.             createMobDropL();
  162.  
  163.         if(c=='3')                                      //Drop Metin
  164.             createMetinDrop();
  165.  
  166.         if (c=='4')                                     //Exit Program with this Choise
  167.             exit = 1;
  168.  
  169.         if((c!='1')and(c!='2')and(c!='3')and(c!='4'))   //Clear Screen if Wrong Choise
  170.             system("cls");
  171.  
  172.     }while((c!='1')and(c!='2')and(c!='3')and(c!='4')and(exit==0));
  173.  
  174.     file.close();
  175. }
  176.  
  177. void createMobDropNL()
  178. {
  179.     int valueMob;
  180.     int numDrop;
  181.     int valueItem;
  182.     int itemQ;
  183.     float prob;
  184.  
  185.     system("cls");          //Clear Screen
  186.  
  187.     headerMain();
  188.  
  189.     cout << "Insert value of Mob: ";
  190.     cin >> valueMob;
  191.  
  192.     cout << "Insert number of Item to drop: ";
  193.     cin >> numDrop;
  194.  
  195.     cout << endl;
  196.  
  197.     file << "Group\t";
  198.     file << valueMob << "\n{\n\t" << "type\tdrop\n\t" << "mob ";
  199.     file << valueMob << "\n\t";
  200.  
  201.     for(int i=0;i<numDrop; i++){
  202.  
  203.         valueItem = 0;
  204.         itemQ = 0;
  205.         prob = 0;
  206.  
  207.         file << i+1 << "\t";
  208.  
  209.         cout << "Insert value of " << i+1 << " item: ";
  210.         cin >> valueItem;
  211.  
  212.         cout << "Insert quantity of " << i+1 << " item: ";
  213.         cin >> itemQ;
  214.  
  215.         cout << "Insert probability of " << i+1 << " item: ";
  216.         cin >> prob;
  217.  
  218.         cout << endl;
  219.  
  220.         file << valueItem << "\t" << itemQ << "\t" << prob << "\n";
  221.  
  222.         if((i+1)==numDrop)
  223.             file << "}" << "\n";
  224.         else
  225.             file << "\t";
  226.     }
  227.  
  228.  
  229.     cout << endl;
  230.     cout << "#Drop added succesfully" << endl;
  231.     cout << "#Press Enter.." << endl;
  232.     cin.get();
  233.     cin.get();
  234.     system("cls");
  235.     programMenu();
  236. }
  237.  
  238. void createMobDropL()
  239. {
  240.     int valueMob;
  241.     int levelLimit;
  242.     int numDrop;
  243.     int valueItem;
  244.     int itemQ;
  245.     float prob;
  246.  
  247.     system("cls");          //Clear Screen
  248.  
  249.     headerMain();
  250.  
  251.     cout << "Insert value of Mob: ";
  252.     cin >> valueMob;
  253.  
  254.     cout << "Insert Level Limit of Drop: ";
  255.     cin >> levelLimit;
  256.  
  257.     cout << "Insert number of Item to drop: ";
  258.     cin >> numDrop;
  259.  
  260.     cout << endl;
  261.  
  262.     file << "Group\t";
  263.     file << valueMob << "\n{\n\t" << "type\tlimit\n\t" << "mob\t";
  264.     file << valueMob << "\n\t";
  265.     file << "level_limit\t" << levelLimit << "\n\t";
  266.  
  267.     for(int i=0;i<numDrop; i++){
  268.  
  269.         valueItem = 0;
  270.         itemQ = 0;
  271.         prob = 0;
  272.  
  273.         file << i+1 << "\t";
  274.  
  275.         cout << "Insert value of " << i+1 << " item: ";
  276.         cin >> valueItem;
  277.  
  278.         cout << "Insert quantity of " << i+1 << " item: ";
  279.         cin >> itemQ;
  280.  
  281.         cout << "Insert probability of " << i+1 << " item: ";
  282.         cin >> prob;
  283.  
  284.         cout << endl;
  285.  
  286.         file << valueItem << "\t" << itemQ << "\t" << prob << "\n";
  287.  
  288.         if((i+1)==numDrop)
  289.             file << "}" << "\n\n";
  290.         else
  291.             file << "\t";
  292.     }
  293.  
  294.     cout << endl;
  295.     cout << "#Drop added succesfully" << endl;
  296.     cout << "#Press Enter.." << endl;
  297.     cin.get();
  298.     cin.get();
  299.     system("cls");
  300.     programMenu();
  301. }
  302.  
  303. void createMetinDrop()
  304. {
  305.     int valueMetin;
  306.     int numDrop;
  307.     int valueItem;
  308.     int itemQ;
  309.     float prob;
  310.  
  311.     system("cls");          //Clear Screen
  312.  
  313.     headerMain();
  314.  
  315.     cout << "Insert value of Metin: ";
  316.     cin >> valueMetin;
  317.  
  318.     cout << "Insert number of Item to drop: ";
  319.     cin >> numDrop;
  320.  
  321.     cout << endl;
  322.  
  323.     file << "Group\t";
  324.     file << valueMetin << "\n{\n\t" << "type\tdrop\n\t" << "mob ";
  325.     file << valueMetin << "\n\t";
  326.  
  327.     for(int i=0;i<numDrop; i++){
  328.  
  329.         valueItem = 0;
  330.         itemQ = 0;
  331.         prob = 0;
  332.  
  333.         file << i+1 << "\t";
  334.  
  335.         cout << "Insert value of " << i+1 << " item: ";
  336.         cin >> valueItem;
  337.  
  338.         cout << "Insert quantity of " << i+1 << " item: ";
  339.         cin >> itemQ;
  340.  
  341.         cout << "Insert probability of " << i+1 << " item: ";
  342.         cin >> prob;
  343.  
  344.         cout << endl;
  345.  
  346.         file << valueItem << "\t" << itemQ << "\t" << prob << "\n";
  347.  
  348.         if((i+1)==numDrop)
  349.             file << "}" << "\n\n";
  350.         else
  351.             file << "\t";
  352.     }
  353.  
  354.     cout << endl;
  355.     cout << "#Drop added succesfully" << endl;
  356.     cout << "#Press Enter.." << endl;
  357.     cin.get();
  358.     cin.get();
  359.     system("cls");
  360.     programMenu();
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement