version 1.49 | | version 1.50 |
---|
| | |
/* | | /* |
* static char *rcsid_time_c = | | * static char *rcsid_time_c = |
* "$Id: time.c,v 1.49 2003/01/07 09:39:15 garbled Exp $"; | | * "$Id: time.c,v 1.50 2003/01/08 08:39:21 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
object *wor=op; | | object *wor=op; |
while(op!=NULL&&op->type!=PLAYER) | | while(op!=NULL&&op->type!=PLAYER) |
op=op->env; | | op=op->env; |
| | |
if(op!=NULL) { | | if(op!=NULL) { |
if(blocks_magic(op->map,op->x,op->y)) | | if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) |
new_draw_info(NDI_UNIQUE, 0,op,"You feel something fizzle inside you."); | | new_draw_info(NDI_UNIQUE, 0,op,"You feel something fizzle inside you."); |
else | | else |
enter_exit(op,wor); | | enter_exit(op,wor); |
| | |
void move_arrow(object *op) { | | void move_arrow(object *op) { |
object *tmp; | | object *tmp; |
sint16 new_x, new_y; | | sint16 new_x, new_y; |
int was_reflected; | | int was_reflected, mflags; |
| | mapstruct *m; |
| | |
if(op->map==NULL) { | | if(op->map==NULL) { |
LOG (llevError, "BUG: Arrow had no map.\n"); | | LOG (llevError, "BUG: Arrow had no map.\n"); |
| | |
new_y = op->y + DIRY(op); | | new_y = op->y + DIRY(op); |
was_reflected = 0; | | was_reflected = 0; |
| | |
/* See if there is any living object on target map square */ | | m = op->map; |
tmp = out_of_map (op->map, new_x, new_y) | | mflags = get_map_flags(m, &m, new_x, new_y, &new_x, &new_y); |
? NULL : get_map_ob (op->map, new_x, new_y); | | |
while (tmp != NULL && ! QUERY_FLAG (tmp, FLAG_ALIVE)) | | |
tmp = tmp->above; | | |
| | |
/* A bad problem was that a monster can throw or fire something and then | | |
* it run in it. Not only this is a sync. problem, the monster will also | | |
* hit herself and used as his own enemy! Result is, that many monsters | | |
* start to hit herself dead. | | |
* I removed both: No monster can be hit from his own missile and it can't | | |
* be his own enemy. - MT, 25.11.01 */ | | |
| | |
if (tmp != NULL && tmp != op->owner) | | if (mflags & P_OUT_OF_MAP) { |
{ | | stop_arrow(op); |
| | return; |
| | } |
| | |
| | /* only need to look for living creatures if this flag is set */ |
| | if (mflags & P_IS_ALIVE) { |
| | for (tmp = get_map_ob(m, new_x, new_y); tmp != NULL; tmp=tmp->above) |
| | if (QUERY_FLAG(tmp, FLAG_ALIVE)) break; |
| | |
| | |
| | /* Not really fair, but don't let monsters hit themselves with |
| | * their own arrow - this can be because they fire it then |
| | * move into it. |
| | */ |
| | |
| | if (tmp != NULL && tmp != op->owner) { |
/* Found living object, but it is reflecting the missile. Update | | /* Found living object, but it is reflecting the missile. Update |
* as below. (Note that for living creatures there is a small | | * as below. (Note that for living creatures there is a small |
* chance that reflect_missile fails.) | | * chance that reflect_missile fails.) |
*/ | | */ |
if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (!QUERY_FLAG(tmp, | | |
FLAG_ALIVE) || (rndm(0, 99)) < 90-op->level/10)) | | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && |
{ | | (rndm(0, 99)) < (90-op->level/10)) { |
| | |
int number = op->face->number; | | int number = op->face->number; |
| | |
op->direction = absdir (op->direction + 4); | | op->direction = absdir (op->direction + 4); |
| | |
number -= 8; | | number -= 8; |
op->face = &new_faces[number]; | | op->face = &new_faces[number]; |
} | | } |
if (wall (op->map, new_x, new_y)) { | | |
/* Target is standing on a wall. Let arrow turn around before | | |
* the wall. */ | | |
new_x = op->x; | | |
new_y = op->y; | | |
} | | |
was_reflected = 1; /* skip normal movement calculations */ | | was_reflected = 1; /* skip normal movement calculations */ |
} | | } |
else | | else { |
{ | | |
/* Attack the object. */ | | /* Attack the object. */ |
op = hit_with_arrow (op, tmp); | | op = hit_with_arrow (op, tmp); |
if (op == NULL) | | if (op == NULL) |
return; | | return; |
} | | } |
} | | } /* if this is not hitting its owner */ |
| | } /* if there is something alive on this space */ |
| | |
if ( ! was_reflected && wall (op->map, new_x, new_y)) | | |
{ | | if (mflags & P_WALL) { |
/* if the object doesn't reflect, stop the arrow from moving */ | | /* if the object doesn't reflect, stop the arrow from moving |
| | * note that this code will now catch cases where a monster is |
| | * on a wall but has reflecting - the arrow won't reflect. |
| | * Mapmakers shouldn't put monsters on top of wall in the first |
| | * place, so I don't consider that a problem. |
| | */ |
if(!QUERY_FLAG(op, FLAG_REFLECTING) || !(rndm(0, 19))) { | | if(!QUERY_FLAG(op, FLAG_REFLECTING) || !(rndm(0, 19))) { |
stop_arrow (op); | | stop_arrow (op); |
return; | | return; |
| | |
* the object should now take. | | * the object should now take. |
*/ | | */ |
| | |
int left= wall(op->map,op->x+freearr_x[absdir(op->direction-1)], | | int left, right; |
op->y+freearr_y[absdir(op->direction-1)]), | | |
right=wall(op->map,op->x+freearr_x[absdir(op->direction+1)], | | |
op->y+freearr_y[absdir(op->direction+1)]); | | left= get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction-1)], |
| | op->y+freearr_y[absdir(op->direction-1)], NULL, NULL) & P_WALL; |
| | right=get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction+1)], |
| | op->y+freearr_y[absdir(op->direction+1)], NULL, NULL) & P_WALL; |
| | |
if(left==right) | | if(left==right) |
op->direction=absdir(op->direction+4); | | op->direction=absdir(op->direction+4); |
| | |
op->direction=absdir(op->direction-2); | | op->direction=absdir(op->direction-2); |
} | | } |
/* Is the new direction also a wall? If show, shuffle again */ | | /* Is the new direction also a wall? If show, shuffle again */ |
if(wall(op->map,op->x+DIRX(op),op->y+DIRY(op))) { | | if(get_map_flags(op->map,NULL, op->x+DIRX(op),op->y+DIRY(op), NULL, NULL) & P_WALL) { |
int left= wall(op->map,op->x+freearr_x[absdir(op->direction-1)], | | int left, right; |
op->y+freearr_y[absdir(op->direction-1)]), | | |
right=wall(op->map,op->x+freearr_x[absdir(op->direction+1)], | | left= get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction-1)], |
op->y+freearr_y[absdir(op->direction+1)]); | | op->y+freearr_y[absdir(op->direction-1)], NULL, NULL) & P_WALL; |
| | right = get_map_flags(op->map,NULL, op->x+freearr_x[absdir(op->direction+1)], |
| | op->y+freearr_y[absdir(op->direction+1)], NULL, NULL) & P_WALL; |
| | |
if(!left) | | if(!left) |
op->direction=absdir(op->direction-1); | | op->direction=absdir(op->direction-1); |
| | |
op->y = new_y; | | op->y = new_y; |
| | |
/* decrease the speed as it flies. 0.05 means a standard bow will shoot | | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
about 17 squares. Tune as needed. */ | | * about 17 squares. Tune as needed. |
| | */ |
op->speed -= 0.05; | | op->speed -= 0.05; |
insert_ob_in_map (op, op->map, op,0); | | insert_ob_in_map (op, m, op,0); |
} | | } |
| | |
/* This routine doesnt seem to work for "inanimate" objects that | | /* This routine doesnt seem to work for "inanimate" objects that |