| 616 | } |
| 617 | |
| 618 | void 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 |
nothing calls this directly
no test coverage detected