DungeonCrawl
Loading...
Searching...
No Matches
monster.h File Reference

Declares routines for creating and destroying monster characters. More...

#include "character.h"

Go to the source code of this file.

Functions

character_tcreate_new_goblin (memory_pool_t *memory_pool)
 Creates and initializes a new goblin character.

Detailed Description

Declares routines for creating and destroying monster characters.

Definition in file monster.h.

Function Documentation

◆ create_new_goblin()

character_t * create_new_goblin ( memory_pool_t * memory_pool)

Creates and initializes a new goblin character.

Parameters
memory_poolA pointer to the memory pool used for allocating the goblin character
Returns
A pointer to the newly created goblin character, or NULL if memory allocation fails

Definition at line 8 of file monster.c.

8 {
9 NULL_PTR_HANDLER_RETURN(memory_pool, NULL, "Goblin", "Memory pool is NULL");
10
11 character_t* goblin = init_character(memory_pool, MONSTER, "Goblin");
12 NULL_PTR_HANDLER_RETURN(goblin, NULL, "Goblin", "Failed to allocate memory for goblin");
13
14 set_character_stats(goblin, 5, 5, 5, 5);
15 set_character_dmg_modifier(goblin, PHYSICAL, 10);
16 set_character_dmg_modifier(goblin, MAGICAL, 5);
17 set_xp_reward(goblin, 120);
18 set_level(goblin, 1);
19 return goblin;
20}
void set_character_stats(character_t *character, int strength, int intelligence, int dexterity, int constitution)
Sets the stats for a character.
Definition character.c:66
character_t * init_character(memory_pool_t *memory_pool, const character_type_t type, const char *name)
Initializes a new character.
Definition character.c:13
void set_character_dmg_modifier(character_t *character, damage_type_t type, int value)
Sets the damage modifier for a character.
Definition character.c:115
void set_xp_reward(character_t *character, int xp_reward)
Sets the XP reward for a character.
Definition character.c:310
void set_level(character_t *character, int level)
Sets the level for a character.
Definition character.c:305