MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FormationPilot

Method FormationPilot

engine/Poseidon/AI/VehicleAIPilot.cpp:618–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616}
617
618void EntityAI::FormationPilot(float& speedWanted, float& headChange, float& turnPredict)
619{
620 if (_userStopped)
621 {
622 speedWanted = 0;
623 headChange = 0;
624 turnPredict = 0;
625 return;
626 }
627
628 // predict leader position
629 AIUnit* unit = PilotUnit();
630 if (!unit)
631 {
632 return;
633 }
634 AIUnit* commander = CommanderUnit();
635 if (!commander)
636 {
637 return;
638 }
639 if (unit->GetAIDisabled() & AIUnit::DAMove)
640 {
641 return;
642 }
643
644 AISubgroup* subgrp = commander->GetSubgroup();
645 AI_ERROR(subgrp);
646 if (!subgrp)
647 {
648 return;
649 }
650
651 AIGroup* grp = commander->GetGroup();
652 AI_ERROR(grp);
653 if (!grp)
654 {
655 return;
656 }
657
658 AIUnit* leader = subgrp->Leader();
659 AI_ERROR(leader);
660 if (!leader)
661 {
662 return;
663 }
664
665 EntityAI* lVehicle = leader->GetVehicle();
666
667 // check if leader is on road
668 bool onRoad = false;
669 if (!IsCautious())
670 {
671 onRoad = lVehicle->IsOnRoad();
672
673 // use follow mode - ignore formation
674
675 // special case - leader on road

Callers

nothing calls this directly

Calls 15

fabsFunction · 0.85
saturateFunction · 0.85
floatMaxFunction · 0.85
saturateMinFunction · 0.85
GetCombatHeightFunction · 0.85
ColorClass · 0.85
floatMinFunction · 0.85
GetAIDisabledMethod · 0.80
GetFormationPreviousMethod · 0.80
PositionModelToWorldMethod · 0.80
GetOnRoadMethod · 0.80
CostAtPosMethod · 0.80

Tested by

no test coverage detected