MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DetermineClosestRoom

Method DetermineClosestRoom

scripts/AIGame3.cpp:5609–5637  ·  view source on GitHub ↗

Returns the index of the wander room closest to current position

Source from the content-addressed store, hash-verified

5607
5608// Returns the index of the wander room closest to current position
5609int AlienBoss::DetermineClosestRoom(int me) {
5610 int j, closest_room;
5611 float closest_dist, dist;
5612 vector my_pos, room_pos;
5613
5614 // Get current position
5615 Obj_Value(me, VF_GET, OBJV_V_POS, &my_pos);
5616
5617 // Find the room closest to
5618 closest_room = 0;
5619 closest_dist = 10000;
5620 for (j = 0; j < AB_NUM_WANDER_ROOMS; j++) {
5621 // Get room's position
5622 Room_Value(memory->wander_rooms[j], VF_GET, RMSV_V_PATH_PNT, &room_pos, 0);
5623
5624 // Get the distance to this room
5625 dist = vm_VectorDistanceQuick(&my_pos, &room_pos);
5626
5627 // See if this room is closer than the currently closest room
5628 if (dist < closest_dist) {
5629 closest_room = j;
5630 closest_dist = dist;
5631 }
5632 }
5633
5634 mprintf(0, "Alien Boss - Determined closest wander room: %d\n", closest_room);
5635
5636 return closest_room;
5637}
5638
5639// Returns any current animations to alert
5640void AlienBoss::AbortCurrentMode(int me) {

Callers

nothing calls this directly

Calls 3

Obj_ValueFunction · 0.85
Room_ValueFunction · 0.85
vm_VectorDistanceQuickFunction · 0.70

Tested by

no test coverage detected