/* * The implementation of rat monsters. This is the initial example of * an animal-intelligence monster. */ #include #include #include "mon.h" #include "vars.h" #include "dice.h" #include "structs.h" /* * The rat tick method. Just use the standard animal tick. */ static void rat_tick(MONST *m) { std_animal_tick(m); } /* * The rat bemoved method. Nothing to do here. */ static void rat_bemoved(MONST *m __attribute__((__unused__))) { } /* * The rat name method. */ static const char *rat_name(MONST *m __attribute__((__unused__))) { return("the rat"); } /* * The rat Name method. */ static const char *rat_Name(MONST *m __attribute__((__unused__))) { return("The rat"); } /* * The rat attack method. They don't have all that good a hit chance. */ static int rat_attack(MONST *m __attribute__((__unused__))) { return(rnd(25)); } /* * The rat defend method. They have semi-decent defense (largely from * their small size). */ static int rat_defend(MONST *m __attribute__((__unused__))) { return(rnd(50)); } /* * The rat damage method. They do minor damage. */ static DAMAGE rat_givedamage(MONST *m __attribute__((__unused__)), int dd __attribute__((__unused__))) { return(DMG_ORDINARY(roll("d1000"))); } /* * The rat MONOPS vector. */ static MONOPS ops = { &rat_tick, &rat_bemoved, &rat_name, &rat_Name, &rat_attack, &rat_defend, &rat_givedamage, &std_takedamage, &std_kill, &std_destroy }; /* * Create a new rat. */ static MONST *new_r(MONST *m, LEVEL *lv __attribute__((__unused__))) { m->symbol = 'r'; m->hp = 3000; m->maxhp = 3000; m->baseflags = Z_mad ? MBF_TRACKING : 0; m->ops = &ops; return(m); } /* * The rat ctl method. */ static void monctl_r(MONST *m, int op, ...) { va_list ap; va_start(ap,op); switch (op) { case MCTL_AGGR: { int ag; ag = va_arg(ap,int); if (ag) m->baseflags |= MBF_TRACKING; else m->baseflags &= ~MBF_TRACKING; } break; } va_end(ap); } /* * The rat MTINFO. */ #define basespeed_r TIMESCALE #define baseheal_r 3 #define exp_r 1000 MTINFO mtinfo_r = MTINFO_INIT(r);