Guest User

Untitled

a guest
Jun 3rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 25.29 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. FILE * fptr;
  7. getLocationName();
  8. getWeapon();
  9. getEnemy();
  10. battle();
  11. damageCalc();
  12.  
  13. int dmg = 0;
  14. //all of the player info
  15. int progress = 1;
  16. int score = 0;
  17. char playerName[14];
  18. int playerLevel = 1;
  19. char currentLocationName[50];
  20. char c;
  21. int playerHp = 10;
  22. int playerMaxHp = 10;
  23. int playerMp = 10;
  24. int playerMaxMp = 10;
  25. int dexterity = 1;
  26. int sword = 1;
  27. int strength = 1;
  28. int axe = 0;
  29. int accuracy = 1;
  30. int bow = 0;
  31. int power = 1;
  32. int staff = 0;
  33. int arrowCount = 5;
  34. int checkedLetter = 0;
  35. //all of the enemy info
  36. char currentEnemyName[20];
  37. int enemyID = 0;
  38. int enemyHp = 0;
  39. int enemyMaxHp = 0;
  40. int enemyStrength = 0;
  41. int enemyScoreGive = 0;
  42. //worker variables
  43. int choice = 1;
  44. int checkedForLoot = 0;
  45. time_t t;
  46. int locationID = 0;
  47. int baseDMG = 0;
  48. int valid = 0;
  49. //int x;
  50. //int y;
  51. //for map system. 0 is wall, 1-10 are occupied rooms. 11-20 are unoccupied rooms.
  52. //rowOne[0]is x-0, y-0. row5[9] is x-10 y-5.
  53. //note that the y affects the row, and x affects the actual value
  54. //within the row.
  55. //-------------------------------------------------------------
  56. //int row_Five[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
  57. //int row_Four[10] = {1, 0, 1, 0, 1, 0, 0, 0, 1, 0};
  58. //int rowThree[10] = {1, 0, 1, 0, 1, 1, 1, 1, 1, 1};
  59. //int row__Two[10] = {1, 0, 1, 0, 0, 0, 1, 0, 0, 1};
  60. //int row__One[10] = {2, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  61. //-------------------------------------------------------------
  62. char * locationNames[10] = {"A Dark, Creepy Room with bones laying about.",
  63.                         "A Stone Room with rats chattering in the walls.",
  64.                         "A Long, Dark Hall with blood stains on the floors.",
  65.                         "A Stone Room with a table in the corner.",
  66.                         "An old Armory. Broken swords hang along the walls.",
  67.                         "An Open Room of a Cave.",
  68.                         "An old Throne Room with a corpse in the seat.",
  69.                         "A Stone Room with a chest in the corner.",
  70.                         "A room with walls made of strange crystals.",
  71.                         "An ancient Dining Hall. There is no food, though."};
  72. main()
  73. {
  74.     srand(time(&t));
  75.     printf("Welcome to Avelaroar, Chapter 1:\n");
  76.     printf("# #  ###  #    ###   ###  ###  #####   ##\n");
  77.     printf("# #  #    #     #   #      #   # # #  #  #\n");
  78.     printf("# #  ###  #     #   # ##   #   # # #  ####\n");
  79.     printf("# #  #    #     #   #  #   #   # # #  #  #\n");
  80.     printf(" #   ###  ###  ###  ####  ###  # # #  #  #\n");
  81.     printf("PRESS ANY CHARACTER TO CONTINUE\n");
  82.     c = getch();
  83.     system("cls");
  84.     printf("Deep in the lands of Avelaroar, in the year 980, within the caves of Mount Veligima\n");
  85.     printf("lives an evil beast. He is called by many names: Tyruili, Bivib,\n");
  86.     printf("and sometime simply the Great Dragon. But he goes by\n");
  87.     printf("Quetzalcoatl, the ancient snake deity of the Aztecs.\n\n\n");
  88.     printf("Quetzalcoatl nows reigns an army of evils. He has destroyed the city of\n");
  89.     printf("Gildendor. BUT YOU have been chosen by the king himself to slay\n");
  90.     printf("this foul beast. Beware, however. You never know what may\n");
  91.     printf("hide in the depths of Veligima...\n\n\n");
  92.     printf("PRESS ANY CHARACTER TO CONTINUE\n");
  93.     c = getch();
  94.     system("cls");
  95.     printf("Are you starting a new game, or loading an old one?\n");
  96.     printf("1. New Game. Previous progress will be lost.\n");
  97.     printf("2. Load Game.\n");
  98.     scanf(" %d", &choice);
  99.  /*   if (fptr == 0)
  100.     {
  101.         printf("FAILED TO CREATE/LOAD DATA.\n");
  102.         printf("FIX: Make a txt file under the following path:\n");
  103.         printf("C->Users->Public->Documents\n");
  104.         printf("With name:\n");
  105.         printf("avelaroarChOneViligimaData\n");
  106.         printf("EXITING PROGRAM...\n");
  107.         exit(0);
  108.     } */
  109.     if (choice == 1)
  110.     {
  111.         printf("\n\n");
  112.         do
  113.         {
  114.             printf("What shall your class be?\n");
  115.             printf("1. Warrior. +2 STR. +1 DEX.\n");
  116.             printf("2. Magister. +2 POW. +1 ACR.\n");
  117.             printf("3. Archer. +2 ACR. +1 DEX.\n");
  118.             printf("4. Paladin. +2 DEX. +1 POW.\n");
  119.             printf("5. Sorcerer. +3 POW.\n");
  120.             printf("6. Brute. +3 STR.\n");
  121.             printf("7. Adventurer. +1 STR. +1 DEX. +1 ACR.\n");
  122.             scanf(" %d", &choice);
  123.             if (choice == 1)
  124.             {
  125.                 strength += 2;
  126.                 dexterity += 1;
  127.                 axe = 1;
  128.                 valid = 1;
  129.             }
  130.             else if (choice == 2)
  131.             {
  132.                 power += 2;
  133.                 accuracy += 1;
  134.                 staff = 1;
  135.                 valid = 1;
  136.             }
  137.             else if (choice == 3)
  138.             {
  139.                 accuracy += 2;
  140.                 power += 1;
  141.                 bow = 1;
  142.                 valid = 1;
  143.             }
  144.             else if (choice == 4)
  145.             {
  146.                 dexterity += 2;
  147.                 power += 1;
  148.                 valid = 1;
  149.             }
  150.             else if (choice == 5)
  151.             {
  152.                 power += 3;
  153.                 staff = 1;
  154.                 valid = 1;
  155.             }
  156.             else if (choice == 6)
  157.             {
  158.                 strength += 3;
  159.                 axe = 1;
  160.                 valid = 1;
  161.             }
  162.             else if (choice == 7)
  163.             {
  164.                 strength += 1;
  165.                 dexterity += 1;
  166.                 accuracy += 1;
  167.                 int randWeaponStart = (rand() % 2) + 1;
  168.                 if (randWeaponStart == 2)
  169.                 {
  170.                     axe = 1;
  171.                 }
  172.                 if (randWeaponStart == 3)
  173.                 {
  174.                     bow = 1;
  175.                 }
  176.                 valid = 1;
  177.             }
  178.             else
  179.             {
  180.                 printf("INVALID INPUT.\n");
  181.                 valid = 0;
  182.             }
  183.         } while (valid == 0);
  184.         printf("PRESS ANY CHARACTER TO CONTINUE\n");
  185.         c = getch();
  186.         printf("\nType your name (up to 12 characters)\n\n");
  187.         fgets(playerName, 13, stdin);
  188.         fgets(playerName, 13, stdin);
  189.         //system("cls");
  190.         printf("\n%s is your name? Good.\n", playerName);
  191.         printf("You will now face hordes of enemies, soon to fight the GREAT DRAGON. \n \n");
  192.         if (playerName[0] == '&')
  193.         {
  194.             progress = 28;
  195.             sword = 40;
  196.             dexterity = 10;
  197.             playerHp = 999;
  198.             playerMaxHp = 999;
  199.         }
  200.         fptr = fopen("avelaroarChOneViligimaData.txt", "w");
  201.         putw(sword, fptr);
  202.         putw(axe, fptr);
  203.         putw(staff, fptr);
  204.         putw(bow, fptr);
  205.         putw(strength, fptr);
  206.         putw(dexterity, fptr);
  207.         putw(power, fptr);
  208.         putw(accuracy, fptr);
  209.         putw(playerHp, fptr);
  210.         putw(playerMaxHp, fptr);
  211.         putw(playerMp, fptr);
  212.         putw(playerMaxMp, fptr);
  213.         putw(playerLevel, fptr);
  214.         putw(score, fptr);
  215.         putw(progress, fptr);
  216.         putw(arrowCount, fptr);
  217.         putw(checkedForLoot, fptr);
  218.         putw(checkedLetter, fptr);
  219.         fputs(playerName, fptr);
  220.         putw(-1, fptr);
  221.     }
  222.     else if (choice == 2)
  223.     {
  224.         fptr = fopen("avelaroarChOneViligimaData.txt", "r");
  225.         //fseek(fptr, 0, SEEK_SET);
  226.         sword = getw(fptr);
  227.         if (sword <= 0)
  228.         {
  229.             printf("NON-VALID FILE: DEFAULT VALUE NOT FOUND.\n");
  230.             printf("EXITING PROGRAM. RELOAD AND GO TO NEW GAME\n");
  231.             exit(0);
  232.         }
  233.         else
  234.         {
  235.             printf("VALID\n");
  236.  
  237.         }
  238.         axe = getw(fptr);
  239.         staff = getw(fptr);
  240.         bow = getw(fptr);
  241.         strength = getw(fptr);
  242.         dexterity = getw(fptr);
  243.         power = getw(fptr);
  244.         accuracy = getw(fptr);
  245.         playerHp = getw(fptr);
  246.         playerMaxHp = getw(fptr);
  247.         playerMp = getw(fptr);
  248.         playerMaxMp = getw(fptr);
  249.         playerLevel = getw(fptr);
  250.         score = getw(fptr);
  251.         progress = getw(fptr);
  252.         arrowCount = getw(fptr);
  253.         checkedForLoot = getw(fptr);
  254.         checkedLetter = getw(fptr);
  255.         //playerName = fread(fptr, sizeof(playerName));
  256.         int i;
  257.         for (i = 0; i < sizeof(playerName); i++)
  258.         {
  259.             playerName[i] = fgetc(fptr);
  260.         }
  261.     }
  262.     fclose(fptr);
  263.     printf("PRESS ANY CHARACTER TO CONTINUE\n");
  264.     c = getch();
  265.     system("cls");
  266.     do
  267.     {
  268.         getLocationName();
  269.         do
  270.         {
  271.             printf("\n\n\n\n You are in %s \n", currentLocationName);
  272.             printf("\nWhat shall you do now?\n");
  273.             printf("1. Move Forward.\n");
  274.             printf("2. Rest. \n");
  275.             printf("3. Search Room for loot. \n");
  276.             printf("4. Check Inventory and Status. \n");
  277.             printf("5. Save Progress. \n");
  278.             scanf(" %d", &choice);
  279.             if (choice == 2)
  280.             {
  281.                 playerHp = playerHp + 2;
  282.                 if (playerHp > playerMaxHp)
  283.                 {
  284.                     playerHp = playerMaxHp;
  285.                 }
  286.                 playerMp = playerMp + 2;
  287.                 if (playerMp > playerMaxMp)
  288.                 {
  289.                     playerMp = playerMaxMp;
  290.                 }
  291.                 system("cls");
  292.             }
  293.             if (choice == 3 && checkedForLoot == 0)
  294.             {
  295.                 printf("Looking for loot... \n\n\n\n");
  296.                 getWeapon();
  297.                 checkedForLoot = 1;
  298.             }
  299.             else if (choice == 3 && checkedForLoot == 1)
  300.             {
  301.                 printf("You already searched this room. \n");
  302.                 printf("PRESS ANY CHARACTER TO CONTINUE\n");
  303.                 c = getch();
  304.                 system("cls");
  305.             }
  306.             if (choice == 4)
  307.             {
  308.                 printf("\n%s\n\nInventory: \n", playerName);
  309.                 printf("Lv. %d sword. \n", sword);
  310.                 if (bow > 0)
  311.                 {
  312.                     printf("Lv. %d bow. \n", bow);
  313.                 }
  314.                 if (arrowCount > 0)
  315.                 {
  316.                     printf("%d arrow(s). \n", arrowCount);
  317.                 }
  318.                 if (axe > 0)
  319.                 {
  320.                     printf("Lv. %d axe.\n", axe);
  321.                 }
  322.                 if (staff > 0)
  323.                 {
  324.                     printf("Lv. %d staff.\n", staff);
  325.                 }
  326.                 printf("\nYou are Level %d.", playerLevel);
  327.                 printf("\nYou have %d XP.", score);
  328.                 printf("\nHealth is at %d / %d.", playerHp, playerMaxHp);
  329.                 printf("\nMagic is at %d / %d.\n", playerMp, playerMaxMp);
  330.                 printf("You have cleared %d rooms.\n", progress - 1);
  331.                 printf("STR: %d. DEX: %d. POW: %d. ACR: %d.\n", strength, dexterity, power, accuracy);
  332.                 printf("PRESS ANY CHARACTER TO CONTINUE\n");
  333.                 c = getch();
  334.                 system("cls");
  335.             }
  336.             if (choice == 5)
  337.             {
  338.                 fptr = fopen("avelaroarChOneViligimaData.txt", "w");
  339.                 putw(sword, fptr);
  340.                 putw(axe, fptr);
  341.                 putw(staff, fptr);
  342.                 putw(bow, fptr);
  343.                 putw(strength, fptr);
  344.                 putw(dexterity, fptr);
  345.                 putw(power, fptr);
  346.                 putw(accuracy, fptr);
  347.                 putw(playerHp, fptr);
  348.                 putw(playerMaxHp, fptr);
  349.                 putw(playerMp, fptr);
  350.                 putw(playerMaxMp, fptr);
  351.                 putw(playerLevel, fptr);
  352.                 putw(score, fptr);
  353.                 putw(progress, fptr);
  354.                 putw(arrowCount, fptr);
  355.                 putw(checkedForLoot, fptr);
  356.                 putw(checkedLetter, fptr);
  357.                 fputs(playerName, fptr);
  358.                 putw(-1, fptr);
  359.                 fclose(fptr);
  360.                 printf("SAVED DATA. PRESS ANY CHARACTER TO CONTINUE\n");
  361.                 c = getch();
  362.                 system("cls");
  363.             }
  364.         } while (choice != 1);
  365.             printf("\n\n LOADING... \n\n");
  366.             system("cls");
  367.         battle();
  368.         //----------------------------------------------------------------------------------------
  369.     } while (playerHp > 0);
  370.     return (0);
  371. }
  372. getLocationName()
  373. {
  374.     locationID = (rand() % 9);
  375.     strcpy(currentLocationName, locationNames[locationID]);
  376. }
  377. getWeapon()
  378. {
  379.     int swordLootChance = (rand() % 24) + 1;
  380.     if (swordLootChance >= 17)
  381.     {
  382.         int newSword = (rand() % progress) + 1;
  383.         if (newSword > sword)
  384.         {
  385.             printf("You found a new, and deadlier sword!\n");
  386.             sword = newSword;
  387.         }
  388.         else
  389.         {
  390.             printf("You found an old, rusted sword. You tossed that junk aside.\n");
  391.         }
  392.     }
  393.     else
  394.     {
  395.         printf("No swords around here.\n");
  396.     }
  397.     int axeLootChance = (rand() % 24) + 1;
  398.     if (axeLootChance >= 18)
  399.     {
  400.         int newAxe = (rand() % progress) + 1;
  401.         if (newAxe > axe)
  402.         {
  403.             printf("You found a new, and deadlier axe!\n");
  404.             axe = newAxe;
  405.         }
  406.         else
  407.         {
  408.             printf("You found an old, chipped axe. You tossed that junk aside.\n");
  409.  
  410.         }
  411.     }
  412.     else
  413.     {
  414.         printf("No axes around here.\n");
  415.     }
  416.     int staffLootChance = (rand() % 20) + 1;
  417.     if (staffLootChance >= 18)
  418.     {
  419.         int newStaff = (rand() % progress) + 1;
  420.         if (newStaff > staff)
  421.         {
  422.             printf("You found a new, powerful staff!\n");
  423.             staff = newStaff;
  424.         }
  425.         else
  426.         {
  427.             printf("You found an old staff with a broke shaft. You tossed that junk aside.\n");
  428.         }
  429.     }
  430.     else
  431.     {
  432.         printf("No staffs around here.\n");
  433.     }
  434.     int bowLootChance = (rand() % 22) + 1;
  435.     if (bowLootChance >= 17)
  436.     {
  437.         int newBow = (rand() % progress) + 1;
  438.         if (newBow > bow)
  439.         {
  440.             printf("You found a sturdy bow that will fair better than yours.\n");
  441.             bow = newBow;
  442.         }
  443.         else
  444.         {
  445.             printf("You found an old, flimsy bow. You tossed that junk aside.\n");
  446.         }
  447.     }
  448.     else
  449.     {
  450.         printf("No bows around here.\n");
  451.     }
  452.     int arrowLootChance = (rand() % 30) + 1;
  453.     if (arrowLootChance >= 20)
  454.     {
  455.         int arrowLoot = (rand() % 9) + 3;
  456.         printf("You found %d arrow(s).\n", arrowLoot);
  457.         arrowCount = arrowCount + arrowLoot;
  458.     }
  459.     else
  460.     {
  461.         printf("No arrows around here.\n");
  462.     }
  463.     if (progress == 19)
  464.     {
  465.         printf("You found a note that reads:\n\n");
  466.         printf("If you are sent by the King of Avelaroar, TURN BACK!\n");
  467.         printf("The fool sent me here telling me I was chosen, but\n");
  468.         printf("it was a lie!!! Up ahead are some Knights sent here\n");
  469.         printf("first, years back. They are all insane and will kill\n");
  470.         printf("you on site!!! One shot me in the knee with a bow, \n");
  471.         printf("and now I can't run. Wait... I hear something...\n\n");
  472.         printf("On the note is blood splatter, and you see a blood\n");
  473.         printf("trail leading into the next room...\n");
  474.     }
  475.         if (progress == 37)
  476.     {
  477.         printf("You found a note that reads:\n\n");
  478.         printf("I made it through the Rogue Knights and Warlords.\n");
  479.         printf("Up ahead I hear dragons. I am unsure if I should or not.\n");
  480.         printf("The King said I would make it back, that I am some\n");
  481.         printf("chosen warrior to save the day. All I can say is, if\n");
  482.         printf("you find this and I am dead, tell my beloved Elizibeth\n");
  483.         printf("that Marcus loves her...\n\n");
  484.         printf("On the note is tear stains and beside a heart-shaped necklace.\n");
  485.         printf("Blood stains the door to the next room...\n");
  486.         checkedLetter = 1;
  487.     }
  488.     if (progress == 38)
  489.     {
  490.         printf("You found a corpse with an engraved armband engraved MARCUS, 978.\n");
  491.         printf("The corpse has a heart and arrow carved into it by a Wyvern.\n");
  492.         if (checkedLetter == 1)
  493.         {
  494.             printf("You take the armband, in hopes of finding Elizibeth later...\n");
  495.         }
  496.     }
  497.         if (progress == 49)
  498.     {
  499.         printf("You found a note that reads:\n\n");
  500.         printf("I killed the Wyverns guarding this door...\n");
  501.         printf("Up ahead I hear Quetzalcoatl laughing... it is\n");
  502.         printf("like he know I was coming. Maybe the king was right\n");
  503.         printf("and I am the Chosen! Still, my arm is cut pretty\n");
  504.         printf("bad. I will rest here for a little while than move on\n");
  505.         printf("ahead for that fiend Quetzalcoatl...\n\n");
  506.         printf("Next to the note is a corpse that has been burnt\n");
  507.         printf("and gashed into. The arms are almost disconnected\n");
  508.         printf("and the belly is layed open...");
  509.     }
  510.     printf("PRESS ANY CHARACTER TO CONTINUE\n");
  511.     c = getch();
  512.     system("cls");
  513. }
  514. battle()
  515. {
  516.     getEnemy();
  517.     //intro
  518.     printf("%s VERSUS %s!!!\n\n\n", playerName, currentEnemyName);
  519.     printf("(Press ENTER to continue)\n");
  520.     //loops until either the player or enemy dies
  521.     do
  522.     {
  523.         //only loops so that the player can perform their turn.
  524.         do
  525.         {
  526.             printf("\n\n\n%s HP: %d / %d.\n", playerName, playerHp, playerMaxHp);
  527.             printf("%s HP: %d / %d. \n", currentEnemyName, enemyHp, enemyMaxHp);
  528.             printf("\n\n\nWhat will you do?\n");
  529.             printf("1. Slash at them with your sword.\n");
  530.             if (bow > 0 && arrowCount > 0)
  531.             {
  532.                 printf("2. Shoot them with your bow. %d Arrow(s) left. \n", arrowCount);
  533.             }
  534.             if (axe > 0)
  535.             {
  536.                 printf("3. Cleave them with your axe.\n");
  537.             }
  538.             if (staff > 0)
  539.             {
  540.                 printf("4. Shoot a Fire Ball with your staff. %d MP left.\n", playerMp);
  541.             }
  542.             scanf(" %d", &choice);
  543.             if (choice == 2 && bow == 0)
  544.             {
  545.                 printf("INVALID INPUT\n");
  546.                 valid = 0;
  547.             }
  548.             else if (choice == 2 && arrowCount == 0)
  549.             {
  550.                 printf("INVALID INPUT\n");
  551.                 valid = 0;
  552.             }
  553.             else if (choice == 4 && staff == 0)
  554.             {
  555.                 printf("INVALID INPUT\n");
  556.                 valid = 0;
  557.             }
  558.             else if (choice != 1 && choice != 2 && choice != 3 && choice != 4)
  559.             {
  560.                 printf("INVALID INPUT\n");
  561.                 valid = 0;
  562.             }
  563.             else if (choice == 3 && axe == 0)
  564.             {
  565.                 printf("INVALID INPUT\n");
  566.                 valid = 0;
  567.             }
  568.             else
  569.             {
  570.                 valid = 1;
  571.             }
  572.         } while (valid == 0);
  573.         if (choice == 1)
  574.         {
  575.             baseDMG = sword + dexterity;
  576.         }
  577.         if (choice == 2)
  578.         {
  579.             baseDMG = bow + accuracy;
  580.             arrowCount = arrowCount - 1;
  581.         }
  582.         if (choice == 3)
  583.         {
  584.             baseDMG = axe + strength;
  585.         }
  586.         if (choice == 4)
  587.         {
  588.             baseDMG = staff + power;
  589.             playerMp = playerMp - 1;
  590.         }
  591.         dmg = 0;
  592.         damageCalc();
  593.         enemyHp = enemyHp - dmg;
  594.         printf("\nYou dealt %d points of damage.\n", dmg);
  595.         dmg = 0;
  596.         //if enemy is dead
  597.         if (enemyHp <= 0 && enemyID != 9)
  598.         {
  599.             printf("You defeated the %s\n", currentEnemyName);
  600.             score = score + enemyScoreGive;
  601.             if (score >= 500 * playerLevel)
  602.             {
  603.                 printf("You are now Level %d!\n", playerLevel + 1);
  604.                 printf("Max Health +5. Max Magic +5.\n");
  605.                 playerMaxHp = playerMaxHp + 5;
  606.                 playerMaxMp = playerMaxMp + 5;
  607.                 score = score - (500 * playerLevel);
  608.                 playerLevel = playerLevel + 1;
  609.                 do
  610.                 {
  611.                     printf("Which stat do you want to increase?\n");
  612.                     printf("1. STR.\n");
  613.                     printf("2. DEX.\n");
  614.                     printf("3. POW.\n");
  615.                     printf("4. ACR.\n");
  616.                     scanf(" %d", &choice);
  617.                     valid = 1;
  618.                     if (choice == 1)
  619.                     {
  620.                         strength += 1;
  621.                     }
  622.                     else if (choice == 2)
  623.                     {
  624.                         dexterity += 1;
  625.                     }
  626.                     else if (choice == 3)
  627.                     {
  628.                         power += 1;
  629.                     }
  630.                     else if (choice == 4)
  631.                     {
  632.                         accuracy += 1;
  633.                     }
  634.                     else
  635.                     {
  636.                         valid = 0;
  637.                     }
  638.                 } while (valid == 0);
  639.             }
  640.             progress = progress + 1;
  641.             checkedForLoot = 0;
  642.             printf("PRESS ANY CHARACTER TO CONTINUE\n");
  643.             c = getch();
  644.             system("cls");
  645.             break;
  646.         }
  647.         if (enemyHp <= 0 && enemyID == 9)
  648.         {
  649.             printf("\n\n\nYou have defeated Quetzalcoatl!\n");
  650.             printf("Your level was %d.\n", playerLevel);
  651.             printf("You had a Lv. %d sword.\n", sword);
  652.             printf("You had a Lv. %d axe.\n", axe);
  653.             printf("You had a Lv. %d bow.\n", bow);
  654.             printf("You had a Lv. %d staff.\n", staff);
  655.             printf("You had %d Arrow(s).\n", arrowCount);
  656.             printf("And your name was %s\n", playerName);
  657.             printf("THE END...\n");
  658.             exit(0);
  659.         }
  660.         baseDMG = enemyStrength;
  661.         damageCalc();
  662.         playerHp = playerHp - dmg;
  663.         printf("\n\n\nYou received %d points of damage.\n", dmg);
  664.         printf("PRESS ANY CHARACTER TO CONTINUE\n");
  665.         c = getch();
  666.         system("cls");
  667.     } while (playerHp > 0 && enemyHp > 0);
  668. }
  669. damageCalc()
  670. {
  671.     dmg = baseDMG + (rand() % 1) + 1;
  672.     int critChance = (rand() % 49) + 1;
  673.     if (critChance == 50)
  674.     {
  675.         printf("CRITICAL STRIKE\n");
  676.         dmg = dmg * 2;
  677.     }
  678. }
  679. getEnemy()
  680. {
  681.         //gets the ID based on how far the player has progressed.
  682.     if (progress > 0 && progress < 6)
  683.     {
  684.         enemyID = (rand() % 1) + 1;
  685.     }
  686.     else if (progress >= 6 && progress < 14)
  687.     {
  688.         enemyID = (rand() % 2) + 1;
  689.     }
  690.     else if (progress >= 14 && progress < 20)
  691.     {
  692.         enemyID = (rand() % 3) + 1;
  693.         if (enemyID == 1)
  694.         {
  695.             enemyID += 1;
  696.         }
  697.     }
  698.     else if (progress >= 20 && progress < 29)
  699.     {
  700.         enemyID = (rand() % 4) + 1;
  701.         if (enemyID == 1 || enemyID == 2 || enemyID == 3)
  702.         {
  703.             enemyID = 4;
  704.         }
  705.     }
  706.     else if (progress >= 29 && progress < 38)
  707.     {
  708.         enemyID = (rand() % 5) + 1;
  709.         if (enemyID == 1 || enemyID == 2 || enemyID == 3)
  710.         {
  711.             enemyID = 6;
  712.         }
  713.     }
  714.     else if (progress >= 38 && progress < 40)
  715.     {
  716.                 enemyID = (rand() % 5) + 1;
  717.         if (enemyID == 1 || enemyID == 2 || enemyID == 3 || enemyID == 4)
  718.         {
  719.                 enemyID = 6;
  720.         }
  721.     }
  722.     else if (progress >= 40 && progress < 50)
  723.     {
  724.         enemyID = (rand() % 7) + 1;
  725.         if (enemyID == 1 || enemyID == 2 || enemyID == 3 || enemyID == 4 || enemyID == 5)
  726.         {
  727.             enemyID = 8;
  728.         }
  729.     }
  730.     else if (progress == 50)
  731.     {
  732.         enemyID = 9;
  733.     }
  734.         if (enemyID == 1)
  735.     {
  736.         enemyHp = 8;
  737.         enemyStrength = 1;
  738.         enemyScoreGive = 100;
  739.         strcpy(currentEnemyName, "Goblin");
  740.     }
  741.     if (enemyID == 2)
  742.     {
  743.         enemyHp = 20;
  744.         enemyStrength = 2;
  745.         enemyScoreGive = 150;
  746.         strcpy(currentEnemyName, "Bandit");
  747.     }
  748.     if (enemyID == 3)
  749.     {
  750.         enemyHp = 29;
  751.         enemyStrength = 3;
  752.         enemyScoreGive = 250;
  753.         strcpy(currentEnemyName, "Ogre");
  754.     }
  755.     if (enemyID == 4)
  756.     {
  757.         enemyHp = 50;
  758.         enemyStrength = 6;
  759.         enemyScoreGive = 300;
  760.         strcpy(currentEnemyName, "Rogue Knight");
  761.     }
  762.     if (enemyID == 5)
  763.     {
  764.         enemyHp = 75;
  765.         enemyStrength = 6;
  766.         enemyScoreGive = 400;
  767.         strcpy(currentEnemyName, "Warlord");
  768.     }
  769.     if (enemyID == 6)
  770.     {
  771.         enemyHp = 100;
  772.         enemyStrength = 7;
  773.         enemyScoreGive = 550;
  774.         strcpy(currentEnemyName, "Lesser Wyvern");
  775.     }
  776.     if (enemyID == 7)
  777.     {
  778.         enemyHp = 120;
  779.         enemyStrength = 6;
  780.         enemyScoreGive = 650;
  781.         strcpy(currentEnemyName, "Armored Wyvern");
  782.     }
  783.     if (enemyID == 8)
  784.     {
  785.         enemyHp = 120;
  786.         enemyStrength = 8;
  787.         enemyScoreGive = 750;
  788.         strcpy(currentEnemyName, "Daemon");
  789.     }
  790.     if (enemyID == 9)
  791.     {
  792.         enemyHp = 225;
  793.         enemyStrength = 10;
  794.         enemyScoreGive = 7;
  795.         strcpy(currentEnemyName, "Quetzalcoatl");
  796.     }
  797.     enemyMaxHp = enemyHp;
  798. }
Advertisement
Add Comment
Please, Sign In to add comment