Skip to content

Commit

Permalink
add sprite generation
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnTW committed Oct 13, 2024
1 parent 5a716e0 commit 9391ffc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ void codes::initCodes(int gameVer)
offsets.removeBuildingSelection = 0x5FA3A0;
offsets.getNextWord = 0xD4F060;
offsets.modelRigidDestructor = 0x933640;
offsets.generateSprite = 0xE7E220;
}


Expand Down Expand Up @@ -664,5 +665,6 @@ void codes::initCodes(int gameVer)
offsets.removeBuildingSelection = 0x005FA790;
offsets.getNextWord = 0xD493C0;
offsets.modelRigidDestructor = 0x934110;
offsets.generateSprite = 0xE78C00;
}
}
1 change: 1 addition & 0 deletions M2TWEOP Code/M2TWEOP library/functionsOffsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions M2TWEOP Code/M2TWEOP library/luaPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions M2TWEOP Code/M2TWEOP library/types/gameHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions M2TWEOP Code/M2TWEOP library/types/gameHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9391ffc

Please sign in to comment.