diff --git a/python-api-src/library.cpp b/python-api-src/library.cpp index 50ec422acb00f0f77d3aa241b671a3fdd45b89fa..e8d5ff9975a194a93587c6384bd545b61eadc30f 100644 --- a/python-api-src/library.cpp +++ b/python-api-src/library.cpp @@ -63,7 +63,7 @@ PYBIND11_MODULE(library, m) .def(py::init()); // IDABot is a specialization of Agent - py::class_<IDABot, PyIDABot, sc2::Agent>(m, "IDABot") + py::class_<IDABot, PyIDABot, sc2::Agent>(m, "IDABot") .def(py::init()) .def("on_game_start", &IDABot::OnGameStart) .def("on_step", &IDABot::OnStep) @@ -78,7 +78,10 @@ PYBIND11_MODULE(library, m) .def_property_readonly("minerals", &IDABot::GetMinerals, "How much minerals we currently have") .def_property_readonly("current_supply", &IDABot::GetCurrentSupply, "How much supply we are currently using") .def_property_readonly("max_supply", &IDABot::GetMaxSupply, "How much supply we can currently use") - .def_property_readonly("gas", &IDABot::GetGas, "How much gas we currently have"); + .def_property_readonly("gas", &IDABot::GetGas, "How much gas we currently have") + .def("use_ability", &IDABot::UseAbility, "Use an ability with the given unit") + .def("use_ability", &IDABot::UseAbilityWithPoint, "Use ability at point with the given unit") + .def("use_ability", &IDABot::UseAbilityWithTarget, "Use ability at target with the given unit"); py::class_<sc2::PlayerSetup>(m, "PlayerSetup"); diff --git a/src/IDABot.cpp b/src/IDABot.cpp index f61dc8329e06685f6078df8c859dd01619207af1..5705dffe94268775333d0223686a1952417ef31d 100644 --- a/src/IDABot.cpp +++ b/src/IDABot.cpp @@ -219,3 +219,17 @@ const TypeData & IDABot::Data(const MetaType & type) const return m_techTree.getData(type); } +void IDABot::UseAbility(const Unit& unit, sc2::AbilityID ability) +{ + Actions()->UnitCommand(unit.getUnitPtr(), ability, false); +} + +void IDABot::UseAbilityWithPoint(const Unit& unit, sc2::AbilityID ability, const sc2::Point2D& point) +{ + Actions()->UnitCommand(unit.getUnitPtr(), ability, point, false); +} + +void IDABot::UseAbilityWithTarget(const Unit& unit, sc2::AbilityID ability, const Unit* target) +{ + Actions()->UnitCommand(unit.getUnitPtr(), ability, target->getUnitPtr(), false); +} diff --git a/src/IDABot.h b/src/IDABot.h index eca954f01a1857bf31747ae128a239b86dc19e88..100b581a5ba449b8c50df19e31b9b037b281e3af 100644 --- a/src/IDABot.h +++ b/src/IDABot.h @@ -62,4 +62,9 @@ public: const TypeData & Data(const CCUpgrade & type) const; const TypeData & Data(const MetaType & type) const; const TypeData & Data(const Unit & unit) const; + + // Used for giving "raw" commands to units + void UseAbility(const Unit& unit, sc2::AbilityID ability); + void UseAbilityWithPoint(const Unit& unit, sc2::AbilityID ability, const sc2::Point2D& point); + void UseAbilityWithTarget(const Unit& unit, sc2::AbilityID ability, const Unit* target); };