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

Function VehFollow

engine/Poseidon/Game/Commands/GameStateExtGrp.cpp:1239–1282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1237DEFINE_COMMAND_S(Stop)
1238
1239GameValue VehFollow(const GameState* state, GameValuePar oper1, GameValuePar oper2, bool silent)
1240{
1241 PackedBoolArray list;
1242 AIGroup* grp = GetUnits(state, oper1, list);
1243 if (!grp)
1244 {
1245 return NOTHING;
1246 }
1247 Vector3 pos;
1248 Object* obj = GetObject(oper2);
1249 EntityAI* veh = dyn_cast<EntityAI>(obj);
1250 if (!veh)
1251 {
1252 return NOTHING;
1253 }
1254 AIUnit* follow = veh->CommanderUnit();
1255 if (!follow)
1256 {
1257 LOG_DEBUG(Script, "Cannot follow empty vehicle");
1258 return NOTHING;
1259 }
1260 if (follow->GetGroup() != grp)
1261 {
1262 LOG_DEBUG(Script, "Cannot follow unit from other group");
1263 return NOTHING;
1264 }
1265 Command cmd;
1266 cmd._message = Command::Join;
1267 cmd._destination = VZero;
1268 cmd._discretion = Command::Undefined;
1269 cmd._context = Command::CtxMission;
1270 cmd._joinToSubgroup = follow->GetSubgroup();
1271 if (silent)
1272 {
1273 cmd._id = grp->GetNextCmdId();
1274 grp->IssueCommand(cmd, list);
1275 }
1276 else
1277 {
1278 grp->SendCommand(cmd, list);
1279 }
1280
1281 return NOTHING;
1282}
1283
1284DEFINE_COMMAND(Follow)
1285

Callers

nothing calls this directly

Calls 8

GetUnitsFunction · 0.85
GetNextCmdIdMethod · 0.80
SendCommandMethod · 0.80
GetObjectFunction · 0.70
CommanderUnitMethod · 0.45
GetGroupMethod · 0.45
GetSubgroupMethod · 0.45
IssueCommandMethod · 0.45

Tested by

no test coverage detected