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

Method RunComputerAI

bwapi/BWScriptEmulator/ComputerAI.cpp:4–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "Controller.h"
3
4void UnitWrap::RunComputerAI()
5{
6 // Run this order on a timer
7 if ( GetOrderTimer() > 0 )
8 return;
9 SetOrderTimer(15);
10
11 // Perform generic unit behaviour
12 if ( DoUnitBehaviour() )
13 return;
14
15 // Run AIController type-specific stuff
16 PerformSpecializedUnitControl();
17
18 // Localize unit type
19 UnitType t = pUnit->getType();
20
21 // Check if this (building) needs to be repaired
22 if ( (GetRace == Races::Terran && IsMechanical && HP_Percent != 100 && IsBuilding && !IsPlagued && !IsIrradiated && !IsWorker)(pUnit)
23 && !IsMilitaryCaptain() )
24 {
25 // Do repair check/assign here
26 }
27 else if ( t == UnitTypes::Terran_Siege_Tank_Tank_Mode ) // Siege Tank special
28 {
29 if ( !MainController.IsCampaign() && pUnit->isIdle() )
30 pUnit->siege();
31 }
32 else if ( t.isBurrowable() ) // Burrowable unit control
33 {
34 if ( !pUnit->isBurrowed() && t != UnitTypes::Zerg_Drone && pUnit->isIdle() )
35 pUnit->burrow();
36 }
37 else if ( t == UnitTypes::Terran_Medic ) // Medic special
38 {
39 if ( !HasNoCaptain() )
40 SetVirtualUnitOrder(Orders::Enum::Medic);
41 //else
42 // Do independant AI Transport stuff
43 }
44}
45
46void UnitWrap::DecloakCheck()
47{

Callers

nothing calls this directly

Calls 7

IsCampaignMethod · 0.80
isIdleMethod · 0.80
isBurrowableMethod · 0.80
isBurrowedMethod · 0.80
getTypeMethod · 0.45
siegeMethod · 0.45
burrowMethod · 0.45

Tested by

no test coverage detected