MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / Mission_Attack

Method Mission_Attack

src/Ext/Script/Mission.Attack.cpp:10–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8// Contains ScriptExt::Mission_Attack and its helper functions.
9
10void ScriptExt::Mission_Attack(TeamClass* pTeam, int calcThreatMode, bool repeatAction, int attackAITargetType, int idxAITargetTypeItem)
11{
12 bool noWaitLoop = false;
13 bool bAircraftsWithoutAmmo = false;
14 bool agentMode = false;
15 bool pacifistTeam = true;
16 const auto pTeamData = TeamExt::ExtMap.Find(pTeam);
17
18 // When the new target wasn't found it sleeps some few frames before the new attempt. This can save cycles and cycles of unnecessary executed lines.
19 if (pTeamData->WaitNoTargetCounter > 0)
20 {
21 if (pTeamData->WaitNoTargetTimer.InProgress())
22 return;
23
24 pTeamData->WaitNoTargetTimer.Stop();
25 noWaitLoop = true;
26 pTeamData->WaitNoTargetCounter = 0;
27
28 if (pTeamData->WaitNoTargetAttempts > 0)
29 pTeamData->WaitNoTargetAttempts--;
30 }
31
32 auto pFocus = abstract_cast<TechnoClass*>(pTeam->Focus);
33
34 if (!ScriptExt::IsUnitAvailable(pFocus, true))
35 {
36 pTeam->Focus = nullptr;
37 pFocus = nullptr;
38 }
39
40 const auto pScript = pTeam->CurrentScript;
41 const auto pScriptType = pScript->Type;
42
43 for (auto pFoot = pTeam->FirstUnit; pFoot; pFoot = pFoot->NextTeamMember)
44 {
45 auto pKillerTechnoData = TechnoExt::ExtMap.Find(pFoot);
46
47 if (pKillerTechnoData->LastKillWasTeamTarget)
48 {
49 // Time for Team award check! (if set any)
50 if (pTeamData->NextSuccessWeightAward > 0)
51 {
52 ScriptExt::IncreaseCurrentTriggerWeight(pTeam, false, pTeamData->NextSuccessWeightAward);
53 pTeamData->NextSuccessWeightAward = 0;
54 }
55
56 // Let's clean the Killer mess
57 pKillerTechnoData->LastKillWasTeamTarget = false;
58 pFocus = nullptr;
59 pTeam->Focus = nullptr;
60
61 if (!repeatAction)
62 {
63 // If the previous Team's Target was killed by this Team Member and the script was a 1-time-use then this script action must be finished.
64 for (auto pFootTeam = pTeam->FirstUnit; pFootTeam; pFootTeam = pFootTeam->NextTeamMember)
65 {
66 // Let's reset all Team Members objective
67 auto pKillerTeamUnitData = TechnoExt::ExtMap.Find(pFootTeam);

Callers

nothing calls this directly

Calls 2

GetTechnoTypeMethod · 0.80
FindMethod · 0.45

Tested by

no test coverage detected