Advertisement
Guest User

Untitled

a guest
May 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 67.44 KB | None | 0 0
  1. #include <string.h>
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <stdio.h>
  7. #include <string>
  8.  
  9. #include "world.h"
  10.  
  11. //Inserted activate comand.
  12. //Inserted a lot of items and simple objects.
  13.  
  14. #define ROOMS_NUMB 18
  15. #define EXITS_NUMB 17
  16. #define ITEMS_NUMB 28
  17. #define SIMPLE_NUMB 12
  18. #define CREATURES_NUMB 6
  19. #define MAX_OBJECTS 10
  20. #define _CRT_SECURE_NO_WARNINGS_
  21. using namespace std;
  22.  
  23. // Simple objects are those that are needed for advancing the game and just need to be true or false, like a on or off generator, a on or off fireplace, check if the user moved the carpet...
  24.  
  25.  
  26. void world::CreateWorld(){
  27. //Actually there are 14 rooms, 4 of of them are "corridors" without any item or functionallity
  28. //they just exist in order to be able to select one of the 3 doors inside a element.
  29. room.Push_Back(new Rooms("WEIRD BEDROOM", "You are in the middle of a dark room, it seems that the only think you conserve with you is your bed, you wake up in\nanother place and you listen to some sinester music as background.\n"));
  30. room.Push_Back(new Rooms("FIRE CORRIDOR", "You are at the end of a corridor, there are 3 doors, one in each wall direction.\n"));
  31. room.Push_Back(new Rooms("BURNER", "In the north of the room there is a fireplace with the fire on, there is a shelving on the west and a wall full of old\nphotographies of a unknown family at south.\n"));
  32. room.Push_Back(new Rooms("EMPTY ROOM", "You are now facing with BOMBOCLATS! this is the fire boss! Go face him! (It's a really weird game so you can now be \nfriend with the monster and buy or sell thing, them you can start fighting, no questions) Type 'buy <creature>' for buying.\n\n"));
  33. room.Push_Back(new Rooms("OLD DAD ROOM", "What ? This is something familiar for you, you suddently entered into your dad's room and everything is like normally,\nyou left the door at west, on the north there is your dad's bed, on the east there is his closet\n and there is a TV with his favourite series at the south, there is a strange way made of fuel on the floor.\n"));
  34. room.Push_Back(new Rooms("WIND CORRIDOR", "You are at the end of a corridor, there are 3 doors, one in each wall direction.\n"));
  35. room.Push_Back(new Rooms("OLD MUM ROOM", "Things don't make sense, now you entered to your old mum's room, lefting the entrance on south, on the north of the \nroom there is a mirror with some make up and a fan, in the east there is the bed, but there are some weird \nscratches on the wall that is at west.\n"));
  36. room.Push_Back(new Rooms("STDUYING ROOM", "This room contains a very big desktop with pens, papers and folders at the east, but the floor starts to break and a creature called BETEP now stands in front of you!(It's a really weird game so you can now be \nfriend with the monster and buy or sell thing, them you can start fighting, no questions) Type 'buy <creature>' for buying\n"));
  37. room.Push_Back(new Rooms("BIG WINDOW ROOM", "You entered to the room lefting the entrance at north, on south there is a huge closed window, on west and east there\n are 2 more windows, those normal in size and both closed, one for each wall.\n"));
  38. room.Push_Back(new Rooms("WATER CORRIDOR", "You are at the end of a corridor, there are 3 doors, one in each wall direction.\n"));
  39. room.Push_Back(new Rooms("AQUARIUM", "You appered into an aquarium, you left the entrance on the west, on the north you can see a wall of glass, behind, a fishbowl\n full of sharks, on the east there is the same type of fishbowl than the one with sharks, they are separated between a huge metalic wall, on south there is just a wall with paintings, in front of this wall there is a red chest.\n"));
  40. room.Push_Back(new Rooms("STICK CONTAINER ROOM", "You left the entrance at north and there is a big container with sticks inside and there is a button next to \nthe container, in the south of the room, at the west the is a table full of buttons with a \nleaver, all the buttons are turned off.\n"));
  41. room.Push_Back(new Rooms("LONELY BATHTUB", "You are seen the exit of the bathroom on the east, and there is a bathtub on the north, something strange happens,\n you start to feel vibrations on the floor and something wakes up from the watter, it's BANYU, the water boss. (It's a really weird game so you can now be \nfriend with the monster and buy or sell thing, them you can start fighting, no questions) Type 'buy <creature>' for buying\n"));
  42. room.Push_Back(new Rooms("EARTH CORRIDOR", "You are at the end of a corridor, there are 3 doors, one in each wall direction.\n"));
  43. room.Push_Back(new Rooms("MINE", "You entered and you suddently appear in a mine, the door is on the north, and the wall on the west seems to be a little bit \,softer, the rest of the walls are full of insects, and due to the bad conditions of the mine, the rocks are breaking and there is some rock dust\n"));
  44. room.Push_Back(new Rooms("BLACK HOLE", "This is such a rude way to go in, but you did it. You left the broken wall at the south and there is a door on the \neast, at west it seems to be a hole on the wall, the sound is higher when you're closer to the hole, you look through it and something starts comming, it's BUMI, the earth boos.(It's a really weird game so you can now be \nfriend with the monster and buy or sell thing, them you can start fighting, no questions) Type 'buy <creature>' for buying\n"));
  45. room.Push_Back(new Rooms("DRAWING ROOM", "You entered to a drawing room with the walls made of white stone stone, it's a long room and the exit is on the\nsouth, on the west there is a table with a strongbox on it, there is a red scarf on the floor with two cavalier figures made of iron at the end of the room, one holds a shield and the other one holds a peak, don't be scared!.\n"));
  46. room.Push_Back(new Rooms("FINAL BOSS ROOM", "it seems you teleported to a open space, you are in the middle of an open field in the mountain, the sky is dark \nand it seems it will rain, but wait... there is something comming? OMG! A huge omnster is comming!\n"));
  47.  
  48. //Setting flatten array of integers for the rooms.
  49. for (int i = 0; i < ROOMS_NUMB; i++){
  50. room[i]->numb = i;
  51. }
  52.  
  53. //Setting the help.
  54. room[0]->help.string = "It would be fine if you enter some of those doors.\n\n";
  55. room[1]->help.string = "There is not much I can tell you, just enter some room.\n\n";
  56. room[2]->help.string = "Sometimes is good giving watter to your enemies.\n\n";
  57. room[3]->help.string = "Search something, there is a secret door somewhere.\n\n";
  58. room[4]->help.string = "Sometimes is better to light it up!\n\n";
  59. room[5]->help.string = "There is not much I can tell you, just enter some room.\n\n";
  60. room[6]->help.string = "Search through the personal objects, wind is your friend!\n\n";
  61. room[7]->help.string = "Check if someone have wrote something important.\n\n";
  62. room[8]->help.string = "Make the wind blow.\n\n";
  63. room[9]->help.string = "There is not much I can tell you, just enter some room.\n\n";
  64. room[10]->help.string = "You won't do anything here, must to find a way to pull up the wall.\n\n ";
  65. room[11]->help.string = "Make things spin!\n\n ";
  66. room[12]->help.string = "Face the enemy!\n\n ";
  67. room[13]->help.string = "There is not much I can tell you, just enter some room.\n\n";
  68. room[14]->help.string = "Just hit something! But maybe you need... something:)\n\n";
  69. room[15]->help.string = "The answer is on the deepness.\n\n";
  70. room[16]->help.string = "Attack the stone!\n\n";
  71. room[17]->help.string = "Just kill this monster and you will be the final king!\n\n";
  72.  
  73. //Setting names of the exits with a constructor.
  74.  
  75. exit.Push_Back(new exits("final boss teleport", "this is a door that suddently apeared on the wall, it has a blue electric color"));
  76. exit.Push_Back(new exits("fire door", "this door adresses to a long corridor with some torches on the wall."));
  77. exit.Push_Back(new exits("burner door", "this is a door made of metal girds."));
  78. exit.Push_Back(new exits("empty room door", "it's a varnished brown woden door."));
  79. exit.Push_Back(new exits("old dad door", "this is like your dad's old room door, white wood door."));
  80. exit.Push_Back(new exits("wind door", "this door adresses to a long corridor with some windows on the wall."));
  81. exit.Push_Back(new exits("old mum room door", "this is like your mum's old room door, white wood door."));
  82. exit.Push_Back(new exits("studying room door", "this is a dor with a note on it, silence!"));
  83. exit.Push_Back(new exits("big window room door", "this is a normal metalic door."));
  84. exit.Push_Back(new exits("water door", "this door adresses to a long corridor with waterfall of watter on the each wall."));
  85. exit.Push_Back(new exits("aquarium door", "this is a big gate with old used wood."));
  86. exit.Push_Back(new exits("container stick door", "this is a door that suddently apeared on the wall, it has a blue electric color"));
  87. exit.Push_Back(new exits("lonely bathtub door", "this is a gate maded of blue wood, it has golden door knob"));
  88. exit.Push_Back(new exits("earth corridor", "this door adresses to a long corridor with tha walls made of stone."));
  89. exit.Push_Back(new exits("mine door", "this is a tiny door maded by the holes of the stones on the wall."));
  90. exit.Push_Back(new exits("black hole room door", "this is a door with a hole on the middle!"));
  91. exit.Push_Back(new exits("drawing room door", "this is an elegant door, tipical of luxury drawing rooms"));
  92.  
  93. //Setting an array of integers for the exits.
  94.  
  95. for (int i = 0; i < EXITS_NUMB; i++){
  96. exit[i]->exit_numb = i;
  97. }
  98.  
  99. //Setting state of the doors. (I made a loop beacuse the case is making all the doors stay open exept one,
  100. //in the case of the zork isegment that need it, i will assign the status for every room)
  101.  
  102. for (int i = 0; i < EXITS_NUMB; i++){
  103. if (exit[i]->exit_numb == 1 || exit[i]->exit_numb == 14 || exit[i]->exit_numb == 15)
  104. exit[i]->open = false;
  105. else
  106. exit[i]->open = true;
  107. }
  108.  
  109. //Setting the diestinations of the exits.
  110.  
  111. exit[0]->destination = 17;
  112. for (int i = 1; i < EXITS_NUMB - 1; i++){
  113. exit[i]->destination = i;
  114. }
  115.  
  116. //Setting the source room of the exits.
  117.  
  118. exit[0]->source = 0;
  119. exit[1]->source = 0;
  120. exit[2]->source = 1;
  121. exit[3]->source = 1;
  122. exit[4]->source = 1;
  123. exit[5]->source = 0;
  124. exit[6]->source = 5;
  125. exit[7]->source = 5;
  126. exit[8]->source = 5;
  127. exit[9]->source = 0;
  128. exit[10]->source = 9;
  129. exit[11]->source = 9;
  130. exit[12]->source = 9;
  131. exit[13]->source = 0;
  132. exit[14]->source = 13;
  133. exit[15]->source = 13;
  134. exit[16]->source = 13;
  135.  
  136. //Setting the player info.
  137.  
  138. //main_character = new player;
  139.  
  140. creatures.Push_Back(new creature("Sunyol", "a big head", WEIRD_BEDROOM, -1, 150,200, 5, rand() % 100 + 150)); //this is the player creature
  141.  
  142. int objects = 0;
  143. while (objects < MAX_OBJECTS){
  144. creatures[PLAYER]->prov_inv[objects] = -1; //we will set -1 for empty object.
  145. objects++;
  146. }
  147.  
  148. //Here we create the enemies
  149. creatures.Push_Back(new creature("bomboclats", "this is the fire boss!", EMPTY_ROOM, ITEM_FLAMETHROWER, 150, rand() % 10 + 5 , rand() % 7 + 5, rand() % 100 + 150));
  150. creatures.Push_Back(new creature("betep", "this is the wind boss!", STUDYING_ROOM, ITEM_CANONBOUX, 150, rand() % 10 + 5, rand() % 7 + 5, rand() % 100 + 150));
  151. creatures.Push_Back(new creature("banyu", "this is the water boss!", LONELY_BATHTUB, ITEM_WATERWALL, 150, rand() % 10 + 5, rand() % 7 + 5, rand() % 100 + 150));
  152. creatures.Push_Back(new creature("bumi", "this is the earth boss!", BLACK_HOLE, ITEM_TNT, 150, rand() % 10 + 5, rand() % 7 + 5, rand() % 100 + 150));
  153. creatures.Push_Back(new creature("rock", "this is the final boss!", FINAL_BOSS_ROOM, ITEM_FLAMETHROWER, 150, rand() % 10 + 5, rand() % 7 + 5, rand() % 100 + 150));
  154.  
  155. objects = 0;
  156. while (objects < MAX_OBJECTS){
  157. creatures[FIRE_CREATURE]->prov_inv[objects] = -1;
  158. creatures[WIND_CREATURE]->prov_inv[objects] = -1;
  159. creatures[WATER_CREATURE]->prov_inv[objects] = -1;
  160. creatures[EARTH_CREATURE]->prov_inv[objects] = -1;
  161. creatures[FINAL_BOSS]->prov_inv[objects] = -1; //we will set -1 for empty object.
  162. objects++;
  163. }
  164.  
  165. //Setting fire creature
  166. creatures[FIRE_CREATURE]->item= ITEM_FLAMETHROWER;
  167. creatures[FIRE_CREATURE]->prov_inv[0] = ITEM_ATTACK_BELT;
  168. creatures[WIND_CREATURE]->item= ITEM_CANONBOUX;
  169. creatures[WIND_CREATURE]->prov_inv[0] = ITEM_COIN_BOX;
  170. creatures[WIND_CREATURE]->prov_inv[1] = ITEM_UZY;
  171. creatures[EARTH_CREATURE]->item = ITEM_TNT;
  172. creatures[EARTH_CREATURE]->prov_inv[0] = ITEM_KNIFE;
  173. creatures[WATER_CREATURE]->item = ITEM_WATERWALL;
  174. creatures[FIRE_CREATURE]->prov_inv[0] = ITEM_POSION;
  175. creatures[FIRE_CREATURE]->prov_inv[1] = ITEM_ARMOR;
  176.  
  177. //Setting the final boss.
  178. creatures[FINAL_BOSS]->current_room = FINAL_BOSS_ROOM;
  179. creatures[FINAL_BOSS]->item = ITEM_DIPLOMA;
  180. creatures[FINAL_BOSS]->special_card = 0;
  181. creatures[FINAL_BOSS]->hp = 200;
  182. creatures[FINAL_BOSS]->attack = rand() % 10 + 5;
  183. creatures[FINAL_BOSS]->defense = rand () % 6 + 4;
  184. creatures[FINAL_BOSS]->coins = 30000000000000000;
  185. creatures[FINAL_BOSS]->damage = 0;
  186.  
  187.  
  188.  
  189. //We set the stats of the enemies
  190.  
  191. //Before setting the items, we first set the simple objects status.
  192. simple_obj.Push_Back(new Simple_Objects(false, "shelving", BURNER));
  193. simple_obj.Push_Back(new Simple_Objects(false, "fireplace", BURNER));
  194. simple_obj.Push_Back(new Simple_Objects(false, "drawer", OLD_DAD_ROOM));
  195. simple_obj.Push_Back(new Simple_Objects(false, "closet", OLD_DAD_ROOM));
  196. simple_obj.Push_Back(new Simple_Objects(false, "chest", AQUARIUM));
  197. simple_obj.Push_Back(new Simple_Objects(false, "fishgate", AQUARIUM));
  198. simple_obj.Push_Back(new Simple_Objects(false, "lever", STICK_CONTAINER));
  199. simple_obj.Push_Back(new Simple_Objects(false, "conatiner", STICK_CONTAINER));
  200. simple_obj.Push_Back(new Simple_Objects(false, "strongbox", DRAWING_ROOM));
  201. simple_obj.Push_Back(new Simple_Objects(true, "dust", MINE));
  202. simple_obj.Push_Back(new Simple_Objects(false, "window1", BIG_WINDOW_ROOM));
  203. simple_obj.Push_Back(new Simple_Objects(true, "window2", BIG_WINDOW_ROOM));
  204. simple_obj.Push_Back(new Simple_Objects(true, "window3", BIG_WINDOW_ROOM));
  205.  
  206.  
  207. //Setting the items information with a constructor.
  208. items.Push_Back(new item("glass", "This is a simple glass of watter, but a big one!", false, BURNER));
  209. items.Push_Back(new item("key", "This is an old golden key that seems to be the key of some old door too, the door is close.", false, BURNER));
  210. items.Push_Back(new item("matchstick", "A matchstick! Light it up!", false, OLD_DAD_ROOM));
  211. items.Push_Back(new item("sword", "What can you do with a sword? This sword has a magical energy that will increase your shield too! Attack = 30 \nHP +10.\n\n", false, OLD_DAD_ROOM));
  212. items.Push_Back(new item("chest", "This is a red chest with golden edges, it seems that needs a code for being opened :)", true, AQUARIUM));
  213. items.Push_Back(new item("AttackCard", "This card will give you an EXTRA 5 points of attack.", false, AQUARIUM));
  214. items.Push_Back(new item("hammer", "That is a strong hammer! Attack = 40 // hp +10.", false, AQUARIUM));
  215. items.Push_Back(new item("note", "The key is on Burner, just search better.\n\n", false, AQUARIUM));
  216. items.Push_Back(new item("shield", "This is the shield of the cavalier. Shield = + 10", false, DRAWING_ROOM));
  217. items.Push_Back(new item("peak", "The peak of the cavalier is a strong one! Take care of it! Attack = 40 // Shield = + 5 // hp = + 5", false, DRAWING_ROOM));
  218. items.Push_Back(new item("gunpowder", "A little bit of gunpowder, it seems it have to match with something else.", true, DRAWING_ROOM));
  219. items.Push_Back(new item("DefenseCard", "This card will give you an EXTRA 10 points of defense.", false, DRAWING_ROOM));
  220. items.Push_Back(new item("strongbox", "A little bit of gunpowder, it seems it have to match with something else.", true, DRAWING_ROOM));
  221. items.Push_Back(new item("wick", "This weak can be mixed with something? mmm... \n\n", false, MINE));
  222. items.Push_Back(new item("bomb", "This is a strong bomb that can break walls!\n\n", false, MINE));
  223. items.Push_Back(new item("fan", "This fan will help you to achieve your CORRIENTE DE AIRE\n\n", false, OLD_MUM_ROOM));
  224. items.Push_Back(new item("HPCard", "You're getting close to the final boss, so here you have a card that will raise 20 HP points.\n\n", false, OLD_MUM_ROOM));
  225. items.Push_Back(new item("flamethrower", "This is the flamehtrower of bomboclats! Attack = 30.\n\n", false, EMPTY_ROOM));
  226. items.Push_Back(new item("canonboux", "This weapon is special from the wind boss, it throws vortex of wind to your enemies. Attack = 25\n\n", false, STUDYING_ROOM));
  227. items.Push_Back(new item("waterwall", "This is a special shield that you can use 3 times, once you're carrying it your oponent won't be able to cause you any damage.\n\n", false, LONELY_BATHTUB));
  228. items.Push_Back(new item("TNT", "This is a special granade that you can use twice. Damage = 50\n\n", false, BLACK_HOLE));
  229. items.Push_Back(new item("diploma", "Congartulations! You got a diploma for playing this silly game.\n\n", false, FINAL_BOSS_ROOM));
  230. items.Push_Back(new item("belt", "this belt will increase your damage", false, EMPTY_ROOM));
  231. items.Push_Back(new item("coins", "This is a box full of coins. Value = 100\n\n", false, STUDYING_ROOM));
  232. items.Push_Back(new item("uzy", "This is an automatic handgun, but you can only shot 3 bullets each turn. Attack = 35; \n\n", false, STUDYING_ROOM));
  233. items.Push_Back(new item("knife", "This is a melee weapon, grey knife with golden hold. Damage = 20\n\n", false, LONELY_BATHTUB));
  234. items.Push_Back(new item("posion", "This posion increase x2 your current hp.\n\n", false, BLACK_HOLE));
  235. items.Push_Back(new item("armor", "this armor will decrease the enemy attack. Defense = 5", false, BLACK_HOLE));
  236.  
  237. //Setting the number of the items and the carriage.
  238. for (int i = 0; i < ITEMS_NUMB; i++){
  239. items[i]->item_num = i;
  240. items[i]->carried = false;
  241. }
  242.  
  243.  
  244. //Setting inventory for the items that can have objects inside.
  245.  
  246. for (int i = 0; i < ITEMS_NUMB; i++){
  247. if (items[i]->item_num == ITEM_CHEST){
  248. for (int j = 2; j < MAX_ITEMS_STORAGE; j++){
  249. items[i]->prov_inv[0] = ITEM_HAMMER;
  250. items[i]->prov_inv[1] = ITEM_ATTACK_CARD;
  251. items[i]->prov_inv[j] = -1;
  252. }
  253. }
  254. else if (items[i]->item_num == ITEM_STRONGBOX){
  255. for (int j = 2; j < MAX_ITEMS_STORAGE; j++){
  256. items[i]->prov_inv[0] = ITEM_GUNPOWDER_CONTAINER;
  257. items[i]->prov_inv[1] = ITEM_DEFENSE_CARD;
  258. items[i]->prov_inv[j] = -1;
  259. }
  260. }
  261.  
  262. else if (items[i]->item_num == ITEM_GUNPOWDER_CONTAINER){
  263. for (int j = 0; j < MAX_ITEMS_STORAGE; j++){
  264. items[i]->prov_inv[j] = -1;
  265. }
  266. }
  267. }
  268.  
  269. items[ITEM_SWORD]->attack = 10; items[ITEM_SWORD]->shield_plus = 10; items[ITEM_SWORD]->hp_plus = 0, items[ITEM_SWORD]->cost = 30;
  270. items[ITEM_ATTACK_CARD]->attack = 5; items[ITEM_ATTACK_CARD]->shield_plus = 0; items[ITEM_ATTACK_CARD]->hp_plus = 0, items[ITEM_ATTACK_CARD]->cost = 10;
  271. items[ITEM_HAMMER]->attack = 20; items[ITEM_HAMMER]->shield_plus = 0; items[ITEM_HAMMER]->hp_plus = 10, items[ITEM_HAMMER]->cost = 20;
  272. items[ITEM_SHIELD]->attack = 0; items[ITEM_SHIELD]->shield_plus = 50; items[ITEM_SHIELD]->hp_plus = 25, items[ITEM_SHIELD]->cost = 15;
  273. items[ITEM_PEAK]->attack = 15; items[ITEM_PEAK]->shield_plus = 0; items[ITEM_PEAK]->hp_plus = 0, items[ITEM_PEAK]->cost = 15;
  274. items[ITEM_DEFENSE_CARD]->attack = 0; items[ITEM_DEFENSE_CARD]->shield_plus = 20; items[ITEM_DEFENSE_CARD]->hp_plus = 20, items[ITEM_DEFENSE_CARD]->cost = 10;
  275. items[ITEM_HP_CARD]->attack = 0; items[ITEM_HP_CARD]->shield_plus = 0; items[ITEM_HP_CARD]->hp_plus = 50, items[ITEM_HP_CARD]->cost = 10;
  276. items[ITEM_FLAMETHROWER]->attack = 30; items[ITEM_FLAMETHROWER]->shield_plus = 0; items[ITEM_FLAMETHROWER]->hp_plus = 0, items[ITEM_FLAMETHROWER]->cost = 40;
  277. items[ITEM_CANONBOUX]->attack = 25; items[ITEM_CANONBOUX]->shield_plus = 0; items[ITEM_CANONBOUX]->hp_plus = 0, items[ITEM_CANONBOUX]->cost = 40;
  278. items[ITEM_WATERWALL]->attack = 0; items[ITEM_WATERWALL]->shield_plus = 0; items[ITEM_WATERWALL]->hp_plus = 0, items[ITEM_WATERWALL]->cost = 40;
  279. items[ITEM_TNT]->attack = 50; items[ITEM_TNT]->shield_plus = 0; items[ITEM_TNT]->hp_plus = 0, items[ITEM_TNT]->cost = 10;
  280. items[ITEM_DIPLOMA]->attack = 0; items[ITEM_DIPLOMA]->shield_plus = 0; items[ITEM_DIPLOMA]->hp_plus = 0, items[ITEM_DIPLOMA]->cost = 0;
  281. items[ITEM_ATTACK_BELT]->attack = 10; items[ITEM_ATTACK_BELT]->shield_plus = 0; items[ITEM_ATTACK_BELT]->hp_plus = 0, items[ITEM_ATTACK_BELT]->cost = 20;
  282. items[ITEM_COIN_BOX]->attack = 0; items[ITEM_COIN_BOX]->shield_plus = 0; items[ITEM_COIN_BOX]->hp_plus = 0, items[ITEM_COIN_BOX]->cost = 0;
  283. items[ITEM_UZY]->attack = 35; items[ITEM_UZY]->shield_plus = 0; items[ITEM_UZY]->hp_plus = 0, items[ITEM_UZY]->cost = 40;
  284. items[ITEM_KNIFE]->attack = 15; items[ITEM_KNIFE]->shield_plus = 0; items[ITEM_KNIFE]->hp_plus = 0, items[ITEM_KNIFE]->cost = 30;
  285. items[ITEM_POSION]->attack = 0; items[ITEM_POSION]->shield_plus = 0; items[ITEM_POSION]->hp_plus = 40, items[ITEM_POSION]->cost = 20;
  286. items[ITEM_ARMOR]->attack = 0; items[ITEM_ARMOR]->shield_plus = 10; items[ITEM_ARMOR]->hp_plus = 0, items[ITEM_ARMOR]->cost = 50;
  287.  
  288. //Here is printed the information of the character
  289. printf("%s\n", room[creatures[PLAYER]->current_room]->name);
  290. printf("%s\n", room[creatures[PLAYER]->current_room]->description);
  291.  
  292.  
  293. }
  294. void world::Check_input(){
  295. bool gameloop_end = 0;
  296. do{
  297. char command_c[20];
  298. char move_c[20];
  299.  
  300. bool button_pressed = false;
  301. bool action_done = false;
  302. bool& ref_move_permision = action_done; //this exist in order to show the description just when the user can move, sometimets he makes and action but he don't move!
  303. bool moved = false;
  304. bool& ref_moved = moved; //this variable holded by reference that exist in order to not show the description everytime the player inserts a command, just when the player changes of room.
  305. static bool object_moved = false;
  306. // this if checks if all monsters are death, if they do, the player will be teleported to the final boss, once he has killed all the other bosses.
  307. if (creatures[PLAYER]->current_room == WEIRD_BEDROOM && creatures[FIRE_CREATURE]->death == true && creatures[WIND_CREATURE]->death == true && creatures[WATER_CREATURE]->death == true && creatures[EARTH_CREATURE]->death == true){
  308. printf("You are almost a legend, you killed all the 4 monsters but that not the end of the story, every game has its final boss right? Go face him!");
  309. creatures[PLAYER]->current_room = FINAL_BOSS_ROOM;
  310. Sleep(1500);
  311. printf("\n\n");
  312. printf("Yoy're being teleported");
  313. Sleep(1500);
  314. printf(".");
  315. Sleep(1500);
  316. printf(".");
  317. Sleep(1500);
  318. printf(".");
  319. printf("\n");
  320. printf("%s \n You apeared to the final boss room, you are facing with ROCK, here is where you have to give everything, he's so strong!\n", room[FINAL_BOSS_ROOM]->name);
  321. gameloop_end = Enter_Battle(FINAL_BOSS);
  322. }
  323.  
  324. printf(">: ");
  325. scanf_s("%s", &command_c, 20);
  326.  
  327. String command(command_c);
  328.  
  329. if (command != "go" && command != "open" && command != "close" && command != "move" && command != "teleport" && command != "pick" && command != "drop" && command != "equip" && command != "unequip" && command != "look" && command != "get" && command != "press" && command != "hit" && command != "win" && command != "attack" && command != "buy" && command != "sell"){
  330. if (command == "quit"){
  331. //if the user wants to quit
  332. gameloop_end = true;
  333. action_done = true;
  334. }
  335. else if (command == "help")
  336. //if the user wants some help
  337. printf("%s", room[creatures[PLAYER]->current_room]->help);
  338. else if (command == "look"){
  339. printf("%s", room[creatures[PLAYER]->current_room]->description.c_str());
  340. //if the user wants to look
  341. }
  342. else if (command == "inventory")
  343. Show_inventory();
  344. else if (command == "stats")
  345. printf("\nHP: %d\nAttack: %d\nDefense: %d\nCoins: %d\n\n", creatures[PLAYER]->hp, creatures[PLAYER]->attack, creatures[PLAYER]->defense, creatures[PLAYER]->coins);
  346. else
  347. printf("\nI don't undestrand you, insert comands like <action> <direction/item>\n\n");
  348. std::cin.clear();
  349. }
  350. else{
  351. scanf_s("%s", &move_c, 20);
  352. String move(move_c);
  353. printf("\n");
  354. //char open_direc[10];
  355. if (command == "teleport"){
  356. if (move == "A"){
  357. creatures[PLAYER]->current_room = EMPTY_ROOM;
  358. goto Start;
  359. }
  360. else if (move == "B"){
  361. creatures[PLAYER]->current_room = STUDYING_ROOM;
  362. goto Start;
  363. }
  364. else if (move == "C"){
  365. creatures[PLAYER]->current_room = LONELY_BATHTUB;
  366. goto Start;
  367. }
  368. else if (move == "D"){
  369. creatures[PLAYER]->current_room = BLACK_HOLE;
  370. goto Start;
  371. }
  372. }
  373. if (command == "go")
  374. move_character(move, moved, action_done);
  375. else if (command == "open"){
  376. //if the user wants to open something
  377. int object_open;
  378.  
  379. if (move == "drawer")
  380. object_open = INTERACT_DRAWER;
  381. else if (move == "door")
  382. object_open = INTERACT_DOOR;
  383. else if (move == "closet")
  384. object_open = INTERACT_CLOSET;
  385. else if (move == "chest" || move == "box")
  386. object_open = INTERACT_CHEST;
  387. else if (move == "strongbox")
  388. object_open = INTERACT_STRONGBOX;
  389. else if (move == "window" || move == "windows")
  390. object_open = INTERACT_WINDOW;
  391.  
  392. Open_Stuff(creatures[PLAYER]->current_room, action_done, object_open, move);
  393. //here will be placed other things that can be opened: "window", "box"...
  394. }
  395. else if (command == "close"){
  396. //if the user wants to close something
  397. int object_open;
  398. if (move == "drawer")
  399. object_open = INTERACT_DRAWER;
  400. else if (move == "door")
  401. object_open = INTERACT_DOOR;
  402. else if (move == "closet")
  403. object_open = INTERACT_CLOSET;
  404. else if (move == "chest" || move == "box")
  405. object_open = INTERACT_CHEST;
  406. else if (move == "strongbox")
  407. object_open = INTERACT_STRONGBOX;
  408. else if (move == "window" || move == "windows")
  409. object_open = INTERACT_WINDOW;
  410. Close_Stuff(creatures[PLAYER]->current_room, action_done, object_open, move);
  411.  
  412. }
  413. else if (command == "look"){
  414. look_item(move);
  415. action_done = true;
  416. }
  417. else if (command == "move"){
  418. //if the user wants to move something (objects that can be moved and don't have no more functionality are in Simple_Objects class).
  419. //This function is for printing what happens when de user moves some object: i.e: You moved a carpet and you discovered a trapdoor!
  420. Move_Simple_Obj(move);
  421. action_done = true;
  422. }
  423. else if (command == "equip"){
  424. Equip_item(move);
  425. action_done = true;
  426. }
  427. else if (command == "unequip"){
  428. Unequip_item(move);
  429. action_done = true;
  430. }
  431. else if (command == "sell"){
  432. if (creatures[PLAYER]->current_room == EMPTY_ROOM) Sell_Item(move, FIRE_CREATURE);
  433. else if (creatures[PLAYER]->current_room == STUDYING_ROOM) Sell_Item(move, WIND_CREATURE);
  434. else if (creatures[PLAYER]->current_room == LONELY_BATHTUB) Sell_Item(move, WATER_CREATURE);
  435. else if (creatures[PLAYER]->current_room == BLACK_HOLE) Sell_Item(move, EARTH_CREATURE);
  436. else if (creatures[PLAYER]->current_room == FINAL_BOSS_ROOM) Sell_Item(move, FINAL_BOSS);
  437. action_done = true;
  438. }
  439. else if (command == "hit"){
  440. Hit_Stuff(move);
  441. action_done = true;
  442. }
  443. else if (command == "attack"){
  444.  
  445. if ((move == "bomboclats" || move == "betep" || move == "banyu" || move == "bumi" || move == "BOMBOCLATS" || move == "BETEP" || move == "BANYU" || move == "BUMI")){
  446. if (move == "bomboclats" && creatures[PLAYER]->current_room == EMPTY_ROOM && creatures[FIRE_CREATURE]->death == false)
  447. gameloop_end = Enter_Battle(FIRE_CREATURE);
  448. else if (move == "betep" && creatures[PLAYER]->current_room == STUDYING_ROOM && creatures[WIND_CREATURE]->death == false)
  449. gameloop_end = Enter_Battle(WIND_CREATURE);
  450. else if (move == "banyu" && creatures[PLAYER]->current_room == LONELY_BATHTUB && creatures[WATER_CREATURE]->death == false)
  451. gameloop_end = Enter_Battle(WATER_CREATURE);
  452. else if (move == "bumi" && creatures[PLAYER]->current_room == BLACK_HOLE && creatures[EARTH_CREATURE]->death == false)
  453. gameloop_end = Enter_Battle(EARTH_CREATURE);
  454. else
  455. printf("This enemy is death dude.\n");
  456. }
  457. else
  458. printf("You can't attack.\n\n");
  459. action_done = true;
  460. }
  461. else if (command == "press"){
  462. if (move == "button" && creatures[PLAYER]->current_room == STICK_CONTAINER && simple_obj[SIMPLE_LEVER]->moved == true){
  463. simple_obj[SIMPLE_FISHGATE]->moved = true;
  464. printf("You pressed the button of the stick container, making the sticks twist and generating enough force to raise something.Go and see it!\n\n");
  465. button_pressed = true;
  466. }
  467. action_done = true;
  468. }
  469. else if (command == "pick"){
  470. Pick_Item(move, creatures[PLAYER]->current_room, PLAYER, false);
  471. action_done = true;
  472. }
  473. else if (command == "drop"){
  474. Drop_item(move, creatures[PLAYER]->current_room, PLAYER, false);
  475. action_done = true;
  476. }
  477. else if (command == "get"){
  478. Get_object_from_object(move, creatures[PLAYER]->current_room);
  479. action_done = true;
  480. }
  481. else if (command == "put"){
  482. Put_Objects(move, creatures[PLAYER]->current_room);
  483. action_done = true;
  484. }
  485. else if (command == "buy"){
  486. if (creatures[PLAYER]->current_room == EMPTY_ROOM) BuyItem(FIRE_CREATURE);
  487. else if (creatures[PLAYER]->current_room == STUDYING_ROOM) BuyItem(WIND_CREATURE);
  488. else if (creatures[PLAYER]->current_room == LONELY_BATHTUB) BuyItem(WATER_CREATURE);
  489. else if (creatures[PLAYER]->current_room == BLACK_HOLE) BuyItem(EARTH_CREATURE);
  490. else if (creatures[PLAYER]->current_room == FINAL_BOSS_ROOM) BuyItem(FINAL_BOSS);
  491. action_done = true;
  492. }
  493.  
  494. else
  495. printf("I can't understand you.\n\n");
  496.  
  497. if (moved == true){
  498. Start:
  499. printf("%s\n", room[creatures[PLAYER]->current_room]->name);
  500. if (simple_obj[SIMPLE_FISHGATE]->moved == false && creatures[PLAYER]->current_room != AQUARIUM)
  501. printf("%s\n", room[creatures[PLAYER]->current_room]->description);
  502. else
  503. printf("When pressing the container button you raised the fishgate, sharks that were separated started to fight and they broke the glass, now there is one shark on the floor with a note on the fin.\n\n");
  504. }
  505. else if (action_done == false && command == "go")
  506. printf("There is any door on that direction, just a wall!\n\n");
  507. else if (command != "look" && action_done == false)
  508. printf("You can't do that.\n\n");
  509. }
  510. } while (gameloop_end == false);
  511. }
  512. void world::Destroy_World(){
  513.  
  514. delete[] room.buffer;
  515. delete[] exit.buffer;
  516. delete[] items.buffer;
  517. delete[] simple_obj.buffer;
  518. delete creatures[PLAYER];
  519.  
  520. }
  521.  
  522. void world::move_character(const String& move, bool& moved, bool& permission){
  523. // if the user inserts the comand go:
  524. if (move == "north"){
  525. // if the user wants to go north
  526. switch (creatures[PLAYER]->current_room){
  527. case 0:
  528. permission = true;
  529. if (exit[1]->open){
  530. permission = true;
  531. creatures[PLAYER]->current_room = 1;
  532. moved = true;
  533. }
  534. else
  535. printf("There is a closed door there.\n\n");
  536. break;
  537. case 1:
  538. permission = true;
  539. creatures[PLAYER]->current_room = 3;
  540. moved = true;
  541. break;
  542. case 13:
  543. permission = true;
  544. creatures[PLAYER]->current_room = 16;
  545. moved = true;
  546. break;
  547. case 9:
  548. permission = true;
  549. creatures[PLAYER]->current_room = 0;
  550. moved = true;
  551. break;
  552. case 11:
  553. permission = true;
  554. creatures[PLAYER]->current_room = 9;
  555. moved = true;
  556. break;
  557. case 8:
  558. permission = true;
  559. creatures[PLAYER]->current_room = 5;
  560. moved = true;
  561. break;
  562. case 5:
  563. permission = true;
  564. creatures[PLAYER]->current_room = 6;
  565. moved = true;
  566. break;
  567. case 14:
  568. permission = true;
  569. creatures[PLAYER]->current_room = 13;
  570. moved = true;
  571. break;
  572. }
  573. }
  574. else if (move == "south"){
  575. //if the user wants to go south
  576. switch (creatures[PLAYER]->current_room){
  577. case 3:
  578. permission = true;
  579. creatures[PLAYER]->current_room = 1;
  580. break;
  581. case 1:
  582. permission = true;
  583. if (exit[1]->open){
  584. creatures[PLAYER]->current_room = 0;
  585. moved = true;
  586. }
  587. else
  588. printf("There is a closed door there.\n\n");
  589. break;
  590. case 0:
  591. permission = true;
  592. creatures[PLAYER]->current_room = 9;
  593. moved = true;
  594. break;
  595. case 9:
  596. permission = true;
  597. creatures[PLAYER]->current_room = 11;
  598. moved = true;
  599. break;
  600. case 6:
  601. permission = true;
  602. creatures[PLAYER]->current_room = 5;
  603. moved = true;
  604. break;
  605. case 5:
  606. permission = true;
  607. creatures[PLAYER]->current_room = 8;
  608. moved = true;
  609. break;
  610. case 16:
  611. permission = true;
  612. creatures[PLAYER]->current_room = 13;
  613. moved = true;
  614. break;
  615. case 13:
  616. permission = true;
  617. if (exit[14]->open == true){
  618. creatures[PLAYER]->current_room = 14;
  619. moved = true;
  620. }
  621. else
  622. printf("There is a wall made of rocks that's blocking the door.\n\n");
  623.  
  624. break;
  625. }
  626. }
  627. else if (move == "east"){
  628. //if the user wants to go east
  629. switch (creatures[PLAYER]->current_room){
  630. case 2:
  631. permission = true;
  632. creatures[PLAYER]->current_room = 1;
  633. moved = true;
  634. break;
  635. case 1:
  636. permission = true;
  637. creatures[PLAYER]->current_room = 4;
  638. moved = true;
  639. break;
  640. case 0:
  641. permission = true;
  642. creatures[PLAYER]->current_room = 5;
  643. moved = true;
  644. break;
  645. case 5:
  646. permission = true;
  647. creatures[PLAYER]->current_room = 7;
  648. moved = true;
  649. break;
  650. case 9:
  651. permission = true;
  652. creatures[PLAYER]->current_room = 10;
  653. moved = true;
  654. break;
  655. case 15:
  656. permission = true;
  657. creatures[PLAYER]->current_room = 13;
  658. moved = true;
  659. break;
  660. case 12:
  661. permission = true;
  662. creatures[PLAYER]->current_room = 9;
  663. moved = true;
  664. break;
  665. case 13:
  666. permission = true;
  667. creatures[PLAYER]->current_room = 0;
  668. moved = true;
  669. break;
  670. }
  671. }
  672.  
  673. else if (move == "west"){
  674. //if the user wants to go west
  675. switch (creatures[PLAYER]->current_room){
  676. case 4:
  677. permission = true;
  678. creatures[PLAYER]->current_room = 1;
  679. moved = true;
  680. break;
  681. case 1:
  682. permission = true;
  683. creatures[PLAYER]->current_room = 2;
  684. moved = true;
  685. break;
  686. case 0:
  687. permission = true;
  688. creatures[PLAYER]->current_room = 13;
  689. moved = true;
  690. break;
  691. case 13:
  692. permission = true;
  693. if (exit[15]->open == true){
  694. creatures[PLAYER]->current_room = 15;
  695. moved = true;
  696. }
  697. else
  698. printf("There is a door that will never be opened.\n\n");
  699.  
  700. break;
  701. case 10:
  702. permission = true;
  703. creatures[PLAYER]->current_room = 9;
  704. moved = true;
  705. break;
  706. case 9:
  707. permission = true;
  708. creatures[PLAYER]->current_room = 12;
  709. moved = true;
  710. break;
  711. case 7:
  712. permission = true;
  713. creatures[PLAYER]->current_room = 5;
  714. moved = true;
  715. break;
  716. case 5:
  717. permission = true;
  718. creatures[PLAYER]->current_room = 0;
  719. moved = true;
  720. break;
  721. }
  722. }
  723. }
  724. void world::Move_Simple_Obj(const String& move){
  725. int item_num = Get_Simple_Num(move.string);
  726. if (item_num != -1){
  727. switch (item_num){
  728. case SIMPLE_SHELV:
  729. {
  730. if (creatures[PLAYER]->current_room == items[item_num]->item_room){
  731. if (simple_obj[SIMPLE_SHELV]->moved == false){
  732. simple_obj[SIMPLE_SHELV]->moved = true;
  733. printf("You moved the shelving, revealing a little hole on the wall with a glass full of watter!\n\n");
  734. }
  735. else {
  736. printf("You moved the shelving to it's original place.\n\n");
  737. simple_obj[SIMPLE_SHELV]->moved = false;
  738. }
  739. }
  740. break;
  741. }
  742. case SIMPLE_LEVER:
  743. char password[10];
  744. printf("Electricity lever is blocked by a set of characters: Insert pasword: ");
  745. scanf_s("%s", &password, 10);
  746. printf("\n");
  747. String password_str(password);
  748. if (password_str == "boom"){
  749. if (creatures[PLAYER]->current_room == simple_obj[item_num]->current_room){
  750. if (simple_obj[SIMPLE_LEVER]->moved == false){
  751. simple_obj[SIMPLE_LEVER]->moved = true;
  752. printf("You turned on the electricity!\n\n");
  753. }
  754. else {
  755. printf("Electircity is already turned on.\n\n");
  756. simple_obj[SIMPLE_LEVER]->moved = false;
  757. }
  758. }
  759. }
  760. else
  761. printf("Incorrect password.\n\n");
  762. break;
  763. }
  764. }
  765. else
  766. printf("I can't recognize that.\n\n");
  767.  
  768. }
  769.  
  770. void world::Pick_Item(const String& move, int current_room, int creature, bool combat_mode){
  771.  
  772. if (combat_mode == false){
  773. bool quit_for = false;
  774. for (int i = 0; i < ITEMS_NUMB && quit_for == false; i++){
  775. if (creatures[creature]->prov_inv[i] == -1){
  776. if (Get_Item_Room(Get_Num(move)) == creatures[creature]->current_room){
  777. //It's hardcoded because it don't follows a pattern, every object has simple objects and every objects acts different.
  778. switch (Get_Num(move)){
  779. case ITEM_GLASS:
  780. quit_for = true;
  781. if (simple_obj[SIMPLE_SHELV]->moved == true){
  782. items[ITEM_GLASS]->carried = true;
  783. printf("You picked up the %s\n\n", move.string);
  784. Full_inventory(items[ITEM_GLASS]->item_num);
  785. }
  786. else
  787. printf("There is no %s here.\n\n", move.string);
  788. break;
  789.  
  790. case ITEM_KEY:
  791. quit_for = true;
  792. if (simple_obj[SIMPLE_FIREPLACE]->moved == true){
  793. items[ITEM_KEY]->carried = true;
  794. printf("You picked up the %s\n\n", move.string);
  795. Full_inventory(items[ITEM_KEY]->item_num);
  796. }
  797. else
  798. printf("There is no %s here.\n\n", move.string);
  799. break;
  800.  
  801. case ITEM_MATCHSTICK:
  802. quit_for = true;
  803. if (simple_obj[SIMPLE_DRAWER]->moved == true){
  804. items[ITEM_MATCHSTICK]->carried = true;
  805. printf("You picked up the %s\n\n", move.string);
  806. Full_inventory(items[ITEM_MATCHSTICK]->item_num);
  807. }
  808. else
  809. printf("There is no %s here.\n\n", move.string);
  810. break;
  811.  
  812. case ITEM_SWORD:
  813. quit_for = true;
  814. if (simple_obj[SIMPLE_CLOSET]->moved == true){
  815. items[ITEM_SWORD]->carried = true;
  816. printf("You picked up the %s\n\n", move.string);
  817. Full_inventory(items[ITEM_SWORD]->item_num);
  818. }
  819. else
  820. printf("There is no %s here.\n\n", move.string);
  821. break;
  822.  
  823. case ITEM_NOTE:
  824.  
  825. quit_for = true;
  826. if (simple_obj[SIMPLE_FISHGATE]->moved == true){
  827. items[ITEM_NOTE]->carried = true;
  828. printf("You picked up the %s\n\n", move.string);
  829. Full_inventory(items[ITEM_NOTE]->item_num);
  830. }
  831. else
  832. printf("There is no %s here.\n\n", move.string);
  833. break;
  834.  
  835. case ITEM_CHEST:
  836.  
  837. quit_for = true;
  838. items[ITEM_CHEST]->carried = true;
  839. printf("You picked up the %s\n\n", move.string);
  840. Full_inventory(items[ITEM_CHEST]->item_num);
  841.  
  842. break;
  843.  
  844. case ITEM_SHIELD:
  845.  
  846. quit_for = true;
  847. items[ITEM_SHIELD]->carried = true;
  848. printf("You picked up the %s\n\n", move.string);
  849. Full_inventory(items[ITEM_SHIELD]->item_num);
  850.  
  851. break;
  852.  
  853. case ITEM_PEAK:
  854. quit_for = true;
  855. items[ITEM_PEAK]->carried = true;
  856. printf("You picked up the %s.\n\n", move.string);
  857. Full_inventory(items[ITEM_PEAK]->item_num);
  858. break;
  859.  
  860. case ITEM_GUNPOWDER_CONTAINER:
  861. quit_for = true;
  862. if (simple_obj[SIMPLE_STRONGBOX]->moved == true){
  863. items[ITEM_GUNPOWDER_CONTAINER]->carried = true;
  864. printf("You picked up the %s\n\n", move.string);
  865. Full_inventory(items[ITEM_GUNPOWDER_CONTAINER]->item_num);
  866. }
  867. else
  868. printf("There is no %s here.\n\n", move.string);
  869. break;
  870.  
  871. case ITEM_STRONGBOX:
  872. quit_for = true;
  873. items[ITEM_GUNPOWDER_CONTAINER]->carried = true;
  874. printf("You picked up the %s\n\n", move.string);
  875. Full_inventory(items[ITEM_GUNPOWDER_CONTAINER]->item_num);
  876. break;
  877.  
  878. case ITEM_WICK:
  879. quit_for = true;
  880. items[ITEM_WICK]->carried = true;
  881. printf("You picked up the %s\n\n", move.string);
  882. Full_inventory(items[ITEM_WICK]->item_num);
  883. break;
  884.  
  885. case ITEM_FAN:
  886. quit_for = true;
  887. items[ITEM_FAN]->carried = true;
  888. printf("You picked up the %s\n\n", move.string);
  889. Full_inventory(items[ITEM_FAN]->item_num);
  890. break;
  891.  
  892. case ITEM_HP_CARD:
  893. quit_for = true;
  894. items[ITEM_HP_CARD]->carried = true;
  895. printf("You picked up the %s\n\n", move.string);
  896. Full_inventory(items[ITEM_HP_CARD]->item_num);
  897. break;
  898.  
  899. case ITEM_CANONBOUX:
  900. quit_for = true;
  901. items[ITEM_CANONBOUX]->carried = true;
  902. printf("You picked up the %s\n\n", move.string);
  903. Full_inventory(items[ITEM_CANONBOUX]->item_num);
  904. break;
  905.  
  906. case ITEM_FLAMETHROWER:
  907. quit_for = true;
  908. items[ITEM_FLAMETHROWER]->carried = true;
  909. printf("You picked up the %s\n\n", move.string);
  910. Full_inventory(items[ITEM_FLAMETHROWER]->item_num);
  911. break;
  912.  
  913. case ITEM_WATERWALL:
  914. quit_for = true;
  915. items[ITEM_WATERWALL]->carried = true;
  916. printf("You picked up the %s\n\n", move.string);
  917. Full_inventory(items[ITEM_WATERWALL]->item_num);
  918. break;
  919.  
  920. case ITEM_TNT:
  921. quit_for = true;
  922. items[ITEM_TNT]->carried = true;
  923. printf("You picked up the %s\n\n", move.string);
  924. Full_inventory(items[ITEM_TNT]->item_num);
  925. break;
  926.  
  927. case ITEM_DIPLOMA:
  928. quit_for = true;
  929. items[ITEM_DIPLOMA]->carried = true;
  930. printf("You picked up the %s\n\n", move.string);
  931. Full_inventory(items[ITEM_DIPLOMA]->item_num);
  932. break;
  933. }
  934. }
  935. }
  936.  
  937. }
  938. }
  939. else{
  940. printf("You sold %s!\n\n", move);
  941. for (int i = 0; i < MAX_OBJECTS; i++){
  942. if (creatures[creature]->prov_inv[i] == -1){
  943. creatures[creature]->prov_inv[i] = Get_Num(move);
  944. return;
  945. }
  946. }
  947. }
  948.  
  949. }
  950. void world::Drop_item(const String& move, int current_room, int creature, bool combat_mode){
  951. int i = 0;
  952. while (i < MAX_OBJECTS){
  953. if (Get_Num(move) == creatures[creature]->prov_inv[i]){
  954. items[creatures[creature]->prov_inv[i]]->item_room = creatures[creature]->current_room;
  955. items[creatures[creature]->prov_inv[i]]->carried = false;
  956. if (combat_mode == false)
  957. printf("You left the %s!\n\n", creatures[creature]->item_name(creatures[creature]->prov_inv[i]));
  958. creatures[creature]->prov_inv[i] = -1;
  959. break;
  960. }
  961. i++;
  962. }
  963. }
  964.  
  965. void world::look_item(const String& item_name){
  966. int item_num = Get_Num(item_name);
  967. //That's for looking photographies on BURNER.
  968. if (creatures[PLAYER]->current_room == items[ITEM_CHEST]->item_room)
  969.  
  970. if (creatures[PLAYER]->current_room == BURNER && item_name == "photographies"){
  971. printf("Say booom!\n\n");
  972. return;
  973. }
  974. else if (creatures[PLAYER]->current_room == DRAWING_ROOM && item_name == "strongbox"){
  975. printf("%s\n\n", items[ITEM_STRONGBOX]->name);
  976. return;
  977. }
  978. else if (creatures[PLAYER]->current_room == MINE && item_name == "dust"){
  979. printf("This is dust of rock, searching trough it you found a wick.\n\n");
  980. return;
  981. }
  982. else if (creatures[PLAYER]->current_room == OLD_MUM_ROOM && item_name == "wall"){
  983. printf("The strength of the wind I so powerfull, think what you have to do in order to achieve a CORREINTE DE AIRE!\n\n");
  984. return;
  985. }
  986. else if (creatures[PLAYER]->current_room == OLD_MUM_ROOM && item_name == "table" || item_name == "mirror"){
  987. printf("The table is so dirty and full of make up, useless things, the only objects that would make you some service would be a +25-HpCard that is on the table and the fan\n\n");
  988. return;
  989. }
  990.  
  991. if (item_num != -1 && isin_inventory(items[item_num]->name, PLAYER) == true){
  992. if (creatures[PLAYER]->current_room == items[item_num]->item_room)
  993. printf("%s", items[item_num]->description);
  994. else
  995. printf("There is no %s to look at.\n\n", items[item_num]->name);
  996. }
  997. else{
  998. printf("You can't look at an object that is not in your inventory.\n\n");
  999. }
  1000.  
  1001.  
  1002. }
  1003. bool world::isin_item(const String& item_name, const String& container){
  1004. int item_num = Get_Num(item_name);
  1005. int container_num = Get_Num(container);
  1006. for (int i = 0; i < MAX_ITEMS_STORAGE; i++){
  1007. if (item_num == items[container_num]->prov_inv[i]);
  1008. return true;
  1009. }
  1010. return false;
  1011. }
  1012.  
  1013. void world::Open_Stuff(int current_room, bool& action_done, int open_type, const String& move){
  1014. switch (open_type){
  1015. case INTERACT_DOOR:
  1016. {
  1017. //this is the function to open doors
  1018. char open_direc[10];
  1019. printf("What is the direction of the door that you want to open?\n\n");
  1020. printf(">: ");
  1021. scanf_s(" %s", &open_direc, 10);
  1022. String open_direc_str(open_direc);
  1023. printf("\n");
  1024. switch (creatures[PLAYER]->current_room){
  1025. case 0:
  1026. if (open_direc_str == "north" && exit[1]->open == false){
  1027. exit[1]->open = true;
  1028. action_done = true;
  1029. }
  1030. printf("You opened the %s!\n", exit[1]->name);
  1031. break;
  1032. case 1:
  1033. if (open_direc_str == "south" && exit[1]->open == false){
  1034. exit[1]->open = true;
  1035. action_done = true;
  1036. }
  1037. printf("You opened the %s!\n\n", exit[1]->name);
  1038. break;
  1039. }
  1040. printf("\n");
  1041. }
  1042. break;
  1043.  
  1044. case INTERACT_DRAWER:
  1045. if (creatures[PLAYER]->current_room == 4 && simple_obj[SIMPLE_DRAWER]->moved == false){
  1046. simple_obj[SIMPLE_DRAWER]->moved = true;
  1047. printf("You opened the drawer, revealing a matchstick of your daddy!\n\n");
  1048. }
  1049. else
  1050. printf("This is already opened!\n\n");
  1051. action_done = true;
  1052. break;
  1053.  
  1054. case INTERACT_CLOSET:
  1055. if (creatures[PLAYER]->current_room == 4 && simple_obj[SIMPLE_CLOSET]->moved == false){
  1056. simple_obj[SIMPLE_CLOSET]->moved = true;
  1057. printf("You opened the closet, and you discovered something you daddy didn't told you, he has a sword on the closet!\n\n");
  1058. }
  1059. else
  1060. printf("The closet is already opened.\n\n");
  1061. action_done = true;
  1062. break;
  1063.  
  1064. case INTERACT_CHEST:
  1065. if (creatures[PLAYER]->current_room == items[Get_Num(move)]->item_room){
  1066. simple_obj[SIMPLE_CHEST]->moved = true;
  1067. printf("You opened the %s! Inside you found:\n", items[SIMPLE_CHEST]->name);
  1068. Show_object_content(Get_Num(move));
  1069. }
  1070. else
  1071. printf("You can't do this now.\n\n");
  1072. action_done = true;
  1073. break;
  1074.  
  1075. case INTERACT_STRONGBOX:
  1076. if (creatures[PLAYER]->current_room == items[Get_Num(move)]->item_room){
  1077. simple_obj[SIMPLE_STRONGBOX]->moved = true;
  1078. printf("You opened the %s! Inside you found:\n", items[ITEM_STRONGBOX]->name);
  1079. Show_object_content(Get_Num(move));
  1080. }
  1081. else
  1082. printf("You can't do this now.\n\n");
  1083. action_done = true;
  1084. break;
  1085.  
  1086. case INTERACT_WINDOW:
  1087. char window_dir[10];
  1088. printf("Where is the window?\n\n>:");
  1089. scanf_s("%s", &window_dir, 10);
  1090. printf("\n");
  1091.  
  1092. String window_str(window_dir);
  1093.  
  1094. if (window_str == "south" && simple_obj[SIMPLE_WINDOW1]->moved == false){
  1095. simple_obj[SIMPLE_WINDOW1]->moved = true;
  1096. printf("You opened to south window!\n\n");
  1097. return;
  1098. }
  1099. else if (window_str == "west" && simple_obj[SIMPLE_WINDOW2]->moved == false){
  1100. simple_obj[SIMPLE_WINDOW2]->moved = true;
  1101. printf("You opened to west window!\n\n");
  1102. return;
  1103. }
  1104. else if (window_str == "east" && simple_obj[SIMPLE_WINDOW3]->moved == false){
  1105. simple_obj[SIMPLE_WINDOW3]->moved = true;
  1106. printf("You opened to east window!\n\n");
  1107. return;
  1108. }
  1109. else
  1110. printf("You can't open anything like this now.\n\n");
  1111. action_done = true;
  1112. break;
  1113. }
  1114. }
  1115. void world::Close_Stuff(int current_room, bool& action_done, int open_type, const String& move){
  1116. switch (open_type){
  1117. case INTERACT_DOOR:
  1118. {
  1119. //this is the function to open doors
  1120. char open_direc[10];
  1121. printf("What is the direction of the door that you want to close?\n\n");
  1122. printf(">: ");
  1123. scanf_s(" %s", &open_direc, 10);
  1124. String open_direc_str(open_direc);
  1125. printf("\n");
  1126. switch (creatures[PLAYER]->current_room){
  1127. case WEIRD_BEDROOM:
  1128. if (open_direc_str == "north" && exit[1]->open == true){
  1129. exit[1]->open = false;
  1130. action_done = true;
  1131. }
  1132. printf("You closed the %s!\n", exit[1]->name);
  1133. break;
  1134. case FIRE_CORRIDOR:
  1135. if (open_direc_str == "south" && exit[1]->open == true){
  1136. exit[1]->open = false;
  1137. action_done = true;
  1138. }
  1139. printf("You closed the %s!\n\n", exit[1]->name);
  1140. break;
  1141. }
  1142. printf("\n");
  1143. }
  1144. break;
  1145.  
  1146. case INTERACT_DRAWER:
  1147. if (creatures[PLAYER]->current_room == 4 && simple_obj[SIMPLE_DRAWER]->moved == true){
  1148. simple_obj[SIMPLE_DRAWER]->moved = false;
  1149. printf("You closed the drawer.\n\n");
  1150. }
  1151. else
  1152. printf("This is already closed!\n\n");
  1153. action_done = true;
  1154. break;
  1155.  
  1156. case INTERACT_CLOSET:
  1157. if (creatures[PLAYER]->current_room == 4 && simple_obj[SIMPLE_CLOSET]->moved == true){
  1158. simple_obj[SIMPLE_CLOSET]->moved = false;
  1159. printf("You closed the closet.\n\n");
  1160. }
  1161. else
  1162. printf("The closet is already closed.\n\n");
  1163. action_done = true;
  1164. break;
  1165.  
  1166. case INTERACT_CHEST:
  1167. if (creatures[PLAYER]->current_room == items[SIMPLE_CHEST]->item_room && simple_obj[SIMPLE_CHEST]->moved == true){
  1168. simple_obj[SIMPLE_CHEST]->moved = false;
  1169. printf("You closed the %s.\n\n", items[SIMPLE_CHEST]->name);
  1170. }
  1171. else
  1172. printf("The %s is already closed.\n\n", simple_obj[Get_Simple_Num(move)]->name);
  1173. action_done = true;
  1174. break;
  1175.  
  1176.  
  1177. case INTERACT_STRONGBOX:
  1178. if (creatures[PLAYER]->current_room == items[SIMPLE_STRONGBOX]->item_room && simple_obj[SIMPLE_STRONGBOX]->moved == true){
  1179. simple_obj[SIMPLE_STRONGBOX]->moved = false;
  1180. printf("You closed the %s.\n\n", simple_obj[SIMPLE_STRONGBOX]->name);
  1181. }
  1182. else
  1183. printf("The %s is already closed.\n\n", simple_obj[Get_Simple_Num(move)]->name);
  1184. action_done = true;
  1185. break;
  1186.  
  1187. case INTERACT_WINDOW:
  1188. char window_dir[10];
  1189. printf("Where is the window?\n\n>:");
  1190. scanf_s("%s", &window_dir, 10);
  1191. printf("\n");
  1192.  
  1193. String window_str(window_dir);
  1194.  
  1195. if (window_str == "south" && simple_obj[SIMPLE_WINDOW1]->moved == true){
  1196. simple_obj[SIMPLE_WINDOW1]->moved = false;
  1197. action_done = true;
  1198. printf("You closed the south window!\n\n");
  1199. return;
  1200. }
  1201. else if (window_str == "west" && simple_obj[SIMPLE_WINDOW2]->moved == true){
  1202. simple_obj[SIMPLE_WINDOW2]->moved = false;
  1203. action_done = true;
  1204. printf("You closed the west window!\n\n");
  1205. return;
  1206. }
  1207. else if (window_str == "east" && simple_obj[SIMPLE_WINDOW3]->moved == true){
  1208. simple_obj[SIMPLE_WINDOW3]->moved = false;
  1209. action_done = true;
  1210. printf("You closed the east window!\n\n");
  1211. return;
  1212. }
  1213. else
  1214. printf("You can't close this!!.\n\n");
  1215. action_done = true;
  1216. break;
  1217. }
  1218. }
  1219.  
  1220. void world::Full_inventory(int item_num){
  1221. int i = 0;
  1222. while (i < MAX_OBJECTS){
  1223. if (creatures[PLAYER]->prov_inv[i] == -1){
  1224. creatures[PLAYER]->prov_inv[i] = item_num;
  1225. break;
  1226. }
  1227. i++;
  1228. }
  1229. if (i == MAX_OBJECTS)
  1230. printf("You can't carry more things!\n\n");
  1231. }
  1232. void world::empty_inventory(int item_num){
  1233. int i = MAX_OBJECTS;
  1234. while (i > MAX_OBJECTS){
  1235. if (creatures[PLAYER]->prov_inv[i] == item_num){
  1236. creatures[PLAYER]->prov_inv[i] = -1;
  1237. break;
  1238. }
  1239. i++;
  1240. }
  1241. if (i == MAX_OBJECTS)
  1242. printf("You can't carry more things! Don't try to be impressive.");
  1243. }
  1244. void world::Show_inventory() const{
  1245. bool isempty = true;
  1246. for (uint i = 0; i < MAX_OBJECTS; i++){
  1247. if (creatures[PLAYER]->prov_inv[i] != -1){
  1248. isempty = false;
  1249. break;
  1250. }
  1251.  
  1252. }
  1253. if (isempty){
  1254. printf("Your inventory is empty!\n\n");
  1255. }
  1256.  
  1257. for (uint i = 0; i < MAX_OBJECTS && !isempty; i++){
  1258. if (creatures[PLAYER]->prov_inv[i] != -1)
  1259. printf("- %s\n", creatures[PLAYER]->item_name(creatures[PLAYER]->prov_inv[i]));
  1260. }
  1261. printf("\n");
  1262. }
  1263. void world::Show_sell_inventory() const{
  1264. bool isempty = true;
  1265. for (uint i = 0; i < MAX_OBJECTS; i++){
  1266. if (creatures[PLAYER]->prov_inv[i] != -1){
  1267. isempty = false;
  1268. break;
  1269. }
  1270.  
  1271. }
  1272. if (isempty){
  1273. printf("Your inventory is empty!\n\n");
  1274. }
  1275.  
  1276. for (uint i = 0; i < MAX_OBJECTS && !isempty; i++){
  1277. if (creatures[PLAYER]->prov_inv[i] != -1)
  1278. printf("- %s Cost: %d coins\n", creatures[PLAYER]->item_name(creatures[PLAYER]->prov_inv[i]), items[creatures[PLAYER]->prov_inv[i]]->cost);
  1279. }
  1280. }
  1281. bool world::isin_inventory(const String& item_name, int owner){
  1282. int i = 0;
  1283. bool isin = false;
  1284. while (i < MAX_OBJECTS){
  1285. if (creatures[owner]->prov_inv[i] == Get_Num(item_name))
  1286. isin = true;
  1287. i++;
  1288. }
  1289. return isin;
  1290. }
  1291.  
  1292. void world::Equip_item(const String& item_name){
  1293. //This is for equiping weapons
  1294. bool equiped = false;
  1295. int i = 0;
  1296. {
  1297. if (creatures[PLAYER]->item != -1)
  1298. printf("You can't equip more than one item.\n\n");
  1299. else{
  1300. if (creatures[PLAYER]->item == -1 && item_name == "sword" || item_name == "hammer" || item_name == "peak" || item_name == "uzy" && isin_inventory(item_name, PLAYER)){
  1301. creatures[PLAYER]->item = Get_Num(item_name);
  1302. equiped = true;
  1303. creatures[PLAYER]->item = Get_Num(item_name);
  1304. printf("You equipped the %s!\n\n", item_name);
  1305. creatures[PLAYER]->attack = items[creatures[PLAYER]->item]->attack;
  1306.  
  1307. }
  1308. if (creatures[PLAYER]->item == -1 && item_name == "AttackCard" || item_name == "DefenseCard" || item_name == "HPCard" && isin_inventory(item_name, PLAYER)){
  1309. creatures[PLAYER]->item = Get_Num(item_name);
  1310. equiped = true;
  1311. printf("You equipped the %s!\n\n", item_name);
  1312. if (creatures[PLAYER]->special_card == ITEM_ATTACK_CARD){
  1313. creatures[PLAYER]->attack += 5;
  1314. }
  1315. if (creatures[PLAYER]->item == ITEM_DEFENSE_CARD){
  1316. creatures[PLAYER]->defense += 10;
  1317. }
  1318. if (creatures[PLAYER]->item == ITEM_HP_CARD){
  1319. creatures[PLAYER]->hp += 20;
  1320. }
  1321. }
  1322. if (creatures[PLAYER]->defense == -1 && item_name == "shield" && isin_inventory(item_name, PLAYER)){
  1323. creatures[PLAYER]->defense = Get_Num(item_name);
  1324. equiped = true;
  1325. printf("You equipped the %s!\n\n", item_name);
  1326. if (creatures[PLAYER]->defense == ITEM_SHIELD){
  1327. creatures[PLAYER]->defense += 50;
  1328. }
  1329. }
  1330.  
  1331. if (equiped == false)
  1332. printf("You can't equip that item.\n\n");
  1333. }
  1334. }
  1335.  
  1336.  
  1337.  
  1338.  
  1339. }
  1340. void world::Unequip_item(const String& item_name){
  1341. //This is for unquiping weapons
  1342. if (item_name == "sword" || item_name == "hammer" || item_name == "peak"){
  1343. creatures[PLAYER]->item = -1;
  1344. creatures[PLAYER]->attack = 10;
  1345. }
  1346. else if (item_name == "AttackCard" || item_name == "DefenseCard" || item_name == "HPCard"){
  1347. creatures[PLAYER]->special_card = -1;
  1348. creatures[PLAYER]->attack -= 5;
  1349. }
  1350. else if (item_name == "shield"){
  1351. creatures[PLAYER]->defense = 5;
  1352.  
  1353. }
  1354. printf("You unequiped the %s.\n\n", item_name.string);
  1355.  
  1356. }
  1357. void world::BuyItem(int creature){
  1358. char item_to_buy[20];
  1359. printf("%s shop: \n", creatures[creature]->name);
  1360. for (int i = 0; i < MAX_OBJECTS; i++){
  1361. if (creatures[creature]->prov_inv[i] != -1)
  1362. printf("- %s Cost: %d\n", creatures[creature]->item_name(creatures[creature]->prov_inv[i]), items[creatures[creature]->prov_inv[i]]->cost);
  1363. }
  1364. printf("\n>: ");
  1365. scanf_s("%s", item_to_buy, 20);
  1366. String item_buy(item_to_buy);
  1367. if (item_buy == "stats"){
  1368. printf("\nHP: %d\nAttack: %d\nDefense: %d\nCoins: %d\n\n", creatures[PLAYER]->hp, creatures[PLAYER]->attack, creatures[PLAYER]->defense, creatures[PLAYER]->coins);
  1369.  
  1370. }
  1371. else if (isin_inventory(item_to_buy, creature)){
  1372. for (int i = 0; i < MAX_OBJECTS; i++){
  1373. if (creatures[creature]->prov_inv[i] == Get_Num(item_buy) && items[creatures[creature]->prov_inv[i]]->cost < creatures[PLAYER]->coins){
  1374. if (creatures[creature]->prov_inv[i] == Get_Num("coins"))
  1375. creatures[PLAYER]->coins += items[creatures[creature]->prov_inv[i]]->cost;
  1376. else
  1377. creatures[PLAYER]->coins -= items[creatures[creature]->prov_inv[i]]->cost;
  1378.  
  1379. printf("You bought %s!\n", creatures[creature]->item_name(creatures[creature]->prov_inv[i]));
  1380. printf("\n");
  1381. Full_inventory(Get_Num(item_buy));
  1382. creatures[creature]->prov_inv[i] = -1;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. void world::Sell_Item(const String& item_name, int creature_destination){
  1388. char sell[20];
  1389. char selling_weapon[20];
  1390. char to[20];
  1391. char monster[20];
  1392.  
  1393. printf("This is your inventory (write 'sell <item> to <creature name>' to sell an object)\n");
  1394. Show_sell_inventory();
  1395. printf("\n>:");
  1396. scanf_s("%s %s %s %s", &sell, 20, &selling_weapon, 20, &to, 20, &monster, 20);
  1397. String selling_weapon_str(selling_weapon);
  1398. String to_str(to);
  1399. String sell_str(sell);
  1400.  
  1401.  
  1402. if (isin_inventory(selling_weapon, PLAYER) && sell_str == "sell" && to_str == "to"){
  1403. Drop_item(selling_weapon, creatures[PLAYER]->current_room, PLAYER, true);
  1404. Pick_Item(selling_weapon, creatures[creature_destination]->current_room, creature_destination, true);
  1405. creatures[PLAYER]->coins += items[ITEM_SWORD]->cost;
  1406. //printf("You sold the %s and you recibed %d coins for that.", item_name, items[Get_Num(item_name)]->cost);
  1407. }
  1408. }
  1409.  
  1410. bool world::Enter_Battle(int creature){
  1411. printf("You entered to a battle with %s!!\n\n", creatures[creature]->name);
  1412. int it = 1, special_attacks = 0, special_damage = 0;
  1413. bool win = false;
  1414. char change_Weapon[30];
  1415. char weapon_selected[30];
  1416. char switcher[30];
  1417. bool player_turn = true;
  1418. while (creatures[PLAYER]->hp >= 0 && creatures[creature]->hp >= 0){
  1419. if (player_turn){
  1420. player_turn = false;
  1421. creatures[PLAYER]->damage = creatures[PLAYER]->attack - creatures[creature]->defense;
  1422. if (creatures[PLAYER]->damage < 0)
  1423. creatures[PLAYER]->damage = 0;
  1424. creatures[creature]->hp -= creatures[PLAYER]->damage;
  1425. printf("You hited %s and you did ", creatures[creature]->name);
  1426. printf("%d damage\n", creatures[PLAYER]->damage);
  1427. Sleep(1500);
  1428. }
  1429. else {
  1430. player_turn = true;
  1431. srand(time(NULL));
  1432. creatures[creature]->attack = rand() % 15;
  1433. creatures[creature]->damage = creatures[creature]->attack - creatures[PLAYER]->defense;
  1434.  
  1435. if (creatures[creature]->damage < 0)
  1436. creatures[creature]->damage = 0;
  1437. creatures[PLAYER]->hp -= creatures[creature]->damage;
  1438. printf("%s hited you and did ", creatures[creature]->name);
  1439. printf("%d damage.\n", creatures[creature]->damage);
  1440. Sleep(1500);
  1441. }
  1442.  
  1443. if (creatures[creature]->hp <= 0){
  1444. creatures[creature]->death = true;
  1445. printf("\nYou killed %s !! He left ", creatures[creature]->name);
  1446. printf("%d", creatures[creature]->coins);
  1447. printf(" coins and a %s", creatures[creature]->item_name(creatures[creature]->item));
  1448. printf("\n\n");
  1449. creatures[PLAYER]->coins += creatures[creature]->coins;
  1450. return false;
  1451. }
  1452. else if (creatures[PLAYER] <= 0){
  1453. printf("\nYou lost the game because you died, the blame is on %s!!!TRY NEXT TIME :D \n \n <press anny button to close the game>", creatures[creature]->name);
  1454. getchar();
  1455. return true;
  1456. }
  1457.  
  1458. if (it == 5){
  1459. printf("\n5 turns spended! Wanna take something from your backpack or throw an special attack? (write yes or no)");
  1460. printf("\nActual battle state: You: %d %s: //", creatures[PLAYER]->hp, creatures[creature]->name);
  1461. printf("%d", creatures[creature]->hp);
  1462. printf("\n\n>:");
  1463. scanf_s("%s", &switcher, 30);
  1464. printf("\n");
  1465. String switch_str(switcher);
  1466. if (switch_str == "yes" || switch_str == "Yes"){
  1467. printf("This are your current items:\n");
  1468. Show_inventory();
  1469. printf("These are your special attacks (write special to use): %d \n\n>: ", special_attacks);
  1470. scanf_s("%s", &weapon_selected, 30);
  1471. printf("\n");
  1472. String weapon_str(weapon_selected);
  1473. if (weapon_str == "special" && special_attacks > 0){
  1474. special_attacks--;
  1475. special_damage = rand() % 20 + 30;
  1476. printf("Critical hit! You did %d damage!\n", special_damage);
  1477. creatures[creature]->hp -= (special_damage - creatures[creature]->defense);
  1478. Sleep(1500);
  1479. }
  1480. else if (exist_item(weapon_str)){
  1481. if (creatures[PLAYER]->item != -1)
  1482. Unequip_item(creatures[PLAYER]->item_name(creatures[PLAYER]->item));
  1483. Equip_item(weapon_str);
  1484. }
  1485. else
  1486. printf("You can't do that");
  1487. }
  1488.  
  1489. }
  1490. if (it == 10){
  1491. printf("\n10 turns spended, you have an special attack available, pres U to use it, and S to save it.\n");
  1492. printf("\nActual battle state: You: %d %s: ", creatures[PLAYER]->hp, creatures[creature]->name);
  1493. printf("%d", creatures[creature]->hp);
  1494. printf("\n\n>:");
  1495. scanf_s("%s", &change_Weapon, 30);
  1496. String weapon_str2(change_Weapon);
  1497. if (weapon_str2 == "U"){
  1498. printf("\nSpecial Attack");
  1499. Sleep(1500);
  1500. printf(". ");
  1501. Sleep(1500);
  1502. printf(" . ");
  1503. Sleep(1500);
  1504. printf(" .");
  1505. Sleep(1500);
  1506. special_damage = rand() % 40 + 30;
  1507. printf("\nCritical hit! You did %d damage!\n", special_damage);
  1508. Sleep(1500);
  1509. creatures[creature]->hp -= (special_damage - creatures[creature]->defense);
  1510. }
  1511. else if (weapon_str2 == "S")
  1512. special_attacks++;
  1513.  
  1514. it = 0;
  1515. }
  1516. it++;
  1517. }
  1518. return false;
  1519. }
  1520.  
  1521. void world::Put_Objects(const String & move, int current_room){
  1522. char into[5];
  1523. char destination[20];
  1524. scanf_s("%s %s",&into, 5, &destination, 20);
  1525.  
  1526. String into_str(into);
  1527. String destination_str(destination);
  1528.  
  1529. printf("\n");
  1530. if (isin_inventory(move, PLAYER)){
  1531. if ((move == "glass" && destination_str == "fireplace" && simple_obj[SIMPLE_FIREPLACE]->moved == false)){
  1532. simple_obj[SIMPLE_FIREPLACE]->moved = true;
  1533. printf("You turned off the fireplace, there is no burning now so you realize a little gold shining that seems to be a key!\n\n");
  1534. }
  1535.  
  1536. if ((move == "wick" && destination_str == "gunpowder" && isin_inventory(move, PLAYER) && isin_inventory(destination_str, PLAYER))){
  1537. printf("You mixed those elements and you crafted a bomb!\n\n");
  1538. for (int i = 0; i < MAX_OBJECTS; i++){
  1539. if (creatures[PLAYER]->prov_inv[i] == ITEM_WICK || creatures[PLAYER]->prov_inv[i] == ITEM_GUNPOWDER_CONTAINER){
  1540. creatures[PLAYER]->prov_inv[i] = -1;
  1541. }
  1542. }
  1543. Full_inventory(ITEM_BOMB);
  1544. }
  1545. }
  1546. }
  1547. void world::Get_object_from_object(const String& item_name, int current_room){
  1548. char from[5];
  1549. char container[20];
  1550. scanf_s("%s %s", &from, 5, &container, 20);
  1551. String into_str(from);
  1552. String container_str(container);
  1553.  
  1554. if (isin_item(item_name, container_str) && items[Get_Num(item_name)]->item_room == creatures[PLAYER]->current_room){
  1555. int item_num = Get_Num(item_name);
  1556. int container_num = Get_Num(container_str);
  1557. Full_inventory(item_num);
  1558. Empty_item(item_name, container_str);
  1559. printf("You picked up the %s.\n\n", item_name);
  1560. }
  1561. }
  1562.  
  1563. void world::Show_object_content(int item_num){
  1564. int count = 0;
  1565. for (int i = 0; i < MAX_ITEMS_STORAGE; i++){
  1566. if (items[item_num]->prov_inv[i] != -1)
  1567. printf("- %s.\n", items[item_num]->Get_Name(items[item_num]->prov_inv[count++]));
  1568. else
  1569. continue;
  1570. }
  1571. printf("\n");
  1572. }
  1573. int world::Get_Num(const String& item_name) const{
  1574. if (item_name == "glass")
  1575. return ITEM_GLASS;
  1576. else if (item_name == "key")
  1577. return ITEM_KEY;
  1578. else if (item_name == "matchstick")
  1579. return ITEM_MATCHSTICK;
  1580. else if (item_name == "sword")
  1581. return ITEM_SWORD;
  1582. else if (item_name == "chest")
  1583. return ITEM_CHEST;
  1584. else if (item_name == "AttackCard")
  1585. return ITEM_ATTACK_CARD;
  1586. else if (item_name == "hammer")
  1587. return ITEM_HAMMER;
  1588. else if (item_name == "note")
  1589. return ITEM_HAMMER;
  1590. else if (item_name == "shield")
  1591. return ITEM_SHIELD;
  1592. else if (item_name == "peak")
  1593. return ITEM_PEAK;
  1594. else if (item_name == "gunpowder")
  1595. return ITEM_GUNPOWDER_CONTAINER;
  1596. else if (item_name == "DefenseCard")
  1597. return ITEM_DEFENSE_CARD;
  1598. else if (item_name == "strongbox")
  1599. return ITEM_STRONGBOX;
  1600. else if (item_name == "wick")
  1601. return ITEM_WICK;
  1602. else if (item_name == "bomb")
  1603. return ITEM_BOMB;
  1604. else if (item_name == "fan")
  1605. return ITEM_FAN;
  1606. else if (item_name == "HPCard")
  1607. return ITEM_HP_CARD;
  1608. else if (item_name == "flamethrower")
  1609. return ITEM_FLAMETHROWER;
  1610. else if (item_name == "canonboux")
  1611. return ITEM_CANONBOUX;
  1612. else if (item_name == "waterwall")
  1613. return ITEM_WATERWALL;
  1614. else if (item_name == "tnt")
  1615. return ITEM_TNT;
  1616. else if (item_name == "diploma")
  1617. return ITEM_DIPLOMA;
  1618. else if (item_name == "belt")
  1619. return ITEM_ATTACK_BELT;
  1620. else if (item_name == "coins")
  1621. return ITEM_COIN_BOX;
  1622. else if (item_name == "uzy")
  1623. return ITEM_UZY;
  1624. else if (item_name == "knife")
  1625. return ITEM_KNIFE;
  1626. else if (item_name == "posion")
  1627. return ITEM_POSION;
  1628. else if (item_name == "armos")
  1629. return ITEM_ARMOR;
  1630. else
  1631. return -1;
  1632.  
  1633. }
  1634. int world::Get_Simple_Num(const String& item_name) const{
  1635. if (item_name== "shelving")
  1636. return SIMPLE_SHELV;
  1637. else if (item_name == "fireplace")
  1638. return SIMPLE_FIREPLACE;
  1639. else if (item_name == "drawer")
  1640. return SIMPLE_DRAWER;
  1641. else if (item_name == "closet")
  1642. return SIMPLE_CLOSET;
  1643. else if (item_name == "chest")
  1644. return SIMPLE_CHEST;
  1645. else if (item_name == "fishgate")
  1646. return SIMPLE_FISHGATE;
  1647. else if (item_name == "lever")
  1648. return SIMPLE_LEVER;
  1649. else if (item_name == "container")
  1650. return SIMPLE_CONTAINER;
  1651. else if (item_name == "strongbox")
  1652. return SIMPLE_STRONGBOX;
  1653. else if (item_name == "dust")
  1654. return SIMPLE_DUST;
  1655. else if (item_name == "window_s")
  1656. return SIMPLE_WINDOW1;
  1657. else if (item_name == "window_e")
  1658. return SIMPLE_WINDOW2;
  1659. else if (item_name == "window_w")
  1660. return SIMPLE_WINDOW3;
  1661. else
  1662. return -1;
  1663.  
  1664. }
  1665.  
  1666. int world::Get_Item_Room(int item_num) const{
  1667. switch (item_num){
  1668. case ITEM_GLASS: return items[ITEM_GLASS]->item_room; break;
  1669. case ITEM_KEY: return items[ITEM_KEY]->item_room; break;
  1670. case ITEM_MATCHSTICK: return items[ITEM_MATCHSTICK]->item_room; break;
  1671. case ITEM_SWORD: return items[ITEM_SWORD]->item_room; break;
  1672. case ITEM_CHEST: return items[ITEM_CHEST]->item_room; break;
  1673. case ITEM_ATTACK_CARD: return items[ITEM_ATTACK_CARD]->item_room; break;
  1674. case ITEM_HAMMER: return items[ITEM_HAMMER]->item_room; break;
  1675. case ITEM_NOTE: return items[ITEM_NOTE]->item_room; break;
  1676. case ITEM_SHIELD: return items[ITEM_SHIELD]->item_room; break;
  1677. case ITEM_PEAK: return items[ITEM_PEAK]->item_room; break;
  1678. case ITEM_GUNPOWDER_CONTAINER: return items[ITEM_GUNPOWDER_CONTAINER]->item_room; break;
  1679. case ITEM_DEFENSE_CARD: return items[ITEM_DEFENSE_CARD]->item_room; break;
  1680. case ITEM_STRONGBOX: return items[ITEM_STRONGBOX]->item_room; break;
  1681. case ITEM_WICK: return items[ITEM_WICK]->item_room; break;
  1682. case ITEM_BOMB: return items[ITEM_BOMB]->item_room; break;
  1683. case ITEM_FAN: return items[ITEM_FAN]->item_room; break;
  1684. case ITEM_HP_CARD: return items[ITEM_HP_CARD]->item_room; break;
  1685. case ITEM_FLAMETHROWER: return items[ITEM_FLAMETHROWER]->item_room; break;
  1686. case ITEM_CANONBOUX: return items[ITEM_CANONBOUX]->item_room; break;
  1687. case ITEM_WATERWALL: return items[ITEM_WATERWALL]->item_room; break;
  1688. case ITEM_TNT: return items[ITEM_TNT]->item_room; break;
  1689. case ITEM_DIPLOMA: return items[ITEM_DIPLOMA]->item_room; break;
  1690. }
  1691. }
  1692. unsigned int world::Carried_Obj_Numb(){
  1693. int obj_numb = 0;
  1694. for (int i = 0; i < ITEMS_NUMB; i++){
  1695. if (items[i]->carried == true)
  1696. obj_numb++;
  1697. }
  1698. return obj_numb;
  1699. }
  1700. void world::Hit_Stuff(const String& move){
  1701. char item[20];
  1702. char with[5];
  1703. scanf_s("%s %s", &with, 5, &item, 20);
  1704.  
  1705. String item_str(item);
  1706. String with_str(with);
  1707.  
  1708. if (creatures[PLAYER]->current_room == EARTH_CORRIDOR && (move == "rock" || move == "rocks") && item_str == "peak" && isin_inventory("peak", PLAYER)){
  1709. exit[14]->open = true;
  1710. printf("You hit the rock with the peak and you broke the wall, now you can go in.\n\n ");
  1711. }
  1712.  
  1713. }
  1714. void world::Empty_item(const String& item_name, const String& container_str){
  1715. int item_num = Get_Num(item_name);
  1716. int container_num = Get_Num(container_str);
  1717. for (int i = 0; i < MAX_ITEMS_STORAGE; i++){
  1718. if (item_num == items[container_num]->prov_inv[i])
  1719. items[container_num]->prov_inv[i] = -1;
  1720. }
  1721. }
  1722. bool world::exist_item(const String& item_name) const{
  1723. int returning = Get_Num(item_name);
  1724. return returning != -1;
  1725. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement