2012-01-23 15:03:29 -07:00
|
|
|
// Show details of currently active strange mood, if any
|
|
|
|
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "modules/Materials.h"
|
|
|
|
#include "modules/Translation.h"
|
2012-01-24 04:36:30 -07:00
|
|
|
#include "modules/Items.h"
|
2015-01-28 14:26:17 -07:00
|
|
|
#include "modules/Units.h"
|
2012-01-23 15:03:29 -07:00
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/job.h"
|
|
|
|
#include "df/job_item.h"
|
2012-08-09 09:07:20 -06:00
|
|
|
#include "df/job_item_ref.h"
|
2012-01-23 15:03:29 -07:00
|
|
|
#include "df/general_ref.h"
|
|
|
|
#include "df/builtin_mats.h"
|
|
|
|
#include "df/inorganic_raw.h"
|
|
|
|
#include "df/matter_state.h"
|
|
|
|
#include "df/unit.h"
|
|
|
|
#include "df/building.h"
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
|
2014-12-06 16:47:35 -07:00
|
|
|
DFHACK_PLUGIN("showmood");
|
|
|
|
REQUIRE_GLOBAL(world);
|
2012-01-23 15:03:29 -07:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result df_showmood (color_ostream &out, vector <string> & parameters)
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
|
|
|
if (!parameters.empty())
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
|
2012-01-27 21:02:43 -07:00
|
|
|
if (!Translation::IsValid())
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Translation data unavailable!\n");
|
2012-01-27 21:02:43 -07:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2012-01-23 15:03:29 -07:00
|
|
|
|
|
|
|
bool found = false;
|
2017-11-24 22:59:59 -07:00
|
|
|
for (df::job_list_link *cur = world->jobs.list.next; cur != NULL; cur = cur->next)
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
|
|
|
df::job *job = cur->item;
|
|
|
|
if ((job->job_type < job_type::StrangeMoodCrafter) || (job->job_type > job_type::StrangeMoodMechanics))
|
|
|
|
continue;
|
|
|
|
found = true;
|
|
|
|
df::unit *unit = NULL;
|
|
|
|
df::building *building = NULL;
|
2012-11-12 07:27:58 -07:00
|
|
|
for (size_t i = 0; i < job->general_refs.size(); i++)
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
2012-11-12 07:27:58 -07:00
|
|
|
df::general_ref *ref = job->general_refs[i];
|
2012-01-23 15:03:29 -07:00
|
|
|
if (ref->getType() == general_ref_type::UNIT_WORKER)
|
|
|
|
unit = ref->getUnit();
|
|
|
|
if (ref->getType() == general_ref_type::BUILDING_HOLDER)
|
|
|
|
building = ref->getBuilding();
|
|
|
|
}
|
|
|
|
if (!unit)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Found strange mood not attached to any dwarf!\n");
|
2012-01-23 15:03:29 -07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (unit->mood == mood_type::None)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Dwarf with strange mood does not have a mood type!\n");
|
2012-01-23 15:03:29 -07:00
|
|
|
continue;
|
|
|
|
}
|
2015-12-24 19:34:38 -07:00
|
|
|
out.print("%s is currently ", DF2CONSOLE(Translation::TranslateName(&unit->name, false)).c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
switch (unit->mood)
|
|
|
|
{
|
|
|
|
case mood_type::Macabre:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("in a macabre mood");
|
2012-01-23 15:03:29 -07:00
|
|
|
if (job->job_type != job_type::StrangeMoodBrooding)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(" (but isn't actually in a macabre mood?)");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case mood_type::Fell:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("in a fell mood");
|
2012-01-23 15:03:29 -07:00
|
|
|
if (job->job_type != job_type::StrangeMoodFell)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(" (but isn't actually in a fell mood?)");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case mood_type::Fey:
|
|
|
|
case mood_type::Secretive:
|
|
|
|
case mood_type::Possessed:
|
|
|
|
switch (unit->mood)
|
|
|
|
{
|
|
|
|
case mood_type::Fey:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("in a fey mood");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case mood_type::Secretive:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("in a secretive mood");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case mood_type::Possessed:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("possessed");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print(" with intent to ");
|
2012-01-23 15:03:29 -07:00
|
|
|
switch (job->job_type)
|
|
|
|
{
|
|
|
|
case job_type::StrangeMoodCrafter:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Craftsdwarf's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodJeweller:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Jeweler's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodForge:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Metalsmith's Forge");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodMagmaForge:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Magma Forge");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodCarpenter:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Carpenter's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodMason:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Mason's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodBowyer:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Boywer's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodTanner:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Leather Works");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodWeaver:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Clothier's Shop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodGlassmaker:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Glass Furnace");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodMechanics:
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claim a Mechanic's Workshop");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodBrooding:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("enter a macabre mood?");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case job_type::StrangeMoodFell:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("enter a fell mood?");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
2012-03-10 08:03:11 -07:00
|
|
|
default:
|
|
|
|
out.print("do something else...");
|
|
|
|
break;
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print(" and become a legendary %s", ENUM_ATTR_STR(job_skill, caption_noun, unit->job.mood_skill));
|
|
|
|
if (unit->mood == mood_type::Possessed)
|
|
|
|
out.print(" (but not really)");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
default:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("insane?");
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print(".\n");
|
2015-01-28 14:26:17 -07:00
|
|
|
if (Units::isMale(unit))
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("He has ");
|
|
|
|
else
|
|
|
|
out.print("She has ");
|
2012-01-23 15:03:29 -07:00
|
|
|
if (building)
|
|
|
|
{
|
|
|
|
string name;
|
|
|
|
building->getName(&name);
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("claimed a %s and wants", name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
|
|
|
else
|
2012-05-25 20:31:47 -06:00
|
|
|
out.print("not yet claimed a workshop but will want");
|
|
|
|
out.print(" the following items:\n");
|
2012-01-23 15:03:29 -07:00
|
|
|
|
2012-01-31 09:55:38 -07:00
|
|
|
for (size_t i = 0; i < job->job_items.size(); i++)
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
|
|
|
df::job_item *item = job->job_items[i];
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("Item %i: ", i + 1);
|
2012-01-23 15:03:29 -07:00
|
|
|
|
|
|
|
MaterialInfo matinfo(item->mat_type, item->mat_index);
|
|
|
|
|
|
|
|
string mat_name = matinfo.toString();
|
|
|
|
|
|
|
|
switch (item->item_type)
|
|
|
|
{
|
|
|
|
case item_type::BOULDER:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s boulder", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::BLOCKS:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s blocks", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::WOOD:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s logs", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::BAR:
|
2012-01-24 04:36:30 -07:00
|
|
|
if (matinfo.isInorganicWildcard())
|
2012-01-23 15:03:29 -07:00
|
|
|
mat_name = "metal";
|
2012-01-24 04:36:30 -07:00
|
|
|
if (matinfo.inorganic && matinfo.inorganic->flags.is_set(inorganic_flags::WAFERS))
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s wafers", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s bars", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::SMALLGEM:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s cut gems", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::ROUGH:
|
2012-01-24 04:36:30 -07:00
|
|
|
if (matinfo.isAnyInorganic())
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
2012-01-24 04:36:30 -07:00
|
|
|
if (matinfo.isInorganicWildcard())
|
2012-01-23 15:03:29 -07:00
|
|
|
mat_name = "any";
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s rough gems", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("raw %s", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::SKIN_TANNED:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s leather", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
case item_type::CLOTH:
|
2012-01-24 04:36:30 -07:00
|
|
|
if (matinfo.isNone())
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
|
|
|
if (item->flags2.bits.plant)
|
|
|
|
mat_name = "any plant fiber";
|
|
|
|
else if (item->flags2.bits.silk)
|
|
|
|
mat_name = "any silk";
|
|
|
|
else if (item->flags2.bits.yarn)
|
|
|
|
mat_name = "any yarn";
|
|
|
|
}
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s cloth", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
2012-01-24 09:03:28 -07:00
|
|
|
case item_type::REMAINS:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s remains", mat_name.c_str());
|
2012-01-24 09:03:28 -07:00
|
|
|
break;
|
|
|
|
case item_type::CORPSE:
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s %scorpse", mat_name.c_str(), (item->flags1.bits.murdered ? "murdered " : ""));
|
2012-01-24 09:03:28 -07:00
|
|
|
break;
|
2012-01-23 15:03:29 -07:00
|
|
|
case item_type::NONE:
|
|
|
|
if (item->flags2.bits.body_part)
|
|
|
|
{
|
|
|
|
if (item->flags2.bits.bone)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s bones", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else if (item->flags2.bits.shell)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s shells", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else if (item->flags2.bits.horn)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s horns", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else if (item->flags2.bits.pearl)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s pearls", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else if (item->flags2.bits.ivory_tooth)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s ivory/teeth", mat_name.c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%s unknown body parts (%s:%s:%s)",
|
2012-01-24 04:36:30 -07:00
|
|
|
mat_name.c_str(),
|
2012-03-17 02:52:22 -06:00
|
|
|
bitfield_to_string(item->flags1).c_str(),
|
|
|
|
bitfield_to_string(item->flags2).c_str(),
|
|
|
|
bitfield_to_string(item->flags3).c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
|
|
|
else
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("indeterminate %s item (%s:%s:%s)",
|
2012-01-24 04:36:30 -07:00
|
|
|
mat_name.c_str(),
|
2012-03-17 02:52:22 -06:00
|
|
|
bitfield_to_string(item->flags1).c_str(),
|
|
|
|
bitfield_to_string(item->flags2).c_str(),
|
|
|
|
bitfield_to_string(item->flags3).c_str());
|
2012-01-23 15:03:29 -07:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-24 04:36:30 -07:00
|
|
|
{
|
|
|
|
ItemTypeInfo itinfo(item->item_type, item->item_subtype);
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("item %s material %s flags (%s:%s:%s)",
|
2012-01-24 04:36:30 -07:00
|
|
|
itinfo.toString().c_str(), mat_name.c_str(),
|
2012-03-17 02:52:22 -06:00
|
|
|
bitfield_to_string(item->flags1).c_str(),
|
|
|
|
bitfield_to_string(item->flags2).c_str(),
|
|
|
|
bitfield_to_string(item->flags3).c_str());
|
2012-01-24 04:36:30 -07:00
|
|
|
break;
|
|
|
|
}
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
2012-01-24 04:36:30 -07:00
|
|
|
|
2014-08-21 14:23:05 -06:00
|
|
|
// count how many items of this type the crafter already collected
|
|
|
|
{
|
|
|
|
int count_got = 0;
|
|
|
|
for (size_t j = 0; j < job->items.size(); j++)
|
|
|
|
{
|
|
|
|
if(job->items[j]->job_item_idx == i)
|
|
|
|
{
|
|
|
|
if (item->item_type == item_type::BAR || item->item_type == item_type::CLOTH)
|
|
|
|
count_got += job->items[j]->item->getTotalDimension();
|
|
|
|
else
|
|
|
|
count_got += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out.print(", quantity %i (got %i)\n", item->quantity, count_got);
|
|
|
|
}
|
2012-01-23 15:03:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("No strange moods currently active.\n");
|
2012-01-23 15:03:29 -07:00
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init (color_ostream &out, std::vector<PluginCommand> &commands)
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
2013-10-30 14:58:14 -06:00
|
|
|
commands.push_back(PluginCommand("showmood", "Shows items needed for current strange mood.", df_showmood, false,
|
|
|
|
"Run this command without any parameters to display information on the currently active Strange Mood."));
|
2012-01-23 15:03:29 -07:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2012-01-23 15:03:29 -07:00
|
|
|
{
|
|
|
|
return CR_OK;
|
2012-02-13 21:54:08 -07:00
|
|
|
}
|