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

Method DoSquadieFrame

scripts/AIGame.cpp:9434–9487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9432}
9433
9434void MantaRay::DoSquadieFrame(int me) {
9435 int type;
9436 Obj_Value(memory->leader_handle, VF_GET, OBJV_I_TYPE, &type);
9437
9438 // Check if the leader is still alive
9439 if (type == OBJ_NONE) {
9440 // Reset the speed
9441 AI_Value(me, VF_SET, AIV_F_MAX_SPEED, &memory->base_speed);
9442
9443 memory->flags = 0;
9444 memory->leader_handle = OBJECT_HANDLE_NONE;
9445
9446 SetMode(me, MRM_NORMAL);
9447 return;
9448 }
9449
9450 // The leader is alive; so, get my new goal pos
9451 SendCommand(me, memory->leader_handle, MRC_GET_GOAL_POS, &memory->goal_pos);
9452 AI_GoalValue(me, 2, VF_SET, AIGV_V_POS, &memory->goal_pos);
9453 SendCommand(me, memory->leader_handle, MRC_GET_GOAL_ROOM, &memory->goal_room);
9454 AI_GoalValue(me, 2, VF_SET, AIGV_I_ROOMNUM, &memory->goal_room);
9455
9456 AI_AddGoal(me, AIG_GET_TO_POS, 2, 1.0f, -1, GF_ORIENT_VELOCITY | GF_KEEP_AT_COMPLETION, &memory->goal_pos,
9457 memory->goal_room);
9458 float cd = .1f;
9459 AI_GoalValue(me, 2, VF_SET, AIGV_F_CIRCLE_DIST, &cd);
9460
9461 vector my_pos;
9462 Obj_Value(me, VF_GET, OBJV_V_POS, &my_pos);
9463
9464 float dist = vm_VectorDistance(&my_pos, &memory->goal_pos);
9465
9466 if (dist <= MRO_CATCHUP_DIST) {
9467 float catchup_speed;
9468 AI_Value(memory->leader_handle, VF_GET, AIV_F_MAX_SPEED, &catchup_speed);
9469
9470 float scaled_speed = dist / MRO_CATCHUP_DIST * 0.23f * catchup_speed;
9471 catchup_speed += scaled_speed;
9472
9473 AI_Value(me, VF_SET, AIV_F_MAX_SPEED, &catchup_speed);
9474 } else if (dist > MRO_CATCHUP_DIST) {
9475 float catchup_speed;
9476 AI_Value(memory->leader_handle, VF_GET, AIV_F_MAX_SPEED, &catchup_speed);
9477
9478 float scaled_speed = 0.23f * catchup_speed;
9479 catchup_speed += scaled_speed;
9480
9481 AI_Value(me, VF_SET, AIV_F_MAX_SPEED, &catchup_speed);
9482 }
9483
9484 // Get the leaders mode
9485
9486 // Set my mode to the leaders mode... (Modes account for flags)
9487}
9488
9489void MantaRay::DoFrame(int me) {
9490 float last_see_target_time;

Callers

nothing calls this directly

Calls 4

Obj_ValueFunction · 0.85
SendCommandFunction · 0.85
AI_GoalValueFunction · 0.85
vm_VectorDistanceFunction · 0.70

Tested by

no test coverage detected