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

Method SendTarget

engine/Poseidon/AI/AIGroupCmd.cpp:861–996  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859}
860
861void AIGroup::SendTarget(Target* target, bool engage, bool fire, PackedBoolArray list, bool silent)
862{
863 AIUnit* leader = Leader();
864 if (!leader)
865 {
866 return;
867 }
868
869 for (int i = 0; i < MAX_UNITS_PER_GROUP; i++)
870 {
871 if (!list.Get(i))
872 {
873 continue;
874 }
875 AIUnit* unit = UnitWithID(i + 1);
876 if (!unit)
877 {
878 list.Set(i, false);
879 continue;
880 }
881
882 if (target)
883 {
884 EntityAI* tgtAI = target->idExact;
885 if (tgtAI == unit->GetVehicleIn() || tgtAI == unit->GetPerson())
886 {
887 // unit cannot target itself
888 list.Set(i, false);
889 continue;
890 }
891 }
892
893 // check if unit is already doing what we tell it
894 if (TargetSent(unit) == target && (!fire || target == FireSent(unit)) &&
895 (!engage || target == EngageSent(unit)))
896 {
897 list.Set(i, false);
898 continue;
899 }
900 if (unit == leader || silent)
901 {
902 // leader - direct processing
903 if (!target)
904 {
905 target = unit->GetTargetAssigned();
906 }
907 else
908 {
909 unit->AssignTarget(target);
910 }
911 if (target)
912 {
913 if (fire)
914 {
915 unit->EnableFireTarget(target);
916 }
917 if (engage)
918 {

Callers 5

ArcadeDestroyAttackFunction · 0.45
ProcessMenuMethod · 0.45
IssueWatchTargetMethod · 0.45
SimulateHUDMethod · 0.45
VehTargetFunction · 0.45

Calls 15

GetCenterFunction · 0.85
GetVehicleInMethod · 0.80
GetPersonMethod · 0.80
GetTargetAssignedMethod · 0.80
AssignTargetMethod · 0.80
EnableFireTargetMethod · 0.80
EngageTargetMethod · 0.80
DeleteToMethod · 0.80
IsOnlyToMethod · 0.80
SetFireMethod · 0.80
SetEngageMethod · 0.80
GetEngageMethod · 0.80

Tested by

no test coverage detected