/* * The implementation of urchin monsters. This is the initial example * of a human-intelligence monster. (Of course, they aren't actually * as smart as a human.) */ #include #include #include "mon.h" #include "obj.h" #include "dice.h" #include "vars.h" #include "pline.h" #include "objtypes.h" #include "obj-armour.h" /* * The urchin tick method. Use the standard human tick, unless next to * the player, in which case there's a small chance of pickpocketing. */ static void urchin_tick(MONST *m) { int amt; INVOBJ *io; if ( (m->loc->on == you->loc->on) && (abs(m->loc->x-you->loc->x) < 2) && (abs(m->loc->y-you->loc->y) < 2) && onein(10) ) { for (io=you->invent.inv;io;io=io->link) if (io->v[0]->type == OBJ_GOLD) break; if (io) { amt = roll("d4") * (onein(2) ? 5 : 1); if (amt > io->dispn) amt = io->dispn; if (amt < io->dispn) io = inventory_split_n(io,amt,-1); inv_move_1(&you->invent,io,&m->invent); pline("The urchin picks your pocket, taking %d gp!",amt); } else { pline("The urchin tries to pick your pocket, but you have no gold."); } } else { std_human_tick(m); } } /* * The urchin bevmoed method. Nothing to do here. */ static void urchin_bemoved(MONST *m __attribute__((__unused__))) { } /* * The urchin name method. */ static const char *urchin_name(MONST *m __attribute__((__unused__))) { return("the urchin"); } /* * The urchin Name method. */ static const char *urchin_Name(MONST *m __attribute__((__unused__))) { return("The urchin"); } /* * The urchin attack method. They have a half-decent hit chance. */ static int urchin_attack(MONST *m __attribute__((__unused__))) { return(rnd(100)); } /* * The urchin defend method. They don't have much innate defense. */ static int urchin_defend(MONST *m __attribute__((__unused__))) { return(rnd(25)); } /* * The urchin damage method. They do minor damage. */ static DAMAGE urchin_givedamage(MONST *m __attribute__((__unused__)), int dd __attribute__((__unused__))) { return(DMG_ORDINARY(roll("d1000"))); } /* * The urchin MONOPS vector. */ static MONOPS ops = { &urchin_tick, &urchin_bemoved, &urchin_name, &urchin_Name, &urchin_attack, &urchin_defend, &urchin_givedamage, &std_takedamage, &std_kill, &std_destroy }; /* * Create a new urchin. */ static MONST *new_u(MONST *m, LEVEL *lv __attribute__((__unused__))) { OBJ *o; m->symbol = 'u'; m->hp = 3000; m->maxhp = 3000; m->baseflags = Z_mad ? MBF_TRACKING : 0; m->ops = &ops; if (rnd(2)) { o = obj_make(OBJ_GOLD); o->number = roll("d4"); add_obj_to_inv(o,&m->invent); } return(m); } /* * The urchin ctl method. */ static void monctl_u(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 urchin MTINFO. */ #define basespeed_u TIMESCALE #define baseheal_u 3 #define exp_u 1500 MTINFO mtinfo_u = MTINFO_INIT(u);