version 1.26 | | version 1.27 |
---|
| | |
/* | | /* |
* static char *rcsid_monster_c = | | * static char *rcsid_monster_c = |
* "$Id: monster.c,v 1.26 2001/06/29 05:59:46 mwedel Exp $"; | | * "$Id: monster.c,v 1.27 2001/07/14 04:11:18 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
/* blinded monsters can only find nearby objects to attack */ | | /* blinded monsters can only find nearby objects to attack */ |
if(QUERY_FLAG(op, FLAG_BLIND) && !QUERY_FLAG(op, FLAG_SEE_INVISIBLE)) | | if(QUERY_FLAG(op, FLAG_BLIND) && !QUERY_FLAG(op, FLAG_SEE_INVISIBLE)) |
radius = MIN_MON_RADIUS; | | radius = MIN_MON_RADIUS; |
#ifdef USE_LIGHTING | | |
/* This covers the situation where the monster is in the dark | | /* This covers the situation where the monster is in the dark |
* and has an enemy. If the enemy has no carried light (or isnt | | * and has an enemy. If the enemy has no carried light (or isnt |
* glowing!) then the monster has trouble finding the enemy. | | * glowing!) then the monster has trouble finding the enemy. |
| | |
int dark = radius/(op->map->darkness); | | int dark = radius/(op->map->darkness); |
radius = (dark>MIN_MON_RADIUS)?(dark+1):MIN_MON_RADIUS; | | radius = (dark>MIN_MON_RADIUS)?(dark+1):MIN_MON_RADIUS; |
} | | } |
#endif | | |
else if(!QUERY_FLAG(op,FLAG_SLEEP)) return 1; | | else if(!QUERY_FLAG(op,FLAG_SLEEP)) return 1; |
/* enemy should already be on this map, so don't really need to check | | /* enemy should already be on this map, so don't really need to check |
* for that. | | * for that. |
| | |
| | |
| | |
if(QUERY_FLAG(op, FLAG_SLEEP)||QUERY_FLAG(op, FLAG_BLIND) | | if(QUERY_FLAG(op, FLAG_SLEEP)||QUERY_FLAG(op, FLAG_BLIND) |
#ifdef USE_LIGHTING | | |
||((op->map->darkness>0)&&!QUERY_FLAG(op,FLAG_SEE_IN_DARK) | | ||((op->map->darkness>0)&&!QUERY_FLAG(op,FLAG_SEE_IN_DARK) |
&&!QUERY_FLAG(op,FLAG_SEE_INVISIBLE)) | | &&!QUERY_FLAG(op,FLAG_SEE_INVISIBLE))) { |
#endif | | |
) { | | |
if(!check_wakeup(op,enemy)) | | if(!check_wakeup(op,enemy)) |
return 0; | | return 0; |
} | | } |
| | |
SET_FLAG(arrow, FLAG_FLY_ON); | | SET_FLAG(arrow, FLAG_FLY_ON); |
SET_FLAG(arrow, FLAG_WALK_ON); | | SET_FLAG(arrow, FLAG_WALK_ON); |
tag = arrow->count; | | tag = arrow->count; |
insert_ob_in_map(arrow,head->map,head); | | insert_ob_in_map(arrow,head->map,head,0); |
if (!was_destroyed(arrow, tag)) | | if (!was_destroyed(arrow, tag)) |
move_arrow(arrow); | | move_arrow(arrow); |
return 1; | | return 1; |
| | |
for(tmp = op; tmp != NULL; tmp = tmp->more) | | for(tmp = op; tmp != NULL; tmp = tmp->more) |
tmp->x+=freearr_x[dir], tmp->y+=freearr_y[dir]; | | tmp->x+=freearr_x[dir], tmp->y+=freearr_y[dir]; |
| | |
insert_ob_in_map(op, op->map, op); | | insert_ob_in_map(op, op->map, op,0); |
return 1; | | return 1; |
} | | } |
| | |
| | |
if(QUERY_FLAG(enemy,FLAG_STEALTH)) | | if(QUERY_FLAG(enemy,FLAG_STEALTH)) |
radius = radius/2, hide_discovery = hide_discovery/3; | | radius = radius/2, hide_discovery = hide_discovery/3; |
| | |
#ifdef USE_LIGHTING | | |
/* Radii adjustment for enemy standing in the dark */ | | /* Radii adjustment for enemy standing in the dark */ |
if(op->map->darkness>0 && !stand_in_light(enemy)) { | | if(op->map->darkness>0 && !stand_in_light(enemy)) { |
| | |
| | |
if(radius<MIN_MON_RADIUS && op->map->darkness<5 && (x_dist<=1||y_dist<=1)) | | if(radius<MIN_MON_RADIUS && op->map->darkness<5 && (x_dist<=1||y_dist<=1)) |
radius = MIN_MON_RADIUS; | | radius = MIN_MON_RADIUS; |
} | | } |
#endif | | |
| | |
/* Lets not worry about monsters that have incredible detection | | /* Lets not worry about monsters that have incredible detection |
* radii, we only need to worry here about things the player can | | * radii, we only need to worry here about things the player can |
| | |
*/ | | */ |
| | |
int stand_in_light( object *op) { | | int stand_in_light( object *op) { |
objectlink *obl; | | |
| | |
if(!op) return 0; | | if(!op) return 0; |
if(has_carried_lights(op)) return 1; | | if(op->glow_radius) return 1; |
| | |
| | if(op->map) { |
| | int x, y; |
| | |
| | /* Check the spacs with the max light radius to see if any of them |
| | * have lights, and if the light is bright enough to illuminate |
| | * this object. Like the los.c logic, this presumes a square |
| | * lighting area. |
| | */ |
| | for (x = op->x - MAX_LIGHT_RADII; x< op->x + MAX_LIGHT_RADII; x++) { |
| | for (y = op->y - MAX_LIGHT_RADII; y< op->y + MAX_LIGHT_RADII; y++) { |
| | if (out_of_map(op->map, x, y)) continue; |
| | |
if(op->map) | | if (GET_MAP_LIGHT(op->map, x, y) > MAX(abs(x - op->x), abs(y - op->y))) return 1; |
for(obl=op->map->light;obl;obl=obl->next) | | } |
if(obl->ob&&(!obl->ob->env&&(!obl->ob->above||obl->ob->invisible))) { | | } |
int dist=isqrt(distance(op,obl->ob)); | | |
if(dist && dist<obl->ob->glow_radius) return 1; | | |
} | | } |
return 0; | | return 0; |
} | | } |
| | |
} else if(looker->type==PLAYER) /* for players, a (possible) shortcut */ | | } else if(looker->type==PLAYER) /* for players, a (possible) shortcut */ |
if(player_can_view(looker,enemy)) return 1; | | if(player_can_view(looker,enemy)) return 1; |
| | |
#ifdef USE_LIGHTING | | |
/* ENEMY IN DARK MAP. Without infravision, the enemy is not seen | | /* ENEMY IN DARK MAP. Without infravision, the enemy is not seen |
* unless they carry a light or stand in light. Darkness doesnt | | * unless they carry a light or stand in light. Darkness doesnt |
* inhibit the undead per se (but we should give their archs | | * inhibit the undead per se (but we should give their archs |
| | |
&&(!QUERY_FLAG(looker,FLAG_SEE_IN_DARK)|| | | &&(!QUERY_FLAG(looker,FLAG_SEE_IN_DARK)|| |
!is_true_undead(looker)||!QUERY_FLAG(looker,FLAG_XRAYS))) | | !is_true_undead(looker)||!QUERY_FLAG(looker,FLAG_XRAYS))) |
return 0; | | return 0; |
#endif | | |
| | |
return 1; | | return 1; |
} | | } |