#include #include "vars.h" #include "fuses.h" #include "pline.h" #include "effect.h" #include "structs.h" #include "speed.h" typedef struct speedpriv SPEEDPRIV; /* * The private data for a haste/slow effect. */ struct speedpriv { MONST *m; TIME expires; int expfuse; EFFECT *eff; } ; static void apply_haste(MONST *m, void *sp __attribute__((__unused__))) { m->speed /= 2; } static void death_haste(MONST *m __attribute__((__unused__)), void *sp) { cancelfuse(((SPEEDPRIV *)sp)->expfuse); free(sp); } static EFFECTOPS effops_haste = EFFECTOPS_INIT(haste); static void haste_expire(long int liarg __attribute__((__unused__)), void *pv) { SPEEDPRIV *sp; sp = pv; if (sp->m == you) pline("You seem to be slowing down."); effect_remove(sp->m,sp->eff); free(sp); } /* * Haste a monster, or extend its existing haste, for the specified * number of ticks. */ void haste_mon(MONST *m, int ticks) { SPEEDPRIV *p; p = malloc(sizeof(SPEEDPRIV)); p->m = m; p->expires = curtime + (ticks * TIMESCALE); p->expfuse = addfuse_abs(&haste_expire,0,p,p->expires); p->eff = effect_add(m,p,&effops_haste); }