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

Method CreateUnit

engine/Poseidon/AI/AICenterImpl.cpp:1521–1729  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1519 AIUnitInfo& info = soldier->GetInfo();
1520 info._rank = (Rank)rank;
1521 info._initExperience = info._experience = ExpForRank((Rank)rank);
1522 return unit;
1523}
1524
1525AIUnit* AICenter::CreateUnit(const ArcadeUnitInfo& info, ArcadeTemplate& t, bool multiplayer, AIGroup* grp,
1526 bool disableC, bool disableD, bool disableG)
1527{
1528 if (info.player == APNonplayable)
1529 {
1530 if (GRandGen.RandomValue() > info.presence)
1531 {
1532 return nullptr;
1533 }
1534 if (!GWorld->GetGameState()->EvaluateBool(info.presenceCondition))
1535 {
1536 return nullptr;
1537 }
1538 }
1539
1540 const char* nameSide = nullptr;
1541 switch (_side)
1542 {
1543 case TEast:
1544 nameSide = "East";
1545 break;
1546 case TWest:
1547 nameSide = "West";
1548 break;
1549 case TGuerrila:
1550 case TCivilian:
1551 case TLogic:
1552 nameSide = "Guerrila";
1553 break;
1554 default:
1555 Fail("No such side");
1556 return nullptr;
1557 }
1558 AI_ERROR(nameSide);
1559 const ParamEntry& cfgSide = Pars >> "CfgWorlds" >> nameSide;
1560
1561 Ref<EntityAI> veh = CreateVehicle(info, t, _side, multiplayer, disableC, disableD, disableG);
1562 if (!veh)
1563 {
1564 return nullptr;
1565 }
1566
1567 AI_ERROR(veh->RefCounter() > 1);
1568
1569 Person* soldier = dyn_cast<Person>(veh.GetRef());
1570 if (soldier)
1571 {
1572 if (info.special == ASpCargo)
1573 {
1574 for (int u = 0; u < MAX_UNITS_PER_GROUP; u++)
1575 {
1576 AIUnit* unit = grp->_units[u];
1577 if (!unit || !unit->IsUnit())
1578 {

Callers

nothing calls this directly

Calls 15

CreateVehicleFunction · 0.85
GameValueExtClass · 0.85
saturateFunction · 0.85
EvaluateBoolMethod · 0.80
IsUnitMethod · 0.80
GetVehicleInMethod · 0.80
GetFreeManCargoMethod · 0.80
GetInCargoMethod · 0.80
BrainMethod · 0.80
AssignAsCargoMethod · 0.80
OrderGetInMethod · 0.80
AddSensorMethod · 0.80

Tested by

no test coverage detected