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

Method SetHideRoomGoal

scripts/AIGame3.cpp:5570–5606  ·  view source on GitHub ↗

Sets goal to go to the current wander room

Source from the content-addressed store, hash-verified

5568
5569// Sets goal to go to the current wander room
5570void AlienBoss::SetHideRoomGoal(int me) {
5571 vector pos, left_room_pos, right_room_pos, my_pos;
5572 int roomnum;
5573 float left_room_dist;
5574 float right_room_dist;
5575
5576 // Get current position
5577 Obj_Value(me, VF_GET, OBJV_V_POS, &my_pos);
5578
5579 // Get positions of hide rooms
5580 Room_Value(memory->left_hide_room, VF_GET, RMSV_V_PATH_PNT, &left_room_pos, 0);
5581 Room_Value(memory->right_hide_room, VF_GET, RMSV_V_PATH_PNT, &right_room_pos, 0);
5582
5583 // Get the distance to each hide room
5584 left_room_dist = vm_VectorDistance(&my_pos, &left_room_pos);
5585 right_room_dist = vm_VectorDistance(&my_pos, &right_room_pos);
5586
5587 // Determine the closest hide room, and go to it
5588 if (left_room_dist < right_room_dist) {
5589 roomnum = memory->left_hide_room;
5590 pos = left_room_pos;
5591 } else {
5592 roomnum = memory->right_hide_room;
5593 pos = right_room_pos;
5594 }
5595
5596 Room_Value(roomnum, VF_GET, RMSV_V_PATH_PNT, &pos, 0);
5597 AI_AddGoal(me, AIG_GET_TO_POS, 2, DEFAULT_INFLUENCE, AB_GUID_GOT_TO_HIDE_ROOM,
5598 GF_ORIENT_VELOCITY | GF_KEEP_AT_COMPLETION, &pos, roomnum);
5599
5600 // Save values for teleport
5601 memory->dest_pos = pos;
5602 memory->dest_room = roomnum;
5603
5604 float dist = 30.0f;
5605 AI_GoalValue(me, 2, VF_SET, AIGV_F_CIRCLE_DIST, &dist);
5606}
5607
5608// Returns the index of the wander room closest to current position
5609int AlienBoss::DetermineClosestRoom(int me) {

Callers

nothing calls this directly

Calls 4

Obj_ValueFunction · 0.85
Room_ValueFunction · 0.85
AI_GoalValueFunction · 0.85
vm_VectorDistanceFunction · 0.70

Tested by

no test coverage detected