… | |
… | |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * and the GNU General Public License along with this program. If not, see |
|
|
20 | * <http://www.gnu.org/licenses/>. |
20 | * |
21 | * |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
… | |
… | |
46 | npc->enemy = NULL; |
47 | npc->enemy = NULL; |
47 | else if (npc->enemy == NULL) |
48 | else if (npc->enemy == NULL) |
48 | npc->enemy = npc->owner->enemy; |
49 | npc->enemy = npc->owner->enemy; |
49 | } |
50 | } |
50 | |
51 | |
51 | /* periodically, a monster mayu change its target. Also, if the object |
52 | /* periodically, a monster may change its target. Also, if the object |
52 | * has been destroyed, etc, clear the enemy. |
53 | * has been destroyed, etc, clear the enemy. |
53 | * TODO: this should be changed, because it invokes to attack forced or |
54 | * TODO: this should be changed, because it invokes to attack forced or |
54 | * attacked monsters to leave the attacker alone, before it is destroyed |
55 | * attacked monsters to leave the attacker alone, before it is destroyed |
55 | */ |
56 | */ |
56 | /* i had removed the random target leave, this invokes problems with friendly |
57 | /* I had removed the random target leave, this invokes problems with friendly |
57 | * objects, getting attacked and defending herself - they don't try to attack |
58 | * objects, getting attacked and defending herself - they don't try to attack |
58 | * again then but perhaps get attack on and on |
59 | * again then but perhaps get attack on and on |
59 | * If we include a aggravated flag in , we can handle evil vs evil and good vs good |
60 | * If we include a aggravated flag in , we can handle evil vs evil and good vs good |
60 | * too. */ |
61 | * too. */ |
61 | |
62 | |
… | |
… | |
65 | * the grouping checks are. Code is the same. |
66 | * the grouping checks are. Code is the same. |
66 | */ |
67 | */ |
67 | if (QUERY_FLAG (npc->enemy, FLAG_REMOVED) || |
68 | if (QUERY_FLAG (npc->enemy, FLAG_REMOVED) || |
68 | QUERY_FLAG (npc->enemy, FLAG_FREED) || |
69 | QUERY_FLAG (npc->enemy, FLAG_FREED) || |
69 | !on_same_map (npc, npc->enemy) || npc == npc->enemy || QUERY_FLAG (npc, FLAG_NEUTRAL) || QUERY_FLAG (npc->enemy, FLAG_NEUTRAL)) |
70 | !on_same_map (npc, npc->enemy) || npc == npc->enemy || QUERY_FLAG (npc, FLAG_NEUTRAL) || QUERY_FLAG (npc->enemy, FLAG_NEUTRAL)) |
70 | npc->enemy = NULL; |
71 | npc->enemy = 0; |
71 | |
72 | |
72 | else if (QUERY_FLAG (npc, FLAG_FRIENDLY) && ((QUERY_FLAG (npc->enemy, FLAG_FRIENDLY) |
73 | else if (QUERY_FLAG (npc, FLAG_FRIENDLY) && ((QUERY_FLAG (npc->enemy, FLAG_FRIENDLY) |
73 | && !(should_arena_attack (npc, npc->owner, npc->enemy))) |
74 | && !(should_arena_attack (npc, npc->owner, npc->enemy))) |
74 | || ((npc->enemy->type == PLAYER) && !(should_arena_attack (npc, npc->owner, npc->enemy))) |
75 | || ((npc->enemy->type == PLAYER) && !(should_arena_attack (npc, npc->owner, npc->enemy))) |
75 | || npc->enemy == npc->owner)) |
76 | || npc->enemy == npc->owner)) |
76 | npc->enemy = NULL; |
77 | npc->enemy = 0; |
77 | |
78 | |
78 | |
79 | |
79 | else if (!QUERY_FLAG (npc, FLAG_FRIENDLY) && (!QUERY_FLAG (npc->enemy, FLAG_FRIENDLY) && npc->enemy->type != PLAYER)) |
80 | else if (!QUERY_FLAG (npc, FLAG_FRIENDLY) && (!QUERY_FLAG (npc->enemy, FLAG_FRIENDLY) && npc->enemy->type != PLAYER)) |
80 | npc->enemy = NULL; |
81 | npc->enemy = 0; |
81 | |
82 | |
82 | /* I've noticed that pets could sometimes get an arrow as the |
83 | /* I've noticed that pets could sometimes get an arrow as the |
83 | * target enemy - this code below makes sure the enemy is something |
84 | * target enemy - this code below makes sure the enemy is something |
84 | * that should be attacked. My guess is that the arrow hits |
85 | * that should be attacked. My guess is that the arrow hits |
85 | * the creature/owner, and so the creature then takes that |
86 | * the creature/owner, and so the creature then takes that |
… | |
… | |
87 | */ |
88 | */ |
88 | else if (!QUERY_FLAG (npc->enemy, FLAG_MONSTER) |
89 | else if (!QUERY_FLAG (npc->enemy, FLAG_MONSTER) |
89 | && !QUERY_FLAG (npc->enemy, FLAG_GENERATOR) |
90 | && !QUERY_FLAG (npc->enemy, FLAG_GENERATOR) |
90 | && npc->enemy->type != PLAYER |
91 | && npc->enemy->type != PLAYER |
91 | && npc->enemy->type != GOLEM) |
92 | && npc->enemy->type != GOLEM) |
92 | npc->enemy = NULL; |
93 | npc->enemy = 0; |
93 | |
|
|
94 | } |
94 | } |
95 | |
95 | |
96 | return can_detect_enemy (npc, npc->enemy, rv) ? npc->enemy : NULL; |
96 | return can_detect_enemy (npc, npc->enemy, rv) ? npc->enemy : 0; |
97 | } |
97 | } |
98 | |
98 | |
99 | /* Returns the nearest living creature (monster or generator). |
99 | /* Returns the nearest living creature (monster or generator). |
100 | * Modified to deal with tiled maps properly. |
100 | * Modified to deal with tiled maps properly. |
101 | * Also fixed logic so that monsters in the lower directions were more |
101 | * Also fixed logic so that monsters in the lower directions were more |
… | |
… | |
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); |
… | |
… | |
704 | return 1; |
706 | return 1; |
705 | |
707 | |
706 | /* 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 |
707 | * 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 |
708 | */ |
710 | */ |
709 | for (more = ob2->more; more != NULL; more = more->more) |
711 | for (more = ob2->more; more; more = more->more) |
710 | { |
712 | { |
711 | get_rangevector (ob1, more, &rv1, 0); |
713 | get_rangevector (ob1, more, &rv1, 0); |
712 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
714 | if (abs (rv1.distance_x) < 2 && abs (rv1.distance_y) < 2) |
713 | return 1; |
715 | return 1; |
714 | } |
716 | } |
… | |
… | |
1195 | flag = 1; |
1197 | flag = 1; |
1196 | |
1198 | |
1197 | else |
1199 | else |
1198 | switch (item->type) |
1200 | switch (item->type) |
1199 | { |
1201 | { |
1200 | case MONEY: |
1202 | case MONEY: |
1201 | case GEM: |
1203 | case GEM: |
1202 | flag = monster->pick_up & 2; |
1204 | flag = monster->pick_up & 2; |
1203 | break; |
1205 | break; |
1204 | |
1206 | |
1205 | case FOOD: |
1207 | case FOOD: |
1206 | flag = monster->pick_up & 4; |
1208 | flag = monster->pick_up & 4; |
1207 | break; |
1209 | break; |
1208 | |
1210 | |
1209 | case WEAPON: |
1211 | case WEAPON: |
1210 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1212 | flag = (monster->pick_up & 8) || QUERY_FLAG (monster, FLAG_USE_WEAPON); |
1211 | break; |
1213 | break; |
1212 | |
1214 | |
1213 | case ARMOUR: |
1215 | case ARMOUR: |
1214 | case SHIELD: |
1216 | case SHIELD: |
1215 | case HELMET: |
1217 | case HELMET: |
1216 | case BOOTS: |
1218 | case BOOTS: |
1217 | case GLOVES: |
1219 | case GLOVES: |
1218 | case GIRDLE: |
1220 | case GIRDLE: |
1219 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1221 | flag = (monster->pick_up & 16) || QUERY_FLAG (monster, FLAG_USE_ARMOUR); |
1220 | break; |
1222 | break; |
1221 | |
1223 | |
1222 | case SKILL: |
1224 | case SKILL: |
1223 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1225 | flag = QUERY_FLAG (monster, FLAG_CAN_USE_SKILL); |
1224 | break; |
1226 | break; |
1225 | |
1227 | |
1226 | case RING: |
1228 | case RING: |
1227 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1229 | flag = QUERY_FLAG (monster, FLAG_USE_RING); |
1228 | break; |
1230 | break; |
1229 | |
1231 | |
1230 | case WAND: |
1232 | case WAND: |
1231 | case HORN: |
1233 | case HORN: |
1232 | case ROD: |
1234 | case ROD: |
1233 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1235 | flag = QUERY_FLAG (monster, FLAG_USE_RANGE); |
1234 | break; |
1236 | break; |
1235 | |
1237 | |
1236 | case SPELLBOOK: |
1238 | case SPELLBOOK: |
1237 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1239 | flag = monster->arch && QUERY_FLAG (monster->arch, FLAG_CAST_SPELL); |
1238 | break; |
1240 | break; |
1239 | |
1241 | |
1240 | case SCROLL: |
1242 | case SCROLL: |
1241 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1243 | flag = QUERY_FLAG (monster, FLAG_USE_SCROLL); |
1242 | break; |
1244 | break; |
1243 | |
1245 | |
1244 | case BOW: |
1246 | case BOW: |
1245 | case ARROW: |
1247 | case ARROW: |
1246 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1248 | flag = QUERY_FLAG (monster, FLAG_USE_BOW); |
1247 | break; |
1249 | break; |
1248 | } |
1250 | } |
1249 | |
1251 | |
1250 | /* 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 |
1251 | * 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 |
1252 | * use several locations. |
1254 | * use several locations. |
… | |
… | |
1280 | for (tmp = monster->below; tmp != NULL; tmp = next) |
1282 | for (tmp = monster->below; tmp != NULL; tmp = next) |
1281 | { |
1283 | { |
1282 | next = tmp->below; |
1284 | next = tmp->below; |
1283 | switch (tmp->type) |
1285 | switch (tmp->type) |
1284 | { |
1286 | { |
1285 | case CF_HANDLE: |
1287 | case T_HANDLE: |
1286 | case TRIGGER: |
1288 | case TRIGGER: |
1287 | if (monster->will_apply & 1) |
1289 | if (monster->will_apply & 1) |
1288 | manual_apply (monster, tmp, 0); |
1290 | manual_apply (monster, tmp, 0); |
1289 | break; |
1291 | break; |
1290 | |
1292 | |
… | |
… | |
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 |
1515 | * server should try to be resilant enough to avoid the problem |
1502 | * server should try to be resilant enough to avoid the problem |
1516 | */ |
1503 | */ |
1517 | 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) |
1518 | return absdir (dir + 4); |
1505 | return absdir (dir + 4); |
1519 | |
1506 | |
1520 | return dist_att (dir, ob, enemy, part, rv); |
1507 | return dist_att (dir, ob, enemy, part, rv); |
1521 | } |
1508 | } |
1522 | |
1509 | |
… | |
… | |
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!"); |