Atrinik Server 2.5
Defines | Functions | Variables
types/monster.c File Reference
#include <global.h>

Go to the source code of this file.

Defines

#define MAX_KNOWN_SPELLS   20

Functions

static int can_detect_enemy (object *op, object *enemy, rv_vector *rv)
static objectfind_nearest_enemy (object *ob)
static int move_randomly (object *op)
static int can_hit (object *ob1, rv_vector *rv)
static objectmonster_choose_random_spell (object *monster, uint32 flags)
static int monster_cast_spell (object *head, object *part, int dir, rv_vector *rv, uint32 flags)
static int monster_use_bow (object *head, object *part, int dir)
static int dist_att (int dir, object *part, rv_vector *rv)
static int run_att (int dir, object *ob, object *part, rv_vector *rv)
static int hitrun_att (int dir, object *ob)
static int wait_att (int dir, object *ob, object *part, rv_vector *rv)
static int disthit_att (int dir, object *ob, object *part, rv_vector *rv)
static int wait_att2 (int dir, rv_vector *rv)
static void circ1_move (object *ob)
static void circ2_move (object *ob)
static void pace_movev (object *ob)
static void pace_moveh (object *ob)
static void pace2_movev (object *ob)
static void pace2_moveh (object *ob)
static void rand_move (object *ob)
static int talk_to_wall (object *op, object *npc, char *txt)
void set_npc_enemy (object *npc, object *enemy, rv_vector *rv)
objectcheck_enemy (object *npc, rv_vector *rv)
objectfind_enemy (object *npc, rv_vector *rv)
int move_monster (object *op)
static int can_detect_target (object *op, object *target, int range, int srange, rv_vector *rv)
static int monster_spell_useful (object *target, int spell_id)
void communicate (object *op, char *txt)
static char * find_matching_message (const char *msg, const char *match)
int talk_to_npc (object *op, object *npc, char *txt)
int faction_is_friend_of (object *mon, object *pl)
int is_friend_of (object *op, object *obj)
int check_good_weapon (object *who, object *item)
int check_good_armour (object *who, object *item)

Variables

spell_struct spells [NROFREALSPELLS]

Detailed Description

Monster memory, NPC interaction, AI, and other related functions are in this file, all used by the monster type objects.

Definition in file monster.c.


Function Documentation

static int can_detect_enemy ( object op,
object enemy,
rv_vector rv 
) [static]

Controls if monster still can see/detect its enemy.

Includes visibility but also map and area control.

Parameters:
opThe monster object.
enemyMonster object's enemy.
rvRange vector.
Returns:
1 if can see/detect, 0 otherwise.

Definition at line 320 of file monster.c.

static int can_detect_target ( object op,
object target,
int  range,
int  srange,
rv_vector rv 
) [static]

Check if monster can detect target (invisibility and being in range).

Parameters:
opMonster.
targetThe target to check.
rangeRange this object can see.
srangeStealth range this object can see.
rvRange vector.
Returns:
1 if can detect target, 0 otherwise.

Definition at line 736 of file monster.c.

static int can_hit ( object ob1,
rv_vector rv 
) [static]

Check if object can hit another object.

Parameters:
ob1Monster object.
rvRange vector.
Returns:
1 if can hit, 0 otherwise.

Definition at line 925 of file monster.c.

object* check_enemy ( object npc,
rv_vector rv 
)

Checks if NPC's enemy is still valid.

Parameters:
npcThe NPC object.
rvRange vector of the enemy.
Returns:
Enemy object if valid, NULL otherwise.

Definition at line 221 of file monster.c.

int check_good_armour ( object who,
object item 
)

Checks if using armor 'item' would be better for 'who'.

Parameters:
whoCreature considering to apply item.
itemItem to check.
Returns:
1 if item is a better object, 0 otherwise.

Definition at line 1980 of file monster.c.

int check_good_weapon ( object who,
object item 
)

Checks if using weapon 'item' would be better for 'who'.

Parameters:
whoCreature considering to apply item.
itemItem to check.
Returns:
1 if item is a better object, 0 otherwise.

Definition at line 1931 of file monster.c.

static void circ1_move ( object ob) [static]

Circle type of move.

Parameters:
obMonster.

Definition at line 1369 of file monster.c.

static void circ2_move ( object ob) [static]

Different type of circle type move.

Parameters:
obMonster.

Definition at line 1387 of file monster.c.

void communicate ( object op,
char *  txt 
)

Communication between NPC and player.

Parameters:
opWho is saying something.
txtWhat was said.

Definition at line 1513 of file monster.c.

static int dist_att ( int  dir,
object part,
rv_vector rv 
) [static]

Monster does a distance attack.

Parameters:
dirDirection.
partPart of the object.
rvRange vector.
Returns:
New direction.

Definition at line 1239 of file monster.c.

static int disthit_att ( int  dir,
object ob,
object part,
rv_vector rv 
) [static]

Distance hit attack.

Parameters:
dirDirection.
obMonster.
partPart of the monster.
rvRange vector.
Returns:
New direction.

Definition at line 1341 of file monster.c.

int faction_is_friend_of ( object mon,
object pl 
)

Check if player is a friend or enemy of monster's faction.

Parameters:
monMonster.
plThe player.
Return values:
-1Neutral.
0Enemy.
1Friend.

Definition at line 1820 of file monster.c.

object* find_enemy ( object npc,
rv_vector rv 
)

Tries to find an enemy for NPC. We pass the range vector since our caller will find the information useful.

Parameters:
npcThe NPC object.
rvRange vector.
Returns:
Enemy object if found, NULL otherwise.

Definition at line 243 of file monster.c.

