… | |
… | |
901 | * The skills we are treating here are all but those. -b.t. |
901 | * The skills we are treating here are all but those. -b.t. |
902 | * |
902 | * |
903 | * At the moment this is only useful for throwing, perhaps for |
903 | * At the moment this is only useful for throwing, perhaps for |
904 | * stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 |
904 | * stealing. TODO: This should be more integrated in the game. -MT, 25.11.01 |
905 | */ |
905 | */ |
906 | |
|
|
907 | int |
906 | int |
908 | monster_use_skill (object *head, object *part, object *pl, int dir) |
907 | monster_use_skill (object *head, object *part, object *pl, int dir) |
909 | { |
908 | { |
910 | object *skill, *owner; |
909 | object *skill, *owner; |
911 | |
910 | |
… | |
… | |
917 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
916 | int dir2 = find_dir_2 (head->x - owner->x, head->y - owner->y); |
918 | |
917 | |
919 | if (dirdiff (dir, dir2) < 1) |
918 | if (dirdiff (dir, dir2) < 1) |
920 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
919 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
921 | } |
920 | } |
|
|
921 | |
922 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
922 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
923 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
923 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
924 | |
924 | |
925 | /* skill selection - monster will use the next unused skill. |
925 | /* skill selection - monster will use the next unused skill. |
926 | * well...the following scenario will allow the monster to |
926 | * well...the following scenario will allow the monster to |
927 | * toggle between 2 skills. One day it would be nice to make |
927 | * toggle between 2 skills. One day it would be nice to make |
928 | * more skills available to monsters. |
928 | * more skills available to monsters. |
929 | */ |
929 | */ |
930 | |
930 | |
931 | for (skill = head->inv; skill != NULL; skill = skill->below) |
931 | for (skill = head->inv; skill; skill = skill->below) |
932 | if (skill->type == SKILL && skill != head->chosen_skill) |
932 | if (skill->type == SKILL && skill != head->chosen_skill) |
933 | { |
933 | { |
934 | head->chosen_skill = skill; |
934 | head->chosen_skill = skill; |
935 | break; |
935 | break; |
936 | } |
936 | } |
… | |
… | |
939 | { |
939 | { |
940 | LOG (llevDebug, "Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", &head->name, head->count); |
940 | LOG (llevDebug, "Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", &head->name, head->count); |
941 | CLEAR_FLAG (head, FLAG_READY_SKILL); |
941 | CLEAR_FLAG (head, FLAG_READY_SKILL); |
942 | return 0; |
942 | return 0; |
943 | } |
943 | } |
|
|
944 | |
944 | /* use skill */ |
945 | /* use skill */ |
945 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
946 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
946 | } |
947 | } |
947 | |
948 | |
948 | /* Monster will use a ranged spell attack. */ |
949 | /* Monster will use a ranged spell attack. */ |
949 | |
|
|
950 | int |
950 | int |
951 | monster_use_range (object *head, object *part, object *pl, int dir) |
951 | monster_use_range (object *head, object *part, object *pl, int dir) |
952 | { |
952 | { |
953 | object *wand, *owner; |
953 | object *wand, *owner; |
954 | int at_least_one = 0; |
954 | int at_least_one = 0; |
… | |
… | |
964 | return 0; /* Might hit owner with spell */ |
964 | return 0; /* Might hit owner with spell */ |
965 | } |
965 | } |
966 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
966 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
967 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
967 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
968 | |
968 | |
969 | for (wand = head->inv; wand != NULL; wand = wand->below) |
969 | for (wand = head->inv; wand; wand = wand->below) |
970 | { |
970 | { |
971 | if (wand->type == WAND) |
971 | if (wand->type == WAND) |
972 | { |
972 | { |
973 | /* Found a wand, let's see if it has charges left */ |
973 | /* Found a wand, let's see if it has charges left */ |
974 | at_least_one = 1; |
974 | at_least_one = 1; |
… | |
… | |
1075 | |
1075 | |
1076 | if (val > 0) |
1076 | if (val > 0) |
1077 | return 1; |
1077 | return 1; |
1078 | else |
1078 | else |
1079 | return 0; |
1079 | return 0; |
1080 | |
|
|
1081 | } |
1080 | } |
1082 | |
1081 | |
1083 | int |
1082 | int |
1084 | check_good_armour (object *who, object *item) |
1083 | check_good_armour (object *who, object *item) |
1085 | { |
1084 | { |
… | |
… | |
1116 | |
1115 | |
1117 | if (val > 0) |
1116 | if (val > 0) |
1118 | return 1; |
1117 | return 1; |
1119 | else |
1118 | else |
1120 | return 0; |
1119 | return 0; |
1121 | |
|
|
1122 | } |
1120 | } |
1123 | |
1121 | |
1124 | /* |
1122 | /* |
1125 | * monster_check_pickup(): checks for items that monster can pick up. |
1123 | * monster_check_pickup(): checks for items that monster can pick up. |
1126 | * |
1124 | * |
… | |
… | |
1134 | * This function was seen be continueing looping at one point (tmp->below |
1132 | * This function was seen be continueing looping at one point (tmp->below |
1135 | * became a recursive loop. It may be better to call monster_check_apply |
1133 | * became a recursive loop. It may be better to call monster_check_apply |
1136 | * after we pick everything up, since that function may call others which |
1134 | * after we pick everything up, since that function may call others which |
1137 | * affect stacking on this space. |
1135 | * affect stacking on this space. |
1138 | */ |
1136 | */ |
1139 | |
|
|
1140 | void |
1137 | void |
1141 | monster_check_pickup (object *monster) |
1138 | monster_check_pickup (object *monster) |
1142 | { |
1139 | { |
1143 | object *tmp, *next; |
1140 | object *tmp, *next; |
1144 | |
1141 | |
… | |
… | |
1163 | * monster_can_pick(): If the monster is interested in picking up |
1160 | * monster_can_pick(): If the monster is interested in picking up |
1164 | * the item, then return 0. Otherwise 0. |
1161 | * the item, then return 0. Otherwise 0. |
1165 | * Instead of pick_up, flags for "greed", etc, should be used. |
1162 | * Instead of pick_up, flags for "greed", etc, should be used. |
1166 | * I've already utilized flags for bows, wands, rings, etc, etc. -Frank. |
1163 | * I've already utilized flags for bows, wands, rings, etc, etc. -Frank. |
1167 | */ |
1164 | */ |
1168 | |
|
|
1169 | int |
1165 | int |
1170 | monster_can_pick (object *monster, object *item) |
1166 | monster_can_pick (object *monster, object *item) |
1171 | { |
1167 | { |
1172 | int flag = 0; |
1168 | int flag = 0; |
1173 | int i; |
1169 | int i; |
… | |
… | |
1231 | case BOW: |
1227 | case BOW: |
1232 | case ARROW: |
1228 | case ARROW: |
1233 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1229 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1234 | break; |
1230 | break; |
1235 | } |
1231 | } |
|
|
1232 | |
1236 | /* Simplistic check - if the monster has a location to equip it, he will |
1233 | /* Simplistic check - if the monster has a location to equip it, he will |
1237 | * pick it up. Note that this doesn't handle cases where an item may |
1234 | * pick it up. Note that this doesn't handle cases where an item may |
1238 | * use several locations. |
1235 | * use several locations. |
1239 | */ |
1236 | */ |
1240 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
1237 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
… | |
… | |
1255 | * monster_apply_below(): |
1252 | * monster_apply_below(): |
1256 | * Vick's (vick@bern.docs.uu.se) @921107 -> If a monster who's |
1253 | * Vick's (vick@bern.docs.uu.se) @921107 -> If a monster who's |
1257 | * eager to apply things, encounters something apply-able, |
1254 | * eager to apply things, encounters something apply-able, |
1258 | * then make him apply it |
1255 | * then make him apply it |
1259 | */ |
1256 | */ |
1260 | |
|
|
1261 | void |
1257 | void |
1262 | monster_apply_below (object *monster) |
1258 | monster_apply_below (object *monster) |
1263 | { |
1259 | { |
1264 | object *tmp, *next; |
1260 | object *tmp, *next; |
1265 | |
1261 | |
… | |
… | |
1292 | * a pointer to that object is returned, so it can be dropped. |
1288 | * a pointer to that object is returned, so it can be dropped. |
1293 | * (so that other monsters can pick it up and use it) |
1289 | * (so that other monsters can pick it up and use it) |
1294 | * Note that as things are now, monsters never drop something - |
1290 | * Note that as things are now, monsters never drop something - |
1295 | * they can pick up all that they can use. |
1291 | * they can pick up all that they can use. |
1296 | */ |
1292 | */ |
1297 | |
|
|
1298 | /* Sept 96, fixed this so skills will be readied -b.t.*/ |
1293 | /* Sept 96, fixed this so skills will be readied -b.t.*/ |
1299 | |
|
|
1300 | void |
1294 | void |
1301 | monster_check_apply (object *mon, object *item) |
1295 | monster_check_apply (object *mon, object *item) |
1302 | { |
1296 | { |
1303 | |
|
|
1304 | int flag = 0; |
1297 | int flag = 0; |
1305 | |
1298 | |
1306 | if (item->type == SPELLBOOK && mon->arch != NULL && (QUERY_FLAG ((&mon->arch->clone), FLAG_CAST_SPELL))) |
1299 | if (item->type == SPELLBOOK && mon->arch && (QUERY_FLAG ((&mon->arch->clone), FLAG_CAST_SPELL))) |
1307 | { |
1300 | { |
1308 | SET_FLAG (mon, FLAG_CAST_SPELL); |
1301 | SET_FLAG (mon, FLAG_CAST_SPELL); |
1309 | return; |
1302 | return; |
1310 | } |
1303 | } |
1311 | |
1304 | |
… | |
… | |
1320 | if (QUERY_FLAG (mon, FLAG_USE_BOW) && item->type == ARROW) |
1313 | if (QUERY_FLAG (mon, FLAG_USE_BOW) && item->type == ARROW) |
1321 | { |
1314 | { |
1322 | /* Check for the right kind of bow */ |
1315 | /* Check for the right kind of bow */ |
1323 | object *bow; |
1316 | object *bow; |
1324 | |
1317 | |
1325 | for (bow = mon->inv; bow != NULL; bow = bow->below) |
1318 | for (bow = mon->inv; bow; bow = bow->below) |
1326 | if (bow->type == BOW && bow->race == item->race) |
1319 | if (bow->type == BOW && bow->race == item->race) |
1327 | { |
1320 | { |
1328 | SET_FLAG (mon, FLAG_READY_BOW); |
1321 | SET_FLAG (mon, FLAG_READY_BOW); |
1329 | LOG (llevMonster, "Found correct bow for arrows.\n"); |
1322 | LOG (llevMonster, "Found correct bow for arrows.\n"); |
1330 | return; /* nothing more to do for arrows */ |
1323 | return; /* nothing more to do for arrows */ |
… | |
… | |
1382 | */ |
1375 | */ |
1383 | SET_FLAG (mon, FLAG_READY_SKILL); |
1376 | SET_FLAG (mon, FLAG_READY_SKILL); |
1384 | return; |
1377 | return; |
1385 | } |
1378 | } |
1386 | |
1379 | |
1387 | |
|
|
1388 | /* if we don't match one of the above types, return now. |
1380 | /* if we don't match one of the above types, return now. |
1389 | * can_apply_object will say that we can apply things like flesh, |
1381 | * can_apply_object will say that we can apply things like flesh, |
1390 | * bolts, and whatever else, because it only checks against the |
1382 | * bolts, and whatever else, because it only checks against the |
1391 | * body_info locations. |
1383 | * body_info locations. |
1392 | */ |
1384 | */ |
… | |
… | |
1403 | /* should only be applying this item, not unapplying it. |
1395 | /* should only be applying this item, not unapplying it. |
1404 | * also, ignore status of curse so they can take off old armour. |
1396 | * also, ignore status of curse so they can take off old armour. |
1405 | * monsters have some advantages after all. |
1397 | * monsters have some advantages after all. |
1406 | */ |
1398 | */ |
1407 | manual_apply (mon, item, AP_APPLY | AP_IGNORE_CURSE); |
1399 | manual_apply (mon, item, AP_APPLY | AP_IGNORE_CURSE); |
1408 | |
|
|
1409 | return; |
|
|
1410 | } |
1400 | } |
1411 | |
1401 | |
1412 | void |
1402 | void |
1413 | npc_call_help (object *op) |
1403 | npc_call_help (object *op) |
1414 | { |
1404 | { |
… | |
… | |
1432 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1422 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1433 | npc->enemy = op->enemy; |
1423 | npc->enemy = op->enemy; |
1434 | } |
1424 | } |
1435 | } |
1425 | } |
1436 | |
1426 | |
1437 | |
|
|
1438 | int |
1427 | int |
1439 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1428 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1440 | { |
1429 | { |
1441 | |
|
|
1442 | if (can_hit (part, enemy, rv)) |
1430 | if (can_hit (part, enemy, rv)) |
1443 | return dir; |
1431 | return dir; |
1444 | if (rv->distance < 10) |
1432 | if (rv->distance < 10) |
1445 | return absdir (dir + 4); |
1433 | return absdir (dir + 4); |
1446 | else if (rv->distance > 18) |
1434 | else if (rv->distance > 18) |
1447 | return dir; |
1435 | return dir; |
|
|
1436 | |
1448 | return 0; |
1437 | return 0; |
1449 | } |
1438 | } |
1450 | |
1439 | |
1451 | int |
1440 | int |
1452 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1441 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1453 | { |
1442 | { |
1454 | |
|
|
1455 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1443 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1456 | { |
1444 | { |
1457 | ob->move_status++; |
1445 | ob->move_status++; |
1458 | return (dir); |
1446 | return (dir); |
1459 | } |
1447 | } |
1460 | else if (ob->move_status > 20) |
1448 | else if (ob->move_status > 20) |
1461 | ob->move_status = 0; |
1449 | ob->move_status = 0; |
|
|
1450 | |
1462 | return absdir (dir + 4); |
1451 | return absdir (dir + 4); |
1463 | } |
1452 | } |
1464 | |
1453 | |
1465 | int |
1454 | int |
1466 | hitrun_att (int dir, object *ob, object *enemy) |
1455 | hitrun_att (int dir, object *ob, object *enemy) |
… | |
… | |
1469 | return dir; |
1458 | return dir; |
1470 | else if (ob->move_status < 50) |
1459 | else if (ob->move_status < 50) |
1471 | return absdir (dir + 4); |
1460 | return absdir (dir + 4); |
1472 | else |
1461 | else |
1473 | ob->move_status = 0; |
1462 | ob->move_status = 0; |
|
|
1463 | |
1474 | return absdir (dir + 4); |
1464 | return absdir (dir + 4); |
1475 | } |
1465 | } |
1476 | |
1466 | |
1477 | int |
1467 | int |
1478 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1468 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
… | |
… | |
1487 | return 0; |
1477 | return 0; |
1488 | else if (ob->move_status < 10) |
1478 | else if (ob->move_status < 10) |
1489 | return dir; |
1479 | return dir; |
1490 | else if (ob->move_status < 15) |
1480 | else if (ob->move_status < 15) |
1491 | return absdir (dir + 4); |
1481 | return absdir (dir + 4); |
|
|
1482 | |
1492 | ob->move_status = 0; |
1483 | ob->move_status = 0; |
1493 | return 0; |
1484 | return 0; |
1494 | } |
1485 | } |
1495 | |
1486 | |
1496 | int |
1487 | int |
… | |
… | |
1504 | * at least one map has this set, and whatever the map contains, the |
1495 | * at least one map has this set, and whatever the map contains, the |
1505 | * server should try to be resilant enough to avoid the problem |
1496 | * server should try to be resilant enough to avoid the problem |
1506 | */ |
1497 | */ |
1507 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1498 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1508 | return absdir (dir + 4); |
1499 | return absdir (dir + 4); |
|
|
1500 | |
1509 | return dist_att (dir, ob, enemy, part, rv); |
1501 | return dist_att (dir, ob, enemy, part, rv); |
1510 | } |
1502 | } |
1511 | |
1503 | |
1512 | int |
1504 | int |
1513 | wait_att2 (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1505 | wait_att2 (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1514 | { |
1506 | { |
1515 | if (rv->distance < 9) |
1507 | if (rv->distance < 9) |
1516 | return absdir (dir + 4); |
1508 | return absdir (dir + 4); |
|
|
1509 | |
1517 | return 0; |
1510 | return 0; |
1518 | } |
1511 | } |
1519 | |
1512 | |
1520 | void |
1513 | void |
1521 | circ1_move (object *ob) |
1514 | circ1_move (object *ob) |
1522 | { |
1515 | { |
1523 | static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; |
1516 | static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; |
|
|
1517 | |
1524 | if (++ob->move_status > 11) |
1518 | if (++ob->move_status > 11) |
1525 | ob->move_status = 0; |
1519 | ob->move_status = 0; |
|
|
1520 | |
1526 | if (!(move_object (ob, circle[ob->move_status]))) |
1521 | if (!(move_object (ob, circle[ob->move_status]))) |
1527 | (void) move_object (ob, rndm (8) + 1); |
1522 | move_object (ob, rndm (8) + 1); |
1528 | } |
1523 | } |
1529 | |
1524 | |
1530 | void |
1525 | void |
1531 | circ2_move (object *ob) |
1526 | circ2_move (object *ob) |
1532 | { |
1527 | { |
1533 | static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 }; |
1528 | static int circle[20] = { 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 1, 1, 1, 2, 2 }; |
|
|
1529 | |
1534 | if (++ob->move_status > 19) |
1530 | if (++ob->move_status > 19) |
1535 | ob->move_status = 0; |
1531 | ob->move_status = 0; |
|
|
1532 | |
1536 | if (!(move_object (ob, circle[ob->move_status]))) |
1533 | if (!(move_object (ob, circle[ob->move_status]))) |
1537 | (void) move_object (ob, rndm (8) + 1); |
1534 | move_object (ob, rndm (8) + 1); |
1538 | } |
1535 | } |
1539 | |
1536 | |
1540 | void |
1537 | void |
1541 | pace_movev (object *ob) |
1538 | pace_movev (object *ob) |
1542 | { |
1539 | { |
1543 | if (ob->move_status++ > 6) |
1540 | if (ob->move_status++ > 6) |
1544 | ob->move_status = 0; |
1541 | ob->move_status = 0; |
|
|
1542 | |
1545 | if (ob->move_status < 4) |
1543 | if (ob->move_status < 4) |
1546 | (void) move_object (ob, 5); |
1544 | move_object (ob, 5); |
1547 | else |
1545 | else |
1548 | (void) move_object (ob, 1); |
1546 | move_object (ob, 1); |
1549 | } |
1547 | } |
1550 | |
1548 | |
1551 | void |
1549 | void |
1552 | pace_moveh (object *ob) |
1550 | pace_moveh (object *ob) |
1553 | { |
1551 | { |
1554 | if (ob->move_status++ > 6) |
1552 | if (ob->move_status++ > 6) |
1555 | ob->move_status = 0; |
1553 | ob->move_status = 0; |
|
|
1554 | |
1556 | if (ob->move_status < 4) |
1555 | if (ob->move_status < 4) |
1557 | (void) move_object (ob, 3); |
1556 | move_object (ob, 3); |
1558 | else |
1557 | else |
1559 | (void) move_object (ob, 7); |
1558 | move_object (ob, 7); |
1560 | } |
1559 | } |
1561 | |
1560 | |
1562 | void |
1561 | void |
1563 | pace2_movev (object *ob) |
1562 | pace2_movev (object *ob) |
1564 | { |
1563 | { |
1565 | if (ob->move_status++ > 16) |
1564 | if (ob->move_status++ > 16) |
1566 | ob->move_status = 0; |
1565 | ob->move_status = 0; |
|
|
1566 | |
1567 | if (ob->move_status < 6) |
1567 | if (ob->move_status < 6) |
1568 | (void) move_object (ob, 5); |
1568 | move_object (ob, 5); |
1569 | else if (ob->move_status < 8) |
1569 | else if (ob->move_status < 8) |
1570 | return; |
1570 | return; |
1571 | else if (ob->move_status < 13) |
1571 | else if (ob->move_status < 13) |
1572 | (void) move_object (ob, 1); |
1572 | move_object (ob, 1); |
1573 | else |
1573 | else |
1574 | return; |
1574 | return; |
1575 | } |
1575 | } |
1576 | |
1576 | |
1577 | void |
1577 | void |
1578 | pace2_moveh (object *ob) |
1578 | pace2_moveh (object *ob) |
1579 | { |
1579 | { |
1580 | if (ob->move_status++ > 16) |
1580 | if (ob->move_status++ > 16) |
1581 | ob->move_status = 0; |
1581 | ob->move_status = 0; |
|
|
1582 | |
1582 | if (ob->move_status < 6) |
1583 | if (ob->move_status < 6) |
1583 | (void) move_object (ob, 3); |
1584 | move_object (ob, 3); |
1584 | else if (ob->move_status < 8) |
1585 | else if (ob->move_status < 8) |
1585 | return; |
1586 | return; |
1586 | else if (ob->move_status < 13) |
1587 | else if (ob->move_status < 13) |
1587 | (void) move_object (ob, 7); |
1588 | move_object (ob, 7); |
1588 | else |
1589 | else |
1589 | return; |
1590 | return; |
1590 | } |
1591 | } |
1591 | |
1592 | |
1592 | void |
1593 | void |
… | |
… | |
1635 | * monsters to throw things like chairs and other pieces of |
1636 | * monsters to throw things like chairs and other pieces of |
1636 | * furniture, even if they are not good throwable objects. |
1637 | * furniture, even if they are not good throwable objects. |
1637 | * Probably better to have the monster throw a throwable object |
1638 | * Probably better to have the monster throw a throwable object |
1638 | * first, then throw any non equipped weapon. |
1639 | * first, then throw any non equipped weapon. |
1639 | */ |
1640 | */ |
1640 | |
|
|
1641 | object * |
1641 | object * |
1642 | find_mon_throw_ob (object *op) |
1642 | find_mon_throw_ob (object *op) |
1643 | { |
1643 | { |
1644 | object *tmp = NULL; |
1644 | object *tmp = NULL; |
1645 | |
1645 | |
… | |
… | |
1820 | /* determine if op stands in a lighted square. This is not a very |
1820 | /* determine if op stands in a lighted square. This is not a very |
1821 | * intellegent algorithm. For one thing, we ignore los here, SO it |
1821 | * intellegent algorithm. For one thing, we ignore los here, SO it |
1822 | * is possible for a bright light to illuminate a player on the |
1822 | * is possible for a bright light to illuminate a player on the |
1823 | * other side of a wall (!). |
1823 | * other side of a wall (!). |
1824 | */ |
1824 | */ |
1825 | |
|
|
1826 | int |
1825 | int |
1827 | stand_in_light (object *op) |
1826 | stand_in_light (object *op) |
1828 | { |
1827 | { |
1829 | sint16 nx, ny; |
1828 | sint16 nx, ny; |
1830 | maptile *m; |
1829 | maptile *m; |
1831 | |
1830 | |
1832 | |
|
|
1833 | if (!op) |
1831 | if (!op) |
1834 | return 0; |
1832 | return 0; |
|
|
1833 | |
1835 | if (op->glow_radius > 0) |
1834 | if (op->glow_radius > 0) |
1836 | return 1; |
1835 | return 1; |
1837 | |
1836 | |
1838 | if (op->map) |
1837 | if (op->map) |
1839 | { |
1838 | { |
1840 | int x, y, x1, y1; |
1839 | int x, y, x1, y1; |
1841 | |
|
|
1842 | |
|
|
1843 | |
1840 | |
1844 | /* Check the spaces with the max light radius to see if any of them |
1841 | /* Check the spaces with the max light radius to see if any of them |
1845 | * have lights, and if any of them light the player enough, then return 1. |
1842 | * have lights, and if any of them light the player enough, then return 1. |
1846 | */ |
1843 | */ |
1847 | for (x = op->x - MAX_LIGHT_RADII; x <= op->x + MAX_LIGHT_RADII; x++) |
1844 | for (x = op->x - MAX_LIGHT_RADII; x <= op->x + MAX_LIGHT_RADII; x++) |
… | |
… | |
1860 | if (isqrt (x1 + y1) < GET_MAP_LIGHT (m, nx, ny)) |
1857 | if (isqrt (x1 + y1) < GET_MAP_LIGHT (m, nx, ny)) |
1861 | return 1; |
1858 | return 1; |
1862 | } |
1859 | } |
1863 | } |
1860 | } |
1864 | } |
1861 | } |
|
|
1862 | |
1865 | return 0; |
1863 | return 0; |
1866 | } |
1864 | } |
1867 | |
|
|
1868 | |
1865 | |
1869 | /* assuming no walls/barriers, lets check to see if its *possible* |
1866 | /* assuming no walls/barriers, lets check to see if its *possible* |
1870 | * to see an enemy. Note, "detection" is different from "seeing". |
1867 | * to see an enemy. Note, "detection" is different from "seeing". |
1871 | * See can_detect_enemy() for more details. -b.t. |
1868 | * See can_detect_enemy() for more details. -b.t. |
1872 | * return 0 if can't be seen, 1 if can be |
1869 | * return 0 if can't be seen, 1 if can be |
1873 | */ |
1870 | */ |
1874 | |
|
|
1875 | int |
1871 | int |
1876 | can_see_enemy (object *op, object *enemy) |
1872 | can_see_enemy (object *op, object *enemy) |
1877 | { |
1873 | { |
1878 | object *looker = op->head ? op->head : op; |
1874 | object *looker = op->head ? op->head : op; |
1879 | |
1875 | |