version 1.16 | | version 1.17 |
---|
| | |
/* | | /* |
* static char *rcsid_spell_util_c = | | * static char *rcsid_spell_util_c = |
* "$Id: spell_util.c,v 1.16 2000/06/08 16:08:42 jec Exp $"; | | * "$Id: spell_util.c,v 1.17 2000/06/13 13:30:03 jec Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
void move_swarm_spell(object *op) | | void move_swarm_spell(object *op) |
{ | | { |
sint16 x,y; | | static int cardinal_adjust[9] = { -3, -2, -1, 0, 0, 0, 1, 2, 3 }; |
int di; | | static int diagonal_adjust[10] = { -3, -2, -2, -1, 0, 0, 1, 2, 2, 3 }; |
| | sint16 target_x, target_y, origin_x, origin_y; |
| | int basedir, adjustdir; |
| | |
if(op->stats.hp == 0 || get_owner (op) == NULL) { | | if(op->stats.hp == 0 || get_owner (op) == NULL) { |
remove_ob(op); | | remove_ob(op); |
| | |
} | | } |
op->stats.hp--; | | op->stats.hp--; |
| | |
if(op->stats.hp) | | basedir = op->direction; |
di=RANDOM()%7-3; /* get a random number of -3->3 */ | | if(basedir == 0) { |
else | | /* spray in all directions! 8) */ |
di=0; /* fire the last one from forward. */ | | basedir = RANDOM()%8+1; |
x = op->x + freearr_x[absdir(op->direction +di)]; | | } |
y = op->y + freearr_y[absdir(op->direction +di)]; | | |
| | /* new offset calculation to make swarm element distribution |
| | more uniform */ |
| | if(op->stats.hp) { |
| | if(basedir & 1) { |
| | adjustdir = cardinal_adjust[RANDOM()%9]; |
| | } else { |
| | adjustdir = diagonal_adjust[RANDOM()%10]; |
| | } |
| | } else { |
| | adjustdir = 0; /* fire the last one from forward. */ |
| | } |
| | |
| | target_x = op->x + freearr_x[absdir(basedir + adjustdir)]; |
| | target_y = op->y + freearr_y[absdir(basedir + adjustdir)]; |
| | |
| | /* back up one space so we can hit point-blank targets, but this |
| | necessitates extra out_of_map check below */ |
| | origin_x = target_x - freearr_x[basedir]; |
| | origin_y = target_y - freearr_y[basedir]; |
| | |
/* for level dependence, we need to know what spell is fired. */ | | /* for level dependence, we need to know what spell is fired. */ |
/* that's stored in op->stats.sp by fire_swarm */ | | /* that's stored in op->stats.sp by fire_swarm */ |
if ( ! wall (op->map, x, y)) | | if ( ! wall (op->map, target_x, target_y) |
fire_arch_from_position (op, op, x, y, op->direction, op->other_arch, | | && ! out_of_map(op->map, origin_x, origin_y)) |
op->stats.sp, op->magic); | | fire_arch_from_position (op, op, origin_x, origin_y, basedir, |
| | op->other_arch, op->stats.sp, op->magic); |
} | | } |
| | |
| | |