static char* find_matching_message ( const char *  msg,
const char *  match 
) [static]

This function takes the message to be parsed in 'msg', the text to match in 'match', and returns the portion of the message.

Parameters:
msgMessage to parse.
matchText to try to match.
Returns:
Returned portion which should be freed later, NULL if there was no match.

Definition at line 1621 of file monster.c.

static object * find_nearest_enemy ( object ob) [static]

Finds nearest enemy for a monster.

Parameters:
obThe monster.
Returns:
Nearest enemy, NULL if none.

Definition at line 771 of file monster.c.

static int hitrun_att ( int  dir,
object ob 
) [static]

Hit and run type of attack.

Parameters:
dirDirection.
obMonster.
Returns:
New direction.

Definition at line 1285 of file monster.c.

int is_friend_of ( object op,
object obj 
)

Check if object op is friend of obj.

Parameters:
opThe first object
objThe second object to check against the first one
Returns:
1 if both objects are friends, 0 otherwise

Definition at line 1859 of file monster.c.

static int monster_cast_spell ( object head,
object part,
int  dir,
rv_vector rv,
uint32  flags 
) [static]

Tries to make a monster cast a spell.

Parameters:
headHead of the monster.
partPart of the monster that we use to cast.
dirDirection to cast.
rvRange vector describing where the enemy is. If NULL, will attempt to find a friendly object to cast the spell on.
flagsFlags the spell must have.
Returns:
1 if monster casted a spell, 0 otherwise.

Definition at line 1010 of file monster.c.

static object * monster_choose_random_spell ( object monster,
uint32  flags 
) [static]

Choose a random spell this monster could cast.

Parameters:
monsterThe monster object.
flagsFlags the spell must have.
Returns:
Random spell object, NULL if no spell found.

Definition at line 942 of file monster.c.

static int monster_spell_useful ( object target,
int  spell_id 
) [static]

Check if it's worth it for monster to cast a spell, based on the target.

Parameters:
targetTarget.
spell_idSpell ID being checked.
Returns:
1 if it's worth it, 0 otherwise.

Definition at line 989 of file monster.c.

static int monster_use_bow ( object head,
object part,
int  dir 
) [static]

Tries to make a (part of a) monster fire a bow.

Parameters:
headHead of the monster.
partPart of the monster that we use to fire.
dirDirection to cast.
Returns:
1 if monster fired something, 0 otherwise.

Definition at line 1148 of file monster.c.

int move_monster ( object op)

Monster moves its tick.

Parameters:
opThe monster.
Returns:
1 if the object has been freed, 0 otherwise.

Definition at line 362 of file monster.c.

static int move_randomly ( object op) [static]

Randomly move a monster.

Parameters:
opThe monster object to move.
Returns:
1 if the monster was moved, 0 otherwise.

Definition at line 849 of file monster.c.

static void pace2_moveh ( object ob) [static]

Another type of horizontal pace movement.

Parameters:
obMonster.

Definition at line 1469 of file monster.c.

static void pace2_movev ( object ob) [static]

Another type of vertical pace movement.

Parameters:
obMonster.

Definition at line 1445 of file monster.c.

static void pace_moveh ( object ob) [static]

Horizontal pace movement.

Parameters:
obMonster.

Definition at line 1425 of file monster.c.

static void pace_movev ( object ob) [static]

Vertical pace movement.

Parameters:
obMonster.

Definition at line 1405 of file monster.c.

static void rand_move ( object ob) [static]

Random movement.

Parameters:
obMonster.

Definition at line 1493 of file monster.c.

static int run_att ( int  dir,
object ob,
object part,
rv_vector rv 
) [static]

Monster runs.

Parameters:
dirDirection.
obThe monster.
partPart of the monster.
rvRange vector.
Returns:
New direction.

Definition at line 1265 of file monster.c.

void set_npc_enemy ( object npc,
object enemy,
rv_vector rv 
)

Update (or clear) an NPC's enemy. Perform most of the housekeeping related to switching enemies

You should always use this method to set (or clear) an NPC's enemy.

If enemy is given an aggro wp may be set up. If rv is given, it will be filled out with the vector to enemy

enemy and/or rv may be NULL.

Parameters:
npcThe NPC object we're setting enemy for.
enemyThe enemy object, NULL if we're clearing the enemy for this NPC.
rvRange vector of the enemy.

Definition at line 72 of file monster.c.

int talk_to_npc ( object op,
object npc,
char *  txt 
)

Give an object the chance to handle something being said.

Plugin hooks will be called.

Parameters:
opWho is talking.
npcObject to try to talk to. Can be an NPC or a MAGIC_EAR.
txtWhat op is saying.
Returns:
0 if text was handled by a plugin or not handled, 1 if handled internally by the server.

Definition at line 1720 of file monster.c.

static int talk_to_wall ( object op,
object npc,
char *  txt 
) [static]

Talk to a magic ear.

Parameters:
opWho is talking.
npcThe magic ear.
txtText said.
Returns:
1 if text matches something, 0 otherwise.

Definition at line 1782 of file monster.c.

static int wait_att ( int  dir,
object ob,
object part,
rv_vector rv 
) [static]

Wait, and attack.

Parameters:
dirDirection.
obMonster.
partPart of the monster.
rvRange vector.
Returns:
New direction.

Definition at line 1310 of file monster.c.

static int wait_att2 ( int  dir,
rv_vector rv 
) [static]

Wait and attack.

Parameters:
dirDirection.
rvRange vector.
Returns:
New direction.

Definition at line 1356 of file monster.c.


Variable Documentation

spell_struct spells[NROFREALSPELLS]

Array of all the spells.

Definition at line 34 of file spellist.h.