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

Method execute

bwapi/BWScriptEmulator/Use_Ability.cpp:21–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21bool Use_Ability::execute(aithread &thread) const
22{
23 // Get the appropriate tech and unit type for the opcode
24 TechType tech;
25 UnitType unit;
26 switch ( this->getOpcode() )
27 {
28 case Enum::NUKE_LOCATION:
29 tech = TechTypes::Nuclear_Strike;
30 unit = UnitTypes::Terran_Ghost;
31 break;
32 case Enum::DISRUPTION_WEB:
33 tech = TechTypes::Disruption_Web;
34 unit = UnitTypes::Protoss_Corsair;
35 break;
36 case Enum::RECALL_LOCATION:
37 tech = TechTypes::Recall;
38 unit = UnitTypes::Protoss_Arbiter;
39 break;
40 }
41
42 // Execute the ability after obtaining a unit
43 Unit pCaster = GetSuitableCaster(tech.energyCost(), unit);
44 if ( pCaster )
45 pCaster->useTech(tech, thread.getLocation().center());
46
47 // Debug and return
48 thread.saveDebug(Text::Green, this->getOpcode());
49 return true;
50}

Callers

nothing calls this directly

Calls 7

GetSuitableCasterFunction · 0.85
getOpcodeMethod · 0.80
energyCostMethod · 0.80
centerMethod · 0.80
getLocationMethod · 0.80
saveDebugMethod · 0.80
useTechMethod · 0.45

Tested by

no test coverage detected