MCPcopy Create free account
hub / github.com/bwapi/bwapi / DoUnitBehaviour

Method DoUnitBehaviour

bwapi/BWScriptEmulator/ComputerAI.cpp:70–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70bool UnitWrap::DoUnitBehaviour()
71{
72 DecloakCheck();
73
74 UnitType t = pUnit->getType();
75 switch ( t )
76 {
77 case UnitTypes::Enum::Protoss_Carrier:
78 case UnitTypes::Enum::Protoss_Reaver:
79 // @TODO: Check AI reserves
80 pUnit->train();
81 return false;
82 case UnitTypes::Enum::Terran_Dropship:
83 if ( pUnit->getHitPoints() < t.maxHitPoints() ) //&& AssignRepairSCV(pUnit) )
84 {
85 Unit pSCV = nullptr;//AssignRepairSCV(pUnit);
86 if ( pSCV ) // do unload, then follow SCV
87 {
88 if ( pUnit->getLoadedUnits().empty() )
89 return pUnit->follow(pSCV);
90 else
91 return pUnit->unloadAll();
92 }
93 }
94 // do what protoss shuttle does after:
95 case UnitTypes::Enum::Protoss_Shuttle:
96 //if ( AI_TranpoerAction(pUnit) )
97 // return true;
98 if ( pUnit->getLoadedUnits().empty() )
99 return false;
100 return pUnit->unloadAll();
101 case UnitTypes::Enum::Zerg_Overlord:
102 if ( pUnit->getLoadedUnits().empty() )
103 return false;
104 return pUnit->unloadAll();
105 case UnitTypes::Enum::Terran_Vulture:
106 return false;//pUnit->useTech(TechTypes::Spider_Mines, GetSpiderMineLocation(pUnit));
107 case UnitTypes::Enum::Terran_Siege_Tank_Tank_Mode:
108 if ( this->GetControlType() == ControlTypes::Guard && pUnit->isIdle() ) // && !AI_Guard_AttackTarget_Proc(unit, 0)
109 return pUnit->siege();
110 return false;
111 case UnitTypes::Enum::Protoss_Shield_Battery:
112 if ( pUnit->getEnergy() >= 50 )
113 {
114 Unitset myUnits(Broodwar->self()->getUnits());
115 for ( auto i = myUnits.begin(); i != myUnits.end(); ++i )
116 {
117
118 // @TODO
119 // if ( i can recharge, not attacking, shields > 40 )
120 // recharge the unit
121 }
122 }
123 return false;
124 case UnitTypes::Enum::Protoss_Arbiter:
125 // Should be "AIOrderTargetUnit" or autotarget
126 Unit pBest = pUnit->getClosestUnit(GetPlayer == Broodwar->self() && !IsBuilding && OrderTarget != nullptr, 640);
127 if ( pBest != nullptr )

Callers

nothing calls this directly

Calls 15

GetControlTypeMethod · 0.95
getHitPointsMethod · 0.80
maxHitPointsMethod · 0.80
isIdleMethod · 0.80
getEnergyMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
getTypeMethod · 0.45
trainMethod · 0.45
getLoadedUnitsMethod · 0.45
followMethod · 0.45
unloadAllMethod · 0.45

Tested by

no test coverage detected