From c659b885b6ab5d6e71a0e5650b7882f99066445e Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 25 Jan 2017 23:06:03 +0530 Subject: [PATCH] Start a plugin to rename generated creatures to have sensible IDs --- plugins/CMakeLists.txt | 1 + plugins/generated-creature-renamer.cpp | 79 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 plugins/generated-creature-renamer.cpp diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 4611009c3..6b1f80634 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -122,6 +122,7 @@ if (BUILD_SUPPORTED) DFHACK_PLUGIN(follow follow.cpp) DFHACK_PLUGIN(forceequip forceequip.cpp) DFHACK_PLUGIN(fortplan fortplan.cpp LINK_LIBRARIES buildingplan-lib) + DFHACK_PLUGIN(generated-creature-renamer generated-creature-renamer.cpp) DFHACK_PLUGIN(getplants getplants.cpp) DFHACK_PLUGIN(hotkeys hotkeys.cpp) DFHACK_PLUGIN(infiniteSky infiniteSky.cpp) diff --git a/plugins/generated-creature-renamer.cpp b/plugins/generated-creature-renamer.cpp new file mode 100644 index 000000000..8c2fe20ef --- /dev/null +++ b/plugins/generated-creature-renamer.cpp @@ -0,0 +1,79 @@ +#include "Console.h" +#include "Core.h" +#include "DataDefs.h" +#include "Export.h" +#include "PluginManager.h" +#include "df/world.h" +#include "df/world_raws.h" +#include "df/creature_raw.h" +#include "df/caste_raw.h" + +//#include "df/world.h" + +using namespace DFHack; + +DFHACK_PLUGIN("rename_creatures"); +REQUIRE_GLOBAL(world); + +command_result rename_creatures (color_ostream &out, std::vector & parameters); + +DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands) +{ + commands.push_back(PluginCommand( + "rename_creatures", + "Renames generated creature tags to something friendlier to modders", + rename_creatures, + false, //allow non-interactive use + "longHelpString" + )); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown (color_ostream &out) +{ + return CR_OK; +} + +std::string descriptors[] = { "blob", "quadruped", "humanoid", "silverfish", "mayfly", "dragonfly", +"damselfly", "stonefly", "earwig", "grasshopper", "cricket", "stick insect", "cockroach", "termite", +"mantis", "louse", "thrips", "aphid", "cicada", "assassin bug", "wasp", "hornet", "tiger beetle", +"ladybug", "weevil", "darkling beetle", "click beetle", "firefly", "scarab beetle", "stag beetle", +"dung beetle", "rhinoceros beetle", "rove beetle", "snakefly", "lacewing", "antlion larva", +"mosquito", "flea", "scorpionfly", "caddisfly", "butterfly", "moth", "caterpillar", "maggot", +"spider", "tarantula", "scorpion", "tick", "mite", "shrimp", "lobster", "crab", "nematode", +"snail", "slug", "earthworm", "leech", "bristleworm", "ribbon worm", "flat worm", "toad", "frog", +"salamander", "newt", "alligator", "crocodile", "lizard", "chameleon", "iguana", "gecko", "skink", +"gila monster", "monitor", "serpent", "viper", "rattlesnake", "cobra", "python", "anaconda", "turtle", +"tortoise", "pterosaur", "dimetrodon", "sauropod", "theropod", "iguanodont", "hadrosaurid", "stegosaurid", +"ceratopsid", "ankylosaurid", "duck", "goose", "swan", "turkey", "grouse", "chicken", "quail", "pheasant", +"gull", "loon", "grebe", "albatross", "petrel", "penguin", "pelican", "stork", "vulture", "flamingo", +"falcon", "kestrel", "condor", "osprey", "buzzard", "eagle", "harrier", "kite", "crane", "dove", +"pigeon", "parrot", "cockatoo", "cuckoo", "nightjar", "swift", "hummingbird", "kingfisher", +"hornbill", "quetzal", "toucan", "woodpecker", "lyrebird", "thornbill", "honeyeater", "oriole", +"fantail", "shrike", "crow", "raven", "magpie", "kinglet", "lark", "swallow", "martin", "bushtit", +"warbler", "thrush", "oxpecker", "starling", "mockingbird", "wren", "nuthatch", "sparrow", "tanager", +"cardinal", "bunting", "finch", "titmouse", "chickadee", "waxwing", "flycatcher", "opossum", "koala", +"wombat", "kangaroo", "sloth", "anteater", "armadillo", "squirrel", "marmot", "beaver", "gopher", +"mouse", "porcupine", "chinchilla", "cavy", "capybara", "rabbit", "hare", "lemur", "loris", "monkey", +"hedgehog", "shrew", "mole", "fruit bat", "wolf", "coyote", "jackal", "raccoon", "coati", +"weasel", "otter", "badger", "skunk", "bear", "panda", "panther", "mongoose", "hyena", "civet", +"walrus", "pangolin", "elephant", "mammoth", "horse", "zebra", "tapir", "rhinoceros", "warthog", +"hippopotamus", "camel", "llama", "giraffe", "deer", "moose", "antelope", "sheep", "goat", +"bison", "buffalo", "bull" }; + +command_result rename_creatures (color_ostream &out, std::vector & parameters) +{ + if (!parameters.empty()) + return CR_WRONG_USAGE; + CoreSuspender suspend; + for (int i = 0; i < world->raws.creatures.all.size(); i++) + { + auto creatureRaw = world->raws.creatures.all[i]; + if (!creatureRaw->flags.is_set(df::enums::creature_raw_flags::GENERATED)) + continue; + out.print(creatureRaw->creature_id.c_str()); + out.print(creatureRaw->caste[0]->description.c_str()); + } + return CR_OK; +} +