diff --git a/plugins/devel/CMakeLists.txt b/plugins/devel/CMakeLists.txt index c1df34fa3..9e7e7af6f 100644 --- a/plugins/devel/CMakeLists.txt +++ b/plugins/devel/CMakeLists.txt @@ -14,4 +14,5 @@ DFHACK_PLUGIN(frozen frozen.cpp) DFHACK_PLUGIN(dumpmats dumpmats.cpp) #DFHACK_PLUGIN(tiles tiles.cpp) DFHACK_PLUGIN(regrass regrass.cpp) +DFHACK_PLUGIN(counters counters.cpp) diff --git a/plugins/devel/counters.cpp b/plugins/devel/counters.cpp new file mode 100644 index 000000000..66d8c63a4 --- /dev/null +++ b/plugins/devel/counters.cpp @@ -0,0 +1,47 @@ +// Show creature counter values + +#include "Core.h" +#include "Console.h" +#include "Export.h" +#include "PluginManager.h" +#include "modules/Gui.h" +#include "df/unit.h" +#include "df/unit_misc_trait.h" + +using std::vector; +using std::string; + +using namespace DFHack; +using namespace df::enums; + +command_result df_counters (color_ostream &out, vector & parameters) +{ + CoreSuspender suspend; + + df::unit *unit = Gui::getSelectedUnit(out); + if (!unit) + return CR_WRONG_USAGE; + auto &counters = unit->status.misc_traits; + for (size_t i = 0; i < counters.size(); i++) + { + auto counter = counters[i]; + out.print("%i (%s): %i\n", counter->id, ENUM_KEY_STR(unit_misc_trait::T_id, counter->id).c_str(), counter->value); + } + + return CR_OK; +} + +DFHACK_PLUGIN("probe"); + +DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) +{ + commands.push_back(PluginCommand("counters", + "Display counters for currently selected creature", + df_counters)); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( color_ostream &out ) +{ + return CR_OK; +} \ No newline at end of file