1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
85 | * target enemy - this code below makes sure the enemy is something |
85 | * target enemy - this code below makes sure the enemy is something |
86 | * that should be attacked. My guess is that the arrow hits |
86 | * that should be attacked. My guess is that the arrow hits |
87 | * the creature/owner, and so the creature then takes that |
87 | * the creature/owner, and so the creature then takes that |
88 | * as the enemy to attack. |
88 | * as the enemy to attack. |
89 | */ |
89 | */ |
90 | else if (!QUERY_FLAG (npc->enemy, FLAG_MONSTER) && |
90 | else if (!QUERY_FLAG (npc->enemy, FLAG_MONSTER) |
91 | !QUERY_FLAG (npc->enemy, FLAG_GENERATOR) && npc->enemy->type != PLAYER && npc->enemy->type != GOLEM) |
91 | && !QUERY_FLAG (npc->enemy, FLAG_GENERATOR) |
|
|
92 | && npc->enemy->type != PLAYER |
|
|
93 | && npc->enemy->type != GOLEM) |
92 | npc->enemy = NULL; |
94 | npc->enemy = NULL; |
93 | |
95 | |
94 | } |
96 | } |
95 | return can_detect_enemy (npc, npc->enemy, rv) ? npc->enemy : NULL; |
97 | return can_detect_enemy (npc, npc->enemy, rv) ? npc->enemy : NULL; |
96 | } |
98 | } |
… | |
… | |
446 | } /* stand still */ |
448 | } /* stand still */ |
447 | return 0; |
449 | return 0; |
448 | } /* no enemy */ |
450 | } /* no enemy */ |
449 | |
451 | |
450 | /* We have an enemy. Block immediately below is for pets */ |
452 | /* We have an enemy. Block immediately below is for pets */ |
451 | if ((op->attack_movement & HI4) == PETMOVE && (owner = op->owner) != NULL && !on_same_map (op, owner)) |
453 | if ((op->attack_movement & HI4) == PETMOVE |
|
|
454 | && (owner = op->owner) != NULL |
|
|
455 | && !on_same_map (op, owner) |
|
|
456 | && !owner->flag [FLAG_REMOVED]) |
452 | return follow_owner (op, owner); |
457 | return follow_owner (op, owner); |
453 | |
458 | |
454 | /* doppleganger code to change monster facing to that of the nearest |
459 | /* doppleganger code to change monster facing to that of the nearest |
455 | * player. Hmm. The code is here, but no monster in the current |
460 | * player. Hmm. The code is here, but no monster in the current |
456 | * arch set uses it. |
461 | * arch set uses it. |
… | |
… | |
475 | if (!QUERY_FLAG (op, FLAG_SCARED)) |
480 | if (!QUERY_FLAG (op, FLAG_SCARED)) |
476 | { |
481 | { |
477 | rv_vector rv1; |
482 | rv_vector rv1; |
478 | |
483 | |
479 | /* now we test every part of an object .... this is a real ugly piece of code */ |
484 | /* now we test every part of an object .... this is a real ugly piece of code */ |
480 | for (part = op; part != NULL; part = part->more) |
485 | for (part = op; part; part = part->more) |
481 | { |
486 | { |
482 | get_rangevector (part, enemy, &rv1, 0x1); |
487 | get_rangevector (part, enemy, &rv1, 0x1); |
483 | dir = rv1.direction; |
488 | dir = rv1.direction; |
484 | |
489 | |
485 | /* hm, not sure about this part - in original was a scared flag here too |
490 | /* hm, not sure about this part - in original was a scared flag here too |
… | |
… | |
896 | * 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. |
897 | * |
902 | * |
898 | * At the moment this is only useful for throwing, perhaps for |
903 | * At the moment this is only useful for throwing, perhaps for |
899 | * 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 |
900 | */ |
905 | */ |
901 | |
|
|
902 | int |
906 | int |
903 | monster_use_skill (object *head, object *part, object *pl, int dir) |
907 | monster_use_skill (object *head, object *part, object *pl, int dir) |
904 | { |
908 | { |
905 | object *skill, *owner; |
909 | object *skill, *owner; |
906 | |
910 | |
… | |
… | |
912 | 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); |
913 | |
917 | |
914 | if (dirdiff (dir, dir2) < 1) |
918 | if (dirdiff (dir, dir2) < 1) |
915 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
919 | return 0; /* Might hit owner with skill -thrown rocks for example ? */ |
916 | } |
920 | } |
|
|
921 | |
917 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
922 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
918 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
923 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
919 | |
924 | |
920 | /* skill selection - monster will use the next unused skill. |
925 | /* skill selection - monster will use the next unused skill. |
921 | * well...the following scenario will allow the monster to |
926 | * well...the following scenario will allow the monster to |
922 | * 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 |
923 | * more skills available to monsters. |
928 | * more skills available to monsters. |
924 | */ |
929 | */ |
925 | |
|
|
926 | for (skill = head->inv; skill != NULL; skill = skill->below) |
930 | for (skill = head->inv; skill; skill = skill->below) |
927 | if (skill->type == SKILL && skill != head->chosen_skill) |
931 | if (skill->type == SKILL && skill != head->chosen_skill) |
928 | { |
932 | { |
929 | head->chosen_skill = skill; |
933 | head->chosen_skill = skill; |
930 | break; |
934 | break; |
931 | } |
935 | } |
… | |
… | |
934 | { |
938 | { |
935 | LOG (llevDebug, "Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", &head->name, head->count); |
939 | LOG (llevDebug, "Error: Monster %s (%d) has FLAG_READY_SKILL without skill.\n", &head->name, head->count); |
936 | CLEAR_FLAG (head, FLAG_READY_SKILL); |
940 | CLEAR_FLAG (head, FLAG_READY_SKILL); |
937 | return 0; |
941 | return 0; |
938 | } |
942 | } |
|
|
943 | |
939 | /* use skill */ |
944 | /* use skill */ |
940 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
945 | return do_skill (head, part, head->chosen_skill, dir, NULL); |
941 | } |
946 | } |
942 | |
947 | |
943 | /* Monster will use a ranged spell attack. */ |
948 | /* Monster will use a ranged spell attack. */ |
944 | |
|
|
945 | int |
949 | int |
946 | monster_use_range (object *head, object *part, object *pl, int dir) |
950 | monster_use_range (object *head, object *part, object *pl, int dir) |
947 | { |
951 | { |
948 | object *wand, *owner; |
952 | object *wand, *owner; |
949 | int at_least_one = 0; |
953 | int at_least_one = 0; |
… | |
… | |
959 | return 0; /* Might hit owner with spell */ |
963 | return 0; /* Might hit owner with spell */ |
960 | } |
964 | } |
961 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
965 | if (QUERY_FLAG (head, FLAG_CONFUSED)) |
962 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
966 | dir = absdir (dir + rndm (3) + rndm (3) - 2); |
963 | |
967 | |
964 | for (wand = head->inv; wand != NULL; wand = wand->below) |
968 | for (wand = head->inv; wand; wand = wand->below) |
965 | { |
969 | { |
966 | if (wand->type == WAND) |
970 | if (wand->type == WAND) |
967 | { |
971 | { |
968 | /* Found a wand, let's see if it has charges left */ |
972 | /* Found a wand, let's see if it has charges left */ |
969 | at_least_one = 1; |
973 | at_least_one = 1; |
… | |
… | |
1070 | |
1074 | |
1071 | if (val > 0) |
1075 | if (val > 0) |
1072 | return 1; |
1076 | return 1; |
1073 | else |
1077 | else |
1074 | return 0; |
1078 | return 0; |
1075 | |
|
|
1076 | } |
1079 | } |
1077 | |
1080 | |
1078 | int |
1081 | int |
1079 | check_good_armour (object *who, object *item) |
1082 | check_good_armour (object *who, object *item) |
1080 | { |
1083 | { |
… | |
… | |
1111 | |
1114 | |
1112 | if (val > 0) |
1115 | if (val > 0) |
1113 | return 1; |
1116 | return 1; |
1114 | else |
1117 | else |
1115 | return 0; |
1118 | return 0; |
1116 | |
|
|
1117 | } |
1119 | } |
1118 | |
1120 | |
1119 | /* |
1121 | /* |
1120 | * monster_check_pickup(): checks for items that monster can pick up. |
1122 | * monster_check_pickup(): checks for items that monster can pick up. |
1121 | * |
1123 | * |
… | |
… | |
1129 | * This function was seen be continueing looping at one point (tmp->below |
1131 | * This function was seen be continueing looping at one point (tmp->below |
1130 | * became a recursive loop. It may be better to call monster_check_apply |
1132 | * became a recursive loop. It may be better to call monster_check_apply |
1131 | * after we pick everything up, since that function may call others which |
1133 | * after we pick everything up, since that function may call others which |
1132 | * affect stacking on this space. |
1134 | * affect stacking on this space. |
1133 | */ |
1135 | */ |
1134 | |
|
|
1135 | void |
1136 | void |
1136 | monster_check_pickup (object *monster) |
1137 | monster_check_pickup (object *monster) |
1137 | { |
1138 | { |
1138 | object *tmp, *next; |
1139 | object *tmp, *next; |
1139 | |
1140 | |
… | |
… | |
1158 | * monster_can_pick(): If the monster is interested in picking up |
1159 | * monster_can_pick(): If the monster is interested in picking up |
1159 | * the item, then return 0. Otherwise 0. |
1160 | * the item, then return 0. Otherwise 0. |
1160 | * Instead of pick_up, flags for "greed", etc, should be used. |
1161 | * Instead of pick_up, flags for "greed", etc, should be used. |
1161 | * I've already utilized flags for bows, wands, rings, etc, etc. -Frank. |
1162 | * I've already utilized flags for bows, wands, rings, etc, etc. -Frank. |
1162 | */ |
1163 | */ |
1163 | |
|
|
1164 | int |
1164 | int |
1165 | monster_can_pick (object *monster, object *item) |
1165 | monster_can_pick (object *monster, object *item) |
1166 | { |
1166 | { |
1167 | int flag = 0; |
1167 | int flag = 0; |
1168 | int i; |
1168 | int i; |
… | |
… | |
1226 | case BOW: |
1226 | case BOW: |
1227 | case ARROW: |
1227 | case ARROW: |
1228 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1228 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1229 | break; |
1229 | break; |
1230 | } |
1230 | } |
|
|
1231 | |
1231 | /* Simplistic check - if the monster has a location to equip it, he will |
1232 | /* Simplistic check - if the monster has a location to equip it, he will |
1232 | * pick it up. Note that this doesn't handle cases where an item may |
1233 | * pick it up. Note that this doesn't handle cases where an item may |
1233 | * use several locations. |
1234 | * use several locations. |
1234 | */ |
1235 | */ |
1235 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
1236 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
… | |
… | |
1250 | * monster_apply_below(): |
1251 | * monster_apply_below(): |
1251 | * Vick's (vick@bern.docs.uu.se) @921107 -> If a monster who's |
1252 | * Vick's (vick@bern.docs.uu.se) @921107 -> If a monster who's |
1252 | * eager to apply things, encounters something apply-able, |
1253 | * eager to apply things, encounters something apply-able, |
1253 | * then make him apply it |
1254 | * then make him apply it |
1254 | */ |
1255 | */ |
1255 | |
|
|
1256 | void |
1256 | void |
1257 | monster_apply_below (object *monster) |
1257 | monster_apply_below (object *monster) |
1258 | { |
1258 | { |
1259 | object *tmp, *next; |
1259 | object *tmp, *next; |
1260 | |
1260 | |
… | |
… | |
1287 | * a pointer to that object is returned, so it can be dropped. |
1287 | * a pointer to that object is returned, so it can be dropped. |
1288 | * (so that other monsters can pick it up and use it) |
1288 | * (so that other monsters can pick it up and use it) |
1289 | * Note that as things are now, monsters never drop something - |
1289 | * Note that as things are now, monsters never drop something - |
1290 | * they can pick up all that they can use. |
1290 | * they can pick up all that they can use. |
1291 | */ |
1291 | */ |
1292 | |
|
|
1293 | /* Sept 96, fixed this so skills will be readied -b.t.*/ |
1292 | /* Sept 96, fixed this so skills will be readied -b.t.*/ |
1294 | |
|
|
1295 | void |
1293 | void |
1296 | monster_check_apply (object *mon, object *item) |
1294 | monster_check_apply (object *mon, object *item) |
1297 | { |
1295 | { |
1298 | |
|
|
1299 | int flag = 0; |
1296 | int flag = 0; |
1300 | |
1297 | |
1301 | if (item->type == SPELLBOOK && mon->arch != NULL && (QUERY_FLAG ((&mon->arch->clone), FLAG_CAST_SPELL))) |
1298 | if (item->type == SPELLBOOK && mon->arch && (QUERY_FLAG ((&mon->arch->clone), FLAG_CAST_SPELL))) |
1302 | { |
1299 | { |
1303 | SET_FLAG (mon, FLAG_CAST_SPELL); |
1300 | SET_FLAG (mon, FLAG_CAST_SPELL); |
1304 | return; |
1301 | return; |
1305 | } |
1302 | } |
1306 | |
1303 | |
… | |
… | |
1315 | if (QUERY_FLAG (mon, FLAG_USE_BOW) && item->type == ARROW) |
1312 | if (QUERY_FLAG (mon, FLAG_USE_BOW) && item->type == ARROW) |
1316 | { |
1313 | { |
1317 | /* Check for the right kind of bow */ |
1314 | /* Check for the right kind of bow */ |
1318 | object *bow; |
1315 | object *bow; |
1319 | |
1316 | |
1320 | for (bow = mon->inv; bow != NULL; bow = bow->below) |
1317 | for (bow = mon->inv; bow; bow = bow->below) |
1321 | if (bow->type == BOW && bow->race == item->race) |
1318 | if (bow->type == BOW && bow->race == item->race) |
1322 | { |
1319 | { |
1323 | SET_FLAG (mon, FLAG_READY_BOW); |
1320 | SET_FLAG (mon, FLAG_READY_BOW); |
1324 | LOG (llevMonster, "Found correct bow for arrows.\n"); |
1321 | LOG (llevMonster, "Found correct bow for arrows.\n"); |
1325 | return; /* nothing more to do for arrows */ |
1322 | return; /* nothing more to do for arrows */ |
… | |
… | |
1377 | */ |
1374 | */ |
1378 | SET_FLAG (mon, FLAG_READY_SKILL); |
1375 | SET_FLAG (mon, FLAG_READY_SKILL); |
1379 | return; |
1376 | return; |
1380 | } |
1377 | } |
1381 | |
1378 | |
1382 | |
|
|
1383 | /* if we don't match one of the above types, return now. |
1379 | /* if we don't match one of the above types, return now. |
1384 | * can_apply_object will say that we can apply things like flesh, |
1380 | * can_apply_object will say that we can apply things like flesh, |
1385 | * bolts, and whatever else, because it only checks against the |
1381 | * bolts, and whatever else, because it only checks against the |
1386 | * body_info locations. |
1382 | * body_info locations. |
1387 | */ |
1383 | */ |
… | |
… | |
1398 | /* should only be applying this item, not unapplying it. |
1394 | /* should only be applying this item, not unapplying it. |
1399 | * also, ignore status of curse so they can take off old armour. |
1395 | * also, ignore status of curse so they can take off old armour. |
1400 | * monsters have some advantages after all. |
1396 | * monsters have some advantages after all. |
1401 | */ |
1397 | */ |
1402 | manual_apply (mon, item, AP_APPLY | AP_IGNORE_CURSE); |
1398 | manual_apply (mon, item, AP_APPLY | AP_IGNORE_CURSE); |
1403 | |
|
|
1404 | return; |
|
|
1405 | } |
1399 | } |
1406 | |
1400 | |
1407 | void |
1401 | void |
1408 | npc_call_help (object *op) |
1402 | npc_call_help (object *op) |
1409 | { |
1403 | { |
… | |
… | |
1427 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1421 | if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) |
1428 | npc->enemy = op->enemy; |
1422 | npc->enemy = op->enemy; |
1429 | } |
1423 | } |
1430 | } |
1424 | } |
1431 | |
1425 | |
1432 | |
|
|
1433 | int |
1426 | int |
1434 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1427 | dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1435 | { |
1428 | { |
1436 | |
|
|
1437 | if (can_hit (part, enemy, rv)) |
1429 | if (can_hit (part, enemy, rv)) |
1438 | return dir; |
1430 | return dir; |
1439 | if (rv->distance < 10) |
1431 | if (rv->distance < 10) |
1440 | return absdir (dir + 4); |
1432 | return absdir (dir + 4); |
1441 | else if (rv->distance > 18) |
1433 | else if (rv->distance > 18) |
1442 | return dir; |
1434 | return dir; |
|
|
1435 | |
1443 | return 0; |
1436 | return 0; |
1444 | } |
1437 | } |
1445 | |
1438 | |
1446 | int |
1439 | int |
1447 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1440 | run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1448 | { |
1441 | { |
1449 | |
|
|
1450 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1442 | if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) |
1451 | { |
1443 | { |
1452 | ob->move_status++; |
1444 | ob->move_status++; |
1453 | return (dir); |
1445 | return (dir); |
1454 | } |
1446 | } |
1455 | else if (ob->move_status > 20) |
1447 | else if (ob->move_status > 20) |
1456 | ob->move_status = 0; |
1448 | ob->move_status = 0; |
|
|
1449 | |
1457 | return absdir (dir + 4); |
1450 | return absdir (dir + 4); |
1458 | } |
1451 | } |
1459 | |
1452 | |
1460 | int |
1453 | int |
1461 | hitrun_att (int dir, object *ob, object *enemy) |
1454 | hitrun_att (int dir, object *ob, object *enemy) |
… | |
… | |
1464 | return dir; |
1457 | return dir; |
1465 | else if (ob->move_status < 50) |
1458 | else if (ob->move_status < 50) |
1466 | return absdir (dir + 4); |
1459 | return absdir (dir + 4); |
1467 | else |
1460 | else |
1468 | ob->move_status = 0; |
1461 | ob->move_status = 0; |
|
|
1462 | |
1469 | return absdir (dir + 4); |
1463 | return absdir (dir + 4); |
1470 | } |
1464 | } |
1471 | |
1465 | |
1472 | int |
1466 | int |
1473 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1467 | wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
… | |
… | |
1482 | return 0; |
1476 | return 0; |
1483 | else if (ob->move_status < 10) |
1477 | else if (ob->move_status < 10) |
1484 | return dir; |
1478 | return dir; |
1485 | else if (ob->move_status < 15) |
1479 | else if (ob->move_status < 15) |
1486 | return absdir (dir + 4); |
1480 | return absdir (dir + 4); |
|
|
1481 | |
1487 | ob->move_status = 0; |
1482 | ob->move_status = 0; |
1488 | return 0; |
1483 | return 0; |
1489 | } |
1484 | } |
1490 | |
1485 | |
1491 | int |
1486 | int |
… | |
… | |
1499 | * at least one map has this set, and whatever the map contains, the |
1494 | * at least one map has this set, and whatever the map contains, the |
1500 | * server should try to be resilant enough to avoid the problem |
1495 | * server should try to be resilant enough to avoid the problem |
1501 | */ |
1496 | */ |
1502 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1497 | if (ob->stats.maxhp && (ob->stats.hp * 100) / ob->stats.maxhp < ob->run_away) |
1503 | return absdir (dir + 4); |
1498 | return absdir (dir + 4); |
|
|
1499 | |
1504 | return dist_att (dir, ob, enemy, part, rv); |
1500 | return dist_att (dir, ob, enemy, part, rv); |
1505 | } |
1501 | } |
1506 | |
1502 | |
1507 | int |
1503 | int |
1508 | wait_att2 (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1504 | wait_att2 (int dir, object *ob, object *enemy, object *part, rv_vector * rv) |
1509 | { |
1505 | { |
1510 | if (rv->distance < 9) |
1506 | if (rv->distance < 9) |
1511 | return absdir (dir + 4); |
1507 | return absdir (dir + 4); |
|
|
1508 | |
1512 | return 0; |
1509 | return 0; |
1513 | } |
1510 | } |
1514 | |
1511 | |
1515 | void |
1512 | void |
1516 | circ1_move (object *ob) |
1513 | circ1_move (object *ob) |
1517 | { |
1514 | { |
1518 | static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; |
1515 | static int circle[12] = { 3, 3, 4, 5, 5, 6, 7, 7, 8, 1, 1, 2 }; |
|
|
1516 | |
1519 | if (++ob->move_status > 11) |
1517 | if (++ob->move_status > 11) |
1520 | ob->move_status = 0; |
1518 | ob->move_status = 0; |
|
|
1519 | |
1521 | if (!(move_object (ob, circle[ob->move_status]))) |
1520 | if (!(move_object (ob, circle[ob->move_status]))) |
1522 | (void) move_object (ob, rndm (8) + 1); |
1521 | move_object (ob, rndm (8) + 1); |
1523 | } |
1522 | } |
1524 | |
1523 | |
1525 | void |
1524 | void |
1526 | circ2_move (object *ob) |
1525 | circ2_move (object *ob) |
1527 | { |
1526 | { |
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 }; |
1527 | 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 | |
1529 | if (++ob->move_status > 19) |
1529 | if (++ob->move_status > 19) |
1530 | ob->move_status = 0; |
1530 | ob->move_status = 0; |
|
|
1531 | |
1531 | if (!(move_object (ob, circle[ob->move_status]))) |
1532 | if (!(move_object (ob, circle[ob->move_status]))) |
1532 | (void) move_object (ob, rndm (8) + 1); |
1533 | move_object (ob, rndm (8) + 1); |
1533 | } |
1534 | } |
1534 | |
1535 | |
1535 | void |
1536 | void |
1536 | pace_movev (object *ob) |
1537 | pace_movev (object *ob) |
1537 | { |
1538 | { |
1538 | if (ob->move_status++ > 6) |
1539 | if (ob->move_status++ > 6) |
1539 | ob->move_status = 0; |
1540 | ob->move_status = 0; |
|
|
1541 | |
1540 | if (ob->move_status < 4) |
1542 | if (ob->move_status < 4) |
1541 | (void) move_object (ob, 5); |
1543 | move_object (ob, 5); |
1542 | else |
1544 | else |
1543 | (void) move_object (ob, 1); |
1545 | move_object (ob, 1); |
1544 | } |
1546 | } |
1545 | |
1547 | |
1546 | void |
1548 | void |
1547 | pace_moveh (object *ob) |
1549 | pace_moveh (object *ob) |
1548 | { |
1550 | { |
1549 | if (ob->move_status++ > 6) |
1551 | if (ob->move_status++ > 6) |
1550 | ob->move_status = 0; |
1552 | ob->move_status = 0; |
|
|
1553 | |
1551 | if (ob->move_status < 4) |
1554 | if (ob->move_status < 4) |
1552 | (void) move_object (ob, 3); |
1555 | move_object (ob, 3); |
1553 | else |
1556 | else |
1554 | (void) move_object (ob, 7); |
1557 | move_object (ob, 7); |
1555 | } |
1558 | } |
1556 | |
1559 | |
1557 | void |
1560 | void |
1558 | pace2_movev (object *ob) |
1561 | pace2_movev (object *ob) |
1559 | { |
1562 | { |
1560 | if (ob->move_status++ > 16) |
1563 | if (ob->move_status++ > 16) |
1561 | ob->move_status = 0; |
1564 | ob->move_status = 0; |
|
|
1565 | |
1562 | if (ob->move_status < 6) |
1566 | if (ob->move_status < 6) |
1563 | (void) move_object (ob, 5); |
1567 | move_object (ob, 5); |
1564 | else if (ob->move_status < 8) |
1568 | else if (ob->move_status < 8) |
1565 | return; |
1569 | return; |
1566 | else if (ob->move_status < 13) |
1570 | else if (ob->move_status < 13) |
1567 | (void) move_object (ob, 1); |
1571 | move_object (ob, 1); |
1568 | else |
1572 | else |
1569 | return; |
1573 | return; |
1570 | } |
1574 | } |
1571 | |
1575 | |
1572 | void |
1576 | void |
1573 | pace2_moveh (object *ob) |
1577 | pace2_moveh (object *ob) |
1574 | { |
1578 | { |
1575 | if (ob->move_status++ > 16) |
1579 | if (ob->move_status++ > 16) |
1576 | ob->move_status = 0; |
1580 | ob->move_status = 0; |
|
|
1581 | |
1577 | if (ob->move_status < 6) |
1582 | if (ob->move_status < 6) |
1578 | (void) move_object (ob, 3); |
1583 | move_object (ob, 3); |
1579 | else if (ob->move_status < 8) |
1584 | else if (ob->move_status < 8) |
1580 | return; |
1585 | return; |
1581 | else if (ob->move_status < 13) |
1586 | else if (ob->move_status < 13) |
1582 | (void) move_object (ob, 7); |
1587 | move_object (ob, 7); |
1583 | else |
1588 | else |
1584 | return; |
1589 | return; |
1585 | } |
1590 | } |
1586 | |
1591 | |
1587 | void |
1592 | void |
… | |
… | |
1630 | * monsters to throw things like chairs and other pieces of |
1635 | * monsters to throw things like chairs and other pieces of |
1631 | * furniture, even if they are not good throwable objects. |
1636 | * furniture, even if they are not good throwable objects. |
1632 | * Probably better to have the monster throw a throwable object |
1637 | * Probably better to have the monster throw a throwable object |
1633 | * first, then throw any non equipped weapon. |
1638 | * first, then throw any non equipped weapon. |
1634 | */ |
1639 | */ |
1635 | |
|
|
1636 | object * |
1640 | object * |
1637 | find_mon_throw_ob (object *op) |
1641 | find_mon_throw_ob (object *op) |
1638 | { |
1642 | { |
1639 | object *tmp = NULL; |
1643 | object *tmp = NULL; |
1640 | |
1644 | |
… | |
… | |
1815 | /* 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 |
1816 | * intellegent algorithm. For one thing, we ignore los here, SO it |
1820 | * intellegent algorithm. For one thing, we ignore los here, SO it |
1817 | * 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 |
1818 | * other side of a wall (!). |
1822 | * other side of a wall (!). |
1819 | */ |
1823 | */ |
1820 | |
|
|
1821 | int |
1824 | int |
1822 | stand_in_light (object *op) |
1825 | stand_in_light (object *op) |
1823 | { |
1826 | { |
1824 | sint16 nx, ny; |
1827 | sint16 nx, ny; |
1825 | maptile *m; |
1828 | maptile *m; |
1826 | |
1829 | |
1827 | |
|
|
1828 | if (!op) |
1830 | if (!op) |
1829 | return 0; |
1831 | return 0; |
|
|
1832 | |
1830 | if (op->glow_radius > 0) |
1833 | if (op->glow_radius > 0) |
1831 | return 1; |
1834 | return 1; |
1832 | |
1835 | |
1833 | if (op->map) |
1836 | if (op->map) |
1834 | { |
1837 | { |
1835 | int x, y, x1, y1; |
1838 | int x, y, x1, y1; |
1836 | |
|
|
1837 | |
|
|
1838 | |
1839 | |
1839 | /* Check the spaces with the max light radius to see if any of them |
1840 | /* Check the spaces with the max light radius to see if any of them |
1840 | * have lights, and if any of them light the player enough, then return 1. |
1841 | * have lights, and if any of them light the player enough, then return 1. |
1841 | */ |
1842 | */ |
1842 | for (x = op->x - MAX_LIGHT_RADII; x <= op->x + MAX_LIGHT_RADII; x++) |
1843 | for (x = op->x - MAX_LIGHT_RADII; x <= op->x + MAX_LIGHT_RADII; x++) |
… | |
… | |
1855 | if (isqrt (x1 + y1) < GET_MAP_LIGHT (m, nx, ny)) |
1856 | if (isqrt (x1 + y1) < GET_MAP_LIGHT (m, nx, ny)) |
1856 | return 1; |
1857 | return 1; |
1857 | } |
1858 | } |
1858 | } |
1859 | } |
1859 | } |
1860 | } |
|
|
1861 | |
1860 | return 0; |
1862 | return 0; |
1861 | } |
1863 | } |
1862 | |
|
|
1863 | |
1864 | |
1864 | /* assuming no walls/barriers, lets check to see if its *possible* |
1865 | /* assuming no walls/barriers, lets check to see if its *possible* |
1865 | * to see an enemy. Note, "detection" is different from "seeing". |
1866 | * to see an enemy. Note, "detection" is different from "seeing". |
1866 | * See can_detect_enemy() for more details. -b.t. |
1867 | * See can_detect_enemy() for more details. -b.t. |
1867 | * return 0 if can't be seen, 1 if can be |
1868 | * return 0 if can't be seen, 1 if can be |
1868 | */ |
1869 | */ |
1869 | |
|
|
1870 | int |
1870 | int |
1871 | can_see_enemy (object *op, object *enemy) |
1871 | can_see_enemy (object *op, object *enemy) |
1872 | { |
1872 | { |
1873 | object *looker = op->head ? op->head : op; |
1873 | object *looker = op->head ? op->head : op; |
1874 | |
1874 | |