… | |
… | |
236 | { |
236 | { |
237 | /* Trim work - if no enemy, no need to do anything below */ |
237 | /* Trim work - if no enemy, no need to do anything below */ |
238 | if (!enemy) |
238 | if (!enemy) |
239 | return 0; |
239 | return 0; |
240 | |
240 | |
|
|
241 | if (!op->flag [FLAG_SLEEP]) |
|
|
242 | return 1; |
|
|
243 | |
241 | int radius = max (op->stats.Wis, MIN_MON_RADIUS); |
244 | int radius = max (op->stats.Wis, MIN_MON_RADIUS); |
242 | |
245 | |
243 | if (op->flag [FLAG_BLIND]) |
246 | if (op->flag [FLAG_BLIND]) |
244 | /* blinded monsters can only find nearby objects to attack */ |
247 | /* blinded monsters can only find nearby objects to attack */ |
245 | radius = MIN_MON_RADIUS; |
248 | radius = MIN_MON_RADIUS; |
… | |
… | |
251 | * and has an enemy. If the enemy has no carried light (or isnt |
254 | * and has an enemy. If the enemy has no carried light (or isnt |
252 | * glowing!) then the monster has trouble finding the enemy. |
255 | * glowing!) then the monster has trouble finding the enemy. |
253 | * Remember we already checked to see if the monster can see in |
256 | * Remember we already checked to see if the monster can see in |
254 | * the dark. */ |
257 | * the dark. */ |
255 | radius = min (radius, MIN_MON_RADIUS + MAX_DARKNESS - op->map->darklevel ()); |
258 | radius = min (radius, MIN_MON_RADIUS + MAX_DARKNESS - op->map->darklevel ()); |
256 | else if (!op->flag [FLAG_SLEEP]) |
|
|
257 | return 1; |
|
|
258 | |
259 | |
259 | if (enemy->flag [FLAG_STEALTH]) |
260 | if (enemy->flag [FLAG_STEALTH]) |
260 | radius = radius / 2 + 1; |
261 | radius = radius / 2 + 1; |
261 | |
262 | |
262 | /* enemy should already be on this map, so don't really need to check |
263 | /* enemy should already be on this map, so don't really need to check |
… | |
… | |
389 | { |
390 | { |
390 | if (op->attack_movement & HI4) |
391 | if (op->attack_movement & HI4) |
391 | { |
392 | { |
392 | switch (op->attack_movement & HI4) |
393 | switch (op->attack_movement & HI4) |
393 | { |
394 | { |
394 | case (PETMOVE): |
395 | case PETMOVE: |
395 | pet_move (op); |
396 | pet_move (op); |
396 | break; |
397 | break; |
397 | |
398 | |
398 | case (CIRCLE1): |
399 | case CIRCLE1: |
399 | circ1_move (op); |
400 | circ1_move (op); |
400 | break; |
401 | break; |
401 | |
402 | |
402 | case (CIRCLE2): |
403 | case CIRCLE2: |
403 | circ2_move (op); |
404 | circ2_move (op); |
404 | break; |
405 | break; |
405 | |
406 | |
406 | case (PACEV): |
407 | case PACEV: |
407 | pace_movev (op); |
408 | pace_movev (op); |
408 | break; |
409 | break; |
409 | |
410 | |
410 | case (PACEH): |
411 | case PACEH: |
411 | pace_moveh (op); |
412 | pace_moveh (op); |
412 | break; |
413 | break; |
413 | |
414 | |
414 | case (PACEV2): |
415 | case PACEV2: |
415 | pace2_movev (op); |
416 | pace2_movev (op); |
416 | break; |
417 | break; |
417 | |
418 | |
418 | case (PACEH2): |
419 | case PACEH2: |
419 | pace2_moveh (op); |
420 | pace2_moveh (op); |
420 | break; |
421 | break; |
421 | |
422 | |
422 | case (RANDO): |
423 | case RANDO: |
423 | rand_move (op); |
424 | rand_move (op); |
424 | break; |
425 | break; |
425 | |
426 | |
426 | case (RANDO2): |
427 | case RANDO2: |
427 | move_randomly (op); |
428 | move_randomly (op); |
428 | break; |
429 | break; |
429 | } |
430 | } |
430 | |
431 | |
431 | return 0; |
432 | return 0; |
… | |
… | |
446 | |
447 | |
447 | /* doppleganger code to change monster facing to that of the nearest |
448 | /* doppleganger code to change monster facing to that of the nearest |
448 | * player. Hmm. The code is here, but no monster in the current |
449 | * player. Hmm. The code is here, but no monster in the current |
449 | * arch set uses it. |
450 | * arch set uses it. |
450 | */ |
451 | */ |
451 | if (op->race && strcmp (op->race, "doppleganger") == 0) |
452 | if (op->race == shstr_doppleganger) |
452 | { |
453 | { |
453 | op->face = enemy->face; |
454 | op->face = enemy->face; |
454 | op->name = enemy->name; |
455 | op->name = enemy->name; |
455 | } |
456 | } |
456 | |
457 | |
… | |
… | |
507 | } /* If not scared */ |
508 | } /* If not scared */ |
508 | |
509 | |
509 | part = rv.part; |
510 | part = rv.part; |
510 | dir = rv.direction; |
511 | dir = rv.direction; |
511 | |
512 | |
512 | #if DEVEL |
513 | // if the enemy is a player, we have los. if los says we |
|
|
514 | // can directly reach the player, we do not deviate. |
|
|
515 | // for non-players, we never deviate |
|
|
516 | if (op->stats.Wis >= 8 |
|
|
517 | && enemy->contr && enemy->contr->darkness_at (op->map, op->x, op->y) == LOS_BLOCKED) |
|
|
518 | { |
513 | int sdir = 0; |
519 | int sdir = 0; |
|
|
520 | uint32_t &smell = op->ms ().smell; |
514 | |
521 | |
515 | for (int dir = 1; dir <= 8; ++dir) |
522 | for (int ndir = 1; ndir <= 8; ++ndir) |
516 | { |
523 | { |
517 | mapxy pos (op); pos.move (dir); |
524 | mapxy pos (op); pos.move (ndir); |
|
|
525 | |
518 | if (pos.normalise ()) |
526 | if (pos.normalise ()) |
519 | { |
|
|
520 | mapspace &ms = pos.ms (); |
|
|
521 | |
|
|
522 | if (ms.smell > op->ms ().smell) |
|
|
523 | { |
527 | { |
|
|
528 | mapspace &ms = pos.ms (); |
|
|
529 | |
|
|
530 | if (ms.smell > smell) |
|
|
531 | { |
524 | printf ("%s: found smell, following it, apparently (%d, %d)\n",& op->name,op->ms().smell,ms.smell);//D |
532 | //printf ("%s: found smell, following it, apparently (%d, %d)\n",& op->name,op->ms().smell,ms.smell);//D |
525 | op->ms ().smell = ms.smell - 1; |
533 | if (op->stats.Wis >= 10) |
|
|
534 | smell = ms.smell - 1; // smarter: tell others |
|
|
535 | |
526 | sdir = dir; |
536 | sdir = ndir; |
527 | |
537 | |
528 | // perturbing the path might let the monster lose track, |
538 | // perturbing the path might let the monster lose track, |
529 | // but it will also wide the actual path, spreading information |
539 | // but it will also widen the actual path, spreading information |
530 | if (!rndm (20)) |
540 | if (op->stats.Wis >= 15 && !rndm (20)) // even smarter, deviate and spread? |
531 | sdir += absdir (1 - rndm (2) * 2); |
541 | sdir = absdir (sdir + 1 - rndm (2) * 2); |
|
|
542 | } |
532 | } |
543 | } |
533 | } |
544 | } |
534 | } |
|
|
535 | |
545 | |
536 | if (sdir) |
546 | if (sdir) |
537 | dir = sdir; |
547 | dir = sdir; |
538 | else |
548 | else if (smell) |
|
|
549 | { |
539 | // no better smell found, so assume the player jumped, and erase this smell |
550 | // no better smell found, so assume the player jumped, and erase this smell |
540 | {if (op->ms ().smell) printf ("erasing smell %d\n", op->ms ().smell);//D |
551 | //printf ("erasing smell %d\n", op->ms ().smell);//D |
541 | ordered_mapwalk_begin (op, -1, -1, 1, 1) |
552 | unordered_mapwalk (op, -1, -1, 1, 1) |
542 | if (m) |
|
|
543 | m->at (nx, ny).smell = 0; |
553 | m->at (nx, ny).smell = 0; |
544 | ordered_mapwalk_end |
554 | } |
545 | }//D |
555 | } |
546 | |
|
|
547 | #endif |
|
|
548 | |
556 | |
549 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |
557 | if (QUERY_FLAG (op, FLAG_SCARED) || QUERY_FLAG (op, FLAG_RUN_AWAY)) |
550 | dir = absdir (dir + 4); |
558 | dir = absdir (dir + 4); |
551 | |
559 | |
552 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
560 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
… | |
… | |
698 | return 1; |
706 | return 1; |
699 | |
707 | |
700 | /* check all the parts of ob2 - just because we can't get to |
708 | /* check all the parts of ob2 - just because we can't get to |
701 | * its head doesn't mean we don't want to pound its feet |
709 | * its head doesn't mean we don't want to pound its feet |
702 | */ |
710 | */ |
703 | for (more = ob2->more; more != NULL; more = more->more) |
711 | for (more = ob2->more; more; more = more->more) |
704 | { |
712 | { |
705 | get_rangevector (ob1, more, &rv1, 0); |
713 | get_rangevector (ob1, more, &rv1, 0); |
706 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
714 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
707 | return 1; |
715 | return 1; |
708 | } |
716 | } |
… | |
… | |
1189 | flag = 1; |
1197 | flag = 1; |
1190 | |
1198 | |
1191 | else |
1199 | else |
1192 | switch (item->type) |
1200 | switch (item->type) |
1193 | { |
1201 | { |
1194 | case MONEY: |
1202 | case MONEY: |
1195 | case GEM: |
1203 | case GEM: |
1196 | flag = monster->pick_up & 2; |
1204 | flag = monster->pick_up & 2; |
1197 | break; |
1205 | break; |
1198 | |
1206 | |
1199 | case FOOD: |
1207 | case FOOD: |
1200 | flag = monster->pick_up & 4; |
1208 | flag = monster->pick_up & 4; |
1201 | break; |
1209 | break; |
1202 | |
1210 | |
1203 | case WEAPON: |
1211 | case WEAPON: |
1204 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1212 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1205 | break; |
1213 | break; |
1206 | |
1214 | |
1207 | case ARMOUR: |
1215 | case ARMOUR: |
1208 | case SHIELD: |
1216 | case SHIELD: |
1209 | case HELMET: |
1217 | case HELMET: |
1210 | case BOOTS: |
1218 | case BOOTS: |
1211 | case GLOVES: |
1219 | case GLOVES: |
1212 | case GIRDLE: |
1220 | case GIRDLE: |
1213 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1221 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1214 | break; |
1222 | break; |
1215 | |
1223 | |
1216 | case SKILL: |
1224 | case SKILL: |
1217 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1225 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1218 | break; |
1226 | break; |
1219 | |
1227 | |
1220 | case RING: |
1228 | case RING: |
1221 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1229 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1222 | break; |
1230 | break; |
1223 | |
1231 | |
1224 | case WAND: |
1232 | case WAND: |
1225 | case HORN: |
1233 | case HORN: |
1226 | case ROD: |
1234 | case ROD: |
1227 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1235 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1228 | break; |
1236 | break; |
1229 | |
1237 | |
1230 | case SPELLBOOK: |
1238 | case SPELLBOOK: |
1231 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1239 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1232 | break; |
1240 | break; |
1233 | |
1241 | |
1234 | case SCROLL: |
1242 | case SCROLL: |
1235 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1243 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1236 | break; |
1244 | break; |
1237 | |
1245 | |
1238 | case BOW: |
1246 | case BOW: |
1239 | case ARROW: |
1247 | case ARROW: |
1240 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1248 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1241 | break; |
1249 | break; |
1242 | } |
1250 | } |
1243 | |
1251 | |
1244 | /* Simplistic check - if the monster has a location to equip it, he will |
1252 | /* Simplistic check - if the monster has a location to equip it, he will |
1245 | * pick it up. Note that this doesn't handle cases where an item may |
1253 | * pick it up. Note that this doesn't handle cases where an item may |
1246 | * use several locations. |
1254 | * use several locations. |
… | |
… | |
1412 | } |
1420 | } |
1413 | |
1421 | |
1414 | void |
1422 | void |
1415 | npc_call_help (object *op) |
1423 | npc_call_help (object *op) |
1416 | { |
1424 | { |
1417 | int x, y, mflags; |
1425 | unordered_mapwalk (op, -7, -7, 7, 7) |
1418 | object *npc; |
|
|
1419 | sint16 sx, sy; |
|
|
1420 | maptile *m; |
|
|
1421 | |
|
|
1422 | for (x = -3; x < 4; x++) |
|
|
1423 | for (y = -3; y < 4; y++) |
|
|
1424 | { |
1426 | { |
1425 | m = op->map; |
1427 | mapspace &ms = m->at (nx, ny); |
1426 | sx = op->x + x; |
1428 | |
1427 | sy = op->y + y; |
|
|
1428 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
|
|
1429 | /* If nothing alive on this space, no need to search the space. */ |
1429 | /* If nothing alive on this space, no need to search the space. */ |
1430 | if ((mflags & P_OUT_OF_MAP) || !(mflags & P_IS_ALIVE)) |
1430 | if (!(ms.flags () & P_IS_ALIVE)) |
1431 | continue; |
1431 | continue; |
1432 | |
1432 | |
1433 | for (npc = GET_MAP_OB (m, sx, sy); npc != NULL; npc = npc->above) |
1433 | for (object *npc = ms.bot; npc; npc = npc->above) |
1434 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1434 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1435 | npc->enemy = op->enemy; |
1435 | npc->enemy = op->enemy; |
1436 | } |
1436 | } |
1437 | } |
1437 | } |
1438 | |
1438 | |
1439 | int |
1439 | int |
1440 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1440 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv) |
1441 | { |
1441 | { |
1442 | if (can_hit (part, enemy, rv)) |
1442 | if (can_hit (part, enemy, rv)) |
1443 | return dir; |
1443 | return dir; |
1444 | |
1444 | |
1445 | if (rv->distance < 10) |
1445 | if (rv->distance < 10) |
… | |
… | |
1449 | |
1449 | |
1450 | return 0; |
1450 | return 0; |
1451 | } |
1451 | } |
1452 | |
1452 | |
1453 | int |
1453 | int |
1454 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1454 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv) |
1455 | { |
1455 | { |
1456 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1456 | if (can_hit (part, enemy, rv)) |
1457 | { |
|
|
1458 | ob->move_status++; |
|
|
1459 | return (dir); |
1457 | return dir; |
1460 | } |
1458 | else |
1461 | else if (ob->move_status > 20) |
|
|
1462 | ob->move_status = 0; |
|
|
1463 | |
|
|
1464 | return absdir (dir + 4); |
1459 | return absdir (dir + 4); |
1465 | } |
1460 | } |
1466 | |
1461 | |
1467 | int |
1462 | int |
1468 | hitrun_att (int dir, object *ob, object *enemy) |
1463 | hitrun_att (int dir, object *ob, object *enemy) |
1469 | { |
1464 | { |
… | |
… | |
1478 | } |
1473 | } |
1479 | |
1474 | |
1480 | int |
1475 | int |
1481 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1476 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1482 | { |
1477 | { |
1483 | |
|
|
1484 | int inrange = can_hit (part, enemy, rv); |
1478 | int inrange = can_hit (part, enemy, rv); |
1485 | |
1479 | |
1486 | if (ob->move_status || inrange) |
1480 | if (ob->move_status || inrange) |
1487 | ob->move_status++; |
1481 | ob->move_status++; |
1488 | |
1482 | |
… | |
… | |
1498 | } |
1492 | } |
1499 | |
1493 | |
1500 | int |
1494 | int |
1501 | disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1495 | disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1502 | { |
1496 | { |
1503 | |
|
|
1504 | /* The logic below here looked plain wrong before. Basically, what should |
1497 | /* The logic below here looked plain wrong before. Basically, what should |
1505 | * happen is that if the creatures hp percentage falls below run_away, |
1498 | * happen is that if the creatures hp percentage falls below run_away, |
1506 | * the creature should run away (dir+4) |
1499 | * the creature should run away (dir+4) |
1507 | * I think its wrong for a creature to have a zero maxhp value, but |
1500 | * I think its wrong for a creature to have a zero maxhp value, but |
1508 | * at least one map has this set, and whatever the map contains, the |
1501 | * at least one map has this set, and whatever the map contains, the |
1509 | * server should try to be resilant enough to avoid the problem |
1502 | * server should try to be resilant enough to avoid the problem |
1510 | */ |
1503 | */ |
1511 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1504 | if (ob->stats.hp * 100 < ob->stats.maxhp * ob->run_away) |
1512 | return absdir (dir + 4); |
1505 | return absdir (dir + 4); |
1513 | |
1506 | |
1514 | return dist_att (dir, ob, enemy, part, rv); |
1507 | return dist_att (dir, ob, enemy, part, rv); |
1515 | } |
1508 | } |
1516 | |
1509 | |
… | |
… | |
1682 | * Returns 0 if enemy can not be detected, 1 if it is detected |
1675 | * Returns 0 if enemy can not be detected, 1 if it is detected |
1683 | */ |
1676 | */ |
1684 | int |
1677 | int |
1685 | can_detect_enemy (object *op, object *enemy, rv_vector * rv) |
1678 | can_detect_enemy (object *op, object *enemy, rv_vector * rv) |
1686 | { |
1679 | { |
1687 | int radius = MIN_MON_RADIUS, hide_discovery; |
|
|
1688 | |
|
|
1689 | /* null detection for any of these condtions always */ |
1680 | /* null detection for any of these condtions always */ |
1690 | if (!op || !enemy || !op->map || !enemy->map) |
1681 | if (!op || !enemy || !op->map || !enemy->map) |
1691 | return 0; |
1682 | return 0; |
1692 | |
1683 | |
1693 | /* If the monster (op) has no way to get to the enemy, do nothing */ |
1684 | /* If the monster (op) has no way to get to the enemy, do nothing */ |
… | |
… | |
1695 | return 0; |
1686 | return 0; |
1696 | |
1687 | |
1697 | get_rangevector (op, enemy, rv, 0); |
1688 | get_rangevector (op, enemy, rv, 0); |
1698 | |
1689 | |
1699 | /* Monsters always ignore the DM */ |
1690 | /* Monsters always ignore the DM */ |
1700 | if (op->type != PLAYER && QUERY_FLAG (enemy, FLAG_WIZ)) |
1691 | if (!op->is_player () && QUERY_FLAG (enemy, FLAG_WIZ)) |
1701 | return 0; |
1692 | return 0; |
1702 | |
1693 | |
1703 | /* simple check. Should probably put some range checks in here. */ |
1694 | /* simple check. Should probably put some range checks in here. */ |
1704 | if (can_see_enemy (op, enemy)) |
1695 | if (can_see_enemy (op, enemy)) |
1705 | return 1; |
1696 | return 1; |
1706 | |
1697 | |
1707 | /* The rest of this is for monsters. Players are on their own for |
1698 | /* The rest of this is for monsters. Players are on their own for |
1708 | * finding enemies! |
1699 | * finding enemies! |
1709 | */ |
1700 | */ |
1710 | if (op->type == PLAYER) |
1701 | if (op->is_player ()) |
1711 | return 0; |
1702 | return 0; |
1712 | |
1703 | |
1713 | /* Quality invisible? Bah, we wont see them w/o SEE_INVISIBLE |
1704 | /* Quality invisible? Bah, we wont see them w/o SEE_INVISIBLE |
1714 | * flag (which was already checked) in can_see_enmy (). Lets get out of here |
1705 | * flag (which was already checked) in can_see_enemy (). Lets get out of here |
1715 | */ |
1706 | */ |
1716 | if (enemy->invisible && (!enemy->contr || (!enemy->contr->tmp_invis && !enemy->contr->hidden))) |
1707 | if (enemy->invisible && (!enemy->contr || (!enemy->contr->tmp_invis && !enemy->contr->hidden))) |
1717 | return 0; |
1708 | return 0; |
1718 | |
1709 | |
|
|
1710 | int radius = MIN_MON_RADIUS; |
|
|
1711 | |
1719 | /* use this for invis also */ |
1712 | /* use this for invis also */ |
1720 | hide_discovery = op->stats.Int / 5; |
1713 | int hide_discovery = op->stats.Int / 5; |
1721 | |
1714 | |
1722 | /* Determine Detection radii */ |
1715 | /* Determine Detection radii */ |
1723 | if (!enemy->flag [FLAG_HIDDEN]) /* to detect non-hidden (eg dark/invis enemy) */ |
1716 | if (!enemy->flag [FLAG_HIDDEN]) /* to detect non-hidden (eg dark/invis enemy) */ |
1724 | radius = max (MIN_MON_RADIUS, op->stats.Wis / 5 + 1); |
1717 | radius = max (MIN_MON_RADIUS, op->stats.Wis / 3 + 1); |
1725 | else |
1718 | else |
1726 | { /* a level/INT/Dex adjustment for hiding */ |
1719 | { /* a level/INT/Dex adjustment for hiding */ |
1727 | int bonus = op->level / 2 + op->stats.Int / 5; |
1720 | int bonus = op->level / 2 + op->stats.Int / 5; |
1728 | |
1721 | |
1729 | if (enemy->is_player ()) |
1722 | if (enemy->is_player ()) |
… | |
… | |
1751 | radius /= 2; |
1744 | radius /= 2; |
1752 | hide_discovery /= 3; |
1745 | hide_discovery /= 3; |
1753 | } |
1746 | } |
1754 | |
1747 | |
1755 | /* Radii adjustment for enemy standing in the dark */ |
1748 | /* Radii adjustment for enemy standing in the dark */ |
1756 | if (op->map->darklevel () > 0 && !stand_in_light (enemy)) |
1749 | if (!stand_in_light (enemy)) |
1757 | { |
1750 | { |
1758 | /* on dark maps body heat can help indicate location with infravision |
1751 | /* on dark maps body heat can help indicate location with infravision |
1759 | * undead don't have body heat, so no benefit detecting them. |
1752 | * undead don't have body heat, so no benefit detecting them. |
1760 | */ |
1753 | */ |
1761 | if (QUERY_FLAG (op, FLAG_SEE_IN_DARK) && !is_true_undead (enemy)) |
1754 | if (QUERY_FLAG (op, FLAG_SEE_IN_DARK) && !is_true_undead (enemy)) |
… | |
… | |
1764 | radius -= op->map->darklevel () / 2; |
1757 | radius -= op->map->darklevel () / 2; |
1765 | |
1758 | |
1766 | /* op next to a monster (and not in complete darkness) |
1759 | /* op next to a monster (and not in complete darkness) |
1767 | * the monster should have a chance to see you. |
1760 | * the monster should have a chance to see you. |
1768 | */ |
1761 | */ |
1769 | if (radius < MIN_MON_RADIUS && op->map->darklevel () < 5 && rv->distance <= 1) |
1762 | if (radius < MIN_MON_RADIUS && op->map->darklevel () < MAX_DARKNESS && rv->distance <= 1) |
1770 | radius = MIN_MON_RADIUS; |
1763 | radius = MIN_MON_RADIUS; |
1771 | } /* if on dark map */ |
1764 | } /* if on dark map */ |
1772 | |
1765 | |
1773 | /* Lets not worry about monsters that have incredible detection |
1766 | /* Lets not worry about monsters that have incredible detection |
1774 | * radii, we only need to worry here about things the player can |
1767 | * radii, we only need to worry here about things the player can |
… | |
… | |
1822 | /* Wasn't detected above, so still hidden */ |
1815 | /* Wasn't detected above, so still hidden */ |
1823 | return 0; |
1816 | return 0; |
1824 | } |
1817 | } |
1825 | |
1818 | |
1826 | /* determine if op stands in a lighted square. This is not a very |
1819 | /* determine if op stands in a lighted square. This is not a very |
1827 | * intellegent algorithm. For one thing, we ignore los here, SO it |
1820 | * intelligent algorithm. For one thing, we ignore los here, SO it |
1828 | * is possible for a bright light to illuminate a player on the |
1821 | * is possible for a bright light to illuminate a player on the |
1829 | * other side of a wall (!). |
1822 | * other side of a wall (!). |
1830 | */ |
1823 | */ |
1831 | int |
1824 | int |
1832 | stand_in_light (object *op) |
1825 | stand_in_light (object *op) |
1833 | { |
1826 | { |
1834 | if (op) |
1827 | if (op) |
1835 | { |
1828 | { |
|
|
1829 | if (!op->is_on_map ()) |
|
|
1830 | return 0; |
|
|
1831 | |
|
|
1832 | if (op->map->darklevel () <= 0) |
|
|
1833 | return 1; |
|
|
1834 | |
1836 | if (op->glow_radius > 0) |
1835 | if (op->glow_radius > 0) |
1837 | return 1; |
1836 | return 1; |
1838 | |
1837 | |
1839 | if (op->map) |
1838 | if (op->map) |
1840 | unordered_mapwalk (op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
1839 | unordered_mapwalk (op, -MAX_LIGHT_RADIUS, -MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS, MAX_LIGHT_RADIUS) |
… | |
… | |
1878 | { |
1877 | { |
1879 | /* HIDDEN ENEMY. by definition, you can't see hidden stuff! |
1878 | /* HIDDEN ENEMY. by definition, you can't see hidden stuff! |
1880 | * However,if you carry any source of light, then the hidden |
1879 | * However,if you carry any source of light, then the hidden |
1881 | * creature is seeable (and stupid) */ |
1880 | * creature is seeable (and stupid) */ |
1882 | |
1881 | |
1883 | if (has_carried_lights (enemy)) |
1882 | if (enemy->has_carried_lights ()) |
1884 | { |
1883 | { |
1885 | if (enemy->flag [FLAG_HIDDEN]) |
1884 | if (enemy->flag [FLAG_HIDDEN]) |
1886 | { |
1885 | { |
1887 | make_visible (enemy); |
1886 | make_visible (enemy); |
1888 | new_draw_info (NDI_UNIQUE, 0, enemy, "Your light reveals your hiding spot!"); |
1887 | new_draw_info (NDI_UNIQUE, 0, enemy, "Your light reveals your hiding spot!"); |
… | |
… | |
1912 | * we care about the enemy maps status, not the looker. |
1911 | * we care about the enemy maps status, not the looker. |
1913 | * only relevant for tiled maps, but it is possible that the |
1912 | * only relevant for tiled maps, but it is possible that the |
1914 | * enemy is on a bright map and the looker on a dark - in that |
1913 | * enemy is on a bright map and the looker on a dark - in that |
1915 | * case, the looker can still see the enemy |
1914 | * case, the looker can still see the enemy |
1916 | */ |
1915 | */ |
1917 | if (enemy->map->darklevel () > 0 |
|
|
1918 | && !stand_in_light (enemy) |
1916 | if (!stand_in_light (enemy) |
1919 | && (!QUERY_FLAG (looker, FLAG_SEE_IN_DARK) || !is_true_undead (looker) || !QUERY_FLAG (looker, FLAG_XRAYS))) |
1917 | && (!QUERY_FLAG (looker, FLAG_SEE_IN_DARK) || !is_true_undead (looker) || !QUERY_FLAG (looker, FLAG_XRAYS))) |
1920 | return 0; |
1918 | return 0; |
1921 | |
1919 | |
1922 | return 1; |
1920 | return 1; |
1923 | } |
1921 | } |