LI2 Roguelite
monster.h
Go to the documentation of this file.
1 #ifndef _MONSTER_H_
2 #define _MONSTER_H_
3 
4 typedef struct state State;
5 typedef struct map Map;
6 
28 typedef struct monster {
29  unsigned int x;
30  unsigned int y;
31  int health;
33  int attack;
34  int defense;
35  // int speed;
36  int is_alive;
37  char symbol;
38  char *name;
39  int color;
41  int pathfinding; // 0: random, 1: searching, 2: towards player, 3: away from player, 4: recruiting
42  int gold;
43  const char *noise;
44  int index;
45  // Item drop; // TODO
47 
48 #define NUMBER_OF_MONSTERS 5
49 
50 // Pathfinding types
51 #define PATHFINDING_RANDOM 0
52 #define PATHFINDING_SEARCHING 1
53 #define PATHFINDING_TOWARDS_PLAYER 2
54 #define PATHFINDING_AWAY_FROM_PLAYER 3
55 #define PATHFINDING_RECRUITING 4
56 
57 // Rat
58 #define RAT_HEALTH 20
59 #define RAT_ATTACK 3
60 #define RAT_DEFENSE 0
61 #define RAT_SYMBOL 'r'
62 #define RAT_COLOR COLOR_GREEN
63 #define RAT_GOLD_MIN 1 // * 10
64 #define RAT_GOLD_MAX 2 // * 10
65 #define RAT_NOISE "squeaks and sniffles"
66 
67 // Goblin
68 #define GOBLIN_HEALTH 30
69 #define GOBLIN_ATTACK 5
70 #define GOBLIN_DEFENSE 10
71 #define GOBLIN_SYMBOL 'g'
72 #define GOBLIN_COLOR COLOR_MAGENTA
73 #define GOBLIN_GOLD_MIN 1
74 #define GOBLIN_GOLD_MAX 3
75 #define GOBLIN_NOISE "robbing noises"
76 
77 // Orc
78 #define ORC_HEALTH 40
79 #define ORC_ATTACK 8
80 #define ORC_DEFENSE 20
81 #define ORC_SYMBOL 'o'
82 #define ORC_COLOR COLOR_RED
83 #define ORC_GOLD_MIN 2
84 #define ORC_GOLD_MAX 4
85 #define ORC_NOISE "grunts and growls"
86 
87 // Troll
88 #define TROLL_HEALTH 50
89 #define TROLL_ATTACK 10
90 #define TROLL_DEFENSE 30
91 #define TROLL_SYMBOL 't'
92 #define TROLL_COLOR COLOR_YELLOW
93 #define TROLL_GOLD_MIN 3
94 #define TROLL_GOLD_MAX 4
95 #define TROLL_NOISE "laughs and grunts"
96 
97 // Dragon
98 #define DRAGON_HEALTH 60
99 #define DRAGON_ATTACK 20
100 #define DRAGON_DEFENSE 50
101 #define DRAGON_SYMBOL 'd'
102 #define DRAGON_COLOR COLOR_BLUE
103 #define DRAGON_GOLD_MIN 4
104 #define DRAGON_GOLD_MAX 5
105 #define DRAGON_NOISE "roars and growls"
106 
107 Monster *initMonster(int x, int y, int health, int attack, int defense, char symbol, char *name, int color, int pathfinding, int gold, const char *noise, int index);
108 void moveMonster(State *st, Monster* monster, int x, int y);
109 // void drawMonster(State *st, Monster *monster, int mode);
110 void drawMonsters(State* st);
111 void freeMonster(void *p);
112 // TODO void freeMonsters(Monster **monsters, int nMonsters);
113 
115 void moveMonsters(State* st, Monster **monsters, int nMonsters);
116 
117 #endif
void freeMonster(void *p)
Free the monster.
Definition: monster.c:515
void moveMonsters(State *st, Monster **monsters, int nMonsters)
Move all the monsters.
Definition: monster.c:476
void moveMonster(State *st, Monster *monster, int x, int y)
Move the monster to the given coordinates.
Definition: monster.c:168
struct monster Monster
Structure of a monster.
void drawMonsters(State *st)
Draw all the monsters on the map.
Definition: monster.c:151
Monster * initMonster(int x, int y, int health, int attack, int defense, char symbol, char *name, int color, int pathfinding, int gold, const char *noise, int index)
Initialize a new monster.
Definition: monster.c:29
Monster ** generateMonsters(Map *map)
Generate monsters array randomly.
Definition: monster.c:457
Structure that represents a map in the game.
Definition: map.h:26
Structure of a monster.
Definition: monster.h:28
int health
Definition: monster.h:31
int attack
Definition: monster.h:33
int max_health
Definition: monster.h:32
int color
Definition: monster.h:39
char symbol
Definition: monster.h:37
int defense
Definition: monster.h:34
unsigned int x
Definition: monster.h:29
int pathfinding
Definition: monster.h:41
int default_color
Definition: monster.h:40
char * name
Definition: monster.h:38
unsigned int y
Definition: monster.h:30
int is_alive
Definition: monster.h:36
int gold
Definition: monster.h:42
int index
Definition: monster.h:44
const char * noise
Definition: monster.h:43
Sructure of the game state.
Definition: state.h:38