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

Method ChronoshiftTeamToTarget

src/Ext/Script/Body.cpp:1162–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160}
1161
1162void ScriptExt::ChronoshiftTeamToTarget(TeamClass* pTeam, TechnoClass* pTeamLeader, AbstractClass* pTarget)
1163{
1164 auto pScript = pTeam->CurrentScript;
1165 HouseClass* pOwner = pTeamLeader->Owner;
1166 SuperClass* pSuperCSphere = nullptr;
1167 SuperClass* pSuperCWarp = nullptr;
1168
1169 HouseExt::GetAIChronoshiftSupers(pOwner, pSuperCSphere, pSuperCWarp);
1170
1171 char logTextBase[1024];
1172 char logTextJump[1024];
1173 char jump[256];
1174
1175 sprintf_s(jump, "Jump to next line: %d = %d,%d -> (Reason: %s)", pScript->CurrentMission + 1, pScript->Type->ScriptActions[pScript->CurrentMission + 1].Action, pScript->Type->ScriptActions[pScript->CurrentMission + 1].Argument, "%s");
1176 sprintf_s(logTextBase, "AI Scripts - ChronoshiftTeamToTarget: [%s] [%s] (line: %d = %d,%d) %s\n", pTeam->Type->ID, pScript->Type->ID, pScript->CurrentMission, pScript->Type->ScriptActions[pScript->CurrentMission].Action, pScript->Type->ScriptActions[pScript->CurrentMission].Argument, "%s");
1177 sprintf_s(logTextJump, logTextBase, jump);
1178
1179 if (!pSuperCSphere || !pSuperCWarp)
1180 {
1181 ScriptExt::Log(logTextJump, "No ChronoSphere or ChronoWarp superweapon found");
1182 pTeam->StepCompleted = true;
1183 return;
1184 }
1185
1186 if (!pSuperCSphere->IsReady || (pSuperCSphere->IsPowered() && !pOwner->Is_Powered()))
1187 {
1188 if (pSuperCSphere->IsPresent && 1.0 - RulesClass::Instance->AIMinorSuperReadyPercent < pSuperCSphere->RechargeTimer.GetTimeLeft() / pSuperCSphere->GetRechargeTime())
1189 {
1190 ScriptExt::Log(logTextBase, "ChronoSphere superweapon [%s] charge not at AIMinorSuperReadyPercent yet, not jumping to next line yet", pSuperCSphere->Type->get_ID());
1191 return;
1192 }
1193 else
1194 {
1195 ScriptExt::Log(logTextJump, "ChronoSphere superweapon [%s] is not available", pSuperCSphere->Type->get_ID());
1196 pTeam->StepCompleted = true;
1197 return;
1198 }
1199 }
1200
1201 auto pTargetCell = MapClass::Instance.TryGetCellAt(pTarget->GetCoords());
1202
1203 if (pTargetCell)
1204 {
1205 pOwner->Fire_SW(pSuperCSphere->Type->ArrayIndex, pTeam->SpawnCell->MapCoords);
1206 pOwner->Fire_SW(pSuperCWarp->Type->ArrayIndex, pTargetCell->MapCoords);
1207 pTeam->AssignMissionTarget(pTargetCell);
1208 ScriptExt::Log(logTextJump, "Finished successfully");
1209 }
1210 else
1211 {
1212 ScriptExt::Log(logTextJump, "No target cell found");
1213 }
1214
1215 pTeam->StepCompleted = true;
1216 return;
1217}
1218
1219bool ScriptExt::ScriptExt::IsUnitAvailable(TechnoClass* pTechno, bool checkIfInTransportOrAbsorbed)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected