|
|
@ -16,18 +16,10 @@ using namespace DFHack;
|
|
|
|
DFHACK_PLUGIN("generated-creature-renamer");
|
|
|
|
DFHACK_PLUGIN("generated-creature-renamer");
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
REQUIRE_GLOBAL(world);
|
|
|
|
|
|
|
|
|
|
|
|
command_result rename_creatures(color_ostream &out, std::vector <std::string> & parameters);
|
|
|
|
|
|
|
|
command_result list_creatures(color_ostream &out, std::vector <std::string> & parameters);
|
|
|
|
command_result list_creatures(color_ostream &out, std::vector <std::string> & parameters);
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
|
|
|
|
"rename-generated",
|
|
|
|
|
|
|
|
"Renames generated creature tags to something friendlier to modders",
|
|
|
|
|
|
|
|
rename_creatures,
|
|
|
|
|
|
|
|
false, //allow non-interactive use
|
|
|
|
|
|
|
|
"Renames generated creature tags to something friendlier to modders"
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"list-generated",
|
|
|
|
"list-generated",
|
|
|
|
"Prints a list of generated creature tokens. Use \"list-generated detailed\" to show descriptions.",
|
|
|
|
"Prints a list of generated creature tokens. Use \"list-generated detailed\" to show descriptions.",
|
|
|
@ -43,7 +35,15 @@ DFhackCExport command_result plugin_shutdown(color_ostream &out)
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_DESC 223
|
|
|
|
DFHACK_PLUGIN_IS_ENABLED(is_enabled);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
is_enabled = enable;
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_DESC 227
|
|
|
|
std::string descriptors[NUM_DESC] = { " blob", " quadruped", " humanoid", " silverfish", " mayfly", " dragonfly",
|
|
|
|
std::string descriptors[NUM_DESC] = { " blob", " quadruped", " humanoid", " silverfish", " mayfly", " dragonfly",
|
|
|
|
" damselfly", " stonefly", " earwig", " grasshopper", " cricket", " stick insect", " cockroach", " termite",
|
|
|
|
" damselfly", " stonefly", " earwig", " grasshopper", " cricket", " stick insect", " cockroach", " termite",
|
|
|
|
" mantis", " louse", " thrips", " aphid", " cicada", " assassin bug", " wasp", " hornet", " tiger beetle",
|
|
|
|
" mantis", " louse", " thrips", " aphid", " cicada", " assassin bug", " wasp", " hornet", " tiger beetle",
|
|
|
@ -69,12 +69,16 @@ std::string descriptors[NUM_DESC] = { "blob", "quadruped", "humanoid", "silverfi
|
|
|
|
" weasel", " otter", " badger", " skunk", " bear", " panda", " panther", " mongoose", " hyena", " civet",
|
|
|
|
" weasel", " otter", " badger", " skunk", " bear", " panda", " panther", " mongoose", " hyena", " civet",
|
|
|
|
" walrus", " pangolin", " elephant", " mammoth", " horse", " zebra", " tapir", " rhinoceros", " warthog",
|
|
|
|
" walrus", " pangolin", " elephant", " mammoth", " horse", " zebra", " tapir", " rhinoceros", " warthog",
|
|
|
|
" hippopotamus", " camel", " llama", " giraffe", " deer", " moose", " antelope", " sheep", " goat",
|
|
|
|
" hippopotamus", " camel", " llama", " giraffe", " deer", " moose", " antelope", " sheep", " goat",
|
|
|
|
"bison", "buffalo", "bull", "ape", "ant" };
|
|
|
|
" bison", " buffalo", " bull", " ape", " ant", " bat", " owl", " pig", " bee" };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command_result rename_creatures(color_ostream &out, std::vector <std::string> & parameters)
|
|
|
|
DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!parameters.empty())
|
|
|
|
if (!is_enabled)
|
|
|
|
return CR_WRONG_USAGE;
|
|
|
|
return CR_OK;
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case DFHack::SC_WORLD_LOADED:
|
|
|
|
CoreSuspender suspend;
|
|
|
|
CoreSuspender suspend;
|
|
|
|
|
|
|
|
|
|
|
|
int descriptorCount[NUM_DESC] = { 0 };
|
|
|
|
int descriptorCount[NUM_DESC] = { 0 };
|
|
|
@ -108,7 +112,7 @@ command_result rename_creatures(color_ostream &out, std::vector <std::string> &
|
|
|
|
if (digitPos > creatureRaw->creature_id.length())
|
|
|
|
if (digitPos > creatureRaw->creature_id.length())
|
|
|
|
digitPos = creatureRaw->creature_id.length();
|
|
|
|
digitPos = creatureRaw->creature_id.length();
|
|
|
|
|
|
|
|
|
|
|
|
creatureRaw->creature_id.replace(digitPos, std::string::npos, descriptors[foundIndex]);
|
|
|
|
creatureRaw->creature_id.replace(digitPos, std::string::npos, descriptors[foundIndex], 1, std::string::npos);
|
|
|
|
|
|
|
|
|
|
|
|
if (descriptorCount[foundIndex] > 0)
|
|
|
|
if (descriptorCount[foundIndex] > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -119,6 +123,8 @@ command_result rename_creatures(color_ostream &out, std::vector <std::string> &
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
World::AddPersistentData("AlreadyRenamedCreatures");
|
|
|
|
World::AddPersistentData("AlreadyRenamedCreatures");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|