From 7331485b46636b4c2916d72290812bad97761ae9 Mon Sep 17 00:00:00 2001 From: Robert Heinrich Date: Thu, 12 Apr 2012 14:40:39 +0200 Subject: [PATCH] removed tweak-merchant and tweak-resident, combined both commands into tweak-migrant. added worn items to their uniform so they don't drop their clothes instantly --- plugins/tweak.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index 5f65fe27d..a1197a342 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -10,6 +10,8 @@ #include "modules/Units.h" #include "modules/Items.h" +#include "MiscUtils.h" + #include "DataDefs.h" #include "df/ui.h" #include "df/world.h" @@ -71,9 +73,10 @@ DFhackCExport command_result plugin_shutdown (color_ostream &out) static command_result lair(color_ostream &out, std::vector & params); -// to be called by tweak-merchant and tweak-resident +// to be called by tweak-fixmigrant // units forced into the fort by removing the flags do not own their clothes // which has the result that they drop all their clothes and become unhappy because they are naked +// so we need to make them own their clothes and add them to their uniform command_result fix_clothing_ownership(color_ostream &out, df::unit* unit) { // first, find one owned item to initialize the vtable @@ -109,12 +112,18 @@ command_result fix_clothing_ownership(color_ostream &out, df::unit* unit) if(!Items::getOwner(item)) { if(Items::setOwner(item, unit)) + { + // add to uniform, so they know they should wear their clothes + insert_into_vector(unit->military.uniforms[0], item->id); fixcount++; + } else out << "could not change ownership for item!" << endl; } } } + // clear uniform_drop (without this they would drop their clothes and pick them up some time later) + unit->military.uniform_drop.clear(); out << "ownership for " << fixcount << " clothes fixed" << endl; return CR_OK; } @@ -180,15 +189,20 @@ static command_result tweak(color_ostream &out, vector ¶meters) return CR_FAILURE; } + // case #1: migrants who have the resident flag set + // see http://dffd.wimbli.com/file.php?id=6139 for a save if (unit->flags2.bits.resident) unit->flags2.bits.resident = 0; + // case #2: migrants who have the merchant flag + // happens on almost all maps after a few migrant waves if(unit->flags1.bits.merchant) unit->flags1.bits.merchant = 0; - // this one is a cheat, but bugged migrants usually have the same civ_id - // but if it happens that the player has 'foreign' units of the same race - // (dwarves not from moutainhome in vanilla df) on his map, just grab them + // this one is a cheat, but bugged migrants usually have the same civ_id + // so it should not be triggered in most cases + // if it happens that the player has 'foreign' units of the same race + // (vanilla df: dwarves not from mountainhome) on his map, just grab them if(unit->civ_id != df::global::ui->civ_id) unit->civ_id = df::global::ui->civ_id;