ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/monster.C
(Generate patch)

Comparing deliantra/server/server/monster.C (file contents):
Revision 1.64 by root, Fri Sep 25 18:13:02 2009 UTC vs.
Revision 1.65 by root, Fri Sep 25 18:44:58 2009 UTC

1420} 1420}
1421 1421
1422void 1422void
1423npc_call_help (object *op) 1423npc_call_help (object *op)
1424{ 1424{
1425 int x, y, mflags; 1425 unordered_mapwalk (op, -7, -7, 7, 7)
1426 object *npc;
1427 sint16 sx, sy;
1428 maptile *m;
1429
1430 for (x = -3; x < 4; x++)
1431 for (y = -3; y < 4; y++)
1432 { 1426 {
1433 m = op->map; 1427 mapspace &ms = m->at (nx, ny);
1434 sx = op->x + x; 1428
1435 sy = op->y + y;
1436 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
1437 /* 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. */
1438 if ((mflags & P_OUT_OF_MAP) || !(mflags & P_IS_ALIVE)) 1430 if (!(ms.flags () & P_IS_ALIVE))
1439 continue; 1431 continue;
1440 1432
1441 for (npc = GET_MAP_OB (m, sx, sy); npc != NULL; npc = npc->above) 1433 for (object *npc = ms.bot; npc; npc = npc->above)
1442 if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE)) 1434 if (QUERY_FLAG (npc, FLAG_ALIVE) && QUERY_FLAG (npc, FLAG_UNAGGRESSIVE))
1443 npc->enemy = op->enemy; 1435 npc->enemy = op->enemy;
1444 } 1436 }
1445} 1437}
1446 1438
1447int 1439int
1448dist_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) 1440dist_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
1449{ 1441{
1450 if (can_hit (part, enemy, rv)) 1442 if (can_hit (part, enemy, rv))
1451 return dir; 1443 return dir;
1452 1444
1453 if (rv->distance < 10) 1445 if (rv->distance < 10)
1457 1449
1458 return 0; 1450 return 0;
1459} 1451}
1460 1452
1461int 1453int
1462run_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) 1454run_att (int dir, object *ob, object *enemy, object *part, rv_vector *rv)
1463{ 1455{
1464 if ((can_hit (part, enemy, rv) && ob->move_status < 20) || ob->move_status < 20) 1456 if (can_hit (part, enemy, rv))
1465 {
1466 ob->move_status++;
1467 return (dir); 1457 return dir;
1468 } 1458 else
1469 else if (ob->move_status > 20)
1470 ob->move_status = 0;
1471
1472 return absdir (dir + 4); 1459 return absdir (dir + 4);
1473} 1460}
1474 1461
1475int 1462int
1476hitrun_att (int dir, object *ob, object *enemy) 1463hitrun_att (int dir, object *ob, object *enemy)
1477{ 1464{
1486} 1473}
1487 1474
1488int 1475int
1489wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) 1476wait_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv)
1490{ 1477{
1491
1492 int inrange = can_hit (part, enemy, rv); 1478 int inrange = can_hit (part, enemy, rv);
1493 1479
1494 if (ob->move_status || inrange) 1480 if (ob->move_status || inrange)
1495 ob->move_status++; 1481 ob->move_status++;
1496 1482
1506} 1492}
1507 1493
1508int 1494int
1509disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv) 1495disthit_att (int dir, object *ob, object *enemy, object *part, rv_vector * rv)
1510{ 1496{
1511
1512 /* The logic below here looked plain wrong before. Basically, what should 1497 /* The logic below here looked plain wrong before. Basically, what should
1513 * 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,
1514 * the creature should run away (dir+4) 1499 * the creature should run away (dir+4)
1515 * 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
1516 * 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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines