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

Method EvaluateObjectWithMask

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

Source from the content-addressed store, hash-verified

631}
632
633bool ScriptExt::EvaluateObjectWithMask(TechnoClass* pTechno, int mask, int attackAITargetType, int idxAITargetTypeItem, TechnoClass* pTeamLeader)
634{
635 const auto pTechnoType = pTechno->GetTechnoType();
636
637 // Special case: validate target if is part of a technos list in [AITargetTypes] section
638 if (attackAITargetType >= 0)
639 {
640 const auto& lists = RulesExt::Global()->AITargetTypesLists;
641
642 if (lists.size() > static_cast<size_t>(attackAITargetType))
643 {
644 for (const auto& item : lists[attackAITargetType])
645 {
646 if (pTechnoType == item)
647 return true;
648 }
649
650 return false;
651 }
652 }
653
654 switch (mask)
655 {
656 case 1:
657 // Anything ;-)
658
659 if (!pTechno->Owner->IsNeutral())
660 return true;
661
662 break;
663
664 case 2:
665 // Building
666
667 if (!pTechno->Owner->IsNeutral())
668 {
669 if (const auto pBuildingType = abstract_cast<BuildingTypeClass*, true>(pTechnoType))
670 {
671 if (!pBuildingType->IsVehicle())
672 return true;
673 }
674 }
675
676 break;
677
678 case 3:
679 // Harvester
680
681 if (!pTechno->Owner->IsNeutral())
682 {
683 switch (pTechno->WhatAmI())
684 {
685 case AbstractType::Unit:
686
687 if (static_cast<UnitTypeClass*>(pTechnoType)->Harvester)
688 return true;
689
690 // No break

Callers

nothing calls this directly

Calls 4

GetTechnoTypeMethod · 0.80
issetMethod · 0.80
sizeMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected