2011-10-29 19:50:29 -06:00
|
|
|
// Dry Buckets : Remove all "water" objects from buckets scattered around the fortress
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
2011-10-29 19:50:29 -06:00
|
|
|
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "DataDefs.h"
|
2012-01-07 22:04:49 -07:00
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/item.h"
|
2012-01-11 07:58:26 -07:00
|
|
|
#include "df/builtin_mats.h"
|
2012-01-07 22:04:49 -07:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
2011-10-29 19:50:29 -06:00
|
|
|
using namespace DFHack;
|
2012-01-21 17:31:15 -07:00
|
|
|
using namespace df::enums;
|
2011-10-29 19:50:29 -06:00
|
|
|
|
2012-01-07 22:04:49 -07:00
|
|
|
using df::global::world;
|
|
|
|
|
2012-02-21 10:19:17 -07:00
|
|
|
DFHACK_PLUGIN("drybuckets");
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_drybuckets (color_ostream &out, vector <string> & parameters)
|
2012-01-07 22:04:49 -07:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
if (!parameters.empty())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2012-01-21 17:31:15 -07:00
|
|
|
|
|
|
|
int dried_total = 0;
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < world->items.all.size(); i++)
|
2012-01-21 17:31:15 -07:00
|
|
|
{
|
|
|
|
df::item *item = world->items.all[i];
|
|
|
|
if ((item->getType() == item_type::LIQUID_MISC) && (item->getMaterial() == builtin_mats::WATER))
|
|
|
|
{
|
2012-03-30 00:44:52 -06:00
|
|
|
item->flags.bits.garbage_collect = 1;
|
2012-01-21 17:31:15 -07:00
|
|
|
dried_total++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dried_total)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("Done. %d buckets of water marked for emptying.\n", dried_total);
|
2012-01-21 17:31:15 -07:00
|
|
|
return CR_OK;
|
2012-01-07 22:04:49 -07:00
|
|
|
}
|
2011-10-29 19:50:29 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
2011-10-29 19:50:29 -06:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
commands.push_back(PluginCommand("drybuckets", "Removes water from buckets.", df_drybuckets));
|
|
|
|
return CR_OK;
|
2011-10-29 19:50:29 -06:00
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2011-10-29 19:50:29 -06:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
return CR_OK;
|
2012-01-15 13:54:14 -07:00
|
|
|
}
|