Skip to content
Snippets Groups Projects
Commit f661b794 authored by David Bergström's avatar David Bergström
Browse files

Merge branch 'master' into 'master'

Added methods to use abilities.

See merge request !3
parents 05af0f93 4b10219b
No related branches found
No related tags found
No related merge requests found
...@@ -63,7 +63,7 @@ PYBIND11_MODULE(library, m) ...@@ -63,7 +63,7 @@ PYBIND11_MODULE(library, m)
.def(py::init()); .def(py::init());
// IDABot is a specialization of Agent // 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(py::init())
.def("on_game_start", &IDABot::OnGameStart) .def("on_game_start", &IDABot::OnGameStart)
.def("on_step", &IDABot::OnStep) .def("on_step", &IDABot::OnStep)
...@@ -78,7 +78,10 @@ PYBIND11_MODULE(library, m) ...@@ -78,7 +78,10 @@ PYBIND11_MODULE(library, m)
.def_property_readonly("minerals", &IDABot::GetMinerals, "How much minerals we currently have") .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("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("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"); py::class_<sc2::PlayerSetup>(m, "PlayerSetup");
......
...@@ -219,3 +219,17 @@ const TypeData & IDABot::Data(const MetaType & type) const ...@@ -219,3 +219,17 @@ const TypeData & IDABot::Data(const MetaType & type) const
return m_techTree.getData(type); 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);
}
...@@ -62,4 +62,9 @@ public: ...@@ -62,4 +62,9 @@ public:
const TypeData & Data(const CCUpgrade & type) const; const TypeData & Data(const CCUpgrade & type) const;
const TypeData & Data(const MetaType & type) const; const TypeData & Data(const MetaType & type) const;
const TypeData & Data(const Unit & unit) 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);
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment