nexus/spell.c

54 lines
1.3 KiB
C

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "defs.h"
#include "flag.h"
#include "map.h"
#include "objects.h"
#include "text.h"
extern lifeform_t *player;
void dospelleffects(lifeform_t *caster, enum OBTYPE spellid, lifeform_t *target) {
char buf[BUFLEN];
if (spellid == OT_S_RNDTELEPORT) {
cell_t *c = NULL;
while (!c || c->type->solid) {
c = getrandomcell(target->cell->map);
}
if ((target->controller != C_PLAYER) && haslos(player, target->cell)) {
getlfname(target, buf);
capitalise(buf);
msg("%s disappears in a puff of smoke!", buf);
}
// TODO: add smoke
movelf(target, c);
// TODO: add more smoke
if (target->controller == C_PLAYER) {
msg("Suddenly, your surroundings appear different!");
} else if (haslos(player, target->cell)) {
getlfname(target, buf);
capitalise(buf);
msg("%s appears in a puff of smoke!", buf);
}
} else if (spellid == OT_S_MAPPING) {
int x,y;
map_t *m;
m = caster->cell->map;
// reveal map
for (y = 0; y < m->h; y++) {
for (x = 0; x < m->w; x++) {
cell_t *c;
c = getcellat(m, x, y);
c->known = B_TRUE;
}
}
if (target->controller == C_PLAYER) {
msg("An image of your surroundings appears in your mind!");
}
}
}