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

Method execute

bwapi/BWScriptEmulator/Rush.cpp:39–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39bool Rush::execute(aithread &thread) const
40{
41 // Retrieve parameters
42 BYTE bRushCategory;
43 WORD wOffset;
44 thread.readTuple( std::tie(bRushCategory, wOffset) );
45
46 // Debug
47 thread.saveDebug(Text::Yellow, this->getOpcode(), "%u p_%04X", bRushCategory, wOffset);
48 bool isRushed = false;
49
50 // Get closest enemy owner
51 Unit pClosest = Broodwar->getClosestUnit(thread.getLocation().center(), IsEnemy && (!IsBuilding || IsLifted) );
52 Player closestEnemy = pClosest ? pClosest->getPlayer() : nullptr;
53 if ( !closestEnemy ) return true;
54
55 // Check rush categories
56 switch ( bRushCategory )
57 {
58 case 0:
59 if ( closestEnemy->allUnitCount(UnitTypes::Terran_Barracks) ||
60 closestEnemy->allUnitCount(UnitTypes::Protoss_Gateway) ||
61 closestEnemy->allUnitCount(UnitTypes::Zerg_Spawning_Pool) )
62 isRushed = true;
63 break;
64 case 1:
65 if ( GetTerranRushScore(closestEnemy) > 16 ||
66 GetZergGroundRushScore(closestEnemy) > 10 ||
67 closestEnemy->completedUnitCount(UnitTypes::Protoss_Zealot) > 6 )
68 isRushed = true;
69 break;
70 case 2:
71 if ( GetTerranRushScore(closestEnemy) > 24 ||
72 GetZergAirRushScore(closestEnemy) > 10 )
73 isRushed = true;
74 break;
75 case 3:
76 if ( GetTerranRushScore(closestEnemy) > 5 ||
77 closestEnemy->completedUnitCount(UnitTypes::Zerg_Hydralisk_Den) ||
78 GetZergGroundRushScore(closestEnemy) > 2 ||
79 closestEnemy->completedUnitCount(UnitTypes::Protoss_Zealot) > 1 )
80 isRushed = true;
81 break;
82 case 4:
83 if ( GetTerranRushScore(closestEnemy) > 16 ||
84 GetZergGroundRushScore(closestEnemy) > 10 ||
85 closestEnemy->completedUnitCount(UnitTypes::Protoss_Zealot) > 8 )
86 isRushed = true;
87 break;
88 case 5:
89 if ( GetTerranRushScore(closestEnemy) > 6 ||
90 GetZergGroundRushScore(closestEnemy) > 6 ||
91 closestEnemy->completedUnitCount(UnitTypes::Protoss_Zealot) > 3 )
92 isRushed = true;
93 break;
94 case 6:
95 if ( GetTerranRushScore(closestEnemy) > 12 ||
96 closestEnemy->completedUnitCount(UnitTypes::Zerg_Sunken_Colony) > 1 ||

Callers

nothing calls this directly

Calls 14

GetTerranRushScoreFunction · 0.85
GetZergGroundRushScoreFunction · 0.85
GetZergAirRushScoreFunction · 0.85
GetProtossAirRushScoreFunction · 0.85
saveDebugMethod · 0.80
getOpcodeMethod · 0.80
centerMethod · 0.80
getLocationMethod · 0.80
allUnitCountMethod · 0.80
completedUnitCountMethod · 0.80
setScriptOffsetMethod · 0.80
readTupleMethod · 0.45

Tested by

no test coverage detected