#include #include "vars.h" #include "fuses.h" #include "pline.h" #include "effect.h" #include "structs.h" #include "phasing.h" typedef struct phasepriv PHASEPRIV; /* * The private data for a phasing effect. */ struct phasepriv { MONST *m; TIME exp1; TIME exp2; int expfuse; EFFECT *eff; } ; static void apply_phase(MONST *m, void *sp __attribute__((__unused__))) { m->effflags |= MEF_PHASING; } static void death_phase(MONST *m __attribute__((__unused__)), void *sp) { cancelfuse(((PHASEPRIV *)sp)->expfuse); free(sp); } static EFFECTOPS effops_phase = EFFECTOPS_INIT(phase); static void phase_expire(long int liarg __attribute__((__unused__)), void *pv) { PHASEPRIV *pp; pp = pv; if (pp->exp2) { pp->exp1 = pp->exp2; pp->exp2 = 0; if (pp->m == you) pline("Your phasing seems to be wearing off..."); pp->expfuse = addfuse_abs(&phase_expire,0,pp,pp->exp1); return; } if (pp->m == you) pline("You are now back in phase."); effect_remove(pp->m,pp->eff); free(pp); } /* * Phase a monster, or extend its existing phasing, for the specified * number of ticks. If ticks2 is zero, phasing ends after ticks1; if * not, the monster is warned after ticks1 and ticks2 additional time * is added on. */ void phase_mon(MONST *m, int ticks1, int ticks2) { PHASEPRIV *p; p = malloc(sizeof(PHASEPRIV)); p->m = m; p->exp1 = curtime + (ticks1 * TIMESCALE); p->exp2 = ticks2 ? p->exp1 + (ticks2 * TIMESCALE) : 0; p->expfuse = addfuse_abs(&phase_expire,0,p,p->exp1); p->eff = effect_add(m,p,&effops_phase); }