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

Function ArcadeGetInGetIn

engine/Poseidon/AI/AIArcade.cpp:1641–1715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1639}
1640
1641static void ArcadeGetInGetIn(AIGroupContext* context)
1642{
1643 STATE_PREFIX
1644 int& index = context->_fsm->Var(0);
1645
1646 Transport* veh = dyn_cast<Transport>(FindTargetVehicle(group, index));
1647 mission->_target = veh;
1648
1649 AIUnit* leader = group->Leader();
1650 AI_ERROR(leader);
1651 if (veh)
1652 {
1653 if (group->IsPlayerGroup())
1654 {
1655 veh->WaitForGetIn(leader);
1656 }
1657 else if (veh->GetDriverAssigned())
1658 {
1659 // assign all members to cargo
1660 if (veh->GetDriverAssigned() != leader)
1661 {
1662 if (leader->AssignAsCargo(veh))
1663 {
1664 for (int i = 0; i < MAX_UNITS_PER_GROUP; i++)
1665 {
1666 AIUnit* unit = group->UnitWithID(i + 1);
1667 if (!unit || unit == leader)
1668 {
1669 continue;
1670 }
1671 if (unit->VehicleAssigned() == veh)
1672 {
1673 continue;
1674 }
1675 if (!unit->AssignAsCargo(veh))
1676 {
1677 break;
1678 }
1679 }
1680 }
1681 else
1682 {
1683 // nothing to do
1684 }
1685 }
1686 }
1687 else
1688 {
1689 if (!veh->GetGroupAssigned() && group->NVehicles() <= 0 && !leader->VehicleAssigned())
1690 {
1691 // specific case - 1st vehicle of the group
1692 // force leader to that vehicle, but not to any specific position?
1693 group->AddVehicle(veh);
1694 }
1695 else
1696 {
1697 AI_ERROR(!veh->QIsDriverIn());
1698 leader->AssignAsDriver(veh);

Callers

nothing calls this directly

Calls 15

FindTargetVehicleFunction · 0.85
VarMethod · 0.80
IsPlayerGroupMethod · 0.80
WaitForGetInMethod · 0.80
GetDriverAssignedMethod · 0.80
AssignAsCargoMethod · 0.80
UnitWithIDMethod · 0.80
VehicleAssignedMethod · 0.80
GetGroupAssignedMethod · 0.80
QIsDriverInMethod · 0.80
AssignAsDriverMethod · 0.80
AssignVehiclesMethod · 0.80

Tested by

no test coverage detected