Ludum Dare 29
HackSoc's entry for the Ludum Dare Jam 29
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
mob.c File Reference
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <math.h>
#include "mob.h"
#include "level.h"
#include "utils.h"
#include "effect.h"
#include "player.h"
Include dependency graph for mob.c:

Functions

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

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:

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: