Ludum Dare 29
HackSoc's entry for the Ludum Dare Jam 29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Typedefs | Functions
mob.h File Reference
#include "item.h"
#include "level.h"
#include "utils.h"
#include "list.h"
Include dependency graph for mob.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Mob
 

Typedefs

typedef struct Mob Mob
 

Functions

bool move_mob (struct Mob *mob, unsigned int x, unsigned int y)
 
bool move_mob_relative (struct Mob *mob, int xdiff, int ydiff)
 
bool move_mob_level (Mob *mob, bool toprev)
 
bool damage_mob (struct Mob *mob, unsigned int amount)
 
void attack_mob (Mob *attacker, Mob *defender)
 
struct Mobkill_mob (struct Mob *mob)
 
bool can_see_point (struct Level *level, unsigned int x0, unsigned int y0, unsigned int x, unsigned int y)
 
bool can_see (struct Mob *mob, unsigned int x, unsigned int y)
 
bool can_see_other (struct Mob *moba, struct Mob *mobb)
 
void simple_enemy_turn (Mob *enemy)
 

Typedef Documentation

typedef struct Mob Mob

A mob is something which roams around the world, they are tied to a level, and all the mobs in one level form a doubly-linked list. There are a couple of callbacks associated with them to determine what happens in certain situations.

Function Documentation

void attack_mob ( Mob attacker,
Mob defender 
)

Attack a mob, modified by the weapon of the attacker and the armour of the defender.

Parameters
attackerThe mob doing the attacking.
defenderThe mob being attacked.

Here is the call graph for this function:

Here is the caller graph for this function:

bool can_see ( Mob mob,
unsigned int  x,
unsigned int  y 
)

Determine if a mob can see the given point.

Note: as this will be primarily used to render the level, a better version might be to operate on a 2d array of three-state variables ("visible", "blocked", and "unknown"), and just iterate the algorithm with different starting points until every point is known. This would avoid the need to check each individual point, possibly duplicating work.

Parameters
mobThe mob
xThe target X coordinate
yThe target Y coordinate

Here is the call graph for this function:

Here is the caller graph for this function:

bool can_see_other ( Mob moba,
Mob mobb 
)

Wrapper for can_see, to determine if a mob can see another mob.

Parameters
mobaOne of the mobs
mobbThe other. It really doesn't matter which way around they are.

Here is the call graph for this function:

Here is the caller graph for this function:

bool can_see_point ( Level level,
unsigned int  x0,
unsigned int  y0,
unsigned int  x,
unsigned int  y 
)

Determine if one point can be seen from another. All points are visible unless there is a wall in the way. This uses Bresenham's line algorithm to determine line-of-sight.

Parameters
levelThe level to check
x0The starting X
y0The starting Y
xThe target X
yThe target Y

Here is the caller graph for this function:

bool damage_mob ( Mob mob,
unsigned int  damage 
)

Damage a mob.

Parameters
mobEntity to damage.
damageAmount of damage to apply to the mob.
Returns
If this killed the mob, a mob is dead if its health drops to zero or below.

Here is the caller graph for this function:

struct Mob* kill_mob ( Mob mob)

Kill a mob - free it, and remove it from the lists.

Parameters
mobThe mob to kill
Returns
The next mob in the list, or NULL

Here is the call graph for this function:

Here is the caller graph for this function:

bool move_mob ( Mob mob,
unsigned int  x,
unsigned int  y 
)

Move the given mob to the new coordinates.

Parameters
mobEntity to move.
xTarget x position.
yTarget y position.
Returns
false if the given space can't be moved into.

Here is the call graph for this function:

Here is the caller graph for this function:

bool move_mob_level ( Mob mob,
bool  toprev 
)

Moves the given mod to the next or previous level.

Parameters
mobMob to move.
toprevDetermines which direction the movement is in. If true, the movement is to the previous level, otherwise to the next.
Returns
If the mob moved sucessfully.

Here is the call graph for this function:

Here is the caller graph for this function:

bool move_mob_relative ( Mob mob,
int  xdiff,
int  ydiff 
)

Move a mob by a relative position

Parameters
mobEntity to move.
xdiffx-coordinate difference.
ydiffy-coordinate difference.
Returns
If the mob was moved successfully.

Here is the call graph for this function:

Here is the caller graph for this function:

void simple_enemy_turn ( Mob enemy)

A very simple enemy: move towards the player, and damage them if adjacent.

Parameters
enemyEntity to move.

Here is the call graph for this function:

Here is the caller graph for this function: