… | |
… | |
390 | { |
390 | { |
391 | if (op->attack_movement & HI4) |
391 | if (op->attack_movement & HI4) |
392 | { |
392 | { |
393 | switch (op->attack_movement & HI4) |
393 | switch (op->attack_movement & HI4) |
394 | { |
394 | { |
395 | case (PETMOVE): |
395 | case PETMOVE: |
396 | pet_move (op); |
396 | pet_move (op); |
397 | break; |
397 | break; |
398 | |
398 | |
399 | case (CIRCLE1): |
399 | case CIRCLE1: |
400 | circ1_move (op); |
400 | circ1_move (op); |
401 | break; |
401 | break; |
402 | |
402 | |
403 | case (CIRCLE2): |
403 | case CIRCLE2: |
404 | circ2_move (op); |
404 | circ2_move (op); |
405 | break; |
405 | break; |
406 | |
406 | |
407 | case (PACEV): |
407 | case PACEV: |
408 | pace_movev (op); |
408 | pace_movev (op); |
409 | break; |
409 | break; |
410 | |
410 | |
411 | case (PACEH): |
411 | case PACEH: |
412 | pace_moveh (op); |
412 | pace_moveh (op); |
413 | break; |
413 | break; |
414 | |
414 | |
415 | case (PACEV2): |
415 | case PACEV2: |
416 | pace2_movev (op); |
416 | pace2_movev (op); |
417 | break; |
417 | break; |
418 | |
418 | |
419 | case (PACEH2): |
419 | case PACEH2: |
420 | pace2_moveh (op); |
420 | pace2_moveh (op); |
421 | break; |
421 | break; |
422 | |
422 | |
423 | case (RANDO): |
423 | case RANDO: |
424 | rand_move (op); |
424 | rand_move (op); |
425 | break; |
425 | break; |
426 | |
426 | |
427 | case (RANDO2): |
427 | case RANDO2: |
428 | move_randomly (op); |
428 | move_randomly (op); |
429 | break; |
429 | break; |
430 | } |
430 | } |
431 | |
431 | |
432 | return 0; |
432 | return 0; |
… | |
… | |
447 | |
447 | |
448 | /* doppleganger code to change monster facing to that of the nearest |
448 | /* doppleganger code to change monster facing to that of the nearest |
449 | * 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 |
450 | * arch set uses it. |
450 | * arch set uses it. |
451 | */ |
451 | */ |
452 | if (op->race && strcmp (op->race, "doppleganger") == 0) |
452 | if (op->race == shstr_doppleganger) |
453 | { |
453 | { |
454 | op->face = enemy->face; |
454 | op->face = enemy->face; |
455 | op->name = enemy->name; |
455 | op->name = enemy->name; |
456 | } |
456 | } |
457 | |
457 | |
… | |
… | |
511 | dir = rv.direction; |
511 | dir = rv.direction; |
512 | |
512 | |
513 | // if the enemy is a player, we have los. if los says we |
513 | // if the enemy is a player, we have los. if los says we |
514 | // can directly reach the player, we do not deviate. |
514 | // can directly reach the player, we do not deviate. |
515 | // for non-players, we never deviate |
515 | // for non-players, we never deviate |
|
|
516 | if (op->stats.Wis >= 8 |
516 | if (enemy->contr && enemy->contr->darkness_at (op->map, op->x, op->y) == LOS_BLOCKED) |
517 | && enemy->contr && enemy->contr->darkness_at (op->map, op->x, op->y) == LOS_BLOCKED) |
517 | { |
518 | { |
518 | int sdir = 0; |
519 | int sdir = 0; |
|
|
520 | uint32_t &smell = op->ms ().smell; |
519 | |
521 | |
520 | for (int ndir = 1; ndir <= 8; ++ndir) |
522 | for (int ndir = 1; ndir <= 8; ++ndir) |
521 | { |
523 | { |
522 | mapxy pos (op); pos.move (ndir); |
524 | mapxy pos (op); pos.move (ndir); |
523 | |
525 | |
524 | if (pos.normalise ()) |
526 | if (pos.normalise ()) |
525 | { |
527 | { |
526 | mapspace &ms = pos.ms (); |
528 | mapspace &ms = pos.ms (); |
527 | |
529 | |
528 | if (ms.smell > op->ms ().smell) |
530 | if (ms.smell > smell) |
529 | { |
531 | { |
530 | //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 |
|
|
533 | if (op->stats.Wis >= 10) |
531 | op->ms ().smell = ms.smell - 1; // smarter: tell others |
534 | smell = ms.smell - 1; // smarter: tell others |
|
|
535 | |
532 | sdir = ndir; |
536 | sdir = ndir; |
533 | |
537 | |
534 | // perturbing the path might let the monster lose track, |
538 | // perturbing the path might let the monster lose track, |
535 | // but it will also widen the actual path, spreading information |
539 | // but it will also widen the actual path, spreading information |
536 | if (!rndm (20)) // even smarter, deviate and spread? |
540 | if (op->stats.Wis >= 15 && !rndm (20)) // even smarter, deviate and spread? |
537 | sdir = absdir (sdir + 1 - rndm (2) * 2); |
541 | sdir = absdir (sdir + 1 - rndm (2) * 2); |
538 | } |
542 | } |
539 | } |
543 | } |
540 | } |
544 | } |
541 | |
545 | |
542 | if (sdir) |
546 | if (sdir) |
543 | dir = sdir; |
547 | dir = sdir; |
544 | else if (op->ms ().smell) |
548 | else if (smell) |
545 | { |
549 | { |
546 | // 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 |
547 | //printf ("erasing smell %d\n", op->ms ().smell);//D |
551 | //printf ("erasing smell %d\n", op->ms ().smell);//D |
548 | ordered_mapwalk_begin (op, -1, -1, 1, 1) |
552 | unordered_mapwalk (op, -1, -1, 1, 1) |
549 | if (m) |
|
|
550 | m->at (nx, ny).smell = 0; |
553 | m->at (nx, ny).smell = 0; |
551 | ordered_mapwalk_end |
|
|
552 | } |
554 | } |
553 | } |
555 | } |
554 | |
556 | |
555 | 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)) |
556 | dir = absdir (dir + 4); |
558 | dir = absdir (dir + 4); |
… | |
… | |
1418 | } |
1420 | } |
1419 | |
1421 | |
1420 | void |
1422 | void |
1421 | npc_call_help (object *op) |
1423 | npc_call_help (object *op) |
1422 | { |
1424 | { |
1423 | int x, y, mflags; |
1425 | unordered_mapwalk (op, -7, -7, 7, 7) |
1424 | object *npc; |
|
|
1425 | sint16 sx, sy; |
|
|
1426 | maptile *m; |
|
|
1427 | |
|
|
1428 | for (x = -3; x < 4; x++) |
|
|
1429 | for (y = -3; y < 4; y++) |
|
|
1430 | { |
1426 | { |
1431 | m = op->map; |
1427 | mapspace &ms = m->at (nx, ny); |
1432 | sx = op->x + x; |
1428 | |
1433 | sy = op->y + y; |
|
|
1434 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
|
|
1435 | /* 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. */ |
1436 | if ((mflags & P_OUT_OF_MAP) || !(mflags & P_IS_ALIVE)) |
1430 | if (!(ms.flags () & P_IS_ALIVE)) |
1437 | continue; |
1431 | continue; |
1438 | |
1432 | |
1439 | for (npc = GET_MAP_OB (m, sx, sy); npc != NULL; npc = npc->above) |
1433 | for (object *npc = ms.bot; npc; npc = npc->above) |
1440 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1434 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1441 | npc->enemy = op->enemy; |
1435 | npc->enemy = op->enemy; |
1442 | } |
1436 | } |
1443 | } |
1437 | } |
1444 | |
1438 | |
1445 | int |
1439 | int |
1446 | 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) |
1447 | { |
1441 | { |
1448 | if (can_hit (part, enemy, rv)) |
1442 | if (can_hit (part, enemy, rv)) |
1449 | return dir; |
1443 | return dir; |
1450 | |
1444 | |
1451 | if (rv->distance < 10) |
1445 | if (rv->distance < 10) |
… | |
… | |
1455 | |
1449 | |
1456 | return 0; |
1450 | return 0; |
1457 | } |
1451 | } |
1458 | |
1452 | |
1459 | int |
1453 | int |
1460 | 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) |
1461 | { |
1455 | { |
1462 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1456 | if (can_hit (part, enemy, rv)) |
1463 | { |
|
|
1464 | ob->move_status++; |
|
|
1465 | return (dir); |
1457 | return dir; |
1466 | } |
1458 | else |
1467 | else if (ob->move_status > 20) |
|
|
1468 | ob->move_status = 0; |
|
|
1469 | |
|
|
1470 | return absdir (dir + 4); |
1459 | return absdir (dir + 4); |
1471 | } |
1460 | } |
1472 | |
1461 | |
1473 | int |
1462 | int |
1474 | hitrun_att (int dir, object *ob, object *enemy) |
1463 | hitrun_att (int dir, object *ob, object *enemy) |
1475 | { |
1464 | { |
… | |
… | |
1484 | } |
1473 | } |
1485 | |
1474 | |
1486 | int |
1475 | int |
1487 | 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) |
1488 | { |
1477 | { |
1489 | |
|
|
1490 | int inrange = can_hit (part, enemy, rv); |
1478 | int inrange = can_hit (part, enemy, rv); |
1491 | |
1479 | |
1492 | if (ob->move_status || inrange) |
1480 | if (ob->move_status || inrange) |
1493 | ob->move_status++; |
1481 | ob->move_status++; |
1494 | |
1482 | |
… | |
… | |
1504 | } |
1492 | } |
1505 | |
1493 | |
1506 | int |
1494 | int |
1507 | 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) |
1508 | { |
1496 | { |
1509 | |
|
|
1510 | /* The logic below here looked plain wrong before. Basically, what should |
1497 | /* The logic below here looked plain wrong before. Basically, what should |
1511 | * 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, |
1512 | * the creature should run away (dir+4) |
1499 | * the creature should run away (dir+4) |
1513 | * 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 |
1514 | * 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 |
… | |
… | |
1890 | { |
1877 | { |
1891 | /* HIDDEN ENEMY. by definition, you can't see hidden stuff! |
1878 | /* HIDDEN ENEMY. by definition, you can't see hidden stuff! |
1892 | * However,if you carry any source of light, then the hidden |
1879 | * However,if you carry any source of light, then the hidden |
1893 | * creature is seeable (and stupid) */ |
1880 | * creature is seeable (and stupid) */ |
1894 | |
1881 | |
1895 | if (has_carried_lights (enemy)) |
1882 | if (enemy->has_carried_lights ()) |
1896 | { |
1883 | { |
1897 | if (enemy->flag [FLAG_HIDDEN]) |
1884 | if (enemy->flag [FLAG_HIDDEN]) |
1898 | { |
1885 | { |
1899 | make_visible (enemy); |
1886 | make_visible (enemy); |
1900 | 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!"); |