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

Method WaitUntilFullAmmoAction

src/Ext/Script/Body.cpp:327–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327void ScriptExt::WaitUntilFullAmmoAction(TeamClass* pTeam)
328{
329 for (auto pUnit = pTeam->FirstUnit; pUnit; pUnit = pUnit->NextTeamMember)
330 {
331 if (!pUnit->InLimbo && pUnit->Health > 0)
332 {
333 auto const pUnitType = pUnit->GetTechnoType();
334
335 if (pUnitType->Ammo > 0 && pUnit->Ammo < pUnitType->Ammo)
336 {
337 // If an aircraft object have AirportBound it must be evaluated
338 if (auto const pAircraft = abstract_cast<AircraftClass*>(pUnit))
339 {
340 if (pAircraft->Type->AirportBound)
341 {
342 // Reset last target, at long term battles this prevented the aircraft to pick a new target (rare vanilla YR bug)
343 pUnit->SetTarget(nullptr);
344 pUnit->LastTarget = nullptr;
345 // Fix YR bug (when returns from the last attack the aircraft switch in loop between Mission::Enter & Mission::Guard, making it impossible to land in the dock)
346 if (pUnit->IsInAir() && pUnit->CurrentMission != Mission::Enter)
347 pUnit->QueueMission(Mission::Enter, true);
348
349 return;
350 }
351 }
352 else if (pUnitType->Reload != 0) // Don't skip units that can reload themselves
353 return;
354 }
355 }
356 }
357
358 pTeam->StepCompleted = true;
359}
360
361void ScriptExt::Mission_Gather_NearTheLeader(TeamClass* pTeam, int countdown)
362{

Callers

nothing calls this directly

Calls 1

GetTechnoTypeMethod · 0.80

Tested by

no test coverage detected