Adilol

Demon Battle

Aug 11th, 2011
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.64 KB | None | 0 0
  1.  
  2.  
  3. #include "Library.h"
  4.  
  5. //Demon battle
  6. int GenerateMonsterNumber();
  7. void GenerateMonsterByType(MONSTER* genlist,int gencount,MONSTER* monsterlist,int monstercount);
  8.  
  9. bool DemonicBattle(PLAYER* player,int monstergroup)
  10. {
  11.     //display message describing area
  12.     cout << "You come to a demonice battle ground";
  13.     GenerateMonsterNumber();
  14.  
  15.     Wait();
  16.  
  17.     cout << endl;
  18.  
  19.     //ask player if they want to summon something
  20.     cout << "Do you wish to fight? (y/n)\n";
  21.  
  22.     char answer[10];
  23.  
  24.     while (true)
  25.     {
  26.         cout << ">";
  27.         cin >> answer;
  28.         cin.ignore(20,'\n');
  29.  
  30.         if (answer[0] == 'n')
  31.         {
  32.             //display generic exit
  33.             cout << "You exit, going back to the crossroad.\n";
  34.             Wait();
  35.             cout << endl;
  36.             return false;
  37.         }
  38.  
  39.         if (answer[0] == 'y')
  40.             break;
  41.     }
  42.  
  43.     //generate an enemy based upon monstergroup
  44.  
  45.     MONSTER* list;
  46.     int monstercount = 0;
  47.  
  48.     //how many monsters?
  49.     monstercount = (rand()%2)+1;    // 1 - 2 monsters
  50.     list = new MONSTER[monstercount];
  51.  
  52.     //which group
  53.     if (monstergroup == 1)
  54.     {
  55.         /*
  56.         Wolf – HP: 10, MP: 0, ATT: 3, AP: 0, G: 2, XP: 1
  57.         Giant Snake – HP: 8, MP:0, ATT 6, AP: 0, G: 5, XP 2
  58.         Hawk – HP: 5, MP: 0, ATT: 2, AP: 0, G: 1, XP: 1
  59.         */
  60.  
  61.         MONSTER monsterlist[3];
  62.         monsterlist[0].CreateMonster("Demonic dog",10,0,3,0,2,1);
  63.         monsterlist[1].CreateMonster("Snake",8,0,6,0,5,2);
  64.         monsterlist[2].CreateMonster("Skeletal bird",5,0,2,0,1,1);
  65.  
  66.         GenerateMonsterByType(list,monstercount,monsterlist,3);
  67.     }
  68.     else if (monstergroup == 2)
  69.     {
  70.         MONSTER monsterlist[3];
  71.         monsterlist[0].CreateMonster("Demonic footsoldier",25,0,10,0,10,5);
  72.         monsterlist[1].CreateMonster("Demonic wizard",15,15,5,0,8,8);
  73.         monsterlist[2].CreateMonster("Demonic Elite Guard",30,0,15,3,15,10);
  74.  
  75.         GenerateMonsterByType(list,monstercount,monsterlist,3);
  76.     }
  77.     else if (monstergroup == 3)
  78.     {
  79.         MONSTER monsterlist[3];
  80.         monsterlist[0].CreateMonster("Creature of the Earth",75,0,10,10,50,35);
  81.         monsterlist[1].CreateMonster("Giant Skeletal Demon",60,10,25,0,30,20);
  82.         monsterlist[2].CreateMonster("Demonic water creature",100,0,35,5,40,25);
  83.  
  84.         GenerateMonsterByType(list,monstercount,monsterlist,3);
  85.     }
  86.     else if (monstergroup == 4)
  87.     {
  88.         MONSTER monsterlist[3];
  89.         monsterlist[0].CreateMonster("Demon Warrior",250,0,50,0,120,75);
  90.         monsterlist[1].CreateMonster("Demon Knight",300,0,20,15,200,100);
  91.         monsterlist[2].CreateMonster("Demonic Prince",200,0,40,0,80,50);
  92.         monsterlist[3].CreateMonster("Demonic Overlord", 400,0,70,0,120,100);
  93.  
  94.         GenerateMonsterByType(list,monstercount,monsterlist,3);
  95.     }
  96.  
  97.     /*
  98.     Goblin – HP: 25, MP: 0, ATT: 10, AP: 0, G:10, XP: 5
  99.     Goblin Mage – HP: 15, MP: 15, ATT: 5, AP: 0, G: 8, XP: 8 (casts fireball and heal)
  100.     Goblin Elite Guard – HP: 30, MP: 0, ATT: 15, AP: 3, G: 15, XP: 10
  101.  
  102.     Mud Monster – HP: 75, MP: 0, ATT: 10, AP: 10, G: 50, XP: 35
  103.     Giant Fly – HP 60, MP: 10, ATT: 25, AP: 0, G: 30, XP: 20 (casts poison)
  104.     Alligator – HP 100: MP: 0, ATT: 35, AP: 5, G: 40, XP:  25;
  105.  
  106.     Skeleton – HP: 250, MP: 0, ATT: 50, AP: 0, G:120,  XP: 75
  107.     Zombie – HP: 300, MP: 0, ATT: 20, AP: 15, G: 200, XP: 100
  108.     Vampire Bat – HP: 200, MP: 0, ATT: 40, AP: 0, G: 80, XP: 50
  109.  
  110.     */
  111.  
  112.     //enter battle
  113.     if (!Battle(player,list,monstercount))
  114.     {
  115.         //battle failed
  116.         delete list;
  117.         //lose half your gold and start in town
  118.  
  119.         return false;
  120.     }
  121.  
  122.     delete list;
  123.  
  124.     return true;
  125. }
  126.  
  127. int GenerateMonsterNumber()
  128. {
  129.     return (int)(rand()%3);
  130. }
  131.  
  132. void GenerateMonsterByType(MONSTER* genlist,int gencount,MONSTER* monsterlist,int monstercount)
  133. {
  134.     for (int loop = 0; loop < gencount; loop++)
  135.     {
  136.         //which monster to spawn?
  137.         int monsternumber = rand()%monstercount;
  138.  
  139.         genlist[loop] = monsterlist[monsternumber];
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment