diff options
| author | Petr Mrázek | 2012-03-09 08:26:41 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-03-09 08:26:41 +0100 |
| commit | 98a226ab636dad8e191cfbb85d2b6bb22254d026 (patch) | |
| tree | 97c635ddd838ca6a2df2b7a5c3a3585155ed0637 /plugins/tweak.cpp | |
| parent | dc0b2b8216e9bad6b5595df333219ab1c49d7a46 (diff) | |
| download | dfhack-98a226ab636dad8e191cfbb85d2b6bb22254d026.tar.gz dfhack-98a226ab636dad8e191cfbb85d2b6bb22254d026.tar.bz2 dfhack-98a226ab636dad8e191cfbb85d2b6bb22254d026.tar.xz | |
Add a lair sub-command to tweak.
This allows setting the whole map as monster lair, effectively locking items in place so they don't scatter on abandon/reclaim.
Diffstat (limited to 'plugins/tweak.cpp')
| -rw-r--r-- | plugins/tweak.cpp | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index c244553a..ba0fa72d 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -46,6 +46,8 @@ DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> & "tweak", "Various tweaks for minor bugs.", tweak, false, " tweak clear-missing\n" " Remove the missing status from the selected unit.\n" + " lair\n" + " Mark the map as monster lair\n" )); return CR_OK; } @@ -54,7 +56,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) { return CR_OK; } - +command_result lair(DFHack::Core * c, std::vector<std::string> & params); static command_result tweak(Core * c, vector <string> ¶meters) { CoreSuspender suspend(c); @@ -81,8 +83,47 @@ static command_result tweak(Core * c, vector <string> ¶meters) crime->flags.bits.discovered = true; } } - else - return CR_WRONG_USAGE; + else if(cmd == "lair") + { + return lair(c,parameters); + } + else return CR_WRONG_USAGE; return CR_OK; } + +#include "modules/Maps.h" +command_result lair(DFHack::Core * c, std::vector<std::string> & params) +{ + for(size_t i = 0; i < params.size();i++) + { + if(params[i] == "help" || params[i] == "?") + { + c->con.print("Makes the map a smonster lair, hopefully preventing item scatter.\n"); + return CR_OK; + } + } + Console & con = c->con; + + //CoreSuspender suspend(c); + if (!Maps::IsValid()) + { + c->con.printerr("Map is not available!\n"); + return CR_FAILURE; + } + uint32_t x_max,y_max,z_max; + Maps::getSize(x_max,y_max,z_max); + for (size_t i = 0; i < world->map.map_blocks.size(); i++) + { + df::map_block *block = world->map.map_blocks[i]; + DFHack::occupancies40d & occupancies = block->occupancy; + // for each tile in block + for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++) + { + // set to revealed + occupancies[x][y].bits.monster_lair = true; + } + } + con.print("Map monsterized.\n"); + return CR_OK; +}
\ No newline at end of file |
