version 1.97 | | version 1.98 |
---|
| | |
/* | | /* |
* static char *rcsid_monster_c = | | * static char *rcsid_monster_c = |
* "$Id: monster.c,v 1.97 2006/03/14 15:33:28 ryo_saeba Exp $"; | | * "$Id: monster.c,v 1.98 2006/05/05 09:26:35 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
#include <skills.h> | | #include <skills.h> |
#endif | | #endif |
| | |
| | static int can_hit(object *ob1, object *ob2, rv_vector *rv); |
| | static int monster_cast_spell(object *head, object *part,object *pl,int dir, rv_vector *rv); |
| | static int monster_use_scroll(object *head, object *part, object *pl, int dir, rv_vector *rv); |
| | static int monster_use_skill(object *head, object *part, object *pl, int dir); |
| | static int monster_use_range(object *head, object *part, object *pl, int dir); |
| | static int monster_use_bow(object *head, object *part, object *pl, int dir); |
| | static void monster_check_pickup(object *monster); |
| | static int monster_can_pick(object *monster, object *item); |
| | static void monster_apply_below(object *monster); |
| | static int dist_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv); |
| | static int run_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv); |
| | static int hitrun_att(int dir, object *ob, object *enemy); |
| | static int wait_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv); |
| | static int disthit_att(int dir, object *ob, object *enemy, object *part, rv_vector *rv); |
| | static int wait_att2(int dir, object *ob, object *enemy, object *part, 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_npc(object *op, object *npc, const char *txt); |
| | static int talk_to_wall(object *pl, object *npc, const char *txt); |
| | |
| | |
#define MIN_MON_RADIUS 3 /* minimum monster detection radius */ | | #define MIN_MON_RADIUS 3 /* minimum monster detection radius */ |
| | |
| | |
* many cases. | | * many cases. |
*/ | | */ |
| | |
object *find_enemy(object *npc, rv_vector *rv) | | static object *find_enemy(object *npc, rv_vector *rv) |
{ | | { |
object *attacker, *tmp=NULL; | | object *attacker, *tmp=NULL; |
| | |
| | |
* returns 1 if the monster should wake up, 0 otherwise. | | * returns 1 if the monster should wake up, 0 otherwise. |
*/ | | */ |
| | |
int check_wakeup(object *op, object *enemy, rv_vector *rv) { | | static int check_wakeup(object *op, object *enemy, rv_vector *rv) { |
int radius = op->stats.Wis>MIN_MON_RADIUS?op->stats.Wis:MIN_MON_RADIUS; | | int radius = op->stats.Wis>MIN_MON_RADIUS?op->stats.Wis:MIN_MON_RADIUS; |
| | |
/* Trim work - if no enemy, no need to do anything below */ | | /* Trim work - if no enemy, no need to do anything below */ |
| | |
return 0; | | return 0; |
} | | } |
| | |
int move_randomly(object *op) { | | static int move_randomly(object *op) { |
int i; | | int i; |
| | |
/* Give up to 15 chances for a monster to move randomly */ | | /* Give up to 15 chances for a monster to move randomly */ |
| | |
} | | } |
return 0; | | return 0; |
} | | } |
int can_hit(object *ob1,object *ob2, rv_vector *rv) { | | |
| | static int can_hit(object *ob1,object *ob2, rv_vector *rv) { |
object *more; | | object *more; |
rv_vector rv1; | | rv_vector rv1; |
| | |
| | |
* wizard spells, as the check is against sp, and not grace. | | * wizard spells, as the check is against sp, and not grace. |
* can mosnters know cleric spells? | | * can mosnters know cleric spells? |
*/ | | */ |
object *monster_choose_random_spell(object *monster) { | | static object *monster_choose_random_spell(object *monster) { |
object *altern[MAX_KNOWN_SPELLS]; | | object *altern[MAX_KNOWN_SPELLS]; |
object *tmp; | | object *tmp; |
int i=0; | | int i=0; |
| | |
* rv is the vector which describes where the enemy is. | | * rv is the vector which describes where the enemy is. |
*/ | | */ |
| | |
int monster_cast_spell(object *head, object *part,object *pl,int dir, rv_vector *rv) { | | static int monster_cast_spell(object *head, object *part,object *pl,int dir, rv_vector *rv) { |
object *spell_item; | | object *spell_item; |
object *owner; | | object *owner; |
rv_vector rv1; | | rv_vector rv1; |
| | |
} | | } |
| | |
| | |
int monster_use_scroll(object *head, object *part,object *pl,int dir, rv_vector *rv) { | | static int monster_use_scroll(object *head, object *part,object *pl,int dir, rv_vector *rv) { |
object *scroll; | | object *scroll; |
object *owner; | | object *owner; |
rv_vector rv1; | | rv_vector rv1; |
| | |
* stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 | | * stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 |
*/ | | */ |
| | |
int monster_use_skill(object *head, object *part, object *pl,int dir) { | | static int monster_use_skill(object *head, object *part, object *pl,int dir) { |
object *skill, *owner; | | object *skill, *owner; |
| | |
if(!(dir=path_to_player(part,pl,0))) | | if(!(dir=path_to_player(part,pl,0))) |
| | |
| | |
/* Monster will use a ranged spell attack. */ | | /* Monster will use a ranged spell attack. */ |
| | |
int monster_use_range(object *head,object *part,object *pl,int dir) | | static int monster_use_range(object *head,object *part,object *pl,int dir) |
{ | | { |
object *wand, *owner; | | object *wand, *owner; |
int at_least_one = 0; | | int at_least_one = 0; |
| | |
return 0; | | return 0; |
} | | } |
| | |
int monster_use_bow(object *head, object *part, object *pl, int dir) { | | static int monster_use_bow(object *head, object *part, object *pl, int dir) { |
object *owner; | | object *owner; |
| | |
if(!(dir=path_to_player(part,pl,0))) | | if(!(dir=path_to_player(part,pl,0))) |
| | |
* return true if item is a better object. | | * return true if item is a better object. |
*/ | | */ |
| | |
int check_good_weapon(object *who, object *item) { | | static int check_good_weapon(object *who, object *item) { |
object *other_weap; | | object *other_weap; |
int val=0, i; | | int val=0, i; |
| | |
| | |
| | |
} | | } |
| | |
int check_good_armour(object *who, object *item) { | | static int check_good_armour(object *who, object *item) { |
object *other_armour; | | object *other_armour; |
int val=0,i; | | int val=0,i; |
| | |
| | |
* affect stacking on this space. | | * affect stacking on this space. |
*/ | | */ |
| | |
void monster_check_pickup(object *monster) { | | static void monster_check_pickup(object *monster) { |
object *tmp,*next; | | object *tmp,*next; |
int next_tag; | | int next_tag; |
| | |
| | |
* I've already utilized flags for bows, wands, rings, etc, etc. -Frank. | | * I've already utilized flags for bows, wands, rings, etc, etc. -Frank. |
*/ | | */ |
| | |
int monster_can_pick(object *monster, object *item) { | | static int monster_can_pick(object *monster, object *item) { |
int flag=0; | | int flag=0; |
int i; | | int i; |
| | |
| | |
* then make him apply it | | * then make him apply it |
*/ | | */ |
| | |
void monster_apply_below(object *monster) { | | static void monster_apply_below(object *monster) { |
object *tmp, *next; | | object *tmp, *next; |
| | |
for(tmp=monster->below;tmp!=NULL;tmp=next) { | | for(tmp=monster->below;tmp!=NULL;tmp=next) { |
| | |
return 0; | | return 0; |
} | | } |
| | |
void circ1_move (object *ob) { | | static void circ1_move (object *ob) { |
static int circle [12] = {3,3,4,5,5,6,7,7,8,1,1,2}; | | static int circle [12] = {3,3,4,5,5,6,7,7,8,1,1,2}; |
if(++ob->move_status > 11) | | if(++ob->move_status > 11) |
ob->move_status = 0; | | ob->move_status = 0; |
| | |
(void) move_object(ob,RANDOM()%8+1); | | (void) move_object(ob,RANDOM()%8+1); |
} | | } |
| | |
void circ2_move (object *ob) { | | static void circ2_move (object *ob) { |
static int circle[20] = {3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,1,1,1,2,2}; | | static int circle[20] = {3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,1,1,1,2,2}; |
if(++ob->move_status > 19) | | if(++ob->move_status > 19) |
ob->move_status = 0; | | ob->move_status = 0; |
| | |
(void) move_object(ob,RANDOM()%8+1); | | (void) move_object(ob,RANDOM()%8+1); |
} | | } |
| | |
void pace_movev(object *ob) { | | static void pace_movev(object *ob) { |
if (ob->move_status++ > 6) | | if (ob->move_status++ > 6) |
ob->move_status = 0; | | ob->move_status = 0; |
if (ob->move_status < 4) | | if (ob->move_status < 4) |
| | |
(void) move_object(ob,1); | | (void) move_object(ob,1); |
} | | } |
| | |
void pace_moveh (object *ob) { | | static void pace_moveh (object *ob) { |
if (ob->move_status++ > 6) | | if (ob->move_status++ > 6) |
ob->move_status = 0; | | ob->move_status = 0; |
if (ob->move_status < 4) | | if (ob->move_status < 4) |
| | |
(void) move_object(ob,7); | | (void) move_object(ob,7); |
} | | } |
| | |
void pace2_movev (object *ob) { | | static void pace2_movev (object *ob) { |
if (ob->move_status ++ > 16) | | if (ob->move_status ++ > 16) |
ob->move_status = 0; | | ob->move_status = 0; |
if (ob->move_status <6) | | if (ob->move_status <6) |
| | |
else return; | | else return; |
} | | } |
| | |
void pace2_moveh (object *ob) { | | static void pace2_moveh (object *ob) { |
if (ob->move_status ++ > 16) | | if (ob->move_status ++ > 16) |
ob->move_status = 0; | | ob->move_status = 0; |
if (ob->move_status <6) | | if (ob->move_status <6) |
| | |
else return; | | else return; |
} | | } |
| | |
void rand_move (object *ob) { | | static void rand_move (object *ob) { |
int i; | | int i; |
if (ob->move_status <1 || ob->move_status >8 || | | if (ob->move_status <1 || ob->move_status >8 || |
!(move_object(ob,ob->move_status|| ! (RANDOM()% 9)))) | | !(move_object(ob,ob->move_status|| ! (RANDOM()% 9)))) |
| | |
return 0; | | return 0; |
} | | } |
| | |
int talk_to_npc(object *op, object *npc, const char *txt) { | | static int talk_to_npc(object *op, object *npc, const char *txt) { |
object *cobj; | | object *cobj; |
| | |
/* Move this commone area up here - shouldn't cost much extra cpu | | /* Move this commone area up here - shouldn't cost much extra cpu |
| | |
return 1; | | return 1; |
} | | } |
| | |
int talk_to_wall(object* pl, object *npc, const char *txt) { | | static int talk_to_wall(object* pl, object *npc, const char *txt) { |
| | |
object* inv; | | object* inv; |
| | |