diff --git a/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp b/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp index b2ca972c..632a2b84 100644 --- a/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp +++ b/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp @@ -331,6 +331,7 @@ void codes::initCodes(int gameVer) offsets.removeBuildingSelection = 0x5FA3A0; offsets.getNextWord = 0xD4F060; offsets.modelRigidDestructor = 0x933640; + offsets.generateSprite = 0xE7E220; } @@ -664,5 +665,6 @@ void codes::initCodes(int gameVer) offsets.removeBuildingSelection = 0x005FA790; offsets.getNextWord = 0xD493C0; offsets.modelRigidDestructor = 0x934110; + offsets.generateSprite = 0xE78C00; } } \ No newline at end of file diff --git a/M2TWEOP Code/M2TWEOP library/functionsOffsets.h b/M2TWEOP Code/M2TWEOP library/functionsOffsets.h index ef39d663..c4031d89 100644 --- a/M2TWEOP Code/M2TWEOP library/functionsOffsets.h +++ b/M2TWEOP Code/M2TWEOP library/functionsOffsets.h @@ -208,6 +208,7 @@ class codes DWORD switchNamedCharacterFaction = NULL; DWORD switchArmyFaction = NULL; DWORD modelRigidDestructor = NULL; + DWORD generateSprite = NULL; DWORD changeCharacterTileStuff = NULL; DWORD initPlaceCharacter = NULL; DWORD getNextWord = NULL; diff --git a/M2TWEOP Code/M2TWEOP library/luaPlugin.cpp b/M2TWEOP Code/M2TWEOP library/luaPlugin.cpp index 0a6266d6..e6e499fa 100644 --- a/M2TWEOP Code/M2TWEOP library/luaPlugin.cpp +++ b/M2TWEOP Code/M2TWEOP library/luaPlugin.cpp @@ -263,6 +263,7 @@ sol::state* luaPlugin::init(std::string& luaFilePath, std::string& modPath) @tfield handleUnitCards handleUnitCards @tfield setKhakiTextColor setKhakiTextColor @tfield getMinorSettlementBalance getMinorSettlementBalance + @tfield generateSprite generateSprite @table M2TWEOP */ @@ -869,6 +870,15 @@ sol::state* luaPlugin::init(std::string& luaFilePath, std::string& modPath) */ tables.M2TWEOP.set_function("getMinorSettlementBalance", &minorSettlementDb::getModifiers); + /*** + Generate sprites for a battle model entry in the bmdb. There needs to be a export/unit_sprites folder in your vanilla Medieval II directory. The game will close after generating the sprites. + @function M2TWEOP.generateSprite + @tparam string modelName + @usage + M2TWEOP.generateSprite("peasants") + */ + tables.M2TWEOP.set_function("generateSprite", &gameHelpers::generateSprite); + /*** Add a banner symbol. Add them onCampaignMapLoaded or later! @function M2TWEOP.addBanner diff --git a/M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp b/M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp index 6cc0ddee..1f15473e 100644 --- a/M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp +++ b/M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp @@ -135,6 +135,12 @@ namespace gameHelpers return globals::dataS.gameVersion; } + void generateSprite(const std::string& model) + { + void* unitSprites = nullptr; + return GAME_FUNC(void(__thiscall*)(void*, const char*), generateSprite)(unitSprites, model.c_str()); + } + void scriptCommandLua(const std::string& command, sol::variadic_args va) { const char* commandC = command.c_str(); diff --git a/M2TWEOP Code/M2TWEOP library/types/gameHelpers.h b/M2TWEOP Code/M2TWEOP library/types/gameHelpers.h index 8058bab0..003f443c 100644 --- a/M2TWEOP Code/M2TWEOP library/types/gameHelpers.h +++ b/M2TWEOP Code/M2TWEOP library/types/gameHelpers.h @@ -366,6 +366,7 @@ namespace gameHelpers std::string getModFolderName(); std::string getModString(const std::string& path); int getGameVersion(); + void generateSprite(const std::string& model); void addToLua(sol::state& luaState); std::string callConsole(const std::string& cmdName, sol::variadic_args va);