From 8a810924a075513a797792e2313ef02784e61332 Mon Sep 17 00:00:00 2001 From: thrillos Date: Sun, 19 Mar 2023 18:06:28 +0200 Subject: [PATCH 01/22] branchstart --- M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj | 8 +- M2TWEOP Code/M2TWEOP library/Injects.cpp | 3 +- .../M2TWEOP library/M2TWEOP library.vcxproj | 10 +- M2TWEOP Code/M2TWEOP library/cpp.hint | 3 + .../M2TWEOP library/eduFastFuncts.cpp | 6 +- M2TWEOP Code/M2TWEOP library/eduFastFuncts.h | 2 +- M2TWEOP Code/M2TWEOP library/eduThings.cpp | 30 +- M2TWEOP Code/M2TWEOP library/eduThings.h | 12 +- M2TWEOP Code/M2TWEOP library/fastFuncts.cpp | 16 +- M2TWEOP Code/M2TWEOP library/fastFuncts.h | 42 +- .../M2TWEOP library/fastFunctsHelpers.cpp | 4 +- .../M2TWEOP library/fastFunctsHelpers.h | 4 +- .../M2TWEOP library/patchesForGame.cpp | 10 +- M2TWEOP Code/M2TWEOP library/patchesForGame.h | 6 +- M2TWEOP Code/M2TWEOP library/plugins.cpp | 521 +-- M2TWEOP Code/M2TWEOP library/plugins.h | 81 +- M2TWEOP Code/M2TWEOP library/realGameTypes.h | 41 +- .../M2TWEOP library/stratModelsChange.cpp | 203 +- .../M2TWEOP library/stratModelsChange.h | 1 + .../M2TWEOP tools/M2TWEOP tools.vcxproj | 8 +- M2TWEOP Code/d3d9/d3d9.vcxproj | 4 +- M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 659 +++- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 879 ++++- M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h | 30 +- M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp | 40 +- M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h | 14 +- .../luaPlugin/factionHelpers.cpp | 2 +- M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp | 62 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h | 1 + .../generalCharactericticsHelpers.cpp | 46 +- .../luaPlugin/generalCharactericticsHelpers.h | 28 +- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 3088 +++++++++++++---- M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h | 14 +- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 439 +-- M2TWEOP-luaPlugin/luaPlugin/luaP.h | 81 +- M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 2 +- M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj | 8 +- .../luaPlugin/m2tweopHelpers.cpp | 12 +- M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h | 12 +- M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp | 156 +- M2TWEOP-luaPlugin/luaPlugin/otherEvents.h | 41 +- M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp | 7 +- M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 81 +- .../luaPlugin/religionEvents.cpp | 71 - M2TWEOP-luaPlugin/luaPlugin/religionEvents.h | 11 +- .../luaPlugin/technicalHelpers.cpp | 10 +- .../luaPlugin/technicalHelpers.h | 14 +- M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp | 6 +- M2TWEOP-luaPlugin/luaPlugin/uiEvents.h | 6 +- QuickEopDebug.ps1 | 57 + 52 files changed, 4581 insertions(+), 2315 deletions(-) create mode 100644 QuickEopDebug.ps1 diff --git a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj index ab8383f81..cb3006b12 100644 --- a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj +++ b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 MultiByte Application false - v142 + v143 true MultiByte Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode diff --git a/M2TWEOP Code/M2TWEOP library/Injects.cpp b/M2TWEOP Code/M2TWEOP library/Injects.cpp index 74634e7c4..67dd2da17 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.cpp +++ b/M2TWEOP Code/M2TWEOP library/Injects.cpp @@ -1393,9 +1393,10 @@ void toEvents::SetlEventsCode() { Assembler* a = new Assembler(); - a->mov(eax, dword_ptr(esp, 0x4)); a->pushad(); a->pushf(); + a->mov(eax, dword_ptr(esp, 0x28)); + a->mov(edx, dword_ptr(esp, 0x2C)); a->mov(ecx, eax); a->mov(eax, (DWORD)funcAdress); diff --git a/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj b/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj index 289100baa..643c1d858 100644 --- a/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj +++ b/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj @@ -23,20 +23,20 @@ Win32Proj {a2353bf6-5423-46e0-91eb-608bb5acbff8} M2TWEOPlibrary - 10.0.19041.0 + 10.0 DynamicLibrary true - v142 + v143 Unicode false DynamicLibrary false - v142 + v143 true Unicode false @@ -44,13 +44,13 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/M2TWEOP Code/M2TWEOP library/cpp.hint b/M2TWEOP Code/M2TWEOP library/cpp.hint index e69de29bb..32f4a9f01 100644 --- a/M2TWEOP Code/M2TWEOP library/cpp.hint +++ b/M2TWEOP Code/M2TWEOP library/cpp.hint @@ -0,0 +1,3 @@ +#define NOINLINE __declspec(noinline) +#define EOP_EXPORT extern "C" __declspec(dllexport) +#define EOP_EXPORT extern "C" __declspec(dllimport) diff --git a/M2TWEOP Code/M2TWEOP library/eduFastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/eduFastFuncts.cpp index 232236a1b..782615578 100644 --- a/M2TWEOP Code/M2TWEOP library/eduFastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/eduFastFuncts.cpp @@ -14,12 +14,12 @@ namespace eduFastFuncts char* _tmpfname; }; - static void prepareEduEntry(EduEntry*& entryForFilling) + static void prepareEduEntry(eduEntry*& entryForFilling) { int* ourInts = new int[8]; memset(ourInts, 0, sizeof(int[8])); - memset(entryForFilling, 0, sizeof(EduEntry)); + memset(entryForFilling, 0, sizeof(eduEntry)); entryForFilling->N00000151 = ourInts; @@ -122,7 +122,7 @@ namespace eduFastFuncts } - int readEduFile(std::string fileName, EduEntry* entryForFilling) + int readEduFile(std::string fileName, eduEntry* entryForFilling) { std::string unitString; diff --git a/M2TWEOP Code/M2TWEOP library/eduFastFuncts.h b/M2TWEOP Code/M2TWEOP library/eduFastFuncts.h index 68ffb5bc6..2134a95c2 100644 --- a/M2TWEOP Code/M2TWEOP library/eduFastFuncts.h +++ b/M2TWEOP Code/M2TWEOP library/eduFastFuncts.h @@ -9,6 +9,6 @@ #include "globals.h" namespace eduFastFuncts { - int readEduFile(std::string fileName,EduEntry*entryForFilling); + int readEduFile(std::string fileName,eduEntry*entryForFilling); }; diff --git a/M2TWEOP Code/M2TWEOP library/eduThings.cpp b/M2TWEOP Code/M2TWEOP library/eduThings.cpp index 9fb946fd1..23d45733a 100644 --- a/M2TWEOP Code/M2TWEOP library/eduThings.cpp +++ b/M2TWEOP Code/M2TWEOP library/eduThings.cpp @@ -9,7 +9,7 @@ namespace eduThings { eopEduEntry(int baseIdx, int newIdx) { - EduEntry* oldEn = fastFunctsHelpers::getEDUEntryById(baseIdx); + eduEntry* oldEn = fastFunctsHelpers::getEDUEntryById(baseIdx); if (oldEn == nullptr) { string errs = "Can`t create eop`s unit entry:\n"; @@ -47,14 +47,14 @@ namespace eduThings struct dataS { int fakeVtable = 0; - EduEntry edu; + eduEntry edu; }data; }; struct eduThingsG { vectoreopEdu; }data; - NOINLINE EOP_EXPORT EduEntry* addEopEduEntryFromFile(const char* fileName, int newIdx) + NOINLINE EOP_EXPORT eduEntry* addEopEduEntryFromFile(const char* fileName, int newIdx) { if (getEopEduEntry(newIdx)) { @@ -79,7 +79,7 @@ namespace eduThings return getEopEduEntry(newIdx); } - NOINLINE EOP_EXPORT EduEntry* addEopEduEntry(int baseIdx, int newIdx) + NOINLINE EOP_EXPORT eduEntry* addEopEduEntry(int baseIdx, int newIdx) { if (getEopEduEntry(newIdx)) { @@ -106,7 +106,7 @@ namespace eduThings } return nullptr; } - NOINLINE EOP_EXPORT EduEntry* getEopEduEntry(int idx) + NOINLINE EOP_EXPORT eduEntry* getEopEduEntry(int idx) { for (eopEduEntry& entry : data.eopEdu) { @@ -117,7 +117,7 @@ namespace eduThings } return nullptr; } - NOINLINE EOP_EXPORT char* getEopNameOfEduEntry(EduEntry* entryAdress) + NOINLINE EOP_EXPORT char* getEopNameOfEduEntry(eduEntry* entryAdress) { for (eopEduEntry& entry : data.eopEdu) { @@ -163,25 +163,25 @@ namespace eduThings } NOINLINE EOP_EXPORT void setEntryUnitCardTga(int entryIdx, const char* newCard) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); fastFunctsHelpers::setCryptedString(&entry->UnitCardTga, newCard); } - NOINLINE EOP_EXPORT EduEntry* getEduEntry(int Idx) + NOINLINE EOP_EXPORT eduEntry* getEduEntry(int Idx) { - EduEntry* entry = fastFunctsHelpers::getEDUEntryById(Idx); + eduEntry* entry = fastFunctsHelpers::getEDUEntryById(Idx); return entry; } NOINLINE EOP_EXPORT void setEntryInfoCardTga(int entryIdx, const char* newCard) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); fastFunctsHelpers::setCryptedString(&entry->InfoCardTga, newCard); } NOINLINE EOP_EXPORT void setEntrySoldierModel(int entryIdx, const char* newModel) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); eopEduEntry* entryInternal = getEopEduEntryInternal(entryIdx); entryInternal->eopSoldierString = newModel; @@ -192,7 +192,7 @@ namespace eduThings NOINLINE EOP_EXPORT void setEntryLocalizedName(int entryIdx, const char* newName) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); UNICODE_STRING*** nameMem = new UNICODE_STRING**; entry->localizedName = nameMem; @@ -203,7 +203,7 @@ namespace eduThings NOINLINE EOP_EXPORT void setEntryLocalizedDescr(int entryIdx, const char* newDesr) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); UNICODE_STRING*** descrMem = new UNICODE_STRING * *[4]; entry->localizedDescr = descrMem; @@ -212,7 +212,7 @@ namespace eduThings NOINLINE EOP_EXPORT void setEntryLocalizedShortDescr(int entryIdx, const char* newDecrShort) { - EduEntry* entry = getEopEduEntry(entryIdx); + eduEntry* entry = getEopEduEntry(entryIdx); UNICODE_STRING*** shDescrMem = new UNICODE_STRING * *[4]; entry->localizedDescrShort = shDescrMem; @@ -222,7 +222,7 @@ namespace eduThings { return fastFunctsHelpers::getEduIndex(type); } - NOINLINE EOP_EXPORT EduEntry* getEduEntryByType(const char* type) + NOINLINE EOP_EXPORT eduEntry* getEduEntryByType(const char* type) { return fastFunctsHelpers::getEduEntryByName(type); } diff --git a/M2TWEOP Code/M2TWEOP library/eduThings.h b/M2TWEOP Code/M2TWEOP library/eduThings.h index f33561550..7686a019b 100644 --- a/M2TWEOP Code/M2TWEOP library/eduThings.h +++ b/M2TWEOP Code/M2TWEOP library/eduThings.h @@ -18,13 +18,13 @@ using namespace std; namespace eduThings { - NOINLINE EOP_EXPORT EduEntry* addEopEduEntryFromFile(const char*fileName, int newIdx); - NOINLINE EOP_EXPORT EduEntry* addEopEduEntry(int baseIdx , int newIdx); - NOINLINE EOP_EXPORT EduEntry* getEopEduEntry(int idx); - NOINLINE EOP_EXPORT EduEntry* getEduEntry(int idx); + NOINLINE EOP_EXPORT eduEntry* addEopEduEntryFromFile(const char*fileName, int newIdx); + NOINLINE EOP_EXPORT eduEntry* addEopEduEntry(int baseIdx , int newIdx); + NOINLINE EOP_EXPORT eduEntry* getEopEduEntry(int idx); + NOINLINE EOP_EXPORT eduEntry* getEduEntry(int idx); - NOINLINE EOP_EXPORT char* getEopNameOfEduEntry(EduEntry*entryAdress); + NOINLINE EOP_EXPORT char* getEopNameOfEduEntry(eduEntry*entryAdress); //used for creation of new units, etc NOINLINE EOP_EXPORT int getDataEopEdu(int idx); NOINLINE EOP_EXPORT int* tryFindDataEopEdu(char* entryName); @@ -39,6 +39,6 @@ namespace eduThings NOINLINE EOP_EXPORT void setEntryLocalizedDescr(int entryIdx,const char*newDesr); NOINLINE EOP_EXPORT void setEntryLocalizedShortDescr(int entryIdx,const char*newDecrShort); NOINLINE EOP_EXPORT int getEduIndexByType(const char* type); - NOINLINE EOP_EXPORT EduEntry* getEduEntryByType(const char* type); + NOINLINE EOP_EXPORT eduEntry* getEduEntryByType(const char* type); }; diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp index 2852fd964..0f2126f7b 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp @@ -80,7 +80,7 @@ namespace fastFuncts } NOINLINE EOP_EXPORT void ViewTacticalMap(int x, int y) { - globals::dataS.Modules.tacticalMapVeiwer.View(x,y); + globals::dataS.Modules.tacticalMapVeiwer.View(x, y); } NOINLINE EOP_EXPORT bool IsStratMap() { @@ -91,7 +91,7 @@ namespace fastFuncts return false; return true; } - + NOINLINE EOP_EXPORT void setCharacterType(general* character, int typeID, int subFaction, int factionDipNum) { DWORD adrFunc = 0x0; @@ -167,7 +167,7 @@ namespace fastFuncts return year; } - NOINLINE EOP_EXPORT void setHeir(generalCharacterictics* gen, bool isJustSet) + NOINLINE EOP_EXPORT void setHeir(namedCharacter* gen, bool isJustSet) { factionStruct* fac = gen->faction; if (isJustSet == true) @@ -491,7 +491,7 @@ namespace fastFuncts return; } - NOINLINE EOP_EXPORT void addTrait(generalCharacterictics* character, const char* traitName, int traitLevel) + NOINLINE EOP_EXPORT void addTrait(namedCharacter* character, const char* traitName, int traitLevel) { DWORD adrFunc = 0; @@ -552,7 +552,7 @@ namespace fastFuncts } } - NOINLINE EOP_EXPORT void removeTrait(generalCharacterictics* character, const char* traitName) + NOINLINE EOP_EXPORT void removeTrait(namedCharacter* character, const char* traitName) { DWORD adrFunc = 0; @@ -610,7 +610,7 @@ namespace fastFuncts } } - EOP_EXPORT int addAnchillary(generalCharacterictics* character, anchillary* anch) + EOP_EXPORT int addAnchillary(namedCharacter* character, anchillary* anch) { if (character == nullptr || anch == nullptr)return 0; @@ -637,7 +637,7 @@ namespace fastFuncts return retr; } - EOP_EXPORT void removeAnchillary(generalCharacterictics* character, anchillary* anch) + EOP_EXPORT void removeAnchillary(namedCharacter* character, anchillary* anch) { if (character == nullptr || anch == nullptr)return; @@ -1239,7 +1239,7 @@ namespace fastFuncts push edi push ebp mov ebp, facOffset - lea ecx, [ebp+0x21608] + lea ecx, [ebp + 0x21608] pop ebp mov eax, funcC call eax diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.h b/M2TWEOP Code/M2TWEOP library/fastFuncts.h index 7a9e97b69..290854e05 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.h +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.h @@ -10,14 +10,14 @@ namespace fastFuncts { - NOINLINE EOP_EXPORT void setSettlementOwner(settlementStruct*sett, factionStruct newOwner); + NOINLINE EOP_EXPORT void setSettlementOwner(settlementStruct* sett, factionStruct newOwner); - NOINLINE EOP_EXPORT void GetGameTileCoordsWithCursor(int&x,int&y); - NOINLINE EOP_EXPORT void ViewTacticalMap(int x,int y); + NOINLINE EOP_EXPORT void GetGameTileCoordsWithCursor(int& x, int& y); + NOINLINE EOP_EXPORT void ViewTacticalMap(int x, int y); NOINLINE EOP_EXPORT bool IsStratMap(); - NOINLINE EOP_EXPORT void setCharacterType(general*character, int typeID,int subFaction,int factionDipNum); - NOINLINE EOP_EXPORT UINT32 getTileRegionID(int x,int y); + NOINLINE EOP_EXPORT void setCharacterType(general* character, int typeID, int subFaction, int factionDipNum); + NOINLINE EOP_EXPORT UINT32 getTileRegionID(int x, int y); NOINLINE EOP_EXPORT regionStruct* getRegionByID(UINT32 regionID); NOINLINE EOP_EXPORT factionStruct* getRegionOwner(int regionID); @@ -26,7 +26,7 @@ namespace fastFuncts NOINLINE EOP_EXPORT UINT32 getYear(); //set character as heir - NOINLINE EOP_EXPORT void setHeir(generalCharacterictics* gen,bool isJustSet); + NOINLINE EOP_EXPORT void setHeir(namedCharacter* gen, bool isJustSet); //count of factions in game NOINLINE EOP_EXPORT UINT32 getFactionsCount(); @@ -67,25 +67,25 @@ namespace fastFuncts //teleport character - NOINLINE EOP_EXPORT void teleportCharacter(general* gen,int x, int y); + NOINLINE EOP_EXPORT void teleportCharacter(general* gen, int x, int y); //add trait to character - NOINLINE EOP_EXPORT void addTrait(generalCharacterictics* character, const char* traitName,int traitLevel); - NOINLINE EOP_EXPORT void removeTrait(generalCharacterictics* character, const char* traitName); + NOINLINE EOP_EXPORT void addTrait(namedCharacter* character, const char* traitName, int traitLevel); + NOINLINE EOP_EXPORT void removeTrait(namedCharacter* character, const char* traitName); //add anchillary to character - NOINLINE EOP_EXPORT int addAnchillary(generalCharacterictics* character, anchillary* anch); + NOINLINE EOP_EXPORT int addAnchillary(namedCharacter* character, anchillary* anch); //remove anchillary from character - NOINLINE EOP_EXPORT void removeAnchillary(generalCharacterictics* character, anchillary* anch); + NOINLINE EOP_EXPORT void removeAnchillary(namedCharacter* character, anchillary* anch); //find anchillary in anch list NOINLINE EOP_EXPORT anchillary* findAnchillary(char* anchName); //edit unit characteristics NOINLINE EOP_EXPORT void setUnitParams(unit* un, int count, int exp, int armor, int weap); - NOINLINE EOP_EXPORT void setSoldiersCount(unit* un,int count); - NOINLINE EOP_EXPORT void setSoldiersCountAndExp(unit* un,int count, int exp); - NOINLINE EOP_EXPORT void setUnitMovepoints(unit* un,float movepoints); + NOINLINE EOP_EXPORT void setSoldiersCount(unit* un, int count); + NOINLINE EOP_EXPORT void setSoldiersCountAndExp(unit* un, int count, int exp); + NOINLINE EOP_EXPORT void setUnitMovepoints(unit* un, float movepoints); //kills NOINLINE EOP_EXPORT void killUnit(unit* un); @@ -94,13 +94,13 @@ namespace fastFuncts NOINLINE EOP_EXPORT void destroyBuilding(settlementStruct* sett, const char* typeName, bool isReturnMoney); NOINLINE EOP_EXPORT void createBuilding(settlementStruct* sett, const char* building_level_id); - NOINLINE EOP_EXPORT general* createCharacter(const char*type,factionStruct*fac,int age, const char*name, const char*name2,int subFaction, const char*portrait,int x,int y); - + NOINLINE EOP_EXPORT general* createCharacter(const char* type, factionStruct* fac, int age, const char* name, const char* name2, int subFaction, const char* portrait, int x, int y); + //very very technical func - NOINLINE EOP_EXPORT general* createCharacterWithoutSpawning(const char*type,factionStruct*fac,int age, const char*name, const char*name2,int subFaction, const char*portrait,int x,int y); + NOINLINE EOP_EXPORT general* createCharacterWithoutSpawning(const char* type, factionStruct* fac, int age, const char* name, const char* name2, int subFaction, const char* portrait, int x, int y); - NOINLINE EOP_EXPORT stackStruct* createArmy(general*character); - NOINLINE EOP_EXPORT stackStruct* createArmyInSettlement(settlementStruct*sett); + NOINLINE EOP_EXPORT stackStruct* createArmy(general* character); + NOINLINE EOP_EXPORT stackStruct* createArmyInSettlement(settlementStruct* sett); //facNum - dipnum @@ -109,7 +109,7 @@ namespace fastFuncts NOINLINE EOP_EXPORT unit* createUnitEDB(int edb, int regionID, int facNum, int exp, int arm, int weap); NOINLINE EOP_EXPORT int addUnitToArmy(stackStruct* army, unit* un); - NOINLINE EOP_EXPORT void setBodyguard(general*gen,unit* un); + NOINLINE EOP_EXPORT void setBodyguard(general* gen, unit* un); NOINLINE EOP_EXPORT ModelDbEntry* findBattleModel(const char* modelName); @@ -123,7 +123,7 @@ namespace fastFuncts NOINLINE EOP_EXPORT void autoResolve(); - NOINLINE EOP_EXPORT bool callGameConsoleCommand(const char* name, const char* arg,char*errorBuffer); + NOINLINE EOP_EXPORT bool callGameConsoleCommand(const char* name, const char* arg, char* errorBuffer); NOINLINE EOP_EXPORT bool useButton(const char* buttonName); diff --git a/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.cpp b/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.cpp index dbda7e15f..a87664a93 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.cpp @@ -28,7 +28,7 @@ namespace fastFunctsHelpers return -1; } - EduEntry* getEduEntryByName(const char* type) + eduEntry* getEduEntryByName(const char* type) { eduEntryes* EDB = reinterpret_cast(dataOffsets::offsets.unitTypesStart - 4); @@ -42,7 +42,7 @@ namespace fastFunctsHelpers } return nullptr; } - EduEntry* getEDUEntryById(int id) + eduEntry* getEDUEntryById(int id) { eduEntryes* EDB = reinterpret_cast(dataOffsets::offsets.unitTypesStart - 4); diff --git a/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.h b/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.h index 4ec7b2088..24f00fc87 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.h +++ b/M2TWEOP Code/M2TWEOP library/fastFunctsHelpers.h @@ -14,8 +14,8 @@ namespace fastFunctsHelpers NOINLINE EOP_EXPORT void setCryptedString(char** targetS, const char* newS); int getEduIndex(const char* type); - EduEntry* getEduEntryByName(const char* type); - EduEntry* getEDUEntryById(int id); + eduEntry* getEduEntryByName(const char* type); + eduEntry* getEDUEntryById(int id); char** makeCryptedString(const char* string); diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp index ed3428fa0..e241459a6 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp @@ -81,7 +81,7 @@ int __fastcall patchesForGame::onfortificationlevelS(settlementStruct* settlemen } return selectedLevel;//use old thing } -char* __fastcall patchesForGame::onSaveEDUStringS(EduEntry* eduEntry) +char* __fastcall patchesForGame::onSaveEDUStringS(eduEntry* eduEntry) { char* retName = eduThings::getEopNameOfEduEntry(eduEntry); if (retName == nullptr) @@ -124,14 +124,14 @@ int __fastcall patchesForGame::OnCreateMercUnitCheck(char** entryName, int eduin return eduindex; } -EduEntry* __fastcall patchesForGame::OnCreateMercUnit(char** entryName, EduEntry* entry) +eduEntry* __fastcall patchesForGame::OnCreateMercUnit(char** entryName, eduEntry* entry) { DWORD entryAddr = (DWORD)entry; DWORD mercEOPValue = codes::offsets.mercEOPValue;//this is some weird address made by subtracting a value from edu start or something I dont really remember but its necesarry if (entryAddr == mercEOPValue) { int* eduindex = eduThings::tryFindDataEopEduIndex(*entryName); - EduEntry* eopentry = eduThings::getEopEduEntry(*eduindex); + eduEntry* eopentry = eduThings::getEopEduEntry(*eduindex); return eopentry; } @@ -421,7 +421,7 @@ void __stdcall patchesForGame::onBattleStratScreen() } -void __fastcall patchesForGame::onEvent(DWORD** vTab) +void __fastcall patchesForGame::onEvent(DWORD** vTab, DWORD arg2) { #if defined TESTPATCHES ofstream f1("logs\\TESTPATCHES.log", ios::app); @@ -429,7 +429,7 @@ void __fastcall patchesForGame::onEvent(DWORD** vTab) f1 << "onEvent" << endl; f1.close(); #endif - plugins::onEvent(vTab); + plugins::onEvent(vTab, arg2); } void __fastcall patchesForGame::onLoadSaveFile(UNICODE_STRING**& savePath) diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.h b/M2TWEOP Code/M2TWEOP library/patchesForGame.h index 9ec280c9a..b1beb56dc 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.h +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.h @@ -11,10 +11,10 @@ class patchesForGame static void __fastcall OnLoadSettlementWorldpkgdesc(worldRecord* selectedRecord); static int __fastcall onfortificationlevelS(settlementStruct* settlement, bool* isCastle); - static char* __fastcall onSaveEDUStringS(EduEntry* eduEntry); + static char* __fastcall onSaveEDUStringS(eduEntry* eduEntry); static int __fastcall onCreateUnit(int* edbIndex, int** edb, char** entryName); static int __fastcall OnCreateMercUnitCheck(char** entryName, int eduindex); - static EduEntry* __fastcall OnCreateMercUnit(char** entryName, EduEntry* entry); + static eduEntry* __fastcall OnCreateMercUnit(char** entryName, eduEntry* entry); static const char* __fastcall onQuickSave(); static const char* __fastcall onAutoSave(); @@ -64,7 +64,7 @@ class patchesForGame //parse events in this functions - static void __fastcall onEvent(DWORD** vTab); + static void __fastcall onEvent(DWORD** vTab, DWORD arg2); //load game static void __fastcall onLoadSaveFile(UNICODE_STRING**& savePath); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.cpp b/M2TWEOP Code/M2TWEOP library/plugins.cpp index e7dab52b1..e4a6d3503 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -36,7 +36,7 @@ int ReplaceByte(int index, int value, char replaceByte) { return (value & ~(0xFF << (index * 8))) | (replaceByte << (index * 8)); } -void __fastcall plugins::onEvent(DWORD** vTab) +void __fastcall plugins::onEvent(DWORD** vTab, DWORD arg2) { DWORD adr = (*vTab)[43]; char* event = nullptr; @@ -47,8 +47,15 @@ void __fastcall plugins::onEvent(DWORD** vTab) mov event, eax } + DWORD* eventAddr = vTab[0]; + if (event == nullptr)return; + for (plugin* pl : pluginsCfg.plugins) + { + (*(*pl->onEventWrapper))(eventAddr, vTab, arg2); + } + if (strcmp(event, "ScrollOpened") == 0) { char* str = reinterpret_cast(vTab[1]); @@ -70,7 +77,7 @@ void __fastcall plugins::onEvent(DWORD** vTab) /*if (strcmp(event, "CharacterSelected") == 0) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); stackStruct* army = prs->gen->armyLeaded; if (army) @@ -108,113 +115,13 @@ void __fastcall plugins::onEvent(DWORD** vTab) for (plugin* pl : pluginsCfg.plugins) { - if (compareEvent(event, &pl->onFactionTurnStart.stringAdr, pl->onFactionTurnStart.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFactionTurnStart))(fac); - } - else if (compareEvent(event, &pl->onGeneralDevastatesTile.stringAdr, pl->onGeneralDevastatesTile.strCmp)) - { - generalCharacterictics* gen = reinterpret_cast(vTab[1]); - (*(*pl->onGeneralDevastatesTile))(gen); - } - else if (compareEvent(event, &pl->onPreFactionTurnStart.stringAdr, pl->onPreFactionTurnStart.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onPreFactionTurnStart))(fac); - } - else if (compareEvent(event, &pl->onFactionTurnEnd.stringAdr, pl->onFactionTurnEnd.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFactionTurnEnd))(fac); - } - else if (compareEvent(event, &pl->onFactionNewCapital.stringAdr, pl->onFactionNewCapital.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFactionNewCapital))(fac); - } - else if (compareEvent(event, &pl->onFactionWarDeclared.stringAdr, pl->onFactionWarDeclared.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onFactionWarDeclared))(fac, fac2); - } - else if (compareEvent(event, &pl->onFactionAllianceDeclared.stringAdr, pl->onFactionAllianceDeclared.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onFactionAllianceDeclared))(fac, fac2); - } - else if (compareEvent(event, &pl->onFactionTradeAgreementMade.stringAdr, pl->onFactionTradeAgreementMade.strCmp)) + if (compareEvent(event, &pl->onCharacterSelected.stringAdr, pl->onCharacterSelected.strCmp)) { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onFactionTradeAgreementMade))(fac, fac2); - } - else if (compareEvent(event, &pl->onFactionBreakAlliance.stringAdr, pl->onFactionBreakAlliance.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onFactionBreakAlliance))(fac, fac2); - } - else if (compareEvent(event, &pl->onGiveMoney.stringAdr, pl->onGiveMoney.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - float money; - techFuncs::Read((DWORD)&vTab[3], &money, 4); - (*(*pl->onGiveMoney))(fac, fac2, money); - } - else if (compareEvent(event, &pl->onUpdateAttitude.stringAdr, pl->onUpdateAttitude.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onUpdateAttitude))(fac, fac2); - } - else if (compareEvent(event, &pl->onDemeanour.stringAdr, pl->onDemeanour.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - float amount; - techFuncs::Read((DWORD)&vTab[3], &amount, 4); - (*(*pl->onDemeanour))(fac, fac2, amount); - } - else if (compareEvent(event, &pl->onCharacterSelected.stringAdr, pl->onCharacterSelected.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); (*(*pl->onCharacterSelected))(prs); - } - else if (compareEvent(event, &pl->onGeneralAssaultsGeneral.stringAdr, pl->onGeneralAssaultsGeneral.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - generalCharacterictics* prs2 = reinterpret_cast(vTab[2]); - - - (*(*pl->onGeneralAssaultsGeneral))(prs, prs2); - } - else if (compareEvent(event, &pl->onGeneralAssaultsResidence.stringAdr, pl->onGeneralAssaultsResidence.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - settlementStruct* setl = reinterpret_cast(vTab[2]); - fortStruct* frt = fastFuncts::findFort(setl->xCoord, setl->yCoord); - - if (frt != nullptr)setl = nullptr; - - (*(*pl->onGeneralAssaultsResidence))(prs, setl, frt); - } - else if (compareEvent(event, &pl->onGeneralCaptureSettlement.stringAdr, pl->onGeneralCaptureSettlement.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - settlementStruct* setl = reinterpret_cast(vTab[2]); - (*(*pl->onGeneralCaptureSettlement))(prs, setl); - } - else if (compareEvent(event, &pl->onGeneralCaptureResidence.stringAdr, pl->onGeneralCaptureResidence.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onGeneralCaptureResidence))(prs); } else if (compareEvent(event, &pl->onSiegeEquipmentCompleted.stringAdr, pl->onSiegeEquipmentCompleted.strCmp)) { @@ -224,11 +131,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) if (frt != nullptr)setl = nullptr; (*(*pl->onSiegeEquipmentCompleted))(setl, frt); } - else if (compareEvent(event, &pl->onPostBattle.stringAdr, pl->onPostBattle.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onPostBattle))(prs); - } else if (compareEvent(event, &pl->onSettlementSelected.stringAdr, pl->onSettlementSelected.strCmp)) { settlementStruct* setl = reinterpret_cast(vTab[1]); @@ -264,19 +166,19 @@ void __fastcall plugins::onEvent(DWORD** vTab) } else if (compareEvent(event, &pl->onOccupySettlement.stringAdr, pl->onOccupySettlement.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); factionStruct* fac = reinterpret_cast(vTab[2]); (*(*pl->onOccupySettlement))(prs, fac); } else if (compareEvent(event, &pl->onExterminatePopulation.stringAdr, pl->onExterminatePopulation.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); factionStruct* fac = reinterpret_cast(vTab[2]); (*(*pl->onExterminatePopulation))(prs, fac); } else if (compareEvent(event, &pl->onSackSettlement.stringAdr, pl->onSackSettlement.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); factionStruct* fac = reinterpret_cast(vTab[2]); (*(*pl->onSackSettlement))(prs, fac); } @@ -298,81 +200,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) settlementStruct* sett = reinterpret_cast(vTab[2]); (*(*pl->onBuildingCompleted))(fac, sett); } - else if (compareEvent(event, &pl->onEventCounter.stringAdr, pl->onEventCounter.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onEventCounter))(str); - } - else if (compareEvent(event, &pl->onPopeAcceptsCrusadeTarget.stringAdr, pl->onPopeAcceptsCrusadeTarget.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onPopeAcceptsCrusadeTarget))(crusade, sett); - } - else if (compareEvent(event, &pl->onCrusadeCalled.stringAdr, pl->onCrusadeCalled.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onCrusadeCalled))(crusade, sett); - } - else if (compareEvent(event, &pl->onCrusadeEnds.stringAdr, pl->onCrusadeEnds.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onCrusadeEnds))(crusade, sett); - } - else if (compareEvent(event, &pl->onPopeRejectsCrusadeTarget.stringAdr, pl->onPopeRejectsCrusadeTarget.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onPopeRejectsCrusadeTarget))(crusade, sett); - } - else if (compareEvent(event, &pl->onArmyTakesCrusadeTarget.stringAdr, pl->onArmyTakesCrusadeTarget.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - stackStruct* army = reinterpret_cast(vTab[3]); - (*(*pl->onArmyTakesCrusadeTarget))(crusade, sett, army); - } - else if (compareEvent(event, &pl->onFactionExcommunicated.stringAdr, pl->onFactionExcommunicated.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFactionExcommunicated))(fac); - } - else if (compareEvent(event, &pl->onDisaster.stringAdr, pl->onDisaster.strCmp)) - { - int eType = (int)vTab[1]; - (*(*pl->onDisaster))(eType); - } - else if (compareEvent(event, &pl->onHordeFormed.stringAdr, pl->onHordeFormed.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onHordeFormed))(fac); - } - else if (compareEvent(event, &pl->onInquisitorAppointed.stringAdr, pl->onInquisitorAppointed.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[3]); - (*(*pl->onInquisitorAppointed))(fac, sett); - } - else if (compareEvent(event, &pl->onUnitsDesertCrusade.stringAdr, pl->onUnitsDesertCrusade.strCmp)) - { - void* crusade = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - factionStruct* fac = reinterpret_cast(vTab[3]); - (*(*pl->onUnitsDesertCrusade))(crusade, sett, fac); - } - else if (compareEvent(event, &pl->onPopeElected.stringAdr, pl->onPopeElected.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - (*(*pl->onPopeElected))(fac, fac2); - } - else if (compareEvent(event, &pl->onVotedForPope.stringAdr, pl->onVotedForPope.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onVotedForPope))(fac); - } else if (compareEvent(event, &pl->onAssassinCaughtAttackingPope.stringAdr, pl->onAssassinCaughtAttackingPope.strCmp)) { factionStruct* fac = reinterpret_cast(vTab[1]); @@ -385,12 +212,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) if (*str == 0)str = nullptr; (*(*pl->onAddedToTrainingQueue))(sett, str); } - else if (compareEvent(event, &pl->onUnitDisbanded.stringAdr, pl->onUnitDisbanded.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - unit* un = reinterpret_cast(vTab[2]); - (*(*pl->onUnitDisbanded))(fac, un); - } else if (compareEvent(event, &pl->onUnitTrained.stringAdr, pl->onUnitTrained.strCmp)) { factionStruct* fac = reinterpret_cast(vTab[1]); @@ -400,20 +221,11 @@ void __fastcall plugins::onEvent(DWORD** vTab) } else if (compareEvent(event, &pl->onAgentCreated.stringAdr, pl->onAgentCreated.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); int prsType = (int)vTab[2]; settlementStruct* sett = reinterpret_cast(vTab[3]); (*(*pl->onAgentCreated))(prs, prsType, sett); } - else if (compareEvent(event, &pl->onObjSeen.stringAdr, pl->onObjSeen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - factionStruct* fac2 = reinterpret_cast(vTab[2]); - int xC = (int)vTab[3]; - int yC = (int)vTab[4]; - - (*(*pl->onObjSeen))(fac, fac2, xC, yC); - } else if (compareEvent(event, &pl->onSettlementPanelOpen.stringAdr, pl->onSettlementPanelOpen.strCmp)) { settlementStruct* sett = reinterpret_cast(vTab[1]); @@ -454,7 +266,7 @@ void __fastcall plugins::onEvent(DWORD** vTab) } else if (compareEvent(event, &pl->onCharacterPanelOpen.stringAdr, pl->onCharacterPanelOpen.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); (*(*pl->onCharacterPanelOpen))(prs); } else if (compareEvent(event, &pl->onTradePanelOpen.stringAdr, pl->onTradePanelOpen.strCmp)) @@ -470,7 +282,7 @@ void __fastcall plugins::onEvent(DWORD** vTab) else if (compareEvent(event, &pl->onRequestTrainingAdvice.stringAdr, pl->onRequestTrainingAdvice.strCmp)) { settlementStruct* sett = reinterpret_cast(vTab[1]); - EduEntry* edEnt = reinterpret_cast(vTab[2]); + eduEntry* edEnt = reinterpret_cast(vTab[2]); (*(*pl->onRequestTrainingAdvice))(sett, edEnt); } else if (compareEvent(event, &pl->onMessageOpen.stringAdr, pl->onMessageOpen.strCmp)) @@ -490,13 +302,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) int some = (int)vTab[1]; (*(*pl->onMessageClosed))(some); } - else if (compareEvent(event, &pl->onTileSeen.stringAdr, pl->onTileSeen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - int x = (int)vTab[2]; - int y = (int)vTab[3]; - (*(*pl->onTileSeen))(fac, x, y); - } else if (compareEvent(event, &pl->onButtonPressed.stringAdr, pl->onButtonPressed.strCmp)) { char* str = reinterpret_cast(vTab[1]); @@ -536,14 +341,9 @@ void __fastcall plugins::onEvent(DWORD** vTab) char* str = reinterpret_cast(*vTab[1]); (*(*pl->onScrollAdviceRequested))(str); } - else if (compareEvent(event, &pl->onUngarrisonedFort.stringAdr, pl->onUngarrisonedFort.strCmp)) - { - fortStruct* str = reinterpret_cast(vTab[1]); - (*(*pl->onUngarrisonedFort))(str); - } else if (compareEvent(event, &pl->onMultiTurnMove.stringAdr, pl->onMultiTurnMove.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); /*if (prs->gen->armyLeaded) { string str = "Mailed Knights"; @@ -554,23 +354,11 @@ void __fastcall plugins::onEvent(DWORD** vTab) }*/ (*(*pl->onMultiTurnMove))(prs); } - else if (compareEvent(event, &pl->onGameReloaded.stringAdr, pl->onGameReloaded.strCmp)) - { - int some = (int)vTab[1]; - (*(*pl->onGameReloaded))(some); - } else if (compareEvent(event, &pl->onCollegeOfCardinalsPanelOpen.stringAdr, pl->onCollegeOfCardinalsPanelOpen.strCmp)) { void* colleg = reinterpret_cast(vTab[1]); (*(*pl->onCollegeOfCardinalsPanelOpen))(colleg); } - else if (compareEvent(event, &pl->onTransgression.stringAdr, pl->onTransgression.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - factionStruct* fac2 = reinterpret_cast(vTab[4]); - (*(*pl->onTransgression))(fac, str, fac2); - } else if (compareEvent(event, &pl->onGuildUpgraded.stringAdr, pl->onGuildUpgraded.strCmp)) { settlementStruct* sett = reinterpret_cast(vTab[1]); @@ -583,34 +371,9 @@ void __fastcall plugins::onEvent(DWORD** vTab) unsigned char guildID = (((BYTE*)vTab)[8]); (*(*pl->onGuildDestroyed))(sett, guildID); } - else if (compareEvent(event, &pl->onBrotherAdopted.stringAdr, pl->onBrotherAdopted.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onBrotherAdopted))(prs); - } - else if (compareEvent(event, &pl->onBirth.stringAdr, pl->onBirth.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onBirth))(prs); - } - else if (compareEvent(event, &pl->onCharacterComesOfAge.stringAdr, pl->onCharacterComesOfAge.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onCharacterComesOfAge))(prs); - } - else if (compareEvent(event, &pl->onCharacterMarries.stringAdr, pl->onCharacterMarries.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onCharacterMarries))(prs); - } - else if (compareEvent(event, &pl->onCharacterBecomesAFather.stringAdr, pl->onCharacterBecomesAFather.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onCharacterBecomesAFather))(prs); - } else if (compareEvent(event, &pl->onNewAdmiralCreated.stringAdr, pl->onNewAdmiralCreated.strCmp)) { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); + namedCharacter* prs = reinterpret_cast(vTab[1]); settlementStruct* sett = reinterpret_cast(vTab[2]); (*(*pl->onNewAdmiralCreated))(prs, sett); } @@ -619,21 +382,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) char* str = reinterpret_cast(vTab[1]); (*(*pl->onShortcutTriggered))(str); } - else if (compareEvent(event, &pl->onCharacterMarriesPrincess.stringAdr, pl->onCharacterMarriesPrincess.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onCharacterMarriesPrincess))(prs); - } - else if (compareEvent(event, &pl->onBecomesFactionLeader.stringAdr, pl->onBecomesFactionLeader.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onBecomesFactionLeader))(prs); - } - else if (compareEvent(event, &pl->onBecomesFactionHeir.stringAdr, pl->onBecomesFactionHeir.strCmp)) - { - generalCharacterictics* prs = reinterpret_cast(vTab[1]); - (*(*pl->onBecomesFactionHeir))(prs); - } } } @@ -981,68 +729,9 @@ int plugin::init(string* nameP) fName = "onChangeTurnNum"; onChangeTurnNum.Load(&plPath, &fName); - - //onPreFactionTurnStart - fName = "onPreFactionTurnStart"; - onPreFactionTurnStart.Load(&plPath, &fName); - onPreFactionTurnStart.strCmp = (*plugins::eventNames)[PreFactionTurnStartNumCode]; - - //onFactionTurnStart - fName = "onFactionTurnStart"; - onFactionTurnStart.Load(&plPath, &fName); - onFactionTurnStart.strCmp = (*plugins::eventNames)[FactionTurnStartCode]; - - //onGeneralDevastatesTile - fName = "onGeneralDevastatesTile"; - onGeneralDevastatesTile.Load(&plPath, &fName); - onGeneralDevastatesTile.strCmp = (*plugins::eventNames)[GeneralDevastatesTileCode]; - - //onFactionTurnEnd - fName = "onFactionTurnEnd"; - onFactionTurnEnd.Load(&plPath, &fName); - onFactionTurnEnd.strCmp = (*plugins::eventNames)[FactionTurnEndCode]; - - //onFactionNewCapital - fName = "onFactionNewCapital"; - onFactionNewCapital.Load(&plPath, &fName); - onFactionNewCapital.strCmp = (*plugins::eventNames)[FactionNewCapitalCode]; - - //onFactionWarDeclared - fName = "onFactionWarDeclared"; - onFactionWarDeclared.Load(&plPath, &fName); - onFactionWarDeclared.strCmp = (*plugins::eventNames)[FactionWarDeclaredCode]; - - //onFactionAllianceDeclared - fName = "onFactionAllianceDeclared"; - onFactionAllianceDeclared.Load(&plPath, &fName); - onFactionAllianceDeclared.strCmp = (*plugins::eventNames)[FactionAllianceDeclaredCode]; - - //onFactionTradeAgreementMade - fName = "onFactionTradeAgreementMade"; - onFactionTradeAgreementMade.Load(&plPath, &fName); - onFactionTradeAgreementMade.strCmp = (*plugins::eventNames)[FactionTradeAgreementMadeCode]; - - //onFactionBreakAlliance - fName = "onFactionBreakAlliance"; - onFactionBreakAlliance.Load(&plPath, &fName); - onFactionBreakAlliance.strCmp = (*plugins::eventNames)[FactionBreakAllianceCode]; - - - //onGiveMoney - fName = "onGiveMoney"; - onGiveMoney.Load(&plPath, &fName); - onGiveMoney.strCmp = (*plugins::eventNames)[GiveMoneyCode]; - - - //onUpdateAttitude - fName = "onUpdateAttitude"; - onUpdateAttitude.Load(&plPath, &fName); - onUpdateAttitude.strCmp = (*plugins::eventNames)[UpdateAttitudeCode]; - - //onDemeanour - fName = "onDemeanour"; - onDemeanour.Load(&plPath, &fName); - onDemeanour.strCmp = (*plugins::eventNames)[DemeanourCode]; + //onEvent + fName = "onEventWrapper"; + onEventWrapper.Load(&plPath, &fName); //onCharacterSelected @@ -1051,38 +740,12 @@ int plugin::init(string* nameP) onCharacterSelected.strCmp = (*plugins::eventNames)[CharacterSelectedCode]; - //onGeneralAssaultsGeneral - fName = "onGeneralAssaultsGeneral"; - onGeneralAssaultsGeneral.Load(&plPath, &fName); - onGeneralAssaultsGeneral.strCmp = (*plugins::eventNames)[GeneralAssaultsGeneralCode]; - - //onGeneralAssaultsResidence - fName = "onGeneralAssaultsResidence"; - onGeneralAssaultsResidence.Load(&plPath, &fName); - onGeneralAssaultsResidence.strCmp = (*plugins::eventNames)[GeneralAssaultsResidenceCode]; - - //onGeneralCaptureSettlement - fName = "onGeneralCaptureSettlement"; - onGeneralCaptureSettlement.Load(&plPath, &fName); - onGeneralCaptureSettlement.strCmp = (*plugins::eventNames)[GeneralCaptureSettlementCode]; - - //onGeneralCaptureResidence - fName = "onGeneralCaptureResidence"; - onGeneralCaptureResidence.Load(&plPath, &fName); - onGeneralCaptureResidence.strCmp = (*plugins::eventNames)[GeneralCaptureResidenceCode]; - - //onSiegeEquipmentCompleted fName = "onSiegeEquipmentCompleted"; onSiegeEquipmentCompleted.Load(&plPath, &fName); onSiegeEquipmentCompleted.strCmp = (*plugins::eventNames)[SiegeEquipmentCompletedCode]; - //onPostBattle - fName = "onPostBattle"; - onPostBattle.Load(&plPath, &fName); - onPostBattle.strCmp = (*plugins::eventNames)[PostBattleCode]; - //onSettlementSelected fName = "onSettlementSelected"; onSettlementSelected.Load(&plPath, &fName); @@ -1148,73 +811,6 @@ int plugin::init(string* nameP) onBuildingCompleted.Load(&plPath, &fName); onBuildingCompleted.strCmp = (*plugins::eventNames)[BuildingCompletedCode]; - - //onEventCounter - fName = "onEventCounter"; - onEventCounter.Load(&plPath, &fName); - onEventCounter.strCmp = (*plugins::eventNames)[EventCounterCode]; - - //onPopeAcceptsCrusadeTarget - fName = "onPopeAcceptsCrusadeTarget"; - onPopeAcceptsCrusadeTarget.Load(&plPath, &fName); - onPopeAcceptsCrusadeTarget.strCmp = (*plugins::eventNames)[PopeAcceptsCrusadeTargetCode]; - - //onCrusadeCalled - fName = "onCrusadeCalled"; - onCrusadeCalled.Load(&plPath, &fName); - onCrusadeCalled.strCmp = (*plugins::eventNames)[CrusadeCalledCode]; - - //onCrusadeEnds - fName = "onCrusadeEnds"; - onCrusadeEnds.Load(&plPath, &fName); - onCrusadeEnds.strCmp = (*plugins::eventNames)[CrusadeEndsCode]; - - //onPopeRejectsCrusadeTarget - fName = "onPopeRejectsCrusadeTarget"; - onPopeRejectsCrusadeTarget.Load(&plPath, &fName); - onPopeRejectsCrusadeTarget.strCmp = (*plugins::eventNames)[PopeRejectsCrusadeTargetCode]; - - //onArmyTakesCrusadeTarget - fName = "onArmyTakesCrusadeTarget"; - onArmyTakesCrusadeTarget.Load(&plPath, &fName); - onArmyTakesCrusadeTarget.strCmp = (*plugins::eventNames)[ArmyTakesCrusadeTargetCode]; - - //onFactionExcommunicated - fName = "onFactionExcommunicated"; - onFactionExcommunicated.Load(&plPath, &fName); - onFactionExcommunicated.strCmp = (*plugins::eventNames)[FactionExcommunicatedCode]; - - //onDisaster - fName = "onDisaster"; - onDisaster.Load(&plPath, &fName); - onDisaster.strCmp = (*plugins::eventNames)[DisasterCode]; - - //onHordeFormed - fName = "onHordeFormed"; - onHordeFormed.Load(&plPath, &fName); - onHordeFormed.strCmp = (*plugins::eventNames)[HordeFormedCode]; - - //onInquisitorAppointed - fName = "onInquisitorAppointed"; - onInquisitorAppointed.Load(&plPath, &fName); - onInquisitorAppointed.strCmp = (*plugins::eventNames)[InquisitorAppointedCode]; - - //onUnitsDesertCrusade - fName = "onUnitsDesertCrusade"; - onUnitsDesertCrusade.Load(&plPath, &fName); - onUnitsDesertCrusade.strCmp = (*plugins::eventNames)[UnitsDesertCrusadeCode]; - - - //onPopeElected - fName = "onPopeElected"; - onPopeElected.Load(&plPath, &fName); - onPopeElected.strCmp = (*plugins::eventNames)[PopeElectedCode]; - - //onVotedForPope - fName = "onVotedForPope"; - onVotedForPope.Load(&plPath, &fName); - onVotedForPope.strCmp = (*plugins::eventNames)[VotedForPopeCode]; - //onAssassinCaughtAttackingPope fName = "onAssassinCaughtAttackingPope"; onAssassinCaughtAttackingPope.Load(&plPath, &fName); @@ -1225,12 +821,6 @@ int plugin::init(string* nameP) onAddedToTrainingQueue.Load(&plPath, &fName); onAddedToTrainingQueue.strCmp = (*plugins::eventNames)[AddedToTrainingQueueCode]; - - //onUnitDisbanded - fName = "onUnitDisbanded"; - onUnitDisbanded.Load(&plPath, &fName); - onUnitDisbanded.strCmp = (*plugins::eventNames)[UnitDisbandedCode]; - //onUnitTrained fName = "onUnitTrained"; onUnitTrained.Load(&plPath, &fName); @@ -1242,11 +832,6 @@ int plugin::init(string* nameP) onAgentCreated.Load(&plPath, &fName); onAgentCreated.strCmp = (*plugins::eventNames)[AgentCreatedCode]; - //onObjSeen - fName = "onObjSeen"; - onObjSeen.Load(&plPath, &fName); - onObjSeen.strCmp = (*plugins::eventNames)[ObjSeenCode]; - //onSettlementPanelOpen fName = "onSettlementPanelOpen"; onSettlementPanelOpen.Load(&plPath, &fName); @@ -1322,11 +907,6 @@ int plugin::init(string* nameP) onMessageClosed.Load(&plPath, &fName); onMessageClosed.strCmp = (*plugins::eventNames)[MessageClosedCode]; - //onTileSeen - fName = "onTileSeen"; - onTileSeen.Load(&plPath, &fName); - onTileSeen.strCmp = (*plugins::eventNames)[TileSeenCode]; - //onButtonPressed fName = "onButtonPressed"; onButtonPressed.Load(&plPath, &fName); @@ -1367,30 +947,15 @@ int plugin::init(string* nameP) onScrollAdviceRequested.Load(&plPath, &fName); onScrollAdviceRequested.strCmp = (*plugins::eventNames)[ScrollAdviceRequestedCode]; - //onUngarrisonedFort - fName = "onUngarrisonedFort"; - onUngarrisonedFort.Load(&plPath, &fName); - onUngarrisonedFort.strCmp = (*plugins::eventNames)[UngarrisonedFortCode]; - //onMultiTurnMove fName = "onMultiTurnMove"; onMultiTurnMove.Load(&plPath, &fName); onMultiTurnMove.strCmp = (*plugins::eventNames)[MultiTurnMoveCode]; - //onGameReloaded - fName = "onGameReloaded"; - onGameReloaded.Load(&plPath, &fName); - onGameReloaded.strCmp = (*plugins::eventNames)[GameReloadedCode]; - //onCollegeOfCardinalsPanelOpen fName = "onCollegeOfCardinalsPanelOpen"; onCollegeOfCardinalsPanelOpen.Load(&plPath, &fName); - onCollegeOfCardinalsPanelOpen.strCmp = (*plugins::eventNames)[GameReloadedCode]; - - //onTransgression - fName = "onTransgression"; - onTransgression.Load(&plPath, &fName); - onTransgression.strCmp = (*plugins::eventNames)[TransgressionCode]; + onCollegeOfCardinalsPanelOpen.strCmp = (*plugins::eventNames)[CollegeOfCardinalsPanelOpenCode]; //onGuildUpgraded fName = "onGuildUpgraded"; @@ -1402,31 +967,6 @@ int plugin::init(string* nameP) onGuildDestroyed.Load(&plPath, &fName); onGuildDestroyed.strCmp = (*plugins::eventNames)[GuildDestroyedCode]; - //onBrotherAdopted - fName = "onBrotherAdopted"; - onBrotherAdopted.Load(&plPath, &fName); - onBrotherAdopted.strCmp = (*plugins::eventNames)[BrotherAdoptedCode]; - - //onBirth - fName = "onBirth"; - onBirth.Load(&plPath, &fName); - onBirth.strCmp = (*plugins::eventNames)[BirthCode]; - - //onCharacterComesOfAge - fName = "onCharacterComesOfAge"; - onCharacterComesOfAge.Load(&plPath, &fName); - onCharacterComesOfAge.strCmp = (*plugins::eventNames)[CharacterComesOfAgeCode]; - - //onCharacterMarries - fName = "onCharacterMarries"; - onCharacterMarries.Load(&plPath, &fName); - onCharacterMarries.strCmp = (*plugins::eventNames)[CharacterMarriesCode]; - - //onCharacterBecomesAFather - fName = "onCharacterBecomesAFather"; - onCharacterBecomesAFather.Load(&plPath, &fName); - onCharacterBecomesAFather.strCmp = (*plugins::eventNames)[CharacterBecomesAFatherCode]; - //onNewAdmiralCreated fName = "onNewAdmiralCreated"; onNewAdmiralCreated.Load(&plPath, &fName); @@ -1437,21 +977,6 @@ int plugin::init(string* nameP) onShortcutTriggered.Load(&plPath, &fName); onShortcutTriggered.strCmp = (*plugins::eventNames)[ShortcutTriggeredCode]; - //onCharacterMarriesPrincess - fName = "onCharacterMarriesPrincess"; - onCharacterMarriesPrincess.Load(&plPath, &fName); - onCharacterMarriesPrincess.strCmp = (*plugins::eventNames)[CharacterMarriesPrincessCode]; - - //onBecomesFactionLeader - fName = "onBecomesFactionLeader"; - onBecomesFactionLeader.Load(&plPath, &fName); - onBecomesFactionLeader.strCmp = (*plugins::eventNames)[BecomesFactionLeaderCode]; - - //onBecomesFactionHeir - fName = "onBecomesFactionHeir"; - onBecomesFactionHeir.Load(&plPath, &fName); - onBecomesFactionHeir.strCmp = (*plugins::eventNames)[BecomesFactionHeirCode]; - //drawOnEndScene fName = "drawOnEndScene"; drawOnEndScene.Load(&plPath, &fName); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.h b/M2TWEOP Code/M2TWEOP library/plugins.h index 754e1920e..199a76727 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.h +++ b/M2TWEOP Code/M2TWEOP library/plugins.h @@ -42,8 +42,10 @@ class ProcLoader } if (!(m_pProc = (T)::GetProcAddress((HMODULE)hModule, m_strNameProcedure.c_str()))) { + std::stringstream error2; + error2 << "Can't load function: " << m_strNameProcedure.c_str(); m_pProc = (T)emptyProc; - MessageBoxA(NULL, "Can`t load function", "Attention", NULL); + MessageBoxA(NULL, error2.str().c_str(), "Attention", NULL); return FALSE; } return TRUE; @@ -84,32 +86,12 @@ class plugin ProcLoader onChangeTurnNum; + ProcLoader onEventWrapper; - ProcLoader onPreFactionTurnStart; - ProcLoader onFactionTurnStart; - ProcLoader onGeneralDevastatesTile; - ProcLoader onFactionTurnEnd; - ProcLoader onFactionNewCapital; - ProcLoader onFactionWarDeclared; - ProcLoader onFactionAllianceDeclared; - ProcLoader onFactionTradeAgreementMade; - ProcLoader onFactionBreakAlliance; - - - ProcLoader onGiveMoney; - ProcLoader onUpdateAttitude; - ProcLoader onDemeanour; - - ProcLoader onCharacterSelected; - ProcLoader onMultiTurnMove; - ProcLoader onGeneralAssaultsGeneral; - - ProcLoader onGeneralAssaultsResidence; - ProcLoader onGeneralCaptureSettlement; - ProcLoader onGeneralCaptureResidence; + ProcLoader onCharacterSelected; + ProcLoader onMultiTurnMove; ProcLoader onSiegeEquipmentCompleted; - ProcLoader onPostBattle; ProcLoader onSettlementSelected; ProcLoader onSettlementUpgraded; @@ -118,45 +100,24 @@ class plugin ProcLoader onCityRiots; ProcLoader onUngarrisonedSettlement; - ProcLoader onUngarrisonedFort; ProcLoader onGiveSettlement; - ProcLoader onOccupySettlement; - ProcLoader onExterminatePopulation; - ProcLoader onSackSettlement; + ProcLoader onOccupySettlement; + ProcLoader onExterminatePopulation; + ProcLoader onSackSettlement; ProcLoader onAddedToBuildingQueue; ProcLoader onBuildingDestroyed; ProcLoader onBuildingCompleted; - - ProcLoader onEventCounter; - ProcLoader onPopeAcceptsCrusadeTarget; - ProcLoader onCrusadeCalled; - ProcLoader onCrusadeEnds; - ProcLoader onPopeRejectsCrusadeTarget; - ProcLoader onArmyTakesCrusadeTarget; - ProcLoader onUnitsDesertCrusade; - - ProcLoader onFactionExcommunicated; - - ProcLoader onDisaster; - - ProcLoader onHordeFormed; - ProcLoader onPopeElected; - ProcLoader onVotedForPope; ProcLoader onAssassinCaughtAttackingPope; ProcLoader onInquisitorAppointed; ProcLoader onAddedToTrainingQueue; - ProcLoader onUnitDisbanded; ProcLoader onUnitTrained; - ProcLoader onAgentCreated; - - ProcLoader onObjSeen; - ProcLoader onTileSeen; + ProcLoader onAgentCreated; ProcLoader onSettlementPanelOpen; @@ -168,10 +129,10 @@ class plugin ProcLoader onPreBattlePanelOpen; ProcLoader onNavalAutoResolvePanelOpen; - ProcLoader onCharacterPanelOpen; + ProcLoader onCharacterPanelOpen; ProcLoader onTradePanelOpen; ProcLoader onRequestBuildingAdvice; - ProcLoader onRequestTrainingAdvice; + ProcLoader onRequestTrainingAdvice; ProcLoader onMessageOpen; ProcLoader onIncomingMessage; @@ -189,26 +150,12 @@ class plugin ProcLoader onNavalPreBattleScrollAdviceRequested; ProcLoader onCollegeOfCardinalsPanelOpen; - - ProcLoader onGameReloaded; - - ProcLoader onTransgression; - ProcLoader onGuildUpgraded; ProcLoader onGuildDestroyed; - ProcLoader onBrotherAdopted; - ProcLoader onBirth; - ProcLoader onCharacterComesOfAge; - ProcLoader onCharacterMarries; - ProcLoader onCharacterBecomesAFather; - - ProcLoader onNewAdmiralCreated; + ProcLoader onNewAdmiralCreated; ProcLoader onShortcutTriggered; - ProcLoader onCharacterMarriesPrincess; - ProcLoader onBecomesFactionLeader; - ProcLoader onBecomesFactionHeir; ProcLoader drawOnEndScene; ProcLoader onReset; @@ -240,7 +187,7 @@ class plugins static void init(); - static void __fastcall onEvent(DWORD** vTab); + static void __fastcall onEvent(DWORD** vTab, DWORD arg2); //from here calls all plugins diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index a90d3d3e5..565bf22e7 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -100,7 +100,7 @@ struct stratMap { struct mercPoolUnit { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t experience; //0x0004 int32_t cost; //0x0008 float replenishMin; //0x000C @@ -349,10 +349,15 @@ struct battleUnit struct UNICODE_STRING** localizedName; //0x0004 float someFloat; //0x0008 int32_t soldiersLost; //0x000C - char pad_0010[12]; //0x0010 + int32_t soldiersKilled; //0x0010 + int32_t takenPrisoner; //0x0014 + int32_t prisonersCaught; //0x0018 int32_t soldiersStart; //0x001C uint32_t unitsRouted; //0x0020 - char pad_0024[20]; //0x0024 + int32_t soldiersHealed; //0x0024 + char pad_0028[4]; //0x0028 + int32_t soldiersEnd; //0x002C + char pad_0030[8]; //0x0030 int8_t hasRouted; //0x0038 char pad_0039[15]; //0x0039 }; //Size: 0x0048 @@ -938,7 +943,7 @@ struct oneSiege { struct unitRQ { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t FourtySeven; //0x0004 struct settlementStruct* settlement; //0x0008 int8_t N0001082F; //0x000C @@ -984,7 +989,7 @@ struct settlementStruct { char* name; /* internal name of settlement */ int nameCrypt; UNICODE_STRING** localizedName; - struct factionStruct* ownerFac; /* faction of the owner */ + struct factionStruct* faction; /* faction of the owner */ undefined field16_0x174[36]; int level; /* level of the settlement/castle */ int fac_creatorModNum; @@ -1111,7 +1116,7 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int xCoord; /* number of x-coord of unit position */ int yCoord; /* number of y-coord of unit position */ undefined field5_0x14[108]; - struct generalCharacterictics* genChar; /* many important info about character */ + struct namedCharacter* genChar; /* many important info about character */ undefined field7_0x84[4]; struct genMod* genType; undefined field9_0x8c[24]; @@ -1135,7 +1140,7 @@ struct general { /* character on the stratmap, who has a unit in a stack */ }; //additional character data(name,label,traits, etc) -struct generalCharacterictics { /* many important info about character */ +struct namedCharacter { /* many important info about character */ UINT32 index; /* index of character */ UNICODE_STRING** localizedFullName; /* displaying name */ UNICODE_STRING** localizedNameForSave; /* saved to save file */ @@ -1216,7 +1221,7 @@ struct generalCharacterictics { /* many important info about character */ int32_t battleSurgery; //0x01E0 struct traitContainer* traits; /* names at [item number] -0x4-here. Not have number, read it in while(traits != 0){this->m_memory->Read(traits + 0x08, 4).toINT32();} */ undefined field_0x1e8[4]; - struct anchData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ + struct ancData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ undefined field_0x1f0[4]; UINT32 anchNum; /* number of character ancillaries */ struct general* gen; /* on stratmap */ @@ -1226,9 +1231,9 @@ struct generalCharacterictics { /* many important info about character */ struct factionStruct* faction; int subFaction; undefined field_0x220[4]; - struct generalCharacterictics* parent; /* father */ - struct generalCharacterictics* spouse; - struct generalCharacterictics* childs[4]; /* children, womens wont have children */ + struct namedCharacter* parent; /* father */ + struct namedCharacter* spouse; + struct namedCharacter* childs[4]; /* children, womens wont have children */ undefined field_0x23c[20]; char* portrait; undefined field_0x254[4]; @@ -1313,7 +1318,7 @@ struct unit { undefined field2_0x8[636]; struct stackStruct* army; undefined field4_0x288[12]; - struct EduEntry* eduEntry; + struct eduEntry* eduEntry; int ID; undefined field7_0x29c[612]; int expScreen; /* screen experience */ @@ -1379,15 +1384,15 @@ struct factionStruct { char* ai_label; /* ai_label of faction */ undefined field_0xc0[4]; struct settlementStruct* capital; /* capital of the faction */ - struct generalCharacterictics* leader; /* faction leader */ - struct generalCharacterictics* heir; /* faction heir */ + struct namedCharacter* leader; /* faction leader */ + struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ UINT32* ai_assistant; undefined field_0xdc[20]; UINT32 holdRegions; undefined field_0xf4[4]; - struct generalCharacterictics** charactersAll; /* all characters, died, alive, etc */ + struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ undefined field_0xfc[4]; int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ @@ -1467,7 +1472,7 @@ struct ArmourUpgModels //type of unit from EDU -struct EduEntry { +struct eduEntry { char* Type; uint32_t typeHash; DWORD Index; @@ -1666,7 +1671,7 @@ struct EduEntry { struct eduEntryes { /* structure with all edu entries */ UINT32 qq; - struct EduEntry unitTupes[500]; + struct eduEntry unitTupes[500]; UINT32 numberOfTupes; }; @@ -1680,7 +1685,7 @@ struct someFactNameStruct { }; //pointer to ancillary -struct anchData { /* data of the ancillary */ +struct ancData { /* data of the ancillary */ struct anchillary* dataAnch; }; diff --git a/M2TWEOP Code/M2TWEOP library/stratModelsChange.cpp b/M2TWEOP Code/M2TWEOP library/stratModelsChange.cpp index 77b4a0bc9..95bad9ae1 100644 --- a/M2TWEOP Code/M2TWEOP library/stratModelsChange.cpp +++ b/M2TWEOP Code/M2TWEOP library/stratModelsChange.cpp @@ -1,4 +1,7 @@ #include "stratModelsChange.h" + +#include + #include "fastFuncts.h" #include "functionsOffsets.h" #include "dataOffsets.h" @@ -24,14 +27,13 @@ namespace stratModelsChange mapstratModels; vectorcharacterStratModels; - NOINLINE EOP_EXPORT void addModelToGame(const char* path, UINT32 modelId) + void addModelToGame(const char* path, const UINT32 modelId) { - stratModelRecord* modRec = new stratModelRecord(); + auto* modRec = new stratModelRecord(); modRec->path = path; modRec->modelId = modelId; stratModels[modelId] = modRec; - return; } @@ -55,13 +57,9 @@ namespace stratModelsChange vectorstratModelCharacterChangeList; - void setModel(int x, int y, UINT32 modelId, UINT32 modelId2) + void setModel(const int x, const int y, const UINT32 modelId, const UINT32 modelId2) { - /*if (fastFuncts::findFort(x, y) == nullptr - && fastFuncts::findPort(x, y) == nullptr - && fastFuncts::findResource(x, y) == nullptr - ) return; -*/ + for (size_t i = 0; i < stratModelChangeList.size(); i++) { if (stratModelChangeList[i]->x == x @@ -73,7 +71,7 @@ namespace stratModelsChange i--; } } - stratModelChangeRecord* rec = new stratModelChangeRecord(); + auto* rec = new stratModelChangeRecord(); rec->modelId = modelId; rec->modelId2 = modelId2; rec->x = x; @@ -83,7 +81,7 @@ namespace stratModelsChange stratModelChangeList.push_back(rec); } - stratModelRecord* findStratModel(UINT32 modelId) + stratModelRecord* findStratModel(const UINT32 modelId) { try { @@ -93,13 +91,10 @@ namespace stratModelsChange { return nullptr; } - - - return nullptr; } - model_Rigid* getModel(UINT32 modelId) + model_Rigid* getModel(const UINT32 modelId) { try { @@ -109,27 +104,21 @@ namespace stratModelsChange { return nullptr; } - - - return nullptr; } //Change only when render queue is happening to avoid crashes void checkAndChangeStratModels() { - for (stratModelChangeRecord* changeMod : stratModelChangeList) //static models + for (const stratModelChangeRecord* changeMod : stratModelChangeList) //static models { - - stratModelRecord* mod1 = findStratModel(changeMod->modelId); + const stratModelRecord* mod1 = findStratModel(changeMod->modelId); if (mod1 == nullptr)continue; - stratModelRecord* mod2 = nullptr; - - mod2 = findStratModel(changeMod->modelId2); + const stratModelRecord* mod2 = findStratModel(changeMod->modelId2); changeModel(changeMod->x, changeMod->y, mod1->modelP, mod2->modelP); } - for (stratModelCharacterRecordChange* changeMod : stratModelCharacterChangeList) //character models + for (const stratModelCharacterRecordChange* changeMod : stratModelCharacterChangeList) //character models { changeStratModel(changeMod->gen, changeMod->modelId); } @@ -151,9 +140,9 @@ namespace stratModelsChange { if (modelsLoaded == true)return; - for (auto& modRec : stratModels) + for (const auto& [fst, snd] : stratModels) { - modRec.second->modelP = loadModel(modRec.second->path.c_str()); + snd->modelP = loadModel(snd->path.c_str()); } modelsLoaded = true; } @@ -185,9 +174,9 @@ namespace stratModelsChange add esp, 0x18 mov[res], eax } - int* modsNum = reinterpret_cast(dataOffsets::offsets.statStratModelsListOffset + 0x8dc); + auto modsNum = reinterpret_cast(dataOffsets::offsets.statStratModelsListOffset + 0x8dc); - model_Rigid** modRig = reinterpret_cast(dataOffsets::offsets.statStratModelsListOffset); + auto** modRig = reinterpret_cast(dataOffsets::offsets.statStratModelsListOffset); modRig[*modsNum - 1] = nullptr; *modsNum = *modsNum - 1; @@ -195,9 +184,9 @@ namespace stratModelsChange return reinterpret_cast(res); } - NOINLINE EOP_EXPORT void setCharacterModel(general* gen, const char* model) //add character to be changed to the queue + void setCharacterModel(general* gen, const char* model) //add character to be changed to the queue { - int stringsize = strlen(model); + const size_t stringsize = strlen(model); for (UINT32 i = 0; i < stratModelCharacterChangeList.size(); i++) { if (stratModelCharacterChangeList[i]->gen == gen) @@ -207,9 +196,9 @@ namespace stratModelsChange i--; } } - stratModelCharacterRecordChange* rec = new stratModelCharacterRecordChange(); + auto* rec = new stratModelCharacterRecordChange(); rec->gen = gen; - char* modelNameCopy = new char[stringsize]; + const auto modelNameCopy = new char[stringsize]; strcpy(modelNameCopy, model); rec->modelId = modelNameCopy; stratModelCharacterChangeList.push_back(rec); @@ -217,39 +206,45 @@ namespace stratModelsChange void changeStratModel(general* gen, const char* model) { - if (gen == nullptr) { //maybe captain dont exist anymore - return; - } - stratModelArrayEntry* modelentry = findCharacterStratModel(model); //get eop strat model from vector - if (modelentry == nullptr) { - stratModelArrayEntry* modelentry = getStratModelEntry(model); //get vanilla strat model from 255 array - } - if (modelentry == nullptr) { - return; - } - int stringsize = strlen(model); - genMod* characterFacEntry = new genMod; //make new descr character faction entry - *characterFacEntry = *gen->genType; //get data of old entry and copy it in - descrCharacterStratModelArray* modelArray = new descrCharacterStratModelArray; //make new model array - *modelArray = *gen->genType->stratInfo; //get data of old model array - characterFacEntry->stratInfo = modelArray; //assign new model array to new descr character faction entry - for (int i = 0; i < characterFacEntry->modelCount; i++) //change all models to new one in this array + if (gen != nullptr) { - if (&characterFacEntry->stratInfo->stratModelsArray[i] != nullptr) + stratModelArrayEntry* modelentry = findCharacterStratModel(model); //get eop strat model from vector + if (!modelentry) { - char* modelNameCopy = new char[stringsize]; - strcpy(modelNameCopy, model); - characterFacEntry->stratInfo->stratModelsArray[i].modelName = modelNameCopy; - characterFacEntry->stratInfo->stratModelsArray[i].stratModelEntry = modelentry; + modelentry = getStratModelEntry(model); //get vanilla strat model from 255 array } + if (!modelentry) + { + return; + } + const size_t stringsize = strlen(model); + + const auto characterFacEntry = new genMod; //make new descr character faction entry + *characterFacEntry = *gen->genType; //get data of old entry and copy it in + + auto* modelArray = new descrCharacterStratModelArray; //make new model array + *modelArray = *gen->genType->stratInfo; //get data of old model array + characterFacEntry->stratInfo = modelArray; //assign new model array to new descr character faction entry + + for (int i = 0; i < characterFacEntry->modelCount; i++) //change all models to new one in this array + { + if (&characterFacEntry->stratInfo->stratModelsArray[i] != nullptr) + { + const auto modelNameCopy = new char[stringsize]; + strcpy(modelNameCopy, model); + characterFacEntry->stratInfo->stratModelsArray[i].modelName = modelNameCopy; + characterFacEntry->stratInfo->stratModelsArray[i].stratModelEntry = modelentry; + } + } + + gen->genType = characterFacEntry; //assign new array to general } - gen->genType = characterFacEntry; //assign new array to general } stratModelArrayEntry* findCharacterStratModel(const char* modelId) //find eop model from vector { - for (stratModelCharacterRecord* newRec : characterStratModels) + for (const stratModelCharacterRecord* newRec : characterStratModels) { if (strcmp(modelId, newRec->modelId) == 0) { return newRec->entry; @@ -261,7 +256,7 @@ namespace stratModelsChange stratModelArrayEntry* getStratModelEntry(const char* name) //find vanilla model from array at offset { - stratModelArrayEntry* array = (stratModelArrayEntry*)dataOffsets::offsets.stratModelArray; + auto* array = reinterpret_cast(dataOffsets::offsets.stratModelArray); for (int i = 0; i < 255; i++) { if (&array[i] != nullptr) @@ -300,13 +295,8 @@ namespace stratModelsChange { DWORD assignfunc = codes::offsets.allocMemFunc; DWORD newModelFlexi = 0; - DWORD createModelFlexi = codes::offsets.createModelFlexi; - DWORD memsize = 0x12c; - - if (shadow == true) { - memsize = 0x11c; - createModelFlexi = codes::offsets.createModelFlexiShadow; - } + DWORD createModelFlexi = shadow == true ? codes::offsets.createModelFlexiShadow : codes::offsets.createModelFlexi; + DWORD memsize = shadow == true ? 0x11c : 0x12c; _asm { @@ -351,13 +341,12 @@ namespace stratModelsChange DWORD loadStratCAS(const char* caspath, bool shadow) //load the cas { - int count = strlen(caspath); + size_t count = strlen(caspath); int zero = 0; int* zeropointer = &zero; DWORD loadFunc = codes::offsets.loadStratCharModel; DWORD stratModel = 0; - DWORD stackOffset = 0x178; - if (shadow) { + if (shadow) { // NOLINT(bugprone-branch-clone) _asm { push count @@ -391,21 +380,21 @@ namespace stratModelsChange void addCharacterCas(const char* skeletonname, const char* caspath, const char* shadowcaspath, const char* typeName, const char* texturepath) { //add entry to vector, using all info that is needed to rebuild cas - int stringsize = strlen(typeName); - stratModelCharacterRecord* newRec = new stratModelCharacterRecord(); - char* typeNameCopy2 = new char[stringsize]; + const size_t stringsize = strlen(typeName); + auto* newRec = new stratModelCharacterRecord(); + const auto typeNameCopy2 = new char[stringsize]; strcpy(typeNameCopy2, typeName); newRec->modelId = typeNameCopy2; - char* skeletonCopy = new char[strlen(skeletonname)]; + const auto skeletonCopy = new char[strlen(skeletonname)]; strcpy(skeletonCopy, skeletonname); newRec->skeletonname = skeletonCopy; - char* caspathCopy = new char[strlen(caspath)]; + const auto caspathCopy = new char[strlen(caspath)]; strcpy(caspathCopy, caspath); newRec->caspath = caspathCopy; - char* shadowpathCopy = new char[strlen(shadowcaspath)]; + const auto shadowpathCopy = new char[strlen(shadowcaspath)]; strcpy(shadowpathCopy, shadowcaspath); newRec->shadowcaspath = shadowpathCopy; - char* textureCopy = new char[strlen(texturepath)]; + const auto textureCopy = new char[strlen(texturepath)]; strcpy(textureCopy, texturepath); newRec->texturepath = textureCopy; newRec->entry = buildCharacterCas(newRec->skeletonname, newRec->caspath, newRec->shadowcaspath, newRec->modelId, newRec->texturepath); @@ -416,43 +405,52 @@ namespace stratModelsChange stratModelArrayEntry* buildCharacterCas(const char* skeletonname, const char* caspath, const char* shadowcaspath, const char* typeName, const char* texturepath) { //build new cas file - int stringsize = strlen(typeName); - DWORD skeleton = getCasAnimSet(skeletonname); - DWORD newModelFlexi = createModelFlexi(false); - DWORD newModelFlexiShadow = createModelFlexi(true); - DWORD stratmodel = loadStratCAS(caspath, false);//this is very fickle with the stack position the data gets pulled from, watch out! - DWORD stratmodelShadow = loadStratCAS(shadowcaspath, true); + const size_t stringsize = strlen(typeName); + const DWORD skeleton = getCasAnimSet(skeletonname); + const DWORD newModelFlexi = createModelFlexi(false); + const DWORD newModelFlexiShadow = createModelFlexi(true); + const DWORD stratmodel = loadStratCAS(caspath, false);//this is very fickle with the stack position the data gets pulled from, watch out! + const DWORD stratmodelShadow = loadStratCAS(shadowcaspath, true); + std::string texturepathString = texturepath; size_t pos = texturepathString.find_last_of("\\/") + 1; texturepathString = texturepathString.substr(0, pos); - pos = texturepathString.find_first_of("\\/") + 1; - texturepathString = texturepathString.substr(pos); - pos = texturepathString.find_first_of("\\/") + 1; - texturepathString = texturepathString.substr(pos); + for (int i = 0; i < 2; i++) + { + pos = texturepathString.find_first_of("\\/") + 1; + texturepathString = texturepathString.substr(pos); + } + fixModelFlexi(false, stratmodel, newModelFlexi, texturepathString.c_str(), skeleton); fixModelFlexi(true, stratmodelShadow, newModelFlexiShadow, texturepathString.c_str(), skeleton); - int textureindex = readTGAfile(texturepath); - stratModelArrayEntry* newEntry = new stratModelArrayEntry; + + const int textureindex = readTGAfile(texturepath); + auto* newEntry = new stratModelArrayEntry; newEntry->model_flexi_m = newModelFlexi; newEntry->zeropoint = 0; //just filling the 0 stuff with loops and assignments so that there isn't random crap in there, we don't know what's used as 0 - for (int i = 0; i < 6; i++) { - newEntry->zeroarray[i] = 0; + for (int& i : newEntry->zeroarray) + { + i = 0; } - newEntry->lodRange = (float)1000000.0; - for (int i = 0; i < 9; i++) { - newEntry->zeroarray2[i] = 0; + newEntry->lodRange = 1000000.0f; + for (int& i : newEntry->zeroarray2) + { + i = 0; } - for (int i = 0; i < 31; i++) { //assigning texture for every faction - newEntry->modelTexturesFactionArray[i].textureIndex = textureindex; - newEntry->modelTexturesFactionArray[i].glossTextureIndex = -1; + for (auto& [textureIndex, glossTextureIndex] : newEntry->modelTexturesFactionArray) + { //assigning texture for every faction + textureIndex = textureindex; + glossTextureIndex = -1; } - for (int i = 0; i < 33; i++) { - newEntry->somearray[i] = -1; + for (int& i : newEntry->somearray) + { + i = -1; } - for (int i = 0; i < 3; i++) { - newEntry->somearray2[i] = 0; + for (int& i : newEntry->somearray2) + { + i = 0; } - newEntry->lod2 = (float)1000000.0; + newEntry->lod2 = 1000000.0f; newEntry->scale = 0; newEntry->skeleton = skeleton; newEntry->modelCountNotShadow = 1; @@ -462,16 +460,17 @@ namespace stratModelsChange newEntry->zeroarray3[i] = 0; newEntry->zeroarray4[i] = 0; } - newEntry->lod3 = (float)1000000.0; + newEntry->lod3 = 1000000.0f; newEntry->modelCountShadow = 1; newEntry->zeroint = 0; - char* typeNameCopy = new char[stringsize]; + const auto typeNameCopy = new char[stringsize]; strcpy(typeNameCopy, typeName); newEntry->typeName = typeNameCopy; newEntry->N54788969 = 54788969; return newEntry; } + // ReSharper disable once CppInconsistentNaming int readTGAfile(const char* path) //read new tga file and add to game tga database { DWORD funcAddr = codes::offsets.readTgaFile; diff --git a/M2TWEOP Code/M2TWEOP library/stratModelsChange.h b/M2TWEOP Code/M2TWEOP library/stratModelsChange.h index 109c1e569..40d0ffefd 100644 --- a/M2TWEOP Code/M2TWEOP library/stratModelsChange.h +++ b/M2TWEOP Code/M2TWEOP library/stratModelsChange.h @@ -28,6 +28,7 @@ namespace stratModelsChange stratModelArrayEntry* getStratModelEntry(const char* name); stratModelArrayEntry* findCharacterStratModel(const char* modelId); EOP_EXPORT void setCharacterModel(general* gen, const char* model); + // ReSharper disable once CppInconsistentNaming int readTGAfile(const char* path); void loadCharModels(); //for internal use only diff --git a/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj b/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj index 24c7c2d64..73315b743 100644 --- a/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj +++ b/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 MultiByte Application false - v142 + v143 true MultiByte Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode diff --git a/M2TWEOP Code/d3d9/d3d9.vcxproj b/M2TWEOP Code/d3d9/d3d9.vcxproj index 1219dfd45..fc901abf5 100644 --- a/M2TWEOP Code/d3d9/d3d9.vcxproj +++ b/M2TWEOP Code/d3d9/d3d9.vcxproj @@ -21,14 +21,14 @@ DynamicLibrary true MultiByte - v142 + v143 false DynamicLibrary false MultiByte - v142 + v143 false diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index cf87b4cdf..298917169 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -1,7 +1,566 @@ #include "basicEvents.h" +#include +using namespace std; + +void onEventWrapper(const DWORD eventAddr, DWORD** vTab, DWORD arg2) +{ + const auto currentEvent = gameEvents::events.find(eventAddr); + if (currentEvent == gameEvents::events.end()) { + return; + } + currentEvent->second->callEvent(vTab); +} + +void initReligionNames() +{ + const auto* religionDb = *reinterpret_cast (0x016A0B90); + for (int i = 0; i < religionDb->religionCount; i++) + { + religionNames[i] = gameHelpers::getReligionName(i); + } +} + +namespace gameEvents +{ + + void initEvents() + { + initReligionNames(); + const int gv = (m2tweopHelpers::getGameVersion()) - 1; + //namedCharacterEvents + DWORD newCode[] = { 0x0136BFE4, 0x01326FBC }; + addEvent(newCode[gv], "onCharacterTurnStart"); + + newCode[0] = 0x013370DC; newCode[1] = 0x012F20BC; + addEvent(newCode[gv], "onCapturedCharacterRansomed"); + + newCode[0] = 0x01337194; newCode[1] = 0x012F2174; + addEvent(newCode[gv], "onCapturedCharacterReleased"); + + newCode[0] = 0x0133DF5C; newCode[1] = 0x012F8F3C; + addEvent(newCode[gv], "onFatherDiesNatural"); + + newCode[0] = 0x01366D54; newCode[1] = 0x01321D2C; + addEvent(newCode[gv], "onPreBattleWithdrawal"); + + newCode[0] = 0x01367ADC; newCode[1] = 0x01322AB4; + addEvent(newCode[gv], "onPostBattle"); + + newCode[0] = 0x01369E3C; newCode[1] = 0x01324E14; + addEvent(newCode[gv], "onHireMercenaries"); + + newCode[0] = 0x01369F0C; newCode[1] = 0x01324EE4; + addEvent(newCode[gv], "onGeneralCaptureResidence"); + + newCode[0] = 0x0136A0B4; newCode[1] = 0x0132508C; + addEvent(newCode[gv], "onLeaderDestroyedFaction"); + + newCode[0] = 0x0136A584; newCode[1] = 0x0132555C; + addEvent(newCode[gv], "onOfferedForAdoption"); + + newCode[0] = 0x0136A65C; newCode[1] = 0x01325634; + addEvent(newCode[gv], "onLesserGeneralOfferedForAdoption"); + + newCode[0] = 0x0136A72C; newCode[1] = 0x01325704; + addEvent(newCode[gv], "onOfferedForMarriage"); + + newCode[0] = 0x0136A7F4; newCode[1] = 0x013257CC; + addEvent(newCode[gv], "onBrotherAdopted"); + + newCode[0] = 0x0136A8C4; newCode[1] = 0x0132589C; + addEvent(newCode[gv], "onBecomesFactionLeader"); + + newCode[0] = 0x0136A994; newCode[1] = 0x0132596C; + addEvent(newCode[gv], "onBecomesFactionHeir"); + + newCode[0] = 0x0136AA64; newCode[1] = 0x01325A3C; + addEvent(newCode[gv], "onCeasedFactionLeader"); + + newCode[0] = 0x0136AB34; newCode[1] = 0x01325B0C; + addEvent(newCode[gv], "onCeasedFactionHeir"); + + newCode[0] = 0x0136B54C; newCode[1] = 0x01326524; + addEvent(newCode[gv], "onBirth"); + + newCode[0] = 0x0136B61C; newCode[1] = 0x013265F4; + addEvent(newCode[gv], "onCharacterComesOfAge"); + + newCode[0] = 0x0136B6EC; newCode[1] = 0x013266C4; + addEvent(newCode[gv], "onCharacterMarries"); + + newCode[0] = 0x0136B7C4; newCode[1] = 0x0132679C; + addEvent(newCode[gv], "onCharacterMarriesPrincess"); + + newCode[0] = 0x0136B89C; newCode[1] = 0x01326874; + addEvent(newCode[gv], "onMarriageAlliancePossible"); + + newCode[0] = 0x0136B96C; newCode[1] = 0x01326944; + addEvent(newCode[gv], "onMarriageAllianceOffered"); + + newCode[0] = 0x0136BA3C; newCode[1] = 0x01326A14; + addEvent(newCode[gv], "onPriestBecomesHeretic"); + + newCode[0] = 0x0136BB0C; newCode[1] = 0x01326AE4; + addEvent(newCode[gv], "onCharacterNearHeretic"); + + newCode[0] = 0x0136BBDC; newCode[1] = 0x01326BB4; + addEvent(newCode[gv], "onCharacterNearWitch"); + + newCode[0] = 0x0136BCAC; newCode[1] = 0x01326C84; + addEvent(newCode[gv], "onCardinalPromoted"); + + newCode[0] = 0x0136BF14; newCode[1] = 0x01326EEC; + addEvent(newCode[gv], "onCharacterBecomesAFather"); + + newCode[0] = 0x0136C25C; newCode[1] = 0x01327234; + addEvent(newCode[gv], "onGeneralDevastatesTile"); + + newCode[0] = 0x0136CD64; newCode[1] = 0x01327D3C; + addEvent(newCode[gv], "onExecutesASpyOnAMission"); + + newCode[0] = 0x0136CFE4; newCode[1] = 0x01327FBC; + addEvent(newCode[gv], "onExecutesAnAssassinOnAMission"); + + newCode[0] = 0x0136D26C; newCode[1] = 0x01328244; + addEvent(newCode[gv], "onSufferAssassinationAttempt"); + + newCode[0] = 0x0136D414; newCode[1] = 0x013283EC; + addEvent(newCode[gv], "onSufferAcquisitionAttempt"); + + newCode[0] = 0x0136D5AC; newCode[1] = 0x01328584; + addEvent(newCode[gv], "onSufferMarriageAttempt"); + + newCode[0] = 0x0136D754; newCode[1] = 0x0132872C; + addEvent(newCode[gv], "onSufferDenouncementAttempt"); + + newCode[0] = 0x0136D8EC; newCode[1] = 0x013288C4; + addEvent(newCode[gv], "onLeaderOrderedSabotage"); + + newCode[0] = 0x0136DA84; newCode[1] = 0x01328A5C; + addEvent(newCode[gv], "onLeaderOrderedBribery"); + + newCode[0] = 0x0136DB4C; newCode[1] = 0x01328B24; + addEvent(newCode[gv], "onAcceptBribe"); + + newCode[0] = 0x0136DC14; newCode[1] = 0x01328BEC; + addEvent(newCode[gv], "onRefuseBribe"); + + newCode[0] = 0x0136DCDC; newCode[1] = 0x01328CB4; + addEvent(newCode[gv], "onInsurrection"); + + newCode[0] = 0x0136DE7C; newCode[1] = 0x01328E54; + addEvent(newCode[gv], "onLeaderOrderedDiplomacy"); + + newCode[0] = 0x0136E394; newCode[1] = 0x0132936C; + addEvent(newCode[gv], "onNewAdmiralCreated"); + + newCode[0] = 0x0136EC8C; newCode[1] = 0x01329C64; + addEvent(newCode[gv], "onGovernorBuildingDestroyed"); + + //ransomEvent + newCode[0] = 0x0136C8EC; newCode[1] = 0x013278C4; + addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptor"); + + newCode[0] = 0x0136C9C4; newCode[1] = 0x0132799C; + addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptive"); + + newCode[0] = 0x0136CAA4; newCode[1] = 0x01327A7C; + addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptor"); + + newCode[0] = 0x0136CB84; newCode[1] = 0x01327B5C; + addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptive"); + + //spyMissionEvent + newCode[0] = 0x0136CC94; newCode[1] = 0x01327C6C; + addEvent(newCode[gv], "onSpyMission"); + + //missionEvent + newCode[0] = 0x0136E0E4; newCode[1] = 0x013290BC; + addEvent(newCode[gv], "onLeaderMissionSuccess"); + + newCode[0] = 0x0136DF64; newCode[1] = 0x01328F3C; + addEvent(newCode[gv], "onLeaderMissionFailed"); + + //diplomacyMissionEvent + newCode[0] = 0x0136D9B4; newCode[1] = 0x0132898C; + addEvent(newCode[gv], "onBriberyMission"); + + newCode[0] = 0x0136DDAC; newCode[1] = 0x01328D84; + addEvent(newCode[gv], "onDiplomacyMission"); + + //agentMissionEvent + newCode[0] = 0x0136CF0C; newCode[1] = 0x01327EE4; + addEvent(newCode[gv], "onAssassinationMission"); + + newCode[0] = 0x0136D33C; newCode[1] = 0x01328314; + addEvent(newCode[gv], "onAcquisitionMission"); + + newCode[0] = 0x0136D4DC; newCode[1] = 0x013284B4; + addEvent(newCode[gv], "onMarriageMission"); + + newCode[0] = 0x0136D67C; newCode[1] = 0x01328654; + addEvent(newCode[gv], "onDenouncementMission"); + + newCode[0] = 0x0136D81C; newCode[1] = 0x013287F4; + addEvent(newCode[gv], "onSabotageMission"); + + //OrderSpyMissionEvent + newCode[0] = 0x0136CE3C; newCode[1] = 0x01327E14; + addEvent(newCode[gv], "onLeaderOrderedSpyingMission"); + + //OrderKillMissionEvent + newCode[0] = 0x0136D194; newCode[1] = 0x0132816C; + addEvent(newCode[gv], "onLeaderOrderedAssassination"); + + //namedCharacterCrusadeEvent + newCode[0] = 0x0136C3E4; newCode[1] = 0x013273BC; + addEvent(newCode[gv], "onGeneralJoinCrusade"); + + newCode[0] = 0x0136C4B4; newCode[1] = 0x0132748C; + addEvent(newCode[gv], "onGeneralAbandonCrusade"); + + newCode[0] = 0x0136C594; newCode[1] = 0x0132756C; + addEvent(newCode[gv], "onGeneralArrivesCrusadeTargetRegion"); + + newCode[0] = 0x0136C66C; newCode[1] = 0x01327644; + addEvent(newCode[gv], "onGeneralTakesCrusadeTarget"); + + //namedCharacterSettEvent + newCode[0] = 0x0136C0B4; newCode[1] = 0x0132708C; + addEvent(newCode[gv], "onCharacterTurnEnd"); + + newCode[0] = 0x0136C18C; newCode[1] = 0x01327164; + addEvent(newCode[gv], "onCharacterTurnEndInSettlement"); + + //namedCharacterTargetSettEvents + newCode[0] = 0x01369FE4; newCode[1] = 0x01324FBC; + addEvent(newCode[gv], "onGeneralCaptureSettlement"); + + newCode[0] = 0x0136A3E4; newCode[1] = 0x013253BC; + addEvent(newCode[gv], "onGeneralAssaultsResidence"); + + //namedCharacterTargetCharEvents + newCode[0] = 0x0136A4B4; newCode[1] = 0x0132548C; + addEvent(newCode[gv], "onGeneralAssaultsGeneral"); + + newCode[0] = 0x0136C75C; newCode[1] = 0x01327734; + addEvent(newCode[gv], "onCharacterAttacksCrusadingGeneral"); + + //namedCharacterDisasterEvents + newCode[0] = 0x0136A254; newCode[1] = 0x0132522C; + addEvent(newCode[gv], "onCharacterDamagedByDisaster"); + + //settlementEvents + newCode[0] = 0x0136E2B4; newCode[1] = 0x0132928C; + addEvent(newCode[gv], "onSettlementTurnStart"); + + //gameEvents + newCode[0] = 0x0135E30C; newCode[1] = 0x013192E4; + addEvent(newCode[gv], "onAbandonShowMe"); + + newCode[0] = 0x013319E4; newCode[1] = 0x012EC9C4; + addEvent(newCode[gv], "onGameReloaded"); + + newCode[0] = 0x01367F5C; newCode[1] = 0x01322F34; + addEvent(newCode[gv], "onBattleWinningPlaza"); + + newCode[0] = 0x01368044; newCode[1] = 0x0132301C; + addEvent(newCode[gv], "onBattleStopsWinningPlaza"); + + newCode[0] = 0x01368124; newCode[1] = 0x013230FC; + addEvent(newCode[gv], "onBattleDominatingPlaza"); + + newCode[0] = 0x013681F4; newCode[1] = 0x013231CC; + addEvent(newCode[gv], "onBattngineUnmanned"); + + newCode[0] = 0x013682E4; newCode[1] = 0x013232BC; + addEvent(newCode[gv], "onBattlePlayerArmyHalfDestroyed"); + + newCode[0] = 0x013683BC; newCode[1] = 0x01323394; + addEvent(newCode[gv], "onBattnemyArmyHalfDestroyed"); + + newCode[0] = 0x01368584; newCode[1] = 0x0132355C; + addEvent(newCode[gv], "onBattleTideofBattle"); + + newCode[0] = 0x01368DA4; newCode[1] = 0x01323D7C; + addEvent(newCode[gv], "onBattleFinished"); + + newCode[0] = 0x01368E5C; newCode[1] = 0x01323E34; + addEvent(newCode[gv], "onBattleArmyHalfDestroyed"); + + //crusadeEvents + newCode[0] = 0x013321D4; newCode[1] = 0x012ED1B4; + addEvent(newCode[gv], "onCrusadeCalled"); + + newCode[0] = 0x0133778C; newCode[1] = 0x012F276C; + addEvent(newCode[gv], "onPopeAcceptsCrusadeTarget"); + + newCode[0] = 0x01337844; newCode[1] = 0x012F2824; + addEvent(newCode[gv], "onPopeRejectsCrusadeTarget"); + + newCode[0] = 0x0133228C; newCode[1] = 0x012ED26C; + addEvent(newCode[gv], "onCrusadeEnds"); + + //factionCrusadeEvents + newCode[0] = 0x0136AEAC; newCode[1] = 0x01325E84; + addEvent(newCode[gv], "onUnitsDesertCrusade"); + + //crusadeTargetEvents + newCode[0] = 0x0136AF7C; newCode[1] = 0x01325F54; + addEvent(newCode[gv], "onArmyTakesCrusadeTarget"); + + //transgressionEvents + newCode[0] = 0x0136B044; newCode[1] = 0x0132601C; + addEvent(newCode[gv], "onTransgression"); + + newCode[0] = 0x0136B1DC; newCode[1] = 0x013261B4; + addEvent(newCode[gv], "onForgiveness"); + + //factionEvents + newCode[0] = 0x01366E24; newCode[1] = 0x01321DFC; + addEvent(newCode[gv], "onBattleAiCommenced"); + + newCode[0] = 0x01366EF8; newCode[1] = 0x01321ED4; + addEvent(newCode[gv], "onBattleDelayPhaseCommenced"); + + newCode[0] = 0x01366FD4; newCode[1] = 0x01321FAC; + addEvent(newCode[gv], "onBattleDeploymentPhaseCommenced"); + + newCode[0] = 0x013670AC; newCode[1] = 0x01322084; + addEvent(newCode[gv], "onBattleConflictPhaseCommenced"); + + newCode[0] = 0x0136931C; newCode[1] = 0x013242F4; + addEvent(newCode[gv], "onFactionTurnStart"); + + newCode[0] = 0x013694BC; newCode[1] = 0x01324494; + addEvent(newCode[gv], "onFactionNewCapital"); + + newCode[0] = 0x013693EC; newCode[1] = 0x013243C4; + addEvent(newCode[gv], "onPreFactionTurnStart"); + + newCode[0] = 0x01369A5C; newCode[1] = 0x01324A34; + addEvent(newCode[gv], "onVotedForPope"); + + newCode[0] = 0x01369B14; newCode[1] = 0x01324AEC; + addEvent(newCode[gv], "onFactionExcommunicated"); + + newCode[0] = 0x01369CAC; newCode[1] = 0x01324C84; + addEvent(newCode[gv], "onHordeFormed"); + + newCode[0] = 0x01369D74; newCode[1] = 0x01324D4C; + addEvent(newCode[gv], "onFactionTurnEnd"); + + newCode[0] = 0x0136BD74; newCode[1] = 0x01326D4C; + addEvent(newCode[gv], "onCardinalRemoved"); + + newCode[0] = 0x0136BE44; newCode[1] = 0x01326E1C; + addEvent(newCode[gv], "onInquisitorAppointed"); + + newCode[0] = 0x0136D0BC; newCode[1] = 0x01328094; + addEvent(newCode[gv], "onAssassinCaughtAttackingPope"); + + //diplomacyEvents + newCode[0] = 0x0136958C; newCode[1] = 0x01324564; + addEvent(newCode[gv], "onFactionWarDeclared"); + + newCode[0] = 0x0136965C; newCode[1] = 0x01324634; + addEvent(newCode[gv], "onFactionAllianceDeclared"); + + newCode[0] = 0x0136972C; newCode[1] = 0x01324704; + addEvent(newCode[gv], "onInterFactionMarriage"); + + newCode[0] = 0x01369804; newCode[1] = 0x013247DC; + addEvent(newCode[gv], "onFactionTradeAgreementMade"); + + newCode[0] = 0x01369994; newCode[1] = 0x0132496C; + addEvent(newCode[gv], "onPopeElected"); + + newCode[0] = 0x01369BE4; newCode[1] = 0x01324BBC; + addEvent(newCode[gv], "onFactionBreakAlliance"); + + newCode[0] = 0x0136B2A4; newCode[1] = 0x0132627C; + addEvent(newCode[gv], "onUpdateAttitude"); + + //diplomacyMoneyEvents + newCode[0] = 0x013698CC; newCode[1] = 0x013248A4; + addEvent(newCode[gv], "onGiveMoney"); + + newCode[0] = 0x0136B36C; newCode[1] = 0x01326344; + addEvent(newCode[gv], "onDemeanour"); + + //armyEvent + newCode[0] = 0x013686FC; newCode[1] = 0x013236D4; + addEvent(newCode[gv], "onBattleArmyRouted"); + + newCode[0] = 0x0136886C; newCode[1] = 0x01323844; + addEvent(newCode[gv], "onBattleReinforcementsArrive"); + + //characterEvent + newCode[0] = 0x013687B4; newCode[1] = 0x0132378C; + addEvent(newCode[gv], "onBattleGeneralRouted"); + + newCode[0] = 0x0136914C; newCode[1] = 0x01324124; + addEvent(newCode[gv], "onBattleGeneralKilled"); + + //stratUnitEvent + newCode[0] = 0x0136B434; newCode[1] = 0x0132640C; + addEvent(newCode[gv], "onUnitDisbanded"); + + //stratUnitSettEvent + newCode[0] = 0x0136E45C; newCode[1] = 0x01329434; + addEvent(newCode[gv], "onUnitTrained"); + + //stratUnitSettEvent + newCode[0] = 0x0136E52C; newCode[1] = 0x01329504; + addEvent(newCode[gv], "onGovernorUnitTrained"); + + //characterBuildingEvent + newCode[0] = 0x0136E614; newCode[1] = 0x013295EC; + addEvent(newCode[gv], "onGovernorBuildingCompleted"); + + //buildingEvent + newCode[0] = 0x0136EA14; newCode[1] = 0x013299EC; + addEvent(newCode[gv], "onBuildingDestroyed"); + + newCode[0] = 0x0136EAE4; newCode[1] = 0x01329ABC; + addEvent(newCode[gv], "onAddedToBuildingQueue"); + + newCode[0] = 0x0136EBB4; newCode[1] = 0x01329B8C; + addEvent(newCode[gv], "onAddedToTrainingQueue"); + + //agentCreatedEvent + newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; + addEvent(newCode[gv], "onAgentCreated"); + + newCode[0] = 0x0136E944; newCode[1] = 0x0132991C; + addEvent(newCode[gv], "onGovernorAgentCreated"); + + //battleUnitEvent + newCode[0] = 0x0136863C; newCode[1] = 0x01323614; + addEvent(newCode[gv], "onBattleUnitGoesBerserk"); + + newCode[0] = 0x01368924; newCode[1] = 0x013238FC; + addEvent(newCode[gv], "onBattleSiegeEngineDestroyed"); + + newCode[0] = 0x013689E4; newCode[1] = 0x013239BC; + addEvent(newCode[gv], "onBattleSiegeEngineDocksWall"); + + newCode[0] = 0x01368AA4; newCode[1] = 0x01323A7C; + addEvent(newCode[gv], "onBattleGatesAttackedByEngine"); + + newCode[0] = 0x01368B64; newCode[1] = 0x01323B3C; + addEvent(newCode[gv], "onBattleGatesDestroyedByEngine"); + + newCode[0] = 0x01368C24; newCode[1] = 0x01323BFC; + addEvent(newCode[gv], "onBattleWallsBreachedByEngine"); + + newCode[0] = 0x0136908C; newCode[1] = 0x01324064; + addEvent(newCode[gv], "onBattleUnitRouts"); + + //battleUnitEvent2 + newCode[0] = 0x01368CE4; newCode[1] = 0x01323CBC; + addEvent(newCode[gv], "onBattleWallsCaptured"); + + //battlePlayerArmyUnitEvent + newCode[0] = 0x013684A4; newCode[1] = 0x0132347C; + addEvent(newCode[gv], "onBattlePlayerUnderAttackIdle"); + + //battleArmyFromUnitEvent + newCode[0] = 0x01368FCC; newCode[1] = 0x0132355C; + addEvent(newCode[gv], "onBattleWinningCombat"); + + //battleArmyFromUnitEvent2 + newCode[0] = 0x01368F14; newCode[1] = 0x01323EEC; + addEvent(newCode[gv], "onBattleArmyTired"); + + //battlePlayerUnitEvents + newCode[0] = 0x0136718C; newCode[1] = 0x01322164; + addEvent(newCode[gv], "onBattlePlayerUnitAttacksEnemyUnit"); + + newCode[0] = 0x013675D4; newCode[1] = 0x013225AC; + addEvent(newCode[gv], "onBattlePlayerUnitGoesBerserk"); + + newCode[0] = 0x0136778C; newCode[1] = 0x01322764; + addEvent(newCode[gv], "onBattlePlayerUnitRouts"); + + newCode[0] = 0x0136793C; newCode[1] = 0x01322914; + addEvent(newCode[gv], "onBattlePlayerSiegeEngineDestroyed"); + + newCode[0] = 0x01367C64; newCode[1] = 0x01322C3C; + addEvent(newCode[gv], "onBattleGatesAttackedByPlayerEngine"); + + //battleAIUnitEvents + newCode[0] = 0x0136726C; newCode[1] = 0x01322244; + addEvent(newCode[gv], "onBattleEnemyUnitAttacksPlayerUnit"); + + newCode[0] = 0x013676AC; newCode[1] = 0x01322684; + addEvent(newCode[gv], "onBattleEnemyUnitGoesBerserk"); + + newCode[0] = 0x0136785C; newCode[1] = 0x01322834; + addEvent(newCode[gv], "onBattnemyUnitRouts"); + + newCode[0] = 0x01367A14; newCode[1] = 0x013229EC; + addEvent(newCode[gv], "onBattnemySiegeEngineDestroyed"); + + newCode[0] = 0x01367D44; newCode[1] = 0x01322D1C; + addEvent(newCode[gv], "onBattleGatesAttackedByEnemyEngine"); + + //disasterEvents + newCode[0] = 0x0136A17C; newCode[1] = 0x01325154; + addEvent(newCode[gv], "onDisaster"); + + //eventCounterEvents + newCode[0] = 0x0136A30C; newCode[1] = 0x013252E4; + addEvent(newCode[gv], "onEventCounter"); + + //fortEvents + newCode[0] = 0x0136AC04; newCode[1] = 0x01325BDC; + addEvent(newCode[gv], "onUngarrisonedFort"); + + //tileEvents + newCode[0] = 0x0136ACCC; newCode[1] = 0x01325CA4; + addEvent(newCode[gv], "onTileSeen"); + + //objEvents + newCode[0] = 0x0136AD8C; newCode[1] = 0x01325D64; + addEvent(newCode[gv], "onObjSeen"); + } + + template void addEvent(const DWORD key, const char* name) + { + events[key] = std::make_unique>(name, plugData::data.luaAll.luaState); + } + + regionStruct* getCharacterRegion(const namedCharacter* character) + { + return gameHelpers::getRegion(m2tweopHelpers::getTileRegionID(character->gen->xCoord, character->gen->yCoord)); + } + +} + + + +void checkLuaFunc(sol::function** lRef) +{ + if ((*lRef)->valid() == false) + { + *lRef = nullptr; + } +}; + +void onCharacterSelected(namedCharacter* gen) +{ + plugData::data.luaAll.onCharacterSelected(gen); +} + +void onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) +{ + plugData::data.luaAll.onSiegeEquipmentCompleted(sett, frt); +} void onReadGameDbsAtStart() { + gameEvents::initEvents(); if (plugData::data.luaAll.onReadGameDbsAtStart != nullptr) { tryLua((*plugData::data.luaAll.onReadGameDbsAtStart)()); @@ -92,13 +651,14 @@ int onfortificationlevelS(settlementStruct* settlement, bool* isCastle, bool* is return 0; } -void onChangeTurnNum(int num) +void onChangeTurnNum(const int num) { plugData::data.luaAll.onChangeTurnNum(num); } void onNewGameStart() { + //initReligionNames(); if (plugData::data.luaAll.onNewGameStart != nullptr) { tryLua((*plugData::data.luaAll.onNewGameStart)()); @@ -115,7 +675,6 @@ void onCampaignMapLoaded() void onLoadGamePl(std::vector* saveFiles) { - if (plugData::data.luaAll.onLoadSaveFile != nullptr) { sol::as_table_t> wrapped_vec = *saveFiles; @@ -145,100 +704,4 @@ std::vector* onSaveGamePl(UNICODE_STRING**& savePath) return retVec; } -void onPreFactionTurnStart(factionStruct* fac) -{ - plugData::data.luaAll.onPreFactionTurnStart(fac); -} - -void onFactionTurnStart(factionStruct* fac) -{ - plugData::data.luaAll.onFactionTurnStart(fac); -} - -void onGeneralDevastatesTile(generalCharacterictics* gen) -{ - plugData::data.luaAll.onGeneralDevastatesTile(gen); -} - -void onFactionTurnEnd(factionStruct* fac) -{ - plugData::data.luaAll.onFactionTurnEnd(fac); -} - -void onFactionNewCapital(factionStruct* fac) -{ - plugData::data.luaAll.onFactionNewCapital(fac); -} - -void onFactionWarDeclared(factionStruct* fac, factionStruct* fac2) -{ - plugData::data.luaAll.onFactionWarDeclared(fac, fac2); -} - -void onFactionAllianceDeclared(factionStruct* fac, factionStruct* fac2) -{ - plugData::data.luaAll.onFactionAllianceDeclared(fac, fac2); -} - -void onFactionTradeAgreementMade(factionStruct* fac, factionStruct* fac2) -{ - plugData::data.luaAll.onFactionTradeAgreementMade(fac, fac2); -} - -void onFactionBreakAlliance(factionStruct* fac, factionStruct* fac2) -{ - plugData::data.luaAll.onFactionBreakAlliance(fac, fac2); -} - -void onGiveMoney(factionStruct* fac, factionStruct* fac2, float amount) -{ - plugData::data.luaAll.onGiveMoney(fac, fac2, amount); -} - -void onUpdateAttitude(factionStruct* fac, factionStruct* fac2) -{ - plugData::data.luaAll.onUpdateAttitude(fac, fac2); -} - -void onDemeanour(factionStruct* fac, factionStruct* fac2, float amount) -{ - plugData::data.luaAll.onDemeanour(fac, fac2, amount); - -} - -void onCharacterSelected(generalCharacterictics* gen) -{ - plugData::data.luaAll.onCharacterSelected(gen); -} - -void onGeneralAssaultsGeneral(generalCharacterictics* gen, generalCharacterictics* gen2) -{ - plugData::data.luaAll.onGeneralAssaultsGeneral(gen, gen2); - -} - -void onGeneralAssaultsResidence(generalCharacterictics* gen, settlementStruct* sett, fortStruct* frt) -{ - plugData::data.luaAll.onGeneralAssaultsResidence(gen, sett, frt); -} - -void onGeneralCaptureSettlement(generalCharacterictics* gen, settlementStruct* sett) -{ - plugData::data.luaAll.onGeneralCaptureSettlement(gen, sett); -} - -void onGeneralCaptureResidence(generalCharacterictics* gen) -{ - plugData::data.luaAll.onGeneralCaptureResidence(gen); -} - -void onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) -{ - plugData::data.luaAll.onSiegeEquipmentCompleted(sett, frt); -} - -void onPostBattle(generalCharacterictics* gen) -{ - plugData::data.luaAll.onPostBattle(gen); -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index beb0726d2..e32e098ae 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -1,6 +1,8 @@ #pragma once #include "pluginM2TWEOP.h" - +#include +#include +using namespace std; extern "C" PLUGINM2TWEOP_API void onReadGameDbsAtStart(); extern "C" PLUGINM2TWEOP_API void onEndSiege(int x, int y); @@ -15,33 +17,870 @@ extern "C" PLUGINM2TWEOP_API void onNewGameStart(); extern "C" PLUGINM2TWEOP_API void onCampaignMapLoaded(); extern "C" PLUGINM2TWEOP_API void onLoadGamePl(std::vector*saveFiles); extern "C" PLUGINM2TWEOP_API std::vector*onSaveGamePl(UNICODE_STRING * *&savePath); +extern "C" PLUGINM2TWEOP_API void onEventWrapper(DWORD eventAddr, DWORD * *vTab, DWORD arg2); +std::unordered_map characterTypes = { + {0,"spy"}, + {1,"assassin"}, + {2,"diplomat"}, + {3,"admiral"}, + {4,"merchant"}, + {5,"priest"}, + {6,"general"}, + {7,"named_character"}, + {8,"princess"}, + {9,"heretic"}, + {10,"witch"}, + {11,"inquisitor"}, + {13,"pope"} +}; +std::unordered_map disasterTypes = { + {0,"earthquake"}, + {1,"flood"}, + {2,"horde"}, + {3,"storm"}, + {4,"volcano"}, + {5,"dustbowl"}, + {6,"locusts"}, + {7,"famine"}, + {8,"plague"}, + {9,"riot"}, + {10,"fire"} +}; +std::unordered_map ransomTypes = { + {0,"ransom"}, + {1,"execute"}, + {2,"release"}, + {3,"cannot_pay_ransom"} +}; +std::unordered_map missionSuccessLvl = { + {0,"not_successful"}, + {1,"slightly_successful"}, + {2,"partly_successful"}, + {3,"highly_successful"} +}; +std::unordered_map religionNames = { +}; +void checkLuaFunc(sol::function** lRef); +void initReligionNames(); +namespace gameEvents +{ + regionStruct* getCharacterRegion(const namedCharacter* character); + enum class EventType + { + namedCharacterEvent = 1, + gameEvent = 2, + crusadeEvent = 3, + crusadeEventEnds = 4, + factionEvent = 5, + battlePlayerUnitAttackEvent = 6, + battleAiUnitAttackEvent = 7, + battlePlayerUnitEvent = 8, + battleAiUnitEvent = 9, + battlePlayerArmyUnitEvent = 10, + battleArmyFromUnitEvent = 11, + battleArmyFromUnitEvent2 = 12, + battleUnitEvent = 13, + armyEvent = 14, + characterEvent = 15, + battleUnitEvent2 = 16, + diplomacyEvent = 17, + diplomacyMoneyEvent = 18, + namedCharacterTargetSettEvent = 19, + disasterEvent = 20, + namedCharacterDisasterEvent = 21, + eventCounterEvent = 22, + namedCharacterTargetCharEvent = 23, + fortEvent = 24, + tileEvent = 25, + objEvent = 26, + factionCrusadeEvent = 27, + crusadeTargetEvent = 28, + transgressionEvent = 29, + stratUnitEvent = 30, + namedCharacterSettEvent = 31, + namedCharacterCrusadeEvent = 32, + ransomEvent = 33, + spyMissionEvent = 34, + orderSpyMissionEvent = 35, + agentMissionEvent = 36, + orderKillMissionEvent = 37, + diplomacyMissionEvent = 38, + missionEvent = 39, + settlementEvent = 40, + stratUnitSettEvent = 41, + characterUnitSettEvent = 42, + characterBuildingEvent = 43, + agentCreatedEvent = 44, + buildingEvent = 45 + }; -extern "C" PLUGINM2TWEOP_API void onPreFactionTurnStart(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onFactionTurnStart(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onGeneralDevastatesTile(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onFactionTurnEnd(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onFactionNewCapital(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onFactionWarDeclared(factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onFactionAllianceDeclared(factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onFactionTradeAgreementMade(factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onFactionBreakAlliance(factionStruct * fac, factionStruct * fac2); + class EventBase + { + public: + virtual ~EventBase() = default; + virtual int callEvent(DWORD** vTab) = 0; + }; -extern "C" PLUGINM2TWEOP_API void onGiveMoney(factionStruct * fac, factionStruct * fac2, float amount); -extern "C" PLUGINM2TWEOP_API void onUpdateAttitude(factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onDemeanour(factionStruct * fac, factionStruct * fac2, float amount); + template class Event :public EventBase + { + public: -extern "C" PLUGINM2TWEOP_API void onCharacterSelected(generalCharacterictics * gen); + sol::function* funk; -extern "C" PLUGINM2TWEOP_API void onGeneralAssaultsGeneral(generalCharacterictics * gen, generalCharacterictics * gen2); + Event(const std::string& luaFunctionName, sol::state& luaState) + : funk(new sol::function(luaState[luaFunctionName])) {} -//if sett==null, then you need use frt, else use sett -extern "C" PLUGINM2TWEOP_API void onGeneralAssaultsResidence(generalCharacterictics * gen, settlementStruct * sett, fortStruct * frt); -extern "C" PLUGINM2TWEOP_API void onGeneralCaptureSettlement(generalCharacterictics * gen, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onGeneralCaptureResidence(generalCharacterictics * gen); + static const char* getType(const namedCharacter* character) + { + if (character->gen != nullptr) + { + const auto charType = characterTypes.find(character->gen->genType->type); + if (charType != characterTypes.end()) + { + return charType->second; + } + } + return "unknown"; + } + static const regionStruct* getRegion(const namedCharacter* character) + { + if (character->gen != nullptr) + { + return getCharacterRegion(character); + } + return nullptr; + } + static const char* getReligion(const int index) + { + if (index == -1) + { + return "unknown"; + } + const auto name = religionNames.find(index); + if (name != religionNames.end()) + { + return name->second; + } + return "unknown"; + } + int callEvent(DWORD** vTab) override + { + if (EvType == EventType::namedCharacterEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + const char* characterType = getType(character); + const regionStruct* region = getRegion(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, region, characterType, religion); + } + return 1; + } + else if (EvType == EventType::gameEvent) + { + if (&(*funk) != nullptr) { + return (*funk)(); + } + return 2; + } + else if (EvType == EventType::crusadeEvent) + { + auto targetSettlement = reinterpret_cast(vTab[2]); + factionStruct* targetFaction = targetSettlement->faction; + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(targetSettlement, targetFaction, targetRegion, targetReligion); + } + return 3; + } + else if (EvType == EventType::crusadeEventEnds) + { + auto targetSettlement = reinterpret_cast(vTab[2]); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + if (&(*funk) != nullptr) { + (*funk)(targetSettlement, targetRegion); + } + return 4; + } + else if (EvType == EventType::factionEvent) + { + auto faction = reinterpret_cast(vTab[1]); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, religion); + } + return 5; + } + else if (EvType == EventType::battlePlayerUnitAttackEvent) + { + auto attackingUnit = reinterpret_cast(vTab[1]); + auto defendingUnit = reinterpret_cast(vTab[2]); + auto playerUnit = reinterpret_cast(vTab[1]); + auto enemyUnit = reinterpret_cast(vTab[2]); + if (&(*funk) != nullptr) { + (*funk)(attackingUnit, defendingUnit, playerUnit, enemyUnit); + } + return 6; + } + else if (EvType == EventType::battleAiUnitAttackEvent) + { + auto attackingUnit = reinterpret_cast(vTab[1]); + auto defendingUnit = reinterpret_cast(vTab[2]); + auto playerUnit = reinterpret_cast(vTab[2]); + auto enemyUnit = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(attackingUnit, defendingUnit, playerUnit, enemyUnit); + } + return 7; + } + else if (EvType == EventType::battlePlayerUnitEvent) + { + auto playerUnit = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(playerUnit); + } + return 8; + } + else if (EvType == EventType::battleAiUnitEvent) + { + auto enemyUnit = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(enemyUnit); + } + return 9; + } + else if (EvType == EventType::battlePlayerArmyUnitEvent) + { + auto playerUnit = reinterpret_cast(vTab[20]); + auto army = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(army, playerUnit); + } + return 10; + } + else if (EvType == EventType::battleArmyFromUnitEvent) + { + auto playerUnit = reinterpret_cast(vTab[1]); + stackStruct* army = playerUnit->army; + if (&(*funk) != nullptr) { + (*funk)(army); + } + return 11; + } + else if (EvType == EventType::battleArmyFromUnitEvent2) + { + auto playerUnit = reinterpret_cast(vTab[2]); + stackStruct* army = playerUnit->army; + if (&(*funk) != nullptr) { + (*funk)(army); + } + return 12; + } + else if (EvType == EventType::battleUnitEvent) + { + auto playerUnit = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(playerUnit); + } + return 13; + } + else if (EvType == EventType::armyEvent) + { + auto army = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(army); + } + return 14; + } + else if (EvType == EventType::characterEvent) + { + auto gen = reinterpret_cast(vTab[1]); + namedCharacter* namedChar = gen->genChar; + if (&(*funk) != nullptr) { + (*funk)(gen, namedChar); + } + return 15; + } + else if (EvType == EventType::battleUnitEvent2) + { + auto playerUnit = reinterpret_cast(vTab[2]); + if (&(*funk) != nullptr) { + (*funk)(playerUnit); + } + return 16; + } + else if (EvType == EventType::diplomacyEvent) + { + auto faction = reinterpret_cast(vTab[1]); + const char* religion = getReligion(faction->religion); + auto targetFaction = reinterpret_cast(vTab[2]); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, religion, targetFaction, targetReligion); + } + return 17; + } + else if (EvType == EventType::diplomacyMoneyEvent) + { + auto faction = reinterpret_cast(vTab[1]); + const char* religion = getReligion(faction->religion); + auto targetFaction = reinterpret_cast(vTab[2]); + const char* targetReligion = getReligion(targetFaction->religion); + float amount = *reinterpret_cast((DWORD)&vTab[3]); + if (&(*funk) != nullptr) { + (*funk)(faction, religion, targetFaction, targetReligion, amount); + } + return 18; + } + else if (EvType == EventType::namedCharacterTargetSettEvent) + { + auto character = reinterpret_cast(vTab[1]); + auto settlement = reinterpret_cast(vTab[2]); + fortStruct* fort = nullptr; + factionStruct* faction = character->faction; + factionStruct* targetFaction = settlement->faction; + if ((DWORD)(*settlement).vTable != 0x012FCF34) + { + fort = reinterpret_cast(vTab[2]); + targetFaction = fort->faction; + } + const char* characterType = getType(character); + regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + if (!fort) + { + (*funk)(character, settlement, faction, targetFaction, region, characterType, religion, targetReligion, false); + } + else + { + (*funk)(character, fort, faction, targetFaction, region, characterType, religion, targetReligion, true); + } + } + return 19; + } + else if (EvType == EventType::disasterEvent) + { + auto eventType = "unknown"; + if (disasterTypes.find(reinterpret_cast(vTab[1])) != disasterTypes.end()) { + eventType = disasterTypes.at(reinterpret_cast(vTab[1])); + } + if (&(*funk) != nullptr) { + (*funk)(eventType); + } + return 20; + } + else if (EvType == EventType::namedCharacterDisasterEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + const char* characterType = getType(character); + const regionStruct* region = getRegion(character); + const char* religion = getReligion(faction->religion); + auto eventType = "unknown"; + if (disasterTypes.find(reinterpret_cast(vTab[2])) != disasterTypes.end()) { + eventType = disasterTypes.at(reinterpret_cast(vTab[2])); + } + if (&(*funk) != nullptr) { + (*funk)(eventType, character, faction, region, characterType, religion); + } + return 21; + } + else if (EvType == EventType::eventCounterEvent) + { + + const char* counter = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(counter); + } + return 22; + } + else if (EvType == EventType::namedCharacterTargetCharEvent) + { + auto character = reinterpret_cast(vTab[1]); + auto targetCharacter = reinterpret_cast(vTab[2]); + factionStruct* faction = character->faction; + factionStruct* targetFaction = character->faction; + const char* characterType = getType(character); + const regionStruct* region = getRegion(character); + const char* religion = getReligion(faction->religion); + const char* targetCharacterType = getType(targetCharacter); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + + (*funk)(character, targetCharacter, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion); + } + return 23; + } + else if (EvType == EventType::fortEvent) + { + auto fort = reinterpret_cast(vTab[1]); + factionStruct* faction = fort->faction; + regionStruct* region = gameHelpers::getRegion(fort->regionID); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(fort, faction, region, religion); + } + return 24; + } + else if (EvType == EventType::tileEvent) + { + auto faction = reinterpret_cast(vTab[1]); + int x = reinterpret_cast(vTab[2]); + int y = reinterpret_cast(vTab[3]); + regionStruct* region = gameHelpers::getRegion(m2tweopHelpers::getTileRegionID(x, y)); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, x, y, region, religion); + } + return 25; + } + else if (EvType == EventType::objEvent) + { + auto faction = reinterpret_cast(vTab[1]); + auto targetFaction = reinterpret_cast(vTab[2]); + int x = reinterpret_cast(vTab[3]); + int y = reinterpret_cast(vTab[4]); + regionStruct* region = gameHelpers::getRegion(m2tweopHelpers::getTileRegionID(x, y)); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, targetFaction, x, y, region, religion); + } + return 26; + } + else if (EvType == EventType::factionCrusadeEvent) + { + auto targetSettlement = reinterpret_cast(vTab[2]); + auto faction = reinterpret_cast(vTab[3]); + factionStruct* targetFaction = targetSettlement->faction; + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(targetSettlement, faction, targetFaction, targetRegion, religion, targetReligion); + } + return 27; + } + else if (EvType == EventType::factionCrusadeEvent) + { + auto targetSettlement = reinterpret_cast(vTab[2]); + auto army = reinterpret_cast(vTab[3]); + factionStruct* faction = army->faction; + factionStruct* targetFaction = targetSettlement->faction; + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(targetSettlement, army, faction, targetFaction, targetRegion, religion, targetReligion); + } + return 28; + } + else if (EvType == EventType::transgressionEvent) + { + auto faction = reinterpret_cast(vTab[1]); + auto targetFaction = reinterpret_cast(vTab[4]); + const char* transgression = reinterpret_cast(vTab[2]); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, targetFaction, transgression, religion, targetReligion); + } + return 29; + } + else if (EvType == EventType::stratUnitEvent) + { + auto faction = reinterpret_cast(vTab[1]); + auto playerUnit = reinterpret_cast(vTab[2]); + eduEntry* edu = playerUnit->eduEntry; + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, playerUnit, edu, religion); + } + return 30; + } + else if (EvType == EventType::namedCharacterSettEvent) + { + auto character = reinterpret_cast(vTab[1]); + auto settlement = reinterpret_cast(vTab[2]); + factionStruct* faction = character->faction; + const char* characterType = getType(character); + regionStruct* region; + if (settlement) + { + region = gameHelpers::getRegion(settlement->regionNumber); + } + else + { + region = const_cast(getRegion(character)); + } + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, settlement, faction, region, characterType, religion); + } + return 31; + } + else if (EvType == EventType::namedCharacterCrusadeEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto targetSettlement = reinterpret_cast(vTab[2] + 0x3C); + factionStruct* targetFaction = targetSettlement->faction; + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion); + } + return 32; + } + else if (EvType == EventType::ransomEvent) + { + auto character = reinterpret_cast(vTab[1]); + auto capInfo = reinterpret_cast(vTab[2]); + auto ransomType = "unknown"; + if (ransomTypes.find(reinterpret_cast(vTab[3])) != ransomTypes.end()) { + ransomType = ransomTypes.at(reinterpret_cast(vTab[3])); + } + factionStruct* faction = character->faction; + factionStruct* targetFaction = gameHelpers::getFaction(capInfo->targetFactionID); + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion); + } + return 33; + } + else if (EvType == EventType::spyMissionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto targetFaction = reinterpret_cast(vTab[2]); + auto missionSuccess = "unknown"; + if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { + missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); + } + int missionProbability = reinterpret_cast(vTab[4]); + settlementStruct* targetSettlement = nullptr; + fortStruct* targetFort = nullptr; + if (vTab[5] != nullptr) + { + targetSettlement = reinterpret_cast(vTab[5]); + if ((DWORD)(*targetSettlement).vTable != 0x012FCF34) + { + targetFort = reinterpret_cast(vTab[5]); + } + } + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + if (!targetFort) + { + (*funk)(character, missionSuccess, missionProbability, targetSettlement, faction, targetFaction, region, characterType, religion, targetReligion); + } + else + { + (*funk)(character, missionSuccess, missionProbability, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); + } + } + return 34; + } + else if (EvType == EventType::orderSpyMissionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto targetFaction = reinterpret_cast(vTab[2]); + auto missionSuccess = "unknown"; + if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { + missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); + } + settlementStruct* targetSettlement = nullptr; + fortStruct* targetFort = nullptr; + if (vTab[4] != nullptr) + { + targetSettlement = reinterpret_cast(vTab[4]); + if ((DWORD)(*targetSettlement).vTable != 0x012FCF34) + { + targetFort = reinterpret_cast(vTab[4]); + } + } + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + if (!targetFort) + { + (*funk)(character, missionSuccess, targetSettlement, faction, targetFaction, region, characterType, religion, targetReligion); + } + else + { + (*funk)(character, missionSuccess, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); + } + } + return 35; + } + else if (EvType == EventType::agentMissionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto missionSuccess = "unknown"; + if (missionSuccessLvl.find(reinterpret_cast(vTab[2])) != missionSuccessLvl.end()) { + missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[2])); + } + int missionProbability = reinterpret_cast(vTab[3]); + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + + (*funk)(character, missionSuccess, missionProbability, faction, region, characterType, religion); + + } + return 36; + } + else if (EvType == EventType::orderKillMissionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto targetCharacter = reinterpret_cast(vTab[2]); + auto missionSuccess = "unknown"; + if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { + missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); + } + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + + (*funk)(character, missionSuccess, targetCharacter, faction, region, characterType, religion); + + } + return 37; + } + else if (EvType == EventType::diplomacyMissionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto targetFaction = reinterpret_cast(vTab[2]); + auto missionSuccess = "unknown"; + if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { + missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); + } + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + + (*funk)(character, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion); + + } + return 38; + } + else if (EvType == EventType::missionEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + const char* missionName = reinterpret_cast(vTab[2]); + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + + (*funk)(character, faction, missionName, region, characterType, religion); + + } + return 39; + } + else if (EvType == EventType::settlementEvent) + { + auto settlement = reinterpret_cast(vTab[1]); + factionStruct* faction = settlement->faction; + regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + + (*funk)(settlement, faction, region, religion); + + } + return 40; + } + else if (EvType == EventType::stratUnitSettEvent) + { + auto faction = reinterpret_cast(vTab[1]); + auto settlement = reinterpret_cast(vTab[2]); + auto playerUnit = reinterpret_cast(vTab[3]); + eduEntry* edu = playerUnit->eduEntry; + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, settlement, playerUnit, edu, religion); + } + return 41; + } + else if (EvType == EventType::characterUnitSettEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto settlement = reinterpret_cast(vTab[2]); + auto playerUnit = reinterpret_cast(vTab[3]); + const regionStruct* region = getRegion(character); + eduEntry* edu = playerUnit->eduEntry; + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, settlement, playerUnit, edu, region, characterType, religion); + } + return 42; + } + else if (EvType == EventType::characterBuildingEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto settlement = reinterpret_cast(vTab[2]); + auto build = reinterpret_cast(vTab[3]); + const regionStruct* region = getRegion(character); + const char* characterType = getType(character); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, settlement, build, region, characterType, religion); + } + return 43; + } + else if (EvType == EventType::agentCreatedEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto settlement = reinterpret_cast(vTab[3]); + const char* characterType = reinterpret_cast(vTab[2]); + regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, settlement, region, characterType, religion); + } + return 44; + } + else if (EvType == EventType::buildingEvent) + { + auto settlement = reinterpret_cast(vTab[1]); + factionStruct* faction = settlement->faction; + regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + const char* build = reinterpret_cast(vTab[2]); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(settlement, faction, build, region, religion); + } + return 45; + } + else + { + return 0; + } + } + }; + + std::unordered_map> events; + void initEvents(); + template void addEvent(DWORD key, const char* name); +} + +/* +*/ +sol::function* onCharacterTurnStart = nullptr; +sol::function* onCapturedCharacterRansomed = nullptr; +sol::function* onCapturedCharacterReleased = nullptr; +sol::function* onPreBattleWithdrawal = nullptr; +sol::function* onPostBattle = nullptr; +sol::function* onAbandonShowMe = nullptr; +sol::function* onGameReloaded = nullptr; +sol::function* onCrusadeCalled = nullptr; +sol::function* onPopeAcceptsCrusadeTarget = nullptr; +sol::function* onPopeRejectsCrusadeTarget = nullptr; +sol::function* onCrusadeEnds = nullptr; +sol::function* onBattleAiCommenced = nullptr; +sol::function* onBattleDelayPhaseCommenced = nullptr; +sol::function* onBattleDeploymentPhaseCommenced = nullptr; +sol::function* onBattleConflictPhaseCommenced = nullptr; +sol::function* onBattlePlayerUnitAttacksEnemyUnit = nullptr; +sol::function* onBattlePlayerUnitGoesBerserk = nullptr; +sol::function* onBattlePlayerUnitRouts = nullptr; +sol::function* onBattlePlayerSiegeEngineDestroyed = nullptr; +sol::function* onBattleGatesAttackedByPlayerEngine = nullptr; +sol::function* onBattleEnemyUnitAttacksPlayerUnit = nullptr; +sol::function* onBattleEnemyUnitGoesBerserk = nullptr; +sol::function* onBattnemyUnitRouts = nullptr; +sol::function* onBattnemySiegeEngineDestroyed = nullptr; +sol::function* onBattleGatesAttackedByEnemyEngine = nullptr; +sol::function* onBattleWinningPlaza = nullptr; +sol::function* onBattleStopsWinningPlaza = nullptr; +sol::function* onBattleDominatingPlaza = nullptr; +sol::function* onBattngineUnmanned = nullptr; +sol::function* onBattlePlayerArmyHalfDestroyed = nullptr; +sol::function* onBattnemyArmyHalfDestroyed = nullptr; +sol::function* onBattlePlayerUnderAttackIdle = nullptr; +sol::function* onBattleWinningCombat = nullptr; +sol::function* onBattleArmyTired = nullptr; +sol::function* onBattleTideofBattle = nullptr; +sol::function* onBattleUnitGoesBerserk = nullptr; +sol::function* onBattleArmyRouted = nullptr; +sol::function* onBattleSiegeEngineDestroyed = nullptr; +sol::function* onBattleReinforcementsArrive = nullptr; +sol::function* onBattleSiegeEngineDocksWall = nullptr; +sol::function* onBattleGatesAttackedByEngine = nullptr; +sol::function* onBattleGatesDestroyedByEngine = nullptr; +sol::function* onBattleWallsBreachedByEngine = nullptr; +sol::function* onBattleWallsCaptured = nullptr; +sol::function* onBattleFinished = nullptr; +sol::function* onBattleArmyHalfDestroyed = nullptr; +sol::function* onBattleUnitRouts = nullptr; +sol::function* onBattleGeneralKilled = nullptr; +sol::function* onFactionTurnStart = nullptr; +sol::function* onFactionNewCapital = nullptr; +sol::function* onPreFactionTurnStart = nullptr; +sol::function* onFactionWarDeclared = nullptr; +sol::function* onFactionAllianceDeclared = nullptr; +sol::function* onInterFactionMarriage = nullptr; +sol::function* onFactionTradeAgreementMade = nullptr; +sol::function* onGiveMoney = nullptr; +sol::function* onPopeElected = nullptr; +sol::function* onVotedForPope = nullptr; +sol::function* onFactionExcommunicated = nullptr; +sol::function* onFactionBreakAlliance = nullptr; +sol::function* onHordeFormed = nullptr; +sol::function* onGeneralCaptureResidence = nullptr; +sol::function* onGeneralCaptureSettlement = nullptr; +sol::function* onLeaderDestroyedFaction = nullptr; +sol::function* onDisaster = nullptr; +sol::function* onEventCounter = nullptr; +sol::function* onGeneralAssaultsResidence = nullptr; +sol::function* onGeneralAssaultsGeneral = nullptr; +sol::function* onOfferedForAdoption = nullptr; +sol::function* onLesserGeneralOfferedForAdoption = nullptr; +sol::function* onOfferedForMarriage = nullptr; +sol::function* onBrotherAdopted = nullptr; +sol::function* onFatherDiesNatural = nullptr; +sol::function* onBecomesFactionLeader = nullptr; +sol::function* onBecomesFactionHeir = nullptr; +sol::function* onCeasedFactionLeader = nullptr; +sol::function* onCeasedFactionHeir = nullptr; +sol::function* onUngarrisonedFort = nullptr; +sol::function* onTileSeen = nullptr; +sol::function* onObjSeen = nullptr; +sol::function* onUnitsDesertCrusade = nullptr; +sol::function* onArmyTakesCrusadeTarget = nullptr; +sol::function* onTransgression = nullptr; +sol::function* onForgiveness = nullptr; +extern "C" PLUGINM2TWEOP_API void onCharacterSelected(namedCharacter * gen); //if sett==null, then you need use frt, else use sett extern "C" PLUGINM2TWEOP_API void onSiegeEquipmentCompleted(settlementStruct * sett, fortStruct * frt); -extern "C" PLUGINM2TWEOP_API void onPostBattle(generalCharacterictics * gen); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h index 939872195..e4d1cb2d1 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h @@ -37,14 +37,14 @@ template class ProcLoader { public: - T m_pProc; - std::string m_strNameProcedure; + T m_pProc; + std::string m_strNameProcedure; //strings for compare char* stringAdr = nullptr; const char* strCmp; - ProcLoader() {}; + ProcLoader() {} BOOL Load(std::string* pczNameLibrary, std::string* pczNameProcedure, char* sCmp = nullptr) { @@ -84,7 +84,7 @@ class ProcLoader ProcLoader& operator = (ProcLoader&) { return *this; - }; + } }; class battleFuncs @@ -135,7 +135,7 @@ class basicFuncs ProcLoader setEDUUnitsSize; - ProcLoader setHeir; + ProcLoader setHeir; ProcLoader setAncLimit; @@ -160,12 +160,12 @@ class basicFuncs ProcLoader attackCharacter; - ProcLoader addAnchillary; - ProcLoader removeAnchillary; + ProcLoader addAnchillary; + ProcLoader removeAnchillary; ProcLoader findAnchillary; - ProcLoader addTrait; - ProcLoader removeTrait; + ProcLoader addTrait; + ProcLoader removeTrait; @@ -207,7 +207,7 @@ class basicFuncs ProcLoader setCharacterType; - ProcLoader getGameVersion; + ProcLoader getGameVersion; ProcLoader saveGame; ProcLoader mergeArmies; @@ -250,11 +250,11 @@ class eopEduFuncs { public: //edu functions - ProcLoader addEopEduEntry; - ProcLoader addEopEduEntryFromFile; - ProcLoader getEopEduEntry; - ProcLoader getEduEntry; - ProcLoader getEduEntryByType; + ProcLoader addEopEduEntry; + ProcLoader addEopEduEntryFromFile; + ProcLoader getEopEduEntry; + ProcLoader getEduEntry; + ProcLoader getEduEntryByType; ProcLoader getEduIndexByType; ProcLoader getDataEopEdu; diff --git a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp index 80d101762..adc385189 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp @@ -5,20 +5,20 @@ -EduEntry* eopEduHelpers::addEopEduEntry(int baseIndex, int newIndex) +eduEntry* eopEduHelpers::addEopEduEntry(int baseIndex, int newIndex) { return (*(*plugData::data.funcsEopEdu.addEopEduEntry))(baseIndex, newIndex); } -EduEntry* eopEduHelpers::addEopEduEntryFromFile(const char* fileName, int newIndex) +eduEntry* eopEduHelpers::addEopEduEntryFromFile(const char* fileName, int newIndex) { return (*(*plugData::data.funcsEopEdu.addEopEduEntryFromFile))(fileName, newIndex); } -EduEntry* eopEduHelpers::getEopEduEntry(int index) +eduEntry* eopEduHelpers::getEopEduEntry(int index) { return (*(*plugData::data.funcsEopEdu.getEopEduEntry))(index); } -EduEntry* eopEduHelpers::getEduEntry(int index) +eduEntry* eopEduHelpers::getEduEntry(int index) { if (index < 500) { @@ -29,7 +29,7 @@ EduEntry* eopEduHelpers::getEduEntry(int index) return (*(*plugData::data.funcsEopEdu.getEopEduEntry))(index); } } -EduEntry* eopEduHelpers::getEduEntryByType(const char* type) +eduEntry* eopEduHelpers::getEduEntryByType(const char* type) { return (*(*plugData::data.funcsEopEdu.getEduEntryByType))(type); } @@ -74,12 +74,12 @@ void eopEduHelpers::setEntryLocalizedShortDescr(int index, const char* newLocSho (*(*plugData::data.funcsEopEdu.setEntryLocalizedShortDescr))(index, newLocShortDescr); } -bool eopEduHelpers::haveAttributeLegioGet(EduEntry* eduEn) +bool eopEduHelpers::haveAttributeLegioGet(eduEntry* eduEn) { return ((eduEn->Attributes6 & 10) != 0); } -void eopEduHelpers::haveAttributeLegioSet(EduEntry* eduEn, bool isHaveLegio) +void eopEduHelpers::haveAttributeLegioSet(eduEntry* eduEn, bool isHaveLegio) { if (isHaveLegio) { @@ -93,7 +93,7 @@ void eopEduHelpers::haveAttributeLegioSet(EduEntry* eduEn, bool isHaveLegio) int eopEduHelpers::getArmourUpgradeLevelsNum(int idx) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); return (eduEn->ArmorUpgradesEnd - eduEn->ArmorUpgradeLevels); } @@ -103,7 +103,7 @@ void eopEduHelpers::setArmourUpgradeLevelsNum(int idx, int amount) { return; } - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int curramount = getArmourUpgradeLevelsNum(idx); eduEn->ArmorUpgradesEnd = eduEn->ArmorUpgradeLevels + amount; eduEn->ArmorUpgrade2 = eduEn->ArmorUpgradeLevels + amount; @@ -120,7 +120,7 @@ void eopEduHelpers::setArmourUpgradeLevelsNum(int idx, int amount) int eopEduHelpers::getArmourUpgradeLevel(int idx, int levelidx) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int LevelsNum = eopEduHelpers::getArmourUpgradeLevelsNum(idx); @@ -133,7 +133,7 @@ int eopEduHelpers::getArmourUpgradeLevel(int idx, int levelidx) void eopEduHelpers::setArmourUpgradeLevel(int idx, int levelidx, int8_t newlevel) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int LevelsNum = eopEduHelpers::getArmourUpgradeLevelsNum(idx); if (levelidx >= LevelsNum) @@ -145,7 +145,7 @@ void eopEduHelpers::setArmourUpgradeLevel(int idx, int levelidx, int8_t newlevel int eopEduHelpers::getArmourUpgradeModelsNum(int idx) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); return ((eduEn->ArmorUpgradeModelsEnd - (int*)eduEn->ArmorUpgradeModels)) / 2; } @@ -156,7 +156,7 @@ void eopEduHelpers::setArmourUpgradeModelsNum(int idx, int amount) return; } amount = amount * 2; - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int curramount = getArmourUpgradeModelsNum(idx); ArmourUpgModels* newModels = new ArmourUpgModels; ArmourUpgModels* oldModels = eduEn->ArmorUpgradeModels; @@ -177,7 +177,7 @@ void eopEduHelpers::setArmourUpgradeModelsNum(int idx, int amount) std::string eopEduHelpers::getArmourUpgradeModel(int idx, int levelidx) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); char* modelname = nullptr; switch (levelidx) { @@ -204,7 +204,7 @@ std::string eopEduHelpers::getArmourUpgradeModel(int idx, int levelidx) void eopEduHelpers::setArmourUpgradeModel(int idx, int levelidx, const std::string& newModel) { - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int modelsNum = getArmourUpgradeModelsNum(idx); ArmourUpgModels* newModels = new ArmourUpgModels; ArmourUpgModels* oldModels = eduEn->ArmorUpgradeModels; @@ -237,7 +237,7 @@ void eopEduHelpers::setArmourUpgradeModel(int idx, int levelidx, const std::stri void eopEduHelpers::setEntryAttackAttribute(int idx, UnitEnums::attackAttr attribute, bool enable, int sec) { using namespace UnitEnums; - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); if (sec == 1) { if (enable == true) @@ -265,7 +265,7 @@ void eopEduHelpers::setEntryAttackAttribute(int idx, UnitEnums::attackAttr attri bool eopEduHelpers::getEntryAttackAttribute(int idx, UnitEnums::attackAttr attribute, int sec) { using namespace UnitEnums; - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); if (sec == 1) { return ((eduEn->StatPri & attribute) != 0); @@ -284,7 +284,7 @@ int eopEduHelpers::multiplexor(int n1, int n2, int sel) void eopEduHelpers::setEntryStat(int idx, UnitEnums::eduStat stat, int value, int sec) { using namespace UnitEnums; - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); int newStat = value * stat; if (stat < UnitEnums::attack) { @@ -307,7 +307,7 @@ void eopEduHelpers::setEntryStat(int idx, UnitEnums::eduStat stat, int value, in int eopEduHelpers::getEntryStat(int idx, UnitEnums::eduStat stat, int sec) { using namespace UnitEnums; - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); if (stat < UnitEnums::attack) { @@ -335,7 +335,7 @@ void eopEduHelpers::addUnitToRQ(int idx, settlementStruct* sett) { return; } - EduEntry* eduEn = eopEduHelpers::getEduEntry(idx); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); unitRQ* newUnit = new unitRQ; int unitsize = m2tweopHelpers::GetUnitSize(); double unitModifier = 1; diff --git a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h index b32361466..09f02f23a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h @@ -36,11 +36,11 @@ namespace UnitEnums }; namespace eopEduHelpers { - EduEntry* addEopEduEntry(int baseIndex, int newIndex); - EduEntry* addEopEduEntryFromFile(const char* fileName, int newIndex); - EduEntry* getEopEduEntry(int index); - EduEntry* getEduEntry(int index); - EduEntry* getEduEntryByType(const char* type); + eduEntry* addEopEduEntry(int baseIndex, int newIndex); + eduEntry* addEopEduEntryFromFile(const char* fileName, int newIndex); + eduEntry* getEopEduEntry(int index); + eduEntry* getEduEntry(int index); + eduEntry* getEduEntryByType(const char* type); int getEduIndexByType(const char* type); @@ -72,8 +72,8 @@ namespace eopEduHelpers //edu things - bool haveAttributeLegioGet(EduEntry* eduEn); - void haveAttributeLegioSet(EduEntry* eduEn, bool isHaveLegio); + bool haveAttributeLegioGet(eduEntry* eduEn); + void haveAttributeLegioSet(eduEntry* eduEn, bool isHaveLegio); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp index 09cd39b66..e5232df88 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp @@ -7,7 +7,7 @@ std::string factionHelpers::getFactionName(const factionStruct* fac) return std::string(fac->factSmDescr->facName); } -generalCharacterictics* factionHelpers::getCharacterFromFullList(const factionStruct* fac, int index) +namedCharacter* factionHelpers::getCharacterFromFullList(const factionStruct* fac, int index) { return fac->charactersAll[index]; } diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h index b2258d434..bab2b385b 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h @@ -8,7 +8,7 @@ namespace factionHelpers { std::string getFactionName(const factionStruct* fac); - generalCharacterictics* getCharacterFromFullList(const factionStruct* fac, int index); + namedCharacter* getCharacterFromFullList(const factionStruct* fac, int index); general* getCharacterFromGeneralsList(const factionStruct* fac, int index); stackStruct* getStack(const factionStruct* fac, int index); settlementStruct* getSettlement(const factionStruct* fac, int index); diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index 6619f25af..248fe6063 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -12,7 +12,7 @@ namespace gameHelpers return (*(*plugData::data.funcs.getFactionsCount))(); } - std::string gameHelpers::callConsole(std::string cmdName, sol::variadic_args va) + std::string gameHelpers::callConsole(const std::string cmdName, sol::variadic_args va) { char buffer[100]{}; buffer[0] = '\0'; @@ -33,17 +33,17 @@ namespace gameHelpers return buffer;; } - factionStruct* gameHelpers::getFaction(int index) + factionStruct* gameHelpers::getFaction(const int index) { return (*(*plugData::data.funcs.getFactionsList))()[index]; } - guild* gameHelpers::getGuild(unsigned char index) + guild* gameHelpers::getGuild(const unsigned char index) { return (*(*plugData::data.funcs.getGuild))(index); } - general* gameHelpers::createCharacter(const char* type, factionStruct* fac, int age, const char* name, const char* name2, int subFaction, const char* portrait, int x, int y) + general* gameHelpers::createCharacter(const char* type, factionStruct* fac, const int age, const char* name, const char* name2, const int subFaction, const char* portrait, const int x, const int y) { if (portrait != nullptr && strlen(portrait) == 0) { @@ -79,46 +79,46 @@ namespace gameHelpers return std::make_tuple(isExist, counterValue); } - void gameHelpers::setScriptCounter(const char* type, int value) + void gameHelpers::setScriptCounter(const char* type, const int value) { (*(*plugData::data.funcs.setScriptCounter))(type, value); } - regionStruct* gameHelpers::getRegion(int index) + regionStruct* gameHelpers::getRegion(const int index) { gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); stratMap* map = gameDataAll->stratMap; return &map->regions[index]; } - oneTile* gameHelpers::getTile(int x, int y) + oneTile* gameHelpers::getTile(const int x, const int y) { gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); stratMap* map = gameDataAll->stratMap; return &map->tilesArr[gameDataAll->stratMap->mapWidth * y + x]; } - stackStruct* gameHelpers::getStack(const regionStruct* region, int index) + stackStruct* gameHelpers::getStack(const regionStruct* region, const int index) { return region->armies[index]; } - fortStruct* gameHelpers::getFort(const regionStruct* region, int index) + fortStruct* gameHelpers::getFort(const regionStruct* region, const int index) { return region->forts[index]; } - watchTowerStruct* gameHelpers::getWatchtower(const regionStruct* region, int index) + watchTowerStruct* gameHelpers::getWatchtower(const regionStruct* region, const int index) { return region->watchtowers[index]; } - resStrat* gameHelpers::getResource(const regionStruct* region, int index) + resStrat* gameHelpers::getResource(const regionStruct* region, const int index) { return region->resources[index]; } - regionStruct* gameHelpers::getNeighbour(regionStruct* region, int index) + regionStruct* gameHelpers::getNeighbour(regionStruct* region, const int index) { neighbourRegion* nregion = ®ion->neighbourRegions[index]; return nregion->region; @@ -142,7 +142,7 @@ namespace gameHelpers return ((resources & set) != 0); } - void gameHelpers::setHiddenResource(regionStruct* region, int index, bool enable) + void gameHelpers::setHiddenResource(regionStruct* region, int index, const bool enable) { int set = 1 << index; if (index < 32) @@ -203,12 +203,12 @@ namespace gameHelpers return units; } - mercPoolUnit* gameHelpers::addMercUnit(mercPool* mercPool, int idx, int exp, int cost, float repmin, float repmax, int maxunits, float startpool, float startyear, float endyear, int crusading) + mercPoolUnit* gameHelpers::addMercUnit(mercPool* mercPool, const int idx, const int exp, const int cost, const float repmin, const float repmax, const int maxunits, const float startpool, const float startyear, const float endyear, const int crusading) { - mercPoolUnit* newMerc = new mercPoolUnit; + auto* newMerc = new mercPoolUnit; *newMerc = mercPool->firstUnits.mercPoolUnits[0]; int mercUnitNum = gameHelpers::getMercUnitNum(mercPool); - EduEntry* entry = eopEduHelpers::getEduEntry(idx); + eduEntry* entry = eopEduHelpers::getEduEntry(idx); newMerc->eduEntry = entry; newMerc->experience = exp; newMerc->cost = cost; @@ -238,7 +238,7 @@ namespace gameHelpers } if ((maxunitsP - currunits) == 0) { - mercPoolUnitsPtr* newPtr = new mercPoolUnitsPtr; + auto* newPtr = new mercPoolUnitsPtr; newPtr->Maxpool = (unitptr->Maxpool) * 2; newPtr->currentPool = 0; newPtr->nextUnitsPtr = nullptr; @@ -247,7 +247,7 @@ namespace gameHelpers unitptr = unitptr->nextUnitsPtr; currunits = 0; } - mercPoolUnit* newArray = new mercPoolUnit[currunits + 1]; + auto* newArray = new mercPoolUnit[currunits + 1]; for (int i = 0; i < currunits; i++) { newArray[i] = unitptr->mercPoolUnits[i]; } @@ -257,7 +257,7 @@ namespace gameHelpers return &unitptr->mercPoolUnits[currunits]; } - mercPoolUnit* gameHelpers::getMercUnit(mercPool* pool, int index) + mercPoolUnit* gameHelpers::getMercUnit(mercPool* pool, const int index) { mercPoolUnitsPtr* unitptr = &pool->firstUnits; int currunits = 0; @@ -278,7 +278,7 @@ namespace gameHelpers } - void gameHelpers::setMercReligion(mercPoolUnit* unit, int religion, bool set) + void gameHelpers::setMercReligion(mercPoolUnit* unit, const int religion, const bool set) { vectorreligions; bool relFound = false; @@ -335,4 +335,26 @@ namespace gameHelpers { (*(*plugData::data.funcs.historicEvent))(name, title, description); } + + + const char* getReligionName(const int index) + { + const auto* religionDb = *reinterpret_cast (0x016A0B90); + const wchar_t* name = religionDb->religionNames[index]->string; + // Determine the size of the required buffer + const int size = WideCharToMultiByte(CP_UTF8, 0, name, -1, nullptr, 0, nullptr, nullptr); + if (size == 0) { + return nullptr; + } + // Allocate a buffer for the converted string + const auto buffer = new char[size]; + if (buffer == nullptr) { + // Allocation failed + return nullptr; + } + // Convert the string + WideCharToMultiByte(CP_UTF8, 0, name, -1, buffer, size, nullptr, nullptr); + // Return the converted string + return buffer; + } } diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index c1fc235b9..438327db9 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -41,5 +41,6 @@ namespace gameHelpers void saveGame(const char* path); void historicEvent(const char* name, const char* title, const char* description); void scriptCommand(const char* command, const char* args); + const char* getReligionName(const int index); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp index 8444bbcb0..c56dd960b 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp @@ -2,54 +2,70 @@ #include "plugData.h" namespace generalCharactericticsHelpers { - traitContainer* getTraits(generalCharacterictics* character) + traitContainer* getTraits(namedCharacter* character) { return character->traits; } - anchillary* getAnchillary(generalCharacterictics* character, int index) + anchillary* getAnchillary(namedCharacter* character, int index) { return character->anchillaries[index]->dataAnch; } - int addAnchillary(generalCharacterictics* character, std::string anchName) + int addAnchillary(namedCharacter* character, std::string anchName) { - anchillary* anch=(*(*plugData::data.funcs.findAnchillary))((char*)anchName.c_str()); + anchillary* anch = (*(*plugData::data.funcs.findAnchillary))((char*)anchName.c_str()); if (anch == nullptr)return 0; return (*(*plugData::data.funcs.addAnchillary))(character, anch); } - void removeAnchillary(generalCharacterictics* character, anchillary* anch) + void removeAnchillary(namedCharacter* character, anchillary* anch) { (*(*plugData::data.funcs.removeAnchillary))(character, anch); } - void addTrait(generalCharacterictics* character, const char* traitName, int traitLevel) + void addTrait(namedCharacter* character, const char* traitName, int traitLevel) { (*(*plugData::data.funcs.addTrait))(character, traitName, traitLevel); } - void removeTrait(generalCharacterictics* character, const char* traitName) + void removeTrait(namedCharacter* character, const char* traitName) { (*(*plugData::data.funcs.removeTrait))(character, traitName); } - int getAge(generalCharacterictics* character) + int getAge(namedCharacter* character) { return (character->age >> 3) & 0x7f; } - void setAge(generalCharacterictics* character, int age) + void setAge(namedCharacter* character, int age) { character->age = character->age ^ (age * 8 ^ character->age) & 0x3f8; } - bool isAlive(generalCharacterictics* character) + bool isAlive(namedCharacter* character) { - return character->age&1; + return character->age & 1; } - bool getIsMale(generalCharacterictics* character) { + bool getIsMale(namedCharacter* character) { return character->age & 2; } - void setIsMale(generalCharacterictics* character, bool isMale) { - character->age = character->age ^ ((int) isMale << 1 ^ character->age) & 2; + void setIsMale(namedCharacter* character, bool isMale) { + character->age = character->age ^ ((int)isMale << 1 ^ character->age) & 2; } - void setAsHeir(generalCharacterictics* character, bool isJustSet) + void setAsHeir(namedCharacter* character, bool isJustSet) { (*(*plugData::data.funcs.setHeir))(character, isJustSet); } + int getCapturedUnitNum(capturedFactionInfo* capInfo) + { + return (capInfo->capturedUnitsEnd - (DWORD)capInfo->capturedUnits) / 12; + } + int getCapturedCharacterNum(capturedFactionInfo* capInfo) + { + return (capInfo->capturedCharactersEnd - (DWORD)capInfo->capturedCharacters) / 8; + } + capturedUnit* getCapturedUnit(const capturedFactionInfo* capInfo, const int index) + { + return &capInfo->capturedUnits[index]; + } + capturedCharacter* getCapturedCharacter(const capturedFactionInfo* capInfo, const int index) + { + return &capInfo->capturedCharacters[index]; + } } diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h index 1938e4df4..23d5b8236 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h @@ -4,24 +4,28 @@ #include "luaGetSetFuncs.h" namespace generalCharactericticsHelpers { - traitContainer* getTraits(generalCharacterictics* character); - anchillary* getAnchillary(generalCharacterictics* character, int index); - int addAnchillary(generalCharacterictics* character, std::string anchName); + traitContainer* getTraits(namedCharacter* character); + anchillary* getAnchillary(namedCharacter* character, int index); + int addAnchillary(namedCharacter* character, std::string anchName); - void removeAnchillary(generalCharacterictics* character, anchillary* anch); + void removeAnchillary(namedCharacter* character, anchillary* anch); - void addTrait(generalCharacterictics* character, const char* traitName,int traitLevel); - void removeTrait(generalCharacterictics* character, const char* traitName); + void addTrait(namedCharacter* character, const char* traitName, int traitLevel); + void removeTrait(namedCharacter* character, const char* traitName); - int getAge(generalCharacterictics* character); - void setAge(generalCharacterictics* character,int age); + int getAge(namedCharacter* character); + void setAge(namedCharacter* character, int age); - bool getIsMale(generalCharacterictics* character); - void setIsMale(generalCharacterictics* character, bool isMale); + bool getIsMale(namedCharacter* character); + void setIsMale(namedCharacter* character, bool isMale); - bool isAlive(generalCharacterictics* character); - void setAsHeir(generalCharacterictics* character,bool isJustSet); + bool isAlive(namedCharacter* character); + void setAsHeir(namedCharacter* character, bool isJustSet); + int getCapturedUnitNum(capturedFactionInfo* capInfo); + int getCapturedCharacterNum(capturedFactionInfo* capInfo); + capturedUnit* getCapturedUnit(const capturedFactionInfo* capInfo, const int index); + capturedCharacter* getCapturedCharacter(const capturedFactionInfo* capInfo, const int index); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index f3c85c8f3..8f149dbd6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -28,6 +28,59 @@ void luaP::onPluginLoadF() @tfield onStartSiege onStartSiege @tfield onSelectWorldpkgdesc onSelectWorldpkgdesc @tfield onChangeTurnNum onChangeTurnNum + + @tfield onCharacterTurnStart onCharacterTurnStart + @tfield onCapturedCharacterRansomed onCapturedCharacterRansomed + @tfield onCapturedCharacterReleased onCapturedCharacterReleased + @tfield onPreBattleWithdrawal onPreBattleWithdrawal + @tfield onHireMercenaries onHireMercenaries + @tfield onOfferedForAdoption onOfferedForAdoption + @tfield onLesserGeneralOfferedForAdoption onLesserGeneralOfferedForAdoption + @tfield onOfferedForMarriage onOfferedForMarriage + @tfield onCharacterDamagedByDisaster onCharacterDamagedByDisaster + @tfield onAbandonShowMe onAbandonShowMe + @tfield onBattleWinningPlaza onBattleWinningPlaza + @tfield onBattleStopsWinningPlaza onBattleStopsWinningPlaza + @tfield onBattleDominatingPlaza onBattleDominatingPlaza + @tfield onBattngineUnmanned onBattngineUnmanned + @tfield onBattlePlayerArmyHalfDestroyed onBattlePlayerArmyHalfDestroyed + @tfield onBattnemyArmyHalfDestroyed onBattnemyArmyHalfDestroyed + @tfield onBattleTideofBattle onBattleTideofBattle + @tfield onBattleFinished onBattleFinished + @tfield onBattleArmyHalfDestroyed onBattleArmyHalfDestroyed + @tfield onBattleAiCommenced onBattleAiCommenced + @tfield onBattleDelayPhaseCommenced onBattleDelayPhaseCommenced + @tfield onBattleDeploymentPhaseCommenced onBattleDeploymentPhaseCommenced + @tfield onBattleConflictPhaseCommenced onBattleConflictPhaseCommenced + @tfield onInterFactionMarriage onInterFactionMarriage + @tfield onBattleArmyRouted onBattleArmyRouted + @tfield onBattleReinforcementsArrive onBattleReinforcementsArrive + @tfield onBattleGeneralRouted onBattleGeneralRouted + @tfield onBattleGeneralKilled onBattleGeneralKilled + @tfield onBattleUnitGoesBerserk onBattleUnitGoesBerserk + @tfield onBattleSiegeEngineDestroyed onBattleSiegeEngineDestroyed + @tfield onBattleSiegeEngineDocksWall onBattleSiegeEngineDocksWall + @tfield onBattleGatesAttackedByEngine onBattleGatesAttackedByEngine + @tfield onBattleGatesDestroyedByEngine onBattleGatesDestroyedByEngine + @tfield onBattleWallsBreachedByEngine onBattleWallsBreachedByEngine + @tfield onBattleUnitRouts onBattleUnitRouts + @tfield onBattleWallsCaptured onBattleWallsCaptured + @tfield onBattlePlayerUnderAttackIdle onBattlePlayerUnderAttackIdle + @tfield onBattleWinningCombat onBattleWinningCombat + @tfield onBattleArmyTired onBattleArmyTired + @tfield onBattlePlayerUnitAttacksEnemyUnit onBattlePlayerUnitAttacksEnemyUnit + @tfield onBattlePlayerUnitGoesBerserk onBattlePlayerUnitGoesBerserk + @tfield onBattlePlayerUnitRouts onBattlePlayerUnitRouts + @tfield onBattlePlayerSiegeEngineDestroyed onBattlePlayerSiegeEngineDestroyed + @tfield onBattleGatesAttackedByPlayerEngine onBattleGatesAttackedByPlayerEngine + @tfield onBattleEnemyUnitGoesBerserk onBattleEnemyUnitGoesBerserk + @tfield onBattnemyUnitRouts onBattnemyUnitRouts + @tfield onBattnemySiegeEngineDestroyed onBattnemySiegeEngineDestroyed + @tfield onBattleGatesAttackedByEnemyEngine onBattleGatesAttackedByEnemyEngine + @tfield onDisaster onDisaster + @tfield onEventCounter onEventCounter + @tfield onFatherDiesNatural onFatherDiesNatural + @tfield onCharacterSelected onCharacterSelected @tfield onPreFactionTurnStart onPreFactionTurnStart @tfield onFactionTurnStart onFactionTurnStart @@ -127,1095 +180,2873 @@ void luaP::onPluginLoadF() */ - - /*** - Called every time an image is rendered for display + Called at a character's turn start. - @function draw - @tparam LPDIRECT3DDEVICE9 pDevice + @function onCharacterTurnStart + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function draw(device) - ImGui.Begin("test"); - - ImGui.Text("Some test text") - - ImGui.End(); + function onCharacterTurnStart(namedChar, faction, region, characterType, religion) + --something here end */ - drawLuaFunc = new sol::function(luaState["draw"]); - checkLuaFunc(&drawLuaFunc); /*** - Called when ImGui backend reload fonts + A captured character has been successfully ransomed back from the enemy. - @function onLoadingFonts + @function onCapturedCharacterRansomed + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onLoadingFonts() + function onCapturedCharacterRansomed(namedChar, faction, region, characterType, religion) --something here end */ - onLoadingFonts = new sol::function(luaState["onLoadingFonts"]); - checkLuaFunc(&onLoadingFonts); - - resetDXFunc = new sol::function(luaState["deinitDX"]); - checkLuaFunc(&resetDXFunc); - - initDXFunc = new sol::function(luaState["initDX"]); - checkLuaFunc(&initDXFunc); /*** - Called when a new campaign is started from the menu. + A captured character has been released by the enemy. - @function onNewGameStart + @function onCapturedCharacterReleased + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onNewGameStart() + function onCapturedCharacterReleased(namedChar, faction, region, characterType, religion) --something here end */ - - - onNewGameStart = new sol::function(luaState["onNewGameStart"]); - checkLuaFunc(&onNewGameStart); - /*** - Called after the game loads various db`s (edu, etc) at startup. + A character father died of natural causes. - @function onReadGameDbsAtStart + @function onFatherDiesNatural + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onReadGameDbsAtStart() + function onFatherDiesNatural(namedChar, faction, region, characterType, religion) --something here end */ - - - onReadGameDbsAtStart = new sol::function(luaState["onReadGameDbsAtStart"]); - checkLuaFunc(&onReadGameDbsAtStart); - /*** - Called on clicking the stratmap. - - @function onClickAtTile - @tparam int x - @tparam int y - @usage - clickAtMap={["isClicked"]=false,["xTile"]=0,["yTile"]=0} - function draw(device) - if(clickAtMap.isClicked==true) - then - print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Right)).."\n"); - print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Left)).."\n"); - print(tostring(clickAtMap.xTile).." "..tostring(clickAtMap.yTile)); + When a battle is about to start but one of the armies withdraws. - clickAtMap.isClicked=false; - end - end + @function onPreBattleWithdrawal + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion - function onClickAtTile(x,y) - clickAtMap.isClicked=true; - clickAtMap.xTile=x; - clickAtMap.yTile=y; + @usage + function onPreBattleWithdrawal(namedChar, faction, region, characterType, religion) + --something here end */ - - - onClickAtTile = new sol::function(luaState["onClickAtTile"]); - checkLuaFunc(&onClickAtTile); - /*** - Called after loading the campaign map + When a battle has finished. - @function onCampaignMapLoaded + @function onPostBattle + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onCampaignMapLoaded() + function onPostBattle(namedChar, faction, region, characterType, religion) --something here end */ - - - onCampaignMapLoaded = new sol::function(luaState["onCampaignMapLoaded"]); - checkLuaFunc(&onCampaignMapLoaded); - /*** - Called on plugin load (at game start). + A General has hired some mercenaries. - @function onPluginLoad + @function onHireMercenaries + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - --An example of using this event to perform actions at the beginning of a campaign once: - - isCampaignLoadedFirstTime=false; - function onNewGameStart() - isCampaignLoadedFirstTime=true; + function onHireMercenaries(namedChar, faction, region, characterType, religion) + --something here end + */ - function onCampaignMapLoaded() - if(isCampaignLoadedFirstTime==false) - then - do return end - end + /*** + A General has captured a residence such as a fort or watchtower. + @function onGeneralCaptureResidence + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion - --here we do our stuff, what works only one time for each campaign - isCampaignLoadedFirstTime=false; + @usage + function onGeneralCaptureResidence(namedChar, faction, region, characterType, religion) + --something end */ - - - onPluginLoad = new sol::function(luaState["onPluginLoad"]); - checkLuaFunc(&onPluginLoad); - - /*** - Called on creating a new save file. + A faction has been destroyed. - @function onCreateSaveFile + @function onLeaderDestroyedFaction + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onCreateSaveFile() - local savefiles, currentPath = {}, M2TWEOP.getPluginPath() - savefiles[1] = currentPath.."\\testSaveFile1.ourSave" - savefiles[2] = currentPath.."\\testSaveFile2.ourSave" - - file1 = io.open(savefiles[1], "w"); file1:write("This is save file 1!!!"); file1:close() - file2 = io.open(savefiles[2], "w"); file2:write("This is save file 2!!!"); file2:close() - - return savefiles - end + function onLeaderDestroyedFaction(namedChar, faction, region, characterType, religion) + --something + end */ - onCreateSaveFile = new sol::function(luaState["onCreateSaveFile"]); - checkLuaFunc(&onCreateSaveFile); /*** - Called on loading a save file. + An adoption has been proposed. - @function onLoadSaveFile + @function onOfferedForAdoption + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onLoadSaveFile(paths) - lastSaveFiles={}; - for key, value in pairs(paths) do - - print(key, " -- ", value); - - lastSaveFiles[key]={}; - lastSaveFiles[key][1]=value; - lastSaveFiles[key][2]=readFile(value); - - end - end - - - --read file and return it`s content - local function readFile(path) - local file = io.open(path, "r") ; - if (not file) then return nil end - local content = file:read "*a"; - file:close(); - return content; + function onOfferedForAdoption(namedChar, faction, region, characterType, religion) + --something end */ - onLoadSaveFile = new sol::function(luaState["onLoadSaveFile"]); - checkLuaFunc(&onLoadSaveFile); - /*** - Called at the start of a new turn. + A lesser general adoption has been proposed (man of the hour event). - @function onChangeTurnNum - @tparam int turnNumber + @function onLesserGeneralOfferedForAdoption + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onChangeTurnNum(turnNum) - --something here + function onLesserGeneralOfferedForAdoption(namedChar, faction, region, characterType, religion) + --something end */ - onChangeTurnNumFunc = new sol::function(luaState["onChangeTurnNum"]); - checkLuaFunc(&onChangeTurnNumFunc); /*** - Called on select worldpkgdesc for battlemap. See https://wiki.twcenter.net/index.php?title=.worldpkgdesc_-_M2TW. M2TWEOP will ignore the return value if its group does not match the required group! + A marriage offer has been proposed. - @function onSelectWorldpkgdesc - @tparam string selectedRecordName - @tparam string selectedRecordGroup - @treturn string newSelectedRecordName + @function onOfferedForMarriage + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onSelectWorldpkgdesc(selectedRecord,selectedRecordGroup) - --something here - - return selectedRecord; + function onOfferedForMarriage(namedChar, faction, region, characterType, religion) + --something end */ - onSelectWorldpkgdesc = new sol::function(luaState["onSelectWorldpkgdesc"]); - checkLuaFunc(&onSelectWorldpkgdesc); + /*** - Called on specified fortificationlevel in a siege of a settlement. + A brother has been adopted. - @function onfortificationlevelS - @tparam settlementStruct siegedSettlement - @treturn int overridedFortificationlevel - @treturn bool isCastle override settlement type (siege equipment is slightly different between cities and castles of the same level) + @function onBrotherAdopted + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onfortificationlevelS(settlement) - if settlement.xCoord == 10 and settlement.yCoord == 25 then - return 3, false --override settlement under siege at these coordinates to level 3 city - end - return nil --else, do not override + function onBrotherAdopted(namedChar, faction, region, characterType, religion) + --something end */ - onfortificationlevelS = new sol::function(luaState["onfortificationlevelS"]); - checkLuaFunc(&onfortificationlevelS); /*** - Called on the completion of the siege (in any way, with any outcome). + A child is born to the faction leader. - @function onEndSiege - @tparam int xCoord x coordinate of siege(settlement or fort) - @tparam int yCoord y coordinate of siege(settlement or fort) + @function onBirth + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onEndSiege(x,y) - --something here + function onBirth(namedChar, faction, region, characterType, religion) + --something end */ - onEndSiege = new sol::function(luaState["onEndSiege"]); - checkLuaFunc(&onEndSiege); + /*** - Called on the starting of the siege (in any way, with any outcome). + A character has come of age. - @function onStartSiege - @tparam int xCoord x coordinate of siege(settlement or fort) - @tparam int yCoord y coordinate of siege(settlement or fort) + @function CharacterComesOfAge + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onStartSiege(x,y) - --something here + function CharacterComesOfAge(namedChar, faction, region, characterType, religion) + --something end */ - onStartSiege = new sol::function(luaState["onStartSiege"]); - checkLuaFunc(&onStartSiege); + /*** - A character has been selected by any means (including through the UI). + A character has married. - @function onCharacterSelected - @tparam namedCharacter selectedChar + @function onCharacterMarries + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religions @usage - function onCharacterSelected(selectedChar) - --something here + function onCharacterMarries(namedChar, faction, region, characterType, religion) + --something end */ - onCharacterSelectedFunc = new sol::function(luaState["onCharacterSelected"]); - checkLuaFunc(&onCharacterSelectedFunc); /*** - Called before the faction's turn starts. + A character has married a princess. - @function onPreFactionTurnStart + @function onCharacterMarriesPrincess + @tparam namedCharacter namedChar @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onPreFactionTurnStart(fac) - --something here + function onCharacterMarriesPrincess(namedChar, faction, region, characterType, religion) + --something end */ - onPreFactionTurnStartFunc = new sol::function(luaState["onPreFactionTurnStart"]); - checkLuaFunc(&onPreFactionTurnStartFunc); /*** - Called at a faction's turn start. + A marriage alliance is possible. - @function onFactionTurnStart + @function onMarriageAlliancePossible + @tparam namedCharacter namedChar @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionTurnStart(fac) - --something here + function onMarriageAlliancePossible(namedChar, faction, region, characterType, religion) + --something end */ - onFactionTurnStartFunc = new sol::function(luaState["onFactionTurnStart"]); - checkLuaFunc(&onFactionTurnStartFunc); /*** - Called when a general devastates a tile. + A marriage alliance has been offered. - @function onGeneralDevastatesTile - @tparam namedCharacter gen + @function onMarriageAllianceOffered + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGeneralDevastatesTile(gen) - --something here + function onMarriageAllianceOffered(namedChar, faction, region, characterType, religion) + --something end */ - onGeneralDevastatesTileFunc = new sol::function(luaState["onGeneralDevastatesTile"]); - checkLuaFunc(&onGeneralDevastatesTileFunc); /*** - Called at a faction's turn end. + A priest has gone mad. - @function onFactionTurnEnd + @function onPriestBecomesHeretic + @tparam namedCharacter namedChar @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionTurnEnd(fac) - --something here + function onPriestBecomesHeretic(namedChar, faction, region, characterType, religion) + --something end */ - onFactionTurnEndFunc = new sol::function(luaState["onFactionTurnEnd"]); - checkLuaFunc(&onFactionTurnEndFunc); /*** - Called after faction changes to a new capital. + A character is adjacent to a heretic. - @function onFactionNewCapital + @function onCharacterNearHeretic + @tparam namedCharacter namedChar @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionNewCapital(fac) - newCapital=fac.capital(); + function onCharacterNearHeretic(namedChar, faction, region, characterType, religion) + --something end */ - onFactionNewCapitalFunc = new sol::function(luaState["onFactionNewCapital"]); - checkLuaFunc(&onFactionNewCapitalFunc); /*** - Called after a faction declares a war. + A character is adjacent to a witch. - @function onFactionWarDeclared + @function onCharacterNearWitch + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionWarDeclared(faction,targetFaction) + function onCharacterNearWitch(namedChar, faction, region, characterType, religion) --something end */ - onFactionWarDeclaredFunc = new sol::function(luaState["onFactionWarDeclared"]); - checkLuaFunc(&onFactionWarDeclaredFunc); /*** - Called after a faction declares an alliance. + A character has been promoted to a cardinal. - @function onFactionAllianceDeclared + @function onCardinalPromoted + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage - function onFactionAllianceDeclared(faction,targetFaction) + function onCardinalPromoted(namedChar, faction, region, characterType, religion) --something end */ - onFactionAllianceDeclaredFunc = new sol::function(luaState["onFactionAllianceDeclared"]); - checkLuaFunc(&onFactionAllianceDeclaredFunc); - /*** - Called after a faction makes a trade agreement. + A character has become a father. - @function onFactionTradeAgreementMade + @function onCharacterBecomesAFather + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionTradeAgreementMade(faction,targetFaction) + function onCharacterBecomesAFather(namedChar, faction, region, characterType, religion) --something end */ - onFactionTradeAgreementMadeFunc = new sol::function(luaState["onFactionTradeAgreementMade"]); - checkLuaFunc(&onFactionTradeAgreementMadeFunc); - /*** - Called after a faction breaks an alliance. + A General and his army has devastated an enemy's fertile land. - @function onFactionBreakAlliance + @function onGeneralDevastatesTile + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onFactionBreakAlliance(faction,targetFaction) + function onGeneralDevastatesTile(namedChar, faction, region, characterType, religion) --something end */ - - onFactionBreakAllianceFunc = new sol::function(luaState["onFactionBreakAlliance"]); - checkLuaFunc(&onFactionBreakAllianceFunc); - - /*** - Called after a faction gives money to another faction. + A spying mission has failed and the spy is executed by the target. - @function onGiveMoney + @function onExecutesASpyOnAMission + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam int amount + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGiveMoney(faction,targetFaction,amount) + function onExecutesASpyOnAMission(namedChar, faction, region, characterType, religion) --something end */ - - onGiveMoneyFunc = new sol::function(luaState["onGiveMoney"]); - checkLuaFunc(&onGiveMoneyFunc); - - /*** - Called after a faction updates it's attitude towards another faction. + An assassination mission has failed and the assassin is executed by the target. - @function onUpdateAttitude + @function onExecutesAnAssassinOnAMission + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onUpdateAttitude(faction,targetFaction) + function onExecutesAnAssassinOnAMission(namedChar, faction, region, characterType, religion) --something end */ - onUpdateAttitudeFunc = new sol::function(luaState["onUpdateAttitude"]); - checkLuaFunc(&onUpdateAttitudeFunc); - /*** - A demeanour response has occured in diplomacy talks. + Someone has had an attempt on their life. - @function onDemeanour + @function onSufferAssassinationAttempt + @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam float amount + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onDemeanour(faction,targetFaction,amount) + function onSufferAssassinationAttempt(namedChar, faction, region, characterType, religion) --something end */ - onDemeanourFunc = new sol::function(luaState["onDemeanour"]); - checkLuaFunc(&onDemeanourFunc); - /*** - A general has attacked another general. + Someone has had an attempt on their assets. - @function onGeneralAssaultsGeneral - @tparam namedCharacter attacker - @tparam namedCharacter defender + @function onSufferAcquisitionAttempt + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGeneralAssaultsGeneral(attacker,defender) + function onSufferAcquisitionAttempt(namedChar, faction, region, characterType, religion) --something end */ - onGeneralAssaultsGeneralFunc = new sol::function(luaState["onGeneralAssaultsGeneral"]); - checkLuaFunc(&onGeneralAssaultsGeneralFunc); - /*** - An assault has taken place. + Someone has had an attempt on their bachelorhood. - @function onGeneralAssaultsResidence - @tparam namedCharacter attacker - @tparam settlementStruct settlement nil if it is fort - @tparam fortStruct fort nil if it is settlement + @function onSufferMarriageAttempt + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGeneralAssaultsResidence(attacker,settlement,fort) - if(settlement~=nil) - then - -settlement - else - -fort - end - + function onSufferMarriageAttempt(namedChar, faction, region, characterType, religion) + --something end */ - onGeneralAssaultsResidenceFunc = new sol::function(luaState["onGeneralAssaultsResidence"]); - checkLuaFunc(&onGeneralAssaultsResidenceFunc); - /*** - A General has captured a settlement. + Someone has had a denouncement attempt. - @function onGeneralCaptureSettlement - @tparam namedCharacter attacker - @tparam settlementStruct settlement + @function onSufferDenouncementAttempt + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGeneralCaptureSettlement(attacker,settlement) + function onSufferDenouncementAttempt(namedChar, faction, region, characterType, religion) --something end */ - onGeneralCaptureSettlementFunc = new sol::function(luaState["onGeneralCaptureSettlement"]); - checkLuaFunc(&onGeneralCaptureSettlementFunc); - /*** - A General has captured a residence such as a fort or watchtower. + A Faction leader has ordered a sabotage mission. - @function onGeneralCaptureResidence - @tparam namedCharacter attacker + @function onLeaderOrderedSabotage + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onGeneralCaptureResidence(attacker) + function onLeaderOrderedSabotage(namedChar, faction, region, characterType, religion) --something end */ - onGeneralCaptureResidenceFunc = new sol::function(luaState["onGeneralCaptureResidence"]); - checkLuaFunc(&onGeneralCaptureResidenceFunc); - /*** - Siege equipment has been completed by one of the sieging armies at this residence. + Someone has been bribed. - @function onSiegeEquipmentCompleted - @tparam settlementStruct settlement nil if it is fort - @tparam fortStruct fort nil if it is settlement + @function onAcceptBribe + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onAcceptBribe(namedChar, faction, region, characterType, religion) --something + end */ - onSiegeEquipmentCompletedFunc = new sol::function(luaState["onSiegeEquipmentCompleted"]); - checkLuaFunc(&onSiegeEquipmentCompletedFunc); - /*** - When a battle has finished. + Someone has refused a bribe. - @function onPostBattle - @tparam namedCharacter character + @function onRefuseBribe + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onRefuseBribe(namedChar, faction, region, characterType, religion) --something + end */ - onPostBattleFunc = new sol::function(luaState["onPostBattle"]); - checkLuaFunc(&onPostBattleFunc); - /*** - The player has attempted to move a character beyond that character's given movement range for that turn. + Insurgence has been provoked. - @function onMultiTurnMove - @tparam namedCharacter character + @function onInsurrection + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onInsurrection(namedChar, faction, region, characterType, religion) --something + end */ - onMultiTurnMoveFunc = new sol::function(luaState["onMultiTurnMove"]); - checkLuaFunc(&onMultiTurnMoveFunc); - /*** - A settlement has been selected by any means (including through the UI). + A Faction leader has ordered a diplomacy mission. - @function onSettlementSelected - @tparam settlementStruct settlement + @function onLeaderOrderedDiplomacy + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onSettlementSelected(settlement) - print("Function: onSettlementSelected()\n\tSettlement: "..settlement.name) + function onLeaderOrderedDiplomacy(namedChar, faction, region, characterType, religion) + --something end */ - onSettlementSelectedFunc = new sol::function(luaState["onSettlementSelected"]); - checkLuaFunc(&onSettlementSelectedFunc); - /*** - A settlement's level has been increased. + A new admiral has been created for a new ship. - @function onSettlementUpgraded - @tparam settlementStruct settlement + @function onNewAdmiralCreated + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onSettlementUpgraded(settlement) - print("Function: onSettlementUpgraded()\n\tSettlement Level: "..settlement.level) + function onNewAdmiralCreated(namedChar, faction, region, characterType, religion) + --something end */ - onSettlementUpgradedFunc = new sol::function(luaState["onSettlementUpgraded"]); - checkLuaFunc(&onSettlementUpgradedFunc); - /*** - A settlement converted between city and castle and vice-versa. + A building has been destroyed. - @function onSettlementConverted - @tparam settlementStruct settlement + @function onGovernorBuildingDestroyed + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage - function onSettlementConverted(settlement) - if settlement.isCastle == 1 then - --do stuff - end + function onGovernorBuildingDestroyed(namedChar, faction, region, characterType, religion) + --something end */ - onSettlementConvertedFunc = new sol::function(luaState["onSettlementConverted"]); - checkLuaFunc(&onSettlementConvertedFunc); - /*** - A settlement has rioted. + A mission has been completed. - @function onCityRiots - @tparam settlementStruct settlement + @function onLeaderMissionSuccess + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam string missionName + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onLeaderMissionSuccess(namedChar, faction, missionName, region, characterType, religion) --something + end */ - onCityRiotsFunc = new sol::function(luaState["onCityRiots"]); - checkLuaFunc(&onCityRiotsFunc); - /*** - The last unit has been removed from a settlement, agents do not count. + A mission has failed. - @function onUngarrisonedSettlement - @tparam settlementStruct settlement + @function onLeaderMissionFailed + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam string missionName + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onLeaderMissionFailed(namedChar, faction, missionName, region, characterType, religion) --something + end */ - onUngarrisonedSettlementFunc = new sol::function(luaState["onUngarrisonedSettlement"]); - checkLuaFunc(&onUngarrisonedSettlementFunc); - /*** - The last unit has been removed from a fort, agents do not count. + A General has been sent on Crusade/Jihad. - @function onUngarrisonedFort - @tparam fortStruct fort + @function onGeneralJoinCrusade + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct targetSettlement + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string characterType + @tparam string religion + @tparam string targetReligion @usage + function onGeneralJoinCrusade(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) --something + end */ - onUngarrisonedFortFunc = new sol::function(luaState["onUngarrisonedFort"]); - checkLuaFunc(&onUngarrisonedFortFunc); - /*** - A settlement has been given to another faction. - - @function onGiveSettlement - @tparam settlementStruct settlement - @tparam factionStruct fac1 - @tparam factionStruct fac2 + A General has left a Crusade/Jihad. + @function onGeneralAbandonCrusade + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct targetSettlement + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string characterType + @tparam string religion + @tparam string targetReligion @usage + function onGeneralAbandonCrusade(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) --something + end */ - onGiveSettlementFunc = new sol::function(luaState["onGiveSettlement"]); - checkLuaFunc(&onGiveSettlementFunc); - /*** - A general has captured a settlement and the occupy option has been chosen + A General has arrived in the Crusade/Jihad target region. - @function onOccupySettlement - @tparam namedCharacter character only generals, event does not fire for captains + @function onGeneralArrivesCrusadeTargetRegion + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct targetSettlement @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string characterType + @tparam string religion + @tparam string targetReligion @usage + function onGeneralArrivesCrusadeTargetRegion(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) --something + end */ - onOccupySettlementFunc = new sol::function(luaState["onOccupySettlement"]); - checkLuaFunc(&onOccupySettlementFunc); - /*** - A general has captured a settlement and the exterminate option has been chosen. + A General has taken the Crusade/Jihad target settlement. - @function onExterminatePopulation - @tparam namedCharacter character only generals, event does not fire for captains + @function onGeneralTakesCrusadeTarget + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct targetSettlement @tparam factionStruct targetFaction - + @tparam regionStruct targetRegion + @tparam string characterType + @tparam string religion + @tparam string targetReligion @usage + function onGeneralTakesCrusadeTarget(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) --something + end */ - onExterminatePopulationFunc = new sol::function(luaState["onExterminatePopulation"]); - checkLuaFunc(&onExterminatePopulationFunc); - /*** - A general has captured a settlement and the sack option has been chosen. - - @function onSackSettlement - @tparam namedCharacter character only generals, event does not fire for captains - @tparam factionStruct targetFaction + A Character has finished its turn. + @function onCharacterTurnEnd + @tparam namedCharacter namedChar + @tparam settlementStruct|nil settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage + function onCharacterTurnEnd(namedChar, faction, region, characterType, religion) --something + end */ - onSackSettlementFunc = new sol::function(luaState["onSackSettlement"]); - checkLuaFunc(&onSackSettlementFunc); - /*** - A building has been added to the construction queue. + A Character has finished its turn in a settlement. - @function onAddedToBuildingQueue + @function onCharacterTurnEndInSettlement + @tparam namedCharacter namedChar @tparam settlementStruct settlement - @tparam string buildNme level name - + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage + function onCharacterTurnEndInSettlement(namedChar, settlement, faction, region, characterType, religion) --something + end */ - onAddedToBuildingQueueFunc = new sol::function(luaState["onAddedToBuildingQueue"]); - checkLuaFunc(&onAddedToBuildingQueueFunc); - /*** - A building has been destroyed. - - @function onBuildingDestroyed - @tparam settlementStruct settlement - @tparam string buildNme level name + The character has been made the faction leader. + @function onBecomesFactionLeader + @tparam namedCharacter leader + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage - --something + function onBecomesFactionLeader(leader, faction, region, characterType, religion) + print("Function: onBecomesFactionLeader()\n\tLeader: "..leader.fullName) + end */ - onBuildingDestroyedFunc = new sol::function(luaState["onBuildingDestroyed"]); - checkLuaFunc(&onBuildingDestroyedFunc); - /*** - A building has been completed. + The character is no longer faction leader. - @function onBuildingCompleted - @tparam factionStruct fac - @tparam settlementStruct settlement + @function onCeasedFactionLeader + @tparam namedCharacter leader + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage - --something + function onCeasedFactionLeader(leader, faction, region, characterType, religion) + --something + end */ - onBuildingCompletedFunc = new sol::function(luaState["onBuildingCompleted"]); - checkLuaFunc(&onBuildingCompletedFunc); - /*** - An event counter has changed it's value. + The character has been made a faction heir. - @function onEventCounter - @tparam string counter + @function onBecomesFactionHeir + @tparam namedCharacter heir + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage - --something + function onBecomesFactionHeir(heir, faction, region, characterType, religion) + print("Function: onBecomesFactionHeir()\n\tHeir: "..heir.fullName) + end */ - onEventCounterFunc = new sol::function(luaState["onEventCounter"]); - checkLuaFunc(&onEventCounterFunc); - /*** - When a faction is excommunicated by the Pope. + The character is no longer faction heir. - @function onFactionExcommunicated - @tparam factionStruct fac + @function onCeasedFactionHeir + @tparam namedCharacter heir + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion @usage - --something + function onCeasedFactionHeir(heir, faction, region, characterType, religion) + print("Function: onCeasedFactionHeir()\n\tHeir: "..heir.fullName) + end */ - onFactionExcommunicatedFunc = new sol::function(luaState["onFactionExcommunicated"]); - checkLuaFunc(&onFactionExcommunicatedFunc); - /*** - When a particular disaster has just happened. + A character has been injured by a disaster. - @function onDisaster - @tparam int eventType (earthquake, flood, horde, fire, riot, storm, volcano), Don't know enum order! + @function onCharacterDamagedByDisaster + @tparam string eventType (earthquake, flood, horde, storm, volcano, dustbowl, locusts, famine, plague, riot, fire) + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion @usage + function onCharacterDamagedByDisaster(eventType, namedChar, faction, region, characterType, religion) --something + end */ - onDisasterFunc = new sol::function(luaState["onDisaster"]); - checkLuaFunc(&onDisasterFunc); - /*** - A Faction has formed a horde. + A General has captured a settlement. - @function onHordeFormed - @tparam factionStruct fac + @function onGeneralCaptureSettlement + @tparam namedCharacter namedChar + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + @tparam string targetReligion @usage + function onGeneralCaptureSettlement(namedChar, settlement, faction, targetFaction, region, characterType, religion, targetReligion) --something + end */ - onHordeFormedFunc = new sol::function(luaState["onHordeFormed"]); - checkLuaFunc(&onHordeFormedFunc); - /*** - A unit has been added to the training queue. + An assault has taken place. - @function onAddedToTrainingQueue - @tparam settlementStruct sett - @tparam string unitName + @function onGeneralAssaultsResidence + @tparam namedCharacter namedChar + @tparam settlementStruct|fortStruct residence + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + @tparam bool isFort @usage + function onGeneralAssaultsResidence(namedChar, residence, faction, targetFaction, region, characterType, religion, targetReligion, isFort) --something + end */ - onAddedToTrainingQueueFunc = new sol::function(luaState["onAddedToTrainingQueue"]); - checkLuaFunc(&onAddedToTrainingQueueFunc); + /*** + An assault has taken place. + + @function onGeneralAssaultsGeneral + @tparam namedCharacter namedChar + @tparam namedCharacter targetNamedChar + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string targetCharacterType + @tparam string religion + @tparam string targetReligion + + @usage + function onGeneralAssaultsGeneral(namedChar, targetNamedChar, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion) + --something + end + */ + + /*** + A general on crusade/jihad has been attacked by other character (it includes crusading generals attacked in a residence or on navy and generals attacked by spotted and killed assassin). + + @function onCharacterAttacksCrusadingGeneral + @tparam namedCharacter namedChar + @tparam namedCharacter targetNamedChar + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string targetCharacterType + @tparam string religion + @tparam string targetReligion + + @usage + function onCharacterAttacksCrusadingGeneral(namedChar, targetNamedChar, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion) + --something + end + */ + + /*** + A General of a captor faction has made a ransom decision. + + @function onGeneralPrisonersRansomedCaptor + @tparam namedCharacter namedChar + @tparam capturedFactionInfo capInfo + @tparam string ransomType + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onGeneralPrisonersRansomedCaptor(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A General of a captive faction has made a ransom decision. + + @function onGeneralPrisonersRansomedCaptive + @tparam namedCharacter namedChar + @tparam capturedFactionInfo capInfo + @tparam string ransomType + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onGeneralPrisonersRansomedCaptive(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A captor faction has made a ransom decision. + + @function onFactionLeaderPrisonersRansomedCaptor + @tparam namedCharacter namedChar + @tparam capturedFactionInfo capInfo + @tparam string ransomType + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onFactionLeaderPrisonersRansomedCaptor(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A captive faction has made a ransom decision. + + @function onFactionLeaderPrisonersRansomedCaptive + @tparam namedCharacter namedChar + @tparam capturedFactionInfo capInfo + @tparam string ransomType + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onFactionLeaderPrisonersRansomedCaptive(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A spy mission has completed. May also export fort or settlement if target was a garrison residence. + + @function onSpyMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam settlementStruct|fortStruct|nil targetResidence + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onSpyMission(namedChar, missionSuccess, missionProbability, targetResidence, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + An assassination mission has completed. + + @function onAssassinationMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onAssassinationMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + --something + end + */ + + /*** + An acquisition mission has completed. + + @function onAcquisitionMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onAcquisitionMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + --something + end + */ + + /*** + A marriage mission has completed. + + @function onMarriageMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onMarriageMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + --something + end + */ + + /*** + A denouncement mission has completed. + + @function onDenouncementMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onDenouncementMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + --something + end + */ + + /*** + A sabotage mission has completed. + + @function onSabotageMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam int missionProbability + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onSabotageMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + --something + end + */ + + /*** + A bribery mission has completed. + + @function onBriberyMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onBriberyMission(namedChar, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A bribery mission has completed. + + @function onDiplomacyMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onDiplomacyMission(namedChar, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A Faction leader has ordered a spying mission. + + @function onLeaderOrderedSpyingMission + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam settlementStruct|fortStruct|nil targetResidence + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + @tparam string targetReligion + + @usage + function onLeaderOrderedSpyingMission(namedChar, missionSuccess, targetResidence, faction, targetFaction, region, characterType, religion, targetReligion) + --something + end + */ + + /*** + A Faction leader has ordered an assassination mission. + + @function onLeaderOrderedAssassination + @tparam namedCharacter namedChar + @tparam string missionSuccess + @tparam namedCharacter targetCharacter + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onLeaderOrderedAssassination(namedChar, missionSuccess, targetCharacter, faction, region, characterType, religion) + --something + end + */ + + /*** + A Faction leader has ordered a bribery mission. + + @function onLeaderOrderedBribery + @tparam namedCharacter namedChar + @tparam namedCharacter targetCharacter + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onLeaderOrderedBribery(namedChar, missionSuccess, targetCharacter, faction, region, characterType, religion) + --something + end + */ + + /*** + A settlement is being processed for the start of its faction's turn. + + @function onSettlementTurnStart + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementTurnStart(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has abandoned a show me scipt. + + @function onAbandonShowMe + + @usage + function onAbandonShowMe() + --something here + end + */ + + /*** + A strat map game has been reloaded. + + @function onGameReloaded + + @usage + function onGameReloaded() + --something here + end + */ + + /*** + The plaza is being captured. + + @function onBattleWinningPlaza + + @usage + function onBattleWinningPlaza() + --something here + end + */ + + /*** + The plaza capture has been stopped. + + @function onBattleStopsWinningPlaza + + @usage + function onBattleStopsWinningPlaza() + --something here + end + */ + + /*** + The enemy will have captured the plaza in 30s. + + @function onBattleDominatingPlaza + + @usage + function onBattleDominatingPlaza() + --something here + end + */ + + /*** + A siege engine is now unmanned. + + @function onBattngineUnmanned + + @usage + function onBattngineUnmanned() + --something here + end + */ + + /*** + Half of the player's army has been destroyed. + + @function onBattlePlayerArmyHalfDestroyed + + @usage + function onBattlePlayerArmyHalfDestroyed() + --something here + end + */ + + /*** + Half of the enemy's army has been destroyed. + + @function onBattnemyArmyHalfDestroyed + + @usage + function onBattnemyArmyHalfDestroyed() + --something here + end + */ + + /*** + The battle has finished. + + @function onBattleFinished + + @usage + function onBattleFinished() + --something here + end + */ + + /*** + Half of an army has been destroyed. + + @function onBattleArmyHalfDestroyed + + @usage + function onBattleArmyHalfDestroyed() + --something here + end + */ + + /*** + An idle unit is under missile fire. + + @function onBattlePlayerUnderAttackIdle + @tparam stackStruct army + @tparam unit playerUnit + + @usage + function onBattlePlayerUnderAttackIdle(army, playerUnit) + --something here + end + */ + + /*** + A team has gained the advantage in combat. + + @function onBattleWinningCombat + @tparam stackStruct army + + @usage + function onBattleWinningCombat(army) + --something here + end + */ + + /*** + The whole army is tired. + + @function onBattleArmyTired + @tparam stackStruct army + + @usage + function onBattleArmyTired(army) + --something here + end + */ + + /*** + A different team is now the strongest. + + @function onBattleTideofBattle + + @usage + function onBattleTideofBattle() + --something here + end + */ + + /*** + A unit has gone berserk. + + @function onBattleUnitGoesBerserk + @tparam unit unit + + @usage + function onBattleUnitGoesBerserk(unit) + --something here + end + */ + + /*** + A siege engine has been destroyed. + + @function onBattleSiegeEngineDestroyed + @tparam unit unit + + @usage + function onBattleSiegeEngineDestroyed(unit) + --something here + end + */ + + /*** + A siege engine has docked with a wall. + + @function onBattleSiegeEngineDocksWall + @tparam unit unit + + @usage + function onBattleSiegeEngineDocksWall(unit) + --something here + end + */ + + /*** + An engine has started attacking a gate. + + @function onBattleGatesAttackedByEngine + @tparam unit unit + + @usage + function onBattleGatesAttackedByEngine(unit) + --something here + end + */ + + /*** + An engine has destroyed a gate. + + @function onBattleGatesDestroyedByEngine + @tparam unit unit + + @usage + function onBattleGatesDestroyedByEngine(unit) + --something here + end + */ + + /*** + A siege engine has knocked down a wall. + + @function onBattleWallsBreachedByEngine + @tparam unit unit + + @usage + function onBattleWallsBreachedByEngine(unit) + --something here + end + */ + + /*** + A wall has been captured. + + @function onBattleWallsCaptured + @tparam unit unit + + @usage + function onBattleWallsCaptured(unit) + --something here + end + */ + + /*** + A unit has routed. + + @function onBattleUnitRouts + @tparam unit unit + + @usage + function onBattleUnitRouts(unit) + --something here + end + */ + + /*** + A unit has been disbanded. + + @function onUnitDisbanded + @tparam factionStruct faction + @tparam unit unit + @tparam eduEntry entry + @tparam string religion + + @usage + function onUnitDisbanded(faction, unit, entry, religion) + --something here + end + */ + + /*** + A unit has been trained. + + @function onUnitTrained + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam unit unit + @tparam eduEntry entry + @tparam string religion + + @usage + function onUnitTrained(faction, settlement, unit, entry, religion) + --something here + end + */ + + /*** + A unit has been trained. + + @function onGovernorUnitTrained + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam unit unit + @tparam eduEntry entry + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onGovernorUnitTrained(namedChar, faction, settlement, unit, entry, region, characterType, religion) + --something here + end + */ + + /*** + A building has been completed. + + @function GovernorBuildingCompleted + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam building building + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function GovernorBuildingCompleted(namedChar, faction, settlement, building, region, characterType, religion) + --something here + end + */ + + /*** + An agent has been trained. + + @function onAgentCreated + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onAgentCreated(namedChar, faction, settlement, region, characterType, religion) + --something here + end + */ + + /*** + An agent has been trained. + + @function onGovernorAgentCreated + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onGovernorAgentCreated(namedChar, faction, settlement, building, region, characterType, religion) + --something here + end + */ + + /*** + A building has been destroyed. + + @function onBuildingDestroyed + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string buildingName + @tparam regionStruct region + @tparam string religion + + @usage + function onBuildingDestroyed(settlement, faction, buildingName, region, religion) + --something here + end + */ + + /*** + A building has been added to the construction queue. + + @function onAddedToBuildingQueue + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string buildingName + @tparam regionStruct region + @tparam string religion + + @usage + function onAddedToBuildingQueue(settlement, faction, buildingName, region, religion) + --something here + end + */ + + /*** + A unit has been added to the training queue. + + @function onAddedToBuildingQueue + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string unitName + @tparam regionStruct region + @tparam string religion + + @usage + function onAddedToBuildingQueue(settlement, faction, unitName, region, religion) + --something here + end + */ + + /*** + An army has been entirely routed. + + @function onBattleArmyRouted + @tparam stackStruct army + + @usage + function onBattleArmyRouted(army) + --something here + end + */ + + /*** + A reinforcing army has arrived on the battlefield. + + @function onBattleReinforcementsArrive + @tparam stackStruct army + + @usage + function onBattleReinforcementsArrive(army) + --something here + end + */ + + /*** + A general has been routed. + + @function onBattleGeneralRouted + @tparam character general + @tparam namedCharacter namedChar + + @usage + function onBattleGeneralRouted(general, namedChar) + --something here + end + */ + + /*** + A general has been killed. + + @function onBattleGeneralKilled + @tparam character general + @tparam namedCharacter namedChar + + @usage + function onBattleGeneralKilled(general, namedChar) + --something here + end + */ + + /*** + A Crusade/Jihad has been called. + + @function onCrusadeCalled + @tparam settlementStruct targetSettlement + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string targetReligion + + @usage + function onCrusadeCalled(targetSettlement, targetFaction, targetRegion, targetReligion) + --something here + end + */ + + /*** + The Pope has accepted the player's crusade target. + + @function onPopeAcceptsCrusadeTarget + @tparam settlementStruct targetSettlement + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string targetReligion + + @usage + function onPopeAcceptsCrusadeTarget(targetSettlement, targetFaction, targetRegion, targetReligion) + --something here + end + */ + + /*** + The Pope has rejected the player's crusade target. + + @function onPopeRejectsCrusadeTarget + @tparam settlementStruct targetSettlement + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string targetReligion + + @usage + function onPopeRejectsCrusadeTarget(targetSettlement, targetFaction, targetRegion, targetReligion) + --something here + end + */ + + /*** + A Crusade/Jihad has ended. + + @function onCrusadeEnds + @tparam settlementStruct targetSettlement + @tparam regionStruct targetRegion + + @usage + function onCrusadeEnds(targetSettlement, targetRegion) + --something here + end + */ + + /*** + Called before the faction's turn starts. + + @function onPreFactionTurnStart + @tparam factionStruct faction + @tparam string religion + + @usage + function onPreFactionTurnStart(faction, religion) + --something here + end + */ + + /*** + Called at a faction's turn start. + + @function onFactionTurnStart + @tparam factionStruct faction + @tparam string religion + + @usage + function onFactionTurnStart(faction, religion) + --something here + end + */ + + /*** + Called after faction changes to a new capital. + + @function onFactionNewCapital + @tparam factionStruct faction + @tparam string religion + + @usage + function onFactionNewCapital(faction, religion) + newCapital=fac.capital(); + end + */ + + /*** + Called at a faction's turn end. + + @function onFactionTurnEnd + @tparam factionStruct faction + @tparam string religion + + @usage + function onFactionTurnEnd(faction, religion) + --something here + end + */ + + /*** + A Faction has voted for the new pope. + + @function onVotedForPope + @tparam factionStruct faction + @tparam string religion + + @usage + function onVotedForPope(faction, religion) + --something here + end + */ + + /*** + A Faction has been excommunicated. + + @function onFactionExcommunicated + @tparam factionStruct faction + @tparam string religion + + @usage + function onFactionExcommunicated(faction, religion) + --something here + end + */ + + /*** + A Faction has formed a horde. + + @function onHordeFormed + @tparam factionStruct faction + @tparam string religion + + @usage + function onHordeFormed(faction, religion) + --something here + end + */ + + /*** + A cardinal has been removed from the game. + + @function onCardinalRemoved + @tparam factionStruct faction + @tparam string religion + + @usage + function onCardinalRemoved(faction, religion) + --something here + end + */ + + /*** + An inquisitor has been dispatched to a region. + + @function onInquisitorAppointed + @tparam factionStruct faction + @tparam string religion + + @usage + function onInquisitorAppointed(faction, religion) + --something here + end + */ + + /*** + An assassination mission against the pope has failed and the assassin is executed. + + @function onAssassinCaughtAttackingPope + @tparam factionStruct faction + @tparam string religion + + @usage + function onAssassinCaughtAttackingPope(faction, religion) + --something here + end + */ + + /*** + The battle AI has begun processing. + + @function onBattleAiCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleAiCommenced(faction, religion) + --something here + end + */ + + /*** + The delay phase has begun. + + @function onBattleDelayPhaseCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleDelayPhaseCommenced(faction, religion) + --something here + end + */ + + /*** + The deployment phase has begun. + + @function onBattleDeploymentPhaseCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleDeploymentPhaseCommenced(faction, religion) + --something here + end + */ + + /*** + The conflict phase has begun. + + @function onBattleConflictPhaseCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleConflictPhaseCommenced(faction, religion) + --something here + end + */ + + /*** + Called after a faction declares a war. + + @function onFactionWarDeclared + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onFactionWarDeclared(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + Called after a faction declares an alliance. + + @function onFactionAllianceDeclared + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onFactionAllianceDeclared(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A marriage has occured between two factions. gets fired for both factions involved. + + @function onInterFactionMarriage + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onInterFactionMarriage(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + Called after a faction makes a trade agreement. + + @function onFactionTradeAgreementMade + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onFactionTradeAgreementMade(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A new pope has been elected. + + @function onPopeElected + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onPopeElected(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + Called after a faction breaks an alliance. + + @function onFactionBreakAlliance + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onFactionBreakAlliance(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A faction to faction attitude update has occurred (once every round). + + @function onUpdateAttitude + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onUpdateAttitude(faction, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A demeanour response has occured in diplomacy talks. + + @function onDemeanour + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + @tparam float amountChange + + @usage + function onDemeanour(faction, religion, targetFaction, targetReligion, amountChange) + --something + end + */ + + /*** + Called after a faction gives money to another faction. + + @function onGiveMoney + @tparam factionStruct faction + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + @tparam int amount + + @usage + function onGiveMoney(faction, religion, targetFaction, targetReligion, amount) + --something + end + */ + + /*** + A player unit has attacked one of the enemies units. + + @function onBattlePlayerUnitAttacksEnemyUnit + @tparam unit attackingUnit + @tparam unit defendingUnit + @tparam unit playerUnit + @tparam unit enemyUnit + + @usage + function onBattlePlayerUnitAttacksEnemyUnit(attackingUnit, defendingUnit, playerUnit, enemyUnit) + --something here + end + */ + + /*** + An enemy unit has attacked one of the players units. + + @function onBattleEnemyUnitAttacksPlayerUnit + @tparam unit attackingUnit + @tparam unit defendingUnit + @tparam unit playerUnit + @tparam unit enemyUnit + + @usage + function onBattleEnemyUnitAttacksPlayerUnit(attackingUnit, defendingUnit, playerUnit, enemyUnit) + --something here + end + */ + + /*** + One of the player's units has gone berserk. + + @function onBattlePlayerUnitGoesBerserk + @tparam unit playerUnit + + @usage + function onBattlePlayerUnitGoesBerserk(playerUnit) + --something here + end + */ + + /*** + One of the player's units has routed. + + @function onBattlePlayerUnitRouts + @tparam unit playerUnit + + @usage + function onBattlePlayerUnitRouts(playerUnit) + --something here + end + */ + + /*** + A siege engine belonging to the player has been destroyed. + + @function onBattlePlayerSiegeEngineDestroyed + @tparam unit playerUnit + + @usage + function onBattlePlayerSiegeEngineDestroyed(playerUnit) + --something here + end + */ + + /*** + A player's engine has started attacking a gate. + + @function onBattleGatesAttackedByPlayerEngine + @tparam unit playerUnit + + @usage + function onBattleGatesAttackedByPlayerEngine(playerUnit) + --something here + end + */ + + /*** + One of the enemy's units has gone berserk. + + @function onBattleEnemyUnitGoesBerserk + @tparam unit enemyUnit + + @usage + function onBattleEnemyUnitGoesBerserk(enemyUnit) + --something here + end + */ + + /*** + One of the enemy's units has routed. + + @function onBattnemyUnitRouts + @tparam unit enemyUnit + + @usage + function onBattnemyUnitRouts(enemyUnit) + --something here + end + */ + + /*** + A siege engine belonging to the enemy has been destroyed. + + @function onBattnemySiegeEngineDestroyed + @tparam unit enemyUnit + + @usage + function onBattnemySiegeEngineDestroyed(enemyUnit) + --something here + end + */ + + /*** + An enemy's engine has started attacking a gate. + + @function onBattleGatesAttackedByEnemyEngine + @tparam unit enemyUnit + + @usage + function onBattleGatesAttackedByEnemyEngine(enemyUnit) + --something here + end + */ + + /*** + When a particular disaster has just happened. + + @function onDisaster + @tparam string eventType (earthquake, flood, storm, volcano, plague) + + @usage + function onDisaster(eventType) + if eventType == "earthquake" then + --something here + end + end + */ + + /*** + An event counter has changed it's value. + + @function onEventCounter + @tparam string counter + + @usage + function onEventCounter(counter) + if counter == "my_event_counter" then + --something here + end + end + */ + + /*** + The last unit has been removed from a fort, agents do not count. + + @function onUngarrisonedFort + @tparam fortStruct fort + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onUngarrisonedFort(fort, faction, region, religion) + --something here + end + */ + + /*** + An object of the target faction has been seen by the faction. + + @function onObjSeen + @tparam factionStruct fac Faction that saw the object. + @tparam factionStruct targetFac Faction that owns the object. + @tparam int xCoord + @tparam int yCoord + + @usage + function onObjSeen(faction, targetFaction, x, y, region, religion) + --something here + end + */ + + /*** + The tile has been seen by the faction. + + @function onTileSeen + @tparam factionStruct faction + @tparam int xCoord + @tparam int yCoord + @tparam regionStruct region + @tparam string religion + + @usage + function onTileSeen(faction, x, y, region, religion) + --something here + end + */ + + /*** + A faction to faction transgression has occurred. + + @function onTransgression + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam string transgression (TC_THREATEN_WAR, TC_DECLARED_WAR, TC_MINOR_ASSASSINATION_ATTEMPT, TC_BROKE_TREATY_TERMS, TC_BROKE_ALLIANCE, TC_INVASION) + @tparam string religion + @tparam string targetReligion + + @usage + function onTransgression(faction, targetFaction, transgression, religion, targetReligion) + --something here + end + */ + + /*** + A faction to faction forgiveness has occurred. + + @function onForgiveness + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam string forgiveness (not sure what this could be) + @tparam string religion + @tparam string targetReligion + + @usage + function onForgiveness(faction, targetFaction, forgiveness, religion, targetReligion) + --something here + end + */ + + /*** + An army has taken a crusade or jihad target settlement. + + @function onArmyTakesCrusadeTarget + @tparam settlementStruct targetSettlement + @tparam stackStruct army + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string religion + @tparam string targetReligion + + @usage + function onArmyTakesCrusadeTarget(targetSettlement, army, faction, targetFaction, targetRegion, religion, targetReligion) + --something here + end + */ + + /*** + Units have deserted a crusade or jihad. + + @function onUnitsDesertCrusade + @tparam settlementStruct targetSettlement + @tparam factionStruct faction + @tparam factionStruct targetFaction + @tparam regionStruct targetRegion + @tparam string religion + @tparam string targetReligion + + @usage + function onUnitsDesertCrusade(targetSettlement, faction, targetFaction, targetRegion, religion, targetReligion) + --something here + end + */ + + + + + /*** + Called every time an image is rendered for display + + @function draw + @tparam LPDIRECT3DDEVICE9 pDevice + + @usage + function draw(device) + ImGui.Begin("test"); + + ImGui.Text("Some test text") + + ImGui.End(); + end + */ + drawLuaFunc = new sol::function(luaState["draw"]); + checkLuaFunc(&drawLuaFunc); + + /*** + Called when ImGui backend reload fonts + + @function onLoadingFonts + + @usage + function onLoadingFonts() + --something here + end + */ + onLoadingFonts = new sol::function(luaState["onLoadingFonts"]); + checkLuaFunc(&onLoadingFonts); + + resetDXFunc = new sol::function(luaState["deinitDX"]); + checkLuaFunc(&resetDXFunc); + + initDXFunc = new sol::function(luaState["initDX"]); + checkLuaFunc(&initDXFunc); + + /*** + Called when a new campaign is started from the menu. + + @function onNewGameStart + + @usage + function onNewGameStart() + --something here + end + */ + + + + onNewGameStart = new sol::function(luaState["onNewGameStart"]); + checkLuaFunc(&onNewGameStart); + + /*** + Called after the game loads various db`s (edu, etc) at startup. + + @function onReadGameDbsAtStart + + @usage + function onReadGameDbsAtStart() + --something here + end + */ + + + + onReadGameDbsAtStart = new sol::function(luaState["onReadGameDbsAtStart"]); + checkLuaFunc(&onReadGameDbsAtStart); + + /*** + Called on clicking the stratmap. + + @function onClickAtTile + @tparam int x + @tparam int y + @usage + clickAtMap={["isClicked"]=false,["xTile"]=0,["yTile"]=0} + function draw(device) + if(clickAtMap.isClicked==true) + then + print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Right)).."\n"); + print(tostring(ImGui.IsMouseDown(ImGuiMouseButton.ImGuiMouseButton_Left)).."\n"); + print(tostring(clickAtMap.xTile).." "..tostring(clickAtMap.yTile)); + + clickAtMap.isClicked=false; + end + end + + function onClickAtTile(x,y) + clickAtMap.isClicked=true; + clickAtMap.xTile=x; + clickAtMap.yTile=y; + end + */ + + + + onClickAtTile = new sol::function(luaState["onClickAtTile"]); + checkLuaFunc(&onClickAtTile); + + /*** + Called after loading the campaign map + + @function onCampaignMapLoaded + + @usage + function onCampaignMapLoaded() + --something here + end + */ + + + + onCampaignMapLoaded = new sol::function(luaState["onCampaignMapLoaded"]); + checkLuaFunc(&onCampaignMapLoaded); + + /*** + Called on plugin load (at game start). + + @function onPluginLoad + + @usage + --An example of using this event to perform actions at the beginning of a campaign once: + + isCampaignLoadedFirstTime=false; + function onNewGameStart() + isCampaignLoadedFirstTime=true; + end + + function onCampaignMapLoaded() + if(isCampaignLoadedFirstTime==false) + then + do return end + end + + + --here we do our stuff, what works only one time for each campaign + isCampaignLoadedFirstTime=false; + end + */ + + + + onPluginLoad = new sol::function(luaState["onPluginLoad"]); + checkLuaFunc(&onPluginLoad); + + + /*** + Called on creating a new save file. + + @function onCreateSaveFile + + @usage + function onCreateSaveFile() + local savefiles, currentPath = {}, M2TWEOP.getPluginPath() + savefiles[1] = currentPath.."\\testSaveFile1.ourSave" + savefiles[2] = currentPath.."\\testSaveFile2.ourSave" + + file1 = io.open(savefiles[1], "w"); file1:write("This is save file 1!!!"); file1:close() + file2 = io.open(savefiles[2], "w"); file2:write("This is save file 2!!!"); file2:close() + + return savefiles + end + */ + onCreateSaveFile = new sol::function(luaState["onCreateSaveFile"]); + checkLuaFunc(&onCreateSaveFile); + + /*** + Called on loading a save file. + + @function onLoadSaveFile + + @usage + function onLoadSaveFile(paths) + lastSaveFiles={}; + for key, value in pairs(paths) do + + print(key, " -- ", value); + + lastSaveFiles[key]={}; + lastSaveFiles[key][1]=value; + lastSaveFiles[key][2]=readFile(value); + + end + end + + + --read file and return it`s content + local function readFile(path) + local file = io.open(path, "r") ; + if (not file) then return nil end + local content = file:read "*a"; + file:close(); + return content; + end + */ + onLoadSaveFile = new sol::function(luaState["onLoadSaveFile"]); + checkLuaFunc(&onLoadSaveFile); + + + /*** + Called at the start of a new turn. + + @function onChangeTurnNum + @tparam int turnNumber + + @usage + function onChangeTurnNum(turnNum) + --something here + end + */ + onChangeTurnNumFunc = new sol::function(luaState["onChangeTurnNum"]); + checkLuaFunc(&onChangeTurnNumFunc); + + /*** + Called on select worldpkgdesc for battlemap. See https://wiki.twcenter.net/index.php?title=.worldpkgdesc_-_M2TW. M2TWEOP will ignore the return value if its group does not match the required group! + + @function onSelectWorldpkgdesc + @tparam string selectedRecordName + @tparam string selectedRecordGroup + @treturn string newSelectedRecordName + + @usage + function onSelectWorldpkgdesc(selectedRecord,selectedRecordGroup) + --something here + + return selectedRecord; + end + */ + onSelectWorldpkgdesc = new sol::function(luaState["onSelectWorldpkgdesc"]); + checkLuaFunc(&onSelectWorldpkgdesc); + /*** + Called on specified fortificationlevel in a siege of a settlement. + + @function onfortificationlevelS + @tparam settlementStruct siegedSettlement + @treturn int overridedFortificationlevel + @treturn bool isCastle override settlement type (siege equipment is slightly different between cities and castles of the same level) + + @usage + function onfortificationlevelS(settlement) + if settlement.xCoord == 10 and settlement.yCoord == 25 then + return 3, false --override settlement under siege at these coordinates to level 3 city + end + return nil --else, do not override + end + */ + onfortificationlevelS = new sol::function(luaState["onfortificationlevelS"]); + checkLuaFunc(&onfortificationlevelS); + + /*** + Called on the completion of the siege (in any way, with any outcome). + + @function onEndSiege + @tparam int xCoord x coordinate of siege(settlement or fort) + @tparam int yCoord y coordinate of siege(settlement or fort) + + @usage + function onEndSiege(x,y) + --something here + end + */ + onEndSiege = new sol::function(luaState["onEndSiege"]); + checkLuaFunc(&onEndSiege); + /*** + Called on the starting of the siege (in any way, with any outcome). + + @function onStartSiege + @tparam int xCoord x coordinate of siege(settlement or fort) + @tparam int yCoord y coordinate of siege(settlement or fort) + + @usage + function onStartSiege(x,y) + --something here + end + */ + onStartSiege = new sol::function(luaState["onStartSiege"]); + checkLuaFunc(&onStartSiege); + /*** + A character has been selected by any means (including through the UI). + + @function onCharacterSelected + @tparam namedCharacter selectedChar + + @usage + function onCharacterSelected(selectedChar) + --something here + end + */ + onCharacterSelectedFunc = new sol::function(luaState["onCharacterSelected"]); + checkLuaFunc(&onCharacterSelectedFunc); + + /*** + Siege equipment has been completed by one of the sieging armies at this residence. + + @function onSiegeEquipmentCompleted + @tparam settlementStruct settlement nil if it is fort + @tparam fortStruct fort nil if it is settlement + + @usage + --something + */ + + onSiegeEquipmentCompletedFunc = new sol::function(luaState["onSiegeEquipmentCompleted"]); + checkLuaFunc(&onSiegeEquipmentCompletedFunc); + /*** - A unit has been disbanded. + The player has attempted to move a character beyond that character's given movement range for that turn. - @function onUnitDisbanded - @tparam factionStruct fac - @tparam unit unit + @function onMultiTurnMove + @tparam namedCharacter character @usage --something */ - onUnitDisbandedFunc = new sol::function(luaState["onUnitDisbanded"]); - checkLuaFunc(&onUnitDisbandedFunc); + onMultiTurnMoveFunc = new sol::function(luaState["onMultiTurnMove"]); + checkLuaFunc(&onMultiTurnMoveFunc); /*** - A unit has been trained. + A settlement has been selected by any means (including through the UI). - @function onUnitTrained - @tparam factionStruct fac - @tparam settlementStruct sett - @tparam unit unit + @function onSettlementSelected + @tparam settlementStruct settlement @usage - --something + function onSettlementSelected(settlement) + print("Function: onSettlementSelected()\n\tSettlement: "..settlement.name) + end */ - onUnitTrainedFunc = new sol::function(luaState["onUnitTrained"]); - checkLuaFunc(&onUnitTrainedFunc); + onSettlementSelectedFunc = new sol::function(luaState["onSettlementSelected"]); + checkLuaFunc(&onSettlementSelectedFunc); /*** - An agent has been trained. + A settlement's level has been increased. - @function onAgentCreated - @tparam namedCharacter character - @tparam int agentType see @{character:setTypeID} for list of type integers - @tparam settlementStruct sett + @function onSettlementUpgraded + @tparam settlementStruct settlement @usage - --something + function onSettlementUpgraded(settlement) + print("Function: onSettlementUpgraded()\n\tSettlement Level: "..settlement.level) + end */ - onAgentCreatedFunc = new sol::function(luaState["onAgentCreated"]); - checkLuaFunc(&onAgentCreatedFunc); + onSettlementUpgradedFunc = new sol::function(luaState["onSettlementUpgraded"]); + checkLuaFunc(&onSettlementUpgradedFunc); /*** - An object of the target faction has been seen by the faction. + A settlement converted between city and castle and vice-versa. - @function onObjSeen - @tparam factionStruct fac Faction that saw the object. - @tparam factionStruct targetFac Faction that owns the object. - @tparam int xCoord - @tparam int yCoord + @function onSettlementConverted + @tparam settlementStruct settlement @usage - --something + function onSettlementConverted(settlement) + if settlement.isCastle == 1 then + --do stuff + end + end */ - onObjSeenFunc = new sol::function(luaState["onObjSeen"]); - checkLuaFunc(&onObjSeenFunc); + onSettlementConvertedFunc = new sol::function(luaState["onSettlementConverted"]); + checkLuaFunc(&onSettlementConvertedFunc); /*** - The tile has been seen by the faction. + A settlement has rioted. - @function onTileSeen - @tparam factionStruct fac - @tparam int xCoord - @tparam int yCoord + @function onCityRiots + @tparam settlementStruct settlement @usage --something */ - onTileSeenFunc = new sol::function(luaState["onTileSeen"]); - checkLuaFunc(&onTileSeenFunc); + onCityRiotsFunc = new sol::function(luaState["onCityRiots"]); + checkLuaFunc(&onCityRiotsFunc); /*** - The game has been reloaded while on the strategy map. + The last unit has been removed from a settlement, agents do not count. - @function onGameReloaded - @tparam int something + @function onUngarrisonedSettlement + @tparam settlementStruct settlement @usage --something */ - onGameReloadedFunc = new sol::function(luaState["onGameReloaded"]); - checkLuaFunc(&onGameReloadedFunc); + onUngarrisonedSettlementFunc = new sol::function(luaState["onUngarrisonedSettlement"]); + checkLuaFunc(&onUngarrisonedSettlementFunc); + /*** - A faction to faction transgression has occurred. + A settlement has been given to another faction. + + @function onGiveSettlement + @tparam settlementStruct settlement + @tparam factionStruct fac1 + @tparam factionStruct fac2 - @function onTransgression - @tparam factionStruct fac - @tparam string description - @tparam factionStruct targetFac @usage --something */ - onTransgressionFunc = new sol::function(luaState["onTransgression"]); - checkLuaFunc(&onTransgressionFunc); + onGiveSettlementFunc = new sol::function(luaState["onGiveSettlement"]); + checkLuaFunc(&onGiveSettlementFunc); /*** - The Pope has accepted the player's crusade target. Deus Vult! + A general has captured a settlement and the occupy option has been chosen - @function onPopeAcceptsCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onOccupySettlement + @tparam namedCharacter character only generals, event does not fire for captains + @tparam factionStruct targetFaction @usage --something */ - onPopeAcceptsCrusadeTargetFunc = new sol::function(luaState["onPopeAcceptsCrusadeTarget"]); - checkLuaFunc(&onPopeAcceptsCrusadeTargetFunc); + onOccupySettlementFunc = new sol::function(luaState["onOccupySettlement"]); + checkLuaFunc(&onOccupySettlementFunc); /*** - A Crusade or Jihad has been called. + A general has captured a settlement and the exterminate option has been chosen. + + @function onExterminatePopulation + @tparam namedCharacter character only generals, event does not fire for captains + @tparam factionStruct targetFaction - @function onCrusadeCalled - @tparam crusadeStruct crusade - @tparam settlementStruct target @usage --something */ - onCrusadeCalledFunc = new sol::function(luaState["onCrusadeCalled"]); - checkLuaFunc(&onCrusadeCalledFunc); + onExterminatePopulationFunc = new sol::function(luaState["onExterminatePopulation"]); + checkLuaFunc(&onExterminatePopulationFunc); /*** - A Crusade or Jihad has ended. + A general has captured a settlement and the sack option has been chosen. + + @function onSackSettlement + @tparam namedCharacter character only generals, event does not fire for captains + @tparam factionStruct targetFaction - @function onCrusadeEnds - @tparam crusadeStruct crusade - @tparam settlementStruct target @usage --something */ - onCrusadeEndsFunc = new sol::function(luaState["onCrusadeEnds"]); - checkLuaFunc(&onCrusadeEndsFunc); + onSackSettlementFunc = new sol::function(luaState["onSackSettlement"]); + checkLuaFunc(&onSackSettlementFunc); /*** - The Pope has rejected the player's crusade target. + A building has been added to the construction queue. + + @function onAddedToBuildingQueue + @tparam settlementStruct settlement + @tparam string buildNme level name - @function onPopeRejectsCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target @usage --something */ - onPopeRejectsCrusadeTargetFunc = new sol::function(luaState["onPopeRejectsCrusadeTarget"]); - checkLuaFunc(&onPopeRejectsCrusadeTargetFunc); + onAddedToBuildingQueueFunc = new sol::function(luaState["onAddedToBuildingQueue"]); + checkLuaFunc(&onAddedToBuildingQueueFunc); /*** - An army has taken a crusade or jihad target settlement. + A building has been destroyed. + + @function onBuildingDestroyed + @tparam settlementStruct settlement + @tparam string buildNme level name - @function onArmyTakesCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target - @tparam stackStruct army @usage --something */ - onArmyTakesCrusadeTargetFunc = new sol::function(luaState["onArmyTakesCrusadeTarget"]); - checkLuaFunc(&onArmyTakesCrusadeTargetFunc); + onBuildingDestroyedFunc = new sol::function(luaState["onBuildingDestroyed"]); + checkLuaFunc(&onBuildingDestroyedFunc); /*** - Units have deserted a crusade or jihad. + A building has been completed. - @function onUnitsDesertCrusade - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onBuildingCompleted @tparam factionStruct fac + @tparam settlementStruct settlement @usage --something */ - onUnitsDesertCrusadeFunc = new sol::function(luaState["onUnitsDesertCrusade"]); - checkLuaFunc(&onUnitsDesertCrusadeFunc); + onBuildingCompletedFunc = new sol::function(luaState["onBuildingCompleted"]); + checkLuaFunc(&onBuildingCompletedFunc); + /*** - A new pope has been elected. + A unit has been added to the training queue. - @function onPopeElected - @tparam factionStruct fac - @tparam factionStruct fac2 + @function onAddedToTrainingQueue + @tparam settlementStruct sett + @tparam string unitName @usage --something */ - onPopeElectedFunc = new sol::function(luaState["onPopeElected"]); - checkLuaFunc(&onPopeElectedFunc); + onAddedToTrainingQueueFunc = new sol::function(luaState["onAddedToTrainingQueue"]); + checkLuaFunc(&onAddedToTrainingQueueFunc); /*** - A Faction has voted for the new pope. + A unit has been trained. - @function onVotedForPope + @function onUnitTrained @tparam factionStruct fac + @tparam settlementStruct sett + @tparam unit unit @usage --something */ - onVotedForPopeFunc = new sol::function(luaState["onVotedForPope"]); - checkLuaFunc(&onVotedForPopeFunc); + onUnitTrainedFunc = new sol::function(luaState["onUnitTrained"]); + checkLuaFunc(&onUnitTrainedFunc); /*** - An assassination mission against the pope has failed and the assassin is executed. + An agent has been trained. - @function onAssassinCaughtAttackingPope - @tparam factionStruct fac + @function onAgentCreated + @tparam namedCharacter character + @tparam int agentType see @{character:setTypeID} for list of type integers + @tparam settlementStruct sett @usage --something */ - onAssassinCaughtAttackingPopeFunc = new sol::function(luaState["onAssassinCaughtAttackingPope"]); - checkLuaFunc(&onAssassinCaughtAttackingPopeFunc); + onAgentCreatedFunc = new sol::function(luaState["onAgentCreated"]); + checkLuaFunc(&onAgentCreatedFunc); /*** - An inquisitor has been dispatched to a region. + An assassination mission against the pope has failed and the assassin is executed. - @function onInquisitorAppointed + @function onAssassinCaughtAttackingPope @tparam factionStruct fac - @tparam settlementStruct sett @usage --something */ - onInquisitorAppointedFunc = new sol::function(luaState["onInquisitorAppointed"]); - checkLuaFunc(&onInquisitorAppointedFunc); + onAssassinCaughtAttackingPopeFunc = new sol::function(luaState["onAssassinCaughtAttackingPope"]); + checkLuaFunc(&onAssassinCaughtAttackingPopeFunc); /*** The player has opened the panel for the selected settlement. @@ -1562,101 +3393,6 @@ void luaP::onPluginLoadF() onGuildDestroyedFunc = new sol::function(luaState["onGuildDestroyed"]); checkLuaFunc(&onGuildDestroyedFunc); - /*** - A character in the family tree has received a brother by adoption. - - @function onBrotherAdopted - @tparam namedCharacter character This is the original child, not the newly adopted character. - - @usage - function onBrotherAdopted(character) - print("Function: onBrotherAdopted()\n\tName: "..character.fullName.."\n\tParent: "..character.parent.fullName.."\n\tFaction: "..character.faction:getFactionName()) - end - */ - - onBrotherAdoptedFunc = new sol::function(luaState["onBrotherAdopted"]); - checkLuaFunc(&onBrotherAdoptedFunc); - - /*** - A child has been born. - - @function onBirth - @tparam namedCharacter child - - @usage - function onBirth(child) - print("Function: onBirth()\n\tChild Name: "..child.fullName.."\n\tParent: "..child.parent.fullName.."\n\tFaction: "..child.faction:getFactionName()) - end - */ - - onBirthFunc = new sol::function(luaState["onBirth"]); - checkLuaFunc(&onBirthFunc); - - /*** - A character has come of age. - - @function onCharacterComesOfAge - @tparam namedCharacter character Character's age is equal to age\_of\_manhood in descr\_campaign\_db.xml. - - @usage - function onCharacterComesOfAge(character) - print("Function: onCharacterComesOfAge()\n\tName: "..character.fullName.."\n\tParent: "..character.parent.fullName.."\n\tFaction: "..character.faction:getFactionName()) - end - */ - - onCharacterComesOfAgeFunc = new sol::function(luaState["onCharacterComesOfAge"]); - checkLuaFunc(&onCharacterComesOfAgeFunc); - - /*** - A character has married (someone who isn't a princess). - - @function onCharacterMarries - @tparam namedCharacter husband - - @usage - function onCharacterMarries(husband) - print("Function: onCharacterMarries()\n\tName: "..husband.fullName.."\n\tSpouse: "..husband.spouse.fullName.."\n\tFaction: "..husband.faction:getFactionName()) - end - */ - - onCharacterMarriesFunc = new sol::function(luaState["onCharacterMarries"]); - checkLuaFunc(&onCharacterMarriesFunc); - - /*** - A character has married a princess agent. - - @function onCharacterMarriesPrincess - @tparam namedCharacter husband - - @usage - function onCharacterMarriesPrincess(husband) - print("Function: onCharacterMarriesPrincess()\n\tName: "..husband.fullName.."\n\tSpouse: "..husband.spouse.fullName.."\n\tFaction: "..husband.faction:getFactionName()) - end - */ - - onCharacterMarriesPrincessFunc = new sol::function(luaState["onCharacterMarriesPrincess"]); - checkLuaFunc(&onCharacterMarriesPrincessFunc); - - /*** - A child has been born. - - @function onCharacterBecomesAFather - @tparam namedCharacter father Note: this event fires for all child births for this father, not just the first one. - - @usage - function onCharacterBecomesAFather(father) - local i, children = 1, "" - while father.childs[i] ~= nil do - children, i = children.." "..father.childs[i].fullName..",", i + 1 - end - children = children:gsub(",$", "") - print("Function: onCharacterBecomesAFather()\n\tName: "..father.fullName.."\n\tChildren:"..children.."\n\tFaction: "..father.faction:getFactionName()) - end - */ - - onCharacterBecomesAFatherFunc = new sol::function(luaState["onCharacterBecomesAFather"]); - checkLuaFunc(&onCharacterBecomesAFatherFunc); - /*** A new admiral has been created for a new ship. @@ -1690,36 +3426,6 @@ void luaP::onPluginLoadF() onShortcutTriggeredFunc = new sol::function(luaState["onShortcutTriggered"]); checkLuaFunc(&onShortcutTriggeredFunc); - /*** - The character has been made the faction leader. - - @function onBecomesFactionLeader - @tparam namedCharacter leader - - @usage - function onBecomesFactionLeader(leader) - print("Function: onBecomesFactionLeader()\n\tLeader: "..leader.fullName) - end - */ - - onBecomesFactionLeaderFunc = new sol::function(luaState["onBecomesFactionLeader"]); - checkLuaFunc(&onBecomesFactionLeaderFunc); - - /*** - The character has been made a faction heir. - - @function onBecomesFactionHeir - @tparam namedCharacter heir - - @usage - function onBecomesFactionHeir(heir) - print("Function: onBecomesFactionHeir()\n\tHeir: "..heir.fullName) - end - */ - - onBecomesFactionHeirFunc = new sol::function(luaState["onBecomesFactionHeir"]); - checkLuaFunc(&onBecomesFactionHeirFunc); - if (onPluginLoad != nullptr) { diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h index e8a8682d9..9dfc70d15 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h @@ -22,7 +22,7 @@ #include "realGameTypes.h" namespace luaGetSetFuncs { - int getTraitLevel(const traitContainer*currTrait); + int getTraitLevel(const traitContainer* currTrait); std::string getTraitName(const traitContainer* currTrait); traitContainer* getNextTrait(const traitContainer* currTrait); @@ -115,12 +115,12 @@ namespace luaGetSetFuncs } #pragma endregion -#pragma region generalCharacterictics +#pragma region namedCharacter - //generalCharacterictics + //namedCharacter template - std::string getStringPropertyGenChar(const generalCharacterictics* genChar) + std::string getStringPropertyGenChar(const namedCharacter* genChar) { char* retS = nullptr; if (fieldIndex == generalCharactericticsStruct_shortName) @@ -162,7 +162,7 @@ namespace luaGetSetFuncs } } template - void setStringPropertyGenChar(generalCharacterictics* genChar, std::string newS) + void setStringPropertyGenChar(namedCharacter* genChar, std::string newS) { char* arg = nullptr; if (fieldIndex == generalCharactericticsStruct_shortName) @@ -211,7 +211,7 @@ namespace luaGetSetFuncs //general template - std::string getStringPropertyEDU(const EduEntry* eduEn) + std::string getStringPropertyEDU(const eduEntry* eduEn) { char* retS = nullptr; if (fieldIndex == EduEntryStruct_Type) @@ -242,7 +242,7 @@ namespace luaGetSetFuncs } template - void setStringPropertyEDU(EduEntry* eduEn, std::string newS) + void setStringPropertyEDU(eduEntry* eduEn, std::string newS) { char* arg = nullptr; if (fieldIndex == EduEntryStruct_Type) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index f1ee418a4..d9099793f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -75,7 +75,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) - struct { sol::table M2TWEOPTable; @@ -99,10 +98,13 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypeunit; sol::usertypecharacter; - sol::usertypenamedCharacter; + sol::usertypenamedCharacter; + sol::usertypecapturedFactionInfo; + sol::usertypecapturedUnit; + sol::usertypecapturedCharacter; sol::usertypeancillary; sol::usertypetraitContainerT; - sol::usertypeEduEntry; + sol::usertypeEduEntry; sol::usertypefactionStruct; sol::usertypefactionStratMapStruct; sol::usertypewatchtowerStruct; @@ -915,7 +917,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @table eduEntry */ - types.EduEntry = luaState.new_usertype("eduEntry"); + types.EduEntry = luaState.new_usertype("eduEntry"); types.EduEntry.set("Type", sol::property( &luaGetSetFuncs::getStringPropertyEDU, &luaGetSetFuncs::setStringPropertyEDU )); @@ -928,38 +930,38 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.EduEntry.set("InfoCardTga", sol::property( &luaGetSetFuncs::getStringPropertyEDU, &luaGetSetFuncs::setStringPropertyEDU )); - types.EduEntry.set("Index", &EduEntry::Index); - types.EduEntry.set("UnitCreatedCounter", &EduEntry::UnitCreatedCounter); - types.EduEntry.set("SoldierCount", &EduEntry::SoldierCount); - types.EduEntry.set("Mass", &EduEntry::Mass); - types.EduEntry.set("Width", &EduEntry::Width); - types.EduEntry.set("Height", &EduEntry::Height); + types.EduEntry.set("Index", &eduEntry::Index); + types.EduEntry.set("UnitCreatedCounter", &eduEntry::UnitCreatedCounter); + types.EduEntry.set("SoldierCount", &eduEntry::SoldierCount); + types.EduEntry.set("Mass", &eduEntry::Mass); + types.EduEntry.set("Width", &eduEntry::Width); + types.EduEntry.set("Height", &eduEntry::Height); types.EduEntry.set("haveAttributeLegio", sol::property(&eopEduHelpers::haveAttributeLegioGet, &eopEduHelpers::haveAttributeLegioSet)); - types.EduEntry.set("MoveSpeedMod", &EduEntry::MoveSpeedMod); - types.EduEntry.set("UnitSpacingFrontToBackClose", &EduEntry::UnitSpacingFrontToBackClose); - types.EduEntry.set("UnitSpacingSideToSideClose", &EduEntry::UnitSpacingSideToSideClose); - types.EduEntry.set("UnitSpacingFrontToBackLoose", &EduEntry::UnitSpacingFrontToBackLoose); - types.EduEntry.set("UnitSpacingSideToSideLoose", &EduEntry::UnitSpacingSideToSideLoose); - types.EduEntry.set("StatHealth", &EduEntry::StatHealth); - types.EduEntry.set("StatHealthAnimal", &EduEntry::StatHealthAnimal); - types.EduEntry.set("StatHeat", &EduEntry::StatHeat); - types.EduEntry.set("StatGround1", &EduEntry::StatGround1); - types.EduEntry.set("StatGround2", &EduEntry::StatGround2); - types.EduEntry.set("StatGround3", &EduEntry::StatGround3); - types.EduEntry.set("StatGround4", &EduEntry::StatGround4); - types.EduEntry.set("StatCost1", &EduEntry::StatCost1); - types.EduEntry.set("StatCost2", &EduEntry::StatCost2); - types.EduEntry.set("StatCost3", &EduEntry::StatCost3); - types.EduEntry.set("StatCost4", &EduEntry::StatCost4); - types.EduEntry.set("StatCost5", &EduEntry::StatCost5); - types.EduEntry.set("StatCost6", &EduEntry::StatCost6); - types.EduEntry.set("StatCost7", &EduEntry::StatCost7); - types.EduEntry.set("StatCost8", &EduEntry::StatCost8); - types.EduEntry.set("Morale", &EduEntry::Morale); - types.EduEntry.set("MoraleLocked", &EduEntry::MoraleLocked); - types.EduEntry.set("StatFood1", &EduEntry::StatFood1); - types.EduEntry.set("StatFood2", &EduEntry::StatFood2); - types.EduEntry.set("Ammunition", &EduEntry::Ammunition); + types.EduEntry.set("MoveSpeedMod", &eduEntry::MoveSpeedMod); + types.EduEntry.set("UnitSpacingFrontToBackClose", &eduEntry::UnitSpacingFrontToBackClose); + types.EduEntry.set("UnitSpacingSideToSideClose", &eduEntry::UnitSpacingSideToSideClose); + types.EduEntry.set("UnitSpacingFrontToBackLoose", &eduEntry::UnitSpacingFrontToBackLoose); + types.EduEntry.set("UnitSpacingSideToSideLoose", &eduEntry::UnitSpacingSideToSideLoose); + types.EduEntry.set("StatHealth", &eduEntry::StatHealth); + types.EduEntry.set("StatHealthAnimal", &eduEntry::StatHealthAnimal); + types.EduEntry.set("StatHeat", &eduEntry::StatHeat); + types.EduEntry.set("StatGround1", &eduEntry::StatGround1); + types.EduEntry.set("StatGround2", &eduEntry::StatGround2); + types.EduEntry.set("StatGround3", &eduEntry::StatGround3); + types.EduEntry.set("StatGround4", &eduEntry::StatGround4); + types.EduEntry.set("StatCost1", &eduEntry::StatCost1); + types.EduEntry.set("StatCost2", &eduEntry::StatCost2); + types.EduEntry.set("StatCost3", &eduEntry::StatCost3); + types.EduEntry.set("StatCost4", &eduEntry::StatCost4); + types.EduEntry.set("StatCost5", &eduEntry::StatCost5); + types.EduEntry.set("StatCost6", &eduEntry::StatCost6); + types.EduEntry.set("StatCost7", &eduEntry::StatCost7); + types.EduEntry.set("StatCost8", &eduEntry::StatCost8); + types.EduEntry.set("Morale", &eduEntry::Morale); + types.EduEntry.set("MoraleLocked", &eduEntry::MoraleLocked); + types.EduEntry.set("StatFood1", &eduEntry::StatFood1); + types.EduEntry.set("StatFood2", &eduEntry::StatFood2); + types.EduEntry.set("Ammunition", &eduEntry::Ammunition); @@ -1192,9 +1194,9 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @table namedCharacter */ - types.namedCharacter = luaState.new_usertype("namedCharacter"); - types.namedCharacter.set("index", &generalCharacterictics::index); - types.namedCharacter.set("character", &generalCharacterictics::gen); + types.namedCharacter = luaState.new_usertype("namedCharacter"); + types.namedCharacter.set("index", &namedCharacter::index); + types.namedCharacter.set("character", &namedCharacter::gen); types.namedCharacter.set("shortName", sol::property(&luaGetSetFuncs::getStringPropertyGenChar, &luaGetSetFuncs::setStringPropertyGenChar)); types.namedCharacter.set("fullName", sol::property(&luaGetSetFuncs::getStringPropertyGenChar, &luaGetSetFuncs::setStringPropertyGenChar)); types.namedCharacter.set("localizedDisplayName", sol::property(&technicalHelpers::namedCharUniStringToStr, &technicalHelpers::namedCharSetLocalizedFullName)); @@ -1203,7 +1205,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.namedCharacter.set("portrait2", sol::property(&luaGetSetFuncs::getStringPropertyGenChar, &luaGetSetFuncs::setStringPropertyGenChar)); types.namedCharacter.set("portrait_custom", sol::property(&luaGetSetFuncs::getStringPropertyGenChar, &luaGetSetFuncs::setStringPropertyGenChar)); types.namedCharacter.set("modelName", sol::property(&luaGetSetFuncs::getStringPropertyGenChar, &luaGetSetFuncs::setStringPropertyGenChar)); - types.namedCharacter.set("status", &generalCharacterictics::status); + types.namedCharacter.set("status", &namedCharacter::status); /*** Sets the named character as the faction heir. @function namedCharacter:setAsHeir @@ -1224,12 +1226,12 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.namedCharacter.set_function("isAlive", &generalCharactericticsHelpers::isAlive); types.namedCharacter.set("isMale", sol::property(&generalCharactericticsHelpers::getIsMale, &generalCharactericticsHelpers::setIsMale)); types.namedCharacter.set("age", sol::property(&generalCharactericticsHelpers::getAge, &generalCharactericticsHelpers::setAge)); - types.namedCharacter.set("yearOfBirth", &generalCharacterictics::yearOfBirth); - types.namedCharacter.set("faction", &generalCharacterictics::faction); - types.namedCharacter.set("subFaction", &generalCharacterictics::subFaction); - types.namedCharacter.set("parent", &generalCharacterictics::parent); - types.namedCharacter.set("spouse", &generalCharacterictics::spouse); - types.namedCharacter.set("childs", sol::property([](generalCharacterictics& self) { return std::ref(self.childs); })); + types.namedCharacter.set("yearOfBirth", &namedCharacter::yearOfBirth); + types.namedCharacter.set("faction", &namedCharacter::faction); + types.namedCharacter.set("subFaction", &namedCharacter::subFaction); + types.namedCharacter.set("parent", &namedCharacter::parent); + types.namedCharacter.set("spouse", &namedCharacter::spouse); + types.namedCharacter.set("childs", sol::property([](namedCharacter& self) { return std::ref(self.childs); })); /*** Get the pointer to the character's traits container. @function namedCharacter:getTraits @@ -1259,7 +1261,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) ourNamedCharacter:removeTrait("GoodCommander"); */ types.namedCharacter.set_function("removeTrait", &generalCharactericticsHelpers::removeTrait); - types.namedCharacter.set("ancNum", &generalCharacterictics::anchNum); + types.namedCharacter.set("ancNum", &namedCharacter::anchNum); /*** Get the pointer to the ancillary using it's index. You can iterate over a character's ancillaries for example by going from index 0 to ancNum - 1. @function namedCharacter:getAncillary @@ -1286,69 +1288,148 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) ourNamedCharacter:removeAncillary(ourAnc); */ types.namedCharacter.set_function("removeAncillary", &generalCharactericticsHelpers::removeAnchillary); - types.namedCharacter.set("level", &generalCharacterictics::level); - types.namedCharacter.set("authority", &generalCharacterictics::leaderAutority); - types.namedCharacter.set("command", &generalCharacterictics::authority); - types.namedCharacter.set("chivalryAndDread", &generalCharacterictics::nobility); - types.namedCharacter.set("loyalty", &generalCharacterictics::loyality); - types.namedCharacter.set("piety", &generalCharacterictics::piety); - types.namedCharacter.set("influence", &generalCharacterictics::influence); - types.namedCharacter.set("subterfuge", &generalCharacterictics::subterfuge); - types.namedCharacter.set("charm", &generalCharacterictics::charm); - types.namedCharacter.set("finance", &generalCharacterictics::finance); - types.namedCharacter.set("magic", &generalCharacterictics::magic); - types.namedCharacter.set("unorthodoxy", &generalCharacterictics::unorthodoxy); - types.namedCharacter.set("heresyImmunity", &generalCharacterictics::heresyImmunity); - types.namedCharacter.set("assassination", &generalCharacterictics::assassination); - types.namedCharacter.set("sabotage", &generalCharacterictics::sabotage); - types.namedCharacter.set("eligibility", &generalCharacterictics::eligibility); - types.namedCharacter.set("purity", &generalCharacterictics::purity); - types.namedCharacter.set("violence", &generalCharacterictics::violence); - types.namedCharacter.set("disposition", &generalCharacterictics::disposition); - types.namedCharacter.set("boldness", &generalCharacterictics::boldness); - types.namedCharacter.set("generosity", &generalCharacterictics::generosity); - types.namedCharacter.set("management", &generalCharacterictics::management); - types.namedCharacter.set("bodyguardSize", &generalCharacterictics::bodyguardSize); - types.namedCharacter.set("troopMorale", &generalCharacterictics::troopMorale); - types.namedCharacter.set("movementPointsBonus", &generalCharacterictics::movementPointsBonus); - types.namedCharacter.set("attack", &generalCharacterictics::attack); - types.namedCharacter.set("defence", &generalCharacterictics::defence); - types.namedCharacter.set("siegeAttack", &generalCharacterictics::siegeAttack); - types.namedCharacter.set("siegeDefense", &generalCharacterictics::siegeDefense); - types.namedCharacter.set("ambush", &generalCharacterictics::ambush); - types.namedCharacter.set("navalCommand", &generalCharacterictics::navalCommand); - types.namedCharacter.set("siegeEngineering", &generalCharacterictics::siegeEngineering); - types.namedCharacter.set("nightBattle", &generalCharacterictics::nightBattle); - types.namedCharacter.set("personalSecurity", &generalCharacterictics::personalSecurity); - types.namedCharacter.set("publicSecurity", &generalCharacterictics::publicSecurity); - types.namedCharacter.set("bribery", &generalCharacterictics::bribery); - types.namedCharacter.set("bribeResistance", &generalCharacterictics::bribeResistance); - types.namedCharacter.set("electability", &generalCharacterictics::electability); - types.namedCharacter.set("lineOfSight", &generalCharacterictics::lineOfSight); - types.namedCharacter.set("trainingUnits", &generalCharacterictics::trainingUnits); - types.namedCharacter.set("trainingAgents", &generalCharacterictics::trainingAgents); - types.namedCharacter.set("construction", &generalCharacterictics::construction); - types.namedCharacter.set("trading", &generalCharacterictics::trading); - types.namedCharacter.set("localPopularity", &generalCharacterictics::localPopularity); - types.namedCharacter.set("footInTheDoor", &generalCharacterictics::footInTheDoor); - types.namedCharacter.set("farming", &generalCharacterictics::farming); - types.namedCharacter.set("mining", &generalCharacterictics::mining); - types.namedCharacter.set("taxCollection", &generalCharacterictics::taxCollection); - types.namedCharacter.set("fertility", &generalCharacterictics::fertility); - types.namedCharacter.set("cavalryCommand", &generalCharacterictics::cavalryCommand); - types.namedCharacter.set("infantryCommand", &generalCharacterictics::infantryCommand); - types.namedCharacter.set("gunpowerCommand", &generalCharacterictics::gunpowerCommand); - types.namedCharacter.set("artilleryCommand", &generalCharacterictics::artilleryCommand); - types.namedCharacter.set("health", &generalCharacterictics::health); - types.namedCharacter.set("squalor", &generalCharacterictics::squalor); - types.namedCharacter.set("unrest", &generalCharacterictics::unrest); - types.namedCharacter.set("law", &generalCharacterictics::law); - types.namedCharacter.set("looting", &generalCharacterictics::looting); - types.namedCharacter.set("bodyguardValour", &generalCharacterictics::bodyguardValour); - types.namedCharacter.set("hitpoints", &generalCharacterictics::hitpoints); - types.namedCharacter.set("trainingAnimalUnits", &generalCharacterictics::trainingAnimalUnits); - types.namedCharacter.set("battleSurgery", &generalCharacterictics::battleSurgery); + types.namedCharacter.set("level", &namedCharacter::level); + types.namedCharacter.set("authority", &namedCharacter::leaderAutority); + types.namedCharacter.set("command", &namedCharacter::authority); + types.namedCharacter.set("chivalryAndDread", &namedCharacter::nobility); + types.namedCharacter.set("loyalty", &namedCharacter::loyality); + types.namedCharacter.set("piety", &namedCharacter::piety); + types.namedCharacter.set("influence", &namedCharacter::influence); + types.namedCharacter.set("subterfuge", &namedCharacter::subterfuge); + types.namedCharacter.set("charm", &namedCharacter::charm); + types.namedCharacter.set("finance", &namedCharacter::finance); + types.namedCharacter.set("magic", &namedCharacter::magic); + types.namedCharacter.set("unorthodoxy", &namedCharacter::unorthodoxy); + types.namedCharacter.set("heresyImmunity", &namedCharacter::heresyImmunity); + types.namedCharacter.set("assassination", &namedCharacter::assassination); + types.namedCharacter.set("sabotage", &namedCharacter::sabotage); + types.namedCharacter.set("eligibility", &namedCharacter::eligibility); + types.namedCharacter.set("purity", &namedCharacter::purity); + types.namedCharacter.set("violence", &namedCharacter::violence); + types.namedCharacter.set("disposition", &namedCharacter::disposition); + types.namedCharacter.set("boldness", &namedCharacter::boldness); + types.namedCharacter.set("generosity", &namedCharacter::generosity); + types.namedCharacter.set("management", &namedCharacter::management); + types.namedCharacter.set("bodyguardSize", &namedCharacter::bodyguardSize); + types.namedCharacter.set("troopMorale", &namedCharacter::troopMorale); + types.namedCharacter.set("movementPointsBonus", &namedCharacter::movementPointsBonus); + types.namedCharacter.set("attack", &namedCharacter::attack); + types.namedCharacter.set("defence", &namedCharacter::defence); + types.namedCharacter.set("siegeAttack", &namedCharacter::siegeAttack); + types.namedCharacter.set("siegeDefense", &namedCharacter::siegeDefense); + types.namedCharacter.set("ambush", &namedCharacter::ambush); + types.namedCharacter.set("navalCommand", &namedCharacter::navalCommand); + types.namedCharacter.set("siegeEngineering", &namedCharacter::siegeEngineering); + types.namedCharacter.set("nightBattle", &namedCharacter::nightBattle); + types.namedCharacter.set("personalSecurity", &namedCharacter::personalSecurity); + types.namedCharacter.set("publicSecurity", &namedCharacter::publicSecurity); + types.namedCharacter.set("bribery", &namedCharacter::bribery); + types.namedCharacter.set("bribeResistance", &namedCharacter::bribeResistance); + types.namedCharacter.set("electability", &namedCharacter::electability); + types.namedCharacter.set("lineOfSight", &namedCharacter::lineOfSight); + types.namedCharacter.set("trainingUnits", &namedCharacter::trainingUnits); + types.namedCharacter.set("trainingAgents", &namedCharacter::trainingAgents); + types.namedCharacter.set("construction", &namedCharacter::construction); + types.namedCharacter.set("trading", &namedCharacter::trading); + types.namedCharacter.set("localPopularity", &namedCharacter::localPopularity); + types.namedCharacter.set("footInTheDoor", &namedCharacter::footInTheDoor); + types.namedCharacter.set("farming", &namedCharacter::farming); + types.namedCharacter.set("mining", &namedCharacter::mining); + types.namedCharacter.set("taxCollection", &namedCharacter::taxCollection); + types.namedCharacter.set("fertility", &namedCharacter::fertility); + types.namedCharacter.set("cavalryCommand", &namedCharacter::cavalryCommand); + types.namedCharacter.set("infantryCommand", &namedCharacter::infantryCommand); + types.namedCharacter.set("gunpowerCommand", &namedCharacter::gunpowerCommand); + types.namedCharacter.set("artilleryCommand", &namedCharacter::artilleryCommand); + types.namedCharacter.set("health", &namedCharacter::health); + types.namedCharacter.set("squalor", &namedCharacter::squalor); + types.namedCharacter.set("unrest", &namedCharacter::unrest); + types.namedCharacter.set("law", &namedCharacter::law); + types.namedCharacter.set("looting", &namedCharacter::looting); + types.namedCharacter.set("bodyguardValour", &namedCharacter::bodyguardValour); + types.namedCharacter.set("hitpoints", &namedCharacter::hitpoints); + types.namedCharacter.set("trainingAnimalUnits", &namedCharacter::trainingAnimalUnits); + types.namedCharacter.set("battleSurgery", &namedCharacter::battleSurgery); + + + ///capturedFactionInfo + //@section capturedFactionInfoTable + + /*** + Basic capturedFactionInfo table. + + @tfield int targetFactionID + @tfield int factionID + @tfield namedCharacter namedChar + @tfield namedCharacter targetCharacter + @tfield getCapturedCharacter getCapturedCharacter + @tfield int capturedCharactersNum + @tfield getCapturedUnit getCapturedUnit + @tfield int capturedUnitsNum + @tfield int ransomValue + + @table capturedFactionInfo + */ + types.capturedFactionInfo = luaState.new_usertype("capturedFactionInfo"); + types.capturedFactionInfo.set("targetFactionID", &capturedFactionInfo::targetFactionID); + types.capturedFactionInfo.set("factionID", &capturedFactionInfo::factionID); + types.capturedFactionInfo.set("namedChar", &capturedFactionInfo::character); + types.capturedFactionInfo.set("targetCharacter", &capturedFactionInfo::targetCharacter); + types.capturedFactionInfo.set("capturedCharactersNum", sol::property(generalCharactericticsHelpers::getCapturedCharacterNum)); + types.capturedFactionInfo.set("capturedUnitsNum", sol::property(generalCharactericticsHelpers::getCapturedUnitNum)); + types.capturedFactionInfo.set("ransomValue", &capturedFactionInfo::ransomValue); + + /*** + Get a captured unit by it's index. + @function capturedFactionInfo:getCapturedUnit + @tparam int index + @treturn capturedUnit capUnit + @usage + capUnit = capInfo:getCapturedUnit(0); + */ + types.capturedFactionInfo.set_function("getCapturedUnit", &generalCharactericticsHelpers::getCapturedUnit); + + /*** + Get a captured character by it's index. + @function capturedFactionInfo:getCapturedCharacter + @tparam int index + @treturn capturedCharacter capChar + @usage + capUnit = capInfo:getCapturedCharacter(0); + */ + types.capturedFactionInfo.set_function("getCapturedCharacter", &generalCharactericticsHelpers::getCapturedCharacter); + ///capturedUnit + //@section capturedUnitTable + + /*** + Basic capturedUnit table. + + @tfield unit unit + @tfield int capturedSoldiers + @tfield int capturedValue + + @table capturedUnit + */ + types.capturedUnit = luaState.new_usertype("capturedUnit"); + types.capturedUnit.set("unit", &capturedUnit::unit); + types.capturedUnit.set("capturedSoldiers", &capturedUnit::capturedSoldiers); + types.capturedUnit.set("capturedValue", &capturedUnit::capturedValue); + + ///capturedCharacter + //@section capturedCharacterTable + + /*** + Basic capturedCharacter table. + + @tfield namedCharacter namedChar + @tfield int capturedValue + + @table capturedCharacter + */ + types.capturedCharacter = luaState.new_usertype("capturedCharacter"); + types.capturedCharacter.set("namedChar", &capturedCharacter::namedChar); + types.capturedCharacter.set("capturedValue", &capturedCharacter::capturedValue); ///Ancillary //@section ancillaryTable @@ -1809,7 +1890,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.settlementStruct.set("localizedName", sol::property( &settlementHelpers::getSettlementName, &settlementHelpers::changeSettlementName )); - types.settlementStruct.set("ownerFaction", &settlementStruct::ownerFac); + types.settlementStruct.set("ownerFaction", &settlementStruct::faction); /*** Change owner faction of settlement. All agents, armies etc. leave the settlement. @function settlementStruct:changeOwner @@ -2436,7 +2517,7 @@ void luaP::onChangeTurnNum(int num) } } -void luaP::onCharacterSelected(generalCharacterictics* gen) +void luaP::onCharacterSelected(namedCharacter* gen) { if (onCharacterSelectedFunc != nullptr) { @@ -2444,134 +2525,6 @@ void luaP::onCharacterSelected(generalCharacterictics* gen) } } -void luaP::onPreFactionTurnStart(factionStruct* fac) -{ - if (onPreFactionTurnStartFunc != nullptr) - { - tryLua((*onPreFactionTurnStartFunc)(fac)); - } -} - -void luaP::onFactionTurnStart(factionStruct* fac) -{ - if (onFactionTurnStartFunc != nullptr) - { - tryLua((*onFactionTurnStartFunc)(fac)); - } -} - -void luaP::onGeneralDevastatesTile(generalCharacterictics* gen) -{ - if (onGeneralDevastatesTileFunc != nullptr) - { - tryLua((*onGeneralDevastatesTileFunc)(gen)); - } -} - -void luaP::onFactionTurnEnd(factionStruct* fac) -{ - if (onFactionTurnEndFunc != nullptr) - { - tryLua((*onFactionTurnEndFunc)(fac)); - } -} - -void luaP::onFactionNewCapital(factionStruct* fac) -{ - if (onFactionNewCapitalFunc != nullptr) - { - tryLua((*onFactionNewCapitalFunc)(fac)); - } -} - -void luaP::onFactionWarDeclared(factionStruct* fac, factionStruct* fac2) -{ - if (onFactionWarDeclaredFunc != nullptr) - { - tryLua((*onFactionWarDeclaredFunc)(fac, fac2)); - } -} - -void luaP::onFactionAllianceDeclared(factionStruct* fac, factionStruct* fac2) -{ - if (onFactionAllianceDeclaredFunc != nullptr) - { - tryLua((*onFactionAllianceDeclaredFunc)(fac, fac2)); - } -} - -void luaP::onFactionTradeAgreementMade(factionStruct* fac, factionStruct* fac2) -{ - if (onFactionTradeAgreementMadeFunc != nullptr) - { - tryLua((*onFactionTradeAgreementMadeFunc)(fac, fac2)); - } -} - -void luaP::onFactionBreakAlliance(factionStruct* fac, factionStruct* fac2) -{ - if (onFactionBreakAllianceFunc != nullptr) - { - tryLua((*onFactionBreakAllianceFunc)(fac, fac2)); - } -} - -void luaP::onGiveMoney(factionStruct* fac, factionStruct* fac2, float amount) -{ - if (onGiveMoneyFunc != nullptr) - { - tryLua((*onGiveMoneyFunc)(fac, fac2, amount)); - } -} - -void luaP::onUpdateAttitude(factionStruct* fac, factionStruct* fac2) -{ - if (onUpdateAttitudeFunc != nullptr) - { - tryLua((*onUpdateAttitudeFunc)(fac, fac2)); - } -} - -void luaP::onDemeanour(factionStruct* fac, factionStruct* fac2, float amount) -{ - if (onDemeanourFunc != nullptr) - { - tryLua((*onDemeanourFunc)(fac, fac2, amount)); - } -} - -void luaP::onGeneralAssaultsGeneral(generalCharacterictics* gen, generalCharacterictics* gen2) -{ - if (onGeneralAssaultsGeneralFunc != nullptr) - { - tryLua((*onGeneralAssaultsGeneralFunc)(gen, gen2)); - } -} - -void luaP::onGeneralAssaultsResidence(generalCharacterictics* gen, settlementStruct* sett, fortStruct* frt) -{ - if (onGeneralAssaultsResidenceFunc != nullptr) - { - tryLua((*onGeneralAssaultsResidenceFunc)(gen, sett, frt)); - } -} - -void luaP::onGeneralCaptureSettlement(generalCharacterictics* gen, settlementStruct* sett) -{ - if (onGeneralCaptureSettlementFunc != nullptr) - { - tryLua((*onGeneralCaptureSettlementFunc)(gen, sett)); - } -} - -void luaP::onGeneralCaptureResidence(generalCharacterictics* gen) -{ - if (onGeneralCaptureResidenceFunc != nullptr) - { - tryLua((*onGeneralCaptureResidenceFunc)(gen)); - } -} - void luaP::onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) { if (onSiegeEquipmentCompletedFunc != nullptr) @@ -2580,15 +2533,7 @@ void luaP::onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) } } -void luaP::onPostBattle(generalCharacterictics* gen) -{ - if (onPostBattleFunc != nullptr) - { - tryLua((*onPostBattleFunc)(gen)); - } -} - -void luaP::onMultiTurnMove(generalCharacterictics* gen) +void luaP::onMultiTurnMove(namedCharacter* gen) { if (onMultiTurnMoveFunc != nullptr) { diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index 2fd793731..f2c378347 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -87,32 +87,17 @@ class luaP //lua functions and events controllers void onPluginLoadF(); void onChangeTurnNum(int num); - void onCharacterSelected(generalCharacterictics* gen); - void onPreFactionTurnStart(factionStruct* fac); - void onFactionTurnStart(factionStruct* fac); - void onGeneralDevastatesTile(generalCharacterictics* gen); - void onFactionTurnEnd(factionStruct* fac); - void onFactionNewCapital(factionStruct* fac); - void onFactionWarDeclared(factionStruct* fac, factionStruct* fac2); - void onFactionAllianceDeclared(factionStruct* fac, factionStruct* fac2); - void onFactionTradeAgreementMade(factionStruct* fac, factionStruct* fac2); - void onFactionBreakAlliance(factionStruct* fac, factionStruct* fac2); - - void onGiveMoney(factionStruct* fac, factionStruct* fac2, float amount); + void onCharacterSelected(namedCharacter* gen); + void onGeneralDevastatesTile(namedCharacter* gen); + void onUpdateAttitude(factionStruct* fac, factionStruct* fac2); void onDemeanour(factionStruct* fac, factionStruct* fac2, float amount); - void onGeneralAssaultsGeneral(generalCharacterictics* gen, generalCharacterictics* gen2); - void onGeneralAssaultsResidence(generalCharacterictics* gen, settlementStruct* sett, fortStruct* frt); - void onGeneralCaptureSettlement(generalCharacterictics* gen, settlementStruct* sett); - - void onGeneralCaptureResidence(generalCharacterictics* gen); void onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt); - void onPostBattle(generalCharacterictics* gen); - void onMultiTurnMove(generalCharacterictics* gen); + void onMultiTurnMove(namedCharacter* gen); void onSettlementSelected(settlementStruct* sett); void onSettlementUpgraded(settlementStruct* sett); void onSettlementConverted(settlementStruct* sett); @@ -155,7 +140,7 @@ class luaP { sol::usertypeunit; sol::usertypecharacter; - sol::usertypenamedCharacter; + sol::usertypenamedCharacter; sol::usertypeancillary; sol::usertypetraitContainerT; sol::usertypeEduEntry; @@ -193,30 +178,9 @@ class luaP sol::function* onLoadingFonts = nullptr; sol::function* initDXFunc = nullptr; - sol::function* onChangeTurnNumFunc = nullptr; sol::function* onCharacterSelectedFunc = nullptr; - sol::function* onPreFactionTurnStartFunc = nullptr; - sol::function* onGeneralDevastatesTileFunc = nullptr; - sol::function* onFactionTurnStartFunc = nullptr; - sol::function* onFactionTurnEndFunc = nullptr; - sol::function* onFactionNewCapitalFunc = nullptr; - sol::function* onFactionWarDeclaredFunc = nullptr; - sol::function* onFactionAllianceDeclaredFunc = nullptr; - sol::function* onFactionTradeAgreementMadeFunc = nullptr; - sol::function* onFactionBreakAllianceFunc = nullptr; - - sol::function* onGiveMoneyFunc = nullptr; - sol::function* onUpdateAttitudeFunc = nullptr; - sol::function* onDemeanourFunc = nullptr; - - sol::function* onGeneralAssaultsGeneralFunc = nullptr; - sol::function* onGeneralAssaultsResidenceFunc = nullptr; - sol::function* onGeneralCaptureSettlementFunc = nullptr; - - sol::function* onGeneralCaptureResidenceFunc = nullptr; sol::function* onSiegeEquipmentCompletedFunc = nullptr; - sol::function* onPostBattleFunc = nullptr; sol::function* onMultiTurnMoveFunc = nullptr; @@ -226,7 +190,6 @@ class luaP sol::function* onCityRiotsFunc = nullptr; sol::function* onUngarrisonedSettlementFunc = nullptr; - sol::function* onUngarrisonedFortFunc = nullptr; sol::function* onGiveSettlementFunc = nullptr; sol::function* onOccupySettlementFunc = nullptr; sol::function* onExterminatePopulationFunc = nullptr; @@ -235,34 +198,12 @@ class luaP sol::function* onAddedToBuildingQueueFunc = nullptr; sol::function* onBuildingDestroyedFunc = nullptr; sol::function* onBuildingCompletedFunc = nullptr; - sol::function* onEventCounterFunc = nullptr; - sol::function* onFactionExcommunicatedFunc = nullptr; - sol::function* onDisasterFunc = nullptr; - sol::function* onHordeFormedFunc = nullptr; sol::function* onAddedToTrainingQueueFunc = nullptr; - sol::function* onUnitDisbandedFunc = nullptr; sol::function* onUnitTrainedFunc = nullptr; sol::function* onAgentCreatedFunc = nullptr; - - sol::function* onObjSeenFunc = nullptr; - sol::function* onTileSeenFunc = nullptr; - sol::function* onGameReloadedFunc = nullptr; - sol::function* onTransgressionFunc = nullptr; - - - sol::function* onPopeAcceptsCrusadeTargetFunc = nullptr; - sol::function* onCrusadeCalledFunc = nullptr; - sol::function* onCrusadeEndsFunc = nullptr; - sol::function* onPopeRejectsCrusadeTargetFunc = nullptr; - sol::function* onArmyTakesCrusadeTargetFunc = nullptr; - - sol::function* onUnitsDesertCrusadeFunc = nullptr; - sol::function* onPopeElectedFunc = nullptr; - sol::function* onVotedForPopeFunc = nullptr; sol::function* onAssassinCaughtAttackingPopeFunc = nullptr; - sol::function* onInquisitorAppointedFunc = nullptr; @@ -296,24 +237,14 @@ class luaP sol::function* onGuildUpgradedFunc = nullptr; sol::function* onGuildDestroyedFunc = nullptr; - sol::function* onBrotherAdoptedFunc = nullptr; - sol::function* onBirthFunc = nullptr; - sol::function* onCharacterComesOfAgeFunc = nullptr; - sol::function* onCharacterMarriesFunc = nullptr; - sol::function* onCharacterMarriesPrincessFunc = nullptr; - sol::function* onCharacterBecomesAFatherFunc = nullptr; - sol::function* onNewAdmiralCreatedFunc = nullptr; sol::function* onShortcutTriggeredFunc = nullptr; - - sol::function* onBecomesFactionLeaderFunc = nullptr; - sol::function* onBecomesFactionHeirFunc = nullptr; + void checkLuaFunc(sol::function** lRef); private: - void checkLuaFunc(sol::function** lRef); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index 153cd86ca..8eaf0a43f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -618,7 +618,7 @@ void luaP::initP2() @tparam int condition @treturn string winCondition destroy\_or\_rout\_enemy, balance\_of\_strength\_percent, destroy\_enemy\_strength\_percent, capture\_location, destroy\_character, capture\_major\_settlement, capture\_army\_settlement, unknown\_condition @usage - function onPostBattle(character) + function onPostBattle(namedChar, faction, region, characterType, religion) getBattleData() end diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj b/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj index 507ccd309..8d9db2ca1 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj +++ b/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode DynamicLibrary true - v142 + v143 Unicode DynamicLibrary false - v142 + v143 true Unicode diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp index 2791478bf..0def69d3f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp @@ -12,7 +12,7 @@ namespace m2tweopHelpers } bool isTileFree(int x, int y) { - int xy[2]{x,y}; + int xy[2]{ x,y }; return (*(*plugData::data.funcs.isTileFree))(xy); } std::tuple getGameTileCoordsWithCursor() @@ -25,7 +25,7 @@ namespace m2tweopHelpers } int getTileRegionID(int x, int y) { - return (*(*plugData::data.funcs.getTileRegionID))(x,y); + return (*(*plugData::data.funcs.getTileRegionID))(x, y); } factionStruct* getRegionOwner(int regionID) { @@ -150,9 +150,9 @@ namespace m2tweopHelpers } void setEDUUnitsSize(signed short min, signed short max) { - (*(*plugData::data.funcs.setEDUUnitsSize))(min,max); + (*(*plugData::data.funcs.setEDUUnitsSize))(min, max); } - std::tuple loadTextureToGame(const std::string& path) + std::tuple loadTextureToGame(const std::string& path) { int x = 0; int y = 0; @@ -162,7 +162,7 @@ namespace m2tweopHelpers x, y }); - return std::make_tuple(x,y, reinterpret_cast(retTexture)); + return std::make_tuple(x, y, reinterpret_cast(retTexture)); } void unloadTextureFromGame(void* texture) { @@ -196,7 +196,7 @@ namespace m2tweopHelpers (*(*plugData::data.funcs.setGuildCooldown))(turns); } - void getGameVersion() + int getGameVersion() { return (*(*plugData::data.funcs.getGameVersion))(); } diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h index 4983f55a6..b51a5533a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h @@ -21,11 +21,11 @@ namespace campaignEnums enum dipStateInternalEnum :int { peaceState = 200, - warState =600, - allianceState =0 + warState = 600, + allianceState = 0 }; constexpr int protectorateState = 15; - constexpr int nonProtectorateeState =6; + constexpr int nonProtectorateeState = 6; } namespace m2tweopHelpers { @@ -38,8 +38,8 @@ namespace m2tweopHelpers int getTileRegionID(int x, int y); factionStruct* getRegionOwner(int regionID); - bool checkDipStance(campaign*campaignStruct,campaignEnums::dipRelEnum dipType,factionStruct* fac1, factionStruct* fac2); - void setDipStance(campaign*campaignStruct,campaignEnums::dipRelEnum dipType,factionStruct* fac1, factionStruct* fac2); + bool checkDipStance(campaign* campaignStruct, campaignEnums::dipRelEnum dipType, factionStruct* fac1, factionStruct* fac2); + void setDipStance(campaign* campaignStruct, campaignEnums::dipRelEnum dipType, factionStruct* fac1, factionStruct* fac2); int GetUnitSize(); void setAncLimit(unsigned char limit); @@ -48,7 +48,7 @@ namespace m2tweopHelpers void unlockGameConsoleCommands(); void setEDUUnitsSize(signed short min, signed short max); - void getGameVersion(); + int getGameVersion(); std::tuple loadTextureToGame(const std::string& path); diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp index 48eaca693..a3f873a88 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp @@ -1,6 +1,6 @@ #include "otherEvents.h" -void onMultiTurnMove(generalCharacterictics* gen) +void onMultiTurnMove(namedCharacter* gen) { plugData::data.luaAll.onMultiTurnMove(gen); } @@ -36,14 +36,6 @@ void onUngarrisonedSettlement(settlementStruct* sett) } } -void onUngarrisonedFort(fortStruct* frt) -{ - if (plugData::data.luaAll.onUngarrisonedFortFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUngarrisonedFortFunc)(frt)); - } -} - void onGiveSettlement(settlementStruct* sett, factionStruct* fac, factionStruct* fac2) { if (plugData::data.luaAll.onGiveSettlementFunc != nullptr) @@ -52,7 +44,7 @@ void onGiveSettlement(settlementStruct* sett, factionStruct* fac, factionStruct* } } -void onOccupySettlement(generalCharacterictics* gen, factionStruct* fac) +void onOccupySettlement(namedCharacter* gen, factionStruct* fac) { if (plugData::data.luaAll.onOccupySettlementFunc != nullptr) { @@ -60,7 +52,7 @@ void onOccupySettlement(generalCharacterictics* gen, factionStruct* fac) } } -void onExterminatePopulation(generalCharacterictics* gen, factionStruct* fac) +void onExterminatePopulation(namedCharacter* gen, factionStruct* fac) { if (plugData::data.luaAll.onExterminatePopulationFunc != nullptr) { @@ -68,7 +60,7 @@ void onExterminatePopulation(generalCharacterictics* gen, factionStruct* fac) } } -void onSackSettlement(generalCharacterictics* gen, factionStruct* fac) +void onSackSettlement(namedCharacter* gen, factionStruct* fac) { if (plugData::data.luaAll.onSackSettlementFunc != nullptr) { @@ -100,38 +92,6 @@ void onBuildingCompleted(factionStruct* fac, settlementStruct* sett) } } -void onEventCounter(const char* str) -{ - if (plugData::data.luaAll.onEventCounterFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onEventCounterFunc)(str)); - } -} - -void onFactionExcommunicated(factionStruct* fac) -{ - if (plugData::data.luaAll.onFactionExcommunicatedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onFactionExcommunicatedFunc)(fac)); - } -} - -void onDisaster(int eventType) -{ - if (plugData::data.luaAll.onDisasterFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onDisasterFunc)(eventType)); - } -} - -void onHordeFormed(factionStruct* fac) -{ - if (plugData::data.luaAll.onHordeFormedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onHordeFormedFunc)(fac)); - } -} - void onAddedToTrainingQueue(settlementStruct* sett, const char* unitName) { if (plugData::data.luaAll.onAddedToTrainingQueueFunc != nullptr) @@ -140,14 +100,6 @@ void onAddedToTrainingQueue(settlementStruct* sett, const char* unitName) } } -void onUnitDisbanded(factionStruct* fac, unit* un) -{ - if (plugData::data.luaAll.onUnitDisbandedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUnitDisbandedFunc)(fac, un)); - } -} - void onUnitTrained(factionStruct* fac, settlementStruct* sett, unit* un) { if (plugData::data.luaAll.onUnitTrainedFunc != nullptr) @@ -156,7 +108,7 @@ void onUnitTrained(factionStruct* fac, settlementStruct* sett, unit* un) } } -void onAgentCreated(generalCharacterictics* pers, int type, settlementStruct* sett) +void onAgentCreated(namedCharacter* pers, int type, settlementStruct* sett) { if (plugData::data.luaAll.onAgentCreatedFunc != nullptr) { @@ -164,38 +116,6 @@ void onAgentCreated(generalCharacterictics* pers, int type, settlementStruct* se } } -void onObjSeen(factionStruct* fac, factionStruct* fac2, int x, int y) -{ - if (plugData::data.luaAll.onObjSeenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onObjSeenFunc)(fac, fac2, x, y)); - } -} - -void onTileSeen(factionStruct* fac, int x, int y) -{ - if (plugData::data.luaAll.onTileSeenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onTileSeenFunc)(fac, x, y)); - } -} - -void onGameReloaded(int something) -{ - if (plugData::data.luaAll.onGameReloadedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onGameReloadedFunc)(something)); - } -} - -void onTransgression(factionStruct* fac, const char* str, factionStruct* fac2) -{ - if (plugData::data.luaAll.onTransgressionFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onTransgressionFunc)(fac, str, fac2)); - } -} - void onGuildUpgraded(settlementStruct* sett, const char* resourceDescription) { if (plugData::data.luaAll.onGuildUpgradedFunc != nullptr) @@ -212,55 +132,7 @@ void onGuildDestroyed(settlementStruct* sett, unsigned char guildID) } } -void onBrotherAdopted(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onBrotherAdoptedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBrotherAdoptedFunc)(gen)) - } -} - -void onBirth(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onBirthFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBirthFunc)(gen)) - } -} - -void onCharacterComesOfAge(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onCharacterComesOfAgeFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCharacterComesOfAgeFunc)(gen)) - } -} - -void onCharacterMarries(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onCharacterMarriesFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCharacterMarriesFunc)(gen)) - } -} - -void onCharacterMarriesPrincess(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onCharacterMarriesPrincessFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCharacterMarriesPrincessFunc)(gen)) - } -} - -void onCharacterBecomesAFather(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onCharacterBecomesAFatherFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCharacterBecomesAFatherFunc)(gen)) - } -} - -void onNewAdmiralCreated(generalCharacterictics* pers, settlementStruct* sett) +void onNewAdmiralCreated(namedCharacter* pers, settlementStruct* sett) { if (plugData::data.luaAll.onNewAdmiralCreatedFunc != nullptr) { @@ -275,19 +147,3 @@ void onShortcutTriggered(const char* str) tryLua((*plugData::data.luaAll.onShortcutTriggeredFunc)(str)) } } - -void onBecomesFactionLeader(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onBecomesFactionLeaderFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBecomesFactionLeaderFunc)(gen)) - } -} - -void onBecomesFactionHeir(generalCharacterictics* gen) -{ - if (plugData::data.luaAll.onBecomesFactionHeirFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBecomesFactionHeirFunc)(gen)) - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h index 76a940c86..eff0dd5ff 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h @@ -1,60 +1,31 @@ #pragma once #include "pluginM2TWEOP.h" -extern "C" PLUGINM2TWEOP_API void onMultiTurnMove(generalCharacterictics * gen); +extern "C" PLUGINM2TWEOP_API void onMultiTurnMove(namedCharacter * gen); extern "C" PLUGINM2TWEOP_API void onSettlementSelected(settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onSettlementUpgraded(settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onSettlementConverted(settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onCityRiots(settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onUngarrisonedSettlement(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onUngarrisonedFort(fortStruct * frt); extern "C" PLUGINM2TWEOP_API void onGiveSettlement(settlementStruct * sett, factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onOccupySettlement(generalCharacterictics * gen, factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onExterminatePopulation(generalCharacterictics * gen, factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onSackSettlement(generalCharacterictics * gen, factionStruct * fac); +extern "C" PLUGINM2TWEOP_API void onOccupySettlement(namedCharacter * gen, factionStruct * fac); +extern "C" PLUGINM2TWEOP_API void onExterminatePopulation(namedCharacter * gen, factionStruct * fac); +extern "C" PLUGINM2TWEOP_API void onSackSettlement(namedCharacter * gen, factionStruct * fac); extern "C" PLUGINM2TWEOP_API void onAddedToBuildingQueue(settlementStruct * sett, const char* build); extern "C" PLUGINM2TWEOP_API void onBuildingDestroyed(settlementStruct * sett, const char* build); extern "C" PLUGINM2TWEOP_API void onBuildingCompleted(factionStruct * fac, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onEventCounter(const char* str); - - - -extern "C" PLUGINM2TWEOP_API void onFactionExcommunicated(factionStruct * fac); - -extern "C" PLUGINM2TWEOP_API void onDisaster(int eventType); - -extern "C" PLUGINM2TWEOP_API void onHordeFormed(factionStruct * fac); - extern "C" PLUGINM2TWEOP_API void onAddedToTrainingQueue(settlementStruct * sett, const char* unitName); -extern "C" PLUGINM2TWEOP_API void onUnitDisbanded(factionStruct * fac, unit * un); extern "C" PLUGINM2TWEOP_API void onUnitTrained(factionStruct * fac, settlementStruct * sett, unit * un); -extern "C" PLUGINM2TWEOP_API void onAgentCreated(generalCharacterictics * pers, int type, settlementStruct * sett); - -extern "C" PLUGINM2TWEOP_API void onObjSeen(factionStruct * fac, factionStruct * fac2, int x, int y); -extern "C" PLUGINM2TWEOP_API void onTileSeen(factionStruct * fac, int x, int y); - - -extern "C" PLUGINM2TWEOP_API void onGameReloaded(int something); -extern "C" PLUGINM2TWEOP_API void onTransgression(factionStruct * fac, const char* str, factionStruct * fac2); +extern "C" PLUGINM2TWEOP_API void onAgentCreated(namedCharacter * pers, int type, settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onGuildUpgraded(settlementStruct * sett, const char* resourceDescription); extern "C" PLUGINM2TWEOP_API void onGuildDestroyed(settlementStruct * sett, unsigned char guildID); -extern "C" PLUGINM2TWEOP_API void onBrotherAdopted(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onBirth(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onCharacterComesOfAge(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onCharacterMarries(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onCharacterMarriesPrincess(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onCharacterBecomesAFather(generalCharacterictics * gen); - -extern "C" PLUGINM2TWEOP_API void onNewAdmiralCreated(generalCharacterictics * pers, settlementStruct * sett); +extern "C" PLUGINM2TWEOP_API void onNewAdmiralCreated(namedCharacter * pers, settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onShortcutTriggered(const char* str); - -extern "C" PLUGINM2TWEOP_API void onBecomesFactionLeader(generalCharacterictics * gen); -extern "C" PLUGINM2TWEOP_API void onBecomesFactionHeir(generalCharacterictics * gen); diff --git a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp index 3434e198e..448614a32 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp @@ -4,7 +4,8 @@ #include "pluginM2TWEOP.h" #include "lua/sol.hpp" -#include + +#include "imgui/sol_ImGui.h" int initPlugin(std::string* modPath) { @@ -459,7 +460,7 @@ int initPlugin(std::string* modPath) void initLua() { - std::string luaFile = plugData::data.modFolder + "\\youneuoy_Data\\plugins\\lua\\luaPluginScript.lua"; + std::string luaFile = plugData::data.modFolder + R"(\youneuoy_Data\plugins\lua\luaPluginScript.lua)"; sol::state* luaState = plugData::data.luaAll.init(luaFile, plugData::data.modFolder); plugData::data.luaAll.initCampaign(); @@ -473,7 +474,7 @@ void initLua() plugData::data.luaAll.onPluginLoadF(); if (luaState == nullptr) { - MessageBoxA(NULL, "LUA loading error!", "Error!", NULL); + MessageBoxA(nullptr, "LUA loading error!", "Error!", NULL); exit(0); } } diff --git a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.h b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.h index 450fd44b0..9e465e87a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.h @@ -18,6 +18,6 @@ //init this plugin -extern "C" PLUGINM2TWEOP_API int initPlugin(std::string* modPath); +extern "C" PLUGINM2TWEOP_API int initPlugin(std::string * modPath); void initLua(); \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index a90d3d3e5..58d9a357d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -17,6 +17,59 @@ struct UNICODE_STRING { USHORT something2;//idk PWSTR Buffer;//y }; + +struct rcString +{ +public: + char pad_0000[12]; //0x0000 + wchar_t* string; //0x000C + char pad_0010[104]; //0x0010 +}; //Size: 0x0078 + +class religionDatabase +{ +public: + void* religionDatabase_vtbl;//0x0000 + struct rcString** religionNames; //0x0004 + int32_t religionNamesSize; //0x0008 + int32_t religionCount; //0x000C + struct rcString** religionPips; //0x0010 + int32_t religionPipsSize; //0x0014 + int32_t religionPipsCount; //0x0018 + void* hashedStringTable; //0x001C + +}; //Size: 0x0020 + +struct capturedCharacter +{ + struct namedCharacter* namedChar; + int32_t capturedValue; +}; + +struct capturedUnit +{ + struct unit* unit; + int32_t capturedSoldiers; + int32_t capturedValue; +}; + +struct capturedFactionInfo +{ + int32_t targetFactionID; + int32_t factionID; + struct namedCharacter* character; + struct namedCharacter* targetCharacter; + int32_t bitMap; + struct capturedCharacter* capturedCharacters; + uint32_t capturedCharactersEnd; + uint32_t capturedCharactersEnd2; + char* logString; + struct capturedUnit* capturedUnits; + uint32_t capturedUnitsEnd; + int32_t capturedUnitsEnd2; + int32_t ransomValue; +}; + struct regionStruct { char* regionName;//0x0000 int regionNameHash;//0x0004 @@ -100,7 +153,7 @@ struct stratMap { struct mercPoolUnit { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t experience; //0x0004 int32_t cost; //0x0008 float replenishMin; //0x000C @@ -938,7 +991,7 @@ struct oneSiege { struct unitRQ { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t FourtySeven; //0x0004 struct settlementStruct* settlement; //0x0008 int8_t N0001082F; //0x000C @@ -984,7 +1037,7 @@ struct settlementStruct { char* name; /* internal name of settlement */ int nameCrypt; UNICODE_STRING** localizedName; - struct factionStruct* ownerFac; /* faction of the owner */ + struct factionStruct* faction; /* faction of the owner */ undefined field16_0x174[36]; int level; /* level of the settlement/castle */ int fac_creatorModNum; @@ -1111,7 +1164,7 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int xCoord; /* number of x-coord of unit position */ int yCoord; /* number of y-coord of unit position */ undefined field5_0x14[108]; - struct generalCharacterictics* genChar; /* many important info about character */ + struct namedCharacter* genChar; /* many important info about character */ undefined field7_0x84[4]; struct genMod* genType; undefined field9_0x8c[24]; @@ -1135,7 +1188,7 @@ struct general { /* character on the stratmap, who has a unit in a stack */ }; //additional character data(name,label,traits, etc) -struct generalCharacterictics { /* many important info about character */ +struct namedCharacter { /* many important info about character */ UINT32 index; /* index of character */ UNICODE_STRING** localizedFullName; /* displaying name */ UNICODE_STRING** localizedNameForSave; /* saved to save file */ @@ -1226,9 +1279,9 @@ struct generalCharacterictics { /* many important info about character */ struct factionStruct* faction; int subFaction; undefined field_0x220[4]; - struct generalCharacterictics* parent; /* father */ - struct generalCharacterictics* spouse; - struct generalCharacterictics* childs[4]; /* children, womens wont have children */ + struct namedCharacter* parent; /* father */ + struct namedCharacter* spouse; + struct namedCharacter* childs[4]; /* children, womens wont have children */ undefined field_0x23c[20]; char* portrait; undefined field_0x254[4]; @@ -1313,7 +1366,7 @@ struct unit { undefined field2_0x8[636]; struct stackStruct* army; undefined field4_0x288[12]; - struct EduEntry* eduEntry; + struct eduEntry* eduEntry; int ID; undefined field7_0x29c[612]; int expScreen; /* screen experience */ @@ -1379,15 +1432,15 @@ struct factionStruct { char* ai_label; /* ai_label of faction */ undefined field_0xc0[4]; struct settlementStruct* capital; /* capital of the faction */ - struct generalCharacterictics* leader; /* faction leader */ - struct generalCharacterictics* heir; /* faction heir */ + struct namedCharacter* leader; /* faction leader */ + struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ UINT32* ai_assistant; undefined field_0xdc[20]; UINT32 holdRegions; undefined field_0xf4[4]; - struct generalCharacterictics** charactersAll; /* all characters, died, alive, etc */ + struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ undefined field_0xfc[4]; int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ @@ -1467,7 +1520,7 @@ struct ArmourUpgModels //type of unit from EDU -struct EduEntry { +struct eduEntry { char* Type; uint32_t typeHash; DWORD Index; @@ -1666,7 +1719,7 @@ struct EduEntry { struct eduEntryes { /* structure with all edu entries */ UINT32 qq; - struct EduEntry unitTupes[500]; + struct eduEntry unitTupes[500]; UINT32 numberOfTupes; }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp index d742f56b9..3269b4cb4 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp @@ -1,68 +1,5 @@ #include "religionEvents.h" -void onPopeAcceptsCrusadeTarget(void* crusade, settlementStruct* sett) -{ - if (plugData::data.luaAll.onPopeAcceptsCrusadeTargetFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onPopeAcceptsCrusadeTargetFunc)((int)crusade, sett)); - } -} - -void onCrusadeCalled(void* crusade, settlementStruct* sett) -{ - if (plugData::data.luaAll.onCrusadeCalledFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCrusadeCalledFunc)((int)crusade, sett)); - } -} - -void onCrusadeEnds(void* crusade, settlementStruct* sett) -{ - if (plugData::data.luaAll.onCrusadeEndsFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCrusadeEndsFunc)((int)crusade, sett)); - } -} - -void onPopeRejectsCrusadeTarget(void* crusade, settlementStruct* sett) -{ - if (plugData::data.luaAll.onPopeRejectsCrusadeTargetFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onPopeRejectsCrusadeTargetFunc)((int)crusade, sett)); - } -} - -void onArmyTakesCrusadeTarget(void* crusade, settlementStruct* sett, stackStruct* army) -{ - if (plugData::data.luaAll.onArmyTakesCrusadeTargetFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onArmyTakesCrusadeTargetFunc)((int)crusade, sett, army)); - } -} - -void onUnitsDesertCrusade(void* crusade, settlementStruct* sett, factionStruct* fac) -{ - if (plugData::data.luaAll.onUnitsDesertCrusadeFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUnitsDesertCrusadeFunc)((int)crusade, sett, fac)); - } -} - -void onPopeElected(factionStruct* fac, factionStruct* fac2) -{ - if (plugData::data.luaAll.onPopeElectedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onPopeElectedFunc)(fac,fac2)); - } -} - -void onVotedForPope(factionStruct* fac) -{ - if (plugData::data.luaAll.onVotedForPopeFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onVotedForPopeFunc)(fac)); - } -} void onAssassinCaughtAttackingPope(factionStruct* fac) { @@ -71,11 +8,3 @@ void onAssassinCaughtAttackingPope(factionStruct* fac) tryLua((*plugData::data.luaAll.onAssassinCaughtAttackingPopeFunc)(fac)); } } - -void onInquisitorAppointed(factionStruct* fac, settlementStruct* sett) -{ - if (plugData::data.luaAll.onInquisitorAppointedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onInquisitorAppointedFunc)(fac,sett)); - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h index ef7367c10..5d1b44825 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h @@ -1,13 +1,4 @@ #pragma once #include "pluginM2TWEOP.h" -extern "C" PLUGINM2TWEOP_API void onPopeAcceptsCrusadeTarget(void* crusade, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onCrusadeCalled(void* crusade, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onCrusadeEnds(void* crusade, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onPopeRejectsCrusadeTarget(void* crusade, settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onArmyTakesCrusadeTarget(void* crusade, settlementStruct * sett, stackStruct * army); -extern "C" PLUGINM2TWEOP_API void onUnitsDesertCrusade(void* crusade, settlementStruct * sett, factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onPopeElected(factionStruct * fac, factionStruct * fac2); -extern "C" PLUGINM2TWEOP_API void onVotedForPope(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onAssassinCaughtAttackingPope(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onInquisitorAppointed(factionStruct * fac, settlementStruct * sett); \ No newline at end of file +extern "C" PLUGINM2TWEOP_API void onAssassinCaughtAttackingPope(factionStruct * fac); \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp index 49fb9502a..7d2f01ecd 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp @@ -28,26 +28,26 @@ namespace technicalHelpers return strTo; } - void namedCharSetLocalizedFullName(generalCharacterictics* genChar, const char* str) + void namedCharSetLocalizedFullName(namedCharacter* genChar, const char* str) { (*(*plugData::data.funcsTech.createUniString))(genChar->localizedFullName, str); } - void namedCharSetLocalizedNameForSave(generalCharacterictics* genChar, const char* str) + void namedCharSetLocalizedNameForSave(namedCharacter* genChar, const char* str) { (*(*plugData::data.funcsTech.createUniString))(genChar->localizedNameForSave, str); } - void namedCharSetLocalizedNextNameForSave(generalCharacterictics* genChar, const char* str) + void namedCharSetLocalizedNextNameForSave(namedCharacter* genChar, const char* str) { (*(*plugData::data.funcsTech.createUniString))(genChar->localizedNextNameForSave, str); } - void namedCharSetLocalizedNicknameForSave(generalCharacterictics* genChar, const char* str) + void namedCharSetLocalizedNicknameForSave(namedCharacter* genChar, const char* str) { (*(*plugData::data.funcsTech.createUniString))(genChar->localizedNicknameForSave, str); } - void createUniString(UNICODE_STRING** &newUniStringPointer, const char* nonUniStr) + void createUniString(UNICODE_STRING**& newUniStringPointer, const char* nonUniStr) { (*(*plugData::data.funcsTech.createUniString))(newUniStringPointer, nonUniStr); } diff --git a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h index 0e01ac9ac..658d98bdc 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h @@ -11,14 +11,14 @@ namespace technicalHelpers { - std::string unitUniStringToStr(unit*unit); + std::string unitUniStringToStr(unit* unit); void setUnitUniStr(unit* unit, const char* str); std::string uniStringToStr(UNICODE_STRING**& uniString); template - std::string namedCharUniStringToStr(generalCharacterictics* genChar) + std::string namedCharUniStringToStr(namedCharacter* genChar) { if (fieldIndex == namedChar_localizedFullName) { @@ -44,10 +44,10 @@ namespace technicalHelpers } - void namedCharSetLocalizedFullName(generalCharacterictics* genChar, const char* str); - void namedCharSetLocalizedNameForSave(generalCharacterictics* genChar, const char* str); - void namedCharSetLocalizedNextNameForSave(generalCharacterictics* genChar, const char* str); - void namedCharSetLocalizedNicknameForSave(generalCharacterictics* genChar, const char* str); + void namedCharSetLocalizedFullName(namedCharacter* genChar, const char* str); + void namedCharSetLocalizedNameForSave(namedCharacter* genChar, const char* str); + void namedCharSetLocalizedNextNameForSave(namedCharacter* genChar, const char* str); + void namedCharSetLocalizedNicknameForSave(namedCharacter* genChar, const char* str); void createUniString(UNICODE_STRING**& newUniStringPointer, const char* nonUniStr); -}; +}; diff --git a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp index e28820fce..e690149d5 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp @@ -65,7 +65,7 @@ void onNavalAutoResolvePanelOpen() } } -void onCharacterPanelOpen(generalCharacterictics* pers) +void onCharacterPanelOpen(namedCharacter* pers) { if (plugData::data.luaAll.onCharacterPanelOpenFunc != nullptr) { @@ -89,7 +89,7 @@ void onRequestBuildingAdvice(settlementStruct* sett) } } -void onRequestTrainingAdvice(settlementStruct* sett, EduEntry* recommend) +void onRequestTrainingAdvice(settlementStruct* sett, eduEntry* recommend) { if (plugData::data.luaAll.onRequestTrainingAdviceFunc != nullptr) { @@ -165,7 +165,7 @@ void onSettlementScrollAdviceRequested(settlementStruct* sett, const char* scrNa { if (plugData::data.luaAll.onSettlementScrollAdviceRequestedFunc != nullptr) { - tryLua((*plugData::data.luaAll.onSettlementScrollAdviceRequestedFunc)(sett,scrName)); + tryLua((*plugData::data.luaAll.onSettlementScrollAdviceRequestedFunc)(sett, scrName)); } } diff --git a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h index 58c83bc45..7445b1323 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h @@ -8,11 +8,11 @@ extern "C" PLUGINM2TWEOP_API void onDiplomaticStandingPanelOpen(); extern "C" PLUGINM2TWEOP_API void onDiplomacyPanelOpen(factionStruct * fac); extern "C" PLUGINM2TWEOP_API void onPreBattlePanelOpen(factionStruct * fac); extern "C" PLUGINM2TWEOP_API void onNavalAutoResolvePanelOpen(); -extern "C" PLUGINM2TWEOP_API void onCharacterPanelOpen(generalCharacterictics * pers); +extern "C" PLUGINM2TWEOP_API void onCharacterPanelOpen(namedCharacter * pers); extern "C" PLUGINM2TWEOP_API void onTradePanelOpen(settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onRequestBuildingAdvice(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, EduEntry * recommend); -extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, EduEntry * recommend); +extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, eduEntry * recommend); +extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, eduEntry * recommend); extern "C" PLUGINM2TWEOP_API void onMessageOpen(factionStruct * fac, int type); extern "C" PLUGINM2TWEOP_API void onIncomingMessage(factionStruct * fac, int type); diff --git a/QuickEopDebug.ps1 b/QuickEopDebug.ps1 new file mode 100644 index 000000000..8b14667a3 --- /dev/null +++ b/QuickEopDebug.ps1 @@ -0,0 +1,57 @@ +# BUILD EOP Script +$currentLoc=(get-location).path + +# Colors +# https://duffney.io/usingansiescapesequencespowershell/ +$color = "`e[$(35)m" +$endColor = "`e[0m`e[30;" + +function CopyFilesToFolder ($fromFolder, $toFolder) { + $childItems = Get-ChildItem $fromFolder + $childItems | ForEach-Object { + Copy-Item -Path $_.FullName -Destination $toFolder -Recurse -Force + } +} + +Write-Output "$color======== 0) Pre Cleanup ======== $endColor" + + +Set-Location -Path $currentLoc +Remove-item ./logs -recurse -erroraction 'silentlycontinue' +new-item ./logs -itemtype directory -erroraction 'silentlycontinue' + +# 1) Build M2TWEOP-library +Write-Output "$color======== 1) Build M2TWEOP-library ======== $endColor" + +devenv "M2TWEOP Code\M2TWEOP library.sln" /build "Debug|x86" /project "M2TWEOP library" /out "logs\library.log" +#devenv "M2TWEOP Code\M2TWEOP library.sln" /build "Release|x86" /project "M2TWEOP GUI" /out "logs\GUI.log" +#devenv "M2TWEOP Code\M2TWEOP library.sln" /build "Release|x86" /project "M2TWEOP tools" /out "logs\tools.log" +#devenv "M2TWEOP Code\M2TWEOP library.sln" /build "Release|x86" /project "d3d9" /out "logs\d3d9.log" + +# 2) Build M2TWEOP-LuaPlugin +Write-Output "$color======== 2) Build M2TWEOP-LuaPlugin ======== $endColor" + +devenv "M2TWEOP-luaPlugin\luaPlugin.sln" /build "Debug|x86" /project "luaPlugin" /out "logs\luaPlugin.log" + +# 3) Build Documentation +#Write-Output "$color======== 3) Build M2TWEOP-Documentation ======== $endColor" +# +#cd "documentationGenerator" +#&".\generateDocs.ps1" -Wait -NoNewWindow | Write-Verbose + +# 4) Copy built files +Write-Output "$color======== 4) Copy all created files ======== $endColor" + +Set-Location -Path $currentLoc +Remove-item ./M2TWEOPGenerated -recurse -erroraction 'silentlycontinue' +new-item ./M2TWEOPGenerated -itemtype directory -erroraction 'silentlycontinue' + +new-item ./M2TWEOPGenerated/youneuoy_Data/plugins -itemtype directory -erroraction 'silentlycontinue' +Copy-Item -Path "M2TWEOP-luaPlugin\Debug\luaPlugin.dll" -Destination "./M2TWEOPGenerated/youneuoy_Data/plugins" +#Copy-Item -Path "M2TWEOP Code\Release\d3d9.dll" -Destination "./M2TWEOPGenerated" +#Copy-Item -Path "M2TWEOP Code\Release\M2TWEOP GUI.exe" -Destination "./M2TWEOPGenerated" +#Copy-Item -Path "M2TWEOP Code\Release\M2TWEOP tools.exe" -Destination "./M2TWEOPGenerated" +Copy-Item -Path "M2TWEOP Code\Debug\M2TWEOPLibrary.dll" -Destination "./M2TWEOPGenerated" + +# 6) Done +Write-Output "$color======== 6) Success! EOP Built Successfully! ======== $endColor" \ No newline at end of file From 994310e0b942ce096edc2bd6cb69251cfdd4fa6f Mon Sep 17 00:00:00 2001 From: Eddie Eldridge Date: Fri, 29 Sep 2023 15:24:56 +0100 Subject: [PATCH 02/22] Add a warning to setBuildingChainLimit() docs --- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 6100f192f..da270f04c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -361,6 +361,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) /*** * Sets the new maximum amount of building levels within a chain. + * WARNING: This function may be bugged -> https://github.com/youneuoy/M2TWEOP-library/issues/58 * @function M2TWEOP.setBuildingChainLimit * @tparam int limit default: 9, maximum: 57 * @usage From c1289c1657f6b1ae763d08aa13f30c61fb64b65a Mon Sep 17 00:00:00 2001 From: FynnTW Date: Sun, 1 Oct 2023 17:24:26 +0300 Subject: [PATCH 03/22] update --- M2TWEOP Code/M2TWEOP library/plugins.cpp | 218 ------ M2TWEOP Code/M2TWEOP library/plugins.h | 31 - M2TWEOP Code/M2TWEOP library/realGameTypes.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 62 +- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 179 ++++- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 629 ++++++++++-------- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 20 +- M2TWEOP-luaPlugin/luaPlugin/luaP.h | 35 - M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp | 130 ---- M2TWEOP-luaPlugin/luaPlugin/otherEvents.h | 25 - .../luaPlugin/settlementHelpers.cpp | 4 +- M2TWEOP-luaPlugin/luaPlugin/tableList.txt | 21 - 12 files changed, 568 insertions(+), 788 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/plugins.cpp b/M2TWEOP Code/M2TWEOP library/plugins.cpp index e4a6d3503..4cfb47101 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -122,14 +122,6 @@ void __fastcall plugins::onEvent(DWORD** vTab, DWORD arg2) (*(*pl->onCharacterSelected))(prs); - } - else if (compareEvent(event, &pl->onSiegeEquipmentCompleted.stringAdr, pl->onSiegeEquipmentCompleted.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - fortStruct* frt = fastFuncts::findFort(setl->xCoord, setl->yCoord); - - if (frt != nullptr)setl = nullptr; - (*(*pl->onSiegeEquipmentCompleted))(setl, frt); } else if (compareEvent(event, &pl->onSettlementSelected.stringAdr, pl->onSettlementSelected.strCmp)) { @@ -137,95 +129,6 @@ void __fastcall plugins::onEvent(DWORD** vTab, DWORD arg2) (*(*pl->onSettlementSelected))(setl); } - else if (compareEvent(event, &pl->onSettlementUpgraded.stringAdr, pl->onSettlementUpgraded.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - (*(*pl->onSettlementUpgraded))(setl); - } - else if (compareEvent(event, &pl->onSettlementConverted.stringAdr, pl->onSettlementConverted.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - (*(*pl->onSettlementConverted))(setl); - } - else if (compareEvent(event, &pl->onCityRiots.stringAdr, pl->onCityRiots.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - (*(*pl->onCityRiots))(setl); - } - else if (compareEvent(event, &pl->onUngarrisonedSettlement.stringAdr, pl->onUngarrisonedSettlement.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - (*(*pl->onUngarrisonedSettlement))(setl); - } - else if (compareEvent(event, &pl->onGiveSettlement.stringAdr, pl->onGiveSettlement.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - factionStruct* fac = reinterpret_cast(vTab[2]); - factionStruct* fac2 = reinterpret_cast(vTab[3]); - (*(*pl->onGiveSettlement))(setl, fac, fac2); - } - else if (compareEvent(event, &pl->onOccupySettlement.stringAdr, pl->onOccupySettlement.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - factionStruct* fac = reinterpret_cast(vTab[2]); - (*(*pl->onOccupySettlement))(prs, fac); - } - else if (compareEvent(event, &pl->onExterminatePopulation.stringAdr, pl->onExterminatePopulation.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - factionStruct* fac = reinterpret_cast(vTab[2]); - (*(*pl->onExterminatePopulation))(prs, fac); - } - else if (compareEvent(event, &pl->onSackSettlement.stringAdr, pl->onSackSettlement.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - factionStruct* fac = reinterpret_cast(vTab[2]); - (*(*pl->onSackSettlement))(prs, fac); - } - else if (compareEvent(event, &pl->onAddedToBuildingQueue.stringAdr, pl->onAddedToBuildingQueue.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - (*(*pl->onAddedToBuildingQueue))(sett, str); - } - else if (compareEvent(event, &pl->onBuildingDestroyed.stringAdr, pl->onBuildingDestroyed.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - (*(*pl->onBuildingDestroyed))(sett, str); - } - else if (compareEvent(event, &pl->onBuildingCompleted.stringAdr, pl->onBuildingCompleted.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onBuildingCompleted))(fac, sett); - } - else if (compareEvent(event, &pl->onAssassinCaughtAttackingPope.stringAdr, pl->onAssassinCaughtAttackingPope.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onAssassinCaughtAttackingPope))(fac); - } - else if (compareEvent(event, &pl->onAddedToTrainingQueue.stringAdr, pl->onAddedToTrainingQueue.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - if (*str == 0)str = nullptr; - (*(*pl->onAddedToTrainingQueue))(sett, str); - } - else if (compareEvent(event, &pl->onUnitTrained.stringAdr, pl->onUnitTrained.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - unit* un = reinterpret_cast(vTab[3]); - (*(*pl->onUnitTrained))(fac, sett, un); - } - else if (compareEvent(event, &pl->onAgentCreated.stringAdr, pl->onAgentCreated.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - int prsType = (int)vTab[2]; - settlementStruct* sett = reinterpret_cast(vTab[3]); - (*(*pl->onAgentCreated))(prs, prsType, sett); - } else if (compareEvent(event, &pl->onSettlementPanelOpen.stringAdr, pl->onSettlementPanelOpen.strCmp)) { settlementStruct* sett = reinterpret_cast(vTab[1]); @@ -359,24 +262,6 @@ void __fastcall plugins::onEvent(DWORD** vTab, DWORD arg2) void* colleg = reinterpret_cast(vTab[1]); (*(*pl->onCollegeOfCardinalsPanelOpen))(colleg); } - else if (compareEvent(event, &pl->onGuildUpgraded.stringAdr, pl->onGuildUpgraded.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - (*(*pl->onGuildUpgraded))(sett, str); - } - else if (compareEvent(event, &pl->onGuildDestroyed.stringAdr, pl->onGuildDestroyed.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - unsigned char guildID = (((BYTE*)vTab)[8]); - (*(*pl->onGuildDestroyed))(sett, guildID); - } - else if (compareEvent(event, &pl->onNewAdmiralCreated.stringAdr, pl->onNewAdmiralCreated.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - settlementStruct* sett = reinterpret_cast(vTab[2]); - (*(*pl->onNewAdmiralCreated))(prs, sett); - } else if (compareEvent(event, &pl->onShortcutTriggered.stringAdr, pl->onShortcutTriggered.strCmp)) { char* str = reinterpret_cast(vTab[1]); @@ -739,99 +624,11 @@ int plugin::init(string* nameP) onCharacterSelected.Load(&plPath, &fName); onCharacterSelected.strCmp = (*plugins::eventNames)[CharacterSelectedCode]; - - //onSiegeEquipmentCompleted - fName = "onSiegeEquipmentCompleted"; - onSiegeEquipmentCompleted.Load(&plPath, &fName); - onSiegeEquipmentCompleted.strCmp = (*plugins::eventNames)[SiegeEquipmentCompletedCode]; - - //onSettlementSelected fName = "onSettlementSelected"; onSettlementSelected.Load(&plPath, &fName); onSettlementSelected.strCmp = (*plugins::eventNames)[SettlementSelectedCode]; - - //onSettlementUpgraded - fName = "onSettlementUpgraded"; - onSettlementUpgraded.Load(&plPath, &fName); - onSettlementUpgraded.strCmp = (*plugins::eventNames)[SettlementUpgradedCode]; - - - //onSettlementConverted - fName = "onSettlementConverted"; - onSettlementConverted.Load(&plPath, &fName); - onSettlementConverted.strCmp = (*plugins::eventNames)[SettlementConvertedCode]; - - - //onCityRiots - fName = "onCityRiots"; - onCityRiots.Load(&plPath, &fName); - onCityRiots.strCmp = (*plugins::eventNames)[CityRiotsCode]; - - //onUngarrisonedSettlement - fName = "onUngarrisonedSettlement"; - onUngarrisonedSettlement.Load(&plPath, &fName); - onUngarrisonedSettlement.strCmp = (*plugins::eventNames)[UngarrisonedSettlementCode]; - - //onGiveSettlement - fName = "onGiveSettlement"; - onGiveSettlement.Load(&plPath, &fName); - onGiveSettlement.strCmp = (*plugins::eventNames)[GiveSettlementCode]; - - - //onOccupySettlement - fName = "onOccupySettlement"; - onOccupySettlement.Load(&plPath, &fName); - onOccupySettlement.strCmp = (*plugins::eventNames)[OccupySettlementCode]; - - //onExterminatePopulation - fName = "onExterminatePopulation"; - onExterminatePopulation.Load(&plPath, &fName); - onExterminatePopulation.strCmp = (*plugins::eventNames)[ExterminatePopulationCode]; - - - //onSackSettlement - fName = "onSackSettlement"; - onSackSettlement.Load(&plPath, &fName); - onSackSettlement.strCmp = (*plugins::eventNames)[SackSettlementCode]; - - //onAddedToBuildingQueue - fName = "onAddedToBuildingQueue"; - onAddedToBuildingQueue.Load(&plPath, &fName); - onAddedToBuildingQueue.strCmp = (*plugins::eventNames)[AddedToBuildingQueueCode]; - - //onBuildingDestroyed - fName = "onBuildingDestroyed"; - onBuildingDestroyed.Load(&plPath, &fName); - onBuildingDestroyed.strCmp = (*plugins::eventNames)[BuildingDestroyedCode]; - - //onBuildingCompleted - fName = "onBuildingCompleted"; - onBuildingCompleted.Load(&plPath, &fName); - onBuildingCompleted.strCmp = (*plugins::eventNames)[BuildingCompletedCode]; - - //onAssassinCaughtAttackingPope - fName = "onAssassinCaughtAttackingPope"; - onAssassinCaughtAttackingPope.Load(&plPath, &fName); - onAssassinCaughtAttackingPope.strCmp = (*plugins::eventNames)[AssassinCaughtAttackingPopeCode]; - - //onAddedToTrainingQueue - fName = "onAddedToTrainingQueue"; - onAddedToTrainingQueue.Load(&plPath, &fName); - onAddedToTrainingQueue.strCmp = (*plugins::eventNames)[AddedToTrainingQueueCode]; - - //onUnitTrained - fName = "onUnitTrained"; - onUnitTrained.Load(&plPath, &fName); - onUnitTrained.strCmp = (*plugins::eventNames)[UnitTrainedCode]; - - - //onAgentCreated - fName = "onAgentCreated"; - onAgentCreated.Load(&plPath, &fName); - onAgentCreated.strCmp = (*plugins::eventNames)[AgentCreatedCode]; - //onSettlementPanelOpen fName = "onSettlementPanelOpen"; onSettlementPanelOpen.Load(&plPath, &fName); @@ -957,21 +754,6 @@ int plugin::init(string* nameP) onCollegeOfCardinalsPanelOpen.Load(&plPath, &fName); onCollegeOfCardinalsPanelOpen.strCmp = (*plugins::eventNames)[CollegeOfCardinalsPanelOpenCode]; - //onGuildUpgraded - fName = "onGuildUpgraded"; - onGuildUpgraded.Load(&plPath, &fName); - onGuildUpgraded.strCmp = (*plugins::eventNames)[GuildUpgradedCode]; - - //onGuildDestroyed - fName = "onGuildDestroyed"; - onGuildDestroyed.Load(&plPath, &fName); - onGuildDestroyed.strCmp = (*plugins::eventNames)[GuildDestroyedCode]; - - //onNewAdmiralCreated - fName = "onNewAdmiralCreated"; - onNewAdmiralCreated.Load(&plPath, &fName); - onNewAdmiralCreated.strCmp = (*plugins::eventNames)[NewAdmiralCreatedCode]; - //onShortcutTriggered fName = "onShortcutTriggered"; onShortcutTriggered.Load(&plPath, &fName); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.h b/M2TWEOP Code/M2TWEOP library/plugins.h index 199a76727..4d68f99b2 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.h +++ b/M2TWEOP Code/M2TWEOP library/plugins.h @@ -91,33 +91,7 @@ class plugin ProcLoader onCharacterSelected; ProcLoader onMultiTurnMove; - ProcLoader onSiegeEquipmentCompleted; - ProcLoader onSettlementSelected; - ProcLoader onSettlementUpgraded; - ProcLoader onSettlementConverted; - - ProcLoader onCityRiots; - - ProcLoader onUngarrisonedSettlement; - - ProcLoader onGiveSettlement; - - ProcLoader onOccupySettlement; - ProcLoader onExterminatePopulation; - ProcLoader onSackSettlement; - - - ProcLoader onAddedToBuildingQueue; - ProcLoader onBuildingDestroyed; - ProcLoader onBuildingCompleted; - ProcLoader onAssassinCaughtAttackingPope; - ProcLoader onInquisitorAppointed; - - - ProcLoader onAddedToTrainingQueue; - ProcLoader onUnitTrained; - ProcLoader onAgentCreated; ProcLoader onSettlementPanelOpen; @@ -150,11 +124,6 @@ class plugin ProcLoader onNavalPreBattleScrollAdviceRequested; ProcLoader onCollegeOfCardinalsPanelOpen; - ProcLoader onGuildUpgraded; - ProcLoader onGuildDestroyed; - - ProcLoader onNewAdmiralCreated; - ProcLoader onShortcutTriggered; ProcLoader drawOnEndScene; diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index 565bf22e7..1d5d7f3a9 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -996,7 +996,7 @@ struct settlementStruct { undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ undefined field21_0x1a5[3]; - UINT32 regionNumber; /* number of region */ + UINT32 regionID; /* number of region */ undefined field_0x1ac[12]; int priceOfUnitsInRecruitmentSlots; undefined field24_0xBC[24]; diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index 298917169..dd1da9a93 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -158,6 +158,18 @@ namespace gameEvents newCode[0] = 0x0136EC8C; newCode[1] = 0x01329C64; addEvent(newCode[gv], "onGovernorBuildingDestroyed"); + newCode[0] = 0x0136F154; newCode[1] = 0x0132A12C; + addEvent(newCode[gv], "onGovernorThrowGames"); + + newCode[0] = 0x0136F224; newCode[1] = 0x0132A1FC; + addEvent(newCode[gv], "onGovernorThrowRaces"); + + newCode[0] = 0x013703A4; newCode[1] = 0x0132B37C; + addEvent(newCode[gv], "onCharacterSelected"); + + newCode[0] = 0x01370474; newCode[1] = 0x0132B44C; + addEvent(newCode[gv], "onEnemyCharacterSelected"); + //ransomEvent newCode[0] = 0x0136C8EC; newCode[1] = 0x013278C4; addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptor"); @@ -240,10 +252,23 @@ namespace gameEvents newCode[0] = 0x0136A3E4; newCode[1] = 0x013253BC; addEvent(newCode[gv], "onGeneralAssaultsResidence"); + //settOccupationEvent + newCode[0] = 0x0136F3C4; newCode[1] = 0x0132A39C; + addEvent(newCode[gv], "onOccupySettlement"); + newCode[0] = 0x0136F48C; newCode[1] = 0x0132A464; + addEvent(newCode[gv], "onSackSettlement"); + newCode[0] = 0x0136F55C; newCode[1] = 0x0132A534; + addEvent(newCode[gv], "onExterminatePopulation"); + + //namedCharacterRiotEvents + newCode[0] = 0x0136EEEC; newCode[1] = 0x01329EC4; + addEvent(newCode[gv], "onGovernorCityRiots"); + newCode[0] = 0x0136F084; newCode[1] = 0x0132A05C; + addEvent(newCode[gv], "onGovernorCityRebels"); + //namedCharacterTargetCharEvents newCode[0] = 0x0136A4B4; newCode[1] = 0x0132548C; addEvent(newCode[gv], "onGeneralAssaultsGeneral"); - newCode[0] = 0x0136C75C; newCode[1] = 0x01327734; addEvent(newCode[gv], "onCharacterAttacksCrusadingGeneral"); @@ -254,6 +279,32 @@ namespace gameEvents //settlementEvents newCode[0] = 0x0136E2B4; newCode[1] = 0x0132928C; addEvent(newCode[gv], "onSettlementTurnStart"); + newCode[0] = 0x0136F2F4; newCode[1] = 0x0132A2CC; + addEvent(newCode[gv], "onUngarrisonedSettlement"); + newCode[0] = 0x0136F6F4; newCode[1] = 0x0132A6CC; + addEvent(newCode[gv], "onSettlementUpgraded"); + newCode[0] = 0x0136F7C4; newCode[1] = 0x0132A79C; + addEvent(newCode[gv], "onSettlementConverted"); + newCode[0] = 0x0136FA24; newCode[1] = 0x0132A9FC; + addEvent(newCode[gv], "onSiegeEquipmentCompleted"); + newCode[0] = 0x0136FADC; newCode[1] = 0x0132AAB4; + addEvent(newCode[gv], "onSettlementTurnEnd"); + + //guildEvents + newCode[0] = 0x0136F88C; newCode[1] = 0x0132A864; + addEvent(newCode[gv], "onGuildUpgraded"); + newCode[0] = 0x0136F954; newCode[1] = 0x0132A92C; + addEvent(newCode[gv], "onGuildDestroyed"); + + //targetSettlementEvents + newCode[0] = 0x0136ED54; newCode[1] = 0x01329D2C; + addEvent(newCode[gv], "onCityRiots"); + newCode[0] = 0x0136EE1C; newCode[1] = 0x01329DF4; + addEvent(newCode[gv], "onGiveSettlement"); + newCode[0] = 0x0136EFB4; newCode[1] = 0x01329F8C; + addEvent(newCode[gv], "onCityRebels"); + newCode[0] = 0x0136F624; newCode[1] = 0x0132A5FC; + addEvent(newCode[gv], "onCitySacked"); //gameEvents newCode[0] = 0x0135E30C; newCode[1] = 0x013192E4; @@ -362,6 +413,7 @@ namespace gameEvents //diplomacyEvents newCode[0] = 0x0136958C; newCode[1] = 0x01324564; + newCode[0] = 0x0136958C; newCode[1] = 0x01324564; addEvent(newCode[gv], "onFactionWarDeclared"); newCode[0] = 0x0136965C; newCode[1] = 0x01324634; @@ -429,6 +481,9 @@ namespace gameEvents newCode[0] = 0x0136EBB4; newCode[1] = 0x01329B8C; addEvent(newCode[gv], "onAddedToTrainingQueue"); + newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; + addEvent(newCode[gv], "onBuildingCompleted"); + //agentCreatedEvent newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; addEvent(newCode[gv], "onAgentCreated"); @@ -553,11 +608,6 @@ void onCharacterSelected(namedCharacter* gen) { plugData::data.luaAll.onCharacterSelected(gen); } - -void onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) -{ - plugData::data.luaAll.onSiegeEquipmentCompleted(sett, frt); -} void onReadGameDbsAtStart() { gameEvents::initEvents(); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index e32e098ae..dad15974f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -113,7 +113,11 @@ namespace gameEvents characterUnitSettEvent = 42, characterBuildingEvent = 43, agentCreatedEvent = 44, - buildingEvent = 45 + buildingEvent = 45, + targetSettlementEvent = 46, + namedCharacterRiotEvents = 47, + settOccupationEvent = 48, + guildEvent = 49 }; class EventBase @@ -190,7 +194,7 @@ namespace gameEvents { auto targetSettlement = reinterpret_cast(vTab[2]); factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); const char* targetReligion = getReligion(targetFaction->religion); if (&(*funk) != nullptr) { (*funk)(targetSettlement, targetFaction, targetRegion, targetReligion); @@ -200,7 +204,7 @@ namespace gameEvents else if (EvType == EventType::crusadeEventEnds) { auto targetSettlement = reinterpret_cast(vTab[2]); - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); if (&(*funk) != nullptr) { (*funk)(targetSettlement, targetRegion); } @@ -343,13 +347,13 @@ namespace gameEvents fortStruct* fort = nullptr; factionStruct* faction = character->faction; factionStruct* targetFaction = settlement->faction; - if ((DWORD)(*settlement).vTable != 0x012FCF34) + if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) { fort = reinterpret_cast(vTab[2]); targetFaction = fort->faction; } const char* characterType = getType(character); - regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); const char* targetReligion = getReligion(targetFaction->religion); if (&(*funk) != nullptr) { @@ -458,7 +462,7 @@ namespace gameEvents auto targetSettlement = reinterpret_cast(vTab[2]); auto faction = reinterpret_cast(vTab[3]); factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); const char* religion = getReligion(faction->religion); const char* targetReligion = getReligion(targetFaction->religion); if (&(*funk) != nullptr) { @@ -472,7 +476,7 @@ namespace gameEvents auto army = reinterpret_cast(vTab[3]); factionStruct* faction = army->faction; factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); const char* religion = getReligion(faction->religion); const char* targetReligion = getReligion(targetFaction->religion); if (&(*funk) != nullptr) { @@ -512,7 +516,7 @@ namespace gameEvents regionStruct* region; if (settlement) { - region = gameHelpers::getRegion(settlement->regionNumber); + region = gameHelpers::getRegion(settlement->regionID); } else { @@ -530,7 +534,7 @@ namespace gameEvents factionStruct* faction = character->faction; auto targetSettlement = reinterpret_cast(vTab[2] + 0x3C); factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionNumber); + regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); const char* characterType = getType(character); const char* religion = getReligion(faction->religion); const char* targetReligion = getReligion(targetFaction->religion); @@ -573,7 +577,7 @@ namespace gameEvents if (vTab[5] != nullptr) { targetSettlement = reinterpret_cast(vTab[5]); - if ((DWORD)(*targetSettlement).vTable != 0x012FCF34) + if ((DWORD)(*targetSettlement).vTable != 0x012FCF34 && (DWORD)(*targetSettlement).vTable != 0x01341F54) { targetFort = reinterpret_cast(vTab[5]); } @@ -608,7 +612,7 @@ namespace gameEvents if (vTab[4] != nullptr) { targetSettlement = reinterpret_cast(vTab[4]); - if ((DWORD)(*targetSettlement).vTable != 0x012FCF34) + if ((DWORD)(*targetSettlement).vTable != 0x012FCF34 && (DWORD)(*targetSettlement).vTable != 0x01341F54) { targetFort = reinterpret_cast(vTab[4]); } @@ -705,8 +709,13 @@ namespace gameEvents else if (EvType == EventType::settlementEvent) { auto settlement = reinterpret_cast(vTab[1]); + factionStruct* faction; + if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) + { + settlement = reinterpret_cast(vTab[1]); + } factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { @@ -762,7 +771,7 @@ namespace gameEvents factionStruct* faction = character->faction; auto settlement = reinterpret_cast(vTab[3]); const char* characterType = reinterpret_cast(vTab[2]); - regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { (*funk)(character, faction, settlement, region, characterType, religion); @@ -773,7 +782,7 @@ namespace gameEvents { auto settlement = reinterpret_cast(vTab[1]); factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionNumber); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* build = reinterpret_cast(vTab[2]); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { @@ -781,6 +790,60 @@ namespace gameEvents } return 45; } + else if (EvType == EventType::targetSettlementEvent) + { + auto settlement = reinterpret_cast(vTab[1]); + factionStruct* faction = settlement->faction; + factionStruct* targetFaction = reinterpret_cast(vTab[2]); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); + const char* religion = getReligion(faction->religion); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(settlement, faction, region, religion, targetFaction, targetReligion); + } + return 46; + } + else if (EvType == EventType::namedCharacterRiotEvents) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + auto settlement = reinterpret_cast(vTab[2]); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); + const char* religion = getReligion(faction->religion); + factionStruct* targetFaction = reinterpret_cast(vTab[3]); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, settlement, region, religion, targetFaction, targetReligion); + } + return 47; + } + else if (EvType == EventType::settOccupationEvent) + { + auto character = reinterpret_cast(vTab[1]); + factionStruct* faction = character->faction; + const regionStruct* region = getRegion(character); + const char* religion = getReligion(faction->religion); + factionStruct* targetFaction = reinterpret_cast(vTab[2]); + const char* targetReligion = getReligion(targetFaction->religion); + if (&(*funk) != nullptr) { + (*funk)(character, faction, region, religion, targetFaction, targetReligion); + } + return 48; + } + else if (EvType == EventType::guildEvent) + { + auto settlement = reinterpret_cast(vTab[1]); + factionStruct* faction = settlement->faction; + regionStruct* region = gameHelpers::getRegion(settlement->regionID); + const char* religion = getReligion(faction->religion); + auto guild = reinterpret_cast(vTab[2]); + if (&(*funk) != nullptr) { + + (*funk)(settlement, faction, region, religion, guild); + + } + return 49; + } else { return 0; @@ -875,12 +938,96 @@ sol::function* onCeasedFactionHeir = nullptr; sol::function* onUngarrisonedFort = nullptr; sol::function* onTileSeen = nullptr; sol::function* onObjSeen = nullptr; +sol::function* onObjSeen = nullptr; sol::function* onUnitsDesertCrusade = nullptr; sol::function* onArmyTakesCrusadeTarget = nullptr; sol::function* onTransgression = nullptr; sol::function* onForgiveness = nullptr; +sol::function* onUpdateAttitude = nullptr; +sol::function* onDemeanour = nullptr; +sol::function* onBirth = nullptr; +sol::function* onCharacterComesOfAge = nullptr; +sol::function* onCharacterMarries = nullptr; +sol::function* onCharacterMarriesPrincess = nullptr; +sol::function* onMarriageAlliancePossible = nullptr; +sol::function* onMarriageAllianceOffered = nullptr; +sol::function* onPriestBecomesHeretic = nullptr; +sol::function* onCharacterNearHeretic = nullptr; +sol::function* onCharacterNearWitch = nullptr; +sol::function* onCardinalPromoted = nullptr; +sol::function* onCardinalRemoved = nullptr; +sol::function* onInquisitorAppointed = nullptr; +sol::function* onCharacterBecomesAFather = nullptr; +sol::function* onCharacterTurnEnd = nullptr; +sol::function* onCharacterTurnEndInSettlement = nullptr; +sol::function* onGeneralDevastatesTile = nullptr; +sol::function* onGeneralJoinCrusade = nullptr; +sol::function* onGeneralAbandonCrusade = nullptr; +sol::function* onGeneralArrivesCrusadeTargetRegion = nullptr; +sol::function* onGeneralTakesCrusadeTarget = nullptr; +sol::function* onCharacterAttacksCrusadingGeneral = nullptr; +sol::function* onGeneralPrisonersRansomedCaptor = nullptr; +sol::function* onGeneralPrisonersRansomedCaptive = nullptr; +sol::function* onFactionLeaderPrisonersRansomedCaptor = nullptr; +sol::function* onFactionLeaderPrisonersRansomedCaptive = nullptr; +sol::function* onSpyMission = nullptr; +sol::function* onExecutesASpyOnAMission = nullptr; +sol::function* onLeaderOrderedSpyingMission = nullptr; +sol::function* onAssassinationMission = nullptr; +sol::function* onExecutesAnAssassinOnAMission = nullptr; +sol::function* onAssassinCaughtAttackingPope = nullptr; +sol::function* onLeaderOrderedAssassination = nullptr; +sol::function* onSufferAssassinationAttempt = nullptr; +sol::function* onAcquisitionMission = nullptr; +sol::function* onSufferAcquisitionAttempt = nullptr; +sol::function* onMarriageMission = nullptr; +sol::function* onSufferMarriageAttempt = nullptr; +sol::function* onDenouncementMission = nullptr; +sol::function* onSufferDenouncementAttempt = nullptr; +sol::function* onSabotageMission = nullptr; +sol::function* onLeaderOrderedSabotage = nullptr; +sol::function* onBriberyMission = nullptr; +sol::function* onLeaderOrderedBribery = nullptr; +sol::function* onAcceptBribe = nullptr; +sol::function* onRefuseBribe = nullptr; +sol::function* onInsurrection = nullptr; +sol::function* onDiplomacyMission = nullptr; +sol::function* onLeaderOrderedDiplomacy = nullptr; +sol::function* onLeaderMissionSuccess = nullptr; +sol::function* onLeaderMissionFailed = nullptr; +sol::function* onForgiveness = nullptr; +sol::function* onSettlementTurnStart = nullptr; +sol::function* onNewAdmiralCreated = nullptr; +sol::function* onUnitTrained = nullptr; +sol::function* onGovernorUnitTrained = nullptr; +sol::function* onGovernorBuildingCompleted = nullptr; +sol::function* onAgentCreated = nullptr; +sol::function* onGovernorAgentCreated = nullptr; +sol::function* onBuildingDestroyed = nullptr; +sol::function* onAddedToBuildingQueue = nullptr; +sol::function* onAddedToTrainingQueue = nullptr; +sol::function* onGovernorBuildingDestroyed = nullptr; +sol::function* onCityRiots = nullptr; +sol::function* onGiveSettlement = nullptr; +sol::function* onGovernorCityRiots = nullptr; +sol::function* onCityRebels = nullptr; +sol::function* onGovernorCityRebels = nullptr; +sol::function* onGovernorThrowGames = nullptr; +sol::function* onGovernorThrowRaces = nullptr; +sol::function* onUngarrisonedSettlement = nullptr; +sol::function* onOccupySettlement = nullptr; +sol::function* onSackSettlement = nullptr; +sol::function* onExterminatePopulation = nullptr; +sol::function* onCitySacked = nullptr; +sol::function* onSettlementUpgraded = nullptr; +sol::function* onSettlementConverted = nullptr; +sol::function* onGuildUpgraded = nullptr; +sol::function* onGuildDestroyed = nullptr; +sol::function* onSiegeEquipmentCompleted = nullptr; +sol::function* onSettlementTurnEnd = nullptr; +sol::function* onBuildingCompleted = nullptr; +sol::function* onCharacterSelected = nullptr; +sol::function* onEnemyCharacterSelected = nullptr; extern "C" PLUGINM2TWEOP_API void onCharacterSelected(namedCharacter * gen); -//if sett==null, then you need use frt, else use sett -extern "C" PLUGINM2TWEOP_API void onSiegeEquipmentCompleted(settlementStruct * sett, fortStruct * frt); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index 8f149dbd6..8c61c2c38 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -762,7 +762,7 @@ void luaP::onPluginLoadF() @function onNewAdmiralCreated @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam regionStruct|nil region + @tparam regionStruct region @tparam string characterType @tparam string religion @@ -778,7 +778,7 @@ void luaP::onPluginLoadF() @function onGovernorBuildingDestroyed @tparam namedCharacter namedChar @tparam factionStruct faction - @tparam regionStruct|nil region + @tparam regionStruct region @tparam string characterType @tparam string religion @@ -788,6 +788,70 @@ void luaP::onPluginLoadF() end */ + /*** + Games have been thrown. + + @function onGovernorThrowGames + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + + @usage + function onGovernorThrowGames(namedChar, faction, region, characterType, religion) + --something + end + */ + + /*** + Races have been thrown. + + @function onGovernorThrowRaces + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + + @usage + function onGovernorThrowRaces(namedChar, faction, region, characterType, religion) + --something + end + */ + + /*** + The player has selected a character. + + @function onCharacterSelected + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + + @usage + function onCharacterSelected(namedChar, faction, region, characterType, religion) + --something + end + */ + + /*** + The player has selected an enemy character. + + @function onEnemyCharacterSelected + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + + @usage + function onEnemyCharacterSelected(namedChar, faction, region, characterType, religion) + --something + end + */ + /*** A mission has been completed. @@ -1391,6 +1455,268 @@ void luaP::onPluginLoadF() end */ + /*** + A settlement is no longer garrisoned. + + @function onUngarrisonedSettlement + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onUngarrisonedSettlement(settlement, faction, region, religion) + --something + end + */ + + /*** + A settlement has been upgraded. + + @function onSettlementUpgraded + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementUpgraded(settlement, faction, region, religion) + --something + end + */ + + /*** + A settlement has been converted. + + @function onSettlementConverted + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementConverted(settlement, faction, region, religion) + --something + end + */ + + /*** + Siege equipment has been completed by one of the besieging armies. + + @function onSiegeEquipmentCompleted + @tparam settlementStruct|fortStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSiegeEquipmentCompleted(settlement, faction, region, religion) + --something + end + */ + + /*** + A Settlement is being processed for the end of its faction's turn. + + @function onSettlementTurnEnd + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementTurnEnd(settlement, faction, region, religion) + --something + end + */ + + /*** + A guild has been created/upgraded. + + @function onGuildUpgraded + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam guild guild + + @usage + function onGuildUpgraded(settlement, faction, region, religion, guild) + --something + end + */ + + /*** + A guild has been destroyed. + + @function onGuildDestroyed + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam guild guild + + @usage + function onGuildDestroyed(settlement, faction, region, religion, guild) + --something + end + */ + + /*** + A settlement has been captured and occupied. + + @function onOccupySettlement + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onOccupySettlement(namedChar, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has been captured and sacked. + + @function onSackSettlement + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onSackSettlement(namedChar, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has been captured and some of its population has been decimated. + + @function onExterminatePopulation + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onExterminatePopulation(namedChar, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has rioted. + + @function onCityRiots + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onCityRiots(settlement, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has been given to another faction. + + @function onGiveSettlement + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onGiveSettlement(settlement, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has rebelled. + + @function onCityRebels + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onCityRebels(settlement, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has been razed. + + @function onCitySacked + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onCitySacked(settlement, faction, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has rioted. + + @function onGovernorCityRiots + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onGovernorCityRiots(namedChar, faction, settlement, region, religion, targetFaction, targetReligion) + --something + end + */ + + /*** + A settlement has rebelled. + + @function onGovernorCityRebels + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam settlementStruct settlement + @tparam regionStruct region + @tparam string religion + @tparam factionStruct targetFaction + @tparam string targetReligion + + @usage + function onGovernorCityRebels(namedChar, faction, settlement, region, religion, targetFaction, targetReligion) + --something + end + */ + /*** The player has abandoned a show me scipt. @@ -1779,6 +2105,22 @@ void luaP::onPluginLoadF() end */ + /*** + A building has been completed. + + @function onBuildingCompleted + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string buildingName + @tparam regionStruct region + @tparam string religion + + @usage + function onBuildingCompleted(settlement, faction, buildingName, region, religion) + --something here + end + */ + /*** A unit has been added to the training queue. @@ -2784,20 +3126,6 @@ void luaP::onPluginLoadF() onCharacterSelectedFunc = new sol::function(luaState["onCharacterSelected"]); checkLuaFunc(&onCharacterSelectedFunc); - /*** - Siege equipment has been completed by one of the sieging armies at this residence. - - @function onSiegeEquipmentCompleted - @tparam settlementStruct settlement nil if it is fort - @tparam fortStruct fort nil if it is settlement - - @usage - --something - */ - - onSiegeEquipmentCompletedFunc = new sol::function(luaState["onSiegeEquipmentCompleted"]); - checkLuaFunc(&onSiegeEquipmentCompletedFunc); - /*** The player has attempted to move a character beyond that character's given movement range for that turn. @@ -2827,227 +3155,6 @@ void luaP::onPluginLoadF() onSettlementSelectedFunc = new sol::function(luaState["onSettlementSelected"]); checkLuaFunc(&onSettlementSelectedFunc); - /*** - A settlement's level has been increased. - - @function onSettlementUpgraded - @tparam settlementStruct settlement - - @usage - function onSettlementUpgraded(settlement) - print("Function: onSettlementUpgraded()\n\tSettlement Level: "..settlement.level) - end - */ - - onSettlementUpgradedFunc = new sol::function(luaState["onSettlementUpgraded"]); - checkLuaFunc(&onSettlementUpgradedFunc); - - /*** - A settlement converted between city and castle and vice-versa. - - @function onSettlementConverted - @tparam settlementStruct settlement - - @usage - function onSettlementConverted(settlement) - if settlement.isCastle == 1 then - --do stuff - end - end - */ - - onSettlementConvertedFunc = new sol::function(luaState["onSettlementConverted"]); - checkLuaFunc(&onSettlementConvertedFunc); - - /*** - A settlement has rioted. - - @function onCityRiots - @tparam settlementStruct settlement - - @usage - --something - */ - - onCityRiotsFunc = new sol::function(luaState["onCityRiots"]); - checkLuaFunc(&onCityRiotsFunc); - - /*** - The last unit has been removed from a settlement, agents do not count. - - @function onUngarrisonedSettlement - @tparam settlementStruct settlement - - @usage - --something - */ - - onUngarrisonedSettlementFunc = new sol::function(luaState["onUngarrisonedSettlement"]); - checkLuaFunc(&onUngarrisonedSettlementFunc); - - - /*** - A settlement has been given to another faction. - - @function onGiveSettlement - @tparam settlementStruct settlement - @tparam factionStruct fac1 - @tparam factionStruct fac2 - - - @usage - --something - */ - - onGiveSettlementFunc = new sol::function(luaState["onGiveSettlement"]); - checkLuaFunc(&onGiveSettlementFunc); - - /*** - A general has captured a settlement and the occupy option has been chosen - - @function onOccupySettlement - @tparam namedCharacter character only generals, event does not fire for captains - @tparam factionStruct targetFaction - - @usage - --something - */ - - onOccupySettlementFunc = new sol::function(luaState["onOccupySettlement"]); - checkLuaFunc(&onOccupySettlementFunc); - - /*** - A general has captured a settlement and the exterminate option has been chosen. - - @function onExterminatePopulation - @tparam namedCharacter character only generals, event does not fire for captains - @tparam factionStruct targetFaction - - - @usage - --something - */ - - onExterminatePopulationFunc = new sol::function(luaState["onExterminatePopulation"]); - checkLuaFunc(&onExterminatePopulationFunc); - - /*** - A general has captured a settlement and the sack option has been chosen. - - @function onSackSettlement - @tparam namedCharacter character only generals, event does not fire for captains - @tparam factionStruct targetFaction - - - @usage - --something - */ - - onSackSettlementFunc = new sol::function(luaState["onSackSettlement"]); - checkLuaFunc(&onSackSettlementFunc); - - /*** - A building has been added to the construction queue. - - @function onAddedToBuildingQueue - @tparam settlementStruct settlement - @tparam string buildNme level name - - - @usage - --something - */ - - onAddedToBuildingQueueFunc = new sol::function(luaState["onAddedToBuildingQueue"]); - checkLuaFunc(&onAddedToBuildingQueueFunc); - - /*** - A building has been destroyed. - - @function onBuildingDestroyed - @tparam settlementStruct settlement - @tparam string buildNme level name - - - @usage - --something - */ - - onBuildingDestroyedFunc = new sol::function(luaState["onBuildingDestroyed"]); - checkLuaFunc(&onBuildingDestroyedFunc); - - /*** - A building has been completed. - - @function onBuildingCompleted - @tparam factionStruct fac - @tparam settlementStruct settlement - - @usage - --something - */ - - onBuildingCompletedFunc = new sol::function(luaState["onBuildingCompleted"]); - checkLuaFunc(&onBuildingCompletedFunc); - - - /*** - A unit has been added to the training queue. - - @function onAddedToTrainingQueue - @tparam settlementStruct sett - @tparam string unitName - - @usage - --something - */ - - onAddedToTrainingQueueFunc = new sol::function(luaState["onAddedToTrainingQueue"]); - checkLuaFunc(&onAddedToTrainingQueueFunc); - - /*** - A unit has been trained. - - @function onUnitTrained - @tparam factionStruct fac - @tparam settlementStruct sett - @tparam unit unit - - @usage - --something - */ - - onUnitTrainedFunc = new sol::function(luaState["onUnitTrained"]); - checkLuaFunc(&onUnitTrainedFunc); - - /*** - An agent has been trained. - - @function onAgentCreated - @tparam namedCharacter character - @tparam int agentType see @{character:setTypeID} for list of type integers - @tparam settlementStruct sett - - @usage - --something - */ - - onAgentCreatedFunc = new sol::function(luaState["onAgentCreated"]); - checkLuaFunc(&onAgentCreatedFunc); - - /*** - An assassination mission against the pope has failed and the assassin is executed. - - @function onAssassinCaughtAttackingPope - @tparam factionStruct fac - - @usage - --something - */ - - onAssassinCaughtAttackingPopeFunc = new sol::function(luaState["onAssassinCaughtAttackingPope"]); - checkLuaFunc(&onAssassinCaughtAttackingPopeFunc); - /*** The player has opened the panel for the selected settlement. @@ -3361,54 +3468,6 @@ void luaP::onPluginLoadF() onCollegeOfCardinalsPanelOpenFunc = new sol::function(luaState["onCollegeOfCardinalsPanelOpen"]); checkLuaFunc(&onCollegeOfCardinalsPanelOpenFunc); - /*** - A guild has been created or upgraded. - - @function onGuildUpgraded - @tparam settlementStruct sett - @tparam string guildName - - @usage - function onGuildUpgraded(sett, guildName) - print("Function: onGuildUpgraded()\n\tSettlement: "..sett.name.."\n\tGuild: "..guildName) - end - */ - - onGuildUpgradedFunc = new sol::function(luaState["onGuildUpgraded"]); - checkLuaFunc(&onGuildUpgradedFunc); - - /*** - A guild has been destroyed. - - @function onGuildDestroyed - @tparam settlementStruct sett - @tparam int guildID - - @usage - function onGuildDestroyed(sett, guildID) - print("Function: onGuildDestroyed()\n\tSettlement: "..sett.name.."\n\tID: "..guildID) - end - */ - - onGuildDestroyedFunc = new sol::function(luaState["onGuildDestroyed"]); - checkLuaFunc(&onGuildDestroyedFunc); - - /*** - A new admiral has been created for a new ship. - - @function onNewAdmiralCreated - @tparam namedCharacter admiral - @tparam settlementStruct sett - - @usage - function onNewAdmiralCreated(admiral, sett) - print("Function: onNewAdmiralCreated()\n\tAdmiral: "..admiral.fullName.."\n\tSettlement: "..sett.name) - end - */ - - onNewAdmiralCreatedFunc = new sol::function(luaState["onNewAdmiralCreated"]); - checkLuaFunc(&onNewAdmiralCreatedFunc); - /*** The player triggered a keyboard shortcut. diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index d9099793f..0e00ff370 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -1809,7 +1809,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield factionStruct ownerFaction @tfield changeOwner changeOwner @tfield int fac_creatorNum - @tfield int regionNumber + @tfield int regionID @tfield int level @tfield int isCastle @tfield int isProvokedRebellion @@ -1903,7 +1903,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.settlementStruct.set_function("changeOwner", &settlementHelpers::changeOwner); types.settlementStruct.set("fac_creatorNum", &settlementStruct::fac_creatorModNum); - types.settlementStruct.set("regionNumber", &settlementStruct::regionNumber); + types.settlementStruct.set("regionID", &settlementStruct::regionID); types.settlementStruct.set("level", &settlementStruct::level); types.settlementStruct.set("isCastle", &settlementStruct::isCastle); types.settlementStruct.set("isProvokedRebellion", &settlementStruct::isProvokedRebellion); @@ -2548,19 +2548,3 @@ void luaP::onSettlementSelected(settlementStruct* sett) tryLua((*onSettlementSelectedFunc)(sett)); } } - -void luaP::onSettlementUpgraded(settlementStruct* sett) -{ - if (onSettlementUpgradedFunc != nullptr) - { - tryLua((*onSettlementUpgradedFunc)(sett)); - } -} - -void luaP::onSettlementConverted(settlementStruct* sett) -{ - if (onSettlementConvertedFunc != nullptr) - { - tryLua((*onSettlementConvertedFunc)(sett)); - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index f2c378347..24ccad170 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -88,19 +88,9 @@ class luaP void onPluginLoadF(); void onChangeTurnNum(int num); void onCharacterSelected(namedCharacter* gen); - void onGeneralDevastatesTile(namedCharacter* gen); - - void onUpdateAttitude(factionStruct* fac, factionStruct* fac2); - void onDemeanour(factionStruct* fac, factionStruct* fac2, float amount); - - void onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt); - - void onMultiTurnMove(namedCharacter* gen); void onSettlementSelected(settlementStruct* sett); - void onSettlementUpgraded(settlementStruct* sett); - void onSettlementConverted(settlementStruct* sett); sol::state luaState; @@ -180,30 +170,10 @@ class luaP sol::function* onChangeTurnNumFunc = nullptr; sol::function* onCharacterSelectedFunc = nullptr; - sol::function* onSiegeEquipmentCompletedFunc = nullptr; sol::function* onMultiTurnMoveFunc = nullptr; sol::function* onSettlementSelectedFunc = nullptr; - sol::function* onSettlementUpgradedFunc = nullptr; - sol::function* onSettlementConvertedFunc = nullptr; - sol::function* onCityRiotsFunc = nullptr; - sol::function* onUngarrisonedSettlementFunc = nullptr; - - sol::function* onGiveSettlementFunc = nullptr; - sol::function* onOccupySettlementFunc = nullptr; - sol::function* onExterminatePopulationFunc = nullptr; - - sol::function* onSackSettlementFunc = nullptr; - sol::function* onAddedToBuildingQueueFunc = nullptr; - sol::function* onBuildingDestroyedFunc = nullptr; - sol::function* onBuildingCompletedFunc = nullptr; - - sol::function* onAddedToTrainingQueueFunc = nullptr; - - sol::function* onUnitTrainedFunc = nullptr; - sol::function* onAgentCreatedFunc = nullptr; - sol::function* onAssassinCaughtAttackingPopeFunc = nullptr; @@ -234,11 +204,6 @@ class luaP sol::function* onNavalPreBattleScrollAdviceRequestedFunc = nullptr; sol::function* onCollegeOfCardinalsPanelOpenFunc = nullptr; - sol::function* onGuildUpgradedFunc = nullptr; - sol::function* onGuildDestroyedFunc = nullptr; - - sol::function* onNewAdmiralCreatedFunc = nullptr; - sol::function* onShortcutTriggeredFunc = nullptr; void checkLuaFunc(sol::function** lRef); diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp index a3f873a88..92151f113 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp @@ -10,136 +10,6 @@ void onSettlementSelected(settlementStruct* sett) plugData::data.luaAll.onSettlementSelected(sett); } -void onSettlementUpgraded(settlementStruct* sett) -{ - plugData::data.luaAll.onSettlementUpgraded(sett); -} - -void onSettlementConverted(settlementStruct* sett) -{ - plugData::data.luaAll.onSettlementConverted(sett); -} - -void onCityRiots(settlementStruct* sett) -{ - if (plugData::data.luaAll.onCityRiotsFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCityRiotsFunc)(sett)); - } -} - -void onUngarrisonedSettlement(settlementStruct* sett) -{ - if (plugData::data.luaAll.onUngarrisonedSettlementFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUngarrisonedSettlementFunc)(sett)); - } -} - -void onGiveSettlement(settlementStruct* sett, factionStruct* fac, factionStruct* fac2) -{ - if (plugData::data.luaAll.onGiveSettlementFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onGiveSettlementFunc)(sett, fac, fac2)); - } -} - -void onOccupySettlement(namedCharacter* gen, factionStruct* fac) -{ - if (plugData::data.luaAll.onOccupySettlementFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onOccupySettlementFunc)(gen, fac)); - } -} - -void onExterminatePopulation(namedCharacter* gen, factionStruct* fac) -{ - if (plugData::data.luaAll.onExterminatePopulationFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onExterminatePopulationFunc)(gen, fac)); - } -} - -void onSackSettlement(namedCharacter* gen, factionStruct* fac) -{ - if (plugData::data.luaAll.onSackSettlementFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onSackSettlementFunc)(gen, fac)); - } -} - -void onAddedToBuildingQueue(settlementStruct* sett, const char* build) -{ - if (plugData::data.luaAll.onAddedToBuildingQueueFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onAddedToBuildingQueueFunc)(sett, build)); - } -} - -void onBuildingDestroyed(settlementStruct* sett, const char* build) -{ - if (plugData::data.luaAll.onBuildingDestroyedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBuildingDestroyedFunc)(sett, build)); - } -} - -void onBuildingCompleted(factionStruct* fac, settlementStruct* sett) -{ - if (plugData::data.luaAll.onBuildingCompletedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onBuildingCompletedFunc)(fac, sett)); - } -} - -void onAddedToTrainingQueue(settlementStruct* sett, const char* unitName) -{ - if (plugData::data.luaAll.onAddedToTrainingQueueFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onAddedToTrainingQueueFunc)(sett, unitName)); - } -} - -void onUnitTrained(factionStruct* fac, settlementStruct* sett, unit* un) -{ - if (plugData::data.luaAll.onUnitTrainedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUnitTrainedFunc)(fac, sett, un)); - } -} - -void onAgentCreated(namedCharacter* pers, int type, settlementStruct* sett) -{ - if (plugData::data.luaAll.onAgentCreatedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onAgentCreatedFunc)(pers, type, sett)); - } -} - -void onGuildUpgraded(settlementStruct* sett, const char* resourceDescription) -{ - if (plugData::data.luaAll.onGuildUpgradedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onGuildUpgradedFunc)(sett, resourceDescription)) - } -} - -void onGuildDestroyed(settlementStruct* sett, unsigned char guildID) -{ - if (plugData::data.luaAll.onGuildDestroyedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onGuildDestroyedFunc)(sett, guildID)) - } -} - -void onNewAdmiralCreated(namedCharacter* pers, settlementStruct* sett) -{ - if (plugData::data.luaAll.onNewAdmiralCreatedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onNewAdmiralCreatedFunc)(pers, sett)) - } -} - void onShortcutTriggered(const char* str) { if (plugData::data.luaAll.onShortcutTriggeredFunc != nullptr) diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h index eff0dd5ff..510085035 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h @@ -2,30 +2,5 @@ #include "pluginM2TWEOP.h" extern "C" PLUGINM2TWEOP_API void onMultiTurnMove(namedCharacter * gen); extern "C" PLUGINM2TWEOP_API void onSettlementSelected(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onSettlementUpgraded(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onSettlementConverted(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onCityRiots(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onUngarrisonedSettlement(settlementStruct * sett); - -extern "C" PLUGINM2TWEOP_API void onGiveSettlement(settlementStruct * sett, factionStruct * fac, factionStruct * fac2); - -extern "C" PLUGINM2TWEOP_API void onOccupySettlement(namedCharacter * gen, factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onExterminatePopulation(namedCharacter * gen, factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onSackSettlement(namedCharacter * gen, factionStruct * fac); - -extern "C" PLUGINM2TWEOP_API void onAddedToBuildingQueue(settlementStruct * sett, const char* build); -extern "C" PLUGINM2TWEOP_API void onBuildingDestroyed(settlementStruct * sett, const char* build); -extern "C" PLUGINM2TWEOP_API void onBuildingCompleted(factionStruct * fac, settlementStruct * sett); - - -extern "C" PLUGINM2TWEOP_API void onAddedToTrainingQueue(settlementStruct * sett, const char* unitName); - -extern "C" PLUGINM2TWEOP_API void onUnitTrained(factionStruct * fac, settlementStruct * sett, unit * un); -extern "C" PLUGINM2TWEOP_API void onAgentCreated(namedCharacter * pers, int type, settlementStruct * sett); - -extern "C" PLUGINM2TWEOP_API void onGuildUpgraded(settlementStruct * sett, const char* resourceDescription); -extern "C" PLUGINM2TWEOP_API void onGuildDestroyed(settlementStruct * sett, unsigned char guildID); - -extern "C" PLUGINM2TWEOP_API void onNewAdmiralCreated(namedCharacter * pers, settlementStruct * sett); extern "C" PLUGINM2TWEOP_API void onShortcutTriggered(const char* str); diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index 9576448a7..91ca92ef0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp @@ -14,7 +14,7 @@ void settlementHelpers::changeOwner(settlementStruct* sett, factionStruct* newOw float settlementHelpers::getReligion(const settlementStruct* sett, int index) { - regionStruct* currRegion = (*(*plugData::data.funcs.getRegionByID))(sett->regionNumber); + regionStruct* currRegion = (*(*plugData::data.funcs.getRegionByID))(sett->regionID); if (currRegion == nullptr) { return 0.0f; @@ -23,7 +23,7 @@ float settlementHelpers::getReligion(const settlementStruct* sett, int index) } void settlementHelpers::setReligion(const settlementStruct* sett, int index, float value) { - regionStruct* currRegion = (*(*plugData::data.funcs.getRegionByID))(sett->regionNumber); + regionStruct* currRegion = (*(*plugData::data.funcs.getRegionByID))(sett->regionID); currRegion->religionsARR[index] = value; } resStrat* settlementHelpers::getResource(const settlementStruct* sett, int index) diff --git a/M2TWEOP-luaPlugin/luaPlugin/tableList.txt b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt index 01f2b3a69..e48978756 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/tableList.txt +++ b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt @@ -12,11 +12,6 @@ @tfield onFactionAllianceDeclared onFactionAllianceDeclared @tfield onFactionTradeAgreementMade onFactionTradeAgreementMade @tfield onFactionBreakAlliance onFactionBreakAlliance - @tfield onGiveMoney onGiveMoney - @tfield onUpdateAttitude onUpdateAttitude - @tfield onDemeanour onDemeanour - @tfield onGeneralAssaultsGeneral onGeneralAssaultsGeneral - @tfield onGeneralAssaultsResidence onGeneralAssaultsResidence @tfield onGeneralCaptureSettlement onGeneralCaptureSettlement @tfield onGeneralCaptureResidence onGeneralCaptureResidence @tfield onSiegeEquipmentCompleted onSiegeEquipmentCompleted @@ -25,26 +20,10 @@ @tfield onSettlementSelected onSettlementSelected @tfield onSettlementUpgraded onSettlementUpgraded @tfield onSettlementConverted onSettlementConverted - @tfield onCityRiots onCityRiots - @tfield onUngarrisonedSettlement onUngarrisonedSettlement @tfield onUngarrisonedFort onUngarrisonedFort - @tfield onGiveSettlement onGiveSettlement - @tfield onOccupySettlement onOccupySettlement - @tfield onExterminatePopulation onExterminatePopulation - @tfield onSackSettlement onSackSettlement - @tfield onAddedToBuildingQueue onAddedToBuildingQueue - @tfield onBuildingDestroyed onBuildingDestroyed - @tfield onBuildingCompleted onBuildingCompleted - @tfield onEventCounter onEventCounter @tfield onFactionExcommunicated onFactionExcommunicated - @tfield onDisaster onDisaster @tfield onHordeFormed onHordeFormed - @tfield onAddedToTrainingQueue onAddedToTrainingQueue @tfield onUnitDisbanded onUnitDisbanded - @tfield onUnitTrained onUnitTrained - @tfield onAgentCreated onAgentCreated - @tfield onObjSeen onObjSeen - @tfield onTileSeen onTileSeen @tfield onGameReloaded onGameReloaded @tfield onTransgression onTransgression @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget From a432253d6ee0a81666f1798fcecc8565b97eb8bc Mon Sep 17 00:00:00 2001 From: FynnTW Date: Sun, 1 Oct 2023 21:08:37 +0300 Subject: [PATCH 04/22] finish adding game events --- M2TWEOP Code/M2TWEOP library/eventsCodes.h | 108 +- M2TWEOP Code/M2TWEOP library/plugins.cpp | 450 -------- M2TWEOP Code/M2TWEOP library/plugins.h | 40 - M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 88 ++ M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 71 +- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 1132 ++++++++++--------- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 32 - M2TWEOP-luaPlugin/luaPlugin/luaP.h | 42 - M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp | 19 - M2TWEOP-luaPlugin/luaPlugin/otherEvents.h | 6 - M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/tableList.txt | 283 +++-- M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp | 194 ---- M2TWEOP-luaPlugin/luaPlugin/uiEvents.h | 31 - 14 files changed, 999 insertions(+), 1499 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/eventsCodes.h b/M2TWEOP Code/M2TWEOP library/eventsCodes.h index 7060e32ff..8b1378917 100644 --- a/M2TWEOP Code/M2TWEOP library/eventsCodes.h +++ b/M2TWEOP Code/M2TWEOP library/eventsCodes.h @@ -1,107 +1 @@ -#pragma once -//indecses for events -#define PreFactionTurnStartNumCode 0//! -#define FactionTurnStartCode 1//! -#define FactionTurnEndCode 2//! -#define FactionNewCapitalCode 3//! -#define FactionWarDeclaredCode 4//! -#define FactionAllianceDeclaredCode 5//! -#define FactionTradeAgreementMadeCode 6//!! -#define FactionBreakAllianceCode 7// -//#define InterFactionMarriageCode 8 -#define GiveMoneyCode 9//! -#define HordeFormedCode 10//! -#define TransgressionCode 11//! -//#define DishonestTransgressionCode 12 -#define UpdateAttitudeCode 13//! -#define DemeanourCode 14//! -#define CharacterSelectedCode 15//! -#define GeneralAssaultsResidenceCode 16//!! -#define GeneralAssaultsGeneralCode 17//!! -#define GeneralCaptureResidenceCode 18//!! -#define GeneralCaptureSettlementCode 19//! -#define SiegeEquipmentCompletedCode 20//! -#define PostBattleCode 21//! -#define SettlementSelectedCode 22//! -#define SettlementUpgradedCode 23//! -#define SettlementConvertedCode 24//! -//#define InsurrectionCode 25 -#define CityRiotsCode 26//! -#define GiveSettlementCode 27//! -//#define CityRebelsCode 28 -#define UngarrisonedSettlementCode 29//! -#define OccupySettlementCode 30//! -#define SackSettlementCode 31//! -#define ExterminatePopulationCode 32//! -//#define CitySackedCode 33 -#define BuildingCompletedCode 34//! -#define BuildingDestroyedCode 35//! -#define AddedToBuildingQueueCode 36//! -#define GuildUpgradedCode 37 -#define GuildDestroyedCode 38 -#define AgentCreatedCode 39//! -#define UnitTrainedCode 40//! -#define UnitDisbandedCode 41//! -#define AddedToTrainingQueueCode 42//! -#define EventCounterCode 43//! -#define TileSeenCode 44// -#define ObjSeenCode 45//! -#define CharacterPanelOpenCode 46//! -#define SettlementPanelOpenCode 47//! -#define FinancesPanelOpenCode 48//! -#define FactionSummaryPanelOpenCode 49//! -#define FamilyTreePanelOpenCode 50//! -#define DiplomaticStandingPanelOpenCode 51//! -#define DiplomacyPanelOpenCode 52//! -#define PreBattlePanelOpenCode 53//! -//#define RecruitmentPanelOpenCode 54 -//#define ConstructionPanelOpenCode 55 -#define TradePanelOpenCode 56//! -//#define HireMercenariesPanelOpenCode 57 -#define NavalAutoResolvePanelOpenCode 58//! -#define IncomingMessageCode 59//! -#define MessageOpenCode 60//! -#define MessageClosedCode 61//! -#define RequestBuildingAdviceCode 62//! -#define RequestTrainingAdviceCode 63//! -//#define RequestMercenariesAdviceCode 64 -#define ButtonPressedCode 65//! -#define UIElementVisibleCode 66//! -#define ScrollOpenedCode 67//! -#define ScrollClosedCode 68//! -//#define AdviceSupressedCode 69 -#define ScrollAdviceRequestedCode 70//! -#define PreBattleScrollAdviceRequestedCode 71//! -#define NavalPreBattleScrollAdviceRequestedCode 72//! -#define SettlementScrollAdviceRequestedCode 73//! -//#define AbandonShowMeCode 74 -//#define ScriptedAdviceCode 75 -#define GameReloadedCode 76//! -//#define DeclineAuatedSettlementManagementCode 77 -#define DisasterCode 78//! -#define PopeElectedCode 70//! -#define VotedForPopeCode 80//! -#define FactionExcommunicatedCode 81//! -#define CrusadeCalledCode 82//! -#define CrusadeEndsCode 83//! -#define PopeAcceptsCrusadeTargetCode 84//! -#define PopeRejectsCrusadeTargetCode 85//! -#define UnitsDesertCrusadeCode 86//! -#define ArmyTakesCrusadeTargetCode 87//! -//#define ForgivenessCode 88 -#define InquisitorAppointedCode 89//! -#define AssassinCaughtAttackingPopeCode 90//! -#define CollegeOfCardinalsPanelOpenCode 91//! -#define MultiTurnMoveCode 92//! -#define UngarrisonedFortCode 93//! -#define BrotherAdoptedCode 94//! -#define BirthCode 95//! -#define CharacterComesOfAgeCode 96//! -#define CharacterMarriesCode 97//! -#define CharacterBecomesAFatherCode 98//! -#define NewAdmiralCreatedCode 99//! -#define ShortcutTriggeredCode 100//! -#define CharacterMarriesPrincessCode 101//! -#define BecomesFactionLeaderCode 102//! -#define BecomesFactionHeirCode 103//! -#define GeneralDevastatesTileCode 104//! + diff --git a/M2TWEOP Code/M2TWEOP library/plugins.cpp b/M2TWEOP Code/M2TWEOP library/plugins.cpp index 4cfb47101..60c532eff 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -8,7 +8,6 @@ #include "eduThings.h" #include "onlineThings.h" plugins::configT plugins::pluginsCfg; -vector* plugins::eventNames; void plugins::init() { @@ -72,202 +71,6 @@ void __fastcall plugins::onEvent(DWORD** vTab, DWORD arg2) battleCreator::onHotseatScreen(); } } - - - /*if (strcmp(event, "CharacterSelected") == 0) - { - - namedCharacter* prs = reinterpret_cast(vTab[1]); - - stackStruct* army = prs->gen->armyLeaded; - if (army) - { - eduThings::addEopEduEntry(army->units[0]->eduEntry->Index,1000); - int edb=eduThings::getDataEopEdu(1000); - eduThings::setEntryUnitCardTga(1000,"#akavir_swordsmen.tga"); - eduThings::setEntryInfoCardTga(1000,"akavir_swordsmen_info.tga"); - eduThings::setEntrySoldierModel(1000,"Sword_and_Buckler_Men"); - eduThings::setEntryLocalizedName(1000,u8"Òåñò"); - eduThings::setEntryLocalizedDescr(1000, u8"Îïèñàíèå"); - eduThings::setEntryLocalizedShortDescr(1000, u8"Êîðîòêîå îïèñàíèå"); - - unit* res = nullptr; - - DWORD adr = codes::offsets.createUnitFunc; - _asm { - mov ecx, edb - - push 1 - push 1 - push -1 - push 1 - push 0 - push 0 - push 0 - - mov eax, [adr] - call eax - mov res, eax - } - fastFuncts::addUnitToArmy(army, res); - } - }*/ - - for (plugin* pl : pluginsCfg.plugins) - { - if (compareEvent(event, &pl->onCharacterSelected.stringAdr, pl->onCharacterSelected.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - - (*(*pl->onCharacterSelected))(prs); - - - } - else if (compareEvent(event, &pl->onSettlementSelected.stringAdr, pl->onSettlementSelected.strCmp)) - { - settlementStruct* setl = reinterpret_cast(vTab[1]); - - (*(*pl->onSettlementSelected))(setl); - } - else if (compareEvent(event, &pl->onSettlementPanelOpen.stringAdr, pl->onSettlementPanelOpen.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - (*(*pl->onSettlementPanelOpen))(sett); - } - else if (compareEvent(event, &pl->onFinancesPanelOpen.stringAdr, pl->onFinancesPanelOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFinancesPanelOpen))(fac); - } - else if (compareEvent(event, &pl->onFactionSummaryPanelOpen.stringAdr, pl->onFactionSummaryPanelOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFactionSummaryPanelOpen))(fac); - } - else if (compareEvent(event, &pl->onFamilyTreePanelOpen.stringAdr, pl->onFamilyTreePanelOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onFamilyTreePanelOpen))(fac); - } - else if (compareEvent(event, &pl->onDiplomaticStandingPanelOpen.stringAdr, pl->onDiplomaticStandingPanelOpen.strCmp)) - { - (*(*pl->onDiplomaticStandingPanelOpen))(); - } - else if (compareEvent(event, &pl->onDiplomacyPanelOpen.stringAdr, pl->onDiplomacyPanelOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onDiplomacyPanelOpen))(fac); - } - else if (compareEvent(event, &pl->onPreBattlePanelOpen.stringAdr, pl->onPreBattlePanelOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - (*(*pl->onPreBattlePanelOpen))(fac); - } - else if (compareEvent(event, &pl->onNavalAutoResolvePanelOpen.stringAdr, pl->onNavalAutoResolvePanelOpen.strCmp)) - { - (*(*pl->onNavalAutoResolvePanelOpen))(); - } - else if (compareEvent(event, &pl->onCharacterPanelOpen.stringAdr, pl->onCharacterPanelOpen.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - (*(*pl->onCharacterPanelOpen))(prs); - } - else if (compareEvent(event, &pl->onTradePanelOpen.stringAdr, pl->onTradePanelOpen.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - (*(*pl->onTradePanelOpen))(sett); - } - else if (compareEvent(event, &pl->onRequestBuildingAdvice.stringAdr, pl->onRequestBuildingAdvice.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - (*(*pl->onRequestBuildingAdvice))(sett); - } - else if (compareEvent(event, &pl->onRequestTrainingAdvice.stringAdr, pl->onRequestTrainingAdvice.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - eduEntry* edEnt = reinterpret_cast(vTab[2]); - (*(*pl->onRequestTrainingAdvice))(sett, edEnt); - } - else if (compareEvent(event, &pl->onMessageOpen.stringAdr, pl->onMessageOpen.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - int some = (int)vTab[2]; - (*(*pl->onMessageOpen))(fac, some); - } - else if (compareEvent(event, &pl->onIncomingMessage.stringAdr, pl->onIncomingMessage.strCmp)) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - int some = (int)vTab[2]; - (*(*pl->onIncomingMessage))(fac, some); - } - else if (compareEvent(event, &pl->onMessageClosed.stringAdr, pl->onMessageClosed.strCmp)) - { - int some = (int)vTab[1]; - (*(*pl->onMessageClosed))(some); - } - else if (compareEvent(event, &pl->onButtonPressed.stringAdr, pl->onButtonPressed.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onButtonPressed))(str); - } - else if (compareEvent(event, &pl->onScrollClosed.stringAdr, pl->onScrollClosed.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onScrollClosed))(str); - } - else if (compareEvent(event, &pl->onScrollOpened.stringAdr, pl->onScrollOpened.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onScrollOpened))(str); - } - else if (compareEvent(event, &pl->onUIElementVisible.stringAdr, pl->onUIElementVisible.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onUIElementVisible))(str); - } - else if (compareEvent(event, &pl->onSettlementScrollAdviceRequested.stringAdr, pl->onSettlementScrollAdviceRequested.strCmp)) - { - settlementStruct* sett = reinterpret_cast(vTab[1]); - char* str = reinterpret_cast(vTab[2]); - (*(*pl->onSettlementScrollAdviceRequested))(sett, str); - } - else if (compareEvent(event, &pl->onPreBattleScrollAdviceRequested.stringAdr, pl->onPreBattleScrollAdviceRequested.strCmp)) - { - (*(*pl->onPreBattleScrollAdviceRequested))(); - } - else if (compareEvent(event, &pl->onNavalPreBattleScrollAdviceRequested.stringAdr, pl->onNavalPreBattleScrollAdviceRequested.strCmp)) - { - (*(*pl->onNavalPreBattleScrollAdviceRequested))(); - } - else if (compareEvent(event, &pl->onScrollAdviceRequested.stringAdr, pl->onScrollAdviceRequested.strCmp)) - { - char* str = reinterpret_cast(*vTab[1]); - (*(*pl->onScrollAdviceRequested))(str); - } - else if (compareEvent(event, &pl->onMultiTurnMove.stringAdr, pl->onMultiTurnMove.strCmp)) - { - namedCharacter* prs = reinterpret_cast(vTab[1]); - /*if (prs->gen->armyLeaded) - { - string str = "Mailed Knights"; - - unit* un = FastFuncts::createUnitN((char*)str.c_str()); - - FastFuncts::addUnitToArmy(un, prs->gen->armyLeaded); - }*/ - (*(*pl->onMultiTurnMove))(prs); - } - else if (compareEvent(event, &pl->onCollegeOfCardinalsPanelOpen.stringAdr, pl->onCollegeOfCardinalsPanelOpen.strCmp)) - { - void* colleg = reinterpret_cast(vTab[1]); - (*(*pl->onCollegeOfCardinalsPanelOpen))(colleg); - } - else if (compareEvent(event, &pl->onShortcutTriggered.stringAdr, pl->onShortcutTriggered.strCmp)) - { - char* str = reinterpret_cast(vTab[1]); - (*(*pl->onShortcutTriggered))(str); - } - } } @@ -482,118 +285,6 @@ vector plugins::getAllPlPachs(string* s) return names; } -void plugins::initEvNames() -{ - eventNames = new vector{ - "PreFactionTurnStart", - "FactionTurnStart", - "FactionTurnEnd", - "FactionNewCapital", - "FactionWarDeclared", - "FactionAllianceDeclared", - "FactionTradeAgreementMade", - "FactionBreakAlliance", - "InterFactionMarriage", - "GiveMoney", - "HordeFormed", - "Transgression", - "DishonestTransgression", - "UpdateAttitude", - "Demeanour", - "CharacterSelected", - "GeneralAssaultsResidence", - "GeneralAssaultsGeneral", - "GeneralCaptureResidence", - "GeneralCaptureSettlement", - "SiegeEquipmentCompleted", - "PostBattle", - "SettlementSelected", - "SettlementUpgraded", - "SettlementConverted", - "Insurrection", - "CityRiots", - "GiveSettlement", - "CityRebels", - "UngarrisonedSettlement", - "OccupySettlement", - "SackSettlement", - "ExterminatePopulation", - "CitySacked", - "BuildingCompleted", - "BuildingDestroyed", - "AddedToBuildingQueue", - "GuildUpgraded", - "GuildDestroyed", - "AgentCreated", - "UnitTrained", - "UnitDisbanded", - "AddedToTrainingQueue", - "EventCounter", - "TileSeen", - "ObjSeen", - "CharacterPanelOpen", - "SettlementPanelOpen", - "FinancesPanelOpen", - "FactionSummaryPanelOpen", - "FamilyTreePanelOpen", - "DiplomaticStandingPanelOpen", - "DiplomacyPanelOpen", - "PreBattlePanelOpen", - "RecruitmentPanelOpen", - "ConstructionPanelOpen", - "TradePanelOpen", - "HireMercenariesPanelOpen", - "NavalAutoResolvePanelOpen", - "IncomingMessage", - "MessageOpen", - "MessageClosed", - "RequestBuildingAdvice", - "RequestTrainingAdvice", - "RequestMercenariesAdvice", - "ButtonPressed", - "UIElementVisible", - "ScrollOpened", - "ScrollClosed", - "AdviceSupressed", - "ScrollAdviceRequested", - "PreBattleScrollAdviceRequested", - "NavalPreBattleScrollAdviceRequested", - "SettlementScrollAdviceRequested", - "AbandonShowMe", - "ScriptedAdvice", - "GameReloaded", - "DeclineAuatedSettlementManagement", - "Disaster", - "PopeElected", - "VotedForPope", - "FactionExcommunicated", - "CrusadeCalled", - "CrusadeEnds", - "PopeAcceptsCrusadeTarget", - "PopeRejectsCrusadeTarget", - "UnitsDesertCrusade", - "ArmyTakesCrusadeTarget", - "Forgiveness", - "InquisitorAppointed", - "AssassinCaughtAttackingPope", - "CollegeOfCardinalsPanelOpen", - "MultiTurnMove", - "UngarrisonedFort", - "BrotherAdopted", - "Birth", - "CharacterComesOfAge", - "CharacterMarries", - "CharacterBecomesAFather", - "NewAdmiralCreated", - "ShortcutTriggered", - "CharacterMarriesPrincess", - "BecomesFactionLeader", - "BecomesFactionHeir", - "GeneralDevastatesTile" - }; - -} - int plugin::init(string* nameP) { //set the name of plugin(filename) @@ -618,147 +309,6 @@ int plugin::init(string* nameP) fName = "onEventWrapper"; onEventWrapper.Load(&plPath, &fName); - - //onCharacterSelected - fName = "onCharacterSelected"; - onCharacterSelected.Load(&plPath, &fName); - onCharacterSelected.strCmp = (*plugins::eventNames)[CharacterSelectedCode]; - - //onSettlementSelected - fName = "onSettlementSelected"; - onSettlementSelected.Load(&plPath, &fName); - onSettlementSelected.strCmp = (*plugins::eventNames)[SettlementSelectedCode]; - - //onSettlementPanelOpen - fName = "onSettlementPanelOpen"; - onSettlementPanelOpen.Load(&plPath, &fName); - onSettlementPanelOpen.strCmp = (*plugins::eventNames)[SettlementPanelOpenCode]; - - //onFinancesPanelOpen - fName = "onFinancesPanelOpen"; - onFinancesPanelOpen.Load(&plPath, &fName); - onFinancesPanelOpen.strCmp = (*plugins::eventNames)[FinancesPanelOpenCode]; - - //onFactionSummaryPanelOpen - fName = "onFactionSummaryPanelOpen"; - onFactionSummaryPanelOpen.Load(&plPath, &fName); - onFactionSummaryPanelOpen.strCmp = (*plugins::eventNames)[FactionSummaryPanelOpenCode]; - - //onFamilyTreePanelOpen - fName = "onFamilyTreePanelOpen"; - onFamilyTreePanelOpen.Load(&plPath, &fName); - onFamilyTreePanelOpen.strCmp = (*plugins::eventNames)[FamilyTreePanelOpenCode]; - - //onDiplomaticStandingPanelOpen - fName = "onDiplomaticStandingPanelOpen"; - onDiplomaticStandingPanelOpen.Load(&plPath, &fName); - onDiplomaticStandingPanelOpen.strCmp = (*plugins::eventNames)[DiplomaticStandingPanelOpenCode]; - - //onDiplomacyPanelOpen - fName = "onDiplomacyPanelOpen"; - onDiplomacyPanelOpen.Load(&plPath, &fName); - onDiplomacyPanelOpen.strCmp = (*plugins::eventNames)[DiplomacyPanelOpenCode]; - - //onPreBattlePanelOpen - fName = "onPreBattlePanelOpen"; - onPreBattlePanelOpen.Load(&plPath, &fName); - onPreBattlePanelOpen.strCmp = (*plugins::eventNames)[PreBattlePanelOpenCode]; - - //onNavalAutoResolvePanelOpen - fName = "onNavalAutoResolvePanelOpen"; - onNavalAutoResolvePanelOpen.Load(&plPath, &fName); - onNavalAutoResolvePanelOpen.strCmp = (*plugins::eventNames)[NavalAutoResolvePanelOpenCode]; - - //onCharacterPanelOpen - fName = "onCharacterPanelOpen"; - onCharacterPanelOpen.Load(&plPath, &fName); - onCharacterPanelOpen.strCmp = (*plugins::eventNames)[CharacterPanelOpenCode]; - - //onTradePanelOpen - fName = "onTradePanelOpen"; - onTradePanelOpen.Load(&plPath, &fName); - onTradePanelOpen.strCmp = (*plugins::eventNames)[TradePanelOpenCode]; - - //onRequestBuildingAdvice - fName = "onRequestBuildingAdvice"; - onRequestBuildingAdvice.Load(&plPath, &fName); - onRequestBuildingAdvice.strCmp = (*plugins::eventNames)[RequestBuildingAdviceCode]; - - //onRequestTrainingAdvice - fName = "onRequestTrainingAdvice"; - onRequestTrainingAdvice.Load(&plPath, &fName); - onRequestTrainingAdvice.strCmp = (*plugins::eventNames)[RequestTrainingAdviceCode]; - - //onMessageOpen - fName = "onMessageOpen"; - onMessageOpen.Load(&plPath, &fName); - onMessageOpen.strCmp = (*plugins::eventNames)[MessageOpenCode]; - - //onIncomingMessage - fName = "onIncomingMessage"; - onIncomingMessage.Load(&plPath, &fName); - onIncomingMessage.strCmp = (*plugins::eventNames)[IncomingMessageCode]; - - //onMessageClosed - fName = "onMessageClosed"; - onMessageClosed.Load(&plPath, &fName); - onMessageClosed.strCmp = (*plugins::eventNames)[MessageClosedCode]; - - //onButtonPressed - fName = "onButtonPressed"; - onButtonPressed.Load(&plPath, &fName); - onButtonPressed.strCmp = (*plugins::eventNames)[ButtonPressedCode]; - - //onScrollClosed - fName = "onScrollClosed"; - onScrollClosed.Load(&plPath, &fName); - onScrollClosed.strCmp = (*plugins::eventNames)[ScrollClosedCode]; - - //onScrollOpened - fName = "onScrollOpened"; - onScrollOpened.Load(&plPath, &fName); - onScrollOpened.strCmp = (*plugins::eventNames)[ScrollOpenedCode]; - - //onUIElementVisible - fName = "onUIElementVisible"; - onUIElementVisible.Load(&plPath, &fName); - onUIElementVisible.strCmp = (*plugins::eventNames)[UIElementVisibleCode]; - - //onSettlementScrollAdviceRequested - fName = "onSettlementScrollAdviceRequested"; - onSettlementScrollAdviceRequested.Load(&plPath, &fName); - onSettlementScrollAdviceRequested.strCmp = (*plugins::eventNames)[SettlementScrollAdviceRequestedCode]; - - //onPreBattleScrollAdviceRequested - fName = "onPreBattleScrollAdviceRequested"; - onPreBattleScrollAdviceRequested.Load(&plPath, &fName); - onPreBattleScrollAdviceRequested.strCmp = (*plugins::eventNames)[PreBattleScrollAdviceRequestedCode]; - - //onNavalPreBattleScrollAdviceRequested - fName = "onNavalPreBattleScrollAdviceRequested"; - onNavalPreBattleScrollAdviceRequested.Load(&plPath, &fName); - onNavalPreBattleScrollAdviceRequested.strCmp = (*plugins::eventNames)[NavalPreBattleScrollAdviceRequestedCode]; - - //onScrollAdviceRequested - fName = "onScrollAdviceRequested"; - onScrollAdviceRequested.Load(&plPath, &fName); - onScrollAdviceRequested.strCmp = (*plugins::eventNames)[ScrollAdviceRequestedCode]; - - //onMultiTurnMove - fName = "onMultiTurnMove"; - onMultiTurnMove.Load(&plPath, &fName); - onMultiTurnMove.strCmp = (*plugins::eventNames)[MultiTurnMoveCode]; - - //onCollegeOfCardinalsPanelOpen - fName = "onCollegeOfCardinalsPanelOpen"; - onCollegeOfCardinalsPanelOpen.Load(&plPath, &fName); - onCollegeOfCardinalsPanelOpen.strCmp = (*plugins::eventNames)[CollegeOfCardinalsPanelOpenCode]; - - //onShortcutTriggered - fName = "onShortcutTriggered"; - onShortcutTriggered.Load(&plPath, &fName); - onShortcutTriggered.strCmp = (*plugins::eventNames)[ShortcutTriggeredCode]; - //drawOnEndScene fName = "drawOnEndScene"; drawOnEndScene.Load(&plPath, &fName); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.h b/M2TWEOP Code/M2TWEOP library/plugins.h index 4d68f99b2..ec3dbbe94 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.h +++ b/M2TWEOP Code/M2TWEOP library/plugins.h @@ -88,44 +88,6 @@ class plugin ProcLoader onEventWrapper; - ProcLoader onCharacterSelected; - ProcLoader onMultiTurnMove; - - ProcLoader onSettlementSelected; - - - ProcLoader onSettlementPanelOpen; - ProcLoader onFinancesPanelOpen; - ProcLoader onFactionSummaryPanelOpen; - ProcLoader onFamilyTreePanelOpen; - ProcLoader onDiplomaticStandingPanelOpen; - ProcLoader onDiplomacyPanelOpen; - ProcLoader onPreBattlePanelOpen; - ProcLoader onNavalAutoResolvePanelOpen; - - ProcLoader onCharacterPanelOpen; - ProcLoader onTradePanelOpen; - ProcLoader onRequestBuildingAdvice; - ProcLoader onRequestTrainingAdvice; - - ProcLoader onMessageOpen; - ProcLoader onIncomingMessage; - ProcLoader onMessageClosed; - - ProcLoader onButtonPressed; - ProcLoader onScrollClosed; - ProcLoader onScrollOpened; - ProcLoader onUIElementVisible; - ProcLoader onScrollAdviceRequested; - - ProcLoader onSettlementScrollAdviceRequested; - - ProcLoader onPreBattleScrollAdviceRequested; - ProcLoader onNavalPreBattleScrollAdviceRequested; - ProcLoader onCollegeOfCardinalsPanelOpen; - - ProcLoader onShortcutTriggered; - ProcLoader drawOnEndScene; ProcLoader onReset; ProcLoader onLoadingFonts; @@ -181,8 +143,6 @@ class plugins static void onLoadingFonts(LPDIRECT3DDEVICE9 pDevice); static void onChangeImGuiCtx(ImGuiContext* imCtx, ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data); - - static vector* eventNames; private: static int compareEvent(const char* event, char** adr1, const char* adr2); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index dd1da9a93..9c5668996 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -170,6 +170,12 @@ namespace gameEvents newCode[0] = 0x01370474; newCode[1] = 0x0132B44C; addEvent(newCode[gv], "onEnemyCharacterSelected"); + newCode[0] = 0x0137060C; newCode[1] = 0x0132B5E4; + addEvent(newCode[gv], "onMultiTurnMove"); + + newCode[0] = 0x013714F4; newCode[1] = 0x0132C4CC; + addEvent(newCode[gv], "onCharacterPanelOpen"); + //ransomEvent newCode[0] = 0x0136C8EC; newCode[1] = 0x013278C4; addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptor"); @@ -289,6 +295,18 @@ namespace gameEvents addEvent(newCode[gv], "onSiegeEquipmentCompleted"); newCode[0] = 0x0136FADC; newCode[1] = 0x0132AAB4; addEvent(newCode[gv], "onSettlementTurnEnd"); + newCode[0] = 0x01370544; newCode[1] = 0x0132B51C; + addEvent(newCode[gv], "onSettlementSelected"); + newCode[0] = 0x013706EC; newCode[1] = 0x0132B6C4; + addEvent(newCode[gv], "onSettlementPanelOpen"); + newCode[0] = 0x01370C04; newCode[1] = 0x0132BBDC; + addEvent(newCode[gv], "onRecruitmentPanelOpen"); + newCode[0] = 0x0132BCAC; newCode[1] = 0x0132BBDC; + addEvent(newCode[gv], "onConstructionPanelOpen"); + newCode[0] = 0x01370D9C; newCode[1] = 0x0132BD74; + addEvent(newCode[gv], "onTradePanelOpen"); + newCode[0] = 0x01371264; newCode[1] = 0x0132C23C; + addEvent(newCode[gv], "onSettlementScrollAdviceRequested"); //guildEvents newCode[0] = 0x0136F88C; newCode[1] = 0x0132A864; @@ -340,6 +358,24 @@ namespace gameEvents newCode[0] = 0x01368E5C; newCode[1] = 0x01323E34; addEvent(newCode[gv], "onBattleArmyHalfDestroyed"); + newCode[0] = 0x0139622C; newCode[1] = 0x013511FC; + addEvent(newCode[gv], "onEscPressed"); + + newCode[0] = 0x0139552C; newCode[1] = 0x013504FC; + addEvent(newCode[gv], "onScriptedAdvice"); + + newCode[0] = 0x013DB05C; newCode[1] = 0x01395DF4; + addEvent(newCode[gv], "onNavalPreBattleScrollAdviceRequested"); + + newCode[0] = 0x013DB114; newCode[1] = 0x01395EAC; + addEvent(newCode[gv], "onPreBattleScrollAdviceRequested"); + + newCode[0] = 0x013D9004; newCode[1] = 0x01393D9C; + addEvent(newCode[gv], "onCollegeOfCardinalsPanelOpen"); + + newCode[0] = 0x013D2074; newCode[1] = 0x0138CE0C; + addEvent(newCode[gv], "onDiplomaticStandingPanelOpen"); + //crusadeEvents newCode[0] = 0x013321D4; newCode[1] = 0x012ED1B4; addEvent(newCode[gv], "onCrusadeCalled"); @@ -411,6 +447,33 @@ namespace gameEvents newCode[0] = 0x0136D0BC; newCode[1] = 0x01328094; addEvent(newCode[gv], "onAssassinCaughtAttackingPope"); + newCode[0] = 0x013707BC; newCode[1] = 0x0132B794; + addEvent(newCode[gv], "onFinancesPanelOpen"); + + newCode[0] = 0x0137088C; newCode[1] = 0x0132B864; + addEvent(newCode[gv], "onFactionSummaryPanelOpen"); + + newCode[0] = 0x0137095C; newCode[1] = 0x0132B934; + addEvent(newCode[gv], "onFamilyTreePanelOpen"); + + newCode[0] = 0x01370A64; newCode[1] = 0x0132BA3C; + addEvent(newCode[gv], "onDiplomacyPanelOpen"); + + newCode[0] = 0x01370B34; newCode[1] = 0x0132BB0C; + addEvent(newCode[gv], "onPreBattlePanelOpen"); + + newCode[0] = 0x01370E9C; newCode[1] = 0x0132BE74; + addEvent(newCode[gv], "onIncomingMessage"); + + newCode[0] = 0x01370F64; newCode[1] = 0x0132BF3C; + addEvent(newCode[gv], "onMessageOpen"); + + newCode[0] = 0x0137102C; newCode[1] = 0x0132C004; + addEvent(newCode[gv], "onMessageClosed"); + + newCode[0] = 0x01371364; newCode[1] = 0x0132C33C; + addEvent(newCode[gv], "onDeclineAutomatedSettlementManagement"); + //diplomacyEvents newCode[0] = 0x0136958C; newCode[1] = 0x01324564; newCode[0] = 0x0136958C; newCode[1] = 0x01324564; @@ -448,6 +511,9 @@ namespace gameEvents newCode[0] = 0x0136886C; newCode[1] = 0x01323844; addEvent(newCode[gv], "onBattleReinforcementsArrive"); + newCode[0] = 0x0137171C; newCode[1] = 0x0132C6F4; + addEvent(newCode[gv], "onRequestMercenariesAdvice"); + //characterEvent newCode[0] = 0x013687B4; newCode[1] = 0x0132378C; addEvent(newCode[gv], "onBattleGeneralRouted"); @@ -484,6 +550,12 @@ namespace gameEvents newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; addEvent(newCode[gv], "onBuildingCompleted"); + newCode[0] = 0x013715AC; newCode[1] = 0x0132C584; + addEvent(newCode[gv], "onRequestBuildingAdvice"); + + newCode[0] = 0x01371664; newCode[1] = 0x0132C63C; + addEvent(newCode[gv], "onRequestTrainingAdvice"); + //agentCreatedEvent newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; addEvent(newCode[gv], "onAgentCreated"); @@ -573,6 +645,22 @@ namespace gameEvents newCode[0] = 0x0136AC04; newCode[1] = 0x01325BDC; addEvent(newCode[gv], "onUngarrisonedFort"); + //uiEvents + newCode[0] = 0x013717D4; newCode[1] = 0x0132C7AC; + addEvent(newCode[gv], "onButtonPressed"); + newCode[0] = 0x0137188C; newCode[1] = 0x0132C864; + addEvent(newCode[gv], "onShortcutTriggered"); + newCode[0] = 0x01371944; newCode[1] = 0x0132C91C; + addEvent(newCode[gv], "onUIElementVisible"); + newCode[0] = 0x013719FC; newCode[1] = 0x0132C9D4; + addEvent(newCode[gv], "onScrollOpened"); + newCode[0] = 0x01371AB4; newCode[1] = 0x0132CA8C; + addEvent(newCode[gv], "onScrollClosed"); + newCode[0] = 0x01371B6C; newCode[1] = 0x0132CB44; + addEvent(newCode[gv], "onScrollAdviceRequested"); + newCode[0] = 0x01371144; newCode[1] = 0x0132C11C; + addEvent(newCode[gv], "onAdviceSupressed"); + //tileEvents newCode[0] = 0x0136ACCC; newCode[1] = 0x01325CA4; addEvent(newCode[gv], "onTileSeen"); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index dad15974f..d8fdda4c6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -117,7 +117,8 @@ namespace gameEvents targetSettlementEvent = 46, namedCharacterRiotEvents = 47, settOccupationEvent = 48, - guildEvent = 49 + guildEvent = 49, + uiEvent = 50 }; class EventBase @@ -709,18 +710,27 @@ namespace gameEvents else if (EvType == EventType::settlementEvent) { auto settlement = reinterpret_cast(vTab[1]); - factionStruct* faction; + fortStruct* fort; + factionStruct* faction = settlement->faction; + regionStruct* region = gameHelpers::getRegion(settlement->regionID); + bool isFort = false; if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) { - settlement = reinterpret_cast(vTab[1]); + fort = (*(*plugData::data.funcs.findFort))(settlement->xCoord, settlement->yCoord) + isFort = true; + faction = fort->faction; + region = gameHelpers::getRegion(fort->regionID); } - factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { - - (*funk)(settlement, faction, region, religion); - + if (!isFort) + { + (*funk)(settlement, faction, region, religion); + } + else + { + (*funk)(fort, faction, region, religion); + } } return 40; } @@ -843,7 +853,17 @@ namespace gameEvents } return 49; + } + else if (EvType == EventType::uiEvent) + { + auto name = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + + (*funk)(name); + } + return 50; + } else { return 0; @@ -1028,6 +1048,37 @@ sol::function* onSettlementTurnEnd = nullptr; sol::function* onBuildingCompleted = nullptr; sol::function* onCharacterSelected = nullptr; sol::function* onEnemyCharacterSelected = nullptr; - -extern "C" PLUGINM2TWEOP_API void onCharacterSelected(namedCharacter * gen); +sol::function* onSettlementSelected = nullptr; +sol::function* onMultiTurnMove = nullptr; +sol::function* onSettlementPanelOpen = nullptr; +sol::function* onFinancesPanelOpen = nullptr; +sol::function* onFactionSummaryPanelOpen = nullptr; +sol::function* onFamilyTreePanelOpen = nullptr; +sol::function* onDiplomacyPanelOpen = nullptr; +sol::function* onPreBattlePanelOpen = nullptr; +sol::function* onRecruitmentPanelOpen = nullptr; +sol::function* onConstructionPanelOpen = nullptr; +sol::function* onTradePanelOpen = nullptr; +sol::function* onIncomingMessage = nullptr; +sol::function* onMessageOpen = nullptr; +sol::function* onMessageClosed = nullptr; +sol::function* onAdviceSupressed = nullptr; +sol::function* onSettlementScrollAdviceRequested = nullptr; +sol::function* onDeclineAutomatedSettlementManagement = nullptr; +sol::function* onCharacterPanelOpen = nullptr; +sol::function* onRequestBuildingAdvice = nullptr; +sol::function* onRequestTrainingAdvice = nullptr; +sol::function* onRequestMercenariesAdvice = nullptr; +sol::function* onButtonPressed = nullptr; +sol::function* onShortcutTriggered = nullptr; +sol::function* onUIElementVisible = nullptr; +sol::function* onScrollOpened = nullptr; +sol::function* onScrollClosed = nullptr; +sol::function* onScrollAdviceRequested = nullptr; +sol::function* onEscPressed = nullptr; +sol::function* onScriptedAdvice = nullptr; +sol::function* onNavalPreBattleScrollAdviceRequested = nullptr; +sol::function* onPreBattleScrollAdviceRequested = nullptr; +sol::function* onCollegeOfCardinalsPanelOpen = nullptr; +sol::function* onDiplomaticStandingPanelOpen = nullptr; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index 8c61c2c38..71bc09fbe 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -15,60 +15,195 @@ void luaP::onPluginLoadF() Events functions list. Just list, use it without EventsFunctionsList.!!! - @tfield draw draw - @tfield onLoadingFonts onLoadingFonts - @tfield onReadGameDbsAtStart onReadGameDbsAtStart - @tfield onClickAtTile onClickAtTile - @tfield onNewGameStart onNewGameStart - @tfield onCampaignMapLoaded onCampaignMapLoaded - @tfield onCreateSaveFile onCreateSaveFile - @tfield onLoadSaveFile onLoadSaveFile - @tfield onPluginLoad onPluginLoad - @tfield onEndSiege onEndSiege - @tfield onStartSiege onStartSiege - @tfield onSelectWorldpkgdesc onSelectWorldpkgdesc - @tfield onChangeTurnNum onChangeTurnNum - @tfield onCharacterTurnStart onCharacterTurnStart @tfield onCapturedCharacterRansomed onCapturedCharacterRansomed @tfield onCapturedCharacterReleased onCapturedCharacterReleased + @tfield onFatherDiesNatural onFatherDiesNatural @tfield onPreBattleWithdrawal onPreBattleWithdrawal + @tfield onPostBattle onPostBattle @tfield onHireMercenaries onHireMercenaries + @tfield onGeneralCaptureResidence onGeneralCaptureResidence + @tfield onLeaderDestroyedFaction onLeaderDestroyedFaction @tfield onOfferedForAdoption onOfferedForAdoption @tfield onLesserGeneralOfferedForAdoption onLesserGeneralOfferedForAdoption @tfield onOfferedForMarriage onOfferedForMarriage + @tfield onBrotherAdopted onBrotherAdopted + @tfield onBirth onBirth + @tfield onCharacterComesOfAge onCharacterComesOfAge + @tfield onCharacterMarries onCharacterMarries + @tfield onCharacterMarriesPrincess onCharacterMarriesPrincess + @tfield onMarriageAlliancePossible onMarriageAlliancePossible + @tfield onMarriageAllianceOffered onMarriageAllianceOffered + @tfield onPriestBecomesHeretic onPriestBecomesHeretic + @tfield onCharacterNearHeretic onCharacterNearHeretic + @tfield onCharacterNearWitch onCharacterNearWitch + @tfield onCardinalPromoted onCardinalPromoted + @tfield onCharacterBecomesAFather onCharacterBecomesAFather + @tfield onGeneralDevastatesTile onGeneralDevastatesTile + @tfield onExecutesASpyOnAMission onExecutesASpyOnAMission + @tfield onExecutesAnAssassinOnAMission onExecutesAnAssassinOnAMission + @tfield onSufferAssassinationAttempt onSufferAssassinationAttempt + @tfield onSufferAcquisitionAttempt onSufferAcquisitionAttempt + @tfield onSufferMarriageAttempt onSufferMarriageAttempt + @tfield onSufferDenouncementAttempt onSufferDenouncementAttempt + @tfield onLeaderOrderedSabotage onLeaderOrderedSabotage + @tfield onAcceptBribe onAcceptBribe + @tfield onRefuseBribe onRefuseBribe + @tfield onInsurrection onInsurrection + @tfield onLeaderOrderedDiplomacy onLeaderOrderedDiplomacy + @tfield onNewAdmiralCreated onNewAdmiralCreated + @tfield onGovernorBuildingDestroyed onGovernorBuildingDestroyed + @tfield onGovernorThrowGames onGovernorThrowGames + @tfield onGovernorThrowRaces onGovernorThrowRaces + @tfield onCharacterSelected onCharacterSelected + @tfield onEnemyCharacterSelected onEnemyCharacterSelected + @tfield onMultiTurnMove onMultiTurnMove + @tfield onCharacterPanelOpen onCharacterPanelOpen + @tfield onLeaderMissionSuccess onLeaderMissionSuccess + @tfield onLeaderMissionFailed onLeaderMissionFailed + @tfield onGeneralJoinCrusade onGeneralJoinCrusade + @tfield onGeneralAbandonCrusade onGeneralAbandonCrusade + @tfield onGeneralArrivesCrusadeTargetRegion onGeneralArrivesCrusadeTargetRegion + @tfield onGeneralTakesCrusadeTarget onGeneralTakesCrusadeTarget + @tfield onCharacterTurnEnd onCharacterTurnEnd + @tfield onCharacterTurnEndInSettlement onCharacterTurnEndInSettlement + @tfield onBecomesFactionLeader onBecomesFactionLeader + @tfield onCeasedFactionLeader onCeasedFactionLeader + @tfield onBecomesFactionHeir onBecomesFactionHeir + @tfield onCeasedFactionHeir onCeasedFactionHeir @tfield onCharacterDamagedByDisaster onCharacterDamagedByDisaster + @tfield onGeneralCaptureSettlement onGeneralCaptureSettlement + @tfield onGeneralAssaultsResidence onGeneralAssaultsResidence + @tfield onGeneralAssaultsGeneral onGeneralAssaultsGeneral + @tfield onCharacterAttacksCrusadingGeneral onCharacterAttacksCrusadingGeneral + @tfield onGeneralPrisonersRansomedCaptor onGeneralPrisonersRansomedCaptor + @tfield onGeneralPrisonersRansomedCaptive onGeneralPrisonersRansomedCaptive + @tfield onFactionLeaderPrisonersRansomedCaptor onFactionLeaderPrisonersRansomedCaptor + @tfield onFactionLeaderPrisonersRansomedCaptive onFactionLeaderPrisonersRansomedCaptive + @tfield onSpyMission onSpyMission + @tfield onAssassinationMission onAssassinationMission + @tfield onAcquisitionMission onAcquisitionMission + @tfield onMarriageMission onMarriageMission + @tfield onDenouncementMission onDenouncementMission + @tfield onSabotageMission onSabotageMission + @tfield onBriberyMission onBriberyMission + @tfield onDiplomacyMission onDiplomacyMission + @tfield onLeaderOrderedSpyingMission onLeaderOrderedSpyingMission + @tfield onLeaderOrderedAssassination onLeaderOrderedAssassination + @tfield onLeaderOrderedBribery onLeaderOrderedBribery + @tfield onSettlementTurnStart onSettlementTurnStart + @tfield onUngarrisonedSettlement onUngarrisonedSettlement + @tfield onSettlementUpgraded onSettlementUpgraded + @tfield onSettlementConverted onSettlementConverted + @tfield onSiegeEquipmentCompleted onSiegeEquipmentCompleted + @tfield onSettlementTurnEnd onSettlementTurnEnd + @tfield onSettlementSelected onSettlementSelected + @tfield onSettlementPanelOpen onSettlementPanelOpen + @tfield onRecruitmentPanelOpen onRecruitmentPanelOpen + @tfield onConstructionPanelOpen onConstructionPanelOpen + @tfield onTradePanelOpen onTradePanelOpen + @tfield onSettlementScrollAdviceRequested onSettlementScrollAdviceRequested + @tfield onGuildUpgraded onGuildUpgraded + @tfield onGuildDestroyed onGuildDestroyed + @tfield onOccupySettlement onOccupySettlement + @tfield onSackSettlement onSackSettlement + @tfield onExterminatePopulation onExterminatePopulation + @tfield onCityRiots onCityRiots + @tfield onGiveSettlement onGiveSettlement + @tfield onCityRebels onCityRebels + @tfield onCitySacked onCitySacked + @tfield onGovernorCityRiots onGovernorCityRiots + @tfield onGovernorCityRebels onGovernorCityRebels @tfield onAbandonShowMe onAbandonShowMe + @tfield onGameReloaded onGameReloaded @tfield onBattleWinningPlaza onBattleWinningPlaza @tfield onBattleStopsWinningPlaza onBattleStopsWinningPlaza @tfield onBattleDominatingPlaza onBattleDominatingPlaza @tfield onBattngineUnmanned onBattngineUnmanned @tfield onBattlePlayerArmyHalfDestroyed onBattlePlayerArmyHalfDestroyed @tfield onBattnemyArmyHalfDestroyed onBattnemyArmyHalfDestroyed - @tfield onBattleTideofBattle onBattleTideofBattle @tfield onBattleFinished onBattleFinished @tfield onBattleArmyHalfDestroyed onBattleArmyHalfDestroyed - @tfield onBattleAiCommenced onBattleAiCommenced - @tfield onBattleDelayPhaseCommenced onBattleDelayPhaseCommenced - @tfield onBattleDeploymentPhaseCommenced onBattleDeploymentPhaseCommenced - @tfield onBattleConflictPhaseCommenced onBattleConflictPhaseCommenced - @tfield onInterFactionMarriage onInterFactionMarriage - @tfield onBattleArmyRouted onBattleArmyRouted - @tfield onBattleReinforcementsArrive onBattleReinforcementsArrive - @tfield onBattleGeneralRouted onBattleGeneralRouted - @tfield onBattleGeneralKilled onBattleGeneralKilled + @tfield onEscPressed onEscPressed + @tfield onScriptedAdvice onScriptedAdvice + @tfield onNavalPreBattleScrollAdviceRequested onNavalPreBattleScrollAdviceRequested + @tfield onPreBattleScrollAdviceRequested onPreBattleScrollAdviceRequested + @tfield onCollegeOfCardinalsPanelOpen onCollegeOfCardinalsPanelOpen + @tfield onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen + @tfield onBattlePlayerUnderAttackIdle onBattlePlayerUnderAttackIdle + @tfield onBattleWinningCombat onBattleWinningCombat + @tfield onBattleArmyTired onBattleArmyTired + @tfield onBattleTideofBattle onBattleTideofBattle @tfield onBattleUnitGoesBerserk onBattleUnitGoesBerserk @tfield onBattleSiegeEngineDestroyed onBattleSiegeEngineDestroyed @tfield onBattleSiegeEngineDocksWall onBattleSiegeEngineDocksWall @tfield onBattleGatesAttackedByEngine onBattleGatesAttackedByEngine @tfield onBattleGatesDestroyedByEngine onBattleGatesDestroyedByEngine @tfield onBattleWallsBreachedByEngine onBattleWallsBreachedByEngine - @tfield onBattleUnitRouts onBattleUnitRouts @tfield onBattleWallsCaptured onBattleWallsCaptured - @tfield onBattlePlayerUnderAttackIdle onBattlePlayerUnderAttackIdle - @tfield onBattleWinningCombat onBattleWinningCombat - @tfield onBattleArmyTired onBattleArmyTired + @tfield onBattleUnitRouts onBattleUnitRouts + @tfield onUnitDisbanded onUnitDisbanded + @tfield onUnitTrained onUnitTrained + @tfield onGovernorUnitTrained onGovernorUnitTrained + @tfield onGovernorBuildingCompleted onGovernorBuildingCompleted + @tfield onAgentCreated onAgentCreated + @tfield onGovernorAgentCreated onGovernorAgentCreated + @tfield onBuildingDestroyed onBuildingDestroyed + @tfield onAddedToBuildingQueue onAddedToBuildingQueue + @tfield onBuildingCompleted onBuildingCompleted + @tfield onRequestBuildingAdvice onRequestBuildingAdvice + @tfield onRequestTrainingAdvice onRequestTrainingAdvice + @tfield onAddedToTrainingQueue onAddedToTrainingQueue + @tfield onBattleArmyRouted onBattleArmyRouted + @tfield onBattleReinforcementsArrive onBattleReinforcementsArrive + @tfield onRequestMercenariesAdvice onRequestMercenariesAdvice + @tfield onButtonPressed onButtonPressed + @tfield onShortcutTriggered onShortcutTriggered + @tfield onUIElementVisible onUIElementVisible + @tfield onScrollOpened onScrollOpened + @tfield onScrollClosed onScrollClosed + @tfield onScrollAdviceRequested onScrollAdviceRequested + @tfield onAdviceSupressed onAdviceSupressed + @tfield onBattleGeneralRouted onBattleGeneralRouted + @tfield onBattleGeneralKilled onBattleGeneralKilled + @tfield onCrusadeCalled onCrusadeCalled + @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget + @tfield onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget + @tfield onCrusadeEnds onCrusadeEnds + @tfield onPreFactionTurnStart onPreFactionTurnStart + @tfield onFactionTurnStart onFactionTurnStart + @tfield onFactionNewCapital onFactionNewCapital + @tfield onFactionTurnEnd onFactionTurnEnd + @tfield onVotedForPope onVotedForPope + @tfield onFactionExcommunicated onFactionExcommunicated + @tfield onHordeFormed onHordeFormed + @tfield onCardinalRemoved onCardinalRemoved + @tfield onInquisitorAppointed onInquisitorAppointed + @tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope + @tfield onFinancesPanelOpen onFinancesPanelOpen + @tfield onFactionSummaryPanelOpen onFactionSummaryPanelOpen + @tfield onFamilyTreePanelOpen onFamilyTreePanelOpen + @tfield onDiplomacyPanelOpen onDiplomacyPanelOpen + @tfield onPreBattlePanelOpen onPreBattlePanelOpen + @tfield onIncomingMessage onIncomingMessage + @tfield onMessageOpen onMessageOpen + @tfield onMessageClosed onMessageClosed + @tfield onDeclineAutomatedSettlementManagement onDeclineAutomatedSettlementManagement + @tfield onBattleAiCommenced onBattleAiCommenced + @tfield onBattleDelayPhaseCommenced onBattleDelayPhaseCommenced + @tfield onBattleDeploymentPhaseCommenced onBattleDeploymentPhaseCommenced + @tfield onBattleConflictPhaseCommenced onBattleConflictPhaseCommenced + @tfield onFactionWarDeclared onFactionWarDeclared + @tfield onFactionAllianceDeclared onFactionAllianceDeclared + @tfield onInterFactionMarriage onInterFactionMarriage + @tfield onFactionTradeAgreementMade onFactionTradeAgreementMade + @tfield onPopeElected onPopeElected + @tfield onFactionBreakAlliance onFactionBreakAlliance + @tfield onUpdateAttitude onUpdateAttitude + @tfield onDemeanour onDemeanour + @tfield onGiveMoney onGiveMoney @tfield onBattlePlayerUnitAttacksEnemyUnit onBattlePlayerUnitAttacksEnemyUnit + @tfield onBattleEnemyUnitAttacksPlayerUnit onBattleEnemyUnitAttacksPlayerUnit @tfield onBattlePlayerUnitGoesBerserk onBattlePlayerUnitGoesBerserk @tfield onBattlePlayerUnitRouts onBattlePlayerUnitRouts @tfield onBattlePlayerSiegeEngineDestroyed onBattlePlayerSiegeEngineDestroyed @@ -79,99 +214,27 @@ void luaP::onPluginLoadF() @tfield onBattleGatesAttackedByEnemyEngine onBattleGatesAttackedByEnemyEngine @tfield onDisaster onDisaster @tfield onEventCounter onEventCounter - @tfield onFatherDiesNatural onFatherDiesNatural - - @tfield onCharacterSelected onCharacterSelected - @tfield onPreFactionTurnStart onPreFactionTurnStart - @tfield onFactionTurnStart onFactionTurnStart - @tfield onFactionTurnEnd onFactionTurnEnd - @tfield onFactionNewCapital onFactionNewCapital - @tfield onFactionWarDeclared onFactionWarDeclared - @tfield onFactionAllianceDeclared onFactionAllianceDeclared - @tfield onFactionTradeAgreementMade onFactionTradeAgreementMade - @tfield onFactionBreakAlliance onFactionBreakAlliance - @tfield onGiveMoney onGiveMoney - @tfield onUpdateAttitude onUpdateAttitude - @tfield onDemeanour onDemeanour - @tfield onGeneralAssaultsGeneral onGeneralAssaultsGeneral - @tfield onGeneralAssaultsResidence onGeneralAssaultsResidence - @tfield onGeneralCaptureSettlement onGeneralCaptureSettlement - @tfield onGeneralCaptureResidence onGeneralCaptureResidence - @tfield onSiegeEquipmentCompleted onSiegeEquipmentCompleted - @tfield onPostBattle onPostBattle - @tfield onMultiTurnMove onMultiTurnMove - @tfield onSettlementSelected onSettlementSelected - @tfield onSettlementUpgraded onSettlementUpgraded - @tfield onSettlementConverted onSettlementConverted - @tfield onCityRiots onCityRiots - @tfield onUngarrisonedSettlement onUngarrisonedSettlement @tfield onUngarrisonedFort onUngarrisonedFort - @tfield onGiveSettlement onGiveSettlement - @tfield onOccupySettlement onOccupySettlement - @tfield onExterminatePopulation onExterminatePopulation - @tfield onSackSettlement onSackSettlement - @tfield onAddedToBuildingQueue onAddedToBuildingQueue - @tfield onBuildingDestroyed onBuildingDestroyed - @tfield onBuildingCompleted onBuildingCompleted - @tfield onEventCounter onEventCounter - @tfield onFactionExcommunicated onFactionExcommunicated - @tfield onDisaster onDisaster - @tfield onHordeFormed onHordeFormed - @tfield onAddedToTrainingQueue onAddedToTrainingQueue - @tfield onUnitDisbanded onUnitDisbanded - @tfield onUnitTrained onUnitTrained - @tfield onAgentCreated onAgentCreated @tfield onObjSeen onObjSeen @tfield onTileSeen onTileSeen - @tfield onGameReloaded onGameReloaded @tfield onTransgression onTransgression - @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget - @tfield onCrusadeCalled onCrusadeCalled - @tfield onCrusadeEnds onCrusadeEnds - @tfield onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget + @tfield onForgiveness onForgiveness @tfield onArmyTakesCrusadeTarget onArmyTakesCrusadeTarget @tfield onUnitsDesertCrusade onUnitsDesertCrusade - @tfield onPopeElected onPopeElected - @tfield onVotedForPope onVotedForPope - @tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope - @tfield onInquisitorAppointed onInquisitorAppointed - @tfield onSettlementPanelOpen onSettlementPanelOpen - @tfield onFinancesPanelOpen onFinancesPanelOpen - @tfield onFactionSummaryPanelOpen onFactionSummaryPanelOpen - @tfield onFamilyTreePanelOpenFunc onFamilyTreePanelOpenFunc - @tfield onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen - @tfield onDiplomacyPanelOpen onDiplomacyPanelOpen - @tfield onPreBattlePanelOpen onPreBattlePanelOpen - @tfield onNavalAutoResolvePanelOpen onNavalAutoResolvePanelOpen - @tfield onCharacterPanelOpen onCharacterPanelOpen - @tfield onTradePanelOpen onTradePanelOpen - @tfield onRequestBuildingAdvice onRequestBuildingAdvice - @tfield onRequestTrainingAdvice onRequestTrainingAdvice - @tfield onMessageOpen onMessageOpen - @tfield onIncomingMessage onIncomingMessage - @tfield onMessageClosed onMessageClosed - @tfield onButtonPressed onButtonPressed - @tfield onScrollClosed onScrollClosed - @tfield onScrollOpened onScrollOpened - @tfield onUIElementVisible onUIElementVisible - @tfield onScrollAdviceRequested onScrollAdviceRequested - @tfield onSettlementScrollAdviceRequested onSettlementScrollAdviceRequested - @tfield onPreBattleScrollAdviceRequested onPreBattleScrollAdviceRequested - @tfield onNavalPreBattleScrollAdviceRequested onNavalPreBattleScrollAdviceRequested - @tfield onCollegeOfCardinalsPanelOpen onCollegeOfCardinalsPanelOpen - @tfield onGuildUpgraded onGuildUpgraded - @tfield onGuildDestroyed onGuildDestroyed - @tfield onBrotherAdopted onBrotherAdopted - @tfield onBirth onBirth - @tfield onCharacterComesOfAge onCharacterComesOfAge - @tfield onCharacterMarries onCharacterMarries - @tfield onCharacterMarriesPrincess onCharacterMarriesPrincess - @tfield onCharacterBecomesAFather onCharacterBecomesAFather - @tfield onNewAdmiralCreated onNewAdmiralCreated - @tfield onShortcutTriggered onShortcutTriggered - @tfield onBecomesFactionLeader onBecomesFactionLeader - @tfield onBecomesFactionHeir onBecomesFactionHeir - @tfield onGeneralDevastatesTile onGeneralDevastatesTile + @tfield draw draw + @tfield onLoadingFonts onLoadingFonts + @tfield onNewGameStart onNewGameStart + @tfield onReadGameDbsAtStart onReadGameDbsAtStart + @tfield onClickAtTile onClickAtTile + @tfield onCampaignMapLoaded onCampaignMapLoaded + @tfield onCreateSaveFile onCreateSaveFile + @tfield onLoadSaveFile onLoadSaveFile + @tfield onChangeTurnNum onChangeTurnNum + @tfield onSelectWorldpkgdesc onSelectWorldpkgdesc + @tfield onfortificationlevelS onfortificationlevelS + @tfield onEndSiege onEndSiege + @tfield onStartSiege onStartSiege + @tfield onPluginLoad onPluginLoad @@ -407,7 +470,7 @@ void luaP::onPluginLoadF() /*** A character has come of age. - @function CharacterComesOfAge + @function onCharacterComesOfAge @tparam namedCharacter namedChar @tparam factionStruct faction @tparam regionStruct|nil region @@ -415,7 +478,7 @@ void luaP::onPluginLoadF() @tparam string religion @usage - function CharacterComesOfAge(namedChar, faction, region, characterType, religion) + function onCharacterComesOfAge(namedChar, faction, region, characterType, religion) --something end */ @@ -852,6 +915,38 @@ void luaP::onPluginLoadF() end */ + /*** + The player has selected a position beyond the character's extents. + + @function onMultiTurnMove + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct region + @tparam string characterType + @tparam string religion + + @usage + function onMultiTurnMove(namedChar, faction, region, characterType, religion) + --something + end + */ + + /*** + The player has opened the panel for the selected character. + + @function onCharacterPanelOpen + @tparam namedCharacter namedChar + @tparam factionStruct faction + @tparam regionStruct|nil region + @tparam string characterType + @tparam string religion + + @usage + function onCharacterPanelOpen(namedChar, faction, region, characterType, religion) + --something + end + */ + /*** A mission has been completed. @@ -1531,17 +1626,107 @@ void luaP::onPluginLoadF() */ /*** - A guild has been created/upgraded. + The player has selected a settlement. - @function onGuildUpgraded + @function onSettlementSelected @tparam settlementStruct settlement @tparam factionStruct faction @tparam regionStruct region @tparam string religion - @tparam guild guild @usage - function onGuildUpgraded(settlement, faction, region, religion, guild) + function onSettlementSelected(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has opened the panel for the selected settlement. + + @function onSettlementPanelOpen + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementPanelOpen(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has opened a recruitment panel. + + @function onRecruitmentPanelOpen + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onRecruitmentPanelOpen(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has opened a construction panel. + + @function onConstructionPanelOpen + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onConstructionPanelOpen(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has opened a trade panel. + + @function onTradePanelOpen + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onTradePanelOpen(settlement, faction, region, religion) + --something + end + */ + + /*** + The player has requested advice on the settlement scroll. + + @function onSettlementScrollAdviceRequested + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + + @usage + function onSettlementScrollAdviceRequested(settlement, faction, region, religion) + --something + end + */ + + /*** + A guild has been created/upgraded. + + @function onGuildUpgraded + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam regionStruct region + @tparam string religion + @tparam guild guild + + @usage + function onGuildUpgraded(settlement, faction, region, religion, guild) --something end */ @@ -1827,6 +2012,72 @@ void luaP::onPluginLoadF() end */ + /*** + The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used. + + @function onEscPressed + + @usage + function onEscPressed() + --something here + end + */ + + /*** + The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used. + + @function onScriptedAdvice + + @usage + function onScriptedAdvice() + --something here + end + */ + + /*** + The player has requested advice on the naval prebattle scroll. + + @function onNavalPreBattleScrollAdviceRequested + + @usage + function onNavalPreBattleScrollAdviceRequested() + --something here + end + */ + + /*** + The player has requested advice on the prebattle scroll. + + @function onPreBattleScrollAdviceRequested + + @usage + function onPreBattleScrollAdviceRequested() + --something here + end + */ + + /*** + The player has opened the college of cardinals panel. + + @function onCollegeOfCardinalsPanelOpen + + @usage + function onCollegeOfCardinalsPanelOpen() + --something here + end + */ + + /*** + The player has opened the diplomatic standing panel. + + @function onDiplomaticStandingPanelOpen + + @usage + function onDiplomaticStandingPanelOpen() + --something here + end + */ + /*** An idle unit is under missile fire. @@ -2024,7 +2275,7 @@ void luaP::onPluginLoadF() /*** A building has been completed. - @function GovernorBuildingCompleted + @function onGovernorBuildingCompleted @tparam namedCharacter namedChar @tparam factionStruct faction @tparam settlementStruct settlement @@ -2034,7 +2285,7 @@ void luaP::onPluginLoadF() @tparam string religion @usage - function GovernorBuildingCompleted(namedChar, faction, settlement, building, region, characterType, religion) + function onGovernorBuildingCompleted(namedChar, faction, settlement, building, region, characterType, religion) --something here end */ @@ -2121,10 +2372,42 @@ void luaP::onPluginLoadF() end */ + /*** + The player has requested building advice. + + @function onRequestBuildingAdvice + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string buildingName + @tparam regionStruct region + @tparam string religion + + @usage + function onRequestBuildingAdvice(settlement, faction, buildingName, region, religion) + --something here + end + */ + + /*** + The player has requested training advice. + + @function onRequestTrainingAdvice + @tparam settlementStruct settlement + @tparam factionStruct faction + @tparam string resource + @tparam regionStruct region + @tparam string religion + + @usage + function onRequestTrainingAdvice(settlement, faction, resource, region, religion) + --something here + end + */ + /*** A unit has been added to the training queue. - @function onAddedToBuildingQueue + @function onAddedToTrainingQueue @tparam settlementStruct settlement @tparam factionStruct faction @tparam string unitName @@ -2132,7 +2415,7 @@ void luaP::onPluginLoadF() @tparam string religion @usage - function onAddedToBuildingQueue(settlement, faction, unitName, region, religion) + function onAddedToTrainingQueue(settlement, faction, unitName, region, religion) --something here end */ @@ -2161,6 +2444,102 @@ void luaP::onPluginLoadF() end */ + /*** + The player has requested mercenaries advice. + + @function onRequestMercenariesAdvice + @tparam stackStruct army + + @usage + function onRequestMercenariesAdvice(army) + --something here + end + */ + + /*** + The player has clicked on a button. + + @function onButtonPressed + @tparam string name + + @usage + function onButtonPressed(name) + --something here + end + */ + + /*** + The player triggered a keyboard shortcut. + + @function onShortcutTriggered + @tparam string name + + @usage + function onShortcutTriggered(name) + --something here + end + */ + + /*** + A special UI Element is visible. + + @function onUIElementVisible + @tparam string name + + @usage + function onUIElementVisible(name) + --something here + end + */ + + /*** + The player opened a scroll. + + @function onScrollOpened + @tparam string name + + @usage + function onScrollOpened(name) + --something here + end + */ + + /*** + The player closed a scroll. + + @function onScrollClosed + @tparam string name + + @usage + function onScrollClosed(name) + --something here + end + */ + + /*** + The player has requested advice on a scroll. + + @function onScrollAdviceRequested + @tparam string name + + @usage + function onScrollAdviceRequested(name) + --something here + end + */ + + /*** + The player has suppressed a piece of advice. + + @function onAdviceSupressed + @tparam string name + + @usage + function onAdviceSupressed(name) + --something here + end + */ + /*** A general has been routed. @@ -2376,33 +2755,150 @@ void luaP::onPluginLoadF() */ /*** - The battle AI has begun processing. + The player has opened his finances panel. - @function onBattleAiCommenced + @function onFinancesPanelOpen @tparam factionStruct faction @tparam string religion @usage - function onBattleAiCommenced(faction, religion) + function onFinancesPanelOpen(faction, religion) --something here end */ /*** - The delay phase has begun. + The player has opened the faction summary panel. - @function onBattleDelayPhaseCommenced + @function onFactionSummaryPanelOpen @tparam factionStruct faction @tparam string religion @usage - function onBattleDelayPhaseCommenced(faction, religion) + function onFactionSummaryPanelOpen(faction, religion) --something here end */ /*** - The deployment phase has begun. + The player has opened the family tree panel. + + @function onFamilyTreePanelOpen + @tparam factionStruct faction + @tparam string religion + + @usage + function onFamilyTreePanelOpen(faction, religion) + --something here + end + */ + + /*** + The player has opened the diplomatic standing panel. + + @function onDiplomacyPanelOpen + @tparam factionStruct faction + @tparam string religion + + @usage + function onDiplomacyPanelOpen(faction, religion) + --something here + end + */ + + /*** + The player has attacked an army or settlement. The decision panel is now open. + + @function onPreBattlePanelOpen + @tparam factionStruct faction + @tparam string religion + + @usage + function onPreBattlePanelOpen(faction, religion) + --something here + end + */ + + /*** + A message has arrived for the player. + + @function onIncomingMessage + @tparam factionStruct faction + @tparam string religion + + @usage + function onIncomingMessage(faction, religion) + --something here + end + */ + + /*** + The player has opened a message. + + @function onMessageOpen + @tparam factionStruct faction + @tparam string religion + + @usage + function onMessageOpen(faction, religion) + --something here + end + */ + + /*** + The player has closed a message. + + @function onMessageClosed + @tparam factionStruct faction + @tparam string religion + + @usage + function onMessageClosed(faction, religion) + --something here + end + */ + + /*** + The player has declined automated settlement management. + + @function onDeclineAutomatedSettlementManagement + @tparam factionStruct faction + @tparam string religion + + @usage + function onDeclineAutomatedSettlementManagement(faction, religion) + --something here + end + */ + + /*** + The battle AI has begun processing. + + @function onBattleAiCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleAiCommenced(faction, religion) + --something here + end + */ + + /*** + The delay phase has begun. + + @function onBattleDelayPhaseCommenced + @tparam factionStruct faction + @tparam string religion + + @usage + function onBattleDelayPhaseCommenced(faction, religion) + --something here + end + */ + + /*** + The deployment phase has begun. @function onBattleDeploymentPhaseCommenced @tparam factionStruct faction @@ -3112,378 +3608,6 @@ void luaP::onPluginLoadF() */ onStartSiege = new sol::function(luaState["onStartSiege"]); checkLuaFunc(&onStartSiege); - /*** - A character has been selected by any means (including through the UI). - - @function onCharacterSelected - @tparam namedCharacter selectedChar - - @usage - function onCharacterSelected(selectedChar) - --something here - end - */ - onCharacterSelectedFunc = new sol::function(luaState["onCharacterSelected"]); - checkLuaFunc(&onCharacterSelectedFunc); - - - /*** - The player has attempted to move a character beyond that character's given movement range for that turn. - - @function onMultiTurnMove - @tparam namedCharacter character - - @usage - --something - */ - - onMultiTurnMoveFunc = new sol::function(luaState["onMultiTurnMove"]); - checkLuaFunc(&onMultiTurnMoveFunc); - - /*** - A settlement has been selected by any means (including through the UI). - - @function onSettlementSelected - @tparam settlementStruct settlement - - @usage - function onSettlementSelected(settlement) - print("Function: onSettlementSelected()\n\tSettlement: "..settlement.name) - end - */ - - onSettlementSelectedFunc = new sol::function(luaState["onSettlementSelected"]); - checkLuaFunc(&onSettlementSelectedFunc); - - /*** - The player has opened the panel for the selected settlement. - - @function onSettlementPanelOpen - @tparam settlementStruct sett - - @usage - --something - */ - - onSettlementPanelOpenFunc = new sol::function(luaState["onSettlementPanelOpen"]); - checkLuaFunc(&onSettlementPanelOpenFunc); - - /*** - The player has opened the finances panel. - - @function onFinancesPanelOpen - @tparam factionStruct fac - - @usage - --something - */ - - onFinancesPanelOpenFunc = new sol::function(luaState["onFinancesPanelOpen"]); - checkLuaFunc(&onFinancesPanelOpenFunc); - - /*** - The player has opened the faction summary panel. - - @function onFactionSummaryPanelOpen - @tparam factionStruct fac - - @usage - --something - */ - - onFactionSummaryPanelOpenFunc = new sol::function(luaState["onFactionSummaryPanelOpen"]); - checkLuaFunc(&onFactionSummaryPanelOpenFunc); - - /*** - The player has opened the family tree panel. - - @function onFamilyTreePanelOpenFunc - @tparam factionStruct fac - - @usage - --something - */ - - onFamilyTreePanelOpenFunc = new sol::function(luaState["onFamilyTreePanelOpenFunc"]); - checkLuaFunc(&onFamilyTreePanelOpenFunc); - - /*** - The player has opened the diplomatic standing panel. - - @function onDiplomaticStandingPanelOpen - @tparam factionStruct fac - - @usage - --something - */ - - onDiplomaticStandingPanelOpenFunc = new sol::function(luaState["onDiplomaticStandingPanelOpen"]); - checkLuaFunc(&onDiplomaticStandingPanelOpenFunc); - - /*** - The player has opened a diplomacy panel. - - @function onDiplomacyPanelOpen - @tparam factionStruct fac - - @usage - --something - */ - - onDiplomacyPanelOpenFunc = new sol::function(luaState["onDiplomacyPanelOpen"]); - checkLuaFunc(&onDiplomacyPanelOpenFunc); - - /*** - The player has attacked an army or settlement. The decision panel is now open. - - @function onPreBattlePanelOpen - @tparam factionStruct fac - - @usage - --something - */ - - onPreBattlePanelOpenFunc = new sol::function(luaState["onPreBattlePanelOpen"]); - checkLuaFunc(&onPreBattlePanelOpenFunc); - - /*** - The naval auto resolve panel has opened. - - @function onNavalAutoResolvePanelOpen - - @usage - --something - */ - - onNavalAutoResolvePanelOpenFunc = new sol::function(luaState["onNavalAutoResolvePanelOpen"]); - checkLuaFunc(&onNavalAutoResolvePanelOpenFunc); - - /*** - The player has opened the panel for the selected character. - - @function onCharacterPanelOpen - @tparam namedCharacter selectedChar - - @usage - --something - */ - - onCharacterPanelOpenFunc = new sol::function(luaState["onCharacterPanelOpen"]); - checkLuaFunc(&onCharacterPanelOpenFunc); - - /*** - The player has opened a trade panel. - - @function onTradePanelOpen - @tparam settlementStruct sett - - @usage - --something - */ - - onTradePanelOpenFunc = new sol::function(luaState["onTradePanelOpen"]); - checkLuaFunc(&onTradePanelOpenFunc); - - /*** - The player has requested building advice. - - @function onRequestBuildingAdvice - @tparam settlementStruct sett - - @usage - --something - */ - - onRequestBuildingAdviceFunc = new sol::function(luaState["onRequestBuildingAdvice"]); - checkLuaFunc(&onRequestBuildingAdviceFunc); - - /*** - The player has requested training advice. - - @function onRequestTrainingAdvice - @tparam settlementStruct sett - @tparam eduEntry recommendedUnitEntry - - @usage - --something - */ - - onRequestTrainingAdviceFunc = new sol::function(luaState["onRequestTrainingAdvice"]); - checkLuaFunc(&onRequestTrainingAdviceFunc); - - /*** - The player has opened a message. - - @function onMessageOpen - @tparam factionStruct fac - @tparam int msgType - - @usage - --something - */ - - onMessageOpenFunc = new sol::function(luaState["onMessageOpen"]); - checkLuaFunc(&onMessageOpenFunc); - - /*** - The player has recieved a message. - - @function onIncomingMessage - @tparam factionStruct fac - @tparam int msgType - - @usage - --something - */ - - onIncomingMessageFunc = new sol::function(luaState["onIncomingMessage"]); - checkLuaFunc(&onIncomingMessageFunc); - - /*** - The player has closed a message. - - @function onMessageClosed - @tparam int msgType - - @usage - --something - */ - - onMessageClosedFunc = new sol::function(luaState["onMessageClosed"]); - checkLuaFunc(&onMessageClosedFunc); - - /*** - The player has clicked on a button. - - @function onButtonPressed - @tparam string buttonName - - @usage - --something - */ - - onButtonPressedFunc = new sol::function(luaState["onButtonPressed"]); - checkLuaFunc(&onButtonPressedFunc); - - /*** - The player closed a scroll. - - @function onScrollClosed - @tparam string scrollName - - @usage - --something - */ - - onScrollClosedFunc = new sol::function(luaState["onScrollClosed"]); - checkLuaFunc(&onScrollClosedFunc); - - /*** - The player opened a scroll. - - @function onScrollOpened - @tparam string scrollName - - @usage - --something - */ - - onScrollOpenedFunc = new sol::function(luaState["onScrollOpened"]); - checkLuaFunc(&onScrollOpenedFunc); - - /*** - A special UI Element is visible. - - @function onUIElementVisible - @tparam string elementName - - @usage - --something - */ - - onUIElementVisibleFunc = new sol::function(luaState["onUIElementVisible"]); - checkLuaFunc(&onUIElementVisibleFunc); - - /*** - The player has requested advice on a scroll. - - @function onScrollAdviceRequested - @tparam string scrollName - - @usage - --something - */ - - onScrollAdviceRequestedFunc = new sol::function(luaState["onScrollAdviceRequested"]); - checkLuaFunc(&onScrollAdviceRequestedFunc); - - /*** - The player has requested advice on the settlement scroll. - - @function onSettlementScrollAdviceRequested - @tparam settlementStruct sett - @tparam string scrollName - - @usage - --something - */ - - onSettlementScrollAdviceRequestedFunc = new sol::function(luaState["onSettlementScrollAdviceRequested"]); - checkLuaFunc(&onSettlementScrollAdviceRequestedFunc); - - /*** - The player has requested advice on the prebattle scroll. - - @function onPreBattleScrollAdviceRequested - - @usage - --something - */ - - onPreBattleScrollAdviceRequestedFunc = new sol::function(luaState["onPreBattleScrollAdviceRequested"]); - checkLuaFunc(&onPreBattleScrollAdviceRequestedFunc); - - /*** - The player has requested advice on the naval prebattle scroll. - - @function onNavalPreBattleScrollAdviceRequested - - @usage - --something - */ - - onNavalPreBattleScrollAdviceRequestedFunc = new sol::function(luaState["onNavalPreBattleScrollAdviceRequested"]); - checkLuaFunc(&onNavalPreBattleScrollAdviceRequestedFunc); - - /*** - The player has opened the college of cardinals panel. - - @function onCollegeOfCardinalsPanelOpen - @tparam collegeCardinalsStruct college - - @usage - --something - */ - - onCollegeOfCardinalsPanelOpenFunc = new sol::function(luaState["onCollegeOfCardinalsPanelOpen"]); - checkLuaFunc(&onCollegeOfCardinalsPanelOpenFunc); - - /*** - The player triggered a keyboard shortcut. - - @function onShortcutTriggered - @tparam string shortcut - - @usage - function onShortcutTriggered(shortcut) - if shortcut == "strat_ui::mission_button" then - --do stuff - end - end - */ - - onShortcutTriggeredFunc = new sol::function(luaState["onShortcutTriggered"]); - checkLuaFunc(&onShortcutTriggeredFunc); if (onPluginLoad != nullptr) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 0e00ff370..f01e83d2d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -2516,35 +2516,3 @@ void luaP::onChangeTurnNum(int num) tryLua((*onChangeTurnNumFunc)(num)); } } - -void luaP::onCharacterSelected(namedCharacter* gen) -{ - if (onCharacterSelectedFunc != nullptr) - { - tryLua((*onCharacterSelectedFunc)(gen)); - } -} - -void luaP::onSiegeEquipmentCompleted(settlementStruct* sett, fortStruct* frt) -{ - if (onSiegeEquipmentCompletedFunc != nullptr) - { - tryLua((*onSiegeEquipmentCompletedFunc)(sett, frt)); - } -} - -void luaP::onMultiTurnMove(namedCharacter* gen) -{ - if (onMultiTurnMoveFunc != nullptr) - { - tryLua((*onMultiTurnMoveFunc)(gen)); - } -} - -void luaP::onSettlementSelected(settlementStruct* sett) -{ - if (onSettlementSelectedFunc != nullptr) - { - tryLua((*onSettlementSelectedFunc)(sett)); - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index 24ccad170..57402f2f0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -87,10 +87,6 @@ class luaP //lua functions and events controllers void onPluginLoadF(); void onChangeTurnNum(int num); - void onCharacterSelected(namedCharacter* gen); - - void onMultiTurnMove(namedCharacter* gen); - void onSettlementSelected(settlementStruct* sett); sol::state luaState; @@ -167,44 +163,6 @@ class luaP sol::function* resetDXFunc = nullptr; sol::function* onLoadingFonts = nullptr; sol::function* initDXFunc = nullptr; - - sol::function* onChangeTurnNumFunc = nullptr; - sol::function* onCharacterSelectedFunc = nullptr; - - - sol::function* onMultiTurnMoveFunc = nullptr; - sol::function* onSettlementSelectedFunc = nullptr; - - - - sol::function* onSettlementPanelOpenFunc = nullptr; - sol::function* onFinancesPanelOpenFunc = nullptr; - sol::function* onFactionSummaryPanelOpenFunc = nullptr; - sol::function* onFamilyTreePanelOpenFunc = nullptr; - sol::function* onDiplomaticStandingPanelOpenFunc = nullptr; - sol::function* onDiplomacyPanelOpenFunc = nullptr; - sol::function* onPreBattlePanelOpenFunc = nullptr; - sol::function* onNavalAutoResolvePanelOpenFunc = nullptr; - - sol::function* onCharacterPanelOpenFunc = nullptr; - sol::function* onTradePanelOpenFunc = nullptr; - sol::function* onRequestBuildingAdviceFunc = nullptr; - sol::function* onRequestTrainingAdviceFunc = nullptr; - sol::function* onMessageOpenFunc = nullptr; - sol::function* onIncomingMessageFunc = nullptr; - sol::function* onMessageClosedFunc = nullptr; - - sol::function* onButtonPressedFunc = nullptr; - sol::function* onScrollClosedFunc = nullptr; - sol::function* onScrollOpenedFunc = nullptr; - sol::function* onUIElementVisibleFunc = nullptr; - sol::function* onScrollAdviceRequestedFunc = nullptr; - sol::function* onSettlementScrollAdviceRequestedFunc = nullptr; - sol::function* onPreBattleScrollAdviceRequestedFunc = nullptr; - sol::function* onNavalPreBattleScrollAdviceRequestedFunc = nullptr; - sol::function* onCollegeOfCardinalsPanelOpenFunc = nullptr; - - sol::function* onShortcutTriggeredFunc = nullptr; void checkLuaFunc(sol::function** lRef); diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp index 92151f113..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp @@ -1,19 +0,0 @@ -#include "otherEvents.h" - -void onMultiTurnMove(namedCharacter* gen) -{ - plugData::data.luaAll.onMultiTurnMove(gen); -} - -void onSettlementSelected(settlementStruct* sett) -{ - plugData::data.luaAll.onSettlementSelected(sett); -} - -void onShortcutTriggered(const char* str) -{ - if (plugData::data.luaAll.onShortcutTriggeredFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onShortcutTriggeredFunc)(str)) - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h index 510085035..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h @@ -1,6 +0,0 @@ -#pragma once -#include "pluginM2TWEOP.h" -extern "C" PLUGINM2TWEOP_API void onMultiTurnMove(namedCharacter * gen); -extern "C" PLUGINM2TWEOP_API void onSettlementSelected(settlementStruct * sett); - -extern "C" PLUGINM2TWEOP_API void onShortcutTriggered(const char* str); diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index 58d9a357d..af9f5e021 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -1044,7 +1044,7 @@ struct settlementStruct { undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ undefined field21_0x1a5[3]; - UINT32 regionNumber; /* number of region */ + UINT32 regionID; /* number of region */ undefined field_0x1ac[12]; int priceOfUnitsInRecruitmentSlots; undefined field24_0xBC[24]; diff --git a/M2TWEOP-luaPlugin/luaPlugin/tableList.txt b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt index e48978756..b88ffa3b5 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/tableList.txt +++ b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt @@ -1,63 +1,220 @@ - @tfield draw draw - @tfield deinitDX deinitDX - @tfield initDX initDX - @tfield onPluginLoad onPluginLoad - @tfield onChangeTurnNum onChangeTurnNum - @tfield onCharacterSelected onCharacterSelected - @tfield onPreFactionTurnStart onPreFactionTurnStart - @tfield onFactionTurnStart onFactionTurnStart - @tfield onFactionTurnEnd onFactionTurnEnd - @tfield onFactionNewCapital onFactionNewCapital - @tfield onFactionWarDeclared onFactionWarDeclared - @tfield onFactionAllianceDeclared onFactionAllianceDeclared - @tfield onFactionTradeAgreementMade onFactionTradeAgreementMade - @tfield onFactionBreakAlliance onFactionBreakAlliance - @tfield onGeneralCaptureSettlement onGeneralCaptureSettlement - @tfield onGeneralCaptureResidence onGeneralCaptureResidence - @tfield onSiegeEquipmentCompleted onSiegeEquipmentCompleted - @tfield onPostBattle onPostBattle - @tfield onMultiTurnMove onMultiTurnMove - @tfield onSettlementSelected onSettlementSelected - @tfield onSettlementUpgraded onSettlementUpgraded - @tfield onSettlementConverted onSettlementConverted - @tfield onUngarrisonedFort onUngarrisonedFort - @tfield onFactionExcommunicated onFactionExcommunicated - @tfield onHordeFormed onHordeFormed - @tfield onUnitDisbanded onUnitDisbanded - @tfield onGameReloaded onGameReloaded - @tfield onTransgression onTransgression - @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget - @tfield onCrusadeCalled onCrusadeCalled - @tfield onCrusadeEnds onCrusadeEnds - @tfield onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget - @tfield onArmyTakesCrusadeTarget onArmyTakesCrusadeTarget - @tfield onUnitsDesertCrusade onUnitsDesertCrusade - @tfield onPopeElected onPopeElected - @tfield onVotedForPope onVotedForPope - @tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope - @tfield onInquisitorAppointed onInquisitorAppointed - @tfield onSettlementPanelOpen onSettlementPanelOpen - @tfield onFinancesPanelOpen onFinancesPanelOpen - @tfield onFactionSummaryPanelOpen onFactionSummaryPanelOpen - @tfield onFamilyTreePanelOpenFunc onFamilyTreePanelOpenFunc - @tfield onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen - @tfield onDiplomacyPanelOpen onDiplomacyPanelOpen - @tfield onPreBattlePanelOpen onPreBattlePanelOpen - @tfield onNavalAutoResolvePanelOpen onNavalAutoResolvePanelOpen - @tfield onCharacterPanelOpen onCharacterPanelOpen - @tfield onTradePanelOpen onTradePanelOpen - @tfield onRequestBuildingAdvice onRequestBuildingAdvice - @tfield onRequestTrainingAdvice onRequestTrainingAdvice - @tfield onMessageOpen onMessageOpen - @tfield onIncomingMessage onIncomingMessage - @tfield onMessageClosed onMessageClosed - @tfield onButtonPressed onButtonPressed - @tfield onScrollClosed onScrollClosed - @tfield onScrollOpened onScrollOpened - @tfield onUIElementVisible onUIElementVisible - @tfield onScrollAdviceRequested onScrollAdviceRequested - @tfield onSettlementScrollAdviceRequested onSettlementScrollAdviceRequested - @tfield onPreBattleScrollAdviceRequested onPreBattleScrollAdviceRequested - @tfield onNavalPreBattleScrollAdviceRequested onNavalPreBattleScrollAdviceRequested - @tfield onCollegeOfCardinalsPanelOpen onCollegeOfCardinalsPanelOpen - @tfield onGeneralDevastatesTile onGeneralDevastatesTile +@tfield onCharacterTurnStart onCharacterTurnStart +@tfield onCapturedCharacterRansomed onCapturedCharacterRansomed +@tfield onCapturedCharacterReleased onCapturedCharacterReleased +@tfield onFatherDiesNatural onFatherDiesNatural +@tfield onPreBattleWithdrawal onPreBattleWithdrawal +@tfield onPostBattle onPostBattle +@tfield onHireMercenaries onHireMercenaries +@tfield onGeneralCaptureResidence onGeneralCaptureResidence +@tfield onLeaderDestroyedFaction onLeaderDestroyedFaction +@tfield onOfferedForAdoption onOfferedForAdoption +@tfield onLesserGeneralOfferedForAdoption onLesserGeneralOfferedForAdoption +@tfield onOfferedForMarriage onOfferedForMarriage +@tfield onBrotherAdopted onBrotherAdopted +@tfield onBirth onBirth +@tfield onCharacterComesOfAge onCharacterComesOfAge +@tfield onCharacterMarries onCharacterMarries +@tfield onCharacterMarriesPrincess onCharacterMarriesPrincess +@tfield onMarriageAlliancePossible onMarriageAlliancePossible +@tfield onMarriageAllianceOffered onMarriageAllianceOffered +@tfield onPriestBecomesHeretic onPriestBecomesHeretic +@tfield onCharacterNearHeretic onCharacterNearHeretic +@tfield onCharacterNearWitch onCharacterNearWitch +@tfield onCardinalPromoted onCardinalPromoted +@tfield onCharacterBecomesAFather onCharacterBecomesAFather +@tfield onGeneralDevastatesTile onGeneralDevastatesTile +@tfield onExecutesASpyOnAMission onExecutesASpyOnAMission +@tfield onExecutesAnAssassinOnAMission onExecutesAnAssassinOnAMission +@tfield onSufferAssassinationAttempt onSufferAssassinationAttempt +@tfield onSufferAcquisitionAttempt onSufferAcquisitionAttempt +@tfield onSufferMarriageAttempt onSufferMarriageAttempt +@tfield onSufferDenouncementAttempt onSufferDenouncementAttempt +@tfield onLeaderOrderedSabotage onLeaderOrderedSabotage +@tfield onAcceptBribe onAcceptBribe +@tfield onRefuseBribe onRefuseBribe +@tfield onInsurrection onInsurrection +@tfield onLeaderOrderedDiplomacy onLeaderOrderedDiplomacy +@tfield onNewAdmiralCreated onNewAdmiralCreated +@tfield onGovernorBuildingDestroyed onGovernorBuildingDestroyed +@tfield onGovernorThrowGames onGovernorThrowGames +@tfield onGovernorThrowRaces onGovernorThrowRaces +@tfield onCharacterSelected onCharacterSelected +@tfield onEnemyCharacterSelected onEnemyCharacterSelected +@tfield onMultiTurnMove onMultiTurnMove +@tfield onCharacterPanelOpen onCharacterPanelOpen +@tfield onLeaderMissionSuccess onLeaderMissionSuccess +@tfield onLeaderMissionFailed onLeaderMissionFailed +@tfield onGeneralJoinCrusade onGeneralJoinCrusade +@tfield onGeneralAbandonCrusade onGeneralAbandonCrusade +@tfield onGeneralArrivesCrusadeTargetRegion onGeneralArrivesCrusadeTargetRegion +@tfield onGeneralTakesCrusadeTarget onGeneralTakesCrusadeTarget +@tfield onCharacterTurnEnd onCharacterTurnEnd +@tfield onCharacterTurnEndInSettlement onCharacterTurnEndInSettlement +@tfield onBecomesFactionLeader onBecomesFactionLeader +@tfield onCeasedFactionLeader onCeasedFactionLeader +@tfield onBecomesFactionHeir onBecomesFactionHeir +@tfield onCeasedFactionHeir onCeasedFactionHeir +@tfield onCharacterDamagedByDisaster onCharacterDamagedByDisaster +@tfield onGeneralCaptureSettlement onGeneralCaptureSettlement +@tfield onGeneralAssaultsResidence onGeneralAssaultsResidence +@tfield onGeneralAssaultsGeneral onGeneralAssaultsGeneral +@tfield onCharacterAttacksCrusadingGeneral onCharacterAttacksCrusadingGeneral +@tfield onGeneralPrisonersRansomedCaptor onGeneralPrisonersRansomedCaptor +@tfield onGeneralPrisonersRansomedCaptive onGeneralPrisonersRansomedCaptive +@tfield onFactionLeaderPrisonersRansomedCaptor onFactionLeaderPrisonersRansomedCaptor +@tfield onFactionLeaderPrisonersRansomedCaptive onFactionLeaderPrisonersRansomedCaptive +@tfield onSpyMission onSpyMission +@tfield onAssassinationMission onAssassinationMission +@tfield onAcquisitionMission onAcquisitionMission +@tfield onMarriageMission onMarriageMission +@tfield onDenouncementMission onDenouncementMission +@tfield onSabotageMission onSabotageMission +@tfield onBriberyMission onBriberyMission +@tfield onDiplomacyMission onDiplomacyMission +@tfield onLeaderOrderedSpyingMission onLeaderOrderedSpyingMission +@tfield onLeaderOrderedAssassination onLeaderOrderedAssassination +@tfield onLeaderOrderedBribery onLeaderOrderedBribery +@tfield onSettlementTurnStart onSettlementTurnStart +@tfield onUngarrisonedSettlement onUngarrisonedSettlement +@tfield onSettlementUpgraded onSettlementUpgraded +@tfield onSettlementConverted onSettlementConverted +@tfield onSiegeEquipmentCompleted onSiegeEquipmentCompleted +@tfield onSettlementTurnEnd onSettlementTurnEnd +@tfield onSettlementSelected onSettlementSelected +@tfield onSettlementPanelOpen onSettlementPanelOpen +@tfield onRecruitmentPanelOpen onRecruitmentPanelOpen +@tfield onConstructionPanelOpen onConstructionPanelOpen +@tfield onTradePanelOpen onTradePanelOpen +@tfield onSettlementScrollAdviceRequested onSettlementScrollAdviceRequested +@tfield onGuildUpgraded onGuildUpgraded +@tfield onGuildDestroyed onGuildDestroyed +@tfield onOccupySettlement onOccupySettlement +@tfield onSackSettlement onSackSettlement +@tfield onExterminatePopulation onExterminatePopulation +@tfield onCityRiots onCityRiots +@tfield onGiveSettlement onGiveSettlement +@tfield onCityRebels onCityRebels +@tfield onCitySacked onCitySacked +@tfield onGovernorCityRiots onGovernorCityRiots +@tfield onGovernorCityRebels onGovernorCityRebels +@tfield onAbandonShowMe onAbandonShowMe +@tfield onGameReloaded onGameReloaded +@tfield onBattleWinningPlaza onBattleWinningPlaza +@tfield onBattleStopsWinningPlaza onBattleStopsWinningPlaza +@tfield onBattleDominatingPlaza onBattleDominatingPlaza +@tfield onBattngineUnmanned onBattngineUnmanned +@tfield onBattlePlayerArmyHalfDestroyed onBattlePlayerArmyHalfDestroyed +@tfield onBattnemyArmyHalfDestroyed onBattnemyArmyHalfDestroyed +@tfield onBattleFinished onBattleFinished +@tfield onBattleArmyHalfDestroyed onBattleArmyHalfDestroyed +@tfield onEscPressed onEscPressed +@tfield onScriptedAdvice onScriptedAdvice +@tfield onNavalPreBattleScrollAdviceRequested onNavalPreBattleScrollAdviceRequested +@tfield onPreBattleScrollAdviceRequested onPreBattleScrollAdviceRequested +@tfield onCollegeOfCardinalsPanelOpen onCollegeOfCardinalsPanelOpen +@tfield onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen +@tfield onBattlePlayerUnderAttackIdle onBattlePlayerUnderAttackIdle +@tfield onBattleWinningCombat onBattleWinningCombat +@tfield onBattleArmyTired onBattleArmyTired +@tfield onBattleTideofBattle onBattleTideofBattle +@tfield onBattleUnitGoesBerserk onBattleUnitGoesBerserk +@tfield onBattleSiegeEngineDestroyed onBattleSiegeEngineDestroyed +@tfield onBattleSiegeEngineDocksWall onBattleSiegeEngineDocksWall +@tfield onBattleGatesAttackedByEngine onBattleGatesAttackedByEngine +@tfield onBattleGatesDestroyedByEngine onBattleGatesDestroyedByEngine +@tfield onBattleWallsBreachedByEngine onBattleWallsBreachedByEngine +@tfield onBattleWallsCaptured onBattleWallsCaptured +@tfield onBattleUnitRouts onBattleUnitRouts +@tfield onUnitDisbanded onUnitDisbanded +@tfield onUnitTrained onUnitTrained +@tfield onGovernorUnitTrained onGovernorUnitTrained +@tfield onGovernorBuildingCompleted onGovernorBuildingCompleted +@tfield onAgentCreated onAgentCreated +@tfield onGovernorAgentCreated onGovernorAgentCreated +@tfield onBuildingDestroyed onBuildingDestroyed +@tfield onAddedToBuildingQueue onAddedToBuildingQueue +@tfield onBuildingCompleted onBuildingCompleted +@tfield onRequestBuildingAdvice onRequestBuildingAdvice +@tfield onRequestTrainingAdvice onRequestTrainingAdvice +@tfield onAddedToTrainingQueue onAddedToTrainingQueue +@tfield onBattleArmyRouted onBattleArmyRouted +@tfield onBattleReinforcementsArrive onBattleReinforcementsArrive +@tfield onRequestMercenariesAdvice onRequestMercenariesAdvice +@tfield onButtonPressed onButtonPressed +@tfield onShortcutTriggered onShortcutTriggered +@tfield onUIElementVisible onUIElementVisible +@tfield onScrollOpened onScrollOpened +@tfield onScrollClosed onScrollClosed +@tfield onScrollAdviceRequested onScrollAdviceRequested +@tfield onAdviceSupressed onAdviceSupressed +@tfield onBattleGeneralRouted onBattleGeneralRouted +@tfield onBattleGeneralKilled onBattleGeneralKilled +@tfield onCrusadeCalled onCrusadeCalled +@tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget +@tfield onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget +@tfield onCrusadeEnds onCrusadeEnds +@tfield onPreFactionTurnStart onPreFactionTurnStart +@tfield onFactionTurnStart onFactionTurnStart +@tfield onFactionNewCapital onFactionNewCapital +@tfield onFactionTurnEnd onFactionTurnEnd +@tfield onVotedForPope onVotedForPope +@tfield onFactionExcommunicated onFactionExcommunicated +@tfield onHordeFormed onHordeFormed +@tfield onCardinalRemoved onCardinalRemoved +@tfield onInquisitorAppointed onInquisitorAppointed +@tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope +@tfield onFinancesPanelOpen onFinancesPanelOpen +@tfield onFactionSummaryPanelOpen onFactionSummaryPanelOpen +@tfield onFamilyTreePanelOpen onFamilyTreePanelOpen +@tfield onDiplomacyPanelOpen onDiplomacyPanelOpen +@tfield onPreBattlePanelOpen onPreBattlePanelOpen +@tfield onIncomingMessage onIncomingMessage +@tfield onMessageOpen onMessageOpen +@tfield onMessageClosed onMessageClosed +@tfield onDeclineAutomatedSettlementManagement onDeclineAutomatedSettlementManagement +@tfield onBattleAiCommenced onBattleAiCommenced +@tfield onBattleDelayPhaseCommenced onBattleDelayPhaseCommenced +@tfield onBattleDeploymentPhaseCommenced onBattleDeploymentPhaseCommenced +@tfield onBattleConflictPhaseCommenced onBattleConflictPhaseCommenced +@tfield onFactionWarDeclared onFactionWarDeclared +@tfield onFactionAllianceDeclared onFactionAllianceDeclared +@tfield onInterFactionMarriage onInterFactionMarriage +@tfield onFactionTradeAgreementMade onFactionTradeAgreementMade +@tfield onPopeElected onPopeElected +@tfield onFactionBreakAlliance onFactionBreakAlliance +@tfield onUpdateAttitude onUpdateAttitude +@tfield onDemeanour onDemeanour +@tfield onGiveMoney onGiveMoney +@tfield onBattlePlayerUnitAttacksEnemyUnit onBattlePlayerUnitAttacksEnemyUnit +@tfield onBattleEnemyUnitAttacksPlayerUnit onBattleEnemyUnitAttacksPlayerUnit +@tfield onBattlePlayerUnitGoesBerserk onBattlePlayerUnitGoesBerserk +@tfield onBattlePlayerUnitRouts onBattlePlayerUnitRouts +@tfield onBattlePlayerSiegeEngineDestroyed onBattlePlayerSiegeEngineDestroyed +@tfield onBattleGatesAttackedByPlayerEngine onBattleGatesAttackedByPlayerEngine +@tfield onBattleEnemyUnitGoesBerserk onBattleEnemyUnitGoesBerserk +@tfield onBattnemyUnitRouts onBattnemyUnitRouts +@tfield onBattnemySiegeEngineDestroyed onBattnemySiegeEngineDestroyed +@tfield onBattleGatesAttackedByEnemyEngine onBattleGatesAttackedByEnemyEngine +@tfield onDisaster onDisaster +@tfield onEventCounter onEventCounter +@tfield onUngarrisonedFort onUngarrisonedFort +@tfield onObjSeen onObjSeen +@tfield onTileSeen onTileSeen +@tfield onTransgression onTransgression +@tfield onForgiveness onForgiveness +@tfield onArmyTakesCrusadeTarget onArmyTakesCrusadeTarget +@tfield onUnitsDesertCrusade onUnitsDesertCrusade +@tfield draw draw +@tfield onLoadingFonts onLoadingFonts +@tfield onNewGameStart onNewGameStart +@tfield onReadGameDbsAtStart onReadGameDbsAtStart +@tfield onClickAtTile onClickAtTile +@tfield onCampaignMapLoaded onCampaignMapLoaded +@tfield onCreateSaveFile onCreateSaveFile +@tfield onLoadSaveFile onLoadSaveFile +@tfield onChangeTurnNum onChangeTurnNum +@tfield onSelectWorldpkgdesc onSelectWorldpkgdesc +@tfield onfortificationlevelS onfortificationlevelS +@tfield onEndSiege onEndSiege +@tfield onStartSiege onStartSiege +@tfield onPluginLoad onPluginLoad \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp index e690149d5..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.cpp @@ -1,194 +0,0 @@ -#include "uiEvents.h" - -void onSettlementPanelOpen(settlementStruct* sett) -{ - if (plugData::data.luaAll.onSettlementPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onSettlementPanelOpenFunc)(sett)); - } -} - -void onFinancesPanelOpen(factionStruct* fac) -{ - if (plugData::data.luaAll.onFinancesPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onFinancesPanelOpenFunc)(fac)); - } -} - -void onFactionSummaryPanelOpen(factionStruct* fac) -{ - if (plugData::data.luaAll.onFactionSummaryPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onFactionSummaryPanelOpenFunc)(fac)); - } -} - -void onFamilyTreePanelOpen(factionStruct* fac) -{ - if (plugData::data.luaAll.onFamilyTreePanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onFamilyTreePanelOpenFunc)(fac)); - } -} - -void onDiplomaticStandingPanelOpen() -{ - if (plugData::data.luaAll.onDiplomaticStandingPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onDiplomaticStandingPanelOpenFunc)()); - } -} - -void onDiplomacyPanelOpen(factionStruct* fac) -{ - if (plugData::data.luaAll.onDiplomacyPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onDiplomacyPanelOpenFunc)(fac)); - } -} - -void onPreBattlePanelOpen(factionStruct* fac) -{ - if (plugData::data.luaAll.onPreBattlePanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onPreBattlePanelOpenFunc)(fac)); - } - -} - -void onNavalAutoResolvePanelOpen() -{ - if (plugData::data.luaAll.onNavalAutoResolvePanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onNavalAutoResolvePanelOpenFunc)()); - } -} - -void onCharacterPanelOpen(namedCharacter* pers) -{ - if (plugData::data.luaAll.onCharacterPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCharacterPanelOpenFunc)(pers)); - } -} - -void onTradePanelOpen(settlementStruct* sett) -{ - if (plugData::data.luaAll.onTradePanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onTradePanelOpenFunc)(sett)); - } -} - -void onRequestBuildingAdvice(settlementStruct* sett) -{ - if (plugData::data.luaAll.onRequestBuildingAdviceFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onRequestBuildingAdviceFunc)(sett)); - } -} - -void onRequestTrainingAdvice(settlementStruct* sett, eduEntry* recommend) -{ - if (plugData::data.luaAll.onRequestTrainingAdviceFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onRequestTrainingAdviceFunc)(sett, recommend)); - } -} - -void onMessageOpen(factionStruct* fac, int type) -{ - if (plugData::data.luaAll.onMessageOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onMessageOpenFunc)(fac, type)); - } -} - -void onIncomingMessage(factionStruct* fac, int type) -{ - if (plugData::data.luaAll.onIncomingMessageFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onIncomingMessageFunc)(fac, type)); - } -} - -void onMessageClosed(int type) -{ - if (plugData::data.luaAll.onMessageClosedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onMessageClosedFunc)(type)); - } -} - -void onButtonPressed(const char* butName) -{ - if (plugData::data.luaAll.onButtonPressedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onButtonPressedFunc)(butName)); - } -} - -void onScrollClosed(const char* scrName) -{ - if (plugData::data.luaAll.onScrollClosedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onScrollClosedFunc)(scrName)); - } -} - -void onScrollOpened(const char* scrName) -{ - if (plugData::data.luaAll.onScrollOpenedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onScrollOpenedFunc)(scrName)); - } -} - -void onUIElementVisible(const char* elName) -{ - if (plugData::data.luaAll.onUIElementVisibleFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onUIElementVisibleFunc)(elName)); - } -} - -void onScrollAdviceRequested(const char* scrName) -{ - if (plugData::data.luaAll.onScrollAdviceRequestedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onScrollAdviceRequestedFunc)(scrName)); - } -} - -void onSettlementScrollAdviceRequested(settlementStruct* sett, const char* scrName) -{ - if (plugData::data.luaAll.onSettlementScrollAdviceRequestedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onSettlementScrollAdviceRequestedFunc)(sett, scrName)); - } -} - -void onPreBattleScrollAdviceRequested() -{ - if (plugData::data.luaAll.onPreBattleScrollAdviceRequestedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onPreBattleScrollAdviceRequestedFunc)()); - } -} - -void onNavalPreBattleScrollAdviceRequested() -{ - if (plugData::data.luaAll.onNavalPreBattleScrollAdviceRequestedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onNavalPreBattleScrollAdviceRequestedFunc)()); - } -} - -void onCollegeOfCardinalsPanelOpen(void* college) -{ - if (plugData::data.luaAll.onCollegeOfCardinalsPanelOpenFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onCollegeOfCardinalsPanelOpenFunc)((int)college)); - } -} diff --git a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h index 7445b1323..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/uiEvents.h @@ -1,31 +0,0 @@ -#pragma once -#include "pluginM2TWEOP.h" -extern "C" PLUGINM2TWEOP_API void onSettlementPanelOpen(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onFinancesPanelOpen(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onFactionSummaryPanelOpen(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onFamilyTreePanelOpen(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onDiplomaticStandingPanelOpen(); -extern "C" PLUGINM2TWEOP_API void onDiplomacyPanelOpen(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onPreBattlePanelOpen(factionStruct * fac); -extern "C" PLUGINM2TWEOP_API void onNavalAutoResolvePanelOpen(); -extern "C" PLUGINM2TWEOP_API void onCharacterPanelOpen(namedCharacter * pers); -extern "C" PLUGINM2TWEOP_API void onTradePanelOpen(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onRequestBuildingAdvice(settlementStruct * sett); -extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, eduEntry * recommend); -extern "C" PLUGINM2TWEOP_API void onRequestTrainingAdvice(settlementStruct * sett, eduEntry * recommend); - -extern "C" PLUGINM2TWEOP_API void onMessageOpen(factionStruct * fac, int type); -extern "C" PLUGINM2TWEOP_API void onIncomingMessage(factionStruct * fac, int type); -extern "C" PLUGINM2TWEOP_API void onMessageClosed(int type); - -extern "C" PLUGINM2TWEOP_API void onButtonPressed(const char* butName); -extern "C" PLUGINM2TWEOP_API void onScrollClosed(const char* scrName); -extern "C" PLUGINM2TWEOP_API void onScrollOpened(const char* scrName); -extern "C" PLUGINM2TWEOP_API void onUIElementVisible(const char* elName); -extern "C" PLUGINM2TWEOP_API void onScrollAdviceRequested(const char* scrName); - -extern "C" PLUGINM2TWEOP_API void onSettlementScrollAdviceRequested(settlementStruct * sett, const char* scrName); - -extern "C" PLUGINM2TWEOP_API void onPreBattleScrollAdviceRequested(); -extern "C" PLUGINM2TWEOP_API void onNavalPreBattleScrollAdviceRequested(); -extern "C" PLUGINM2TWEOP_API void onCollegeOfCardinalsPanelOpen(void* college); \ No newline at end of file From ee9022b1b9fee86726b8efa220311bd41889125f Mon Sep 17 00:00:00 2001 From: FynnTW Date: Sun, 1 Oct 2023 23:04:54 +0300 Subject: [PATCH 05/22] bugfixes --- M2TWEOP Code/M2TWEOP library/plugins.cpp | 3 +-- M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 5 ----- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 8 +++----- M2TWEOP-luaPlugin/luaPlugin/luaP.h | 1 + M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp | 11 +---------- M2TWEOP-luaPlugin/luaPlugin/religionEvents.h | 4 ---- 6 files changed, 6 insertions(+), 26 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/plugins.cpp b/M2TWEOP Code/M2TWEOP library/plugins.cpp index 60c532eff..900f75ba3 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -16,8 +16,7 @@ void plugins::init() pluginsCfg.pluginsPath = pluginsCfg.pluginsPath + "\\youneuoy_Data\\plugins"; vectorplList = getAllPlPachs(&pluginsCfg.pluginsPath); if (plList.size() < 1)return; - - initEvNames(); + for (string s : plList) { if (s == "M2TWEOPLibrary.dll" diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index 9c5668996..7dd833460 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -476,7 +476,6 @@ namespace gameEvents //diplomacyEvents newCode[0] = 0x0136958C; newCode[1] = 0x01324564; - newCode[0] = 0x0136958C; newCode[1] = 0x01324564; addEvent(newCode[gv], "onFactionWarDeclared"); newCode[0] = 0x0136965C; newCode[1] = 0x01324634; @@ -692,10 +691,6 @@ void checkLuaFunc(sol::function** lRef) } }; -void onCharacterSelected(namedCharacter* gen) -{ - plugData::data.luaAll.onCharacterSelected(gen); -} void onReadGameDbsAtStart() { gameEvents::initEvents(); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index d8fdda4c6..20778312d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -716,7 +716,7 @@ namespace gameEvents bool isFort = false; if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) { - fort = (*(*plugData::data.funcs.findFort))(settlement->xCoord, settlement->yCoord) + fort = (*(*plugData::data.funcs.findFort))(settlement->xCoord, settlement->yCoord); isFort = true; faction = fort->faction; region = gameHelpers::getRegion(fort->regionID); @@ -846,10 +846,10 @@ namespace gameEvents factionStruct* faction = settlement->faction; regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); - auto guild = reinterpret_cast(vTab[2]); + auto guild_handler = reinterpret_cast< guild* >(vTab[2]); if (&(*funk) != nullptr) { - (*funk)(settlement, faction, region, religion, guild); + (*funk)(settlement, faction, region, religion, guild_handler); } return 49; @@ -958,7 +958,6 @@ sol::function* onCeasedFactionHeir = nullptr; sol::function* onUngarrisonedFort = nullptr; sol::function* onTileSeen = nullptr; sol::function* onObjSeen = nullptr; -sol::function* onObjSeen = nullptr; sol::function* onUnitsDesertCrusade = nullptr; sol::function* onArmyTakesCrusadeTarget = nullptr; sol::function* onTransgression = nullptr; @@ -1015,7 +1014,6 @@ sol::function* onDiplomacyMission = nullptr; sol::function* onLeaderOrderedDiplomacy = nullptr; sol::function* onLeaderMissionSuccess = nullptr; sol::function* onLeaderMissionFailed = nullptr; -sol::function* onForgiveness = nullptr; sol::function* onSettlementTurnStart = nullptr; sol::function* onNewAdmiralCreated = nullptr; sol::function* onUnitTrained = nullptr; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index 57402f2f0..3ced2116f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -153,6 +153,7 @@ class luaP sol::function* onStartSiege = nullptr; sol::function* onSelectWorldpkgdesc = nullptr; sol::function* onfortificationlevelS = nullptr; + sol::function* onChangeTurnNumFunc = nullptr; sol::function* onClickAtTile = nullptr; sol::function* onNewGameStart = nullptr; sol::function* onPluginLoad = nullptr; diff --git a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp index 3269b4cb4..0519ecba6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp @@ -1,10 +1 @@ -#include "religionEvents.h" - - -void onAssassinCaughtAttackingPope(factionStruct* fac) -{ - if (plugData::data.luaAll.onAssassinCaughtAttackingPopeFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onAssassinCaughtAttackingPopeFunc)(fac)); - } -} + \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h index 5d1b44825..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h @@ -1,4 +0,0 @@ -#pragma once -#include "pluginM2TWEOP.h" - -extern "C" PLUGINM2TWEOP_API void onAssassinCaughtAttackingPope(factionStruct * fac); \ No newline at end of file From 0c3844e2dbffbaf99d9e425dc5c7f135efeabb90 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Mon, 2 Oct 2023 10:20:10 +0300 Subject: [PATCH 06/22] final fixes --- M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj | 4 +- M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 27 +++++----- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 50 +++++++++++++++++-- .../luaPlugin/battleHandlerHelpers.cpp | 4 +- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 15 +++--- 5 files changed, 73 insertions(+), 27 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj index cb3006b12..051138d30 100644 --- a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj +++ b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj @@ -96,7 +96,7 @@ Level3 true - SFML_STATIC;WIN32;WIN32_LEAN_AND_MEAN;_DEBUG;%(PreprocessorDefinitions) + SFML_STATIC;WIN32;WIN32_LEAN_AND_MEAN;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;_DEBUG;%(PreprocessorDefinitions) true stdcpplatest $(SolutionDir)\3rd\sfml\include;..\3rd\glfw\include;%(AdditionalIncludeDirectories) @@ -119,7 +119,7 @@ true true true - SFML_STATIC;WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;%(PreprocessorDefinitions) + SFML_STATIC;WIN32;WIN32_LEAN_AND_MEAN;NDEBUG;_SILENCE_ALL_CXX23_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) true stdcpplatest $(SolutionDir)\3rd\sfml\include;..\3rd\glfw\include;%(AdditionalIncludeDirectories) diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index 7dd833460..9a67fee7f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -462,15 +462,6 @@ namespace gameEvents newCode[0] = 0x01370B34; newCode[1] = 0x0132BB0C; addEvent(newCode[gv], "onPreBattlePanelOpen"); - newCode[0] = 0x01370E9C; newCode[1] = 0x0132BE74; - addEvent(newCode[gv], "onIncomingMessage"); - - newCode[0] = 0x01370F64; newCode[1] = 0x0132BF3C; - addEvent(newCode[gv], "onMessageOpen"); - - newCode[0] = 0x0137102C; newCode[1] = 0x0132C004; - addEvent(newCode[gv], "onMessageClosed"); - newCode[0] = 0x01371364; newCode[1] = 0x0132C33C; addEvent(newCode[gv], "onDeclineAutomatedSettlementManagement"); @@ -546,15 +537,17 @@ namespace gameEvents newCode[0] = 0x0136EBB4; newCode[1] = 0x01329B8C; addEvent(newCode[gv], "onAddedToTrainingQueue"); - newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; - addEvent(newCode[gv], "onBuildingCompleted"); - newCode[0] = 0x013715AC; newCode[1] = 0x0132C584; addEvent(newCode[gv], "onRequestBuildingAdvice"); newCode[0] = 0x01371664; newCode[1] = 0x0132C63C; addEvent(newCode[gv], "onRequestTrainingAdvice"); + + //buildingCompletedEvents + newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; + addEvent(newCode[gv], "onBuildingCompleted"); + //agentCreatedEvent newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; addEvent(newCode[gv], "onAgentCreated"); @@ -660,6 +653,16 @@ namespace gameEvents newCode[0] = 0x01371144; newCode[1] = 0x0132C11C; addEvent(newCode[gv], "onAdviceSupressed"); + //closeMessageEvents + newCode[0] = 0x0137102C; newCode[1] = 0x0132C004; + addEvent(newCode[gv], "onMessageClosed"); + + //factionUiEvents + newCode[0] = 0x01370E9C; newCode[1] = 0x0132BE74; + addEvent(newCode[gv], "onIncomingMessage"); + newCode[0] = 0x01370F64; newCode[1] = 0x0132BF3C; + addEvent(newCode[gv], "onMessageOpen"); + //tileEvents newCode[0] = 0x0136ACCC; newCode[1] = 0x01325CA4; addEvent(newCode[gv], "onTileSeen"); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index 20778312d..190cc977c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -118,7 +118,10 @@ namespace gameEvents namedCharacterRiotEvents = 47, settOccupationEvent = 48, guildEvent = 49, - uiEvent = 50 + uiEvent = 50, + factionUiEvent = 51, + buildingCompletedEvent = 52, + closeMessageEvent = 53 }; class EventBase @@ -149,6 +152,15 @@ namespace gameEvents } return "unknown"; } + static const char* getTypeInteger(int type) + { + const auto charType = characterTypes.find(type); + if (charType != characterTypes.end()) + { + return charType->second; + } + return "unknown"; + } static const regionStruct* getRegion(const namedCharacter* character) { if (character->gen != nullptr) @@ -766,12 +778,12 @@ namespace gameEvents auto character = reinterpret_cast(vTab[1]); factionStruct* faction = character->faction; auto settlement = reinterpret_cast(vTab[2]); - auto build = reinterpret_cast(vTab[3]); + building* building = settlement->buildings[settlement->buildingsNum - 1]; const regionStruct* region = getRegion(character); const char* characterType = getType(character); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { - (*funk)(character, faction, settlement, build, region, characterType, religion); + (*funk)(character, faction, settlement, building, region, characterType, religion); } return 43; } @@ -780,7 +792,7 @@ namespace gameEvents auto character = reinterpret_cast(vTab[1]); factionStruct* faction = character->faction; auto settlement = reinterpret_cast(vTab[3]); - const char* characterType = reinterpret_cast(vTab[2]); + const char* characterType = getTypeInteger(reinterpret_cast(vTab[2])); regionStruct* region = gameHelpers::getRegion(settlement->regionID); const char* religion = getReligion(faction->religion); if (&(*funk) != nullptr) { @@ -864,6 +876,36 @@ namespace gameEvents } return 50; } + else if (EvType == EventType::factionUiEvent) + { + auto faction = reinterpret_cast(vTab[1]); + int name = reinterpret_cast(vTab[2]); + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(faction, religion, name); + } + return 51; + } + else if (EvType == EventType::buildingCompletedEvent) + { + auto faction = reinterpret_cast(vTab[1]); + auto settlement = reinterpret_cast(vTab[2]); + regionStruct* region = gameHelpers::getRegion(settlement->regionID); + building* building = settlement->buildings[settlement->buildingsNum - 1]; + const char* religion = getReligion(faction->religion); + if (&(*funk) != nullptr) { + (*funk)(settlement, faction, building, region, religion); + } + return 52; + } + else if (EvType == EventType::closeMessageEvent) + { + int name = reinterpret_cast(vTab[1]); + if (&(*funk) != nullptr) { + (*funk)(name); + } + return 53; + } else { return 0; diff --git a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp index e2a4f6dd5..60508b8a2 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp @@ -21,11 +21,11 @@ namespace battleHandlerHelpers armyAndCharacter* getBattleArmy(const battleSide* side, int index) { - return side->forces + (sizeof(armyAndCharacter) * index); + return &side->forces[index]; } battleUnit* getBattleUnit(const armyAndCharacter* battleArmy, int index) { - return battleArmy->units + (sizeof(battleUnit) * index); + return &battleArmy->units[index]; } }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index 71bc09fbe..d1bea1cb5 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -491,7 +491,7 @@ void luaP::onPluginLoadF() @tparam factionStruct faction @tparam regionStruct|nil region @tparam string characterType - @tparam string religions + @tparam string religion @usage function onCharacterMarries(namedChar, faction, region, characterType, religion) @@ -2362,7 +2362,7 @@ void luaP::onPluginLoadF() @function onBuildingCompleted @tparam settlementStruct settlement @tparam factionStruct faction - @tparam string buildingName + @tparam building building @tparam regionStruct region @tparam string religion @@ -2825,9 +2825,10 @@ void luaP::onPluginLoadF() @function onIncomingMessage @tparam factionStruct faction @tparam string religion + @tparam int eventid @usage - function onIncomingMessage(faction, religion) + function onIncomingMessage(faction, religion, eventid) --something here end */ @@ -2838,9 +2839,10 @@ void luaP::onPluginLoadF() @function onMessageOpen @tparam factionStruct faction @tparam string religion + @tparam int eventid @usage - function onMessageOpen(faction, religion) + function onMessageOpen(faction, religion, eventid) --something here end */ @@ -2849,11 +2851,10 @@ void luaP::onPluginLoadF() The player has closed a message. @function onMessageClosed - @tparam factionStruct faction - @tparam string religion + @tparam int eventid @usage - function onMessageClosed(faction, religion) + function onMessageClosed(eventid) --something here end */ From 3ea63fe97a5bdb6d8e9f8d817583fc68ffffae51 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Mon, 2 Oct 2023 10:38:11 +0300 Subject: [PATCH 07/22] Update PathMap.cpp --- M2TWEOP Code/M2TWEOP library/PathMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/PathMap.cpp b/M2TWEOP Code/M2TWEOP library/PathMap.cpp index b27ddcf19..5c2797b68 100644 --- a/M2TWEOP Code/M2TWEOP library/PathMap.cpp +++ b/M2TWEOP Code/M2TWEOP library/PathMap.cpp @@ -176,7 +176,7 @@ namespace PathFinder { settlementStruct* set = (settlementStruct*)endObj; - if (set->ownerFac->dipNum == army->faction->dipNum) + if (set->faction->dipNum == army->faction->dipNum) { return true; } @@ -497,7 +497,7 @@ namespace PathFinder { settlementStruct* set = (settlementStruct*)endObj; - if (set->ownerFac->dipNum == army->faction->dipNum) + if (set->faction->dipNum == army->faction->dipNum) { if (set->army == nullptr) { From fc0ebcd959d4beea01f6263bcad3a69af736690a Mon Sep 17 00:00:00 2001 From: FynnTW Date: Mon, 2 Oct 2023 10:40:30 +0300 Subject: [PATCH 08/22] toolset fix for older vs --- M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj | 8 ++++---- M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj | 8 ++++---- M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj | 8 ++++---- M2TWEOP Code/d3d9/d3d9.vcxproj | 4 ++-- M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj index 5c2703135..a2b6997cf 100644 --- a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj +++ b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj @@ -29,26 +29,26 @@ Application true - v143 + v142 MultiByte Application false - v143 + v142 true MultiByte Application true - v143 + v142 Unicode Application false - v143 + v142 true Unicode diff --git a/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj b/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj index e3a1be474..f74c558c6 100644 --- a/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj +++ b/M2TWEOP Code/M2TWEOP library/M2TWEOP library.vcxproj @@ -29,14 +29,14 @@ DynamicLibrary true - v143 + v142 Unicode false DynamicLibrary false - v143 + v142 true Unicode false @@ -44,13 +44,13 @@ DynamicLibrary true - v143 + v142 Unicode DynamicLibrary false - v143 + v142 true Unicode diff --git a/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj b/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj index 73315b743..24c7c2d64 100644 --- a/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj +++ b/M2TWEOP Code/M2TWEOP tools/M2TWEOP tools.vcxproj @@ -29,26 +29,26 @@ Application true - v143 + v142 MultiByte Application false - v143 + v142 true MultiByte Application true - v143 + v142 Unicode Application false - v143 + v142 true Unicode diff --git a/M2TWEOP Code/d3d9/d3d9.vcxproj b/M2TWEOP Code/d3d9/d3d9.vcxproj index fc901abf5..1219dfd45 100644 --- a/M2TWEOP Code/d3d9/d3d9.vcxproj +++ b/M2TWEOP Code/d3d9/d3d9.vcxproj @@ -21,14 +21,14 @@ DynamicLibrary true MultiByte - v143 + v142 false DynamicLibrary false MultiByte - v143 + v142 false diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj b/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj index 01ba277f3..05b46cdec 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj +++ b/M2TWEOP-luaPlugin/luaPlugin/luaPlugin.vcxproj @@ -29,26 +29,26 @@ DynamicLibrary true - v143 + v142 Unicode DynamicLibrary false - v143 + v142 true Unicode DynamicLibrary true - v143 + v142 Unicode DynamicLibrary false - v143 + v142 true Unicode From ff8db543a317018b8dc68127402dd18a3d7cff92 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Mon, 2 Oct 2023 21:59:21 +0300 Subject: [PATCH 09/22] inject for unitwrapper function maybe fix eop mercs crashing rebel garrison and give settlement generation --- M2TWEOP Code/M2TWEOP library/Injects.cpp | 74 +++++++++++++++++++ M2TWEOP Code/M2TWEOP library/Injects.h | 13 ++++ M2TWEOP Code/M2TWEOP library/managerF.cpp | 6 ++ M2TWEOP Code/M2TWEOP library/onlineThings.cpp | 2 +- .../M2TWEOP library/patchesForGame.cpp | 11 +++ M2TWEOP Code/M2TWEOP library/patchesForGame.h | 1 + M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 11 ++- 7 files changed, 116 insertions(+), 2 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/Injects.cpp b/M2TWEOP Code/M2TWEOP library/Injects.cpp index 7600326d2..55f98ab46 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.cpp +++ b/M2TWEOP Code/M2TWEOP library/Injects.cpp @@ -3105,6 +3105,80 @@ void OnCreateMercUnit::SetNewCode() delete a; } +OnCreateUnitWrapper::OnCreateUnitWrapper(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x008EC39F; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x008EC39F; + } +} + +OnCreateUnitWrapper::~OnCreateUnitWrapper() +{ +} + +void OnCreateUnitWrapper::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnCreateUnitWrapper::SetNewCode() +{ + Assembler* a = new Assembler(); + auto skip = a->newLabel(); + auto skip2 = a->newLabel(); + + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + + a->pushf(); + + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + a->lea(esi, dword_ptr(eax)); + + a->popf(); + + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + a->pushf(); + a->cmp(esi, 0); + a->je(skip); + + a->mov(eax, dword_ptr(esi, 0x3C)); + + a->bind(skip); + a->cmp(esi, 0); + a->jne(skip2); + a->mov(eax, 0x10); + + a->bind(skip2); + a->popf(); + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + OnQuickSave::OnQuickSave(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { diff --git a/M2TWEOP Code/M2TWEOP library/Injects.h b/M2TWEOP Code/M2TWEOP library/Injects.h index 7cef08b0a..97cd48bd8 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.h +++ b/M2TWEOP Code/M2TWEOP library/Injects.h @@ -806,6 +806,19 @@ class OnCreateMercUnit DWORD otherFunc; }; +class OnCreateUnitWrapper + :public AATemplate +{ +public: + OnCreateUnitWrapper(MemWork* mem, LPVOID addr, int ver); + ~OnCreateUnitWrapper(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + class OnCreateMercUnitCheck :public AATemplate { diff --git a/M2TWEOP Code/M2TWEOP library/managerF.cpp b/M2TWEOP Code/M2TWEOP library/managerF.cpp index f9628866a..1f2f54dc4 100644 --- a/M2TWEOP Code/M2TWEOP library/managerF.cpp +++ b/M2TWEOP Code/M2TWEOP library/managerF.cpp @@ -471,6 +471,12 @@ void managerF::doPachs() toCreateMercUnit->Enable(); f1 << "Done" << endl; + f1 << "Start applying OnCreateUnitWrapper patch" << endl; + OnCreateUnitWrapper* toCreateUnitWrapper = new OnCreateUnitWrapper(mem, (LPVOID)patchesForGame::OnCreateUnitWrapper, globals::dataS.gamever); + toCreateUnitWrapper->SetNewCode(); + toCreateUnitWrapper->Enable(); + f1 << "Done" << endl; + f1 << "Start applying toCreateMercUnitCheck patch" << endl; OnCreateMercUnitCheck* toCreateMercUnitCheck = new OnCreateMercUnitCheck(mem, (LPVOID)patchesForGame::OnCreateMercUnitCheck, globals::dataS.gamever); diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp index 3d384b85c..d4b74a2d1 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp @@ -51,7 +51,7 @@ namespace battleCreator { json.at("enableAutoGeneration").get_to(data.isGenerationNeeded); json.at("enableResultsTransfer").get_to(data.isResultTransferNeeded); - json.at("isPlannedRetreatRoute").get_to(data.isPlannedRetreatRoute); + //json.at("isPlannedRetreatRoute").get_to(data.isPlannedRetreatRoute); } catch (jsn::json::type_error& e) { diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp index 2bba2d47e..fd64f5859 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp @@ -139,6 +139,17 @@ eduEntry* __fastcall patchesForGame::OnCreateMercUnit(char** entryName, eduEntry return entry; } + +eduEntry* __fastcall patchesForGame::OnCreateUnitWrapper(int eduindexBase, int removeValue) +{ + int eduindex = eduindexBase - (removeValue * 8); + eduEntry* entry = eduThings::getEduEntry(eduindex); + if (entry == nullptr) + { + entry = eduThings::getEopEduEntry(eduindex); + } + return entry; +} const char* __fastcall patchesForGame::onQuickSave() { static std::vector saveNames = { u8"%S-1.sav" ,u8"%S-2.sav", u8"%S-3.sav" }; diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.h b/M2TWEOP Code/M2TWEOP library/patchesForGame.h index 942823db0..9d454ecb7 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.h +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.h @@ -15,6 +15,7 @@ class patchesForGame static int __fastcall onCreateUnit(int* edbIndex, int** edb, char** entryName); static int __fastcall OnCreateMercUnitCheck(char** entryName, int eduindex); static eduEntry* __fastcall OnCreateMercUnit(char** entryName, eduEntry* entry); + static eduEntry* __fastcall OnCreateUnitWrapper(int eduindexBase, int removeValue); static const char* __fastcall onQuickSave(); static const char* __fastcall onAutoSave(); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index 190cc977c..e1bf8a806 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -61,6 +61,14 @@ std::unordered_map missionSuccessLvl = { }; std::unordered_map religionNames = { }; + +struct crusade +{ +public: + char pad_0x0000[60]; //0x0000 + settlementStruct* targetSettlement; //0x003C +}; + void checkLuaFunc(sol::function** lRef); void initReligionNames(); namespace gameEvents @@ -545,7 +553,8 @@ namespace gameEvents { auto character = reinterpret_cast(vTab[1]); factionStruct* faction = character->faction; - auto targetSettlement = reinterpret_cast(vTab[2] + 0x3C); + auto crusadeActive = reinterpret_cast(vTab[2]); + auto targetSettlement = crusadeActive->targetSettlement; factionStruct* targetFaction = targetSettlement->faction; regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); const char* characterType = getType(character); From 9083c4588705fa201750b629a0953bfa9915f1f4 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Mon, 2 Oct 2023 22:04:41 +0300 Subject: [PATCH 10/22] disk offset --- M2TWEOP Code/M2TWEOP library/Injects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/M2TWEOP Code/M2TWEOP library/Injects.cpp b/M2TWEOP Code/M2TWEOP library/Injects.cpp index 55f98ab46..b57af75ce 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.cpp +++ b/M2TWEOP Code/M2TWEOP library/Injects.cpp @@ -3114,7 +3114,7 @@ OnCreateUnitWrapper::OnCreateUnitWrapper(MemWork* mem, LPVOID addr, int ver) } else if (ver == 1)//kingdoms { - m_adress = 0x008EC39F; + m_adress = 0x008EB91F; } } From 58047ba94970f316aff5a60b11d0f58670ba0138 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 3 Oct 2023 13:37:55 +0300 Subject: [PATCH 11/22] auto select cfg launcher update --- M2TWEOP Code/M2TWEOP GUI/helpers.cpp | 102 +++++++++++++++++++-- M2TWEOP Code/M2TWEOP GUI/helpers.h | 10 ++ M2TWEOP Code/M2TWEOP GUI/main.cpp | 13 +++ M2TWEOP Code/M2TWEOP GUI/modSettingsUI.cpp | 58 +++++++++++- 4 files changed, 172 insertions(+), 11 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp index 9d6e58844..95205766e 100644 --- a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp @@ -356,18 +356,108 @@ bool helpers::compareFiles(string& oneFile, string& nextFile) return true; } -void helpers::getCurrentPath(string& path) +void helpers::setModFolder(string& modFolder) { TCHAR currentPath[MAX_PATH] = { 0 }; DWORD ret = GetCurrentDirectoryA(MAX_PATH, currentPath); - path = currentPath; + modFolder = currentPath; + size_t pos = modFolder.find_last_of("\\/")+1; + modFolder = modFolder.substr(pos); } -void helpers::setModFolder(string& modFolder) +void helpers::getCurrentPath(string& path) { TCHAR currentPath[MAX_PATH] = { 0 }; DWORD ret = GetCurrentDirectoryA(MAX_PATH, currentPath); - modFolder = currentPath; - size_t pos = modFolder.find_last_of("\\/")+1; - modFolder = modFolder.substr(pos); + path = currentPath; +} + +vector helpers::getCfgFilesInFolder() +{ + string path; + getCurrentPath(path); + path += "\\*.cfg"; + + WIN32_FIND_DATAA findFileData; + HANDLE hFind = FindFirstFileA(path.c_str(), &findFileData); + + std::vector cfgFiles; + + if (hFind != INVALID_HANDLE_VALUE) + { + do { + const std::string name = findFileData.cFileName; + + if (!(findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + string currentPath; + getCurrentPath(currentPath); + if (checkCfgFileForMod(currentPath + "\\" + name) != "") + { + cfgFiles.push_back(name); + } + } + + } while (FindNextFileA(hFind, &findFileData) != 0); + + FindClose(hFind); + } + + return cfgFiles; +} + +std::string helpers::checkCfgFileForMod(const std::string& filePath) +{ + std::ifstream file(filePath); + if (!file.is_open()) + return ""; + + std::string line; + while (std::getline(file, line)) + { + line.erase(std::remove_if(line.begin(), line.end(), ::isspace), line.end()); + + if (line.find("mod=") == 0) + return extractModPathFromLine(line); + } + + return ""; +} + +std::vector helpers::split(const std::string& s, char delimiter) +{ + std::vector tokens; + std::string token; + std::istringstream tokenStream(s); + while (std::getline(tokenStream, token, delimiter)) + { + tokens.push_back(token); + } + return tokens; +} + +bool helpers::verifyModPath(const std::string& modPath) +{ + string currentPath; + getCurrentPath(currentPath); + auto modPathDirs = split(modPath, '\\'); + auto currentPathDirs = split(currentPath, '\\'); + + if (currentPathDirs.size() < 2) + return false; + + std::string lastDir = currentPathDirs[currentPathDirs.size() - 1]; + std::string secondLastDir = currentPathDirs[currentPathDirs.size() - 2]; + std::string expectedPath = secondLastDir + "\\" + lastDir; + + return modPath == expectedPath; +} + +std::string helpers::extractModPathFromLine(const std::string& line) +{ + size_t pos = line.find("mod="); + if (pos == std::string::npos) + return ""; + + return line.substr(pos + 4); } diff --git a/M2TWEOP Code/M2TWEOP GUI/helpers.h b/M2TWEOP Code/M2TWEOP GUI/helpers.h index a29f4a519..e7c3868ef 100644 --- a/M2TWEOP Code/M2TWEOP GUI/helpers.h +++ b/M2TWEOP Code/M2TWEOP GUI/helpers.h @@ -10,6 +10,16 @@ class helpers static void closeGame(const string& exeName); + static vector getCfgFilesInFolder(); + + static std::string checkCfgFileForMod(const std::string& filePath); + + static std::vector split(const std::string& s, char delimiter); + + static bool verifyModPath(const std::string& modPath); + + static std::string extractModPathFromLine(const std::string& line); + static void updateMetrics(); static screenS& getScreen(); diff --git a/M2TWEOP Code/M2TWEOP GUI/main.cpp b/M2TWEOP Code/M2TWEOP GUI/main.cpp index 5573271b2..762b1f100 100644 --- a/M2TWEOP Code/M2TWEOP GUI/main.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/main.cpp @@ -206,6 +206,19 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine } } } + + + std::vector cfgFiles = helpers::getCfgFilesInFolder(); + std::vector items; + for (const auto& file : cfgFiles) { + items.push_back(file.c_str()); + } + if (dataG::data.modData.configName == "" && items.size() > 0) + { + dataG::data.modData.configName = items[0]; + dataG::data.modData.useVanillaConfig = false; + managerG::saveJsonSettings(); + } // Main loop runApp(toolRoutine::drawTick); diff --git a/M2TWEOP Code/M2TWEOP GUI/modSettingsUI.cpp b/M2TWEOP Code/M2TWEOP GUI/modSettingsUI.cpp index 5721ff3d0..bc252c8cb 100644 --- a/M2TWEOP Code/M2TWEOP GUI/modSettingsUI.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/modSettingsUI.cpp @@ -34,14 +34,12 @@ namespace modSettingsUI ImVec2 selectablesSize{}; }settingsUIData; - - + void initSettingsUI() { settingsUIData.settingsPages.clear(); - //main page { settingsPage generalPage; @@ -92,15 +90,56 @@ namespace modSettingsUI void drawGeneralSettings() { + + //ImGui::InputText("Config file name", &dataG::data.modData.configName); + + std::vector cfgFiles = helpers::getCfgFilesInFolder(); + std::vector items; + for (const auto& file : cfgFiles) { + items.push_back(file.c_str()); + } + string path; + helpers::getCurrentPath(path); + static int selectedItem = -1; + if (items.size() == 0) + { + dataG::data.modData.useVanillaConfig = true; + } + else + { + if (dataG::data.modData.configName == "") + { + dataG::data.modData.configName = items[0]; + dataG::data.modData.useVanillaConfig = false; + selectedItem = 0; + } + else + { + for (const auto& file : items) { + if (file == dataG::data.modData.configName) + { + selectedItem = std::distance(items.begin(), std::find(items.begin(), items.end(), file)); + dataG::data.modData.configName = items[selectedItem]; + dataG::data.modData.useVanillaConfig = false; + break; + } + } + } + } if (dataG::data.modData.useVanillaConfig == true) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); } - ImVec2 textSize = ImGui::CalcTextSize("Readme Teutonic"); ImGui::PushItemWidth(textSize.x); - ImGui::InputText("Config file name", &dataG::data.modData.configName); + ImGui::Combo("Config Files", &selectedItem, &items[0], items.size()); + + if (selectedItem != -1) + { + dataG::data.modData.configName = items[selectedItem]; + dataG::data.modData.useVanillaConfig = false; + } if (dataG::data.modData.useVanillaConfig == true) { @@ -112,6 +151,15 @@ namespace modSettingsUI ImGui::Checkbox("Use standard config", &dataG::data.modData.useVanillaConfig); ImGui::NewLine(); + + if (!helpers::verifyModPath(helpers::checkCfgFileForMod(path + "\\" + dataG::data.modData.configName))) + { + // Warn the user + if (dataG::data.modData.useVanillaConfig == false) + { + ImGui::Text("Warning: Mod path in %s does not match the current directory.", dataG::data.modData.configName.c_str()); + } + } ImGui::Checkbox("Use M2TWEOP", &dataG::data.modData.useM2TWEOP); ImGui::Checkbox("Hide launcher on startup", &dataG::data.modData.hideLauncherAtStart); From 5c308f136f5fe9838807e412c5aea5bde8e684b9 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 3 Oct 2023 14:39:58 +0300 Subject: [PATCH 12/22] fix gameevent --- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index e1bf8a806..1ff16bb0e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -207,7 +207,7 @@ namespace gameEvents else if (EvType == EventType::gameEvent) { if (&(*funk) != nullptr) { - return (*funk)(); + (*funk)(); } return 2; } From 4a5563927027b29b8307905d93ee0e002acdae37 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 3 Oct 2023 15:29:45 +0300 Subject: [PATCH 13/22] small event fixes and make verify mod path case and slash insensitive --- M2TWEOP Code/M2TWEOP GUI/helpers.cpp | 6 + M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 14 +- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 184 +++++++++----------- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 6 +- 4 files changed, 96 insertions(+), 114 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp index 95205766e..6e0c1598d 100644 --- a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp @@ -449,6 +449,12 @@ bool helpers::verifyModPath(const std::string& modPath) std::string lastDir = currentPathDirs[currentPathDirs.size() - 1]; std::string secondLastDir = currentPathDirs[currentPathDirs.size() - 2]; std::string expectedPath = secondLastDir + "\\" + lastDir; + std::replace(expectedPath.begin(), expectedPath.end(), '/', '\\'); + std::replace(expectedPath.begin(), expectedPath.end(), ' ', ''); + std::replace(modPath.begin(), modPath.end(), '/', '\\'); + std::replace(modPath.begin(), modPath.end(), ' ', ''); + std::transform(expectedPath.begin(), expectedPath.end(), expectedPath.begin(), ::tolower); + std::transform(modPath.begin(), modPath.end(), modPath.begin(), ::tolower); return modPath == expectedPath; } diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index d5876c103..22e4dd1cd 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -376,6 +376,12 @@ namespace gameEvents newCode[0] = 0x013D2074; newCode[1] = 0x0138CE0C; addEvent(newCode[gv], "onDiplomaticStandingPanelOpen"); + newCode[0] = 0x01368FCC; newCode[1] = 0x0132355C; + addEvent(newCode[gv], "onBattleWinningCombat"); + + newCode[0] = 0x01368F14; newCode[1] = 0x01323EEC; + addEvent(newCode[gv], "onBattleArmyTired"); + //crusadeEvents newCode[0] = 0x013321D4; newCode[1] = 0x012ED1B4; addEvent(newCode[gv], "onCrusadeCalled"); @@ -585,14 +591,6 @@ namespace gameEvents newCode[0] = 0x013684A4; newCode[1] = 0x0132347C; addEvent(newCode[gv], "onBattlePlayerUnderAttackIdle"); - //battleArmyFromUnitEvent - newCode[0] = 0x01368FCC; newCode[1] = 0x0132355C; - addEvent(newCode[gv], "onBattleWinningCombat"); - - //battleArmyFromUnitEvent2 - newCode[0] = 0x01368F14; newCode[1] = 0x01323EEC; - addEvent(newCode[gv], "onBattleArmyTired"); - //battlePlayerUnitEvents newCode[0] = 0x0136718C; newCode[1] = 0x01322164; addEvent(newCode[gv], "onBattlePlayerUnitAttacksEnemyUnit"); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index 1ff16bb0e..3e114ee2e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -87,49 +87,47 @@ namespace gameEvents battlePlayerUnitEvent = 8, battleAiUnitEvent = 9, battlePlayerArmyUnitEvent = 10, - battleArmyFromUnitEvent = 11, - battleArmyFromUnitEvent2 = 12, - battleUnitEvent = 13, - armyEvent = 14, - characterEvent = 15, - battleUnitEvent2 = 16, - diplomacyEvent = 17, - diplomacyMoneyEvent = 18, - namedCharacterTargetSettEvent = 19, - disasterEvent = 20, - namedCharacterDisasterEvent = 21, - eventCounterEvent = 22, - namedCharacterTargetCharEvent = 23, - fortEvent = 24, - tileEvent = 25, - objEvent = 26, - factionCrusadeEvent = 27, - crusadeTargetEvent = 28, - transgressionEvent = 29, - stratUnitEvent = 30, - namedCharacterSettEvent = 31, - namedCharacterCrusadeEvent = 32, - ransomEvent = 33, - spyMissionEvent = 34, - orderSpyMissionEvent = 35, - agentMissionEvent = 36, - orderKillMissionEvent = 37, - diplomacyMissionEvent = 38, - missionEvent = 39, - settlementEvent = 40, - stratUnitSettEvent = 41, - characterUnitSettEvent = 42, - characterBuildingEvent = 43, - agentCreatedEvent = 44, - buildingEvent = 45, - targetSettlementEvent = 46, - namedCharacterRiotEvents = 47, - settOccupationEvent = 48, - guildEvent = 49, - uiEvent = 50, - factionUiEvent = 51, - buildingCompletedEvent = 52, - closeMessageEvent = 53 + battleUnitEvent = 11, + armyEvent = 12, + characterEvent = 13, + battleUnitEvent2 = 14, + diplomacyEvent = 15, + diplomacyMoneyEvent = 16, + namedCharacterTargetSettEvent = 17, + disasterEvent = 18, + namedCharacterDisasterEvent = 19, + eventCounterEvent = 20, + namedCharacterTargetCharEvent = 21, + fortEvent = 22, + tileEvent = 23, + objEvent = 24, + factionCrusadeEvent = 25, + crusadeTargetEvent = 26, + transgressionEvent = 27, + stratUnitEvent = 28, + namedCharacterSettEvent = 29, + namedCharacterCrusadeEvent = 30, + ransomEvent = 31, + spyMissionEvent = 32, + orderSpyMissionEvent = 33, + agentMissionEvent = 34, + orderKillMissionEvent = 35, + diplomacyMissionEvent = 36, + missionEvent = 37, + settlementEvent = 38, + stratUnitSettEvent = 39, + characterUnitSettEvent = 40, + characterBuildingEvent = 41, + agentCreatedEvent = 42, + buildingEvent = 43, + targetSettlementEvent = 44, + namedCharacterRiotEvents = 45, + settOccupationEvent = 46, + guildEvent = 47, + uiEvent = 48, + factionUiEvent = 49, + buildingCompletedEvent = 50, + closeMessageEvent = 51 }; class EventBase @@ -287,31 +285,13 @@ namespace gameEvents } return 10; } - else if (EvType == EventType::battleArmyFromUnitEvent) - { - auto playerUnit = reinterpret_cast(vTab[1]); - stackStruct* army = playerUnit->army; - if (&(*funk) != nullptr) { - (*funk)(army); - } - return 11; - } - else if (EvType == EventType::battleArmyFromUnitEvent2) - { - auto playerUnit = reinterpret_cast(vTab[2]); - stackStruct* army = playerUnit->army; - if (&(*funk) != nullptr) { - (*funk)(army); - } - return 12; - } else if (EvType == EventType::battleUnitEvent) { auto playerUnit = reinterpret_cast(vTab[1]); if (&(*funk) != nullptr) { (*funk)(playerUnit); } - return 13; + return 11; } else if (EvType == EventType::armyEvent) { @@ -319,7 +299,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(army); } - return 14; + return 12; } else if (EvType == EventType::characterEvent) { @@ -328,7 +308,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(gen, namedChar); } - return 15; + return 13; } else if (EvType == EventType::battleUnitEvent2) { @@ -336,7 +316,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(playerUnit); } - return 16; + return 14; } else if (EvType == EventType::diplomacyEvent) { @@ -347,7 +327,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, religion, targetFaction, targetReligion); } - return 17; + return 15; } else if (EvType == EventType::diplomacyMoneyEvent) { @@ -359,7 +339,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, religion, targetFaction, targetReligion, amount); } - return 18; + return 16; } else if (EvType == EventType::namedCharacterTargetSettEvent) { @@ -387,7 +367,7 @@ namespace gameEvents (*funk)(character, fort, faction, targetFaction, region, characterType, religion, targetReligion, true); } } - return 19; + return 17; } else if (EvType == EventType::disasterEvent) { @@ -398,7 +378,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(eventType); } - return 20; + return 18; } else if (EvType == EventType::namedCharacterDisasterEvent) { @@ -414,7 +394,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(eventType, character, faction, region, characterType, religion); } - return 21; + return 19; } else if (EvType == EventType::eventCounterEvent) { @@ -423,7 +403,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(counter); } - return 22; + return 20; } else if (EvType == EventType::namedCharacterTargetCharEvent) { @@ -440,7 +420,7 @@ namespace gameEvents (*funk)(character, targetCharacter, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion); } - return 23; + return 21; } else if (EvType == EventType::fortEvent) { @@ -451,7 +431,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(fort, faction, region, religion); } - return 24; + return 22; } else if (EvType == EventType::tileEvent) { @@ -463,7 +443,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, x, y, region, religion); } - return 25; + return 23; } else if (EvType == EventType::objEvent) { @@ -476,7 +456,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, targetFaction, x, y, region, religion); } - return 26; + return 24; } else if (EvType == EventType::factionCrusadeEvent) { @@ -489,7 +469,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(targetSettlement, faction, targetFaction, targetRegion, religion, targetReligion); } - return 27; + return 25; } else if (EvType == EventType::factionCrusadeEvent) { @@ -503,7 +483,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(targetSettlement, army, faction, targetFaction, targetRegion, religion, targetReligion); } - return 28; + return 26; } else if (EvType == EventType::transgressionEvent) { @@ -515,7 +495,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, targetFaction, transgression, religion, targetReligion); } - return 29; + return 27; } else if (EvType == EventType::stratUnitEvent) { @@ -526,7 +506,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, playerUnit, edu, religion); } - return 30; + return 28; } else if (EvType == EventType::namedCharacterSettEvent) { @@ -547,7 +527,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, settlement, faction, region, characterType, religion); } - return 31; + return 29; } else if (EvType == EventType::namedCharacterCrusadeEvent) { @@ -563,7 +543,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion); } - return 32; + return 30; } else if (EvType == EventType::ransomEvent) { @@ -582,7 +562,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion); } - return 33; + return 31; } else if (EvType == EventType::spyMissionEvent) { @@ -618,7 +598,7 @@ namespace gameEvents (*funk)(character, missionSuccess, missionProbability, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); } } - return 34; + return 32; } else if (EvType == EventType::orderSpyMissionEvent) { @@ -653,7 +633,7 @@ namespace gameEvents (*funk)(character, missionSuccess, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); } } - return 35; + return 33; } else if (EvType == EventType::agentMissionEvent) { @@ -672,7 +652,7 @@ namespace gameEvents (*funk)(character, missionSuccess, missionProbability, faction, region, characterType, religion); } - return 36; + return 34; } else if (EvType == EventType::orderKillMissionEvent) { @@ -691,7 +671,7 @@ namespace gameEvents (*funk)(character, missionSuccess, targetCharacter, faction, region, characterType, religion); } - return 37; + return 35; } else if (EvType == EventType::diplomacyMissionEvent) { @@ -711,7 +691,7 @@ namespace gameEvents (*funk)(character, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion); } - return 38; + return 36; } else if (EvType == EventType::missionEvent) { @@ -726,7 +706,7 @@ namespace gameEvents (*funk)(character, faction, missionName, region, characterType, religion); } - return 39; + return 37; } else if (EvType == EventType::settlementEvent) { @@ -753,7 +733,7 @@ namespace gameEvents (*funk)(fort, faction, region, religion); } } - return 40; + return 38; } else if (EvType == EventType::stratUnitSettEvent) { @@ -765,7 +745,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, settlement, playerUnit, edu, religion); } - return 41; + return 39; } else if (EvType == EventType::characterUnitSettEvent) { @@ -780,7 +760,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, settlement, playerUnit, edu, region, characterType, religion); } - return 42; + return 40; } else if (EvType == EventType::characterBuildingEvent) { @@ -794,7 +774,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, settlement, building, region, characterType, religion); } - return 43; + return 41; } else if (EvType == EventType::agentCreatedEvent) { @@ -807,7 +787,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, settlement, region, characterType, religion); } - return 44; + return 42; } else if (EvType == EventType::buildingEvent) { @@ -819,7 +799,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(settlement, faction, build, region, religion); } - return 45; + return 43; } else if (EvType == EventType::targetSettlementEvent) { @@ -832,7 +812,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(settlement, faction, region, religion, targetFaction, targetReligion); } - return 46; + return 44; } else if (EvType == EventType::namedCharacterRiotEvents) { @@ -846,7 +826,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, settlement, region, religion, targetFaction, targetReligion); } - return 47; + return 45; } else if (EvType == EventType::settOccupationEvent) { @@ -859,7 +839,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(character, faction, region, religion, targetFaction, targetReligion); } - return 48; + return 46; } else if (EvType == EventType::guildEvent) { @@ -873,7 +853,7 @@ namespace gameEvents (*funk)(settlement, faction, region, religion, guild_handler); } - return 49; + return 47; } else if (EvType == EventType::uiEvent) { @@ -883,7 +863,7 @@ namespace gameEvents (*funk)(name); } - return 50; + return 48; } else if (EvType == EventType::factionUiEvent) { @@ -893,7 +873,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(faction, religion, name); } - return 51; + return 49; } else if (EvType == EventType::buildingCompletedEvent) { @@ -905,7 +885,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(settlement, faction, building, region, religion); } - return 52; + return 50; } else if (EvType == EventType::closeMessageEvent) { @@ -913,7 +893,7 @@ namespace gameEvents if (&(*funk) != nullptr) { (*funk)(name); } - return 53; + return 51; } else { diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index d1bea1cb5..6ec997a20 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -2095,10 +2095,9 @@ void luaP::onPluginLoadF() A team has gained the advantage in combat. @function onBattleWinningCombat - @tparam stackStruct army @usage - function onBattleWinningCombat(army) + function onBattleWinningCombat() --something here end */ @@ -2107,10 +2106,9 @@ void luaP::onPluginLoadF() The whole army is tired. @function onBattleArmyTired - @tparam stackStruct army @usage - function onBattleArmyTired(army) + function onBattleArmyTired() --something here end */ From 9db374f31fcdff26e7a4782a28d8fb0f15c5bf6a Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 3 Oct 2023 18:25:55 +0300 Subject: [PATCH 14/22] ignore comments for mod verify and fix doc string --- M2TWEOP Code/M2TWEOP GUI/helpers.cpp | 21 ++++++++++++++++----- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 1 - 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp index 6e0c1598d..cb09e0fe1 100644 --- a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp @@ -446,17 +446,28 @@ bool helpers::verifyModPath(const std::string& modPath) if (currentPathDirs.size() < 2) return false; + std::string modPathCheck = modPath + ""; + + size_t pos = modPathCheck.find("#"); + if (pos != std::string::npos) + { + modPathCheck = modPathCheck.substr(0, pos); + } + pos = modPathCheck.find(";"); + if (pos != std::string::npos) + { + modPathCheck = modPathCheck.substr(0, pos); + } + std::string lastDir = currentPathDirs[currentPathDirs.size() - 1]; std::string secondLastDir = currentPathDirs[currentPathDirs.size() - 2]; std::string expectedPath = secondLastDir + "\\" + lastDir; std::replace(expectedPath.begin(), expectedPath.end(), '/', '\\'); - std::replace(expectedPath.begin(), expectedPath.end(), ' ', ''); - std::replace(modPath.begin(), modPath.end(), '/', '\\'); - std::replace(modPath.begin(), modPath.end(), ' ', ''); + std::replace(modPathCheck.begin(), modPathCheck.end(), '/', '\\'); std::transform(expectedPath.begin(), expectedPath.end(), expectedPath.begin(), ::tolower); - std::transform(modPath.begin(), modPath.end(), modPath.begin(), ::tolower); + std::transform(modPathCheck.begin(), modPathCheck.end(), modPathCheck.begin(), ::tolower); - return modPath == expectedPath; + return modPathCheck == expectedPath; } std::string helpers::extractModPathFromLine(const std::string& line) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 340e7e953..35f16890b 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -363,7 +363,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) /*** * Sets the new maximum amount of building levels within a chain. - * WARNING: This function may be bugged -> https://github.com/youneuoy/M2TWEOP-library/issues/58 * @function M2TWEOP.setBuildingChainLimit * @tparam int limit default: 9, maximum: 57 * @usage From 8f1cb96e964ec3cbcb6615bc23046dc50393abad Mon Sep 17 00:00:00 2001 From: FynnTW Date: Sun, 8 Oct 2023 01:05:41 +0300 Subject: [PATCH 15/22] expansion of unit and campaign structs --- M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 4 + M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 11 +- M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp | 14 + M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h | 1 + .../luaPlugin/factionHelpers.cpp | 39 ++ M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h | 5 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp | 43 ++ M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h | 6 +- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 233 +++++++- M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 147 ++++- .../luaPlugin/m2tweopHelpers.cpp | 60 +- M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 525 ++++++++++++++++-- .../luaPlugin/stackStructHelpers.cpp | 2 +- M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp | 109 +++- M2TWEOP-luaPlugin/luaPlugin/unitHelpers.h | 24 +- 15 files changed, 1124 insertions(+), 99 deletions(-) diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index 22e4dd1cd..a98011632 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -15,6 +15,10 @@ void onEventWrapper(const DWORD eventAddr, DWORD** vTab, DWORD arg2) void initReligionNames() { const auto* religionDb = *reinterpret_cast (0x016A0B90); + if (m2tweopHelpers::getGameVersion() == 1) + { + religionDb = *reinterpret_cast (0x016E9DC0); + } for (int i = 0; i < religionDb->religionCount; i++) { religionNames[i] = gameHelpers::getReligionName(i); diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index 3e114ee2e..f2cfe2708 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -7,6 +7,8 @@ using namespace std; extern "C" PLUGINM2TWEOP_API void onReadGameDbsAtStart(); extern "C" PLUGINM2TWEOP_API void onEndSiege(int x, int y); extern "C" PLUGINM2TWEOP_API void onStartSiege(int x, int y); +std::unordered_map religionNames = { +}; extern "C" PLUGINM2TWEOP_API void onClickAtTile(int x, int y); @@ -59,15 +61,6 @@ std::unordered_map missionSuccessLvl = { {2,"partly_successful"}, {3,"highly_successful"} }; -std::unordered_map religionNames = { -}; - -struct crusade -{ -public: - char pad_0x0000[60]; //0x0000 - settlementStruct* targetSettlement; //0x003C -}; void checkLuaFunc(sol::function** lRef); void initReligionNames(); diff --git a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp index adc385189..a575cded8 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp @@ -91,6 +91,20 @@ void eopEduHelpers::haveAttributeLegioSet(eduEntry* eduEn, bool isHaveLegio) } } +bool eopEduHelpers::hasAttribute(unit* unit, const char* attributeName) +{ + const auto entry = unit->eduEntry; + const int attributesNum = (reinterpret_cast(entry->EndOfAttributes) - reinterpret_cast(entry->Attributes)) / 8; + for (int i = 0; i < attributesNum; i+= 2) + { + if (strcmp(reinterpret_cast(entry->Attributes[i]), attributeName) == 0) + { + return true; + } + } + return false; +} + int eopEduHelpers::getArmourUpgradeLevelsNum(int idx) { eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); diff --git a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h index 09f02f23a..246322735 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.h @@ -65,6 +65,7 @@ namespace eopEduHelpers int getEntryStat(int idx, UnitEnums::eduStat stat, int sec); void addUnitToRQ(int idx, settlementStruct* sett); int multiplexor(int n1, int n2, int sel); + bool hasAttribute(unit* unit, const char* attributeName); void setEntryLocalizedName(int index, const char* newLocName); void setEntryLocalizedDescr(int index, const char* newLocDescr); diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp index e5232df88..7cc3f190a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp @@ -2,6 +2,8 @@ #include "plugData.h" #include +#include "gameDataAllHelper.h" + std::string factionHelpers::getFactionName(const factionStruct* fac) { return std::string(fac->factSmDescr->facName); @@ -47,6 +49,43 @@ void factionHelpers::deleteFort(const factionStruct* fac, fortStruct* fort) (*(*plugData::data.funcs.deleteFort))(fac, fort); } +bool factionHelpers::hasMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2) +{ + const auto gameData = gameDataAllHelper::get(); + const auto campaign = gameData->campaignData; + const auto agreements = campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade; + return agreements & static_cast(0x2); +} + +void factionHelpers::setMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2, bool set) +{ + const auto gameData = gameDataAllHelper::get(); + const auto campaign = gameData->campaignData; + const auto agreements = campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade; + if (set) + { + campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade = agreements | static_cast(0x2); + } + else + { + campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade = agreements & static_cast(~0x2); + } +} + +float factionHelpers::getFactionStanding(const factionStruct* fac1, const factionStruct* fac2) +{ + const auto gameData = gameDataAllHelper::get(); + const auto campaign = gameData->campaignData; + return campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].factionStanding; +} + +void factionHelpers::setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing) +{ + const auto gameData = gameDataAllHelper::get(); + const auto campaign = gameData->campaignData; + campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].factionStanding = standing; +} + void factionHelpers::createFortXY(const factionStruct* fac, int x, int y) { (*(*plugData::data.funcs.createFortXY))(fac, x, y); diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h index bab2b385b..461ffc176 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h @@ -19,7 +19,10 @@ namespace factionHelpers void createFortXY(const factionStruct* fac, int x, int y); void createFort(const general* gen); void changeFactionName(factionStruct* fac, const char* newName); - + bool hasMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2); + float getFactionStanding(const factionStruct* fac1, const factionStruct* fac2); + void setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing); + void setMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2, bool set); std::string getLocalizedFactionName(factionStruct* fac); //faction diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index 248fe6063..03c45e38e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -336,10 +336,53 @@ namespace gameHelpers (*(*plugData::data.funcs.historicEvent))(name, title, description); } + general* gameHelpers::getCardinal(const collegeOfCardinals* college, const int index) + { + return college->cardinalsArray[index].trackedCharacter->character; + } + + fortStruct* gameHelpers::getFortAll(const campaign* campaign, const int index) + { + return campaign->fortsArray[index]; + } + + portBuildingStruct* gameHelpers::getPortAll(const campaign* campaign, const int index) + { + return campaign->portsBuildings[index]; + } + + watchTowerStruct* gameHelpers::getWatchTowerAll(const campaign* campaign, const int index) + { + return campaign->watchtowers[index]; + } + + settlementStruct* getSettlementByName(campaign* campaign, const char* name) + { + settlementList* settlementList = &campaign->settlementList; + int settNum = 0; + while (settlementList != nullptr) + { + settNum = settlementList->settlementsNum; + for (int i = 0; i < settNum; i++) + { + if (strcmp(settlementList->settlements[i]->name, name) == 0) + { + return settlementList->settlements[i]; + } + } + settlementList = settlementList->nextSettlements; + } + return nullptr; + } const char* getReligionName(const int index) { + const auto* religionDb = *reinterpret_cast (0x016A0B90); + if (m2tweopHelpers::getGameVersion() == 1) + { + religionDb = *reinterpret_cast (0x016E9DC0); + } const wchar_t* name = religionDb->religionNames[index]->string; // Determine the size of the required buffer const int size = WideCharToMultiByte(CP_UTF8, 0, name, -1, nullptr, 0, nullptr, nullptr); diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index 438327db9..df3af8fe6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -31,7 +31,11 @@ namespace gameHelpers void changeRegionName(regionStruct* region, const char* newName); std::string getRegionName(regionStruct* region); void changeRebelsName(regionStruct* region, const char* newName); - + general* getCardinal(const collegeOfCardinals* college, const int index); + fortStruct* getFortAll(const campaign* campaign, const int index); + portBuildingStruct* getPortAll(const campaign* campaign, const int index); + watchTowerStruct* getWatchTowerAll(const campaign* campaign, const int index); + settlementStruct* getSettlementByName(campaign* campaign, const char* name); std::string getRebelsName(regionStruct* region); int getMercUnitNum(mercPool* mercPool); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 35f16890b..743c566e4 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -121,6 +121,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypesiege; sol::usertypebuildingLevel; sol::usertypebattleCameraStruct; + sol::usertypeunitPositionData; }types; luaState = {}; luaPath = modPath + "\\youneuoy_Data\\plugins\\lua"; @@ -165,6 +166,12 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) return nullptr; } + luaState.new_enum( + "unitBattleProperties", + "guardMode", unitHelpers::guardMode, + "fireAtWill", unitHelpers::fireAtWill, + "skirmish", unitHelpers::skirmish + ); //luaState.new_enum( // "buildingCap", @@ -251,6 +258,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getTileVisibility getTileVisibility @tfield getRegionOwner getRegionOwner @tfield setEDUUnitsSize setEDUUnitsSize + @tfield getReligionName getReligionName @table M2TWEOP */ @@ -485,6 +493,15 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) local ownerFac=M2TWEOP.getRegionOwner(regionID); */ tables.M2TWEOPTable.set_function("getRegionOwner", &m2tweopHelpers::getRegionOwner); + /*** + Get religion name by index. + @function M2TWEOP.getReligionName + @tparam int index + @treturn string name + @usage + local religionName =M2TWEOP.getReligionName(1); + */ + tables.M2TWEOPTable.set_function("getReligionName", &gameHelpers::getReligionName); @@ -895,31 +912,58 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield eduEntry eduEntry @tfield float movePoints + @tfield int aiActiveSet 0 means inactive, 1 means active, 2 means labelled unit (for Battle) @tfield int soldierCountStratMap soldiers count. You can change it on stratmap and soldiers updated. Use @{setParams} if you need change several parameters at once. @tfield int exp soldiers expierence. You can change it on stratmap and soldiers updated. Use @{setParams} if you need change several parameters at once. @tfield int armourLVL soldiers armour. You can change it on stratmap and soldiers updated. Use @{setParams} if you need change several parameters at once. @tfield int weaponLVL soldiers weapon. You can change it on stratmap and soldiers updated. Use @{setParams} if you need change several parameters at once. @tfield int soldierCountStratMapMax Read only @tfield int soldierCountBattleMap Read only + @tfield int moraleLevel (6 means routing) + @tfield int isCloseFormation + @tfield int fatigue (battle) + @tfield int maxAmmo (battle) + @tfield int currentAmmo (battle) + @tfield float battlePosX 2d position on battlemap useful for getting distance etc (battle) + @tfield float battlePosY 2d position on battlemap useful for getting distance etc (battle) @tfield character character @tfield stackStruct army + @tfield siegeEngineNum siegeEngineNum @tfield kill kill @tfield setParams setParams change soldierCountStratMap, exp, armourLVL, weaponLVL at one time. + @tfield hasAttribute hasAttribute Check if unit has edu attribute. @tfield string alias + @tfield hasBattleProperty hasBattleProperty + @tfield setBattleProperty setBattleProperty + @tfield getActionStatus getActionStatus + @tfield isMovingFastSet isMovingFastSet + @tfield setMovingFastSet setMovingFastSet + @tfield isOnWalls isOnWalls + @tfield isEngaged isEngaged + @tfield isUnderFire isUnderFire @table unit */ types.unit = luaState.new_usertype("unit"); types.unit.set("eduEntry", &unit::eduEntry); + types.unit.set("aiActiveSet", &unit::aiActiveSet); types.unit.set("movePoints", sol::property(&unitHelpers::getMovepoints, &unitHelpers::setMovepoints)); types.unit.set("soldierCountStratMap", sol::property(&unitHelpers::getsoldierCountStratMap, &unitHelpers::setSoldiersCount)); types.unit.set("exp", sol::property(&unitHelpers::getExp, &unitHelpers::setExp)); types.unit.set("armourLVL", sol::property(&unitHelpers::getarmourLVL, &unitHelpers::setarmourLVL)); types.unit.set("weaponLVL", sol::property(&unitHelpers::getweaponLVL, &unitHelpers::setweaponLVL)); types.unit.set("soldierCountStratMapMax", sol::property(&unitHelpers::getMaxSoldiersCount)); - types.unit.set("soldierCountBattleMap", &unit::numberTact); + types.unit.set("soldierCountBattleMap", &unit::SoldierCountBattlemap); types.unit.set("character", &unit::general); + types.unit.set("isCloseFormation", &unit::isCloseFormation); + types.unit.set("moraleLevel", &unit::moraleLevel); + types.unit.set("battlePosX", &unit::positionX); + types.unit.set("battlePosY", &unit::positionY); + types.unit.set("fatigue", &unit::fatigue); + types.unit.set("maxAmmo", &unit::maxAmmo); + types.unit.set("currentAmmo", &unit::currentAmmo); + types.unit.set("siegeEngineNum", &unit::siegeEnNum); types.unit.set("army", &unit::army); /*** Kill this unit @@ -939,6 +983,149 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.unit.set_function("setParams", &unitHelpers::setUnitParams); types.unit.set("alias", sol::property(&technicalHelpers::unitUniStringToStr, &technicalHelpers::setUnitUniStr)); + /*** + Check if unit has edu attribute. + @function unit:hasAttribute + @usage + local hasAttr = unit:hasAttribute("sea_faring"); + */ + types.unit.set_function("hasAttribute", &eopEduHelpers::hasAttribute); + /*** + Check if unit has guard mode, skirmish or fire at will on. + @function unit:hasBattleProperty + @tparam int property use enum: unitBattleProperties.guardMode, unitBattleProperties.skirmish, unitBattleProperties.fireAtWill + @treturn bool hasProperty + @usage + local hasProp = unit:hasBattleProperty(unitBattleProperties.guardMode); + */ + types.unit.set_function("hasBattleProperty", &unitHelpers::hasBattleProperty); + /*** + Set a unit battle property (guard mode, skirmish or fire at will). + @function unit:setBattleProperty + @tparam int property use enum: unitBattleProperties.guardMode, unitBattleProperties.skirmish, unitBattleProperties.fireAtWill + @tparam bool value + @usage + unit:setBattleProperty(unitBattleProperties.skirmish); + */ + types.unit.set_function("setBattleProperty", &unitHelpers::setBattleProperty); + /*** + Get unit action status in battle ( idling, hiding, ready, reforming, moving, withdrawing, missiles_firing, missiles_reloading, charging, fighting, pursuing, routing, fighting_backs_to_the_walls, running_amok, rallying, dead, leaving_battle, entering_battle, left_battle, go_berserk, taunting, bracing, infighting). + @function unit:getActionStatus + @treturn string actionStatus + @usage + local status = unit:getActionStatus(); + */ + types.unit.set_function("getActionStatus", &unitHelpers::getActionStatus); + /*** + Is unit set to run? + @function unit:isMovingFastSet + @treturn bool movingFastSet + @usage + local isRunning = unit:isMovingFastSet(); + */ + types.unit.set_function("isMovingFastSet", &unitHelpers::isMovingFastSet); + /*** + Toggle unit running. + @function unit:setMovingFastSet + @tparam bool movingFastSet + @usage + unit:setMovingFastSet(true); + */ + types.unit.set_function("setMovingFastSet", &unitHelpers::setMovingFastSet); + /*** + Is unit on walls? + @function unit:isOnWalls + @treturn bool isOnWalls + @usage + local isOnWalls = unit:isOnWalls(); + */ + types.unit.set_function("isOnWalls", &unitHelpers::isOnWalls); + /*** + Is unit engaged in melee? + @function unit:isEngaged + @treturn bool isEngaged + @usage + local isEngaged = unit:isEngaged(); + */ + types.unit.set_function("isEngaged", &unitHelpers::isEngaged); + /*** + Is unit under fire? + @function unit:isUnderFire + @treturn bool isUnderFire + @usage + local isUnderFire = unit:isUnderFire(); + */ + types.unit.set_function("isUnderFire", &unitHelpers::isUnderFire); + + ///Unit Position Data + //@section unitPositionData + + /*** + + @tfield int engagedUnitsNum + @tfield unit unit + @tfield int isOnWallsCount (amount of walls + @tfield int isInTowerCount (amount of towers) + @tfield int isInGateHouseCount (amount of gatehouses) + @tfield int targetsDone dont set + @tfield int additionalTargetsOverOne dont set + @tfield int targetsToGo dont set + @tfield int hasTargets dont set + @tfield int isHalted + @tfield float lastTargetCoord1 dont set + @tfield float lastTargetCoord2 dont set + @tfield int towersUnderFireFromCount + @tfield int unitsUnderFireFromCount + @tfield getUnitUnderFireFrom getUnitUnderFireFrom + @tfield getEngagedUnit getEngagedUnit + @tfield getTargetUnit getTargetUnit + + @table unitPositionData + */ + types.unitPositionData = luaState.new_usertype("unitPositionData"); + types.unitPositionData.set("engagedUnitsNum", &unitPositionData::engagedUnitsNum); + types.unitPositionData.set("unit", &unitPositionData::unit); + types.unitPositionData.set("isOnWallsCount", &unitPositionData::isOnWallsCount); + types.unitPositionData.set("isInTowerCount", &unitPositionData::isInTowerCount); + types.unitPositionData.set("isInGateHouseCount", &unitPositionData::isInGateHouseCount); + types.unitPositionData.set("targetsDone", &unitPositionData::targetsDone); + types.unitPositionData.set("additionalTargetsOverOne", &unitPositionData::additionalTargetsOverOne); + types.unitPositionData.set("targetsToGo", &unitPositionData::targetsToGo); + types.unitPositionData.set("hasTargets", &unitPositionData::hasTargets); + types.unitPositionData.set("isHalted", &unitPositionData::isHalted); + types.unitPositionData.set("lastTargetCoord1", &unitPositionData::lastTargetCoord1); + types.unitPositionData.set("lastTargetCoord2", &unitPositionData::lastTargetCoord2); + types.unitPositionData.set("towersUnderFireFromCount", &unitPositionData::towersUnderFireFromCount); + types.unitPositionData.set("unitsUnderFireFromCount", &unitPositionData::unitsUnderFireFromCount); + + /*** + Get unit that is firing at this unit. + @function unitPositionData:getUnitUnderFireFrom + @tparam int index + @treturn unit unit + @usage + local enemyUnit = unit.unitPositionData:getUnitUnderFireFrom(0); + */ + types.unitPositionData.set_function("getUnitUnderFireFrom", &unitHelpers::getUnitUnderFireFrom); + + /*** + Get unit that is fighting this unit in melee. + @function unitPositionData:getEngagedUnit + @tparam int index + @treturn unit unit + @usage + local enemyUnit = unit.unitPositionData:getEngagedUnit(0); + */ + types.unitPositionData.set_function("getEngagedUnit", &unitHelpers::getEngagedUnit); + + /*** + Get the unit this unit is currently targeting. + @function unitPositionData:getTargetUnit + @treturn unit unit + @usage + local enemyUnit = unit.unitPositionData:getTargetUnit(); + */ + types.unitPositionData.set_function("getTargetUnit", &unitHelpers::getTargetUnit); ///EduEntry @@ -1578,6 +1765,10 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getWatchtower getWatchtower @tfield deleteFort deleteFort @tfield createFortXY createFortXY + @tfield hasMilitaryAccess hasMilitaryAccess + @tfield setMilitaryAccess setMilitaryAccess + @tfield getFactionStanding getFactionStanding + @tfield setFactionStanding setFactionStanding @table factionStruct */ @@ -1746,6 +1937,46 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.factionStruct.set_function("createFortXY", &factionHelpers::createFortXY); + /*** + Check if a faction has military access to another faction. + @function factionStruct:hasMilitaryAccess + @tparam factionStruct targetFaction + @treturn bool hasMilitaryAccess + @usage + local hasAccess = fac:hasMilitaryAccess(targetFac) + */ + types.factionStruct.set_function("hasMilitaryAccess", &factionHelpers::hasMilitaryAccess); + + /*** + Set if a faction has military access to another faction. + @function factionStruct:setMilitaryAccess + @tparam factionStruct targetFaction + @tparam bool hasMilitaryAccess + @usage + fac:setMilitaryAccess(targetFac, true) + */ + types.factionStruct.set_function("setMilitaryAccess", &factionHelpers::setMilitaryAccess); + + /*** + Get the faction standing between 2 factions (a faction with itself returns global standing). + @function factionStruct:getFactionStanding + @tparam factionStruct targetFaction + @treturn float factionStanding + @usage + local standing = fac:getFactionStanding(targetFac) + */ + types.factionStruct.set_function("getFactionStanding", &factionHelpers::getFactionStanding); + /*** + Set the faction standing between 2 factions (a faction with itself sets global standing). + @function factionStruct:setFactionStanding + @tparam factionStruct targetFaction + @tparam float factionStanding + @usage + fac:setFactionStanding(targetFac, 0.5) + */ + types.factionStruct.set_function("setFactionStanding", &factionHelpers::setFactionStanding); + + ///FactionStratMapStruct //@section factionStratMapStructTable diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index b5c81ddf8..7d1a94de0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -21,6 +21,9 @@ void luaP::initCampaign() sol::usertype region; sol::usertype mercPool; sol::usertype mercPoolUnit; + sol::usertype collegeOfCardinals; + sol::usertype crusadeStruct; + sol::usertype jihadStruct; }typeAll; using namespace campaignEnums; @@ -59,16 +62,29 @@ void luaP::initCampaign() /*** Basic campaign table. + @tfield int playerFactionId + @tfield int[31] campaignDifficultyFaction Indexing starts at 1, so add 1 to faction ID. + @tfield int[31] battleDifficultyFaction Indexing starts at 1, so add 1 to faction ID. @tfield factionStruct[31] factionsSortedByDescrStrat Table of factionStruct[31], indexing starts at 1. + @tfield factionStruct[31] factionsSortedByID Table of factionStruct[31], indexing starts at 1, so add 1 to faction ID. @tfield int numberOfFactions @tfield int numberHumanFactions Number of player-controlled factions. @tfield factionStruct currentFaction Faction whose turn it is at the moment, can be set. + @tfield collegeOfCardinals collegeOfCardinals + @tfield factionStruct papalFaction + @tfield int tickCount + @tfield int millisecondCount + @tfield float secondCount @tfield int passedTurnsNum @tfield float timescale Factor for number of turns per year, see descr\_strat.txt @tfield settlementStruct romeSettlement @tfield settlementStruct constantinopleSettlement + @tfield crusadeStruct crusade + @tfield jihadStruct jihad @tfield float BrigandSpawnValue Lower values increase spawn rate. @tfield float PirateSpawnValue Lower values increase spawn rate. + @tfield bool restrictAutoResolve + @tfield bool saveEnabled @tfield int FreeUpkeepForts Number of units who get free upkeep in forts. @tfield float currentDate @tfield int currentseason season (0=summer, 1=winter) @@ -78,19 +94,36 @@ void luaP::initCampaign() @tfield int endSeason season (0=summer, 1=winter) @tfield int daysInBattle @tfield float currentTimeInBattle 24 max, so calculate as daysInBattle*24+currentTimeInBattle. + @tfield int fortsNum + @tfield int portsBuildingsNum + @tfield int watchTowerNum @tfield checkDipStance checkDipStance @tfield setDipStance setDipStance @tfield GetUnitSize GetUnitSize + @tfield getFort getFort + @tfield getPort getPort + @tfield getWatchTower getWatchTower + @tfield getSettlementByName getSettlementByName @table gameDataAll.campaignStruct */ typeAll.campaignTable = luaState.new_usertype("campaignStruct"); + typeAll.campaignTable.set("playerFactionId", &campaign::playerFactionId); + typeAll.campaignTable.set("campaignDifficultyFaction", sol::property([](campaign& self) { return std::ref(self.campaignDifficultyFaction); })); + typeAll.campaignTable.set("battleDifficultyFaction", sol::property([](campaign& self) { return std::ref(self.battleDifficultyFaction); })); typeAll.campaignTable.set("factionsSortedByDescrStrat", sol::property([](campaign& self) { return std::ref(self.factionsSortedByDescrStrat); })); + typeAll.campaignTable.set("factionsSortedByID", sol::property([](campaign& self) { return std::ref(self.factionsSortedByID); })); typeAll.campaignTable.set("numberOfFactions", &campaign::numberOfFactionsWithSlave); + typeAll.campaignTable.set("papalFaction", &campaign::papalFaction); typeAll.campaignTable.set("numberHumanFactions", &campaign::humanPlayers); + typeAll.campaignTable.set("collegeOfCardinals", &campaign::collegeOfCardinals); typeAll.campaignTable.set("currentFaction", &campaign::currentFactionTurn); - + typeAll.campaignTable.set("tickCount", &campaign::tickCount); + typeAll.campaignTable.set("millisecondCount", &campaign::millisecondCount); + typeAll.campaignTable.set("secondCount", &campaign::secondCount); typeAll.campaignTable.set("passedTurnsNum", &campaign::TurnNumber); + typeAll.campaignTable.set("crusade", &campaign::crusade); + typeAll.campaignTable.set("jihad", &campaign::jihad); typeAll.campaignTable.set("timescale", &campaign::TimeScale); typeAll.campaignTable.set("romeSettlement", &campaign::rome); @@ -98,6 +131,8 @@ void luaP::initCampaign() typeAll.campaignTable.set("BrigandSpawnValue", &campaign::BrigandSpawnValue); typeAll.campaignTable.set("BrigandSpawnValue", &campaign::PirateSpawnValue); + typeAll.campaignTable.set("restrictAutoResolve", &campaign::restrictAutoResolve); + typeAll.campaignTable.set("saveEnabled", &campaign::saveEnabled); typeAll.campaignTable.set("FreeUpkeepForts", &campaign::FreeUpkeepForts); typeAll.campaignTable.set("currentDate", &campaign::currentDate); @@ -111,6 +146,9 @@ void luaP::initCampaign() typeAll.campaignTable.set("daysInBattle", &campaign::daysInBattle); typeAll.campaignTable.set("currentTimeInBattle", &campaign::currentTimeInBattle); + typeAll.campaignTable.set("fortsNum", &campaign::fortsNum); + typeAll.campaignTable.set("portsBuildingsNum", &campaign::portsBuildingsNum); + typeAll.campaignTable.set("watchtowersNum", &campaign::watchtowersNum); /*** Check if a diplomatic relation between two factions. @function campaignStruct:checkDipStance @@ -147,6 +185,113 @@ void luaP::initCampaign() local unitSize=campaign:GetUnitSize(); */ typeAll.campaignTable.set_function("GetUnitSize", &m2tweopHelpers::GetUnitSize); + /*** + Get fort by index. + @function campaignStruct:getFort + @tparam int index + @treturn fortStruct fort + @usage + local campaign=gameDataAll.get().campaignStruct; + local fort=campaign:getFort(0); + */ + typeAll.campaignTable.set_function("getFort", &gameHelpers::getFortAll); + /*** + Get port by index. + @function campaignStruct:getPort + @tparam int index + @treturn portBuildingStruct port + @usage + local campaign=gameDataAll.get().campaignStruct; + local port=campaign:getPort(0); + */ + typeAll.campaignTable.set_function("getPort", &gameHelpers::getPortAll); + /*** + Get watchtower by index. + @function campaignStruct:getWatchTower + @tparam int index + @treturn watchTowerStruct watchtower + @usage + local campaign=gameDataAll.get().campaignStruct; + local watchtower=campaign:getWatchTower(0); + */ + typeAll.campaignTable.set_function("getWatchTower", &gameHelpers::getWatchTowerAll); + /*** + Get settlement by internal name. + @function campaignStruct:getSettlementByName + @tparam string name + @treturn settlementStruct settlement + @usage + local campaign=gameDataAll.get().campaignStruct; + local sett=campaign:getSettlementByName("London"); + */ + typeAll.campaignTable.set_function("getSettlementByName", &gameHelpers::getSettlementByName); + + /// College of Cardinals + //@section collegeOfCardinals + /*** + Basic College of Cardinals table. + @tfield namedCharacter pope + @tfield int cardinalNum + @tfield getCardinal getCardinal + + @table collegeOfCardinals + */ + typeAll.collegeOfCardinals = luaState.new_usertype("collegeOfCardinals"); + typeAll.collegeOfCardinals.set("pope", &collegeOfCardinals::pope); + typeAll.collegeOfCardinals.set("cardinalNum", &collegeOfCardinals::cardinalNum); + + /*** + Get a specific cardinal by index. + @function collegeOfCardinals:getCardinal + @tparam int index + @treturn character cardinal + @usage + local college = campaign.collegeOfCardinals; + local cardinal = college:getCardinal(2); + */ + typeAll.collegeOfCardinals.set_function("getCardinal", &gameHelpers::getCardinal); + + /// Crusade + //@section crusade + + /*** + Basic crusade table. + + @tfield int startTurn + @tfield int endTurn + @tfield settlementStruct targetSettlement + @tfield int length + @tfield int outcome + + @table crusadeStruct + */ + typeAll.crusadeStruct = luaState.new_usertype("crusadeStruct"); + typeAll.crusadeStruct.set("startTurn", &crusade::startTurn); + typeAll.crusadeStruct.set("endTurn", &crusade::endTurn); + typeAll.crusadeStruct.set("targetSettlement", &crusade::targetSettlement); + typeAll.crusadeStruct.set("length", &crusade::length); + typeAll.crusadeStruct.set("outcome", &crusade::outcome); + + /// Jihad + //@section jihad + + /*** + Basic jihad table. + + @tfield int startTurn + @tfield int endTurn + @tfield settlementStruct targetSettlement + @tfield int length + @tfield int outcome + + @table jihadStruct + */ + typeAll.jihadStruct = luaState.new_usertype("jihadStruct"); + typeAll.jihadStruct.set("startTurn", &jihad::startTurn); + typeAll.jihadStruct.set("endTurn", &jihad::endTurn); + typeAll.jihadStruct.set("targetSettlement", &jihad::targetSettlement); + typeAll.jihadStruct.set("length", &jihad::length); + typeAll.jihadStruct.set("outcome", &jihad::outcome); /// Strat Map //@section stratMap diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp index 81baa7d9d..4ddcae500 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp @@ -47,25 +47,25 @@ namespace m2tweopHelpers using namespace campaignEnums; if (dipType == dipRelEnum::war) { - return (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::warState); + return (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::warState); } else if (dipType == dipRelEnum::peace) { - return (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::peaceState); + return (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::peaceState); } else if (dipType == dipRelEnum::alliance) { - return (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::allianceState); + return (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::allianceState); } else if (dipType == dipRelEnum::suzerain) { - return (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::allianceState - && campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].protectorate == protectorateState + return (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state == dipStateInternalEnum::allianceState + && campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].protectorate == protectorateState ); } else if (dipType == dipRelEnum::trade) { - return (campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].trade == 1); + return (campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].trade == 1); } return false; } @@ -73,16 +73,16 @@ namespace m2tweopHelpers { using namespace campaignEnums; - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::peaceState; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::peaceState; - if (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].protectorate == protectorateState) + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::peaceState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::peaceState; + if (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].protectorate == protectorateState) { - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].protectorate = nonProtectorateeState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].protectorate = nonProtectorateeState; } - if (campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].protectorate == protectorateState) + if (campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].protectorate == protectorateState) { - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].protectorate = nonProtectorateeState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].protectorate = nonProtectorateeState; } } @@ -93,48 +93,48 @@ namespace m2tweopHelpers { disableVassalage(campaignStruct, fac1, fac2); - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].trade = 0; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].trade = 0; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade = 0; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].trade = 0; - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::warState; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::warState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::warState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::warState; } else if (dipType == dipRelEnum::peace) { disableVassalage(campaignStruct, fac1, fac2); - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::peaceState; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::peaceState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::peaceState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::peaceState; } else if (dipType == dipRelEnum::alliance) { disableVassalage(campaignStruct, fac1, fac2); - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::allianceState; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::allianceState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::allianceState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::allianceState; } else if (dipType == dipRelEnum::suzerain) { disableVassalage(campaignStruct, fac1, fac2); - if (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].protectorate == protectorateState) + if (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].protectorate == protectorateState) { - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].protectorate = nonProtectorateeState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].protectorate = nonProtectorateeState; } - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].protectorate = protectorateState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].protectorate = protectorateState; - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::allianceState; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::allianceState; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state = dipStateInternalEnum::allianceState; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].state = dipStateInternalEnum::allianceState; - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].trade = 1; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].trade = 1; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade = 1; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].trade = 1; } else if (dipType == dipRelEnum::trade) { - if (campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].state != dipStateInternalEnum::warState) + if (campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].state != dipStateInternalEnum::warState) { - campaignStruct->dipArray[fac1->dipNum][fac2->dipNum].trade = 1; - campaignStruct->dipArray[fac2->dipNum][fac1->dipNum].trade = 1; + campaignStruct->diplomaticStandings[fac1->dipNum][fac2->dipNum].trade = 1; + campaignStruct->diplomaticStandings[fac2->dipNum][fac1->dipNum].trade = 1; } } diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index cf5019836..cb7b156df 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -16,6 +16,8 @@ typedef unsigned short ushort; #pragma pack(push,1) typedef struct stackStruct stackStruct, * PstackStruct; typedef struct settlementStruct settlementStruct, * PsettlementStruct; + + struct UNICODE_STRING { USHORT something;//idk USHORT Length;//idk @@ -252,15 +254,6 @@ struct siegeS { struct stackStruct* army; }; -//diplomacy data of faction to another faction -struct factionDiplomacy { - undefined field_0x0[16]; - int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ - int trade; /* trade rights(0 or 1) */ - int protectorate; /* protectorate or not(15 or 6) */ - undefined field_0x1c[108]; -}; - struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int id; char* facName; @@ -315,6 +308,91 @@ struct worldRecord { undefined field_0x38[40]; }; +struct crusade +{ +public: + char pad_0000[20]; //0x0000 + void* N0000121D; //0x0014 + char pad_0018[28]; //0x0018 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[252]; //0x0048 + void* N00001269; //0x0144 + char pad_0148[44]; //0x0148 +}; //Size: 0x0174 + + + +struct jihad +{ +public: + char pad_0000[52]; //0x0000 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[292]; //0x0048 +}; //Size: 0x016C + +struct settlementList +{ + struct settlementStruct** settlements; //0x0000 + struct settlementList* nextSettlements; //0x0004 + struct settlementList* previousSettlements; //0x0008 + int32_t settlementsSize; //0x000C + int32_t settlementsNum; //0x0010 +}; + + +struct factionDiplomacy +{ +public: + char pad_0000[4]; //0x0000 + int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ + int trade; /* trade rights(0 or 1) */ + int protectorate; /* protectorate or not(15 or 6) */ + float factionStanding; //0x0010 + char pad_0014[116]; //0x0014 +}; //Size: 0x0088 + +struct trackedCharacter +{ +public: + struct N0001F08D* N0001F061; //0x0000 + struct general* character; //0x0004 +}; //Size: 0x0008 + +struct cardinal +{ +public: + struct trackedCharacter* trackedCharacter; //0x0000 + struct N0001F079* cardinalInfo; //0x0004 +}; //Size: 0x0008 + +struct collegeOfCardinals +{ +public: + char pad_0000[4]; //0x0000 + struct namedCharacter* pope; //0x0004 + char pad_0008[4]; //0x0008 + struct cardinal* cardinalsArray; //0x000C + int32_t cardinalsArraySize; //0x0010 + int32_t cardinalNum; //0x0014 + int8_t N0001D9D6; //0x0018 + int8_t getsUsedForCountVotes; //0x0019 + int8_t N0001F1B6; //0x001A + int8_t N0001F1B4; //0x001B + struct N0001F0B9* someOtherArray; //0x001C + int32_t someOtherArraySize; //0x0020 + int32_t someOtherArrayCount; //0x0024 + struct UNICODE_STRING** localizedCardinalNames; //0x0028 + char pad_002C[32]; //0x002C +}; //Size: 0x004C + struct campaign { undefined field0_0x0[4]; undefined field1_0x4[52]; @@ -324,22 +402,21 @@ struct campaign { undefined field5_0x44[232]; int humanPlayers; /* number of player-controlled factions */ int factionIdPow; /* pow(2,factionId) */ - int campaignDifficultyFaction[8]; - undefined field9_0x154[120]; - int battleDifficulty07; - undefined field11_0x1d0[88]; - int battleDifficulty30; + int32_t campaignDifficultyFaction[31]; + int32_t battleDifficultyFaction[31]; struct factionStruct* factionsSortedByDescrStrat[31]; struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; - undefined field16_0x328[28]; + char pad_0328[20]; //0x0328 + struct collegeOfCardinals* collegeOfCardinals; //0x033C + struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; - int field18_0x348; /* FactionTurn? */ + int factionTurnID; /* FactionTurn? */ UNICODE_STRING** currentDescrFile; /* path to descr_battle.txt or to descr_strat.txt */ undefined field20_0x350[28]; - int field21_0x36c; /* TickCount? */ - int MillisecondCount; - float SecondCount; + int tickCount; /* TickCount? */ + int millisecondCount; + float secondCount; int TurnNumber; int field25_0x37c; /* PauseForBattleDialog? */ float TimeScale; @@ -353,15 +430,20 @@ struct campaign { undefined field34_0x3d2[26]; float BrigandSpawnValue; float PirateSpawnValue; - undefined field37_0x3f4[4]; + int8_t N00001211; //0x03F4 + int8_t smthingDateTurnDisplay; //0x03F5 + int8_t restrictAutoResolve; //0x03F6 + char pad_03F7[1]; //0x03F7 int FreeUpkeepForts; int ActiveFactions; /* number factions minus slave */ undefined field40_0x400[12]; int lastrandomseed; - undefined field42_0x410[744]; - int8_t isAdminPasswordExist; - int8_t isHotseatLogon; - undefined field45_0x6fa[2]; + struct crusade crusade; //0x0410 + struct jihad jihad; //0x0584 + struct UNICODE_STRING** someUniStringMaybePassword; //0x06F0 + int8_t isAdminPasswordExist; //0x06F4 + int8_t saveEnabled; //0x06F5 + undefined field45_0x6f6[6]; int8_t hotseatConsole; int8_t hotseatConsole2; undefined field48_0x6fe[14]; @@ -375,18 +457,23 @@ struct campaign { float timeAtStartBattle; int daysInBattle; float currentTimeInBattle; /* 24 max, so calc as daysInBattle*24+currentTimeInBattle */ - undefined field59_0x734[4124]; - struct factionDiplomacy dipArray[31][31]; - undefined field61_0x215d8[48]; + char pad_0734[28]; //0x0734 + float clockTime; //0x0750 + char pad_0754[260]; //0x0754 + int32_t interFactionMarriage[31][31]; //0x0858 + struct factionDiplomacy diplomaticStandings[31][31]; //0x175C + struct settlementList settlementList; //0x215E4 + char* introVid; //0x215F8 + char pad_215FC[16]; //0x215FC struct fortStruct** fortsArray; - undefined field63_0x2160c; - int fortsNum; + int32_t fortsSize; //0x21610 + int32_t fortsNum; //0x21614 struct portBuildingStruct** portsBuildings; - undefined field66_0x21615; - int portsBuildingsNum; + int32_t portsBuildingsSize; //0x2161C + int32_t portsBuildingsNum; //0x21620 struct watchTowerStruct** watchtowers; - undefined field69_0x2161e; - int watchtowersNum; + int32_t watchtowersSize; //0x21628 + int32_t watchtowersNum; //0x2162C }; struct gameDataAllStruct { @@ -1367,34 +1454,378 @@ struct engineRecord { }; struct soldierInBattle { - undefined field_0x0[24]; + undefined field_0x0[8]; + int32_t unitCategory; //0x0008 + int16_t someFlags; //0x000C + int8_t N00008AC5; //0x000E + int8_t N00008AC7; //0x000F + float mass; //0x0010 + float inverseMass; //0x0014 float xCoord; float zCoord; float yCoord; - undefined field_0x24[1440]; -}; + struct soldierInBattle* self; //0x0024 + float someRadius1; //0x0028 + float someRadius2; //0x002C + float someRadius3; //0x0030 + float markerRadius; //0x0034 + float height; //0x0038 + char pad_003C[8]; //0x003C + int16_t rotation; //0x0044 + char pad_0046[2]; //0x0046 + float velocity1; + float velocity2; + float velocity3; + char pad_0054[196]; //0x0054 + struct soldierInBattle *self2; //0x0118 + char pad_011C[4]; //0x011C + float speed; //0x0120 + char pad_0124[4]; //0x0124 + float xCoord_writable; + float zCoord_writable; + float yCoord_writable; + uint16_t angle_writable; //0x0134 + int8_t N0000713A; //0x0136 + int8_t N00009525; //0x0137 + float velocityModifier; //0x0138 + int32_t currentStateGroupID; //0x013C + int32_t currentStateStateID; //0x0140 + int32_t pendingStateGroupID; //0x0144 + int32_t pendingStateStateID; //0x0148 + char pad_014C[4]; //0x014C + float xCoord_destination; + float zCoord_destination; + float yCoord_destination; + int16_t destinationAngle; //0x015C + int16_t thisIsAngleCauseTwoByteMaybe; //0x015E + float destinationRadius; //0x0160 + char pad_0164[16]; //0x0164 + int16_t N00001DC6; //0x0174 + char pad_0176[2]; //0x0176 + int32_t targetStateGroupID; //0x0178 + int32_t targetStateStateID; //0x017C (One = Standing, 2 = Walking, 3 = running) + int32_t moveStateGroupID; //0x0180 + int32_t moveStateStateID; //0x0184 (2 = walking, 3 = running) + int32_t finishStateGroupID; //0x0188 + int32_t finishStateStateID; //0x018C + int32_t options; //0x0190 + int32_t pendingAction; //0x0194 + float stoppingModifier; //0x0198 + float slideRotation; //0x019C + int32_t numTicks; //0x01A0 + char pad_01A4[20]; //0x01A4 + int32_t surfaceID; //0x01B8 + int16_t pathHistoryAndObstacleDirection; //0x01BC + int16_t unk; //0x01BE + char pad_01C0[16]; //0x01C0 + int16_t waypoint; //0x01D0 + char pad_01D2[18]; //0x01D2 + int16_t cone; //0x01E4 + int16_t directionOffset; //0x01E6 + int16_t blockedCounter; //0x01E8 + int16_t N0000954E; //0x01EA + float radiusModifier; //0x01EC + float speedModifier; //0x01F0 + int32_t deflectionCounter; //0x01F4 + float stoppingDistance; //0x01F8 + float externalModifier; //0x01FC + uint32_t locomotionFlags; //0x0200 + char pad[960]; //0x01D2 + +}; + +struct generalInfo +{ +public: + char** generalModelName; //0x0000 + struct unit* unit; //0x0004 + struct namedCharacter* namedChar; //0x0008 + char pad_000C[48]; //0x000C + int8_t N00010FEA; //0x003C + char pad_003D[43]; //0x003D + struct soldierInBattle* soldier; //0x0068 + int8_t isCharacter; //0x006C + int8_t alive; //0x006D + char pad_006E[2]; //0x006E + struct heroAbility* ability; //0x0070 + char pad_0074[144]; //0x0074 +}; //Size: 0x0104 + +struct floatPosData +{ +public: + float rotStart; //0x0000 + float coord2_1; //0x0004 + float coord2_2; //0x0008 + float coord3_2; //0x000C + float coord3_1; //0x0010 + float coord0_2; //0x0014 + float coord0_1; //0x0018 + float unk1; //0x001C + float unk2; //0x0020 + float unk; //0x0024 + float rotation1; //0x0028 + float rotation2; //0x002C + float coord1_1; //0x0030 + float coord1_2; //0x0034 + float val15; //0x0038 + float rotValue1; //0x003C + float rotValue2; //0x0040 +}; //Size: 0x0044 + +struct targetUnitStruct +{ +public: + char pad_0000[4]; //0x0000 + struct unit* target; //0x0004 + char pad_0008[4]; //0x0008 + int32_t targetUnitIndex; //0x000C + char pad_0010[4]; //0x0010 +}; //Size: 0x0014 + +struct targetPos +{ +public: + int32_t typeOrSomething; //0x0000 + int32_t N0001B8DA; //0x0004 + void* getsSet0IfHalted; //0x0008 + struct targetUnitStruct* targetUnit; //0x000C + char pad_0010[4]; //0x0010 + float targetPosX; //0x0014 + float targetPosY; //0x0018 + char pad_001C[24]; //0x001C + float N0001B8E6; //0x0034 + char pad_0038[4]; //0x0038 + float N0001B8E8; //0x003C + char pad_0040[4]; //0x0040 + int32_t N0001B8EA; //0x0044 + char pad_0048[96]; //0x0048 +}; //Size: 0x00A8 + +struct battleMapPosition +{ +public: + int32_t positionIDMaybe; //0x0000 + int32_t numSoldiers; //0x0004 +}; //Size: 0x0008 + +struct engagedUnit +{ +public: + struct unit* unit; //0x0000 + int32_t intValue; //0x0004 + int32_t intValue2; //0x0008 + int32_t intValue3; //0x000C + int32_t intValue4; //0x0010 + int32_t intValue5; //0x0014 + float floatValue; //0x0018 +}; //Size: 0x001C + + +struct unitPositionData +{ +public: + struct engagedUnit* engagedUnits; //0x0000 + int32_t engagedUnitsSize; //0x0004 + int32_t engagedUnitsNum; //0x0008 + struct engagedUnit* engagedUnits2; //0x000C + int32_t engagedUnits2Size; //0x0010 + int32_t engagedUnits2Num; //0x0014 + char pad_0018[16]; //0x0018 + struct unit* unit; //0x0028 + char pad_002C[4]; //0x002C + void* N00002C71; //0x0030 + char pad_0034[4]; //0x0034 + struct unit* N00002C73; //0x0038 + float coord0; //0x003C + float coord1; //0x0040 + float coord2; //0x0044 + float coord3; //0x0048 + float rotation; //0x004C + struct battleMapPosition* isOnWalls; //0x0050 + int32_t isOnWallsSize; //0x0054 + int32_t isOnWallsCount; //0x0058 + struct battleMapPosition *isInTower; //0x005C + int32_t isInTowerSize; //0x0060 + int32_t isInTowerCount; //0x0064 + struct battleMapPosition* isInGateHouse; //0x0068 + int32_t isInGateHouseSize; //0x006C + int32_t isInGateHouseCount; //0x0070 + struct battleMapPosition* positions1; //0x0074 + int32_t positions1Size; //0x0078 + int32_t positions1Count; //0x007C + struct battleMapPosition* positions2; //0x0080 + int32_t positions2Size; //0x0084 + int32_t positions2Count; //0x0088 + struct battleMapPosition* positions3; //0x008C + int32_t positions3Size; //0x0090 + int32_t positions3Count; //0x0094 + struct battleMapPosition* positions4; //0x0098 + int32_t positions4Size; //0x009C + int32_t positions4Count; //0x00A0 + char pad_00A4[12]; //0x00A4 + struct floatPosData floatPosData; //0x00B0 + char pad_00F4[4]; //0x00F4 + struct targetPos targetArray[16]; //0x00F8 + int32_t targetsDone; //0x0B78 + int32_t additionalTargetsOverOne; //0x0B7C + int32_t targetsToGo; //0x0B80 + int8_t hasTargets; //0x0B84 + int8_t isHalted; //0x0B85 + char pad_0B86[6]; //0x0B86 + float lastTargetCoord1; //0x0B8C + float lastTargetCoord2; //0x0B90 + char pad_0B94[20]; //0x0B94 + float N00002F68; //0x0BA8 + float N00002F69; //0x0BAC + float N00002F6A; //0x0BB0 + float N00002F6B; //0x0BB4 + float N00002F6C; //0x0BB8 + float N00002F6D; //0x0BBC + float N00002F6E; //0x0BC0 + float N00002F6F; //0x0BC4 + float N00002F70; //0x0BC8 + float N00002F71; //0x0BCC + float N00002F72; //0x0BD0 + float N00002F73; //0x0BD4 + float N00002F74; //0x0BD8 + float N00002F75; //0x0BDC + float N00002F76; //0x0BE0 + float N00002F77; //0x0BE4 + float N00002F78; //0x0BE8 + char pad_0BEC[20]; //0x0BEC + void** towersUnderFireFrom; //0x0C00 + int32_t towersUnderFireFromSize; //0x0C04 + int32_t towersUnderFireFromCount; //0x0C08 + struct unit** unitsUnderFireFrom; //0x0C0C + int32_t unitsUnderFireFromSize; //0x0C10 + int32_t unitsUnderFireFromCount; //0x0C14 + void** underFireSomething2; //0x0C18 + int32_t underFireSomething2Size; //0x0C1C + int32_t underFireSomething2Count; //0x0C20 + void** underFireSomething3; //0x0C24 + int32_t underFireSomething3Size; //0x0C28 + int32_t underFireSomething3Count; //0x0C2C + char pad_0C30[8]; //0x0C30 + int32_t combatStatus; //0x0C38 +}; //Size: 0x0C3C //unit data struct unit { undefined field0_0x0[4]; struct trackedPointerUnit** trackedUnitPointerP; - undefined field2_0x8[636]; - struct stackStruct* army; + undefined field2_0x8[52]; + int32_t aiActiveSet; //0x003C + undefined field_0040[24]; + struct modelEntry* bmdbEntry; //0x0058 + undefined field3_0x5C[548];//0x005C + struct unitPositionData* unitPositionData; //0x0280 + struct stackStruct* army;//0x0284 undefined field4_0x288[12]; struct eduEntry* eduEntry; - int ID; - undefined field7_0x29c[612]; + int ID; //0x0298 + int battlemapTeam; //0x029C + int actionStatus; //0x02A0 + char pad_02A4[24]; //0x02A4 + void* ThirtyTwoByteObject; //0x02BC + char pad_02C0[8]; //0x02C0 + void* hundredSixtyByteObject; //0x02C8 + char pad_02CC[8]; //0x02CC + int fatigue; //0x02D4 + float killChanceModifier; //0x02D8 + struct Unit* this2; //0x02DC + int moraleLevel; //0x02E0 + int moraleStatusSum; //0x02E4 + char pad_02E8[24]; //0x02E8 + int moraleValue1; //0x0300 + int moraleValue2; //0x0304 + int moraleValue3; //0x0308 + int moraleValue4; //0x030C + int moraleValue5; //0x0310 + int moraleValue6; //0x0314 + int moraleValue7; //0x0318 + int moraleValue8; //0x031C + int moraleValue9; //0x0320 + char pad_0324[372]; //0x0324 + struct unitMorale* moralePartOfUnitLookAbove; //0x0498 + char pad_049C[4]; //0x049C + int someMoraleValue; //0x04A0 + char pad_04A4[4]; //0x04A4 + int16_t N0000271D; //0x04A8 + int8_t N00009770; //0x04AA + int8_t skipsMoraleCalcIFNotZero; //0x04AB + int8_t lockedMorale; //0x04AC + char pad_04AD[11]; //0x04AD + int moraleAreaEffectEnd; //0x04B8 + char pad_04BC[60]; //0x04BC + int hasActiveEffects; //0x04F8 + int activeEffectsOnThisUnit; //0x04FC int expScreen; /* screen experience */ struct general* general; float movePoints; - int number; /* number of soldiers */ - int numberTact; /* number of soldiers on tactical map */ - int numberMax; /* max number of soldiers */ - undefined field14_0x518[216]; + int SoldierCountStrat; /* number of soldiers */ + int SoldierCountMaxStrat; /* number of soldiers on tactical map */ + int SoldierCountBattlemap; /* max number of soldiers */ + int soldierCountMaxBattlemap; /* max number of soldiers */ + char pad_051C[64]; //0x051C + struct generalInfo* officer1; //0x055C + struct generalInfo* officer2; //0x0560 + struct generalInfo* officer3; //0x0560 + struct generalInfo* generalInfo; //0x0568 + struct soldierInBattle* generalSoldier; //0x056C + struct soldierInBattle* officer1Soldier; //0x0570 + struct soldierInBattle* officer2Soldier; //0x0574 + struct soldierInBattle* officer3Soldier; //0x0578 + int32_t numOfficer; //0x057C + int32_t numOfficerInBattle; //0x0580 + int32_t N00002755; //0x0584 + int32_t N00002756; //0x0588 + int32_t N00002757; //0x058C + int32_t N00002758; //0x0590 + int32_t statPri; //0x0594 + char pad_0598[20]; //0x0598 + int32_t weaponType; //0x05AC + int32_t weaponTecType; //0x05B0 + char pad_05B4[8]; //0x05B4 + int32_t minAttackDelayPri; //0x05BC + char pad_05C0[28]; //0x05C0 + int32_t statPriArmour; //0x05DC + int32_t valueAfterInEdu; //0x05E0 + int8_t attackInBattle; //0x05E4 + int16_t armourInBattle; //0x05E5 + char pad_05E7[1]; //0x05E7 + int8_t N0000276E; //0x05E8 + int8_t N00010E95; //0x05E9 + char pad_05EA[6]; //0x05EA UINT32 stats; /* def/atk/etc */ struct soldierInBattle** soldiersBattleArr; /* array of soldiers battle data */ struct soldierData* soldiersArr; /* array of soldiers data */ - undefined field18_0x5fc[6780]; + void* soldierIndices; //0x05FC + void* generalOrMount; //0x0600 + int32_t attachmentCount; //0x0604 + char pad_0608[6172]; //0x0608 + void* UNIT_TASK_INTERFACE; //0x1E24 + char pad_1E28[28]; //0x1E28 + int32_t unitBattleProperties; //0x1E44 + char pad_1E48[4]; //0x1E48 + void* formationsArray; //0x1E4C + char pad_1E50[28]; //0x1E28 + int16_t ranks; //0x1E76 + char pad_1E78[14]; //0x1E78 + int8_t isCloseFormation; //0x1E84 + char pad_1E85[59]; //0x1E85 + float positionX; //0x1EC0 + float N00002FB7; //0x1EC4 + float positionY; //0x1EC8 + char pad_1ECC[400]; //0x1ECC + int32_t maxAmmo; //0x205C + int32_t currentAmmo; //0x2060 + uint8_t statusField1; //0x2064 + uint8_t statusField2; //0x2065 + uint8_t statusField3; //0x2066 + char pad_2067[1]; //0x2067 + int8_t rallyHornCountdown; //0x2068 + char pad_2069[15];; //0x2069 UNICODE_STRING** alias; /* Legio string etc */ undefined field20_0x207c[44]; struct siegeEngine** siegeEngine; @@ -1728,8 +2159,8 @@ struct eduEntry { void* N00000152; void* N00000153; char pad_0394[12]; - void* Attributes; - void* EndOfAttributes; + DWORD* Attributes; + DWORD* EndOfAttributes; void* BytesBeforeNextAttributes; int8_t Attributes2; int8_t Attributes3; diff --git a/M2TWEOP-luaPlugin/luaPlugin/stackStructHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/stackStructHelpers.cpp index 8f000af91..72e6d42da 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/stackStructHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/stackStructHelpers.cpp @@ -36,7 +36,7 @@ namespace stackStructHelpers // Soldier Count else if (sortType == 4) { - return unitA->number > unitB->number; + return unitA->SoldierCountStrat > unitB->SoldierCountStrat; } // Experience else if (sortType == 5) diff --git a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp index a963e86b3..8c524907b 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp @@ -2,13 +2,38 @@ #include "plugData.h" namespace unitHelpers { + std::unordered_map actionTypes = { + {0,"idling"}, + {1,"hiding"}, + {4,"ready"}, + {5,"reforming"}, + {6,"moving"}, + {7,"withdrawing"}, + {8,"missiles_firing"}, + {9,"missiles_reloading"}, + {10,"charging"}, + {11,"fighting"}, + {12,"pursuing"}, + {13,"routing"}, + {14,"fighting_backs_to_the_walls"}, + {15,"running_amok"}, + {23,"infighting"}, + {16,"go_berserk"}, + {17,"rallying"}, + {18,"dead"}, + {19,"leaving_battle"}, + {20,"entering_battle"}, + {21,"left_battle"}, + {2,"taunting"}, + {24,"bracing"}, + }; int getExp(unit* un) { return un->expScreen; } void setExp(unit* un, int exp) { - (*(*plugData::data.funcs.setUnitParams))(un, un->number, exp, getarmourLVL(un), getweaponLVL(un)); + (*(*plugData::data.funcs.setUnitParams))(un, un->SoldierCountStrat, exp, getarmourLVL(un), getweaponLVL(un)); } int getarmourLVL(unit* un) { @@ -16,7 +41,7 @@ namespace unitHelpers } void setarmourLVL(unit* un, int lvl) { - (*(*plugData::data.funcs.setUnitParams))(un, un->number, un->expScreen, lvl, getweaponLVL(un)); + (*(*plugData::data.funcs.setUnitParams))(un, un->SoldierCountStrat, un->expScreen, lvl, getweaponLVL(un)); } int getweaponLVL(unit* un) { @@ -24,7 +49,7 @@ namespace unitHelpers } void setweaponLVL(unit* un, int lvl) { - (*(*plugData::data.funcs.setUnitParams))(un, un->number, un->expScreen, getarmourLVL(un), lvl); + (*(*plugData::data.funcs.setUnitParams))(un, un->SoldierCountStrat, un->expScreen, getarmourLVL(un), lvl); } int getMaxSoldiersCount(unit* un) { @@ -69,7 +94,7 @@ namespace unitHelpers } void setUnitParams(unit* un, int exp, int armor, int weap) { - (*(*plugData::data.funcs.setUnitParams))(un, un->number, exp, armor, weap); + (*(*plugData::data.funcs.setUnitParams))(un, un->SoldierCountStrat, exp, armor, weap); } float getMovepoints(const unit* un) { @@ -77,6 +102,80 @@ namespace unitHelpers } int getsoldierCountStratMap(const unit* un) { - return un->number; + return un->SoldierCountStrat; } + bool hasBattleProperty(const unit* un, unitBattleProperties prop) + { + return (un->unitBattleProperties & prop) != 0; + } + void setBattleProperty(unit* un, unitBattleProperties prop, bool value) + { + if (value) + { + un->unitBattleProperties |= prop; + } + else + { + un->unitBattleProperties &= ~prop; + } + } + const char* getActionStatus(unit* un) + { + auto it = actionTypes.find(un->actionStatus); + if (it != actionTypes.end()) + { + return it->second; + } + return "unknown"; + } + bool isMovingFastSet(unit* un) + { + return un->statusField2 & 0x1; + } + void setMovingFastSet(unit* un, bool set) + { + un->statusField2 = set ? un->statusField2 | 0x1 : un->statusField2 & ~0x1; + } + bool isOnWalls(unit* un) + { + return un->unitPositionData->isInGateHouseCount + un->unitPositionData->isInTowerCount + un->unitPositionData->isOnWallsCount; + } + bool isEngaged(unit* un) + { + return un->unitPositionData->engagedUnitsNum; + } + bool isUnderFire(unit* un) + { + auto posData = un->unitPositionData; + return posData->towersUnderFireFromCount + posData->unitsUnderFireFromCount + posData->underFireSomething2Count + posData->underFireSomething3Count; + } + unit* getUnitUnderFireFrom(unitPositionData* posData, int index) + { + if (index < posData->unitsUnderFireFromCount) + { + return posData->unitsUnderFireFrom[index]; + } + return nullptr; + } + unit* getEngagedUnit(unitPositionData* posData, int index) + { + if (index < posData->engagedUnitsNum) + { + return posData->engagedUnits[index].unit; + } + return nullptr; + } + unit* getTargetUnit(unitPositionData* posData) + { + if (!posData->hasTargets || posData->isHalted) + { + return nullptr; + } + if (posData->targetArray[posData->targetsToGo].targetUnit) + { + return posData->targetArray[posData->targetsToGo].targetUnit->target; + } + return nullptr; + } + } \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.h index 3e07ef385..a1b3eef60 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.h @@ -1,24 +1,42 @@ #pragma once #include +#include + #include "realGameTypes.h" #include "luaGetSetFuncs.h" namespace unitHelpers { + + enum unitBattleProperties :int + { + guardMode = 1, + fireAtWill = 2, + skirmish = 4, + }; + int getExp(unit* un); void setExp(unit* un,int exp); int getarmourLVL(unit* un); void setarmourLVL(unit* un,int lvl); int getweaponLVL(unit* un); void setweaponLVL(unit* un,int lvl); - + bool hasBattleProperty(const unit* un, unitBattleProperties prop); + void setBattleProperty(unit* un, unitBattleProperties prop, bool value); int getMaxSoldiersCount(unit* un); - + const char* getActionStatus(unit* un); void setMovepoints(unit* un,float movepoints); void setSoldiersCount(unit* un,int number); void killUnit(unit* un); void setUnitParams(unit* un, int exp, int armor, int weap); float getMovepoints(const unit* un); - + bool isMovingFastSet(unit* un); + void setMovingFastSet(unit* un, bool set); + bool isOnWalls(unit* un); + bool isEngaged(unit* un); + bool isUnderFire(unit* un); + unit* getUnitUnderFireFrom(unitPositionData* posData, int index); + unit* getEngagedUnit(unitPositionData* posData, int index); + unit* getTargetUnit(unitPositionData* posData); int getsoldierCountStratMap(const unit* un); }; From af42136f2b419a580f993a7d3996b3abb89c2f27 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 10 Oct 2023 19:29:10 +0300 Subject: [PATCH 16/22] big update to many structs --- M2TWEOP Code/M2TWEOP library/fastFuncts.cpp | 8 +- M2TWEOP Code/M2TWEOP library/onlineThings.cpp | 2 +- .../M2TWEOP library/onlineThings2.cpp | 4 +- M2TWEOP Code/M2TWEOP library/realGameTypes.h | 1467 +++++++++++++++-- .../luaPlugin/battleHandlerHelpers.cpp | 23 + .../luaPlugin/battleHandlerHelpers.h | 3 + .../luaPlugin/factionHelpers.cpp | 44 + M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h | 8 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp | 217 ++- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h | 34 +- .../luaPlugin/generalHelpers.cpp | 32 +- M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 438 ++++- M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 782 ++++++++- .../luaPlugin/m2tweopHelpers.cpp | 18 + M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h | 2 + M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 889 +++++++++- .../luaPlugin/settlementHelpers.cpp | 20 + .../luaPlugin/settlementHelpers.h | 5 + M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp | 4 +- 20 files changed, 3740 insertions(+), 262 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp index 7406eaafa..f06bce51b 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp @@ -879,8 +879,8 @@ namespace fastFuncts } return; } - un->general->movepoints1 = movepoints; - un->general->movepoints2 = movepoints; + un->general->movePointsCharacter = movepoints; + un->general->movePointsArmy = movepoints; general* gen = un->general; @@ -926,7 +926,7 @@ namespace fastFuncts - int diff = count - un->number; + int diff = count - un->SoldierCountStrat; if (diff == 0) { return; @@ -947,7 +947,7 @@ namespace fastFuncts } else { - un->number = count; + un->SoldierCountStrat = count; } diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp index d4b74a2d1..e0be83eb6 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp @@ -370,7 +370,7 @@ namespace battleCreator unit* un = army->units[k]; tempS = "unit "; tempS.append(un->eduEntry->Type); - tempS.append(" soldiers ").append(to_string(un->number)); + tempS.append(" soldiers ").append(to_string(un->SoldierCountStrat)); tempS.append(" exp ").append(to_string(un->expScreen)); tempS.append(" armour ").append(to_string(un->stats >> 0xd & 0x1f)); tempS.append(" weapon_lvl ").append(to_string(un->stats >> 0x8 & 0x1f)); diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp index b2ce6a856..ac68d3fe9 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp @@ -26,7 +26,7 @@ namespace battleCreator { numberInArmy = pnumberInArmy; type = un->eduEntry->Type; - soldiersNumber = un->number; + soldiersNumber = un->SoldierCountStrat; exp = un->expScreen; @@ -232,7 +232,7 @@ namespace battleCreator { unitJson["general"] = 0; } - unitJson["soldiers"] = unit->number; + unitJson["soldiers"] = unit->SoldierCountStrat; unitJson["exp"] = unit->expScreen; j.push_back(unitJson); diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index 5b67ffd27..774c3dd6d 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -16,12 +16,115 @@ typedef unsigned short ushort; #pragma pack(push,1) typedef struct stackStruct stackStruct, * PstackStruct; typedef struct settlementStruct settlementStruct, * PsettlementStruct; + + struct UNICODE_STRING { USHORT something;//idk USHORT Length;//idk USHORT something2;//idk PWSTR Buffer;//y }; + +struct rcString +{ +public: + char pad_0000[12]; //0x0000 + wchar_t* string; //0x000C + char pad_0010[104]; //0x0010 +}; //Size: 0x0078 + +struct generalStats +{ +public: + struct soldierInBattle* generalBgSoldier; //0x0000 + struct soldierInBattle* generalBgMount; //0x0004 +}; //Size: 0x0008 + +struct coordPair +{ +public: + int32_t xCoord; //0x0000 + int32_t yCoord; //0x0004 +}; //Size: 0x0008 + +struct movePath +{ +public: + struct coordPair* tileCoords; //0x0000 + int32_t tileCoordsSize; //0x0004 + int32_t tileCoordsCount; //0x0008 +}; //Size: 0x000C + + +class religionDatabase +{ +public: + void* religionDatabase_vtbl;//0x0000 + struct rcString** religionNames; //0x0004 + int32_t religionNamesSize; //0x0008 + int32_t religionCount; //0x000C + struct rcString** religionPips; //0x0010 + int32_t religionPipsSize; //0x0014 + int32_t religionPipsCount; //0x0018 + void* hashedStringTable; //0x001C + +}; //Size: 0x0020 + +struct capturedCharacter +{ + struct namedCharacter* namedChar; + int32_t capturedValue; +}; + +struct capturedUnit +{ + struct unit* unit; + int32_t capturedSoldiers; + int32_t capturedValue; +}; + +struct capturedFactionInfo +{ + int32_t targetFactionID; + int32_t factionID; + struct namedCharacter* character; + struct namedCharacter* targetCharacter; + int32_t bitMap; + struct capturedCharacter* capturedCharacters; + uint32_t capturedCharactersEnd; + uint32_t capturedCharactersEnd2; + char* logString; + struct capturedUnit* capturedUnits; + uint32_t capturedUnitsEnd; + int32_t capturedUnitsEnd2; + int32_t ransomValue; +}; + +struct floatsSeaConnect +{ +public: + uint32_t tileId; //0x0000 + float someFloat; //0x0004 +}; //Size: 0x0008 + +struct seaConnectedRegion +{ +public: + int32_t regionID; //0x0000 + char pad_0004[4]; //0x0004 + float angle; //0x0008 + float distance; //0x000C + int32_t seaExportValue; //0x0010 + int32_t seaImportValue; //0x0014 + struct floatsSeaConnect* tilesReachable; //0x0018 + int32_t tilesReachableSize; //0x001C + int32_t tilesReachableCount; //0x0020 + struct coordPair* seaTradeLanePath; //0x0024 + int32_t seaTradeLanePathSize; //0x0028 + int32_t seaTradeLanePathCount; //0x002C + char pad_0030[4]; //0x0030 +}; //Size: 0x0034 + struct regionStruct { char* regionName;//0x0000 int regionNameHash;//0x0004 @@ -31,7 +134,9 @@ struct regionStruct { int legioNameHash;//0x0014 undefined field4_0x10[4];//0x0018 int regionID;//0x001C - char pad_0020[12]; //0x0020 + int32_t N00008C49; //0x0020 + int32_t N00008C4A; //0x0024 + int32_t overOneAllowsFamine; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -43,23 +148,46 @@ struct regionStruct { int32_t watchtowersNum; //0x004C int8_t isSea; //0x0050 int8_t hasLake; //0x0051 - char pad_0052[58]; //0x0052 + char pad_0052[2]; //0x0052 + struct landMass* landMass; //0x0054 + struct roadStruct* roadToPort; //0x0054 + struct seaConnectedRegion* seaConnectedRegions; //0x005C + int32_t seaConnectedRegionsCountArraySize; //0x0060 + int32_t seaConnectedRegionsCount; //0x0064 + int32_t loyaltyFactionID; //0x0068 + struct seaConnectedRegion* seaExportRegion; //0x006C + char pad_0070[12]; //0x0070 + struct seaConnectedRegion** seaImportRegions; //0x007C + int32_t seaImportRegionsSize; //0x0080 + int32_t seaImportRegionsCount; //0x0084 + int32_t canSeaTrade; //0x0088 struct mercPool* mercPool;//0x008C - undefined field6_0x90[36];//0x0090 + int32_t* regionSeaEdges; //0x0090 + int32_t regionSeaEdgesSize; //0x0094 + int32_t regionSeaEdgesCount; //0x0098 + char pad_009C[24]; //0x009C float* religionsARR;//0x00B4 - int* religionsEnd; //0x00B8 - undefined field8_0xbc[212];//0x00BC + float* religionHistory[20]; + uint32_t* tilesBorderingEdgeOfMap; //0x0108 + int32_t tilesBorderingEdgeOfMapSize; //0x010C + int32_t tilesBorderingEdgeOfMapCount; //0x0110 + char pad_0114[124]; //0x0114 struct settlementStruct* settlement;//0x0190 - char pad_0194[8]; //0x0194 + int* tiles; //0x0194 + int32_t tilesSize; //0x0198 int32_t tileCount; //0x019C - char pad_0177[12]; //0x0194 + int* fertileTiles; //0x01A0 + int32_t fertileTilesSize; //0x01A4 + int32_t fertileTilesCount; //0x01A8 struct neighbourRegion* neighbourRegions;//0x01AC int32_t neighbourRegionsCountArraySize; //0x01B0 int32_t neighbourRegionsNum; //0x01B4 struct resStrat** resources;//0x01B8 - int32_t resourceCountArrayZie; //0x01BC + int32_t resourcesSize; //0x01BC int32_t resourcesNum; //0x01C0 - char pad_01C4[12]; //0x01C4 + int32_t N00008CB2; //0x01C4 + uint32_t resourceTypesBitMap; //0x01C8 + int32_t N00008CB4; //0x01CC uint32_t hiddenResources1; //0x01D0 uint32_t hiddenResources2; //0x01D4 char pad_01D8[4]; //0x01D8 @@ -87,20 +215,45 @@ struct neighbourRegion int32_t regionID; //0x0004 float distance; //0x0008 char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + struct roadStruct* connectingRoad; //0x0010 + int32_t tradeValue; //0x0014 + int32_t* bordertiles; //0x0018 + int32_t borderTilessize; //0x001C + int32_t borderTilesCount; //0x0020 + char pad_0024[52]; //0x0024 }; //Size: 0x0058 +struct landMass +{ +public: + int32_t index; //0x0000 + int32_t* regions; //0x0004 + int32_t regionsSize; //0x0008 + int32_t regionsNum; //0x000C +}; //Size: 0x0010 + struct stratMap { - undefined field_0x0[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + char pad_000C[28]; //0x000C + void* climates; //0x0028 int mapWidth; int mapHeight; undefined field_0x34[20]; struct oneTile* tilesArr; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD TileListEnd; //0x004C + undefined field_0x50[20]; + struct coordPair* volcanoes; //0x0064 + int32_t volcanoesSize; //0x0068 + int32_t volcanoesNum; //0x006C + struct coordPair* landMassConnections; //0x0070 + int32_t landMassConnectionsSize; //0x0074 + int32_t landMassConnectionsNum; //0x0078 struct regionStruct regions[200]; int regionsNum; + struct landMass landMass[20]; //0x1A660 + int32_t landMassNum; //0x1A7A0 }; struct mercPoolUnit { @@ -170,9 +323,24 @@ struct uiElement { undefined field_0x58[112]; }; +struct roadStruct +{ +public: + struct coordPair* coords; //0x0000 + int32_t coordsSize; //0x0004 + int32_t coordsNum; //0x0008 + void* someOtherArray; //0x000C + int32_t someOtherArraySize; //0x0010 + int32_t someOtherArrayCount; //0x0014 + int32_t regionIdStart; //0x0018 + int32_t regionIdEnd; //0x001C + char pad_0020[24]; //0x0020 +}; //Size: 0x0038 + struct oneTile { void* object; - undefined field_0x4[6]; + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -188,9 +356,13 @@ struct oneTile { int8_t hasRoad; int8_t border; undefined field_0x22[2]; - int8_t objectTypes; + int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 int8_t passable; - undefined field_0x26[14]; + int8_t N0002227F; //0x0026 + int8_t N00022271; //0x0027 + uint32_t armiesNearTile; //0x0028 + uint32_t charactersOnTile; //0x002C + float mpModifier; //0x0030 }; struct siegeS { @@ -199,20 +371,77 @@ struct siegeS { struct stackStruct* army; }; -//diplomacy data of faction to another faction -struct factionDiplomacy { - undefined field_0x0[16]; - int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ - int trade; /* trade rights(0 or 1) */ - int protectorate; /* protectorate or not(15 or 6) */ - undefined field_0x1c[108]; -}; +struct stringWithHash +{ +public: + char* name; //0x0000 + int32_t hash; //0x0004 +}; //Size: 0x0008 + +struct holdRegionsWinCondition +{ +public: + char pad_0000[4]; //0x0000 + int32_t intSomethingTurns; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + char pad_0014[4]; //0x0014 + int32_t numberOfRegions; //0x0018 + char pad_001C[4]; //0x001C + int32_t* holdRegionLengths; //0x0020 + int32_t holdRegionLengthsSize; //0x0024 + int32_t holdRegionLengthsCount; //0x0028 + char pad_002C[12]; //0x002C +}; //Size: 0x0080 + +struct battleSettlement +{ +public: + char pad_0000[4]; //0x0000 + struct settlementStruct* settlement; //0x0004 + char pad_0008[4]; //0x0008 + struct battleResidence* battleResidence; //0x000C + char pad_0010[304]; //0x0010 +}; //Size: 0x0140 + +struct battleResidence +{ +public: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + char pad_0034[8]; //0x0034 + float N000203C6; //0x003C + float N000203C7; //0x0040 + char pad_0044[40]; //0x0044 + int8_t settlementWallsBreached; //0x006C + int8_t settlementGateDestroyed; //0x006D + char pad_006E[2]; //0x006E + int8_t N0003A33C; //0x0070 + char pad_0071[7]; //0x0071 + float N0003A33E; //0x0078 + char pad_007C[200]; //0x007C +}; //Size: 0x0144 + +struct factionRanking +{ +public: + float totalRanking; //0x0000 + float militaryRanking; //0x0004 + float productionRanking; //0x0008 + float territoryRanking; //0x000C + float FinancialRanking; //0x0010 + float populationRanking; //0x0014 +}; //Size: 0x0018 struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int id; char* facName; DWORD facNameHash; - undefined field_0xc[60]; + undefined field_0xc[56]; + int religionID; struct model_Rigid* symbol; char* symbolPath; DWORD symbolPathHash; @@ -233,7 +462,26 @@ struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int standard_index; int logo_index; int small_logo_index; - undefined field_0x88[88]; + undefined field_0x88[20]; + int32_t hordeMaxUnits; //0x009C + char pad_00A0[28]; //0x00A0 + uint8_t customBattleAvailability; //0x00BC + char pad_00BD[3]; //0x00BD + uint32_t periodsUnavailableInCustomBattle; //0x00C0 + uint8_t N00008DC2; //0x00C4 + uint8_t canSap; //0x00C5 + char pad_00C6[2]; //0x00C6 + int32_t prefersNavalInvasions; //0x00C8 + uint8_t canHavePrincess; //0x00CC + char pad_00CD[3]; //0x00CD + char* specialfactionType; //0x00D0 + char pad_00D4[4]; //0x00D4 + uint8_t hasFamilyTree; //0x00D8 + uint8_t teutonic; //0x00D9 + uint8_t disbandToPools; //0x00DA + uint8_t canBuildSiegeTowers; //0x00DB + uint8_t canTransmitPlague; //0x00DC + char pad_00DD[3]; //0x00DD }; struct watchTowerModel { @@ -262,6 +510,91 @@ struct worldRecord { undefined field_0x38[40]; }; +struct crusade +{ +public: + char pad_0000[20]; //0x0000 + void* N0000121D; //0x0014 + char pad_0018[28]; //0x0018 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[252]; //0x0048 + void* N00001269; //0x0144 + char pad_0148[44]; //0x0148 +}; //Size: 0x0174 + + + +struct jihad +{ +public: + char pad_0000[52]; //0x0000 + int32_t startTurn; //0x0034 + int32_t endTurn; //0x0038 + struct settlementStruct* targetSettlement; //0x003C + int32_t length; //0x0040 + int32_t outcome; //0x0044 + char pad_0048[292]; //0x0048 +}; //Size: 0x016C + +struct settlementList +{ + struct settlementStruct** settlements; //0x0000 + struct settlementList* nextSettlements; //0x0004 + struct settlementList* previousSettlements; //0x0008 + int32_t settlementsSize; //0x000C + int32_t settlementsNum; //0x0010 +}; + + +struct factionDiplomacy +{ +public: + char pad_0000[4]; //0x0000 + int state; /* diplomatic state(war, alliance, peace)(600/0/200) */ + int trade; /* trade rights(0 or 1) */ + int protectorate; /* protectorate or not(15 or 6) */ + float factionStanding; //0x0010 + char pad_0014[116]; //0x0014 +}; //Size: 0x0088 + +struct trackedCharacter +{ +public: + struct N0001F08D* N0001F061; //0x0000 + struct general* character; //0x0004 +}; //Size: 0x0008 + +struct cardinal +{ +public: + struct trackedCharacter* trackedCharacter; //0x0000 + struct N0001F079* cardinalInfo; //0x0004 +}; //Size: 0x0008 + +struct collegeOfCardinals +{ +public: + char pad_0000[4]; //0x0000 + struct namedCharacter* pope; //0x0004 + char pad_0008[4]; //0x0008 + struct cardinal* cardinalsArray; //0x000C + int32_t cardinalsArraySize; //0x0010 + int32_t cardinalNum; //0x0014 + int8_t N0001D9D6; //0x0018 + int8_t getsUsedForCountVotes; //0x0019 + int8_t N0001F1B6; //0x001A + int8_t N0001F1B4; //0x001B + struct N0001F0B9* someOtherArray; //0x001C + int32_t someOtherArraySize; //0x0020 + int32_t someOtherArrayCount; //0x0024 + struct UNICODE_STRING** localizedCardinalNames; //0x0028 + char pad_002C[32]; //0x002C +}; //Size: 0x004C + struct campaign { undefined field0_0x0[4]; undefined field1_0x4[52]; @@ -271,22 +604,22 @@ struct campaign { undefined field5_0x44[232]; int humanPlayers; /* number of player-controlled factions */ int factionIdPow; /* pow(2,factionId) */ - int campaignDifficultyFaction[8]; - undefined field9_0x154[120]; - int battleDifficulty07; - undefined field11_0x1d0[88]; - int battleDifficulty30; + int32_t campaignDifficultyFaction[31]; + int32_t battleDifficultyFaction[31]; struct factionStruct* factionsSortedByDescrStrat[31]; struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; - undefined field16_0x328[28]; + char pad_0328[20]; //0x0328 + struct collegeOfCardinals* collegeOfCardinals; //0x033C + struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; - int field18_0x348; /* FactionTurn? */ + int factionTurnID; /* FactionTurn? */ UNICODE_STRING** currentDescrFile; /* path to descr_battle.txt or to descr_strat.txt */ - undefined field20_0x350[28]; - int field21_0x36c; /* TickCount? */ - int MillisecondCount; - float SecondCount; + int32_t fogOfWar; //0x0350 + undefined field20_0x354[24]; + int tickCount; /* TickCount? */ + int millisecondCount; + float secondCount; int TurnNumber; int field25_0x37c; /* PauseForBattleDialog? */ float TimeScale; @@ -300,17 +633,22 @@ struct campaign { undefined field34_0x3d2[26]; float BrigandSpawnValue; float PirateSpawnValue; - undefined field37_0x3f4[4]; + int8_t N00001211; //0x03F4 + int8_t smthingDateTurnDisplay; //0x03F5 + int8_t restrictAutoResolve; //0x03F6 + char pad_03F7[1]; //0x03F7 int FreeUpkeepForts; int ActiveFactions; /* number factions minus slave */ undefined field40_0x400[12]; int lastrandomseed; - undefined field42_0x410[744]; - int8_t isAdminPasswordExist; - int8_t isHotseatLogon; - undefined field45_0x6fa[2]; + struct crusade crusade; //0x0410 + struct jihad jihad; //0x0584 + struct UNICODE_STRING** someUniStringMaybePassword; //0x06F0 + int8_t isAdminPasswordExist; //0x06F4 + int8_t saveEnabled; //0x06F5 + undefined field45_0x6f6[6]; int8_t hotseatConsole; - int8_t hotseatConsole2; + int8_t hotseatConsoleEnabledWithLogon; undefined field48_0x6fe[14]; float currentDate; int season; /* season(0-summer,1-winter) */ @@ -322,18 +660,49 @@ struct campaign { float timeAtStartBattle; int daysInBattle; float currentTimeInBattle; /* 24 max, so calc as daysInBattle*24+currentTimeInBattle */ - undefined field59_0x734[4124]; - struct factionDiplomacy dipArray[31][31]; - undefined field61_0x215d8[48]; + char pad_0734[28]; //0x0734 + float clockTime; //0x0750 + char pad_0754[260]; //0x0754 + int32_t interFactionMarriage[31][31]; //0x0858 + struct factionDiplomacy diplomaticStandings[31][31]; //0x175C + struct settlementList settlementList; //0x215E4 + char* introVid; //0x215F8 + char pad_215FC[16]; //0x215FC struct fortStruct** fortsArray; - undefined field63_0x2160c; - int fortsNum; + int32_t fortsSize; //0x21610 + int32_t fortsNum; //0x21614 struct portBuildingStruct** portsBuildings; - undefined field66_0x21615; - int portsBuildingsNum; + int32_t portsBuildingsSize; //0x2161C + int32_t portsBuildingsNum; //0x21620 struct watchTowerStruct** watchtowers; - undefined field69_0x2161e; - int watchtowersNum; + int32_t watchtowersSize; //0x21628 + int32_t watchtowersNum; //0x2162C +}; + +struct uiUnitCard +{ +public: + char pad_0000[380]; //0x0000 + unit* unit; //0x0384 +}; + +struct uiCardManager +{ +public: + char pad_0000[16]; //0x0000 + struct uiUnitCard** selectedUnitCards; //0x0010 + int32_t selectedUnitCardsSize; //0x0014 + int32_t selectedUnitCardsCount; //0x0018 + char pad_001C[24]; //0x001C + struct uiUnitCard** unitCards; //0x0034 + int32_t unitCardsSize; //0x0038 + int32_t unitCardsCount; //0x003C + char pad_0060[328]; //0x0060 + struct settlementStruct* selectedSettlement; //0x0188 + char pad_018C[12]; //0x018C + struct general* selectedCharacter; //0x0198 + char pad_019C[12]; //0x019C + struct fortStruct* selectedFort; //0x01A8 }; struct gameDataAllStruct { @@ -344,7 +713,11 @@ struct gameDataAllStruct { struct campaign* field_0x38; undefined field_0x3c[28]; struct battleDataS* battleHandler; - undefined field_0x5c[8]; + undefined field_0x5c[36]; + struct battleSettlement* battleSettlement; + char pad[112]; + struct uiCardManager* uiCardManager; + char pad2[84]; }; struct battleUnit @@ -360,13 +733,242 @@ struct battleUnit int32_t soldiersStart; //0x001C uint32_t unitsRouted; //0x0020 int32_t soldiersHealed; //0x0024 - char pad_0028[4]; //0x0028 + int32_t unitsRoutedEnd; //0x0028 int32_t soldiersEnd; //0x002C - char pad_0030[8]; //0x0030 - int8_t hasRouted; //0x0038 - char pad_0039[15]; //0x0039 + int32_t friendlyFireCasualties; //0x0030 + int32_t expStart; //0x0034 + int32_t expGained; //0x0038 + int8_t isGeneral; //0x003C + char pad_003D[11]; //0x003D }; //Size: 0x0048 +struct options1 +{ + void* cursor; //0x0000 + int8_t N0003DD45; //0x0004 + int8_t widescreen; //0x0005 + char pad_0006[2]; //0x0006 + int64_t antiAliasMode; //0x0008 + int16_t subtitles; //0x0010 + int8_t english; //0x0012 + int8_t noBattleTimeLimit; //0x0013 + char pad_0014[4]; //0x0014 + int32_t useNewCursorActions; //0x0018 + int32_t campaignNumTimesPlay; //0x001C + int8_t uiWinConditions; //0x0020 + int8_t isScenario; //0x0021 + char pad_0022[2]; //0x0022 + int32_t isHotseatEnabled; //0x0024 + int8_t hotseatAutosave; //0x0028 + int8_t email; //0x0029 + int8_t saveConfig; //0x002A + int8_t closeAfterSave; //0x002B + int8_t validateData; //0x002C + int8_t campaignMapSpeedUp; //0x002D + char pad_002E[2]; //0x002E + int32_t skipAiFactions; //0x0030 + int8_t labelCharacters; //0x0034 + int8_t noBackGroundFmv; //0x0035 + int8_t disableArrowMarkers; //0x0036 + int8_t arcadeBattles; //0x0037 + int8_t disableEvents; //0x0038 + int8_t isPrologue; //0x0039 + int8_t updateAiCamera; //0x003A + int8_t hideCampaign; //0x003B + int32_t unlimitedMenOnBattlefield; //0x003C + char pad_0040[4]; //0x0040 + class N0003DA46* prefFactionsPlayed; //0x0044 + int32_t tgaReserveSpace; //0x0048 + int32_t keysetUsed; //0x004C + class N0003DD67* descrShortcuts; //0x0050 + int8_t muteAdvisor; //0x0054 + int8_t advancedStatsAlways; //0x0055 + int8_t microManageAllSettlements; //0x0056 + int8_t blindAdvisor; //0x0057 + int32_t terrainQuality; //0x0058 + int32_t vegetationQuality; //0x005C + int8_t useQuickChat; //0x0060 + int8_t someBoolNetworkManager; //0x0061 + char pad_0062[1]; //0x0062 + int8_t someBoolOnlinePlay; //0x0063 + int32_t graphicsAdaptor; //0x0064 + int8_t byte_2C6D86C; //0x0068 + int8_t showDemeanour; //0x0069 + char pad_006A[2]; //0x006A + int32_t radar; //0x006C + int32_t unitCards; //0x0070 + int32_t sa_cards; //0x0074 + int32_t buttons; //0x0078 + int8_t tutorialBattlePlayed; //0x007C + int8_t disableVnVs; //0x007D + int8_t allUsers; //0x007E + char pad_007F[29]; //0x007F + int32_t unk_2C6D8A0; //0x009C + char pad_00A0[28]; //0x00A0 + char* audioProvider; //0x00BC + char pad_00C0[20]; //0x00C0 + struct UNICODE_STRING** campaignName; //0x00D4 + char pad_00D8[4]; //0x00D8 + struct UNICODE_STRING*** N0003DA7C; //0x00DC + struct UNICODE_STRING*** maybeGameSpyUsername; //0x00E0 + struct UNICODE_STRING*** gameSpyPassword; //0x00E4 + char pad_00E8[4]; //0x00E8 + char* gameName; //0x00EC + char pad_00F0[24]; //0x00F0 + char adminPassword[28]; //0x0108 + char* tutorialPath; //0x0124 +}; //Size: 0x0128 + + +struct options2 +{ + uint16_t defaultCampaignResolutionX; //0x0000 + uint16_t defaultCampaignResolutionY; //0x0002 + uint16_t campaignResolutionX; //0x0004 + uint16_t campaignResolutionY; //0x0006 + uint16_t defaultBattleResolutionX; //0x0008 + uint16_t defaultBattleResolutionY; //0x000A + uint16_t battleResolutionX; //0x000C + uint16_t battleResolutionY; //0x000E + int8_t idk; //0x0010 + int8_t vSync; //0x0011 + char pad_0012[6]; //0x0012 + int8_t uiIconBarCheck; //0x0018 + int8_t uiRadarCheck; //0x0019 + int8_t useMorale; //0x001A + int8_t uiAmmoCheck; //0x001B + int8_t useFatigue; //0x001C + int8_t uiSupplyCheck; //0x001D + int8_t toggleFowState; //0x001E + int8_t cameraRestrict; //0x001F + int8_t eventCutscenes; //0x0020 + char pad_0021[3]; //0x0021 + int32_t defaultCameraInBattle; //0x0024 + int8_t splashes; //0x0028 + int8_t vegetationVideo; //0x0029 + int8_t byte_1639F1A; //0x002A + int8_t stencilShadows; //0x002B + int8_t byte_1639F1C; //0x002C + int8_t audioEnable; //0x002D + int8_t speechEnable; //0x002E + int8_t firstTimePlay; //0x002F + char* audioProviderName; //0x0030 + char pad_0034[1]; //0x0034 + int8_t byte_1639F25; //0x0035 + char pad_0036[1]; //0x0036 + int8_t toggleAutoSave; //0x0037 + int8_t showBanners; //0x0038 + int8_t passwords; //0x0039 + int8_t hotseatTurns; //0x003A + int8_t hotseatScroll; //0x003B + int32_t allowValidationFeatures; //0x003C + int32_t campaignSpeed; //0x0040 + int8_t labelSettlements; //0x0044 + int8_t disablePapalElections; //0x0045 + int8_t autoresolveAllBattles; //0x0046 + int8_t savePrefs; //0x0047 + int8_t disableConsole; //0x0048 + int8_t validateDiplomacy; //0x0049 + char pad_004A[2]; //0x004A + float someFloat; //0x004C + int32_t unitDetail; //0x0050 + int32_t buildingDetail; //0x0054 + int32_t maxSoldiersOnBattlefield; //0x0058 + int32_t unitSize; //0x005C + int32_t cameraRotateSpeed; //0x0060 + int32_t cameraMoveSpeed; //0x0064 + float cameraSmoothing; //0x0068 + int32_t somethingBasedOnBuildingDetail; //0x006C + int32_t masterVolume; //0x0070 + int32_t musicVolume; //0x0074 + int32_t speechVolume; //0x0078 + int32_t sfxVolume; //0x007C + int32_t subFactionAccents; //0x0080 + int32_t playerFactionId; //0x0084 + int32_t campaignDifficulty; //0x0088 + int32_t battleDifficulty; //0x008C + int32_t tgaWidth; //0x0090 + float tgaAspect; //0x0094 + int32_t tgaInputScale; //0x0098 + int32_t scrollMinZoom; //0x009C + int32_t scrollMaxZoom; //0x00A0 + int32_t advisorVerbosity; //0x00A4 + int8_t useSomethingTgaTextures; //0x00A8 + int8_t byte_1639F99; //0x00A9 + char pad_00AA[2]; //0x00AA + int32_t effectQuality; //0x00AC + int32_t EnableCameraCampaignSmoothing; //0x00B0 + int32_t chatMsgDuration; //0x00B4 + int8_t N0003DDF9; //0x00B8 + int8_t saveGameSpyPassword; //0x00B9 + int8_t addDateToLogs; //0x00BA + int8_t showToolTips; //0x00BB + int8_t isNormalHud; //0x00BC + int8_t showPackageLitter; //0x00BD + char pad_00BE[2]; //0x00BE + char* normal; //0x00C0 + char pad_00C4[8]; //0x00C4 + int32_t effectNormal; //0x00CC + char pad_00D0[8]; //0x00D0 + char* low; //0x00D8 + char pad_00DC[8]; //0x00DC + int32_t effectLow; //0x00E4 + char pad_00E8[8]; //0x00E8 + char* high; //0x00F0 + char pad_00F4[8]; //0x00F4 + int32_t effectHigh; //0x00FC + char pad_0100[8]; //0x0100 + char* lowest; //0x0108 + char pad_010C[8]; //0x010C + int32_t effectLowest; //0x0114 + char pad_0118[8]; //0x0118 + char* highest; //0x0120 + char pad_0124[8]; //0x0124 + int32_t effectHighest; //0x012C + char pad_0130[8]; //0x0130 + char* custom; //0x0138 + char pad_013C[8]; //0x013C + int32_t effectCustom; //0x0144 + char pad_0148[8]; //0x0148 + char* lower; //0x0150 + char pad_0154[8]; //0x0154 + int32_t effectLower; //0x015C + char pad_0160[8]; //0x0160 + char* higher; //0x0168 + char pad_016C[8]; //0x016C + int32_t effectHigher; //0x0174 + char pad_0178[8]; //0x0178 + char* off; //0x0180 + char pad_0184[8]; //0x0184 + int32_t effectOff; //0x018C + char pad_0190[32]; //0x0190 + int32_t maxSizeEduMaybe1; //0x01B0 + float unitMultDefault; //0x01B4 + int32_t unitMultDefaultId; //0x01B8 + int32_t maxSizeEduMaybe2; //0x01BC + float unitSizeMultiplierLow; //0x01C0 + int32_t unitMult1ID; //0x01C4 + int32_t maxSizeEduMaybe3; //0x01C8 + float unitSizeMultiplierMedium; //0x01CC + int32_t unitMult2ID; //0x01D0 + int32_t maxSizeEduMaybe4; //0x01D4 + float unitSizeMultiplierLarge; //0x01D8 + int32_t unitMult3ID; //0x01DC + char pad_01E0[12]; //0x01E0 + uint16_t word_163A0DC; //0x01EC + char pad_01EE[10]; //0x01EE + uint16_t word_163A0E8; //0x01F8 + char pad_01FA[2]; //0x01FA + uint16_t word_163A0EC; //0x01FC + char pad_01FE[54]; //0x01FE + int16_t currentHotseatPlayerOrSomething; //0x0234 + char pad_0236[2]; //0x0236 + class N0003DF44* keysetPointer; //0x0238 + char pad_023C[4]; //0x023C + int32_t keySetUsed; //0x0240 + int32_t preferencesWereLoaded; //0x0244 +}; + struct armyAndCharacter { /* in battle leader and leader army */ struct stackStruct* army;//0x0000 @@ -375,11 +977,18 @@ struct armyAndCharacter { /* in battle leader and leader army */ float generalHPRatioLost; //0x000C float someFloat; //0x0010 float battleOdds; //0x0014 - char pad_0018[20]; //0x0018 + char pad_0018[12]; //0x0018 + struct general* killedGenerals; //0x0024 + int32_t killedGeneralsSize; //0x0028 int32_t numKilledGenerals; //0x002C - char pad_0030[36]; //0x0030 - DWORD N0001FC50; //0x0054 - char pad_0058[68]; //0x0058 + char pad_0030[24]; //0x0030 + struct general* generalsDied; //0x0048 + int32_t generalsDiedSize; //0x004C + int32_t generalsDiedCount; //0x0050 + struct general* killedCaptains; //0x0054 + int32_t killedCaptainsSize; //0x0058 + int32_t killedCaptainsCount; //0x005C + char pad_005C[60]; //0x005C struct battleUnit* units; //0x009C int32_t unitArraySize; //0x00A0 int32_t unitCount; //0x00A4 @@ -538,6 +1147,13 @@ struct battleSide { char pad_1928[4]; //0x1928 }; +struct playerArmy +{ +public: + struct stackStruct* army; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + struct battleDataS { undefined field_0x0[4];//0x0000 int battleState; /* 0-not in battle,5-active battle,9-results screen,etc 0x0004 */ @@ -556,11 +1172,32 @@ struct battleDataS { float speed; //0x0058 char pad_005C[8]; //0x005C float secondsPassed; //0x0064 - char pad_0068[48]; //0x0068 + int32_t secondsSinceBattleLoaded; //0x0068 + char pad_006C[16]; //0x006C + float mapWidthDoubled; //0x007C + float mapHeightDoubled; //0x0080 + char pad_0084[12]; //0x0084 + int32_t hidingEnabledSet; //0x0090 + char pad_0094[4]; //0x0094 struct UNICODE_STRING** someUniString; //0x0098 struct battleSide sides[8]; //0x009C int32_t factionSide[31]; //0xC9FC int sidesNum;//0xCA78 + char pad_CA7C[44]; //0xCA7C + struct playerArmy playerArmies[30]; //0xCAA8 + char pad_CD78[4]; //0xCD78 + int32_t playerArmyCount; //0xCD7C + char pad_CD80[84]; //0xCD80 + int32_t N0001D4DC; //0xCDD4 + int32_t N0001D4DD; //0xCDD8 + char pad_CDDC[20]; //0xCDDC + int32_t N0001D4E3; //0xCDF0 + int32_t N0001D4E4; //0xCDF4 + char pad_CDF8[4]; //0xCDF8 + int32_t N0001D4E6; //0xCDFC + int32_t N0001D4E7; //0xCE00 + char pad_CE04[44]; //0xCE04 + struct battleDataS* thisStruct; //0xCE30 };//Size: 0xCA7C struct stratPortModel { @@ -978,6 +1615,36 @@ struct RallyPointSundry { undefined field4_0x44[16]; }; +struct settlementCapability +{ +public: + int16_t value; //0x0000 + int16_t bonus; //0x0002 +}; //Size: 0x0004 + +struct recruitCapRome +{ +public: + char pad[8]; +}; //Size: 0x0008 + +struct recruitmentCapability +{ +public: + int32_t eduIndex; //0x0000 + int32_t xp; //0x0004 + float initialSize; //0x0008 + float replenishRate; //0x000C + float maxSize; //0x0010 +}; //Size: 0x0014 + +struct settlementRecruitmentPool +{ +public: + int32_t eduIndex; //0x0000 + float availablePool; //0x0004 +}; //Size: 0x0008 + //settlement struct settlementStruct { void* vTable; @@ -1022,19 +1689,51 @@ struct settlementStruct { undefined field26_0x5ac[520]; struct building* buildings[128]; int buildingsNum; /* number of the buildings in the settlement */ - undefined field29_0x9b8[1100]; - uchar isProvokedRebellion; - uchar field31_0xe05[3]; - undefined field32_0xe08[24]; - struct general* governor; - undefined field34_0xe24[32]; + undefined field29_0x9b8[1080]; + int32_t rallyPointX; //0x0DF0 + int32_t rallyPointY; //0x0DF4 + void* rallyPointPointer; //0x0DF8 + void* AIProductionController; //0x0DFC + char pad_0E00[4]; //0x0E00 + int8_t scriptRebel; //0x0E04 + uchar isProvokedRebellion;//0x0E05 + uchar field31_0xe06[34];//0x0E06 + struct general* governor;//0x0E28 + char pad_0E2C[12]; //0x0E2C + int32_t publicOrderLastTurnEnd; //0x0E38 + int32_t populationLastTurnEnd; //0x0E3C + char pad_0E40[4]; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct settlementCapability settlementCapabilities[57]; //0x0E54 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 + struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) + char pad_0F78[4]; //0x0F78 + struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C + struct recruitmentCapability recruitmentCapabilities[64]; //0x117C + int32_t recruitPoolCapabilityCount; //0x167C + int8_t N000089C8; //0x1680 + char pad_1681[3]; //0x1681 + struct settlementStruct* thisSett; //0x1684 + struct settlementRecruitmentPool* recruitmentPools; //0x1688 + int32_t recruitmentPoolsSize; //0x168C + int32_t recruitmentPoolCount; //0x1690 + char pad_1694[12]; //0x1694 + int8_t freezeRecruitmentPool; //0x16A0 + char pad_16A1[3]; //0x16A1 + int32_t spiesInRecruitmentQueue; //0x16A4 + int32_t assassinsInRecruitmentQueue; //0x16A8 + int32_t diplomatsInRecruitmentQueue; //0x16AC + int32_t admiralsInRecruitmentQueue; //0x16B0 + int32_t merchantsInRecruitmentQueue; //0x16B4 + int32_t priestsInRecruitmentQueue; //0x16B8 + char pad_16BC[8]; //0x16BC intptr_t guildStandings; char pad_16C8[56]; //0x16C8 - int32_t Turmoil; //0x1700 + int32_t turmoil; //0x1700 char pad_1704[116]; //0x1704 int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C @@ -1134,24 +1833,56 @@ struct general { /* character on the stratmap, who has a unit in a stack */ struct genMod* genType; undefined field9_0x8c[24]; uchar ifMarkedToKill; - undefined field11_0xa5[19]; + undefined field11_0xa5[1]; + int8_t inEnemyZOC; //0x00A6 + char pad_00A7[17]; //0x00A7 int ambushState; undefined field13_0xbc[12]; - float movepoints1; + int8_t doNotSpendMovePoints; //0x00C5 + char pad_00C6[2]; //0x00C6 + float movePointsCharacter; undefined field15_0xcc[4]; uchar isStopCharacterNeeded; /* set to 1 if character moving now and he stops */ - undefined field17_0xd1[47]; + int32_t numTurnsIdle; //0x00D4 + int32_t regionID; //0x00D8 + float percentCharacterReligionInRegion; //0x00DC + float popConvertedThisTurn; //0x00E0 + int32_t timeInRegion; //0x00E4 + int32_t timeWithArmy; //0x00E8 + char pad_00EC[20]; //0x00EC struct stackStruct* armyLeaded; /* army of the general */ undefined field19_0x104[4]; struct unit* bodyguards; /* unit of general */ struct stackStruct* armyNotLeaded; /* army, if not leader */ undefined field22_0x110[208]; undefined field23_0x1e0[4]; - float movepointsModifier; - float movepointsMax; - float movepoints2; - undefined field27_0x1f0[64]; + float movePointsModifier; + float movePointsMax; + float movePointsArmy; + float movePointsMaxArmy; //0x01F0 + struct crusade* crusade; //0x01F4 + int32_t turnJoinedCrusade; //0x01F8 + int32_t currentTurn; //0x01FC + char pad_0200[48]; //0x0200 char* ability; /* custom ability */ + char pad_0234[4]; //0x0234 + struct general* thisCharacter; //0x0238 + char pad_023C[16]; //0x023C + struct general* thisCharacter2; //0x024C + int32_t xCoordLast; //0x0250 + int32_t yCoordLast; //0x0254 + int32_t xCoordCurrent; //0x0258 + int32_t yCoordCurrent; //0x025C + char pad_0260[332]; //0x0260 + void* someCoordStruct; //0x03AC + int32_t someCoordStructSize; //0x03B0 + int32_t someCoordStructCount; //0x03B4 + struct movePath* multiTurnMovePaths; //0x03B8 + int8_t multiTurnMovePathsSize; //0x03BC + int8_t multiTurnMovePathsCount; //0x03BD + int8_t N00032E71; //0x03BE + int8_t N00032E76; //0x03BF + char pad_03C0[8]; //0x03C0 }; //additional character data(name,label,traits, etc) @@ -1236,7 +1967,7 @@ struct namedCharacter { /* many important info about character */ int32_t battleSurgery; //0x01E0 struct traitContainer* traits; /* names at [item number] -0x4-here. Not have number, read it in while(traits != 0){this->m_memory->Read(traits + 0x08, 4).toINT32();} */ undefined field_0x1e8[4]; - struct ancData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ + struct anchData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ undefined field_0x1f0[4]; UINT32 anchNum; /* number of character ancillaries */ struct general* gen; /* on stratmap */ @@ -1319,34 +2050,411 @@ struct engineRecord { }; struct soldierInBattle { - undefined field_0x0[24]; + undefined field_0x0[8]; + int32_t unitCategory; //0x0008 + int16_t someFlags; //0x000C + int8_t N00008AC5; //0x000E + int8_t N00008AC7; //0x000F + float mass; //0x0010 + float inverseMass; //0x0014 float xCoord; float zCoord; float yCoord; - undefined field_0x24[1440]; -}; + struct soldierInBattle* self; //0x0024 + float someRadius1; //0x0028 + float someRadius2; //0x002C + float someRadius3; //0x0030 + float markerRadius; //0x0034 + float height; //0x0038 + char pad_003C[8]; //0x003C + int16_t rotation; //0x0044 + char pad_0046[2]; //0x0046 + float velocity1; + float velocity2; + float velocity3; + char pad_0054[196]; //0x0054 + struct soldierInBattle* self2; //0x0118 + char pad_011C[4]; //0x011C + float speed; //0x0120 + char pad_0124[4]; //0x0124 + float xCoord_writable; + float zCoord_writable; + float yCoord_writable; + uint16_t angle_writable; //0x0134 + int8_t N0000713A; //0x0136 + int8_t N00009525; //0x0137 + float velocityModifier; //0x0138 + int32_t currentStateGroupID; //0x013C + int32_t currentStateStateID; //0x0140 + int32_t pendingStateGroupID; //0x0144 + int32_t pendingStateStateID; //0x0148 + char pad_014C[4]; //0x014C + float xCoord_destination; + float zCoord_destination; + float yCoord_destination; + int16_t destinationAngle; //0x015C + int16_t thisIsAngleCauseTwoByteMaybe; //0x015E + float destinationRadius; //0x0160 + char pad_0164[16]; //0x0164 + int16_t N00001DC6; //0x0174 + char pad_0176[2]; //0x0176 + int32_t targetStateGroupID; //0x0178 + int32_t targetStateStateID; //0x017C (One = Standing, 2 = Walking, 3 = running) + int32_t moveStateGroupID; //0x0180 + int32_t moveStateStateID; //0x0184 (2 = walking, 3 = running) + int32_t finishStateGroupID; //0x0188 + int32_t finishStateStateID; //0x018C + int32_t options; //0x0190 + int32_t pendingAction; //0x0194 + float stoppingModifier; //0x0198 + float slideRotation; //0x019C + int32_t numTicks; //0x01A0 + char pad_01A4[20]; //0x01A4 + int32_t surfaceID; //0x01B8 + int16_t pathHistoryAndObstacleDirection; //0x01BC + int16_t unk; //0x01BE + char pad_01C0[16]; //0x01C0 + int16_t waypoint; //0x01D0 + char pad_01D2[18]; //0x01D2 + int16_t cone; //0x01E4 + int16_t directionOffset; //0x01E6 + int16_t blockedCounter; //0x01E8 + int16_t N0000954E; //0x01EA + float radiusModifier; //0x01EC + float speedModifier; //0x01F0 + int32_t deflectionCounter; //0x01F4 + float stoppingDistance; //0x01F8 + float externalModifier; //0x01FC + uint32_t locomotionFlags; //0x0200 + char pad[960]; //0x01D2 + +}; + +struct generalInfo +{ +public: + char** generalModelName; //0x0000 + struct unit* unit; //0x0004 + struct namedCharacter* namedChar; //0x0008 + char pad_000C[48]; //0x000C + int8_t N00010FEA; //0x003C + char pad_003D[43]; //0x003D + struct soldierInBattle* soldier; //0x0068 + int8_t isCharacter; //0x006C + int8_t alive; //0x006D + char pad_006E[2]; //0x006E + struct heroAbility* ability; //0x0070 + char pad_0074[144]; //0x0074 +}; //Size: 0x0104 + +struct floatPosData +{ +public: + float rotStart; //0x0000 + float coord2_1; //0x0004 + float coord2_2; //0x0008 + float coord3_2; //0x000C + float coord3_1; //0x0010 + float coord0_2; //0x0014 + float coord0_1; //0x0018 + float unk1; //0x001C + float unk2; //0x0020 + float unk; //0x0024 + float rotation1; //0x0028 + float rotation2; //0x002C + float coord1_1; //0x0030 + float coord1_2; //0x0034 + float val15; //0x0038 + float rotValue1; //0x003C + float rotValue2; //0x0040 +}; //Size: 0x0044 + +struct targetUnitStruct +{ +public: + char pad_0000[4]; //0x0000 + struct unit* target; //0x0004 + char pad_0008[4]; //0x0008 + int32_t targetUnitIndex; //0x000C + char pad_0010[4]; //0x0010 +}; //Size: 0x0014 + +struct targetPos +{ +public: + int32_t typeOrSomething; //0x0000 + int32_t N0001B8DA; //0x0004 + void* unitVerificationTable; //0x0008 + struct targetUnitStruct* targetUnit; //0x000C + char pad_0010[4]; //0x0010 + float targetPosXStart; //0x0014 + float targetPosYStart; //0x0018 + char pad_001C[16]; //0x001C + int32_t noDraggedFormation; //0x002C + float N0001B8E5; //0x0030 + float N0001B8E6; //0x0034 + char pad_0038[4]; //0x0038 + float somethingDistanceRelated; //0x003C + int32_t ranks; //0x0040 + float N0001B8EA; //0x0044 + char pad_0048[4]; //0x0048 + float N0001B8EC; //0x004C + char pad_0050[4]; //0x0050 + int8_t N0001B8EE; //0x0054 + int8_t draggedFormation1; //0x0055 + int8_t N0003D819; //0x0056 + int8_t draggedFormation2; //0x0057 + int8_t N0001B8EF; //0x0058 + int8_t N0003D80B; //0x0059 + int8_t N0003D80E; //0x005A + int8_t N0003D80C; //0x005B + float targetPosXEnd; //0x005C + float targetPosYEnd; //0x0060 + int8_t N0001B8F4; //0x0064 + int8_t N0003D7F4; //0x0065 + int8_t N0003D7F7; //0x0066 + int8_t N0003D7F5; //0x0067 + void* N0001B8F5; //0x0068 + int8_t N0001B8F6; //0x006C + int8_t N0003D7EA; //0x006D + int8_t N0003D7ED; //0x006E + int8_t N0003D7EB; //0x006F + float targetCoordXEngine; //0x0070 + float targetCoordZEngine; //0x0074 + float targetCoordYEngine; //0x0078 + struct siegeEngine* siegeEngine; //0x007C + int32_t N0001B8FB; //0x0080 + int32_t N0001B8FC; //0x0084 + char pad_0088[8]; //0x0088 + float N0001B8FF; //0x0090 + char pad_0094[16]; //0x0094 + float N0003A5AB; //0x00A4 +}; //Size: 0x00A8 + +struct battleMapPosition +{ +public: + int32_t positionIDMaybe; //0x0000 + int32_t numSoldiers; //0x0004 +}; //Size: 0x0008 + +struct engagedUnit +{ +public: + struct unit* unit; //0x0000 + int32_t intValue; //0x0004 + int32_t intValue2; //0x0008 + int32_t intValue3; //0x000C + int32_t intValue4; //0x0010 + int32_t intValue5; //0x0014 + float floatValue; //0x0018 +}; //Size: 0x001C + + +struct unitPositionData +{ +public: + struct engagedUnit* engagedUnits; //0x0000 + int32_t engagedUnitsSize; //0x0004 + int32_t engagedUnitsNum; //0x0008 + struct engagedUnit* engagedUnits2; //0x000C + int32_t engagedUnits2Size; //0x0010 + int32_t engagedUnits2Num; //0x0014 + char pad_0018[16]; //0x0018 + struct unit* unit; //0x0028 + char pad_002C[4]; //0x002C + void* N00002C71; //0x0030 + char pad_0034[4]; //0x0034 + struct unit* N00002C73; //0x0038 + float coord0; //0x003C + float coord1; //0x0040 + float coord2; //0x0044 + float coord3; //0x0048 + float rotation; //0x004C + struct battleMapPosition* isOnWalls; //0x0050 + int32_t isOnWallsSize; //0x0054 + int32_t isOnWallsCount; //0x0058 + struct battleMapPosition* isInTower; //0x005C + int32_t isInTowerSize; //0x0060 + int32_t isInTowerCount; //0x0064 + struct battleMapPosition* isInGateHouse; //0x0068 + int32_t isInGateHouseSize; //0x006C + int32_t isInGateHouseCount; //0x0070 + struct battleMapPosition* positions1; //0x0074 + int32_t positions1Size; //0x0078 + int32_t positions1Count; //0x007C + struct battleMapPosition* positions2; //0x0080 + int32_t positions2Size; //0x0084 + int32_t positions2Count; //0x0088 + struct battleMapPosition* positions3; //0x008C + int32_t positions3Size; //0x0090 + int32_t positions3Count; //0x0094 + struct battleMapPosition* positions4; //0x0098 + int32_t positions4Size; //0x009C + int32_t positions4Count; //0x00A0 + char pad_00A4[12]; //0x00A4 + struct floatPosData floatPosData; //0x00B0 + char pad_00F4[4]; //0x00F4 + struct targetPos targetArray[16]; //0x00F8 + int32_t targetsDone; //0x0B78 + int32_t additionalTargetsOverOne; //0x0B7C + int32_t targetsToGo; //0x0B80 + int8_t hasTargets; //0x0B84 + int8_t isHalted; //0x0B85 + char pad_0B86[6]; //0x0B86 + float lastTargetCoord1; //0x0B8C + float lastTargetCoord2; //0x0B90 + char pad_0B94[20]; //0x0B94 + float N00002F68; //0x0BA8 + float N00002F69; //0x0BAC + float N00002F6A; //0x0BB0 + float N00002F6B; //0x0BB4 + float N00002F6C; //0x0BB8 + float N00002F6D; //0x0BBC + float N00002F6E; //0x0BC0 + float N00002F6F; //0x0BC4 + float N00002F70; //0x0BC8 + float N00002F71; //0x0BCC + float N00002F72; //0x0BD0 + float N00002F73; //0x0BD4 + float N00002F74; //0x0BD8 + float N00002F75; //0x0BDC + float N00002F76; //0x0BE0 + float N00002F77; //0x0BE4 + float N00002F78; //0x0BE8 + char pad_0BEC[20]; //0x0BEC + void** towersUnderFireFrom; //0x0C00 + int32_t towersUnderFireFromSize; //0x0C04 + int32_t towersUnderFireFromCount; //0x0C08 + struct unit** unitsUnderFireFrom; //0x0C0C + int32_t unitsUnderFireFromSize; //0x0C10 + int32_t unitsUnderFireFromCount; //0x0C14 + void** underFireSomething2; //0x0C18 + int32_t underFireSomething2Size; //0x0C1C + int32_t underFireSomething2Count; //0x0C20 + void** underFireSomething3; //0x0C24 + int32_t underFireSomething3Size; //0x0C28 + int32_t underFireSomething3Count; //0x0C2C + char pad_0C30[8]; //0x0C30 + int32_t combatStatus; //0x0C38 +}; //Size: 0x0C3C //unit data struct unit { undefined field0_0x0[4]; struct trackedPointerUnit** trackedUnitPointerP; - undefined field2_0x8[636]; - struct stackStruct* army; + undefined field2_0x8[52]; + int32_t aiActiveSet; //0x003C + undefined field_0040[24]; + struct modelEntry* bmdbEntry; //0x0058 + undefined field3_0x5C[548];//0x005C + struct unitPositionData* unitPositionData; //0x0280 + struct stackStruct* army;//0x0284 undefined field4_0x288[12]; struct eduEntry* eduEntry; - int ID; - undefined field7_0x29c[612]; + int ID; //0x0298 + int battlemapTeam; //0x029C + int actionStatus; //0x02A0 + char pad_02A4[24]; //0x02A4 + void* ThirtyTwoByteObject; //0x02BC + char pad_02C0[8]; //0x02C0 + void* hundredSixtyByteObject; //0x02C8 + char pad_02CC[8]; //0x02CC + int fatigue; //0x02D4 + float killChanceModifier; //0x02D8 + struct Unit* this2; //0x02DC + int moraleLevel; //0x02E0 + int moraleStatusSum; //0x02E4 + char pad_02E8[24]; //0x02E8 + int moraleValue1; //0x0300 + int moraleValue2; //0x0304 + int moraleValue3; //0x0308 + int moraleValue4; //0x030C + int moraleValue5; //0x0310 + int moraleValue6; //0x0314 + int moraleValue7; //0x0318 + int moraleValue8; //0x031C + int moraleValue9; //0x0320 + char pad_0324[372]; //0x0324 + struct unitMorale* moralePartOfUnitLookAbove; //0x0498 + char pad_049C[4]; //0x049C + int someMoraleValue; //0x04A0 + char pad_04A4[4]; //0x04A4 + int16_t N0000271D; //0x04A8 + int8_t N00009770; //0x04AA + int8_t skipsMoraleCalcIFNotZero; //0x04AB + int8_t lockedMorale; //0x04AC + char pad_04AD[11]; //0x04AD + int moraleAreaEffectEnd; //0x04B8 + char pad_04BC[60]; //0x04BC + int hasActiveEffects; //0x04F8 + int activeEffectsOnThisUnit; //0x04FC int expScreen; /* screen experience */ struct general* general; float movePoints; - int number; /* number of soldiers */ - int numberTact; /* number of soldiers on tactical map */ - int numberMax; /* max number of soldiers */ - undefined field14_0x518[216]; + int SoldierCountStrat; /* number of soldiers */ + int SoldierCountMaxStrat; /* number of soldiers on tactical map */ + int SoldierCountBattlemap; /* max number of soldiers */ + int soldierCountMaxBattlemap; /* max number of soldiers */ + char pad_051C[64]; //0x051C + struct generalInfo* officer1; //0x055C + struct generalInfo* officer2; //0x0560 + struct generalInfo* officer3; //0x0560 + struct generalInfo* generalInfo; //0x0568 + struct soldierInBattle* generalSoldier; //0x056C + struct soldierInBattle* officer1Soldier; //0x0570 + struct soldierInBattle* officer2Soldier; //0x0574 + struct soldierInBattle* officer3Soldier; //0x0578 + int32_t numOfficer; //0x057C + int32_t numOfficerInBattle; //0x0580 + int32_t N00002755; //0x0584 + int32_t N00002756; //0x0588 + int32_t N00002757; //0x058C + int32_t N00002758; //0x0590 + int32_t statPri; //0x0594 + char pad_0598[20]; //0x0598 + int32_t weaponType; //0x05AC + int32_t weaponTecType; //0x05B0 + char pad_05B4[8]; //0x05B4 + int32_t minAttackDelayPri; //0x05BC + char pad_05C0[28]; //0x05C0 + int32_t statPriArmour; //0x05DC + int32_t valueAfterInEdu; //0x05E0 + int8_t attackInBattle; //0x05E4 + int16_t armourInBattle; //0x05E5 + char pad_05E7[1]; //0x05E7 + int8_t N0000276E; //0x05E8 + int8_t N00010E95; //0x05E9 + char pad_05EA[6]; //0x05EA UINT32 stats; /* def/atk/etc */ struct soldierInBattle** soldiersBattleArr; /* array of soldiers battle data */ struct soldierData* soldiersArr; /* array of soldiers data */ - undefined field18_0x5fc[6780]; + void* soldierIndices; //0x05FC + void* generalOrMount; //0x0600 + int32_t attachmentCount; //0x0604 + char pad_0608[6172]; //0x0608 + void* UNIT_TASK_INTERFACE; //0x1E24 + char pad_1E28[28]; //0x1E28 + int32_t unitBattleProperties; //0x1E44 + char pad_1E48[4]; //0x1E48 + void* formationsArray; //0x1E4C + char pad_1E50[28]; //0x1E28 + int16_t ranks; //0x1E76 + char pad_1E78[14]; //0x1E78 + int8_t isCloseFormation; //0x1E84 + char pad_1E85[59]; //0x1E85 + float positionX; //0x1EC0 + float N00002FB7; //0x1EC4 + float positionY; //0x1EC8 + char pad_1ECC[400]; //0x1ECC + int32_t maxAmmo; //0x205C + int32_t currentAmmo; //0x2060 + uint8_t statusField1; //0x2064 + uint8_t statusField2; //0x2065 + uint8_t statusField3; //0x2066 + char pad_2067[1]; //0x2067 + int8_t rallyHornCountdown; //0x2068 + char pad_2069[15];; //0x2069 UNICODE_STRING** alias; /* Legio string etc */ undefined field20_0x207c[44]; struct siegeEngine** siegeEngine; @@ -1363,27 +2471,50 @@ struct stackStruct { /* structure of stack */ struct factionStruct* faction; int regionID; struct unit** units; - undefined field_0x58[4]; + int32_t unitsSize; //0x0058 int numOfUnits; - undefined field_0x60[56]; + undefined field_0x60[48]; + int8_t isBoarded; //0x0090 + char pad_0091[7]; //0x0091 struct stackStruct* boardedArmy; /* if fleet, here army */ undefined field_0x9c[4]; struct stackStruct* shipArmy; /* here fleet what contain our army */ undefined field_0xa4[8]; struct siegeS* siege; struct portBuildingStruct* blockedPort; /* if port blocked by this army when it here */ - undefined field_0xb4[32]; + undefined field_0xb4[3]; + int8_t ladders; //0x00B7 + int8_t rams; //0x00B8 + int8_t towers; //0x00B9 + char pad_00BA[10]; //0x00BA + int32_t tilesMovedThisTurnDoesntStatAtZero; //0x00C4 + char pad_00C8[4]; //0x00C8 + uint32_t upkeepModifier; //0x00CC + char pad_00D0[4]; //0x00D0 struct general* gen; /* 0 if in settlement/fort */ - undefined field_0xd8[24]; - struct general** characters; - undefined field_0xf4[4]; - int charactersNum; - undefined field_0xfc[4]; - struct settlementStruct* settlement; - undefined field_0x104[32]; + struct unit* generalsUnit; //0x00D8 + struct generalInfo* generalInfo; //0x00DC + float armyStrengthForAutoResolveMaybe; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct general** characters; //0x00F0 + undefined field_0xf4[4]; //0x00F4 + int charactersNum; //0x00F8 + undefined field_0xfc[4]; //0x00FC + struct settlementStruct* settlement; //0x0100 + undefined field_0x104[16]; + struct stackStruct* enemyArmy; + int32_t inBattle; //0x0118 + int8_t N00001BCA; //0x011C + int8_t N0003D211; //0x011D + uint16_t N0003D214; //0x011E + char pad_0120[4]; //0x0120 int totalStrength; float reform_point_x; float reform_point_y; + int32_t battleSide; //0x0130 + char pad_0134[16]; //0x0134 + int32_t battleAllianceOrSomething; //0x0144 + int32_t battleDifficulty; //0x0148 }; struct coords { @@ -1401,56 +2532,129 @@ struct factionTileStruct { int revealedTilesNumber; undefined field7_0x34[24]; }; + +struct factionEconomy +{ +public: + int32_t farmingIncome; //0x0000 + int32_t taxesIncome; //0x0004 + int32_t miningIncome; //0x0008 + int32_t tradeIncome; //0x000C + int32_t merchantIncome; //0x0010 + int32_t constructionIncome; //0x0014 + int32_t otherIncome1; //0x0018 + int32_t otherIncome2; //0x001C + int32_t diplomacyIncome; //0x0020 + int32_t tributesIncome; //0x0024 + int32_t adminIncome; //0x0028 + int32_t kingsPurseIncome; //0x002C + int32_t wagesExpense; //0x0030 + int32_t upkeepExpense; //0x0034 + int32_t constructionExpenseBuildings; //0x0038 + int32_t constructionExpenseField; //0x003C + int32_t recruitmentExpenseBuildings; //0x0040 + int32_t recruitmentExpenseMercs; //0x0044 + int32_t corruptionExpense; //0x0048 + int32_t diplomacyExpense; //0x004C + int32_t tributesExpense; //0x0050 + int32_t otherExpense1; //0x0054 + int32_t otherExpense2; //0x0058 + int32_t devastationExpense; //0x005C +}; //Size: 0x0060 + +struct battleFactionCounter +{ +public: + int32_t battlesWon; //0x0000 + int32_t battlesLost; //0x0004 + int32_t wonLostRatio; //0x0008 +}; //Size: 0x000C + //faction struct factionStruct { undefined field_0x0[180]; int dipNum; /* number of faction in diplomatic array */ int cultureID; char* ai_label; /* ai_label of faction */ - undefined field_0xc0[4]; + int32_t AILabelHash; //0x00C0 struct settlementStruct* capital; /* capital of the faction */ struct namedCharacter* leader; /* faction leader */ struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - UINT32* ai_assistant; - undefined field_0xdc[20]; - UINT32 holdRegions; - undefined field_0xf4[4]; + struct aiFaction* AIFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t someInteger; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ - undefined field_0xfc[4]; + int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ - undefined field_0x108[4]; + int32_t charactersSize; //0x0108 int numOfCharacters; /* characters on stratmap */ struct stackStruct** stacks; - undefined field_0x114[4]; + int32_t armiesSize; //0x0114 int stackNum; int* regionsID; - undefined field_0x120[4]; + int32_t regionsSize; //0x0120 int regionsNum; struct settlementStruct** settlements; - undefined field_0x12c[4]; + int32_t settlementsSize; //0x012C int settlementsNum; struct fortStruct** forts; - undefined field_0x138[4]; + int32_t fortsSize; //0x0138 int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ - undefined field_0x144[4]; + int32_t watchtowersSize; //0x0144 int wathtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ - undefined field_0x150[4]; + int32_t portBuildingsSize; //0x0150 int portBuildingsNum; - undefined field_0x158[68]; + uint32_t neighBourFactionsBitmap; //0x0158 + int* neighBourRegions; //0x015C + int32_t neighBourRegionsSize; //0x0160 + int32_t neighBourRegionsNum; //0x0164 + char pad_0168[49]; //0x0168 + int8_t isUndiscovered; //0x0199 + char pad_019A[2]; //0x019A factionTileStruct* tilesFac; - undefined field_0x1a0[2208]; + struct mission** missions; //0x01A0 + int32_t missionsSize; //0x01A4 + int32_t missionCount; //0x01A8 + char pad_01AC[48]; //0x01AC + struct factionRanking* factionRankings; //0x01DC + int32_t factionRankingsSize; //0x01E0 + int32_t factionRankingsCount; //0x01E4 + char pad_01E8[24]; //0x01E8 + int32_t freezeFactionAI; //0x0200 + char pad_0204[2096]; //0x0204 + int32_t treasuryTurnStart; //0x0A34 + char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ - undefined field_0xa44[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + char pad_0A55[67]; //0x0A55 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; int money; /* money of the faction */ int KingsPurse; /* money of the faction */ + int32_t incomeDoubled; //0x0AF4 + struct factionEconomy factionEconomy[10]; //0x0AF8 + int32_t nextCounterEconomy; //0x0EB8 + int32_t counterEconomy; //0x0EBC + int32_t maxTurnsTillReset; //0x0EC0 + char pad_0EC4[16]; //0x0EC4 + struct battleFactionCounter(*battlesWonVsFaction)[31]; //0x0ED4 + int32_t factionCountStart; //0x0ED8 + int32_t otherFactionCount; //0x0EDC + int32_t battlesWon; //0x0EE0 + int32_t battlesLost; //0x0EE4 + int32_t settlementsCaptured; //0x0EE8 + int32_t settlementsLost; //0x0EEC + char pad_0EF0[24]; //0x0EF0 }; struct ModelDbEntry @@ -1678,8 +2882,8 @@ struct eduEntry { void* N00000152; void* N00000153; char pad_0394[12]; - void* Attributes; - void* EndOfAttributes; + DWORD* Attributes; + DWORD* EndOfAttributes; void* BytesBeforeNextAttributes; int8_t Attributes2; int8_t Attributes3; @@ -1710,7 +2914,7 @@ struct someFactNameStruct { }; //pointer to ancillary -struct ancData { /* data of the ancillary */ +struct anchData { /* data of the ancillary */ struct anchillary* dataAnch; }; @@ -1779,21 +2983,20 @@ struct consoleCommands { int size; }; +struct battleCameraStruct +{ +public: + float xCoord; //0x0000 + char pad_0004[4]; //0x0004 + float yCoord; //0x0008 + char pad_000C[20]; //0x000C + float zCoord; //0x0020 +}; //Size: 0x0024 + struct descr_sm_factions_list { struct factionStratMapDescrS* facDescrs; int capacity; int size; }; -struct battleCameraStruct -{ - public: - float xCoord; //0x0000 - char pad_0004[4]; //0x0004 - float yCoord; //0x0008 - char pad_000C[20]; //0x000C - float zCoord; //0x0020 -}; //Size: 0x0024 - - #pragma pack(pop) \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp index 60508b8a2..3738261f5 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp @@ -1,4 +1,6 @@ #include "battleHandlerHelpers.h" + +#include "gameDataAllHelper.h" #include "plugData.h" namespace battleHandlerHelpers { @@ -28,4 +30,25 @@ namespace battleHandlerHelpers { return &battleArmy->units[index]; } + + stackStruct* getPlayerArmy(const battleDataS* battleData) + { + return battleData->playerArmies[0].army; + } + + factionStruct* getFaction(const battleSide* side, int index) + { + return side->factions[index]; + } + + battleResidence* getBattleResidence() + { + const auto gameData = gameDataAllHelper::get(); + const auto battleSettlement = gameData->battleSettlement; + if (battleSettlement) + { + return battleSettlement->battleResidence; + } + return nullptr; + } }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h index 12de1186d..6faac4212 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.h @@ -6,5 +6,8 @@ namespace battleHandlerHelpers std::string getWinConditionS(DWORD condition); armyAndCharacter* getBattleArmy(const battleSide* side, int index); battleUnit* getBattleUnit(const armyAndCharacter* battleArmy, int index); + stackStruct* getPlayerArmy(const battleDataS* battleData); + factionStruct* getFaction(const battleSide* side, int index); + battleResidence* getBattleResidence(); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp index 7cc3f190a..f1f05738c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp @@ -39,6 +39,11 @@ portBuildingStruct* factionHelpers::getPort(const factionStruct* fac, int index) return fac->portBuildings[index]; } +int factionHelpers::getNeighbourRegionID(const factionStruct* fac, int index) +{ + return fac->neighBourRegions[index]; +} + watchTowerStruct* factionHelpers::getWatchtower(const factionStruct* fac, int index) { return fac->watchTowers[index]; @@ -49,6 +54,11 @@ void factionHelpers::deleteFort(const factionStruct* fac, fortStruct* fort) (*(*plugData::data.funcs.deleteFort))(fac, fort); } +battleFactionCounter* factionHelpers::getBattleVsFactionStats(factionStruct* fac, int targetFactionID) +{ + return fac->battlesWonVsFaction[targetFactionID]; +} + bool factionHelpers::hasMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2) { const auto gameData = gameDataAllHelper::get(); @@ -79,6 +89,11 @@ float factionHelpers::getFactionStanding(const factionStruct* fac1, const factio return campaign->diplomaticStandings[fac1->dipNum][fac2->dipNum].factionStanding; } +bool factionHelpers::isNeighbourFaction(const factionStruct* fac1, const factionStruct* fac2) +{ + return fac1->neighBourFactionsBitmap & (1 << fac2->dipNum); +} + void factionHelpers::setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing) { const auto gameData = gameDataAllHelper::get(); @@ -101,6 +116,35 @@ void factionHelpers::changeFactionName(factionStruct* fac, const char* newName) (*(*plugData::data.funcs.changeFactionName))(fac, newName); } +factionRanking* factionHelpers::getFactionRanking(const factionStruct* fac, int turnNum) +{ + return &fac->factionRankings[turnNum]; +} + +factionEconomy* factionHelpers::getFactionEconomy(factionStruct* fac, int turnsAgo) +{ + int turnIndex = fac->counterEconomy - turnsAgo; + if (turnIndex < 0) + { + turnIndex += fac->maxTurnsTillReset; + } + return &fac->factionEconomy[turnIndex]; +} + +const char* factionHelpers::getRegionToHoldName(const holdRegionsWinCondition* condition, int index) +{ + return condition->regionsToHold[index].name; +} + +int factionHelpers::getRegionToHoldLength(const holdRegionsWinCondition* condition, int index) +{ + if (index < condition->holdRegionLengthsCount) + { + return condition->holdRegionLengths[index]; + } + return 0; +} + std::string factionHelpers::getLocalizedFactionName(factionStruct* fac) { UNICODE_STRING** localizedname = fac->localizedName; diff --git a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h index 461ffc176..66c4b1947 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.h @@ -24,7 +24,13 @@ namespace factionHelpers void setFactionStanding(const factionStruct* fac1, const factionStruct* fac2, float standing); void setMilitaryAccess(const factionStruct* fac1, const factionStruct* fac2, bool set); std::string getLocalizedFactionName(factionStruct* fac); - + const char* getRegionToHoldName(const holdRegionsWinCondition* condition, int index); + int getRegionToHoldLength(const holdRegionsWinCondition* condition, int index); + factionRanking* getFactionRanking(const factionStruct* fac, int turnNum); + factionEconomy* getFactionEconomy(factionStruct* fac, int turnsAgo); + bool isNeighbourFaction(const factionStruct* fac1, const factionStruct* fac2); + int getNeighbourRegionID(const factionStruct* fac, int index); + battleFactionCounter* getBattleVsFactionStats(factionStruct* fac, int targetFactionID); //faction template std::string getStringProperty(const factionStruct* fac) diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index 03c45e38e..45c2dfafc 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -118,10 +118,9 @@ namespace gameHelpers return region->resources[index]; } - regionStruct* gameHelpers::getNeighbour(regionStruct* region, const int index) + neighbourRegion* gameHelpers::getNeighbour(regionStruct* region, const int index) { - neighbourRegion* nregion = ®ion->neighbourRegions[index]; - return nregion->region; + return ®ion->neighbourRegions[index]; } bool gameHelpers::getHiddenResource(regionStruct* region, int index) @@ -356,6 +355,130 @@ namespace gameHelpers return campaign->watchtowers[index]; } + unit* gameHelpers::getSelectedUnitCard(const uiCardManager* cardManager, const int index) + { + return cardManager->selectedUnitCards[index]->unit; + } + + unit* gameHelpers::getUnitCard(const uiCardManager* cardManager, const int index) + { + return cardManager->unitCards[index]->unit; + } + + coordPair* getVolcanoCoords(const stratMap* map, const int index) + { + return &map->volcanoes[index]; + } + + coordPair* getLandConnection(const stratMap* map, const int index) + { + return &map->landMassConnections[index]; + } + + landMass* getLandMass(stratMap* map, const int index) + { + return &map->landMass[index]; + } + + int getRegionID(const landMass* landMass, const int index) + { + return landMass->regions[index]; + } + + coordPair* getRoadCoord(const roadStruct* road, const int index) + { + return &road->coords[index]; + } + + int getTileFactionID(const oneTile* tile) + { + return tile->factionId & 0b00111111; + } + + bool tileHasRiver(const oneTile* tile) + { + return tile->factionId & 0b01000000; + } + + bool tileHasCrossing(const oneTile* tile) + { + return tile->factionId & 0b10000000; + } + + int tileBorderType(const oneTile* tile) + { + return tile->border / 4; + } + + bool tileHasCharacter(const oneTile* tile) + { + return tile->objectTypes & (1 << 6); + } + + bool tileHasShip(const oneTile* tile) + { + return tile->objectTypes & (1 << 5); + } + + bool tileHasWatchtower(const oneTile* tile) + { + return tile->objectTypes & (1 << 4); + } + + bool tileHasPort(const oneTile* tile) + { + return tile->objectTypes & (1 << 3); + } + + bool tileHasFort(const oneTile* tile) + { + return tile->objectTypes & (1 << 1); + } + + bool tileHasSettlement(const oneTile* tile) + { + return tile->objectTypes & (1 << 0); + } + + bool factionHasArmyNearTile(const oneTile* tile, int factionID) + { + return tile->armiesNearTile & (1 << factionID); + } + + bool factionHasCharacterOnTile(const oneTile* tile, int factionID) + { + return tile->charactersOnTile & (1 << factionID); + } + + coordPair* convertTileCoords(DWORD arrayIndex) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + bool found = false; + int x = 0; + int y = 0; + int index = arrayIndex; + for (y = 0;y < map->mapHeight;y++) + { + x = index - y * map->mapWidth; + if (x >= 0 && x < map->mapWidth) + { + auto coords = new coordPair; + coords->xCoord = x; + coords->yCoord = y; + return coords; + } + } + return nullptr; + } + + coordPair* getTileCoords(const oneTile* tile) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + return convertTileCoords(tile - map->tilesArr); + } + settlementStruct* getSettlementByName(campaign* campaign, const char* name) { settlementList* settlementList = &campaign->settlementList; @@ -400,4 +523,92 @@ namespace gameHelpers // Return the converted string return buffer; } + + seaConnectedRegion* getSeaConnectedRegion(const regionStruct* region, const int index) + { + return ®ion->seaConnectedRegions[index]; + } + + seaConnectedRegion* getSeaImportRegion(const regionStruct* region, const int index) + { + return region->seaImportRegions[index]; + } + + oneTile* getRegionSeaEdge(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->regionSeaEdges[index]]; + } + + float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo) + { + if (turnsAgo > 19) + { + return 0.0f; + } + if (turnsAgo == 0) + { + return region->religionsARR[religionID]; + } + return region->religionHistory[turnsAgo][religionID]; + } + + oneTile* getTileBorderingEdgeOfMap(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->tilesBorderingEdgeOfMap[index]]; + } + + oneTile* getTileRegion(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->tiles[index]]; + } + + oneTile* getFertileTile(const regionStruct* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->fertileTiles[index]]; + } + + oneTile* getBorderTile(const neighbourRegion* region, const int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->bordertiles[index]]; + } + + oneTile* getReachableTile(const seaConnectedRegion* region, int index) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + if (!®ion->tilesReachable[index]) + { + return nullptr; + } + auto tile = region->tilesReachable[index].tileId; + return &map->tilesArr[tile]; + } + + coordPair* getTradeLaneCoord(const seaConnectedRegion* region, int index) + { + return ®ion->seaTradeLanePath[index]; + } + + bool hasResourceType(const regionStruct* region, const int resourceType) + { + return region->resourceTypesBitMap & (1 << resourceType); + } + + + } diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index df3af8fe6..0e719ec29 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -25,7 +25,8 @@ namespace gameHelpers fortStruct* getFort(const regionStruct* region, int index); watchTowerStruct* getWatchtower(const regionStruct* region, int index); resStrat* getResource(const regionStruct* region, int index); - regionStruct* getNeighbour(regionStruct* region, int index); + neighbourRegion* getNeighbour(regionStruct* region, const int index); + oneTile* getBorderTile(const neighbourRegion* region, const int index); bool getHiddenResource(regionStruct* region, int index); void setHiddenResource(regionStruct* region, int index, bool enable); void changeRegionName(regionStruct* region, const char* newName); @@ -37,6 +38,35 @@ namespace gameHelpers watchTowerStruct* getWatchTowerAll(const campaign* campaign, const int index); settlementStruct* getSettlementByName(campaign* campaign, const char* name); std::string getRebelsName(regionStruct* region); + coordPair* getVolcanoCoords(const stratMap* map, const int index); + coordPair* getLandConnection(const stratMap* map, const int index); + landMass* getLandMass(stratMap* map, const int index); + int getRegionID(const landMass* landMass, const int index); + coordPair* getRoadCoord(const roadStruct* road, const int index); + int getTileFactionID(const oneTile* tile); + bool tileHasRiver(const oneTile* tile); + bool tileHasCrossing(const oneTile* tile); + int tileBorderType(const oneTile* tile); + bool tileHasCharacter(const oneTile* tile); + bool tileHasShip(const oneTile* tile); + bool tileHasWatchtower(const oneTile* tile); + bool tileHasPort(const oneTile* tile); + bool tileHasFort(const oneTile* tile); + bool tileHasSettlement(const oneTile* tile); + bool factionHasArmyNearTile(const oneTile* tile, int factionID); + bool factionHasCharacterOnTile(const oneTile* tile, int factionID); + coordPair* convertTileCoords(DWORD arrayIndex); + coordPair* getTileCoords(const oneTile* tile); + seaConnectedRegion* getSeaConnectedRegion(const regionStruct* region, const int index); + seaConnectedRegion* getSeaImportRegion(const regionStruct* region, const int index); + oneTile* getRegionSeaEdge(const regionStruct* region, const int index); + float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo); + oneTile* getTileBorderingEdgeOfMap(const regionStruct* region, const int index); + oneTile* getTileRegion(const regionStruct* region, const int index); + oneTile* getFertileTile(const regionStruct* region, const int index); + bool hasResourceType(const regionStruct* region, const int resourceType); + oneTile* getReachableTile(const seaConnectedRegion* region, int index); + coordPair* getTradeLaneCoord(const seaConnectedRegion* region, int index); int getMercUnitNum(mercPool* mercPool); mercPoolUnit* getMercUnit(mercPool* pool, int index); @@ -46,5 +76,7 @@ namespace gameHelpers void historicEvent(const char* name, const char* title, const char* description); void scriptCommand(const char* command, const char* args); const char* getReligionName(const int index); + unit* getSelectedUnitCard(const uiCardManager* cardManager, const int index); + unit* getUnitCard(const uiCardManager* cardManager, const int index); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp index acdb5e7dc..82ae36e32 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.cpp @@ -3,7 +3,21 @@ namespace generalHelpers { - + std::unordered_map characterTypes = { + {0,"spy"}, + {1,"assassin"}, + {2,"diplomat"}, + {3,"admiral"}, + {4,"merchant"}, + {5,"priest"}, + {6,"general"}, + {7,"named_character"}, + {8,"princess"}, + {9,"heretic"}, + {10,"witch"}, + {11,"inquisitor"}, + {13,"pope"} + }; void moveToTile(general* gen, int x, int y) { (*(*plugData::data.funcs.moveNormal))(gen, x, y); @@ -40,8 +54,8 @@ namespace generalHelpers void setMovepoints(general* gen, float movepoints) { - gen->movepoints1 = movepoints; - gen->movepoints2 = movepoints; + gen->movePointsCharacter = movepoints; + gen->movePointsArmy = movepoints; if (gen->bodyguards == nullptr)return; @@ -50,7 +64,17 @@ namespace generalHelpers float getMovepoints(const general* gen) { - return gen->movepoints2; + return gen->movePointsArmy; + } + + const char* getTypeName(const general* gen) + { + const auto charType = characterTypes.find(gen->genType->type); + if (charType != characterTypes.end()) + { + return charType->second; + } + return "unknown"; } int getTypeID(const general* gen) diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h index 016778b9c..02c254269 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/generalHelpers.h @@ -7,7 +7,7 @@ namespace generalHelpers void moveToTile(general* gen, int x, int y); void reposition(general* gen, int x, int y); - + const char* getTypeName(const general* gen); void killGeneral(general* gen); void setBodyguard(general* gen, unit* un); void setMovepoints(general* gen, float movepoints); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 743c566e4..d70578234 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -122,6 +122,13 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypebuildingLevel; sol::usertypebattleCameraStruct; sol::usertypeunitPositionData; + sol::usertypefactionEconomy; + sol::usertypefactionRanking; + sol::usertypeholdRegionsWinCondition; + sol::usertypesettlementCapability; + sol::usertyperecruitmentCapability; + sol::usertypesettlementRecruitmentPool; + sol::usertypebattleFactionCounter; }types; luaState = {}; luaPath = modPath + "\\youneuoy_Data\\plugins\\lua"; @@ -502,7 +509,22 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) local religionName =M2TWEOP.getReligionName(1); */ tables.M2TWEOPTable.set_function("getReligionName", &gameHelpers::getReligionName); - + /*** + Get some game options. + @function M2TWEOP.getOptions1 + @treturn options1 options + @usage + local options =M2TWEOP.getOptions1(); + */ + tables.M2TWEOPTable.set_function("getOptions1", &m2tweopHelpers::getOptions1); + /*** + Get some game options. + @function M2TWEOP.getOptions2 + @treturn options1 options + @usage + local options =M2TWEOP.getOptions2(); + */ + tables.M2TWEOPTable.set_function("getOptions2", &m2tweopHelpers::getOptions2); /// BattleCamera @@ -927,6 +949,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield float battlePosX 2d position on battlemap useful for getting distance etc (battle) @tfield float battlePosY 2d position on battlemap useful for getting distance etc (battle) @tfield character character + @tfield unitPositionData unitPositionData @tfield stackStruct army @tfield siegeEngineNum siegeEngineNum @tfield kill kill @@ -955,6 +978,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.unit.set("weaponLVL", sol::property(&unitHelpers::getweaponLVL, &unitHelpers::setweaponLVL)); types.unit.set("soldierCountStratMapMax", sol::property(&unitHelpers::getMaxSoldiersCount)); types.unit.set("soldierCountBattleMap", &unit::SoldierCountBattlemap); + types.unit.set("unitPositionData", &unit::unitPositionData); types.unit.set("character", &unit::general); types.unit.set("isCloseFormation", &unit::isCloseFormation); types.unit.set("moraleLevel", &unit::moraleLevel); @@ -1233,11 +1257,23 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield unit bodyguards @tfield stackStruct armyLeaded @tfield stackStruct armyNotLeaded in the stack but not leading it - @tfield float movePointsMax + @tfield int inEnemyZOC + @tfield int ambushState + @tfield int doNotSpendMovePoints + @tfield float movePointsCharacter @tfield float movePointsModifier - @tfield float movePoints + @tfield float movePointsMaxCharacter + @tfield float movePointsMaxArmy + @tfield float movePointsArmy + @tfield int turnJoinedCrusade + @tfield int numTurnsIdle + @tfield float percentCharacterReligionInRegion 0 to 1 + @tfield float popConvertedThisTurn + @tfield int timeInRegion + @tfield int timeWithArmy for auxiliary generals, not leading general @tfield string ability see descr\_hero\_abilities.xml @tfield getTypeID getTypeID + @tfield getTypeName getTypeName @tfield setTypeID setTypeID @tfield moveToTile moveToTile @tfield reposition reposition @@ -1255,9 +1291,20 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.character.set("bodyguards", &general::bodyguards); types.character.set("armyLeaded", &general::armyLeaded); types.character.set("armyNotLeaded", &general::armyNotLeaded); - types.character.set("movePointsMax", &general::movepointsMax); - types.character.set("movePointsModifier", &general::movepointsModifier); - types.character.set("movePoints", sol::property(&generalHelpers::getMovepoints, &generalHelpers::setMovepoints)); + types.character.set("inEnemyZOC", &general::inEnemyZOC); + types.character.set("ambushState", &general::ambushState); + types.character.set("doNotSpendMovePoints", &general::doNotSpendMovePoints); + types.character.set("turnJoinedCrusade", &general::turnJoinedCrusade); + types.character.set("numTurnsIdle", &general::numTurnsIdle); + types.character.set("percentCharacterReligionInRegion", &general::percentCharacterReligionInRegion); + types.character.set("popConvertedThisTurn", &general::popConvertedThisTurn); + types.character.set("timeInRegion", &general::timeInRegion); + types.character.set("timeWithArmy", &general::timeWithArmy); + types.character.set("movePointsCharacter", &general::movePointsCharacter); + types.character.set("movePointsModifier", &general::movePointsModifier); + types.character.set("movePointsMaxArmy", &general::movePointsMaxArmy); + types.character.set("movePointsMaxCharacter", &general::movePointsMax); + types.character.set("movePointsArmy", sol::property(&generalHelpers::getMovepoints, &generalHelpers::setMovepoints)); types.character.set("ability", sol::property(&luaGetSetFuncs::getStringPropertyGen, &luaGetSetFuncs::setStringPropertyGen)); /*** Get the character type. See hint below for the types. @@ -1281,6 +1328,27 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.character.set_function("getTypeID", &generalHelpers::getTypeID); /*** + Get the character type. See hint below for the types. + 0-spy + 1-assassin + 2-diplomat + 3-admiral + 4-merchant + 5-priest + 6-general + 7-named character + 8-princess + 9-heretic + 10-witch + 11-inquisitor + 13-pope + @function character:getTypeName + @treturn string type + @usage + local ourType=ourCharacter:getTypeName(); + */ + types.character.set_function("getTypeName", &generalHelpers::getTypeName); + /*** Set the character type. See hint below for the types. 0-spy 1-assassin @@ -1738,6 +1806,8 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int dipNum @tfield getFactionName getFactionName @tfield int cultureID + @tfield int AIPersonalityType + @tfield int AIPersonalityName @tfield string ai_label @tfield string name @tfield string localizedName @@ -1745,7 +1815,18 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield namedCharacter leader @tfield namedCharacter heir @tfield int isPlayerControlled 0=AI, 1=player + @tfield int neighBourFactionsBitmap @tfield int religion + @tfield int isUndiscovered + @tfield int missionCount + @tfield int freezeFactionAI + @tfield int treasuryTurnStart + @tfield int incomeDoubled + @tfield int battlesWon + @tfield int battlesLost + @tfield int settlementsCaptured + @tfield int settlementsLost + @tfield int otherFactionCount @tfield int money @tfield int kingsPurse @tfield factionStratMapStruct facStrat @@ -1763,17 +1844,24 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getPort getPort @tfield int watchtowersNum @tfield getWatchtower getWatchtower + @tfield int neighBourRegionsNum @tfield deleteFort deleteFort @tfield createFortXY createFortXY @tfield hasMilitaryAccess hasMilitaryAccess @tfield setMilitaryAccess setMilitaryAccess @tfield getFactionStanding getFactionStanding @tfield setFactionStanding setFactionStanding + @tfield getFactionRanking getFactionRanking + @tfield getFactionEconomy getFactionEconomy + @tfield getNeighbourRegionID getNeighbourRegionID + @tfield getBattleVsFactionStats getBattleVsFactionStats @table factionStruct */ types.factionStruct = luaState.new_usertype("factionStruct"); types.factionStruct.set("dipNum", &factionStruct::dipNum); + types.factionStruct.set("AIPersonalityType", &factionStruct::AIPersonalityType); + types.factionStruct.set("AIPersonalityName", &factionStruct::AIPersonalityName); /*** Get the faction's internal name @function factionStruct:getFactionName @@ -1801,9 +1889,21 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.factionStruct.set("heir", &factionStruct::heir); types.factionStruct.set("isPlayerControlled", &factionStruct::isPlayerControlled); types.factionStruct.set("religion", &factionStruct::religion); + types.factionStruct.set("missionCount", &factionStruct::missionCount); + types.factionStruct.set("isUndiscovered", &factionStruct::isUndiscovered); + types.factionStruct.set("neighBourRegionsNum", &factionStruct::neighBourRegionsNum); + types.factionStruct.set("factionRankings", &factionStruct::factionRankings); types.factionStruct.set("money", &factionStruct::money); types.factionStruct.set("kingsPurse", &factionStruct::KingsPurse); types.factionStruct.set("facStrat", &factionStruct::factSmDescr); + types.factionStruct.set("freezeFactionAI", &factionStruct::freezeFactionAI); + types.factionStruct.set("treasuryTurnStart", &factionStruct::treasuryTurnStart); + types.factionStruct.set("incomeDoubled", &factionStruct::incomeDoubled); + types.factionStruct.set("battlesWon", &factionStruct::battlesWon); + types.factionStruct.set("battlesLost", &factionStruct::battlesLost); + types.factionStruct.set("settlementsCaptured", &factionStruct::settlementsCaptured); + types.factionStruct.set("settlementsLost", &factionStruct::settlementsLost); + types.factionStruct.set("otherFactionCount", &factionStruct::otherFactionCount); types.factionStruct.set("numOfNamedCharacters", &factionStruct::numOfCharactersAll); /*** Get named character using it's index. @@ -1975,8 +2075,191 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) fac:setFactionStanding(targetFac, 0.5) */ types.factionStruct.set_function("setFactionStanding", &factionHelpers::setFactionStanding); + + /*** + Get the faction ranking scores. + @function factionStruct:getFactionRanking + @tparam int turnNumber + @treturn factionRanking factionRanking + @usage + local rankings = fac:getFactionRanking(30) + */ + types.factionStruct.set_function("getFactionRanking", &factionHelpers::getFactionRanking); + + /*** + Get the faction ecomomy table, specified number of turns ago (max 10). + @function factionStruct:getFactionEconomy + @tparam int turnsAgo + @treturn factionEconomy factionEconomy + @usage + local economyTable = fac:getFactionEconomy(0) + */ + types.factionStruct.set_function("getFactionEconomy", &factionHelpers::getFactionEconomy); + + /*** + Check if 2 factions are neighbours. + @function factionStruct:isNeighbourFaction + @tparam factionStruct targetFaction + @treturn bool isNeighbour + @usage + local isNeighbour = fac:isNeighbourFaction(targetFac) + */ + types.factionStruct.set_function("isNeighbourFaction", &factionHelpers::isNeighbourFaction); + + /*** + Get a region ID of a neighbouring region by index. + @function factionStruct:getNeighbourRegionID + @tparam int index + @treturn int nRegionID + @usage + local nRegionID = fac:getNeighbourRegionID(0) + */ + types.factionStruct.set_function("getNeighbourRegionID", &factionHelpers::getNeighbourRegionID); + + /*** + Get stats versus a specific other faction. + @function factionStruct:getBattleVsFactionStats + @tparam int targetFactionID + @treturn battleFactionCounter battleStats + @usage + local battleStats = fac:getBattleVsFactionStats(2) + */ + types.factionStruct.set_function("getBattleVsFactionStats", &factionHelpers::getBattleVsFactionStats); + + ///battleFactionCounter + //@section battleFactionCounter + + /*** + Basic battleFactionCounter table + + @tfield int battlesWon + @tfield int battlesLost + + @table battleFactionCounter + */ + types.battleFactionCounter = luaState.new_usertype("battleFactionCounter"); + types.battleFactionCounter.set("battlesWon", &battleFactionCounter::battlesWon); + types.battleFactionCounter.set("battlesLost", &battleFactionCounter::battlesLost); + + ///holdRegionsWinCondition + //@section holdRegionsWinCondition + + /*** + Basic holdRegionsWinCondition table + + @tfield int regionsToHoldCount + @tfield int numberOfRegions + @tfield getRegionToHoldName getRegionToHoldName + @tfield getRegionToHoldLength getRegionToHoldLength + @table holdRegionsWinCondition + */ + types.holdRegionsWinCondition = luaState.new_usertype("holdRegionsWinCondition"); + types.holdRegionsWinCondition.set("regionsToHoldCount", &holdRegionsWinCondition::regionsToHoldCount); + types.holdRegionsWinCondition.set("numberOfRegions", &holdRegionsWinCondition::numberOfRegions); + /*** + Get the name of the region that has to be held to win the campaign. + @function holdRegionsWinCondition:getRegionToHoldName + @tparam int index + @treturn string regionName + @usage + local regionName = fac.winCondition:getRegionToHoldName(0) + */ + types.holdRegionsWinCondition.set_function("getRegionToHoldName", &factionHelpers::getRegionToHoldName); + + /*** + Get the number of turns the region has to be held to win the campaign. + @function holdRegionsWinCondition:getRegionToHoldLength + @tparam int index + @treturn int turnsToHold + @usage + local turnsToHold = fac.winCondition:getRegionToHoldLength(0) + */ + types.holdRegionsWinCondition.set_function("getRegionToHoldLength", &factionHelpers::getRegionToHoldLength); + + + ///FactionEconomy + //@section factionEconomy + + /*** + Basic factionEconomy table + + @tfield int farmingIncome + @tfield int taxesIncome + @tfield int miningIncome + @tfield int tradeIncome + @tfield int merchantIncome + @tfield int constructionIncome + @tfield int otherIncome1 + @tfield int otherIncome2 + @tfield int diplomacyIncome + @tfield int tributesIncome + @tfield int adminIncome + @tfield int kingsPurseIncome + @tfield int wagesExpense + @tfield int upkeepExpense + @tfield int constructionExpenseBuildings + @tfield int constructionExpenseField + @tfield int recruitmentExpenseBuildings + @tfield int recruitmentExpenseMercs + @tfield int corruptionExpense + @tfield int diplomacyExpense + @tfield int tributesExpense + @tfield int otherExpense1 + @tfield int otherExpense2 + @tfield int devastationExpense + + @table factionEconomy + */ + types.factionEconomy = luaState.new_usertype("factionEconomy"); + types.factionEconomy.set("farmingIncome", &factionEconomy::farmingIncome); + types.factionEconomy.set("taxesIncome", &factionEconomy::taxesIncome); + types.factionEconomy.set("miningIncome", &factionEconomy::miningIncome); + types.factionEconomy.set("tradeIncome", &factionEconomy::tradeIncome); + types.factionEconomy.set("merchantIncome", &factionEconomy::merchantIncome); + types.factionEconomy.set("constructionIncome", &factionEconomy::constructionIncome); + types.factionEconomy.set("otherIncome1", &factionEconomy::otherIncome1); + types.factionEconomy.set("otherIncome2", &factionEconomy::otherIncome2); + types.factionEconomy.set("diplomacyIncome", &factionEconomy::diplomacyIncome); + types.factionEconomy.set("tributesIncome", &factionEconomy::tributesIncome); + types.factionEconomy.set("adminIncome", &factionEconomy::adminIncome); + types.factionEconomy.set("kingsPurseIncome", &factionEconomy::kingsPurseIncome); + types.factionEconomy.set("wagesExpense", &factionEconomy::wagesExpense); + types.factionEconomy.set("upkeepExpense", &factionEconomy::upkeepExpense); + types.factionEconomy.set("constructionExpenseBuildings", &factionEconomy::constructionExpenseBuildings); + types.factionEconomy.set("constructionExpenseField", &factionEconomy::constructionExpenseField); + types.factionEconomy.set("recruitmentExpenseBuildings", &factionEconomy::recruitmentExpenseBuildings); + types.factionEconomy.set("recruitmentExpenseMercs", &factionEconomy::recruitmentExpenseMercs); + types.factionEconomy.set("corruptionExpense", &factionEconomy::corruptionExpense); + types.factionEconomy.set("diplomacyExpense", &factionEconomy::diplomacyExpense); + types.factionEconomy.set("tributesExpense", &factionEconomy::tributesExpense); + types.factionEconomy.set("otherExpense1", &factionEconomy::otherExpense1); + types.factionEconomy.set("otherExpense2", &factionEconomy::otherExpense2); + types.factionEconomy.set("devastationExpense", &factionEconomy::devastationExpense); + + ///FactionRankings + //@section factionRanking + + /*** + Basic factionRanking table + + @tfield float totalRankingScore + @tfield float militaryRankingScore + @tfield float productionRankingScore + @tfield float territoryRankingScore + @tfield float FinancialRankingScore + @tfield float populationRankingScore + + @table factionRanking + */ + types.factionRanking = luaState.new_usertype("factionRanking"); + types.factionRanking.set("totalRankingScore", &factionRanking::totalRanking); + types.factionRanking.set("militaryRankingScore", &factionRanking::militaryRanking); + types.factionRanking.set("productionRankingScore", &factionRanking::productionRanking); + types.factionRanking.set("territoryRankingScore", &factionRanking::territoryRanking); + types.factionRanking.set("FinancialRankingScore", &factionRanking::FinancialRanking); + types.factionRanking.set("populationRankingScore", &factionRanking::populationRanking); ///FactionStratMapStruct //@section factionStratMapStructTable @@ -1991,9 +2274,21 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int secondaryColorGreen Warning: resets on reload. @tfield int secondaryColorBlue Warning: resets on reload. @tfield int triumphValue Usage unknown. + @tfield int religionID. @tfield int standardIndex Warning: resets on reload. @tfield int logoIndex Warning: resets on reload. @tfield int smallLogoIndex Warning: resets on reload. + @tfield int hordeMaxUnits + @tfield int customBattleAvailability + @tfield int periodsUnavailableInCustomBattle + @tfield int canSap shouldnt do anything in med 2, but could potentially use flag to store some other info about this faction + @tfield int prefersNavalInvasions + @tfield int canHavePrincess + @tfield int hasFamilyTree + @tfield int teutonic + @tfield int disbandToPools + @tfield int canBuildSiegeTowers + @tfield int canTransmitPlague @table factionStratMapStruct */ @@ -2008,6 +2303,18 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.factionStratMapStruct.set("standardIndex", &factionStratMapDescrS::standard_index); types.factionStratMapStruct.set("logoIndex", &factionStratMapDescrS::logo_index); types.factionStratMapStruct.set("smallLogoIndex", &factionStratMapDescrS::small_logo_index); + types.factionStratMapStruct.set("religionID", &factionStratMapDescrS::religionID); + types.factionStratMapStruct.set("hordeMaxUnits", &factionStratMapDescrS::hordeMaxUnits); + types.factionStratMapStruct.set("customBattleAvailability", &factionStratMapDescrS::customBattleAvailability); + types.factionStratMapStruct.set("periodsUnavailableInCustomBattle", &factionStratMapDescrS::periodsUnavailableInCustomBattle); + types.factionStratMapStruct.set("canSap", &factionStratMapDescrS::canSap); + types.factionStratMapStruct.set("prefersNavalInvasions", &factionStratMapDescrS::prefersNavalInvasions); + types.factionStratMapStruct.set("canHavePrincess", &factionStratMapDescrS::canHavePrincess); + types.factionStratMapStruct.set("hasFamilyTree", &factionStratMapDescrS::hasFamilyTree); + types.factionStratMapStruct.set("teutonic", &factionStratMapDescrS::teutonic); + types.factionStratMapStruct.set("disbandToPools", &factionStratMapDescrS::disbandToPools); + types.factionStratMapStruct.set("canBuildSiegeTowers", &factionStratMapDescrS::canBuildSiegeTowers); + types.factionStratMapStruct.set("canTransmitPlague", &factionStratMapDescrS::canTransmitPlague); ///WatchtowerStruct @@ -2111,6 +2418,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int regionID @tfield int level @tfield int isCastle + @tfield int settlementTaxLevel @tfield int isProvokedRebellion @tfield int populationSize @tfield int PopGrowthBaseFarm - Get only @@ -2175,6 +2483,11 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getResource getResource @tfield int siegesNum @tfield getSiege getSiege + @tfield getSettlementCapability getSettlementCapability + @tfield getAgentCapability getAgentCapability + @tfield getAgentLimitCapability getAgentLimitCapability + @tfield getRecruitmentCapability getRecruitmentCapability + @tfield getSettlementRecruitmentPool getSettlementRecruitmentPool @table settlementStruct */ @@ -2205,8 +2518,19 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.settlementStruct.set("regionID", &settlementStruct::regionID); types.settlementStruct.set("level", &settlementStruct::level); types.settlementStruct.set("isCastle", &settlementStruct::isCastle); + types.settlementStruct.set("settlementTaxLevel", &settlementStruct::settlementTaxLevel); types.settlementStruct.set("isProvokedRebellion", &settlementStruct::isProvokedRebellion); types.settlementStruct.set("populationSize", &settlementStruct::populationSize); + types.settlementStruct.set("recruitPoolCapabilityCount", &settlementStruct::recruitPoolCapabilityCount); + types.settlementStruct.set("recruitmentPoolCount", &settlementStruct::recruitmentPoolCount); + types.settlementStruct.set("freezeRecruitmentPool", &settlementStruct::freezeRecruitmentPool); + types.settlementStruct.set("spiesInRecruitmentQueue", &settlementStruct::spiesInRecruitmentQueue); + types.settlementStruct.set("assassinsInRecruitmentQueue", &settlementStruct::assassinsInRecruitmentQueue); + types.settlementStruct.set("diplomatsInRecruitmentQueue", &settlementStruct::diplomatsInRecruitmentQueue); + types.settlementStruct.set("admiralsInRecruitmentQueue", &settlementStruct::admiralsInRecruitmentQueue); + types.settlementStruct.set("merchantsInRecruitmentQueue", &settlementStruct::merchantsInRecruitmentQueue); + types.settlementStruct.set("priestsInRecruitmentQueue", &settlementStruct::priestsInRecruitmentQueue); + types.settlementStruct.set("turmoil", &settlementStruct::turmoil); types.settlementStruct.set("PopGrowthBaseFarm", &settlementStruct::PopGrowthBaseFarm); types.settlementStruct.set("PopGrowthFarms", &settlementStruct::PopGrowthFarms); types.settlementStruct.set("PopGrowthHealth", &settlementStruct::PopGrowthHealth); @@ -2346,8 +2670,102 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) end */ types.settlementStruct.set_function("getSiege", &settlementHelpers::getSiege); + /*** + Get a capability by capability type. + @function settlementStruct:getSettlementCapability + @tparam int capabilityType + @treturn settlementCapability capability + @usage + local incomeBonus = settlementStruct:getSettlementCapability(55) + */ + types.settlementStruct.set_function("getSettlementCapability", &settlementHelpers::getSettlementCapability); + /*** + Get an agent capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. + @function settlementStruct:getAgentCapability + @tparam int agentType + @treturn settlementCapability capability + @usage + local spyCap = settlementStruct:getAgentCapability(0) + */ + types.settlementStruct.set_function("getAgentCapability", &settlementHelpers::getAgentCapability); + /*** + Get an agent limit capability by agent type (only recruitable agents) 0 = spy, 1 = assassin, 2 = diplomat, 3 = princess, 4 = merchant, 5 = priest. + @function settlementStruct:getAgentLimitCapability + @tparam int agentType + @treturn settlementCapability capability + @usage + local spyCapLimit = settlementStruct:getAgentLimitCapability(0) + */ + types.settlementStruct.set_function("getAgentLimitCapability", &settlementHelpers::getAgentCapability); + /*** + Get a recruitment capability by index (max 64!). + @function settlementStruct:getRecruitmentCapability + @tparam int index + @treturn recruitmentCapability capability + @usage + local capability = settlementStruct:getRecruitmentCapability(0) + */ + types.settlementStruct.set_function("getRecruitmentCapability", &settlementHelpers::getRecruitmentCapability); + /*** + Get a recruitment pool by index. + @function settlementStruct:getSettlementRecruitmentPool + @tparam int index + @treturn settlementRecruitmentPool pool + @usage + local pool = settlementStruct:getSettlementRecruitmentPool(0) + */ + types.settlementStruct.set_function("getSettlementRecruitmentPool", &settlementHelpers::getSettlementRecruitmentPool); + + ///settlementCapability + //@section settlementCapability + + /*** + Basic settlementCapability table + + @tfield int value + @tfield int bonus + @table settlementCapability + */ + types.settlementCapability = luaState.new_usertype("settlementCapability"); + types.settlementCapability.set("value", &settlementCapability::value); + types.settlementCapability.set("bonus", &settlementCapability::bonus); + + ///recruitmentCapability + //@section recruitmentCapability + + /*** + Basic recruitmentCapability table + + @tfield int eduIndex + @tfield int xp + @tfield float initialSize + @tfield float replenishRate + @tfield float maxSize + + @table recruitmentCapability + */ + types.recruitmentCapability = luaState.new_usertype("recruitmentCapability"); + types.recruitmentCapability.set("eduIndex", &recruitmentCapability::eduIndex); + types.recruitmentCapability.set("xp", &recruitmentCapability::xp); + types.recruitmentCapability.set("initialSize", &recruitmentCapability::initialSize); + types.recruitmentCapability.set("replenishRate", &recruitmentCapability::replenishRate); + types.recruitmentCapability.set("maxSize", &recruitmentCapability::maxSize); + + ///settlementRecruitmentPool + //@section settlementRecruitmentPool + + /*** + Basic settlementRecruitmentPool table + + @tfield int eduIndex + @tfield float availablePool + @table settlementRecruitmentPool + */ + types.settlementRecruitmentPool = luaState.new_usertype("settlementRecruitmentPool"); + types.settlementRecruitmentPool.set("eduIndex", &settlementRecruitmentPool::eduIndex); + types.settlementRecruitmentPool.set("availablePool", &settlementRecruitmentPool::availablePool); ///Building @@ -2618,6 +3036,10 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield factionStruct faction @tfield getUnit getUnit @tfield int numOfUnits + @tfield int isBoarded + @tfield int ladders + @tfield int rams + @tfield int towers @tfield getCharacter getCharacter @tfield int numOfCharacters Includes Auxiliary generals and agents (i.e all characters excluding the leading general) @tfield stackStruct boardedArmy army embarked on this fleet stack @@ -2642,6 +3064,10 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) */ types.stackStruct = luaState.new_usertype("stackStruct"); types.stackStruct.set("faction", &stackStruct::faction); + types.stackStruct.set("isBoarded", &stackStruct::isBoarded); + types.stackStruct.set("ladders", &stackStruct::ladders); + types.stackStruct.set("rams", &stackStruct::rams); + types.stackStruct.set("towers", &stackStruct::towers); /*** Sort units in a stack. diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index 7d1a94de0..7a4105d95 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -24,6 +24,14 @@ void luaP::initCampaign() sol::usertype collegeOfCardinals; sol::usertype crusadeStruct; sol::usertype jihadStruct; + sol::usertype options1; + sol::usertype options2; + sol::usertype uiCardManager; + sol::usertype coordPair; + sol::usertype landMass; + sol::usertype roadStruct; + sol::usertype seaConnectedRegion; + sol::usertype neighbourRegion; }typeAll; using namespace campaignEnums; @@ -56,6 +64,281 @@ void luaP::initCampaign() "trade", dipRelEnum::trade ); + ///options1 + //@section options1 + + /*** + Basic options1 table + + @tfield bool widescreen + @tfield int antiAliasMode + @tfield int subtitles + @tfield bool english + @tfield bool noBattleTimeLimit + @tfield int useNewCursorActions + @tfield int campaignNumTimesPlay + @tfield bool uiWinConditions + @tfield bool isScenario + @tfield int isHotseatEnabled + @tfield bool hotseatAutosave + @tfield bool email + @tfield bool saveConfig + @tfield bool closeAfterSave + @tfield bool validateData + @tfield bool campaignMapSpeedUp + @tfield int skipAiFactions + @tfield bool labelCharacters + @tfield bool noBackGroundFmv + @tfield bool disableArrowMarkers + @tfield bool arcadeBattles + @tfield bool disableEvents + @tfield bool isPrologue + @tfield bool updateAiCamera + @tfield bool hideCampaign + @tfield int unlimitedMenOnBattlefield + @tfield int tgaReserveSpace + @tfield int keysetUsed + @tfield bool muteAdvisor + @tfield bool advancedStatsAlways + @tfield bool microManageAllSettlements + @tfield bool blindAdvisor + @tfield int terrainQuality + @tfield int vegetationQuality + @tfield bool useQuickChat + @tfield int graphicsAdaptor + @tfield bool showDemeanour + @tfield int radar + @tfield int unitCards + @tfield int sa_cards + @tfield int buttons + @tfield bool tutorialBattlePlayed + @tfield bool disableVnVs + @tfield bool allUsers + + @table options1 + */ + typeAll.options1 = luaState.new_usertype("options1"); + typeAll.options1.set("widescreen", &options1::widescreen); + typeAll.options1.set("antiAliasMode", &options1::antiAliasMode); + typeAll.options1.set("subtitles", &options1::subtitles); + typeAll.options1.set("english", &options1::english); + typeAll.options1.set("noBattleTimeLimit", &options1::noBattleTimeLimit); + typeAll.options1.set("useNewCursorActions", &options1::useNewCursorActions); + typeAll.options1.set("campaignNumTimesPlay", &options1::campaignNumTimesPlay); + typeAll.options1.set("uiWinConditions", &options1::uiWinConditions); + typeAll.options1.set("isScenario", &options1::isScenario); + typeAll.options1.set("isHotseatEnabled", &options1::isHotseatEnabled); + typeAll.options1.set("hotseatAutosave", &options1::hotseatAutosave); + typeAll.options1.set("email", &options1::email); + typeAll.options1.set("saveConfig", &options1::saveConfig); + typeAll.options1.set("closeAfterSave", &options1::closeAfterSave); + typeAll.options1.set("validateData", &options1::validateData); + typeAll.options1.set("campaignMapSpeedUp", &options1::campaignMapSpeedUp); + typeAll.options1.set("skipAiFactions", &options1::skipAiFactions); + typeAll.options1.set("noBackGroundFmv", &options1::noBackGroundFmv); + typeAll.options1.set("disableArrowMarkers", &options1::disableArrowMarkers); + typeAll.options1.set("arcadeBattles", &options1::arcadeBattles); + typeAll.options1.set("disableEvents", &options1::disableEvents); + typeAll.options1.set("isPrologue", &options1::isPrologue); + typeAll.options1.set("updateAiCamera", &options1::updateAiCamera); + typeAll.options1.set("unlimitedMenOnBattlefield", &options1::unlimitedMenOnBattlefield); + typeAll.options1.set("tgaReserveSpace", &options1::tgaReserveSpace); + typeAll.options1.set("keysetUsed", &options1::keysetUsed); + typeAll.options1.set("muteAdvisor", &options1::muteAdvisor); + typeAll.options1.set("advancedStatsAlways", &options1::advancedStatsAlways); + typeAll.options1.set("microManageAllSettlements", &options1::microManageAllSettlements); + typeAll.options1.set("blindAdvisor", &options1::blindAdvisor); + typeAll.options1.set("terrainQuality", &options1::terrainQuality); + typeAll.options1.set("vegetationQuality", &options1::vegetationQuality); + typeAll.options1.set("useQuickChat", &options1::useQuickChat); + typeAll.options1.set("graphicsAdaptor", &options1::graphicsAdaptor); + typeAll.options1.set("showDemeanour", &options1::showDemeanour); + typeAll.options1.set("radar", &options1::radar); + typeAll.options1.set("unitCards", &options1::unitCards); + typeAll.options1.set("sa_cards", &options1::sa_cards); + typeAll.options1.set("buttons", &options1::buttons); + typeAll.options1.set("tutorialBattlePlayed", &options1::tutorialBattlePlayed); + typeAll.options1.set("disableVnVs", &options1::disableVnVs); + typeAll.options1.set("allUsers", &options1::allUsers); + + + ///options2 + //@section options2 + + /*** + Basic options2 table + + @tfield int campaignResolutionX + @tfield int campaignResolutionY + @tfield int battleResolutionX + @tfield int battleResolutionY + @tfield bool vSync + @tfield bool uiIconBarCheck + @tfield bool uiRadarCheck + @tfield bool useMorale + @tfield bool uiAmmoCheck + @tfield bool useFatigue + @tfield bool uiSupplyCheck + @tfield bool toggleFowState this does not toggle fow just remembers if it was on or off + @tfield bool cameraRestrict + @tfield bool eventCutscenes + @tfield int defaultCameraInBattle + @tfield bool splashes + @tfield bool stencilShadows + @tfield bool audioEnable + @tfield bool speechEnable + @tfield bool firstTimePlay + @tfield bool toggleAutoSave + @tfield bool showBanners + @tfield bool passwords + @tfield bool hotseatTurns + @tfield bool hotseatScroll + @tfield int allowValidationFeatures + @tfield int campaignSpeed + @tfield bool labelSettlements + @tfield bool disablePapalElections + @tfield bool autoresolveAllBattles + @tfield bool savePrefs + @tfield bool disableConsole + @tfield bool validateDiplomacy + @tfield int unitDetail + @tfield int buildingDetail + @tfield int maxSoldiersOnBattlefield if limited + @tfield int unitSize + @tfield int cameraRotateSpeed + @tfield int cameraMoveSpeed + @tfield float cameraSmoothing + @tfield int masterVolume + @tfield int musicVolume + @tfield int speechVolume + @tfield int sfxVolume + @tfield int subFactionAccents + @tfield int tgaWidth + @tfield float tgaAspect + @tfield int tgaInputScale + @tfield int scrollMinZoom + @tfield int scrollMaxZoom + @tfield int advisorVerbosity + @tfield int effectQuality + @tfield int EnableCameraCampaignSmoothing + @tfield int chatMsgDuration + @tfield bool saveGameSpyPassword + @tfield bool addDateToLogs + @tfield bool showToolTips + @tfield bool isNormalHud + @tfield bool showPackageLitter + @tfield float unitSizeMultiplierLow + @tfield float unitSizeMultiplierMedium + @tfield float unitSizeMultiplierLarge + + @table options2 + */ + typeAll.options2 = luaState.new_usertype("options2"); + typeAll.options2.set("campaignResolutionX", &options2::campaignResolutionX); + typeAll.options2.set("campaignResolutionY", &options2::campaignResolutionY); + typeAll.options2.set("battleResolutionX", &options2::battleResolutionX); + typeAll.options2.set("battleResolutionY", &options2::battleResolutionY); + typeAll.options2.set("vSync", &options2::vSync); + typeAll.options2.set("uiIconBarCheck", &options2::uiIconBarCheck); + typeAll.options2.set("uiRadarCheck", &options2::uiRadarCheck); + typeAll.options2.set("useMorale", &options2::useMorale); + typeAll.options2.set("uiAmmoCheck", &options2::uiAmmoCheck); + typeAll.options2.set("useFatigue", &options2::useFatigue); + typeAll.options2.set("uiSupplyCheck", &options2::uiSupplyCheck); + typeAll.options2.set("toggleFowState", &options2::toggleFowState); + typeAll.options2.set("cameraRestrict", &options2::cameraRestrict); + typeAll.options2.set("eventCutscenes", &options2::eventCutscenes); + typeAll.options2.set("defaultCameraInBattle", &options2::defaultCameraInBattle); + typeAll.options2.set("splashes", &options2::splashes); + typeAll.options2.set("stencilShadows", &options2::stencilShadows); + typeAll.options2.set("audioEnable", &options2::audioEnable); + typeAll.options2.set("speechEnable", &options2::speechEnable); + typeAll.options2.set("firstTimePlay", &options2::firstTimePlay); + typeAll.options2.set("toggleAutoSave", &options2::toggleAutoSave); + typeAll.options2.set("showBanners", &options2::showBanners); + typeAll.options2.set("passwords", &options2::passwords); + typeAll.options2.set("hotseatTurns", &options2::hotseatTurns); + typeAll.options2.set("hotseatScroll", &options2::hotseatScroll); + typeAll.options2.set("allowValidationFeatures", &options2::allowValidationFeatures); + typeAll.options2.set("campaignSpeed", &options2::campaignSpeed); + typeAll.options2.set("labelSettlements", &options2::labelSettlements); + typeAll.options2.set("disablePapalElections", &options2::disablePapalElections); + typeAll.options2.set("autoresolveAllBattles", &options2::autoresolveAllBattles); + typeAll.options2.set("savePrefs", &options2::savePrefs); + typeAll.options2.set("disableConsole", &options2::disableConsole); + typeAll.options2.set("validateDiplomacy", &options2::validateDiplomacy); + typeAll.options2.set("unitDetail", &options2::unitDetail); + typeAll.options2.set("buildingDetail", &options2::buildingDetail); + typeAll.options2.set("maxSoldiersOnBattlefield", &options2::maxSoldiersOnBattlefield); + typeAll.options2.set("unitSize", &options2::unitSize); + typeAll.options2.set("cameraRotateSpeed", &options2::cameraRotateSpeed); + typeAll.options2.set("cameraMoveSpeed", &options2::cameraMoveSpeed); + typeAll.options2.set("cameraSmoothing", &options2::cameraSmoothing); + typeAll.options2.set("masterVolume", &options2::masterVolume); + typeAll.options2.set("musicVolume", &options2::musicVolume); + typeAll.options2.set("speechVolume", &options2::speechVolume); + typeAll.options2.set("sfxVolume", &options2::sfxVolume); + typeAll.options2.set("subFactionAccents", &options2::subFactionAccents); + typeAll.options2.set("tgaWidth", &options2::tgaWidth); + typeAll.options2.set("tgaAspect", &options2::tgaAspect); + typeAll.options2.set("tgaInputScale", &options2::tgaInputScale); + typeAll.options2.set("scrollMinZoom", &options2::scrollMinZoom); + typeAll.options2.set("scrollMaxZoom", &options2::scrollMaxZoom); + typeAll.options2.set("advisorVerbosity", &options2::advisorVerbosity); + typeAll.options2.set("effectQuality", &options2::effectQuality); + typeAll.options2.set("EnableCameraCampaignSmoothing", &options2::EnableCameraCampaignSmoothing); + typeAll.options2.set("chatMsgDuration", &options2::chatMsgDuration); + typeAll.options2.set("saveGameSpyPassword", &options2::saveGameSpyPassword); + typeAll.options2.set("addDateToLogs", &options2::addDateToLogs); + typeAll.options2.set("isNormalHud", &options2::isNormalHud); + typeAll.options2.set("showPackageLitter", &options2::showPackageLitter); + typeAll.options2.set("unitSizeMultiplierLow", &options2::unitSizeMultiplierLow); + typeAll.options2.set("unitSizeMultiplierMedium", &options2::unitSizeMultiplierMedium); + typeAll.options2.set("unitSizeMultiplierLarge", &options2::unitSizeMultiplierLarge); + + ///uiCardManager + //@section uiCardManager + + /*** + Basic uiCardManager table + + @tfield int selectedUnitCardsCount + @tfield int unitCardsCount + @tfield settlementStruct selectedSettlement + @tfield character selectedCharacter + @tfield fortStruct selectedFort + @tfield getSelectedUnitCard getSelectedUnitCard + @tfield getUnitCard getUnitCard + + @table uiCardManager + */ + typeAll.uiCardManager = luaState.new_usertype("uiCardManager"); + typeAll.uiCardManager.set("selectedUnitCardsCount", &uiCardManager::selectedUnitCardsCount); + typeAll.uiCardManager.set("unitCardsCount", &uiCardManager::unitCardsCount); + typeAll.uiCardManager.set("selectedSettlement", &uiCardManager::selectedSettlement); + typeAll.uiCardManager.set("selectedCharacter", &uiCardManager::selectedCharacter); + typeAll.uiCardManager.set("selectedFort", &uiCardManager::selectedFort); + /*** + Get selected unit card by index. + @function uiCardManager:getSelectedUnitCard + @tparam int index + @treturn unit selectedUnit + @usage + local cardManager=gameDataAll.get().uiCardManager; + local selectedUnit=cardManager:getSelectedUnitCard(0); + */ + typeAll.uiCardManager.set_function("getSelectedUnitCard", &gameHelpers::getSelectedUnitCard); + /*** + Get unit card by index (battle or strat). + @function uiCardManager:getUnitCard + @tparam int index + @treturn unit unit + @usage + local cardManager=gameDataAll.get().uiCardManager; + local unit=cardManager:getUnitCard(0); + */ + typeAll.uiCardManager.set_function("getUnitCard", &gameHelpers::getUnitCard); + /// Campaign //@section campaignStruct @@ -72,6 +355,8 @@ void luaP::initCampaign() @tfield factionStruct currentFaction Faction whose turn it is at the moment, can be set. @tfield collegeOfCardinals collegeOfCardinals @tfield factionStruct papalFaction + @tfield int fogOfWar + @tfield int factionTurnID @tfield int tickCount @tfield int millisecondCount @tfield float secondCount @@ -118,9 +403,11 @@ void luaP::initCampaign() typeAll.campaignTable.set("numberHumanFactions", &campaign::humanPlayers); typeAll.campaignTable.set("collegeOfCardinals", &campaign::collegeOfCardinals); typeAll.campaignTable.set("currentFaction", &campaign::currentFactionTurn); + typeAll.campaignTable.set("factionTurnID", &campaign::factionTurnID); typeAll.campaignTable.set("tickCount", &campaign::tickCount); typeAll.campaignTable.set("millisecondCount", &campaign::millisecondCount); typeAll.campaignTable.set("secondCount", &campaign::secondCount); + typeAll.campaignTable.set("fogOfWar", &campaign::fogOfWar); typeAll.campaignTable.set("passedTurnsNum", &campaign::TurnNumber); typeAll.campaignTable.set("crusade", &campaign::crusade); typeAll.campaignTable.set("jihad", &campaign::jihad); @@ -226,8 +513,9 @@ void luaP::initCampaign() */ typeAll.campaignTable.set_function("getSettlementByName", &gameHelpers::getSettlementByName); - /// College of Cardinals + ///CollegeofCardinals //@section collegeOfCardinals + /*** Basic College of Cardinals table. @tfield namedCharacter pope @@ -293,6 +581,21 @@ void luaP::initCampaign() typeAll.jihadStruct.set("length", &jihad::length); typeAll.jihadStruct.set("outcome", &jihad::outcome); + /// coords + //@section coordPair + + /*** + Basic coordPair table. + + @tfield int xCoord + @tfield int yCoord + + @table coordPair + */ + typeAll.coordPair = luaState.new_usertype("coordPair"); + typeAll.coordPair.set("xCoord", &coordPair::xCoord); + typeAll.coordPair.set("yCoord", &coordPair::yCoord); + /// Strat Map //@section stratMap @@ -302,8 +605,14 @@ void luaP::initCampaign() @tfield int mapWidth @tfield int mapHeight @tfield int regionsNum + @tfield int volcanoesNum + @tfield int landConnectionsNum + @tfield int landMassNum @tfield getRegion getRegion @tfield getTile getTile + @tfield getVolcanoCoords getVolcanoCoords + @tfield getLandConnection getLandConnection + @tfield getLandMass getLandMass @table gameDataAll.stratMap */ @@ -311,6 +620,9 @@ void luaP::initCampaign() typeAll.stratMap.set("mapWidth", &stratMap::mapWidth); typeAll.stratMap.set("mapHeight", &stratMap::mapHeight); typeAll.stratMap.set("regionsNum", &stratMap::regionsNum); + typeAll.stratMap.set("volcanoesNum", &stratMap::volcanoesNum); + typeAll.stratMap.set("landConnectionsNum", &stratMap::landMassConnectionsNum); + typeAll.stratMap.set("landMassNum", &stratMap::landMassNum); /*** Get a specific region by index. @@ -334,12 +646,101 @@ void luaP::initCampaign() local tile = sMap.getTile(182, 243); */ typeAll.stratMap.set_function("getTile", &gameHelpers::getTile); + + /*** + Get a volcano's coordinates. + @function stratMap:getVolcanoCoords + @tparam int index + @treturn coordPair tile + @usage + local sMap = gameDataAll.get().stratMap; + local volcano = sMap:getVolcanoCoords(0); + */ + typeAll.stratMap.set_function("getVolcanoCoords", &gameHelpers::getVolcanoCoords); + + /*** + Get a land connection's coordinates (the green arrows on the map that allow you to cross bodies of water). + @function stratMap:getLandConnection + @tparam int index + @treturn coordPair tile + @usage + local sMap = gameDataAll.get().stratMap; + local connection = sMap:getLandConnection(0); + */ + typeAll.stratMap.set_function("getLandConnection", &gameHelpers::getLandConnection); + + /*** + Get a landmass (collection of regions reachable by land, like a continent or island). + @function stratMap:getLandMass + @tparam int index + @treturn landMass landMass + @usage + local sMap = gameDataAll.get().stratMap; + local tile = sMap:getLandMass(0); + */ + typeAll.stratMap.set_function("getLandMass", &gameHelpers::getLandMass); + + /// landMass + //@section landMass + + /*** + Basic landMass table. + + @tfield int index + @tfield int regionsNum + @tfield getRegionID getRegionID + + @table landMass + */ + typeAll.landMass = luaState.new_usertype("landMass"); + typeAll.landMass.set("index", &landMass::index); + typeAll.landMass.set("regionsNum", &landMass::regionsNum); + + /*** + Get a region ID by index. + @function landMass:getRegionID + @tparam int index + @treturn int regionID + @usage + local region = landMass:getRegionID(0); + */ + typeAll.landMass.set_function("getRegionID", &gameHelpers::getRegionID); + + /// roadStruct + //@section roadStruct + + /*** + Basic roadStruct table. + + @tfield int coordsNum + @tfield int regionIdStart + @tfield int regionIdEnd + @tfield getCoord getCoord + + @table roadStruct + */ + typeAll.roadStruct = luaState.new_usertype("roadStruct"); + typeAll.roadStruct.set("coordsNum", &roadStruct::coordsNum); + typeAll.roadStruct.set("regionIdStart", &roadStruct::regionIdStart); + typeAll.roadStruct.set("regionIdEnd", &roadStruct::regionIdEnd); + + /*** + Get a road coord by index. + @function roadStruct:getCoord + @tparam int index + @treturn coordPair coords + @usage + local coords = road:getCoord(0); + */ + typeAll.roadStruct.set_function("getCoord", &gameHelpers::getRoadCoord); + ///Tile //@section tileStruct /*** Basic tile table, not everything very known and understood yet, you can research with these fields. + @tfield roadStruct road @tfield int isLand (1 = land, 0 = sea) @tfield int groundType 0 low fertility @@ -359,21 +760,68 @@ void luaP::initCampaign() 14 impassable_land 15 impassable_sea @tfield int regionID - @tfield int factionID (Doesn't work if tile is river). - @tfield int borderingSettlement Not 0 means bordering settlement. - @tfield int hasRoad Not 0 means it has a road. - @tfield int border Not 0 means it is on border of region. - + @tfield int factionID + @tfield coordPair coords + @tfield int objectTypes bitfield, from left to right: unknown, character, ship, watchtower, port, unknown, fort, settlement. + @tfield bool hasRiver + @tfield bool hasCrossing + @tfield bool tileHasCharacter + @tfield bool tileHasShip + @tfield bool tileHasWatchtower + @tfield bool tileHasPort + @tfield bool tileHasFort + @tfield bool tileHasSettlement + @tfield int borderingSettlement 1 = bordering 2 = settlement. + @tfield int border 1 = border, 2 = seaBorder, 3 = sea edge border (point where the region border both another land region and sea). + @tfield int armiesNearTile bitfield of faction id's (counts both tile and the 8 tiles around it, if you want only on tile combine with charactersOnTile). + @tfield int charactersOnTile bitfield of faction id's + @tfield float mpModifier + @tfield factionHasArmyNearTile factionHasArmyNearTile + @tfield factionHasCharacterOnTile factionHasCharacterOnTile + @table tileStruct */ typeAll.tileStruct = luaState.new_usertype("tileStruct"); + typeAll.tileStruct.set("road", &oneTile::road); typeAll.tileStruct.set("isLand", &oneTile::isLand); typeAll.tileStruct.set("groundType", &oneTile::groundType); typeAll.tileStruct.set("regionID", &oneTile::regionId); - typeAll.tileStruct.set("factionID", &oneTile::factionId); + typeAll.tileStruct.set("objectTypes", &oneTile::objectTypes); + typeAll.tileStruct.set("coords", sol::property(gameHelpers::getTileCoords)); + typeAll.tileStruct.set("factionID", sol::property(gameHelpers::getTileFactionID)); typeAll.tileStruct.set("borderingSettlement", &oneTile::borderingSettlement); - typeAll.tileStruct.set("hasRoad", &oneTile::hasRoad); - typeAll.tileStruct.set("border", &oneTile::border); + typeAll.tileStruct.set("hasRiver", sol::property(gameHelpers::tileHasRiver)); + typeAll.tileStruct.set("hasCrossing", sol::property(gameHelpers::tileHasCrossing)); + typeAll.tileStruct.set("border", sol::property(gameHelpers::tileBorderType)); + typeAll.tileStruct.set("tileHasCharacter", sol::property(gameHelpers::tileHasCharacter)); + typeAll.tileStruct.set("tileHasShip", sol::property(gameHelpers::tileHasShip)); + typeAll.tileStruct.set("tileHasWatchtower", sol::property(gameHelpers::tileHasWatchtower)); + typeAll.tileStruct.set("tileHasPort", sol::property(gameHelpers::tileHasPort)); + typeAll.tileStruct.set("tileHasFort", sol::property(gameHelpers::tileHasFort)); + typeAll.tileStruct.set("tileHasSettlement", sol::property(gameHelpers::tileHasSettlement)); + typeAll.tileStruct.set("armiesNearTile", &oneTile::armiesNearTile); + typeAll.tileStruct.set("charactersOnTile", &oneTile::charactersOnTile); + typeAll.tileStruct.set("mpModifier", &oneTile::mpModifier); + + /*** + Check if a faction has an army near a tile. + @function tileStruct:factionHasArmyNearTile + @tparam int factionID + @treturn bool hasArmyNearTile + @usage + local hasArmyNearTile = tile:factionHasArmyNearTile(3); + */ + typeAll.roadStruct.set_function("factionHasArmyNearTile", &gameHelpers::factionHasArmyNearTile); + + /*** + Check if a faction has a character on a tile. + @function tileStruct:factionHasCharacterOnTile + @tparam int factionID + @treturn bool hasCharacterOnTile + @usage + local hasCharacterOnTile = tile:factionHasCharacterOnTile(3); + */ + typeAll.roadStruct.set_function("factionHasCharacterOnTile", &gameHelpers::factionHasCharacterOnTile); ///Region //@section Region @@ -391,11 +839,21 @@ void luaP::initCampaign() @tfield int watchtowersNum @tfield int isSea @tfield int hasLake (fully enclosed by region) - @tfield mercPool mercPool + @tfield landMass landMass + @tfield roadStruct roadToPort + @tfield int seaConnectedRegionsCount + @tfield int loyaltyFactionID + @tfield seaConnectedRegion seaExportRegion + @tfield int seaImportRegionsCount + @tfield int canSeaTrade + @tfield int regionSeaEdgesCount (point where the region border both another land region and sea). + @tfield int tilesBorderingEdgeOfMapCount @tfield settlementStruct settlement @tfield int tileCount + @tfield int fertileTilesCount @tfield int neighbourRegionsNum @tfield int resourcesNum + @tfield int resourceTypesBitMap @tfield int hiddenResources1 (bitmap with 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua. @tfield int hiddenResources2 (bitmap last 32 first hidden resources), needs to be converted to binary and then use bitwise operators from lua. @tfield int settlementXCoord @@ -413,6 +871,14 @@ void luaP::initCampaign() @tfield getNeighbour getNeighbour @tfield getHiddenResource getHiddenResource @tfield setHiddenResource setHiddenResource + @tfield getSeaConnectedRegion getSeaConnectedRegion + @tfield getSeaImportRegion getSeaImportRegion + @tfield getRegionSeaEdge getRegionSeaEdge + @tfield getReligionHistory getReligionHistory + @tfield getTileBorderingEdgeOfMap getTileBorderingEdgeOfMap + @tfield getTile getTile + @tfield getFertileTile getFertileTile + @tfield hasResourceType hasResourceType @table region */ @@ -424,6 +890,16 @@ void luaP::initCampaign() )); typeAll.region.set("legioName", ®ionStruct::legioName); typeAll.region.set("regionID", ®ionStruct::regionID); + typeAll.region.set("seaConnectedRegionsCount", ®ionStruct::seaConnectedRegionsCount); + typeAll.region.set("seaImportRegionsCount", ®ionStruct::seaImportRegionsCount); + typeAll.region.set("canSeaTrade", ®ionStruct::canSeaTrade); + typeAll.region.set("landMass", ®ionStruct::landMass); + typeAll.region.set("roadToPort", ®ionStruct::roadToPort); + typeAll.region.set("seaExportRegion", ®ionStruct::seaExportRegion); + typeAll.region.set("regionSeaEdgesCount", ®ionStruct::regionSeaEdgesCount); + typeAll.region.set("tilesBorderingEdgeOfMapCount", ®ionStruct::tilesBorderingEdgeOfMapCount); + typeAll.region.set("fertileTilesCount", ®ionStruct::fertileTilesCount); + typeAll.region.set("resourceTypesBitMap", ®ionStruct::resourceTypesBitMap); typeAll.region.set("stacksNum", ®ionStruct::stacksNum); typeAll.region.set("fortsNum", ®ionStruct::fortsNum); typeAll.region.set("watchtowersNum", ®ionStruct::watchtowersNum); @@ -499,11 +975,11 @@ void luaP::initCampaign() Get a neighbour region by it's index. @function region:getNeighbour @tparam int index - @treturn region nRegion + @treturn neighbourRegion nRegion @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); - region:getNeighbour(0) + local nRegion = region:getNeighbour(0) */ typeAll.region.set_function("getNeighbour", &gameHelpers::getNeighbour); @@ -515,7 +991,7 @@ void luaP::initCampaign() @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); - region:getHiddenResource(0) + localhr = region:getHiddenResource(0) */ typeAll.region.set_function("getHiddenResource", &gameHelpers::getHiddenResource); @@ -531,6 +1007,182 @@ void luaP::initCampaign() */ typeAll.region.set_function("setHiddenResource", &gameHelpers::setHiddenResource); + /*** + Get a region that is reachable from this region. + @function region:getSeaConnectedRegion + @tparam int index + @treturn seaConnectedRegion connectedRegion + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local connectedRegion = region:getSeaConnectedRegion(0) + */ + typeAll.region.set_function("getSeaConnectedRegion", &gameHelpers::getSeaConnectedRegion); + + /*** + Get a region this region is importing trade goods from. + @function region:getSeaImportRegion + @tparam int index + @treturn seaConnectedRegion seaImportRegion + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local seaImportRegion = region:getSeaImportRegion(0) + */ + typeAll.region.set_function("getSeaImportRegion", &gameHelpers::getSeaImportRegion); + + /*** + Get a region sea edge (point where it borders both sea and another land region). + @function region:getRegionSeaEdge + @tparam int index + @treturn tileStruct edge + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local edge = region:getRegionSeaEdge(0) + */ + typeAll.region.set_function("getRegionSeaEdge", &gameHelpers::getRegionSeaEdge); + + /*** + Get a tile that borders the edge of the map. + @function region:getTileBorderingEdgeOfMap + @tparam int index + @treturn tileStruct edge + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local edge = region:getTileBorderingEdgeOfMap(0) + */ + typeAll.region.set_function("getTileBorderingEdgeOfMap", &gameHelpers::getTileBorderingEdgeOfMap); + + /*** + Get a tile by index. + @function region:getTile + @tparam int index + @treturn tileStruct tile + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local tile = region:getTile(0) + */ + typeAll.region.set_function("getTile", &gameHelpers::getTileRegion); + + /*** + Get a fertile tile by index. + @function region:getFertileTile + @tparam int index + @treturn tileStruct tile + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local tile = region:getFertileTile(0) + */ + typeAll.region.set_function("getFertileTile", &gameHelpers::getFertileTile); + + /*** + Get religion amount from a set number of turns ago. + @function region:getReligionHistory + @tparam int religionID + @tparam int turnsAgo (max 19) + @treturn float religionAmount + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local catholicThreeTurnsAgo = region:getReligionHistory(0, 3) + */ + typeAll.region.set_function("getReligionHistory", &gameHelpers::getReligionHistory); + + /*** + Check if region has a resource type. + @function region:hasResourceType + @tparam int resourceID + @treturn bool hasResource + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local hasResource = region:hasResourceType(16) + */ + typeAll.region.set_function("hasResourceType", &gameHelpers::hasResourceType); + + ///neighbourRegion + //@section neighbourRegion + + /*** + Basic neighbourRegion table. + + @tfield int regionID + @tfield regionStruct region + @tfield int tradeValue + @tfield int borderTilesCount + @tfield roadStruct connectingRoad + @tfield getBorderTile getBorderTile + + + @table neighbourRegion + */ + typeAll.neighbourRegion = luaState.new_usertype("neighbourRegion"); + typeAll.neighbourRegion.set("regionID", &neighbourRegion::regionID); + typeAll.neighbourRegion.set("tradeValue", &neighbourRegion::tradeValue); + typeAll.neighbourRegion.set("region", &neighbourRegion::region); + typeAll.neighbourRegion.set("borderTilesCount", &neighbourRegion::borderTilesCount); + typeAll.neighbourRegion.set("connectingRoad", &neighbourRegion::connectingRoad); + + /*** + Get a border tile by index. + @function neighbourRegion:getBorderTile + @tparam int index + @treturn tileStruct tile + @usage + local tile = nRegion:getBorderTile(0) + */ + typeAll.neighbourRegion.set_function("getBorderTile", &gameHelpers::getBorderTile); + + + + ///seaConnectedRegion + //@section seaConnectedRegion + + /*** + Basic seaConnectedRegion table. + + @tfield int regionID + @tfield int seaExportValue + @tfield int seaImportValue + @tfield int tilesReachableCount + @tfield int seaTradeLanePathCount + @tfield getReachableTile getReachableTile + @tfield getTradeLaneCoord getTradeLaneCoord + + + @table seaConnectedRegion + */ + typeAll.seaConnectedRegion = luaState.new_usertype("seaConnectedRegion"); + typeAll.seaConnectedRegion.set("regionID", &seaConnectedRegion::regionID); + typeAll.seaConnectedRegion.set("seaExportValue", &seaConnectedRegion::seaExportValue); + typeAll.seaConnectedRegion.set("seaImportValue", &seaConnectedRegion::seaImportValue); + typeAll.seaConnectedRegion.set("tilesReachableCount", &seaConnectedRegion::tilesReachableCount); + typeAll.seaConnectedRegion.set("seaTradeLanePathCount", &seaConnectedRegion::seaTradeLanePathCount); + + /*** + Get a reachable tile by index. + @function seaConnectedRegion:getReachableTile + @tparam int index + @treturn tileStruct tile + @usage + local tile = seaRegion:getReachableTile(0) + */ + typeAll.seaConnectedRegion.set_function("getReachableTile", &gameHelpers::getReachableTile); + + /*** + Get trade lane coords by index. + @function seaConnectedRegion:getTradeLaneCoord + @tparam int index + @treturn coordPair coords + @usage + local coords = seaRegion:getTradeLaneCoord(0) + */ + typeAll.seaConnectedRegion.set_function("getTradeLaneCoord", &gameHelpers::getTradeLaneCoord); + ///MercPools //@section mercPool @@ -669,6 +1321,7 @@ void luaP::initP2() sol::usertype battleAI; sol::usertype battleArmy; sol::usertype battleUnit; + sol::usertype battleResidence; }typeAll; ///GameDataAll @@ -734,9 +1387,15 @@ void luaP::initP2() @tfield int paused @tfield float battleSpeed @tfield float secondsPassed + @tfield int secondsSinceBattleLoaded + @tfield int hidingEnabledSet + @tfield float mapWidthDoubled + @tfield float mapHeightDoubled @tfield int sidesNum Returns a battleSide[8]. Maximum: 8. @tfield battleSide[8] sides - @tfield factionSide[31] faction alliance array, -1 if not in battle + @tfield factionSide[31] faction alliance array, -1 if not in battle, start at 1 so faction dipnum + 1 + tfield getPlayerArmy getPlayerArmy + @tfield getBattleResidence getBattleResidence @table gameDataAll.battleStruct */ @@ -753,9 +1412,34 @@ void luaP::initP2() typeAll.battleTable.set("paused", &battleDataS::paused); typeAll.battleTable.set("battleSpeed", &battleDataS::speed); typeAll.battleTable.set("secondsPassed", &battleDataS::secondsPassed); + typeAll.battleTable.set("secondsSinceBattleLoaded", &battleDataS::secondsSinceBattleLoaded); + typeAll.battleTable.set("hidingEnabledSet", &battleDataS::hidingEnabledSet); + typeAll.battleTable.set("mapWidthDoubled", &battleDataS::mapWidthDoubled); + typeAll.battleTable.set("mapHeightDoubled", &battleDataS::mapHeightDoubled); typeAll.battleTable.set("sidesNum", &battleDataS::sidesNum); typeAll.battleTable.set("sides", sol::property([](battleDataS& self) { return std::ref(self.sides); })); typeAll.battleTable.set("factionSide", sol::property([](battleDataS& self) { return std::ref(self.factionSide); })); + /*** + Get the players army. + @function battleStruct:getPlayerArmy + @treturn stackStruct army + @usage + + local playerArmy = battle:getPlayerArmy() + + */ + typeAll.battleTable.set_function("getPlayerArmy", &battleHandlerHelpers::getPlayerArmy); + /*** + Get table with certain info about the battle residence. + @function battleStruct.getBattleResidence + @treturn battleResidence battleResidence + @usage + + local battleResidence = battle.getBattleResidence() + + */ + typeAll.battleTable.set_function("getBattleResidence", &battleHandlerHelpers::getBattleResidence); + ///BattleSide //@section battleSide @@ -771,10 +1455,13 @@ void luaP::initP2() @tfield int armiesNum @tfield int alliance @tfield int soldierCount + @tfield int factionCount @tfield int totalStrenght @tfield battleAI battleAIPlan @tfield getBattleArmy getBattleArmy - @tfield trackedPointerArmy[8] Returns a table of trackedPointerArmy. Maximum: 8. + @tfield trackedPointerArmy[8] armies Returns a table of trackedPointerArmy. Maximum: 8. + + @@ -788,6 +1475,7 @@ void luaP::initP2() typeAll.battleSideTable.set("alliance", &battleSide::alliance); typeAll.battleSideTable.set("soldierCount", &battleSide::soldierCount); typeAll.battleSideTable.set("totalStrenght", &battleSide::totalStrenght); + typeAll.battleSideTable.set("factionCount", &battleSide::factionCount); typeAll.battleSideTable.set("battleAIPlan", &battleSide::battleAIPlan); typeAll.battleSideTable.set("winConditions", sol::property([](battleSide& self) { return std::ref(self.winConditions); })); /*** @@ -833,16 +1521,26 @@ void luaP::initP2() typeAll.battleSideTable.set("armies", sol::property([](battleSide& self) { return std::ref(self.armies); })); /*** Get a battle army by it's index. - @function getBattleArmy - @tparam battleSideTable side + @function battleSideTable:getBattleArmy @tparam int index @treturn battleArmy army @usage - unit = side:getBattleArmy(0) + battleArmy = side:getBattleArmy(0) */ typeAll.battleSideTable.set_function("getBattleArmy", &battleHandlerHelpers::getBattleArmy); + /*** + Get a faction in this side by it's index. + @function battleSideTable:getFaction + @tparam int index + @treturn factionStruct faction + @usage + + faction = side:getFaction(0) + + */ + typeAll.battleSideTable.set_function("getFaction", &battleHandlerHelpers::getFaction); ///TrackedPointerArmy @@ -934,6 +1632,8 @@ void luaP::initP2() @tfield float generalHPRatioLost @tfield float battleOdds @tfield int numKilledGenerals + @tfield int numDiedGenerals + @tfield int numKilledCaptains @tfield int unitCount @tfield getBattleUnit getBattleUnit @@ -946,11 +1646,12 @@ void luaP::initP2() typeAll.battleArmy.set("generalHPRatioLost", &armyAndCharacter::generalHPRatioLost); typeAll.battleArmy.set("battleOdds", &armyAndCharacter::battleOdds); typeAll.battleArmy.set("numKilledGenerals", &armyAndCharacter::numKilledGenerals); + typeAll.battleArmy.set("numDiedGenerals", &armyAndCharacter::generalsDiedCount); + typeAll.battleArmy.set("numKilledCaptains", &armyAndCharacter::killedCaptainsCount); typeAll.battleArmy.set("unitCount", &armyAndCharacter::unitCount); /*** Get a battle unit by it's index. - @function getBattleUnit - @tparam battleArmy army + @function battleArmy:getBattleUnit @tparam int index @treturn battleUnit unit @usage @@ -969,7 +1670,16 @@ void luaP::initP2() @tfield int soldiersLost @tfield int soldiersStart @tfield int unitsRouted - @tfield boolean hasRouted + @tfield int soldiersKilled + @tfield int takenPrisoner + @tfield int prisonersCaught + @tfield int soldiersHealed + @tfield int unitsRoutedEnd + @tfield int soldiersEnd + @tfield int friendlyFireCasualties + @tfield int expStart + @tfield int expGained + @tfield int isGeneral @table battleUnit */ @@ -978,5 +1688,33 @@ void luaP::initP2() typeAll.battleUnit.set("soldiersLost", &battleUnit::soldiersLost); typeAll.battleUnit.set("soldiersStart", &battleUnit::soldiersStart); typeAll.battleUnit.set("unitsRouted", &battleUnit::unitsRouted); - typeAll.battleUnit.set("hasRouted", &battleUnit::hasRouted); + typeAll.battleUnit.set("soldiersKilled", &battleUnit::soldiersKilled); + typeAll.battleUnit.set("takenPrisoner", &battleUnit::takenPrisoner); + typeAll.battleUnit.set("prisonersCaught", &battleUnit::prisonersCaught); + typeAll.battleUnit.set("soldiersHealed", &battleUnit::soldiersHealed); + typeAll.battleUnit.set("unitsRoutedEnd", &battleUnit::unitsRoutedEnd); + typeAll.battleUnit.set("soldiersEnd", &battleUnit::soldiersEnd); + typeAll.battleUnit.set("friendlyFireCasualties", &battleUnit::friendlyFireCasualties); + typeAll.battleUnit.set("expStart", &battleUnit::expStart); + typeAll.battleUnit.set("expGained", &battleUnit::expGained); + typeAll.battleUnit.set("isGeneral", &battleUnit::isGeneral); + + /// battleResidence + //@section battleResidence + + /*** + Basic battleResidence table + + @tfield settlementStruct settlement + @tfield int isFortBattle + @tfield bool settlementWallsBreached + @tfield bool settlementGateDestroyed + + @table battleResidence + */ + typeAll.battleResidence = luaState.new_usertype("battleResidence"); + typeAll.battleResidence.set("settlement", &battleResidence::settlement); + typeAll.battleResidence.set("isFortBattle", &battleResidence::isFortBattle); + typeAll.battleResidence.set("settlementWallsBreached", &battleResidence::settlementWallsBreached); + typeAll.battleResidence.set("settlementGateDestroyed", &battleResidence::settlementGateDestroyed); } \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp index 4ddcae500..66f2fa428 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.cpp @@ -215,4 +215,22 @@ namespace m2tweopHelpers return (*(*plugData::data.funcs.getGameVersion))(); } + options1* getOptions1() + { + if (getGameVersion() == 1) + { + return reinterpret_cast(0x02CB693C); + } + return reinterpret_cast(0x02C6D804); + } + + options2* getOptions2() + { + if (getGameVersion() == 1) + { + return reinterpret_cast(0x016818A0); + } + return reinterpret_cast(0x01639EF0); + } + } \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h index 8ef6eb1c9..da8f05861 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/m2tweopHelpers.h @@ -50,6 +50,8 @@ namespace m2tweopHelpers void setEDUUnitsSize(signed short min, signed short max); int getGameVersion(); + options1* getOptions1(); + options2* getOptions2(); std::tuple loadTextureToGame(const std::string& path); diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index cb7b156df..1b9e26fe3 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -33,6 +33,29 @@ struct rcString char pad_0010[104]; //0x0010 }; //Size: 0x0078 +struct generalStats +{ +public: + struct soldierInBattle* generalBgSoldier; //0x0000 + struct soldierInBattle* generalBgMount; //0x0004 +}; //Size: 0x0008 + +struct coordPair +{ +public: + int32_t xCoord; //0x0000 + int32_t yCoord; //0x0004 +}; //Size: 0x0008 + +struct movePath +{ +public: + struct coordPair* tileCoords; //0x0000 + int32_t tileCoordsSize; //0x0004 + int32_t tileCoordsCount; //0x0008 +}; //Size: 0x000C + + class religionDatabase { public: @@ -77,6 +100,31 @@ struct capturedFactionInfo int32_t ransomValue; }; +struct floatsSeaConnect +{ +public: + uint32_t tileId; //0x0000 + float someFloat; //0x0004 +}; //Size: 0x0008 + +struct seaConnectedRegion +{ +public: + int32_t regionID; //0x0000 + char pad_0004[4]; //0x0004 + float angle; //0x0008 + float distance; //0x000C + int32_t seaExportValue; //0x0010 + int32_t seaImportValue; //0x0014 + struct floatsSeaConnect *tilesReachable; //0x0018 + int32_t tilesReachableSize; //0x001C + int32_t tilesReachableCount; //0x0020 + struct coordPair* seaTradeLanePath; //0x0024 + int32_t seaTradeLanePathSize; //0x0028 + int32_t seaTradeLanePathCount; //0x002C + char pad_0030[4]; //0x0030 +}; //Size: 0x0034 + struct regionStruct { char* regionName;//0x0000 int regionNameHash;//0x0004 @@ -86,7 +134,9 @@ struct regionStruct { int legioNameHash;//0x0014 undefined field4_0x10[4];//0x0018 int regionID;//0x001C - char pad_0020[12]; //0x0020 + int32_t N00008C49; //0x0020 + int32_t N00008C4A; //0x0024 + int32_t overOneAllowsFamine; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -98,23 +148,46 @@ struct regionStruct { int32_t watchtowersNum; //0x004C int8_t isSea; //0x0050 int8_t hasLake; //0x0051 - char pad_0052[58]; //0x0052 + char pad_0052[2]; //0x0052 + struct landMass* landMass; //0x0054 + struct roadStruct* roadToPort; //0x0054 + struct seaConnectedRegion* seaConnectedRegions; //0x005C + int32_t seaConnectedRegionsCountArraySize; //0x0060 + int32_t seaConnectedRegionsCount; //0x0064 + int32_t loyaltyFactionID; //0x0068 + struct seaConnectedRegion* seaExportRegion; //0x006C + char pad_0070[12]; //0x0070 + struct seaConnectedRegion** seaImportRegions; //0x007C + int32_t seaImportRegionsSize; //0x0080 + int32_t seaImportRegionsCount; //0x0084 + int32_t canSeaTrade; //0x0088 struct mercPool* mercPool;//0x008C - undefined field6_0x90[36];//0x0090 + int32_t* regionSeaEdges; //0x0090 + int32_t regionSeaEdgesSize; //0x0094 + int32_t regionSeaEdgesCount; //0x0098 + char pad_009C[24]; //0x009C float* religionsARR;//0x00B4 - int* religionsEnd; //0x00B8 - undefined field8_0xbc[212];//0x00BC + float* religionHistory[20]; + uint32_t* tilesBorderingEdgeOfMap; //0x0108 + int32_t tilesBorderingEdgeOfMapSize; //0x010C + int32_t tilesBorderingEdgeOfMapCount; //0x0110 + char pad_0114[124]; //0x0114 struct settlementStruct* settlement;//0x0190 - char pad_0194[8]; //0x0194 + int* tiles; //0x0194 + int32_t tilesSize; //0x0198 int32_t tileCount; //0x019C - char pad_0177[12]; //0x0194 + int* fertileTiles; //0x01A0 + int32_t fertileTilesSize; //0x01A4 + int32_t fertileTilesCount; //0x01A8 struct neighbourRegion* neighbourRegions;//0x01AC int32_t neighbourRegionsCountArraySize; //0x01B0 int32_t neighbourRegionsNum; //0x01B4 struct resStrat** resources;//0x01B8 - int32_t resourceCountArrayZie; //0x01BC + int32_t resourcesSize; //0x01BC int32_t resourcesNum; //0x01C0 - char pad_01C4[12]; //0x01C4 + int32_t N00008CB2; //0x01C4 + uint32_t resourceTypesBitMap; //0x01C8 + int32_t N00008CB4; //0x01CC uint32_t hiddenResources1; //0x01D0 uint32_t hiddenResources2; //0x01D4 char pad_01D8[4]; //0x01D8 @@ -142,20 +215,45 @@ struct neighbourRegion int32_t regionID; //0x0004 float distance; //0x0008 char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + struct roadStruct* connectingRoad; //0x0010 + int32_t tradeValue; //0x0014 + int32_t* bordertiles; //0x0018 + int32_t borderTilessize; //0x001C + int32_t borderTilesCount; //0x0020 + char pad_0024[52]; //0x0024 }; //Size: 0x0058 +struct landMass +{ +public: + int32_t index; //0x0000 + int32_t* regions; //0x0004 + int32_t regionsSize; //0x0008 + int32_t regionsNum; //0x000C +}; //Size: 0x0010 + struct stratMap { - undefined field_0x0[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + char pad_000C[28]; //0x000C + void* climates; //0x0028 int mapWidth; int mapHeight; undefined field_0x34[20]; struct oneTile* tilesArr; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD TileListEnd; //0x004C + undefined field_0x50[20]; + struct coordPair* volcanoes; //0x0064 + int32_t volcanoesSize; //0x0068 + int32_t volcanoesNum; //0x006C + struct coordPair* landMassConnections; //0x0070 + int32_t landMassConnectionsSize; //0x0074 + int32_t landMassConnectionsNum; //0x0078 struct regionStruct regions[200]; int regionsNum; + struct landMass landMass[20]; //0x1A660 + int32_t landMassNum; //0x1A7A0 }; struct mercPoolUnit { @@ -225,9 +323,24 @@ struct uiElement { undefined field_0x58[112]; }; +struct roadStruct +{ +public: + struct coordPair* coords; //0x0000 + int32_t coordsSize; //0x0004 + int32_t coordsNum; //0x0008 + void* someOtherArray; //0x000C + int32_t someOtherArraySize; //0x0010 + int32_t someOtherArrayCount; //0x0014 + int32_t regionIdStart; //0x0018 + int32_t regionIdEnd; //0x001C + char pad_0020[24]; //0x0020 +}; //Size: 0x0038 + struct oneTile { void* object; - undefined field_0x4[6]; + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -243,9 +356,13 @@ struct oneTile { int8_t hasRoad; int8_t border; undefined field_0x22[2]; - int8_t objectTypes; + int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 int8_t passable; - undefined field_0x26[14]; + int8_t N0002227F; //0x0026 + int8_t N00022271; //0x0027 + uint32_t armiesNearTile; //0x0028 + uint32_t charactersOnTile; //0x002C + float mpModifier; //0x0030 }; struct siegeS { @@ -254,11 +371,77 @@ struct siegeS { struct stackStruct* army; }; +struct stringWithHash +{ +public: + char* name; //0x0000 + int32_t hash; //0x0004 +}; //Size: 0x0008 + +struct holdRegionsWinCondition +{ +public: + char pad_0000[4]; //0x0000 + int32_t intSomethingTurns; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + char pad_0014[4]; //0x0014 + int32_t numberOfRegions; //0x0018 + char pad_001C[4]; //0x001C + int32_t* holdRegionLengths; //0x0020 + int32_t holdRegionLengthsSize; //0x0024 + int32_t holdRegionLengthsCount; //0x0028 + char pad_002C[12]; //0x002C +}; //Size: 0x0080 + +struct battleSettlement +{ +public: + char pad_0000[4]; //0x0000 + struct settlementStruct* settlement; //0x0004 + char pad_0008[4]; //0x0008 + struct battleResidence* battleResidence; //0x000C + char pad_0010[304]; //0x0010 +}; //Size: 0x0140 + +struct battleResidence +{ +public: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + char pad_0034[8]; //0x0034 + float N000203C6; //0x003C + float N000203C7; //0x0040 + char pad_0044[40]; //0x0044 + int8_t settlementWallsBreached; //0x006C + int8_t settlementGateDestroyed; //0x006D + char pad_006E[2]; //0x006E + int8_t N0003A33C; //0x0070 + char pad_0071[7]; //0x0071 + float N0003A33E; //0x0078 + char pad_007C[200]; //0x007C +}; //Size: 0x0144 + +struct factionRanking +{ +public: + float totalRanking; //0x0000 + float militaryRanking; //0x0004 + float productionRanking; //0x0008 + float territoryRanking; //0x000C + float FinancialRanking; //0x0010 + float populationRanking; //0x0014 +}; //Size: 0x0018 + struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int id; char* facName; DWORD facNameHash; - undefined field_0xc[60]; + undefined field_0xc[56]; + int religionID; struct model_Rigid* symbol; char* symbolPath; DWORD symbolPathHash; @@ -279,7 +462,26 @@ struct factionStratMapDescrS { /* see descr_sm_factions.txt */ int standard_index; int logo_index; int small_logo_index; - undefined field_0x88[88]; + undefined field_0x88[20]; + int32_t hordeMaxUnits; //0x009C + char pad_00A0[28]; //0x00A0 + uint8_t customBattleAvailability; //0x00BC + char pad_00BD[3]; //0x00BD + uint32_t periodsUnavailableInCustomBattle; //0x00C0 + uint8_t N00008DC2; //0x00C4 + uint8_t canSap; //0x00C5 + char pad_00C6[2]; //0x00C6 + int32_t prefersNavalInvasions; //0x00C8 + uint8_t canHavePrincess; //0x00CC + char pad_00CD[3]; //0x00CD + char* specialfactionType; //0x00D0 + char pad_00D4[4]; //0x00D4 + uint8_t hasFamilyTree; //0x00D8 + uint8_t teutonic; //0x00D9 + uint8_t disbandToPools; //0x00DA + uint8_t canBuildSiegeTowers; //0x00DB + uint8_t canTransmitPlague; //0x00DC + char pad_00DD[3]; //0x00DD }; struct watchTowerModel { @@ -413,7 +615,8 @@ struct campaign { struct factionStruct* currentFactionTurn; int factionTurnID; /* FactionTurn? */ UNICODE_STRING** currentDescrFile; /* path to descr_battle.txt or to descr_strat.txt */ - undefined field20_0x350[28]; + int32_t fogOfWar; //0x0350 + undefined field20_0x354[24]; int tickCount; /* TickCount? */ int millisecondCount; float secondCount; @@ -445,7 +648,7 @@ struct campaign { int8_t saveEnabled; //0x06F5 undefined field45_0x6f6[6]; int8_t hotseatConsole; - int8_t hotseatConsole2; + int8_t hotseatConsoleEnabledWithLogon; undefined field48_0x6fe[14]; float currentDate; int season; /* season(0-summer,1-winter) */ @@ -476,6 +679,32 @@ struct campaign { int32_t watchtowersNum; //0x2162C }; +struct uiUnitCard +{ +public: + char pad_0000[380]; //0x0000 + unit* unit; //0x0384 +}; + +struct uiCardManager +{ +public: + char pad_0000[16]; //0x0000 + struct uiUnitCard** selectedUnitCards; //0x0010 + int32_t selectedUnitCardsSize; //0x0014 + int32_t selectedUnitCardsCount; //0x0018 + char pad_001C[24]; //0x001C + struct uiUnitCard** unitCards; //0x0034 + int32_t unitCardsSize; //0x0038 + int32_t unitCardsCount; //0x003C + char pad_0060[328]; //0x0060 + struct settlementStruct* selectedSettlement; //0x0188 + char pad_018C[12]; //0x018C + struct general* selectedCharacter; //0x0198 + char pad_019C[12]; //0x019C + struct fortStruct* selectedFort; //0x01A8 +}; + struct gameDataAllStruct { undefined field_0x0[40]; struct campaign* campaignData; @@ -484,7 +713,11 @@ struct gameDataAllStruct { struct campaign* field_0x38; undefined field_0x3c[28]; struct battleDataS* battleHandler; - undefined field_0x5c[8]; + undefined field_0x5c[36]; + struct battleSettlement* battleSettlement; + char pad[112]; + struct uiCardManager* uiCardManager; + char pad2[84]; }; struct battleUnit @@ -494,14 +727,248 @@ struct battleUnit struct UNICODE_STRING** localizedName; //0x0004 float someFloat; //0x0008 int32_t soldiersLost; //0x000C - char pad_0010[12]; //0x0010 + int32_t soldiersKilled; //0x0010 + int32_t takenPrisoner; //0x0014 + int32_t prisonersCaught; //0x0018 int32_t soldiersStart; //0x001C uint32_t unitsRouted; //0x0020 - char pad_0024[20]; //0x0024 - int8_t hasRouted; //0x0038 - char pad_0039[15]; //0x0039 + int32_t soldiersHealed; //0x0024 + int32_t unitsRoutedEnd; //0x0028 + int32_t soldiersEnd; //0x002C + int32_t friendlyFireCasualties; //0x0030 + int32_t expStart; //0x0034 + int32_t expGained; //0x0038 + int8_t isGeneral; //0x003C + char pad_003D[11]; //0x003D }; //Size: 0x0048 +struct options1 +{ + void* cursor; //0x0000 + int8_t N0003DD45; //0x0004 + int8_t widescreen; //0x0005 + char pad_0006[2]; //0x0006 + int64_t antiAliasMode; //0x0008 + int16_t subtitles; //0x0010 + int8_t english; //0x0012 + int8_t noBattleTimeLimit; //0x0013 + char pad_0014[4]; //0x0014 + int32_t useNewCursorActions; //0x0018 + int32_t campaignNumTimesPlay; //0x001C + int8_t uiWinConditions; //0x0020 + int8_t isScenario; //0x0021 + char pad_0022[2]; //0x0022 + int32_t isHotseatEnabled; //0x0024 + int8_t hotseatAutosave; //0x0028 + int8_t email; //0x0029 + int8_t saveConfig; //0x002A + int8_t closeAfterSave; //0x002B + int8_t validateData; //0x002C + int8_t campaignMapSpeedUp; //0x002D + char pad_002E[2]; //0x002E + int32_t skipAiFactions; //0x0030 + int8_t labelCharacters; //0x0034 + int8_t noBackGroundFmv; //0x0035 + int8_t disableArrowMarkers; //0x0036 + int8_t arcadeBattles; //0x0037 + int8_t disableEvents; //0x0038 + int8_t isPrologue; //0x0039 + int8_t updateAiCamera; //0x003A + int8_t hideCampaign; //0x003B + int32_t unlimitedMenOnBattlefield; //0x003C + char pad_0040[4]; //0x0040 + class N0003DA46* prefFactionsPlayed; //0x0044 + int32_t tgaReserveSpace; //0x0048 + int32_t keysetUsed; //0x004C + class N0003DD67* descrShortcuts; //0x0050 + int8_t muteAdvisor; //0x0054 + int8_t advancedStatsAlways; //0x0055 + int8_t microManageAllSettlements; //0x0056 + int8_t blindAdvisor; //0x0057 + int32_t terrainQuality; //0x0058 + int32_t vegetationQuality; //0x005C + int8_t useQuickChat; //0x0060 + int8_t someBoolNetworkManager; //0x0061 + char pad_0062[1]; //0x0062 + int8_t someBoolOnlinePlay; //0x0063 + int32_t graphicsAdaptor; //0x0064 + int8_t byte_2C6D86C; //0x0068 + int8_t showDemeanour; //0x0069 + char pad_006A[2]; //0x006A + int32_t radar; //0x006C + int32_t unitCards; //0x0070 + int32_t sa_cards; //0x0074 + int32_t buttons; //0x0078 + int8_t tutorialBattlePlayed; //0x007C + int8_t disableVnVs; //0x007D + int8_t allUsers; //0x007E + char pad_007F[29]; //0x007F + int32_t unk_2C6D8A0; //0x009C + char pad_00A0[28]; //0x00A0 + char* audioProvider; //0x00BC + char pad_00C0[20]; //0x00C0 + struct UNICODE_STRING** campaignName; //0x00D4 + char pad_00D8[4]; //0x00D8 + struct UNICODE_STRING*** N0003DA7C; //0x00DC + struct UNICODE_STRING*** maybeGameSpyUsername; //0x00E0 + struct UNICODE_STRING*** gameSpyPassword; //0x00E4 + char pad_00E8[4]; //0x00E8 + char* gameName; //0x00EC + char pad_00F0[24]; //0x00F0 + char adminPassword[28]; //0x0108 + char* tutorialPath; //0x0124 +}; //Size: 0x0128 + + +struct options2 +{ + uint16_t defaultCampaignResolutionX; //0x0000 + uint16_t defaultCampaignResolutionY; //0x0002 + uint16_t campaignResolutionX; //0x0004 + uint16_t campaignResolutionY; //0x0006 + uint16_t defaultBattleResolutionX; //0x0008 + uint16_t defaultBattleResolutionY; //0x000A + uint16_t battleResolutionX; //0x000C + uint16_t battleResolutionY; //0x000E + int8_t idk; //0x0010 + int8_t vSync; //0x0011 + char pad_0012[6]; //0x0012 + int8_t uiIconBarCheck; //0x0018 + int8_t uiRadarCheck; //0x0019 + int8_t useMorale; //0x001A + int8_t uiAmmoCheck; //0x001B + int8_t useFatigue; //0x001C + int8_t uiSupplyCheck; //0x001D + int8_t toggleFowState; //0x001E + int8_t cameraRestrict; //0x001F + int8_t eventCutscenes; //0x0020 + char pad_0021[3]; //0x0021 + int32_t defaultCameraInBattle; //0x0024 + int8_t splashes; //0x0028 + int8_t vegetationVideo; //0x0029 + int8_t byte_1639F1A; //0x002A + int8_t stencilShadows; //0x002B + int8_t byte_1639F1C; //0x002C + int8_t audioEnable; //0x002D + int8_t speechEnable; //0x002E + int8_t firstTimePlay; //0x002F + char* audioProviderName; //0x0030 + char pad_0034[1]; //0x0034 + int8_t byte_1639F25; //0x0035 + char pad_0036[1]; //0x0036 + int8_t toggleAutoSave; //0x0037 + int8_t showBanners; //0x0038 + int8_t passwords; //0x0039 + int8_t hotseatTurns; //0x003A + int8_t hotseatScroll; //0x003B + int32_t allowValidationFeatures; //0x003C + int32_t campaignSpeed; //0x0040 + int8_t labelSettlements; //0x0044 + int8_t disablePapalElections; //0x0045 + int8_t autoresolveAllBattles; //0x0046 + int8_t savePrefs; //0x0047 + int8_t disableConsole; //0x0048 + int8_t validateDiplomacy; //0x0049 + char pad_004A[2]; //0x004A + float someFloat; //0x004C + int32_t unitDetail; //0x0050 + int32_t buildingDetail; //0x0054 + int32_t maxSoldiersOnBattlefield; //0x0058 + int32_t unitSize; //0x005C + int32_t cameraRotateSpeed; //0x0060 + int32_t cameraMoveSpeed; //0x0064 + float cameraSmoothing; //0x0068 + int32_t somethingBasedOnBuildingDetail; //0x006C + int32_t masterVolume; //0x0070 + int32_t musicVolume; //0x0074 + int32_t speechVolume; //0x0078 + int32_t sfxVolume; //0x007C + int32_t subFactionAccents; //0x0080 + int32_t playerFactionId; //0x0084 + int32_t campaignDifficulty; //0x0088 + int32_t battleDifficulty; //0x008C + int32_t tgaWidth; //0x0090 + float tgaAspect; //0x0094 + int32_t tgaInputScale; //0x0098 + int32_t scrollMinZoom; //0x009C + int32_t scrollMaxZoom; //0x00A0 + int32_t advisorVerbosity; //0x00A4 + int8_t useSomethingTgaTextures; //0x00A8 + int8_t byte_1639F99; //0x00A9 + char pad_00AA[2]; //0x00AA + int32_t effectQuality; //0x00AC + int32_t EnableCameraCampaignSmoothing; //0x00B0 + int32_t chatMsgDuration; //0x00B4 + int8_t N0003DDF9; //0x00B8 + int8_t saveGameSpyPassword; //0x00B9 + int8_t addDateToLogs; //0x00BA + int8_t showToolTips; //0x00BB + int8_t isNormalHud; //0x00BC + int8_t showPackageLitter; //0x00BD + char pad_00BE[2]; //0x00BE + char* normal; //0x00C0 + char pad_00C4[8]; //0x00C4 + int32_t effectNormal; //0x00CC + char pad_00D0[8]; //0x00D0 + char* low; //0x00D8 + char pad_00DC[8]; //0x00DC + int32_t effectLow; //0x00E4 + char pad_00E8[8]; //0x00E8 + char* high; //0x00F0 + char pad_00F4[8]; //0x00F4 + int32_t effectHigh; //0x00FC + char pad_0100[8]; //0x0100 + char* lowest; //0x0108 + char pad_010C[8]; //0x010C + int32_t effectLowest; //0x0114 + char pad_0118[8]; //0x0118 + char* highest; //0x0120 + char pad_0124[8]; //0x0124 + int32_t effectHighest; //0x012C + char pad_0130[8]; //0x0130 + char* custom; //0x0138 + char pad_013C[8]; //0x013C + int32_t effectCustom; //0x0144 + char pad_0148[8]; //0x0148 + char* lower; //0x0150 + char pad_0154[8]; //0x0154 + int32_t effectLower; //0x015C + char pad_0160[8]; //0x0160 + char* higher; //0x0168 + char pad_016C[8]; //0x016C + int32_t effectHigher; //0x0174 + char pad_0178[8]; //0x0178 + char* off; //0x0180 + char pad_0184[8]; //0x0184 + int32_t effectOff; //0x018C + char pad_0190[32]; //0x0190 + int32_t maxSizeEduMaybe1; //0x01B0 + float unitMultDefault; //0x01B4 + int32_t unitMultDefaultId; //0x01B8 + int32_t maxSizeEduMaybe2; //0x01BC + float unitSizeMultiplierLow; //0x01C0 + int32_t unitMult1ID; //0x01C4 + int32_t maxSizeEduMaybe3; //0x01C8 + float unitSizeMultiplierMedium; //0x01CC + int32_t unitMult2ID; //0x01D0 + int32_t maxSizeEduMaybe4; //0x01D4 + float unitSizeMultiplierLarge; //0x01D8 + int32_t unitMult3ID; //0x01DC + char pad_01E0[12]; //0x01E0 + uint16_t word_163A0DC; //0x01EC + char pad_01EE[10]; //0x01EE + uint16_t word_163A0E8; //0x01F8 + char pad_01FA[2]; //0x01FA + uint16_t word_163A0EC; //0x01FC + char pad_01FE[54]; //0x01FE + int16_t currentHotseatPlayerOrSomething; //0x0234 + char pad_0236[2]; //0x0236 + class N0003DF44* keysetPointer; //0x0238 + char pad_023C[4]; //0x023C + int32_t keySetUsed; //0x0240 + int32_t preferencesWereLoaded; //0x0244 +}; + struct armyAndCharacter { /* in battle leader and leader army */ struct stackStruct* army;//0x0000 @@ -510,11 +977,18 @@ struct armyAndCharacter { /* in battle leader and leader army */ float generalHPRatioLost; //0x000C float someFloat; //0x0010 float battleOdds; //0x0014 - char pad_0018[20]; //0x0018 + char pad_0018[12]; //0x0018 + struct general* killedGenerals; //0x0024 + int32_t killedGeneralsSize; //0x0028 int32_t numKilledGenerals; //0x002C - char pad_0030[36]; //0x0030 - DWORD N0001FC50; //0x0054 - char pad_0058[68]; //0x0058 + char pad_0030[24]; //0x0030 + struct general* generalsDied; //0x0048 + int32_t generalsDiedSize; //0x004C + int32_t generalsDiedCount; //0x0050 + struct general* killedCaptains; //0x0054 + int32_t killedCaptainsSize; //0x0058 + int32_t killedCaptainsCount; //0x005C + char pad_005C[60]; //0x005C struct battleUnit* units; //0x009C int32_t unitArraySize; //0x00A0 int32_t unitCount; //0x00A4 @@ -673,6 +1147,13 @@ struct battleSide { char pad_1928[4]; //0x1928 }; +struct playerArmy +{ +public: + struct stackStruct* army; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + struct battleDataS { undefined field_0x0[4];//0x0000 int battleState; /* 0-not in battle,5-active battle,9-results screen,etc 0x0004 */ @@ -691,11 +1172,32 @@ struct battleDataS { float speed; //0x0058 char pad_005C[8]; //0x005C float secondsPassed; //0x0064 - char pad_0068[48]; //0x0068 + int32_t secondsSinceBattleLoaded; //0x0068 + char pad_006C[16]; //0x006C + float mapWidthDoubled; //0x007C + float mapHeightDoubled; //0x0080 + char pad_0084[12]; //0x0084 + int32_t hidingEnabledSet; //0x0090 + char pad_0094[4]; //0x0094 struct UNICODE_STRING** someUniString; //0x0098 struct battleSide sides[8]; //0x009C int32_t factionSide[31]; //0xC9FC int sidesNum;//0xCA78 + char pad_CA7C[44]; //0xCA7C + struct playerArmy playerArmies[30]; //0xCAA8 + char pad_CD78[4]; //0xCD78 + int32_t playerArmyCount; //0xCD7C + char pad_CD80[84]; //0xCD80 + int32_t N0001D4DC; //0xCDD4 + int32_t N0001D4DD; //0xCDD8 + char pad_CDDC[20]; //0xCDDC + int32_t N0001D4E3; //0xCDF0 + int32_t N0001D4E4; //0xCDF4 + char pad_CDF8[4]; //0xCDF8 + int32_t N0001D4E6; //0xCDFC + int32_t N0001D4E7; //0xCE00 + char pad_CE04[44]; //0xCE04 + struct battleDataS* thisStruct; //0xCE30 };//Size: 0xCA7C struct stratPortModel { @@ -1113,6 +1615,36 @@ struct RallyPointSundry { undefined field4_0x44[16]; }; +struct settlementCapability +{ +public: + int16_t value; //0x0000 + int16_t bonus; //0x0002 +}; //Size: 0x0004 + +struct recruitCapRome +{ +public: + char pad[8]; +}; //Size: 0x0008 + +struct recruitmentCapability +{ +public: + int32_t eduIndex; //0x0000 + int32_t xp; //0x0004 + float initialSize; //0x0008 + float replenishRate; //0x000C + float maxSize; //0x0010 +}; //Size: 0x0014 + +struct settlementRecruitmentPool +{ +public: + int32_t eduIndex; //0x0000 + float availablePool; //0x0004 +}; //Size: 0x0008 + //settlement struct settlementStruct { void* vTable; @@ -1157,19 +1689,51 @@ struct settlementStruct { undefined field26_0x5ac[520]; struct building* buildings[128]; int buildingsNum; /* number of the buildings in the settlement */ - undefined field29_0x9b8[1100]; - uchar isProvokedRebellion; - uchar field31_0xe05[3]; - undefined field32_0xe08[24]; - struct general* governor; - undefined field34_0xe24[32]; + undefined field29_0x9b8[1080]; + int32_t rallyPointX; //0x0DF0 + int32_t rallyPointY; //0x0DF4 + void* rallyPointPointer; //0x0DF8 + void* AIProductionController; //0x0DFC + char pad_0E00[4]; //0x0E00 + int8_t scriptRebel; //0x0E04 + uchar isProvokedRebellion;//0x0E05 + uchar field31_0xe06[34];//0x0E06 + struct general* governor;//0x0E28 + char pad_0E2C[12]; //0x0E2C + int32_t publicOrderLastTurnEnd; //0x0E38 + int32_t populationLastTurnEnd; //0x0E3C + char pad_0E40[4]; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct settlementCapability settlementCapabilities[57]; //0x0E54 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 + struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) + char pad_0F78[4]; //0x0F78 + struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C + struct recruitmentCapability recruitmentCapabilities[64]; //0x117C + int32_t recruitPoolCapabilityCount; //0x167C + int8_t N000089C8; //0x1680 + char pad_1681[3]; //0x1681 + struct settlementStruct* thisSett; //0x1684 + struct settlementRecruitmentPool* recruitmentPools; //0x1688 + int32_t recruitmentPoolsSize; //0x168C + int32_t recruitmentPoolCount; //0x1690 + char pad_1694[12]; //0x1694 + int8_t freezeRecruitmentPool; //0x16A0 + char pad_16A1[3]; //0x16A1 + int32_t spiesInRecruitmentQueue; //0x16A4 + int32_t assassinsInRecruitmentQueue; //0x16A8 + int32_t diplomatsInRecruitmentQueue; //0x16AC + int32_t admiralsInRecruitmentQueue; //0x16B0 + int32_t merchantsInRecruitmentQueue; //0x16B4 + int32_t priestsInRecruitmentQueue; //0x16B8 + char pad_16BC[8]; //0x16BC intptr_t guildStandings; char pad_16C8[56]; //0x16C8 - int32_t Turmoil; //0x1700 + int32_t turmoil; //0x1700 char pad_1704[116]; //0x1704 int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C @@ -1269,24 +1833,56 @@ struct general { /* character on the stratmap, who has a unit in a stack */ struct genMod* genType; undefined field9_0x8c[24]; uchar ifMarkedToKill; - undefined field11_0xa5[19]; + undefined field11_0xa5[1]; + int8_t inEnemyZOC; //0x00A6 + char pad_00A7[17]; //0x00A7 int ambushState; undefined field13_0xbc[12]; - float movepoints1; + int8_t doNotSpendMovePoints; //0x00C5 + char pad_00C6[2]; //0x00C6 + float movePointsCharacter; undefined field15_0xcc[4]; uchar isStopCharacterNeeded; /* set to 1 if character moving now and he stops */ - undefined field17_0xd1[47]; + int32_t numTurnsIdle; //0x00D4 + int32_t regionID; //0x00D8 + float percentCharacterReligionInRegion; //0x00DC + float popConvertedThisTurn; //0x00E0 + int32_t timeInRegion; //0x00E4 + int32_t timeWithArmy; //0x00E8 + char pad_00EC[20]; //0x00EC struct stackStruct* armyLeaded; /* army of the general */ undefined field19_0x104[4]; struct unit* bodyguards; /* unit of general */ struct stackStruct* armyNotLeaded; /* army, if not leader */ undefined field22_0x110[208]; undefined field23_0x1e0[4]; - float movepointsModifier; - float movepointsMax; - float movepoints2; - undefined field27_0x1f0[64]; + float movePointsModifier; + float movePointsMax; + float movePointsArmy; + float movePointsMaxArmy; //0x01F0 + struct crusade* crusade; //0x01F4 + int32_t turnJoinedCrusade; //0x01F8 + int32_t currentTurn; //0x01FC + char pad_0200[48]; //0x0200 char* ability; /* custom ability */ + char pad_0234[4]; //0x0234 + struct general* thisCharacter; //0x0238 + char pad_023C[16]; //0x023C + struct general* thisCharacter2; //0x024C + int32_t xCoordLast; //0x0250 + int32_t yCoordLast; //0x0254 + int32_t xCoordCurrent; //0x0258 + int32_t yCoordCurrent; //0x025C + char pad_0260[332]; //0x0260 + void* someCoordStruct; //0x03AC + int32_t someCoordStructSize; //0x03B0 + int32_t someCoordStructCount; //0x03B4 + struct movePath *multiTurnMovePaths; //0x03B8 + int8_t multiTurnMovePathsSize; //0x03BC + int8_t multiTurnMovePathsCount; //0x03BD + int8_t N00032E71; //0x03BE + int8_t N00032E76; //0x03BF + char pad_03C0[8]; //0x03C0 }; //additional character data(name,label,traits, etc) @@ -1588,18 +2184,51 @@ struct targetPos public: int32_t typeOrSomething; //0x0000 int32_t N0001B8DA; //0x0004 - void* getsSet0IfHalted; //0x0008 + void* unitVerificationTable; //0x0008 struct targetUnitStruct* targetUnit; //0x000C char pad_0010[4]; //0x0010 - float targetPosX; //0x0014 - float targetPosY; //0x0018 - char pad_001C[24]; //0x001C + float targetPosXStart; //0x0014 + float targetPosYStart; //0x0018 + char pad_001C[16]; //0x001C + int32_t noDraggedFormation; //0x002C + float N0001B8E5; //0x0030 float N0001B8E6; //0x0034 char pad_0038[4]; //0x0038 - float N0001B8E8; //0x003C - char pad_0040[4]; //0x0040 - int32_t N0001B8EA; //0x0044 - char pad_0048[96]; //0x0048 + float somethingDistanceRelated; //0x003C + int32_t ranks; //0x0040 + float N0001B8EA; //0x0044 + char pad_0048[4]; //0x0048 + float N0001B8EC; //0x004C + char pad_0050[4]; //0x0050 + int8_t N0001B8EE; //0x0054 + int8_t draggedFormation1; //0x0055 + int8_t N0003D819; //0x0056 + int8_t draggedFormation2; //0x0057 + int8_t N0001B8EF; //0x0058 + int8_t N0003D80B; //0x0059 + int8_t N0003D80E; //0x005A + int8_t N0003D80C; //0x005B + float targetPosXEnd; //0x005C + float targetPosYEnd; //0x0060 + int8_t N0001B8F4; //0x0064 + int8_t N0003D7F4; //0x0065 + int8_t N0003D7F7; //0x0066 + int8_t N0003D7F5; //0x0067 + void* N0001B8F5; //0x0068 + int8_t N0001B8F6; //0x006C + int8_t N0003D7EA; //0x006D + int8_t N0003D7ED; //0x006E + int8_t N0003D7EB; //0x006F + float targetCoordXEngine; //0x0070 + float targetCoordZEngine; //0x0074 + float targetCoordYEngine; //0x0078 + struct siegeEngine* siegeEngine; //0x007C + int32_t N0001B8FB; //0x0080 + int32_t N0001B8FC; //0x0084 + char pad_0088[8]; //0x0088 + float N0001B8FF; //0x0090 + char pad_0094[16]; //0x0094 + float N0003A5AB; //0x00A4 }; //Size: 0x00A8 struct battleMapPosition @@ -1842,29 +2471,50 @@ struct stackStruct { /* structure of stack */ struct factionStruct* faction; int regionID; struct unit** units; - undefined field_0x58[4]; + int32_t unitsSize; //0x0058 int numOfUnits; - undefined field_0x60[56]; + undefined field_0x60[48]; + int8_t isBoarded; //0x0090 + char pad_0091[7]; //0x0091 struct stackStruct* boardedArmy; /* if fleet, here army */ undefined field_0x9c[4]; struct stackStruct* shipArmy; /* here fleet what contain our army */ undefined field_0xa4[8]; struct siegeS* siege; struct portBuildingStruct* blockedPort; /* if port blocked by this army when it here */ - undefined field_0xb4[32]; + undefined field_0xb4[3]; + int8_t ladders; //0x00B7 + int8_t rams; //0x00B8 + int8_t towers; //0x00B9 + char pad_00BA[10]; //0x00BA + int32_t tilesMovedThisTurnDoesntStatAtZero; //0x00C4 + char pad_00C8[4]; //0x00C8 + uint32_t upkeepModifier; //0x00CC + char pad_00D0[4]; //0x00D0 struct general* gen; /* 0 if in settlement/fort */ - undefined field_0xd8[24]; - struct general** characters; - undefined field_0xf4[4]; - int charactersNum; - undefined field_0xfc[4]; - struct settlementStruct* settlement; - undefined field_0x104[32]; + struct unit* generalsUnit; //0x00D8 + struct generalInfo* generalInfo; //0x00DC + float armyStrengthForAutoResolveMaybe; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct general** characters; //0x00F0 + undefined field_0xf4[4]; //0x00F4 + int charactersNum; //0x00F8 + undefined field_0xfc[4]; //0x00FC + struct settlementStruct* settlement; //0x0100 + undefined field_0x104[16]; + struct stackStruct* enemyArmy; + int32_t inBattle; //0x0118 + int8_t N00001BCA; //0x011C + int8_t N0003D211; //0x011D + uint16_t N0003D214; //0x011E + char pad_0120[4]; //0x0120 int totalStrength; float reform_point_x; float reform_point_y; - - + int32_t battleSide; //0x0130 + char pad_0134[16]; //0x0134 + int32_t battleAllianceOrSomething; //0x0144 + int32_t battleDifficulty; //0x0148 }; struct coords { @@ -1882,56 +2532,129 @@ struct factionTileStruct { int revealedTilesNumber; undefined field7_0x34[24]; }; + +struct factionEconomy +{ +public: + int32_t farmingIncome; //0x0000 + int32_t taxesIncome; //0x0004 + int32_t miningIncome; //0x0008 + int32_t tradeIncome; //0x000C + int32_t merchantIncome; //0x0010 + int32_t constructionIncome; //0x0014 + int32_t otherIncome1; //0x0018 + int32_t otherIncome2; //0x001C + int32_t diplomacyIncome; //0x0020 + int32_t tributesIncome; //0x0024 + int32_t adminIncome; //0x0028 + int32_t kingsPurseIncome; //0x002C + int32_t wagesExpense; //0x0030 + int32_t upkeepExpense; //0x0034 + int32_t constructionExpenseBuildings; //0x0038 + int32_t constructionExpenseField; //0x003C + int32_t recruitmentExpenseBuildings; //0x0040 + int32_t recruitmentExpenseMercs; //0x0044 + int32_t corruptionExpense; //0x0048 + int32_t diplomacyExpense; //0x004C + int32_t tributesExpense; //0x0050 + int32_t otherExpense1; //0x0054 + int32_t otherExpense2; //0x0058 + int32_t devastationExpense; //0x005C +}; //Size: 0x0060 + +struct battleFactionCounter +{ +public: + int32_t battlesWon; //0x0000 + int32_t battlesLost; //0x0004 + int32_t wonLostRatio; //0x0008 +}; //Size: 0x000C + //faction struct factionStruct { undefined field_0x0[180]; int dipNum; /* number of faction in diplomatic array */ int cultureID; char* ai_label; /* ai_label of faction */ - undefined field_0xc0[4]; + int32_t AILabelHash; //0x00C0 struct settlementStruct* capital; /* capital of the faction */ struct namedCharacter* leader; /* faction leader */ struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - UINT32* ai_assistant; - undefined field_0xdc[20]; - UINT32 holdRegions; - undefined field_0xf4[4]; + struct aiFaction* AIFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t someInteger; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ - undefined field_0xfc[4]; + int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ struct general** characters; /* characters on stratmap */ - undefined field_0x108[4]; + int32_t charactersSize; //0x0108 int numOfCharacters; /* characters on stratmap */ struct stackStruct** stacks; - undefined field_0x114[4]; + int32_t armiesSize; //0x0114 int stackNum; int* regionsID; - undefined field_0x120[4]; + int32_t regionsSize; //0x0120 int regionsNum; struct settlementStruct** settlements; - undefined field_0x12c[4]; + int32_t settlementsSize; //0x012C int settlementsNum; struct fortStruct** forts; - undefined field_0x138[4]; + int32_t fortsSize; //0x0138 int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ - undefined field_0x144[4]; + int32_t watchtowersSize; //0x0144 int wathtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ - undefined field_0x150[4]; + int32_t portBuildingsSize; //0x0150 int portBuildingsNum; - undefined field_0x158[68]; + uint32_t neighBourFactionsBitmap; //0x0158 + int* neighBourRegions; //0x015C + int32_t neighBourRegionsSize; //0x0160 + int32_t neighBourRegionsNum; //0x0164 + char pad_0168[49]; //0x0168 + int8_t isUndiscovered; //0x0199 + char pad_019A[2]; //0x019A factionTileStruct* tilesFac; - undefined field_0x1a0[2208]; + struct mission** missions; //0x01A0 + int32_t missionsSize; //0x01A4 + int32_t missionCount; //0x01A8 + char pad_01AC[48]; //0x01AC + struct factionRanking* factionRankings; //0x01DC + int32_t factionRankingsSize; //0x01E0 + int32_t factionRankingsCount; //0x01E4 + char pad_01E8[24]; //0x01E8 + int32_t freezeFactionAI; //0x0200 + char pad_0204[2096]; //0x0204 + int32_t treasuryTurnStart; //0x0A34 + char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ - undefined field_0xa44[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + char pad_0A55[67]; //0x0A55 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; int money; /* money of the faction */ int KingsPurse; /* money of the faction */ + int32_t incomeDoubled; //0x0AF4 + struct factionEconomy factionEconomy[10]; //0x0AF8 + int32_t nextCounterEconomy; //0x0EB8 + int32_t counterEconomy; //0x0EBC + int32_t maxTurnsTillReset; //0x0EC0 + char pad_0EC4[16]; //0x0EC4 + struct battleFactionCounter(*battlesWonVsFaction)[31]; //0x0ED4 + int32_t factionCountStart; //0x0ED8 + int32_t otherFactionCount; //0x0EDC + int32_t battlesWon; //0x0EE0 + int32_t battlesLost; //0x0EE4 + int32_t settlementsCaptured; //0x0EE8 + int32_t settlementsLost; //0x0EEC + char pad_0EF0[24]; //0x0EF0 }; struct ModelDbEntry diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index 91ca92ef0..331b144d7 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp @@ -61,3 +61,23 @@ void settlementHelpers::setGuildStanding(settlementStruct* sett, int index, int { *(int*)((sett->guildStandings) + 0x4 * index) = amount; } +settlementCapability* settlementHelpers::getSettlementCapability(settlementStruct* sett, int capabilityType) +{ + return &sett->settlementCapabilities[capabilityType]; +} +settlementCapability* settlementHelpers::getAgentCapability(settlementStruct* sett, int agentType) +{ + return &sett->settlementCapabilitiesAgent[agentType]; +} +settlementCapability* settlementHelpers::getAgentLimitCapability(settlementStruct* sett, int agentType) +{ + return &sett->settlementCapabilitiesAgentLimit[agentType]; +} +recruitmentCapability* settlementHelpers::getRecruitmentCapability(settlementStruct* sett, int index) +{ + return &sett->recruitmentCapabilities[index]; +} +settlementRecruitmentPool* settlementHelpers::getSettlementRecruitmentPool(settlementStruct* sett, int index) +{ + return &sett->recruitmentPools[index]; +} diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h index b610340a2..c2861577a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h @@ -19,6 +19,11 @@ namespace settlementHelpers int getGuildStanding(settlementStruct* sett, int index); void setGuildStanding(settlementStruct* sett, int index, int amount); void changeSettlementName(settlementStruct* sett, const char* newName); + settlementCapability* getSettlementCapability(settlementStruct* sett, int capabilityType); + settlementCapability* getAgentCapability(settlementStruct* sett, int agentType); + settlementCapability* getAgentLimitCapability(settlementStruct* sett, int agentType); + recruitmentCapability* getRecruitmentCapability(settlementStruct* sett, int index); + settlementRecruitmentPool* getSettlementRecruitmentPool(settlementStruct* sett, int index); std::string getSettlementName(settlementStruct* sett); diff --git a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp index 8c524907b..47bf84815 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp @@ -171,9 +171,9 @@ namespace unitHelpers { return nullptr; } - if (posData->targetArray[posData->targetsToGo].targetUnit) + if (posData->targetArray[posData->targetsDone].targetUnit) { - return posData->targetArray[posData->targetsToGo].targetUnit->target; + return posData->targetArray[posData->targetsDone].targetUnit->target; } return nullptr; } From 95d183dc10380847fcd695f611a5222a8849b39e Mon Sep 17 00:00:00 2001 From: FynnTW Date: Tue, 17 Oct 2023 14:57:17 +0300 Subject: [PATCH 17/22] recruitable eop units and more --- M2TWEOP Code/M2TWEOP library/Injects.cpp | 570 +++++- M2TWEOP Code/M2TWEOP library/Injects.h | 122 +- M2TWEOP Code/M2TWEOP library/eopBuildings.cpp | 19 +- M2TWEOP Code/M2TWEOP library/eopBuildings.h | 2 +- .../M2TWEOP library/functionsOffsets.cpp | 2 + .../M2TWEOP library/functionsOffsets.h | 1 + M2TWEOP Code/M2TWEOP library/managerF.cpp | 54 +- .../M2TWEOP library/patchesForGame.cpp | 64 +- M2TWEOP Code/M2TWEOP library/patchesForGame.h | 8 +- M2TWEOP Code/M2TWEOP library/plugins.cpp | 12 + M2TWEOP Code/M2TWEOP library/plugins.h | 4 +- M2TWEOP Code/M2TWEOP library/realGameTypes.h | 200 +- M2TWEOP Code/M2TWEOP library/smallFuncs.cpp | 68 +- M2TWEOP Code/M2TWEOP library/smallFuncs.h | 31 + M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp | 523 +++--- M2TWEOP-luaPlugin/luaPlugin/basicEvents.h | 841 +-------- M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h | 4 +- .../luaPlugin/buildingStructHelpers.cpp | 4 +- .../luaPlugin/buildingStructHelpers.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp | 275 ++- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h | 37 + M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp | 5 +- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 1650 +++++++---------- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 13 +- M2TWEOP-luaPlugin/luaPlugin/luaP.h | 1 + M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 86 + M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp | 6 + M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 202 +- .../luaPlugin/technicalHelpers.cpp | 5 + .../luaPlugin/technicalHelpers.h | 1 + 30 files changed, 2553 insertions(+), 2259 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/Injects.cpp b/M2TWEOP Code/M2TWEOP library/Injects.cpp index b57af75ce..4dddeab50 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.cpp +++ b/M2TWEOP Code/M2TWEOP library/Injects.cpp @@ -2480,6 +2480,54 @@ void onGameConsoleCommandFromConsole::SetNewCode() delete a; } +onGameInitialized::onGameInitialized(MemWork* mem, LPVOID adr, int ver) + :AATemplate(mem), funcAddress(adr) +{ + if (ver == 2)//steam + m_adress = 0x00414E08; + + else if (ver == 1)//kingdoms + m_adress = 0x00414C08; +} + +onGameInitialized::~onGameInitialized() +{ +} + +void onGameInitialized::SetOriginalCode() +{ + Assembler* a = new Assembler(); + + a->add(esp, 0x4); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void onGameInitialized::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->pushad(); + a->pushf(); + + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + a->popad(); + a->add(esp, 0x4); + a->push(0x1); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + onGameConsoleCommandFromScript::onGameConsoleCommandFromScript(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { @@ -2966,30 +3014,95 @@ void OnCreateUnit::SetNewCode() a->push(ebx); a->push(ebp); a->push(edi); + a->push(esi); a->pushf(); + a->mov(edx, eax); + a->mov(ecx, edi); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + + a->pop(esi); + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + + + +OnFindUnit::OnFindUnit(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + m_adress = 0x0047543A; + + else if (ver == 1)//kingdoms + m_adress = 0x0047504A; +} + +OnFindUnit::~OnFindUnit() +{ +} + +void OnFindUnit::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->test(eax, eax); + //jz + + a->push(edx); + a->mov(eax, dword_ptr(eax)); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnFindUnit::SetNewCode() +{ + static int fakeEDBPointer; + Assembler* a = new Assembler(); + + a->push(ecx); + //a->mov(ecx, dword_ptr(esp, 0x8)); + + a->push(edx); + a->push(ebx); + a->push(ebp); + a->push(edi); + a->push(esi); - a->mov(ecx, (int)&fakeEDBPointer); - a->mov(dword_ptr(ecx), esi); + a->pushf(); - a->mov(edx, ecx);//here pointer to edb - a->mov(ecx, eax);//here pointer to index in edb - a->push(edi);//entry name - a->mov(eax, (DWORD)funcAddress);//we must return index + a->mov(edx, eax); + a->mov(eax, (DWORD)funcAddress); a->call(eax); - //here in eax we must put -1 if not find - a->mov(esi, (int)&fakeEDBPointer); - a->mov(esi, dword_ptr(esi)); a->popf(); + a->pop(esi); a->pop(edi); a->pop(ebp); a->pop(ebx); - a->pop(ecx); a->pop(edx); - + a->pop(ecx); @@ -3105,6 +3218,353 @@ void OnCreateMercUnit::SetNewCode() delete a; } +OnGetRecruitPoolUnitEntry::OnGetRecruitPoolUnitEntry(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x005E61A6; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x005E5D46; + } +} + +OnGetRecruitPoolUnitEntry::~OnGetRecruitPoolUnitEntry() +{ +} + +void OnGetRecruitPoolUnitEntry::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} +void OnGetRecruitPoolUnitEntry::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + + a->pushf(); + + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + a->lea(esi, dword_ptr(eax)); + + a->popf(); + + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + + + +loadRecruitQueue::loadRecruitQueue(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x005D82F5; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x005D7E65; + } +} + +loadRecruitQueue::~loadRecruitQueue() +{ +} + +void loadRecruitQueue::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} +void loadRecruitQueue::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + a->push(esi); + + a->pushf(); + + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + + a->pop(esi); + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + + +loadRecruitQueue2::loadRecruitQueue2(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x005D835D; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x005D7ECD; + } +} + +loadRecruitQueue2::~loadRecruitQueue2() +{ +} + +void loadRecruitQueue2::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} +void loadRecruitQueue2::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + a->push(esi); + + a->pushf(); + + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + + a->pop(esi); + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +OnGetRecruitPoolUnitEntry2::OnGetRecruitPoolUnitEntry2(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x00AB92A8; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x00AB8278; + } +} + +OnGetRecruitPoolUnitEntry2::~OnGetRecruitPoolUnitEntry2() +{ +} + +void OnGetRecruitPoolUnitEntry2::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} +void OnGetRecruitPoolUnitEntry2::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + + a->pushf(); + + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +OnFindUnitStrings::OnFindUnitStrings(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x005F6412; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x005F6022; + } +} + +OnFindUnitStrings::~OnFindUnitStrings() +{ +} + + +void OnFindUnitStrings::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnFindUnitStrings::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->push(esi); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + + a->pushf(); + + a->mov(edx, ecx); + a->mov(ecx, eax); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + a->mov(edx, dword_ptr(eax, 0x30)); + + a->popf(); + + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(esi); + + + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +OnFindUnitStrings2::OnFindUnitStrings2(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + { + m_adress = 0x005F6419; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x005F6029; + } +} + +OnFindUnitStrings2::~OnFindUnitStrings2() +{ +} + + +void OnFindUnitStrings2::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnFindUnitStrings2::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + OnCreateUnitWrapper::OnCreateUnitWrapper(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { @@ -3605,15 +4065,14 @@ void OnPathCasheCrashPlace::SetNewCode() delete a; } -//this function allows recruiting eop unit in rq but it is not really functional, as it doesnt work with saving, will not be bound to lua, leaving it here for future maybe recruitEOPunit::recruitEOPunit(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x005EEEA0; + m_adress = 0x008ECFFE; else if (ver == 1)//kingdoms - m_adress = 0x005EEAC1; + m_adress = 0x008EC57E; } recruitEOPunit::~recruitEOPunit() @@ -3637,8 +4096,91 @@ void recruitEOPunit::SetNewCode() { Assembler* a = new Assembler(); + + a->push(edx); + a->push(ebx); + a->push(ebp); + a->push(edi); + + a->pushf(); + + a->push(ecx); + a->mov(ecx, ebp); a->mov(eax, (DWORD)funcAddress); a->call(eax); + a->lea(esi, dword_ptr(eax)); + a->pop(ecx); + a->mov(dword_ptr(esp, 0x20), ecx); + + a->popf(); + + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(edx); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + + +recruitEOPunit2::recruitEOPunit2(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + m_adress = 0x008ECFF2; + + else if (ver == 1)//kingdoms + m_adress = 0x008EC572; +} + +recruitEOPunit2::~recruitEOPunit2() +{ +} + +void recruitEOPunit2::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->call(m_adress); + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void recruitEOPunit2::SetNewCode() +{ + Assembler* a = new Assembler(); + + + a->push(esi); + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + a->push(eax); + + a->pushf(); + + a->mov(ecx, ebp); + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + + a->pop(eax); + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + a->pop(esi); a->ret(); m_cheatBytes = (unsigned char*)a->make(); diff --git a/M2TWEOP Code/M2TWEOP library/Injects.h b/M2TWEOP Code/M2TWEOP library/Injects.h index 97cd48bd8..4f83691ff 100644 --- a/M2TWEOP Code/M2TWEOP library/Injects.h +++ b/M2TWEOP Code/M2TWEOP library/Injects.h @@ -514,7 +514,6 @@ class toBattleLoaded -//select worldpkgdesc from db class toReadGameDBsAtGameStart :public AATemplate { @@ -530,6 +529,8 @@ class toReadGameDBsAtGameStart + + //draw parts of stratmodels class toDrawPartsOfStratObjects :public AATemplate @@ -670,6 +671,18 @@ class mercenaryMovepointsGetGeneral }; +class onGameInitialized + :public AATemplate +{ +public: + onGameInitialized(MemWork* mem, LPVOID adr, int ver); + ~onGameInitialized(); + + void SetOriginalCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; class onGameConsoleCommandFromConsole :public AATemplate @@ -792,6 +805,19 @@ class OnCreateUnit LPVOID funcAddress; }; +class OnFindUnit + :public AATemplate +{ +public: + OnFindUnit(MemWork* mem, LPVOID addr, int ver); + ~OnFindUnit(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + class OnCreateMercUnit :public AATemplate { @@ -819,6 +845,58 @@ class OnCreateUnitWrapper LPVOID funcAddress; }; +class OnGetRecruitPoolUnitEntry + :public AATemplate +{ +public: + OnGetRecruitPoolUnitEntry(MemWork* mem, LPVOID addr, int ver); + ~OnGetRecruitPoolUnitEntry(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + +class OnGetRecruitPoolUnitEntry2 + :public AATemplate +{ +public: + OnGetRecruitPoolUnitEntry2(MemWork* mem, LPVOID addr, int ver); + ~OnGetRecruitPoolUnitEntry2(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + +class OnFindUnitStrings + :public AATemplate +{ +public: + OnFindUnitStrings(MemWork* mem, LPVOID addr, int ver); + ~OnFindUnitStrings(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + +class OnFindUnitStrings2 + :public AATemplate +{ +public: + OnFindUnitStrings2(MemWork* mem, LPVOID addr, int ver); + ~OnFindUnitStrings2(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + class OnCreateMercUnitCheck :public AATemplate { @@ -969,6 +1047,48 @@ class recruitEOPunit LPVOID funcAddress; }; +//create eop unit +class recruitEOPunit2 + :public AATemplate +{ +public: + recruitEOPunit2(MemWork* mem, LPVOID addr, int ver); + ~recruitEOPunit2(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + +//create eop unit +class loadRecruitQueue + :public AATemplate +{ +public: + loadRecruitQueue(MemWork* mem, LPVOID addr, int ver); + ~loadRecruitQueue(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + +//create eop unit +class loadRecruitQueue2 + :public AATemplate +{ +public: + loadRecruitQueue2(MemWork* mem, LPVOID addr, int ver); + ~loadRecruitQueue2(); + + void SetOriginialCode(); + void SetNewCode(); +private: + LPVOID funcAddress; +}; + //create eop unit class recruitEOPMercunit :public AATemplate diff --git a/M2TWEOP Code/M2TWEOP library/eopBuildings.cpp b/M2TWEOP Code/M2TWEOP library/eopBuildings.cpp index 42e32f987..29293dfd5 100644 --- a/M2TWEOP Code/M2TWEOP library/eopBuildings.cpp +++ b/M2TWEOP Code/M2TWEOP library/eopBuildings.cpp @@ -2,6 +2,7 @@ #include "fastFunctsHelpers.h" #include "fastFuncts.h" +#include "smallFuncs.h" #include namespace eopBuildings @@ -170,7 +171,7 @@ namespace eopBuildings { DWORD funcPointer = (DWORD)0x008A955B; //I dont think this does anything but not 100% sure, havent checked disk version as I do not think this is needed DWORD EDBpointer = dataOffsets::offsets.edbDataStart; //for some reason this is included, not sure if needed - BuildingLvlCapability* cap = new BuildingLvlCapability; //allocating memory + BuildingLvlCapability* cap = reinterpret_cast(fastFuncts::allocateGameMem(0x20)); buildingLevel* eoplevel = &entry->buildingLevel[level]; cap->capabilityType = 0; //always 0 for normal capabilities if (bonus) @@ -197,9 +198,9 @@ namespace eopBuildings } - NOINLINE EOP_EXPORT void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp) + NOINLINE EOP_EXPORT void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp, const char* condition) { - recruitPool* pool = new recruitPool; + recruitPool* pool = reinterpret_cast(fastFuncts::allocateGameMem(0x20)); buildingLevel* eoplevel = &entry->buildingLevel[level]; pool->capabilityType = 5; //5 means normal unit, there are some other for agents I havent added yet pool->capabilityLvlorExp = exp; //for units this always is xp, for agents this can be agent @@ -209,6 +210,18 @@ namespace eopBuildings pool->maxSize = maxSize; pool->buildingLevelCondition = nullptr; pool->nextPool = nullptr; + auto fakeText = std::make_shared(fakeTextInput(condition, 0)); + auto rawText = fakeText.get(); + const auto makeConditionFunc = reinterpret_cast(0x008A7510); + auto conditionPtr = &pool->buildingLevelCondition; + _asm + { + push 3 + push conditionPtr + push fakeText + mov eax, makeConditionFunc + call eax + } if (eoplevel->recruitPools != nullptr) { pool->nextPool = eoplevel->recruitPools; //always insert at start of pools diff --git a/M2TWEOP Code/M2TWEOP library/eopBuildings.h b/M2TWEOP Code/M2TWEOP library/eopBuildings.h index 22c1775b8..dd5d7f5f5 100644 --- a/M2TWEOP Code/M2TWEOP library/eopBuildings.h +++ b/M2TWEOP Code/M2TWEOP library/eopBuildings.h @@ -28,7 +28,7 @@ namespace eopBuildings NOINLINE EOP_EXPORT void setBuildingLocalizedDescr(edbEntry* entry, const char* newName, int level, int facnum); NOINLINE EOP_EXPORT void setBuildingLocalizedDescrShort(edbEntry* entry, const char* newName, int level, int facnum); NOINLINE EOP_EXPORT void addBuildingCapability(edbEntry* entry, int level, int capability, int16_t value, bool bonus); - NOINLINE EOP_EXPORT void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp); + NOINLINE EOP_EXPORT void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp, const char* condition); NOINLINE EOP_EXPORT void removeBuildingCapability(edbEntry* entry, int level, int index); NOINLINE EOP_EXPORT void removeBuildingPool(edbEntry* entry, int level, int index); NOINLINE EOP_EXPORT BuildingLvlCapability* getBuildingCapability(edbEntry* entry, int level, int index); diff --git a/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp b/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp index 59fbbe19b..ba98ab730 100644 --- a/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp +++ b/M2TWEOP Code/M2TWEOP library/functionsOffsets.cpp @@ -52,6 +52,7 @@ void codes::initCodes(int gameVer) offsets.createUnitFunc = 0x008edf60; offsets.addUnitToArmyFunc = 0x00719380; offsets.setBodyguard = 0x00598f10; + offsets.makeConditionFunc = 0x00874920; offsets.killCharStratMapFunc = 0x00592900; offsets.killUnitStratMapFunc = 0x007417e0; @@ -131,6 +132,7 @@ void codes::initCodes(int gameVer) offsets.createUnitFunc = 0x008ee9e0; offsets.addUnitToArmyFunc = 0x00719ab0; offsets.setBodyguard = 0x00599400; + offsets.makeConditionFunc = 0x00875310; offsets.killCharStratMapFunc = 0x00592e00; diff --git a/M2TWEOP Code/M2TWEOP library/functionsOffsets.h b/M2TWEOP Code/M2TWEOP library/functionsOffsets.h index 65dd1ecb9..fd960e98a 100644 --- a/M2TWEOP Code/M2TWEOP library/functionsOffsets.h +++ b/M2TWEOP Code/M2TWEOP library/functionsOffsets.h @@ -96,6 +96,7 @@ class codes DWORD deleteFortFuncTwo = NULL; DWORD createFortFunc = NULL; DWORD mercEOPValue = NULL; + DWORD makeConditionFunc = NULL; }offsets; static void initCodes(int gameVer); diff --git a/M2TWEOP Code/M2TWEOP library/managerF.cpp b/M2TWEOP Code/M2TWEOP library/managerF.cpp index 1f2f54dc4..7c4cab619 100644 --- a/M2TWEOP Code/M2TWEOP library/managerF.cpp +++ b/M2TWEOP Code/M2TWEOP library/managerF.cpp @@ -117,6 +117,12 @@ void managerF::doPachs() toRecruitEOPunit->Enable(); f1 << "Done" << endl; + f1 << "Start applying recruit eop unit patch" << endl; + recruitEOPunit2* toRecruitEOPunit2 = new recruitEOPunit2(mem, (LPVOID)patchesForGame::recruitEOPunit2, globals::dataS.gamever); + toRecruitEOPunit2->SetNewCode(); + toRecruitEOPunit2->Enable(); + f1 << "Done" << endl; + f1 << "Start applying recruit merc eop unit patch" << endl; recruitEOPMercunit* torecruitEOPMercunit = new recruitEOPMercunit(mem, (LPVOID)patchesForGame::recruitEOPMercunit, globals::dataS.gamever); torecruitEOPMercunit->SetNewCode(); @@ -146,6 +152,7 @@ void managerF::doPachs() ed->Enable(); f1 << "Done" << endl; + f1 << "Start applying OnChangePassedTurnsCount patch" << endl; toChangePassedTurnsCount* tcptc = new toChangePassedTurnsCount(mem, (LPVOID)patchesForGame::onChangeTurnNum, globals::dataS.gamever); @@ -348,7 +355,7 @@ void managerF::doPachs() //f1 << "Start applying toReadGameDBsAtGameStart patch" << endl; //toReadGameDBsAtGameStart* toReadGameDbsAtStart = new toReadGameDBsAtGameStart(mem, (LPVOID)patchesForGame::toReadGameDbsAtStart, globals::dataS.gamever); //toReadGameDbsAtStart->SetlReadCode(); - //toReadGameDbsAtStart->Enable(); + //totoReadGameDBsAtGameStartDbsAtStart->Enable(); //f1 << "Done" << endl; @@ -396,6 +403,11 @@ void managerF::doPachs() cityConversionLvlSetter->Enable(); f1 << "Done" << endl; + f1 << "Start applying toGameInitialize patch" << endl; + onGameInitialized* toGameInitialize = new onGameInitialized(mem, (LPVOID)patchesForGame::onGameInit, globals::dataS.gamever); + toGameInitialize->SetNewCode(); + toGameInitialize->Enable(); + f1 << "Done" << endl; f1 << "Start applying mercenaryMovepointsGetGeneral patch" << endl; @@ -464,6 +476,11 @@ void managerF::doPachs() onCreateUnit->Enable(); f1 << "Done" << endl; + f1 << "Start applying toFindUnit patch" << endl; + OnFindUnit*toFindUnit = new OnFindUnit(mem, (LPVOID)patchesForGame::onFindUnit, globals::dataS.gamever); + toFindUnit->SetNewCode(); + toFindUnit->Enable(); + f1 << "Done" << endl; f1 << "Start applying toCreateMercUnit patch" << endl; OnCreateMercUnit* toCreateMercUnit = new OnCreateMercUnit(mem, (LPVOID)patchesForGame::OnCreateMercUnit, globals::dataS.gamever); @@ -477,6 +494,41 @@ void managerF::doPachs() toCreateUnitWrapper->Enable(); f1 << "Done" << endl; + f1 << "Start applying OnFindUnitStrings patch" << endl; + OnFindUnitStrings* toFindUnitStrings = new OnFindUnitStrings(mem, (LPVOID)patchesForGame::OnCreateUnitWrapper, globals::dataS.gamever); //its same func as unit wrapper on purpose not error + toFindUnitStrings->SetNewCode(); + toFindUnitStrings->Enable(); + f1 << "Done" << endl; + + f1 << "Start applying OnFindUnitStrings patch" << endl; + OnFindUnitStrings2* toFindUnitStrings2 = new OnFindUnitStrings2(mem, (LPVOID)patchesForGame::OnCreateUnitWrapper, globals::dataS.gamever); //its same func as unit wrapper on purpose not error + toFindUnitStrings2->SetNewCode(); + toFindUnitStrings2->Enable(); + f1 << "Done" << endl; + + f1 << "Start applying OnGetRecruitPoolUnitEntry patch" << endl; + OnGetRecruitPoolUnitEntry* toGetRecruitPoolUnitEntry = new OnGetRecruitPoolUnitEntry(mem, (LPVOID)patchesForGame::OnGetRecruitPoolUnitEntry, globals::dataS.gamever); + toGetRecruitPoolUnitEntry->SetNewCode(); + toGetRecruitPoolUnitEntry->Enable(); + f1 << "Done" << endl; + + f1 << "Start applying toLoadRecruitQueue patch" << endl; + loadRecruitQueue* toLoadRecruitQueue = new loadRecruitQueue(mem, (LPVOID)patchesForGame::OnGetRecruitPoolUnitEntry, globals::dataS.gamever); + toLoadRecruitQueue->SetNewCode(); + toLoadRecruitQueue->Enable(); + f1 << "Done" << endl; + + f1 << "Start applying toLoadRecruitQueue2 patch" << endl; + loadRecruitQueue2* toLoadRecruitQueue2 = new loadRecruitQueue2(mem, (LPVOID)patchesForGame::OnGetRecruitPoolUnitEntry, globals::dataS.gamever); + toLoadRecruitQueue2->SetNewCode(); + toLoadRecruitQueue2->Enable(); + f1 << "Done" << endl; + + f1 << "Start applying OnGetRecruitPoolUnitEntry2 patch" << endl; + OnGetRecruitPoolUnitEntry2* toGetRecruitPoolUnitEntry2 = new OnGetRecruitPoolUnitEntry2(mem, (LPVOID)patchesForGame::OnGetRecruitPoolUnitEntry, globals::dataS.gamever); + toGetRecruitPoolUnitEntry2->SetNewCode(); + toGetRecruitPoolUnitEntry2->Enable(); + f1 << "Done" << endl; f1 << "Start applying toCreateMercUnitCheck patch" << endl; OnCreateMercUnitCheck* toCreateMercUnitCheck = new OnCreateMercUnitCheck(mem, (LPVOID)patchesForGame::OnCreateMercUnitCheck, globals::dataS.gamever); diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp index fd64f5859..7445900c7 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp @@ -93,23 +93,40 @@ char* __fastcall patchesForGame::onSaveEDUStringS(eduEntry* eduEntry) return retName; } -int __fastcall patchesForGame::onCreateUnit(int* edbIndex, int** edb, char** entryName) +int __fastcall patchesForGame::onCreateUnit(char** entryName, int* edbIndex) { if (edbIndex == nullptr) { - int* newEdu = eduThings::tryFindDataEopEdu(*entryName); + int* newEdu = eduThings::tryFindDataEopEduIndex(*entryName); if (newEdu == nullptr) { return -1; } - *edb = newEdu; - return 0; + return *newEdu; + } + + return *edbIndex; +} + +int __fastcall patchesForGame::onFindUnit(char* entryName, int* edbIndex) +{ + if (edbIndex == nullptr) + { + int* newEdu = eduThings::tryFindDataEopEduIndex(entryName); + + if (newEdu == nullptr) + { + return -1; + } + + return *newEdu; } return *edbIndex; } + int __fastcall patchesForGame::OnCreateMercUnitCheck(char** entryName, int eduindex) { if (eduindex == -1) @@ -150,6 +167,17 @@ eduEntry* __fastcall patchesForGame::OnCreateUnitWrapper(int eduindexBase, int r } return entry; } + +eduEntry* __fastcall patchesForGame::OnGetRecruitPoolUnitEntry(int eduIndex) +{ + eduEntry* entry = eduThings::getEduEntry(eduIndex); + if (entry == nullptr) + { + entry = eduThings::getEopEduEntry(eduIndex); + } + return entry; +} + const char* __fastcall patchesForGame::onQuickSave() { static std::vector saveNames = { u8"%S-1.sav" ,u8"%S-2.sav", u8"%S-3.sav" }; @@ -317,6 +345,11 @@ void __stdcall patchesForGame::afterEDUread() #endif } +void __stdcall patchesForGame::onGameInit() +{ + plugins::onGameInit(); +} + void __stdcall patchesForGame::onChangeTurnNum() { #if defined TESTPATCHES @@ -560,17 +593,26 @@ void __fastcall patchesForGame::OnStopCharacter(general* character) } } -void __fastcall patchesForGame::recruitEOPunit(DWORD eduoffset, DWORD pad, regionStruct* region, int eduindex, int factionid, int exp, int minusone, int armlvl, int wplvl) +eduEntry* __fastcall patchesForGame::recruitEOPunit(int eduIndex) { - int regionID = region->regionID; - if (eduindex > 499) + eduEntry* entry = eduThings::getEduEntry(eduIndex); + if (entry == nullptr) { - int eopIDX = eduThings::getDataEopEdu(eduindex); - fastFuncts::createUnitEDB(eopIDX, regionID, factionid, exp, armlvl, wplvl); + entry = eduThings::getEopEduEntry(eduIndex); } - else + return entry; +} + +void __fastcall patchesForGame::recruitEOPunit2(int eduIndex) +{ + eduEntry* entry = eduThings::getEduEntry(eduIndex); + if (entry == nullptr) + { + entry = eduThings::getEopEduEntry(eduIndex); + } + if (entry) { - fastFuncts::createUnitIdx(eduindex, regionID, factionid, exp, armlvl, wplvl); + entry->UnitCreatedCounter++; } } diff --git a/M2TWEOP Code/M2TWEOP library/patchesForGame.h b/M2TWEOP Code/M2TWEOP library/patchesForGame.h index 9d454ecb7..638a997f0 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.h +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.h @@ -12,12 +12,14 @@ class patchesForGame static void __fastcall OnLoadSettlementWorldpkgdesc(worldRecord* selectedRecord); static int __fastcall onfortificationlevelS(settlementStruct* settlement, bool* isCastle); static char* __fastcall onSaveEDUStringS(eduEntry* eduEntry); - static int __fastcall onCreateUnit(int* edbIndex, int** edb, char** entryName); + static int __fastcall onCreateUnit(char** entryName, int* edbIndex); static int __fastcall OnCreateMercUnitCheck(char** entryName, int eduindex); static eduEntry* __fastcall OnCreateMercUnit(char** entryName, eduEntry* entry); static eduEntry* __fastcall OnCreateUnitWrapper(int eduindexBase, int removeValue); static const char* __fastcall onQuickSave(); static const char* __fastcall onAutoSave(); + static eduEntry* __fastcall OnGetRecruitPoolUnitEntry(int eduIndex); + static int __fastcall onFindUnit(char* entryName, int* edbIndex); static general* __fastcall mercenaryMovepointsGetGeneral(stackStruct* army); @@ -32,6 +34,7 @@ class patchesForGame static void WINAPI onNewGameStart(); //after reading EDU static void WINAPI afterEDUread(); + static void WINAPI onGameInit(); //before start of a first faction turn @@ -99,7 +102,8 @@ class patchesForGame static void __fastcall OnStopCharacter(general* character); static void WINAPI OnMoveRecruitQueue(); - static void __fastcall recruitEOPunit(DWORD eduoffset, DWORD pad, regionStruct* region, int eduindex, int factionid, int exp, int minusone, int armlvl, int wplvl); + static eduEntry* __fastcall recruitEOPunit(int eduIndex); + static void __fastcall recruitEOPunit2(int eduIndex); static void __fastcall recruitEOPMercunit(DWORD pad, DWORD pad2, regionStruct* region, int eduindex, int factionid, int exp); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.cpp b/M2TWEOP Code/M2TWEOP library/plugins.cpp index c0f83969e..465a8b640 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -227,6 +227,14 @@ void plugins::onReadGameDbsAtStart() } } +void plugins::onGameInit() +{ + for (plugin* pl : pluginsCfg.plugins) + { + (*(*pl->onGameInit))(); + } +} + void plugins::onWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { for (plugin* pl : pluginsCfg.plugins) @@ -374,6 +382,10 @@ int plugin::init(string* nameP) onfortificationlevelS.Load(&plPath, &fName); + //onReadGameDbsAtStart + fName = "onGameInit"; + onGameInit.Load(&plPath, &fName); + //onReadGameDbsAtStart fName = "onReadGameDbsAtStart"; onReadGameDbsAtStart.Load(&plPath, &fName); diff --git a/M2TWEOP Code/M2TWEOP library/plugins.h b/M2TWEOP Code/M2TWEOP library/plugins.h index 8b780fa9a..a52283d3d 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.h +++ b/M2TWEOP Code/M2TWEOP library/plugins.h @@ -97,6 +97,7 @@ class plugin ProcLoader onWndProc; ProcLoader onReadGameDbsAtStart; + ProcLoader onGameInit; ProcLoader onEndSiege; ProcLoader onStartSiege; @@ -136,6 +137,7 @@ class plugins static void onSaveGame(UNICODE_STRING**& savePath); static void onReadGameDbsAtStart(); + static void onGameInit(); static void onWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static void onEndScene(LPDIRECT3DDEVICE9 pDevice); @@ -148,7 +150,5 @@ class plugins static vector getAllPlPachs(string* s); - static void initEvNames(); - }; diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index 774c3dd6d..e4ac04093 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -40,6 +40,59 @@ struct generalStats struct soldierInBattle* generalBgMount; //0x0004 }; //Size: 0x0008 +struct legioString +{ +public: + char* name; //0x0000 + int32_t nameHash; //0x0004 + struct UNICODE_STRING** localizedLegoName; //0x0008 + int32_t recruitCount; //0x000C + char pad_0010[4]; //0x0010 +}; //Size: 0x0014 + +struct cultureModels +{ +public: + char pad_0000[5584]; //0x0000 +}; //Size: 0x15D0 + +struct cultureAgent +{ +public: + char* cardName; //0x0000 + int32_t cardNameHash; //0x0004 + char* infoCardName; //0x0008 + int32_t infoCardNameHash; //0x000C + char* cardName2; //0x0010 + int32_t cardName2Hash; //0x0014 + int16_t index1; //0x0018 + char pad_001A[2]; //0x001A + int16_t index2; //0x001C + char pad_001E[2]; //0x001E + int16_t cost; //0x0020 + int16_t time; //0x0022 + int16_t popCost; //0x0024 + int16_t someOtherRomeShit; //0x0026 + char pad_0028[4]; //0x0028 +}; //Size: 0x002C + + + +struct culture +{ +public: + int32_t cultureID; //0x0000 + char* cultureName; //0x0004 + int32_t cultureNameHash; //0x0008 + char pad_000C[1072]; //0x000C + int32_t fortCost; //0x043C + int32_t watchTowerCost; //0x0440 + char pad_0444[24]; //0x0444 + struct cultureModels cultureModelCrap; //0x045C + struct cultureAgent cultureAgents[6]; //0x1A2C + char pad_1B34[4]; //0x1B34 +}; //Size: 0x1B38 + struct coordPair { public: @@ -56,7 +109,33 @@ struct movePath }; //Size: 0x000C -class religionDatabase +struct eventTrigger +{ + void* eventTrigger_vtbl; //0x0000 + char pad_0004[28]; //0x0004 +}; + +struct buildingBattle +{ +public: + char pad_0000[24]; //0x0000 + int32_t type; //0x0018 + char pad_001C[8]; //0x001C + float posX; //0x0024 + float posZ; //0x0028 + float posY; //0x002C + char pad_0030[4]; //0x0030 + int32_t endHealth; //0x0034 + int32_t currentHealth; //0x0038 + int32_t startHealth; //0x003C + char pad_0040[4]; //0x0040 + int32_t isDefenderControlled; //0x0044 + char pad_0048[8]; //0x0048 +}; //Size: 0x0050 + + + +struct religionDatabase { public: void* religionDatabase_vtbl;//0x0000 @@ -307,6 +386,16 @@ struct mercPool struct mercPoolUnitsPtr firstUnits; //0x001C }; //Size: 0x0180 +struct mercPoolList +{ +public: + struct mercPool* mercPools; //0x0000 + struct mercPoolList* nextMercPools; //0x0004 + struct mercPoolList* previousMercPools; //0x0008 + int32_t currentSize; //0x000C + int32_t currentCount; //0x0010 +}; //Size: 0x0014 + struct uiElement { undefined field_0x0[16]; int xSize; @@ -491,11 +580,25 @@ struct watchTowerModel { //watchtower struct watchTowerStruct { - undefined field_0x0[12]; + void* watchTowerVtable; //0x0000 + char pad_0004[4]; //0x0004 + struct character* character; //0x0008 int xCoord; int yCoord; - undefined field_0x14[16]; + char pad_0014[4]; //0x0014 + int8_t N000021C7; //0x0018 + char pad_0019[3]; //0x0019 + float N000021C8; //0x001C + int8_t N000021C9; //0x0020 + char pad_0021[3]; //0x0021 struct watchTowerModel* model; + int32_t regionID; //0x0028 + struct factionStruct* faction; //0x002C + struct settlementStruct* settlement; //0x0030 + void* trackedPointerArmyVtable; //0x0034 + struct stackStruct* blockingArmy; //0x0038 + int32_t factionID; //0x003C + char pad_0040[8]; //0x0040 }; struct worldRecord { @@ -597,7 +700,11 @@ struct collegeOfCardinals struct campaign { undefined field0_0x0[4]; - undefined field1_0x4[52]; + undefined field1_0x4[36]; + int32_t type; //0x0024 + char pad_0028[4]; //0x0028 + uint32_t playableFactionsBitmap; //0x002C + char pad_0030[4]; //0x0030 int playerFactionId; undefined field3_0x3c[4]; int hotSeatPlayer2FactionId; @@ -609,7 +716,8 @@ struct campaign { struct factionStruct* factionsSortedByDescrStrat[31]; struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; - char pad_0328[20]; //0x0328 + uint32_t existingFactionsBitMap; //0x0324 + char pad_032A[16]; //0x032A struct collegeOfCardinals* collegeOfCardinals; //0x033C struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; @@ -627,14 +735,33 @@ struct campaign { struct settlementStruct* rome; undefined field29_0x38c[4]; struct settlementStruct* constantinople; - undefined field31_0x394[60]; - int8_t field32_0x3d0; - int8_t field33_0x3d1; - undefined field34_0x3d2[26]; + char pad_0390[12]; //0x0390 + void* unkArray1; //0x039C + int32_t unkArray1Size; //0x03A0 + int32_t unkArray1Count; //0x03A4 + void* unkArray2; //0x03A8 + int32_t unkArray2Size; //0x03AC + int32_t unkArray2Count; //0x03B0 + void* script; //0x03B4 + void* scriptEnd; //0x03B8 + char pad_03BC[8]; //0x03BC + void* pointerToScript; //0x03C4 + void* pointerToScriptEnd; //0x03C8 + int8_t N00001208; //0x03CC + int8_t forceAllowManageAllSetts; //0x03CD + char pad_03CE[18]; //0x03CE + int8_t marianReformsActive; //0x03E0 + int8_t marianReformsDisabled; //0x03E1 + int8_t rebellingCharactersActive; //0x03E2 + int8_t gladiatorUprisingDisabled; //0x03E3 + int8_t nightBattlesEnabled; //0x03E4 + int8_t N00038FC9; //0x03E5 + int8_t N00038FCC; //0x03E6 + char pad_03E7[1]; //0x03E7 float BrigandSpawnValue; float PirateSpawnValue; int8_t N00001211; //0x03F4 - int8_t smthingDateTurnDisplay; //0x03F5 + int8_t showDateAsTurns; //0x03F5 int8_t restrictAutoResolve; //0x03F6 char pad_03F7[1]; //0x03F7 int FreeUpkeepForts; @@ -677,6 +804,10 @@ struct campaign { struct watchTowerStruct** watchtowers; int32_t watchtowersSize; //0x21628 int32_t watchtowersNum; //0x2162C + char pad[16]; //0x21638 + struct mercPoolList allMercPools; //0x2163C + void* unk3; //0x21650 + void* unk4; //0x21654 }; struct uiUnitCard @@ -739,7 +870,10 @@ struct battleUnit int32_t expStart; //0x0034 int32_t expGained; //0x0038 int8_t isGeneral; //0x003C - char pad_003D[11]; //0x003D + int8_t hasWithdrawn; //0x003D + uint16_t N000400D6; //0x003E + int32_t N0001FD2C; //0x0040 + int32_t N0001FDB3; //0x0044 }; //Size: 0x0048 struct options1 @@ -2007,14 +2141,10 @@ struct anchillary { /* structure of ancillary */ undefined field_0x12; undefined field_0x13; char* patchToAnchImage; - undefined field_0x18; - undefined field_0x19; - undefined field_0x1a; - undefined field_0x1b; - undefined field_0x1c; - undefined field_0x1d; - undefined field_0x1e; - undefined field_0x1f; + char pad_0018[4]; //0x0018 + int8_t isUnique; //0x001C + char pad_001D[23]; //0x001D + uint32_t excludedCultures; //0x0034 }; struct trait { /* traits of the character */ @@ -2931,22 +3061,42 @@ struct soldierData { /* one soldier in unit */ //fort struct fortStruct { public: - undefined field_0x0[4]; + void* fortVtable; struct general* gubernator; undefined field_0x8[4]; UINT32 xCoord; UINT32 yCoord; undefined field_0x14[48]; struct stackStruct* army; - undefined field_0x48[4]; - struct siegeS* siege; - undefined field_0x50[144]; + struct oneSiege sieges[8]; + int8_t siegeNum; //0x0088 + char pad_0089[3]; //0x0089 + int32_t N000106CC; //0x008C + int32_t N000106CD; //0x0090 + int32_t N000106CE; //0x0094 + int32_t N000106CF; //0x0098 + int32_t N000106D0; //0x009C + int32_t N000106D1; //0x00A0 + int8_t N000106D2; //0x00A4 + int8_t setZeroAfterInvaded; //0x00A5 + int8_t N000393C1; //0x00A6 + int8_t N000393BF; //0x00A7 + int32_t N000106D3; //0x00A8 + struct descrRebelEntry* descrRebel; //0x00AC + int32_t subFactionID; //0x00B0 + void* spyingInfoBase; //0x00B4 + int8_t spyingInfoFactions[31]; //0x00B8 + char pad_00D7[9]; //0x00D7 struct stratFortMod* stratModel; int regionID; struct factionStruct* faction; - undefined field_0xec[12]; + int32_t factionID; //0x00EC + int32_t cultureID; //0x00F0 + void* localString; //0x00F4 char* fortType; - undefined field_0xfc[28]; + char pad_00FC[4]; //0x00FC + int32_t fortFortificationLevel; //0x0100 + char pad_0104[20]; //0x0104 }; struct traidingResource { diff --git a/M2TWEOP Code/M2TWEOP library/smallFuncs.cpp b/M2TWEOP Code/M2TWEOP library/smallFuncs.cpp index 9c9c06f2b..b9dd129fe 100644 --- a/M2TWEOP Code/M2TWEOP library/smallFuncs.cpp +++ b/M2TWEOP Code/M2TWEOP library/smallFuncs.cpp @@ -393,20 +393,31 @@ namespace smallFuncs return result; } - struct fakeTextInput - { - public: - char* textBuffer; //0x0000 - uint32_t byteSize; //0x0004 - char* endString; //0x0008 - struct UNICODE_STRING** unicodePointerPointer; //0x000C - char* currRead; //0x0010 - char* currLine; //0x0014 - uint32_t lineNumber; //0x0018 - int32_t N1814981889; //0x001C - int32_t N0; //0x0020 - DWORD classPointer; //0x0024 - }; //Size: 0x0028 + + + NOINLINE EOP_EXPORT bool condition(const char* condition, const eventTrigger* eventData) + { + + auto fakeText = std::make_shared(fakeTextInput(condition, 0)); + auto rawText = fakeText.get(); + const auto makeConditionFunc = reinterpret_cast(0x00875310); + void* result = nullptr; + + _asm + { + push rawText + mov ecx, rawText + mov eax, makeConditionFunc + call eax + mov result, eax + add esp, 0x4 + } + + if (result == nullptr) + return false; + + return CallVFunc<1, bool>(result, eventData); + } NOINLINE EOP_EXPORT void scriptCommand(const char* command, const char* args) { @@ -415,24 +426,9 @@ namespace smallFuncs { return; } - char* fullCommand = new char[strlen(command) + strlen(args) + 2]; - strcpy(fullCommand, command); - strcat(fullCommand, " "); - strcat(fullCommand, args); - fakeTextInput* fakeText = new fakeTextInput; - std::string scriptPath = "data/world/maps/campaign/imperial_campaign/campaign_script.txt"; - fakeText->unicodePointerPointer = new UNICODE_STRING*; - smallFuncs::createUniString(fakeText->unicodePointerPointer, scriptPath.c_str()); - fakeText->textBuffer = fullCommand; - fakeText->byteSize = strlen(command) + (int8_t)0x4; - size_t len = strlen(fullCommand); - char* endAddress = fullCommand + len; - fakeText->endString = endAddress; - fakeText->currRead = fullCommand; - fakeText->currLine = fullCommand; - fakeText->lineNumber = 1; - fakeText->N1814981889 = 1814981889; - fakeText->N0 = 0; + std::string fullCommand = std::string(command) + " " + args; + size_t start = strlen(command) + static_cast(0x8); + fakeTextInput* fakeText = std::make_shared(fakeTextInput(fullCommand.c_str(), start)).get(); DWORD classPointer = 0x0; _asm { @@ -441,7 +437,7 @@ namespace smallFuncs mov classPointer, eax } fakeText->classPointer = classPointer; - DWORD funcAddr = scriptClass + (int8_t)0x4; + DWORD funcAddr = scriptClass + static_cast(0x4); DWORD scriptObject = 0x0; _asm { @@ -452,12 +448,8 @@ namespace smallFuncs mov scriptObject, eax add esp, 0x4 } - if (scriptObject == 0x0) - { return; - } - _asm { mov ecx, scriptObject @@ -765,4 +757,6 @@ namespace smallFuncs return (float)sqrt((double)(dx * dx) + (double)(dy * dy)); } + + }; diff --git a/M2TWEOP Code/M2TWEOP library/smallFuncs.h b/M2TWEOP Code/M2TWEOP library/smallFuncs.h index 8ec54a2af..ef5230ce8 100644 --- a/M2TWEOP Code/M2TWEOP library/smallFuncs.h +++ b/M2TWEOP Code/M2TWEOP library/smallFuncs.h @@ -28,6 +28,7 @@ namespace smallFuncs NOINLINE EOP_EXPORT void scriptCommand(const char* command, const char* args); NOINLINE EOP_EXPORT void changeRegionName(regionStruct* region, const char* newName); NOINLINE EOP_EXPORT void changeRebelsName(regionStruct* region, const char* newName); + NOINLINE EOP_EXPORT bool condition(const char* condition, const eventTrigger* eventData); NOINLINE EOP_EXPORT gameDataAllStruct* getGameDataAll(); @@ -53,3 +54,33 @@ namespace smallFuncs float GetDistanceInTiles(int x, int y, int destX, int destY); }; + +struct fakeTextInput +{ + explicit fakeTextInput(const char* condition, size_t start) + { + const std::string scriptPath = "luaCommand"; + unicodePointerPointer = new UNICODE_STRING*; + smallFuncs::createUniString(unicodePointerPointer, scriptPath.c_str()); + textBuffer = condition; + byteSize = start; + endString = condition + strlen(condition); + currRead = condition; + currLine = condition; + lineNumber = 1; + N1814981889 = 1814981889; + N0 = 0; + classPointer = 0; + } + const char* textBuffer; //0x0000 + uint32_t byteSize; //0x0004 + const char* endString; //0x0008 + UNICODE_STRING** unicodePointerPointer; //0x000C + const char* currRead; //0x0010 + const char* currLine; //0x0014 + uint32_t lineNumber; //0x0018 + int32_t N1814981889; //0x001C + int32_t N0; //0x0020 + DWORD classPointer; //0x0024 +}; //Size: 0x0028 + diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index a98011632..d1ff88be6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -12,666 +12,651 @@ void onEventWrapper(const DWORD eventAddr, DWORD** vTab, DWORD arg2) currentEvent->second->callEvent(vTab); } -void initReligionNames() -{ - const auto* religionDb = *reinterpret_cast (0x016A0B90); - if (m2tweopHelpers::getGameVersion() == 1) - { - religionDb = *reinterpret_cast (0x016E9DC0); - } - for (int i = 0; i < religionDb->religionCount; i++) - { - religionNames[i] = gameHelpers::getReligionName(i); - } -} - namespace gameEvents { void initEvents() { - initReligionNames(); const int gv = (m2tweopHelpers::getGameVersion()) - 1; - //namedCharacterEvents DWORD newCode[] = { 0x0136BFE4, 0x01326FBC }; - addEvent(newCode[gv], "onCharacterTurnStart"); + addEvent(newCode[gv], "onCharacterTurnStart"); newCode[0] = 0x013370DC; newCode[1] = 0x012F20BC; - addEvent(newCode[gv], "onCapturedCharacterRansomed"); + addEvent(newCode[gv], "onCapturedCharacterRansomed"); newCode[0] = 0x01337194; newCode[1] = 0x012F2174; - addEvent(newCode[gv], "onCapturedCharacterReleased"); + addEvent(newCode[gv], "onCapturedCharacterReleased"); newCode[0] = 0x0133DF5C; newCode[1] = 0x012F8F3C; - addEvent(newCode[gv], "onFatherDiesNatural"); + addEvent(newCode[gv], "onFatherDiesNatural"); newCode[0] = 0x01366D54; newCode[1] = 0x01321D2C; - addEvent(newCode[gv], "onPreBattleWithdrawal"); + addEvent(newCode[gv], "onPreBattleWithdrawal"); newCode[0] = 0x01367ADC; newCode[1] = 0x01322AB4; - addEvent(newCode[gv], "onPostBattle"); + addEvent(newCode[gv], "onPostBattle"); newCode[0] = 0x01369E3C; newCode[1] = 0x01324E14; - addEvent(newCode[gv], "onHireMercenaries"); + addEvent(newCode[gv], "onHireMercenaries"); newCode[0] = 0x01369F0C; newCode[1] = 0x01324EE4; - addEvent(newCode[gv], "onGeneralCaptureResidence"); + addEvent(newCode[gv], "onGeneralCaptureResidence"); newCode[0] = 0x0136A0B4; newCode[1] = 0x0132508C; - addEvent(newCode[gv], "onLeaderDestroyedFaction"); + addEvent(newCode[gv], "onLeaderDestroyedFaction"); newCode[0] = 0x0136A584; newCode[1] = 0x0132555C; - addEvent(newCode[gv], "onOfferedForAdoption"); + addEvent(newCode[gv], "onOfferedForAdoption"); newCode[0] = 0x0136A65C; newCode[1] = 0x01325634; - addEvent(newCode[gv], "onLesserGeneralOfferedForAdoption"); + addEvent(newCode[gv], "onLesserGeneralOfferedForAdoption"); newCode[0] = 0x0136A72C; newCode[1] = 0x01325704; - addEvent(newCode[gv], "onOfferedForMarriage"); + addEvent(newCode[gv], "onOfferedForMarriage"); newCode[0] = 0x0136A7F4; newCode[1] = 0x013257CC; - addEvent(newCode[gv], "onBrotherAdopted"); + addEvent(newCode[gv], "onBrotherAdopted"); newCode[0] = 0x0136A8C4; newCode[1] = 0x0132589C; - addEvent(newCode[gv], "onBecomesFactionLeader"); + addEvent(newCode[gv], "onBecomesFactionLeader"); newCode[0] = 0x0136A994; newCode[1] = 0x0132596C; - addEvent(newCode[gv], "onBecomesFactionHeir"); + addEvent(newCode[gv], "onBecomesFactionHeir"); newCode[0] = 0x0136AA64; newCode[1] = 0x01325A3C; - addEvent(newCode[gv], "onCeasedFactionLeader"); + addEvent(newCode[gv], "onCeasedFactionLeader"); newCode[0] = 0x0136AB34; newCode[1] = 0x01325B0C; - addEvent(newCode[gv], "onCeasedFactionHeir"); + addEvent(newCode[gv], "onCeasedFactionHeir"); newCode[0] = 0x0136B54C; newCode[1] = 0x01326524; - addEvent(newCode[gv], "onBirth"); + addEvent(newCode[gv], "onBirth"); newCode[0] = 0x0136B61C; newCode[1] = 0x013265F4; - addEvent(newCode[gv], "onCharacterComesOfAge"); + addEvent(newCode[gv], "onCharacterComesOfAge"); newCode[0] = 0x0136B6EC; newCode[1] = 0x013266C4; - addEvent(newCode[gv], "onCharacterMarries"); + addEvent(newCode[gv], "onCharacterMarries"); newCode[0] = 0x0136B7C4; newCode[1] = 0x0132679C; - addEvent(newCode[gv], "onCharacterMarriesPrincess"); + addEvent(newCode[gv], "onCharacterMarriesPrincess"); newCode[0] = 0x0136B89C; newCode[1] = 0x01326874; - addEvent(newCode[gv], "onMarriageAlliancePossible"); + addEvent(newCode[gv], "onMarriageAlliancePossible"); newCode[0] = 0x0136B96C; newCode[1] = 0x01326944; - addEvent(newCode[gv], "onMarriageAllianceOffered"); + addEvent(newCode[gv], "onMarriageAllianceOffered"); newCode[0] = 0x0136BA3C; newCode[1] = 0x01326A14; - addEvent(newCode[gv], "onPriestBecomesHeretic"); + addEvent(newCode[gv], "onPriestBecomesHeretic"); newCode[0] = 0x0136BB0C; newCode[1] = 0x01326AE4; - addEvent(newCode[gv], "onCharacterNearHeretic"); + addEvent(newCode[gv], "onCharacterNearHeretic"); newCode[0] = 0x0136BBDC; newCode[1] = 0x01326BB4; - addEvent(newCode[gv], "onCharacterNearWitch"); + addEvent(newCode[gv], "onCharacterNearWitch"); newCode[0] = 0x0136BCAC; newCode[1] = 0x01326C84; - addEvent(newCode[gv], "onCardinalPromoted"); + addEvent(newCode[gv], "onCardinalPromoted"); newCode[0] = 0x0136BF14; newCode[1] = 0x01326EEC; - addEvent(newCode[gv], "onCharacterBecomesAFather"); + addEvent(newCode[gv], "onCharacterBecomesAFather"); newCode[0] = 0x0136C25C; newCode[1] = 0x01327234; - addEvent(newCode[gv], "onGeneralDevastatesTile"); + addEvent(newCode[gv], "onGeneralDevastatesTile"); newCode[0] = 0x0136CD64; newCode[1] = 0x01327D3C; - addEvent(newCode[gv], "onExecutesASpyOnAMission"); + addEvent(newCode[gv], "onExecutesASpyOnAMission"); newCode[0] = 0x0136CFE4; newCode[1] = 0x01327FBC; - addEvent(newCode[gv], "onExecutesAnAssassinOnAMission"); + addEvent(newCode[gv], "onExecutesAnAssassinOnAMission"); newCode[0] = 0x0136D26C; newCode[1] = 0x01328244; - addEvent(newCode[gv], "onSufferAssassinationAttempt"); + addEvent(newCode[gv], "onSufferAssassinationAttempt"); newCode[0] = 0x0136D414; newCode[1] = 0x013283EC; - addEvent(newCode[gv], "onSufferAcquisitionAttempt"); + addEvent(newCode[gv], "onSufferAcquisitionAttempt"); newCode[0] = 0x0136D5AC; newCode[1] = 0x01328584; - addEvent(newCode[gv], "onSufferMarriageAttempt"); + addEvent(newCode[gv], "onSufferMarriageAttempt"); newCode[0] = 0x0136D754; newCode[1] = 0x0132872C; - addEvent(newCode[gv], "onSufferDenouncementAttempt"); + addEvent(newCode[gv], "onSufferDenouncementAttempt"); newCode[0] = 0x0136D8EC; newCode[1] = 0x013288C4; - addEvent(newCode[gv], "onLeaderOrderedSabotage"); + addEvent(newCode[gv], "onLeaderOrderedSabotage"); newCode[0] = 0x0136DA84; newCode[1] = 0x01328A5C; - addEvent(newCode[gv], "onLeaderOrderedBribery"); + addEvent(newCode[gv], "onLeaderOrderedBribery"); newCode[0] = 0x0136DB4C; newCode[1] = 0x01328B24; - addEvent(newCode[gv], "onAcceptBribe"); + addEvent(newCode[gv], "onAcceptBribe"); newCode[0] = 0x0136DC14; newCode[1] = 0x01328BEC; - addEvent(newCode[gv], "onRefuseBribe"); + addEvent(newCode[gv], "onRefuseBribe"); newCode[0] = 0x0136DCDC; newCode[1] = 0x01328CB4; - addEvent(newCode[gv], "onInsurrection"); + addEvent(newCode[gv], "onInsurrection"); newCode[0] = 0x0136DE7C; newCode[1] = 0x01328E54; - addEvent(newCode[gv], "onLeaderOrderedDiplomacy"); + addEvent(newCode[gv], "onLeaderOrderedDiplomacy"); newCode[0] = 0x0136E394; newCode[1] = 0x0132936C; - addEvent(newCode[gv], "onNewAdmiralCreated"); + addEvent(newCode[gv], "onNewAdmiralCreated"); newCode[0] = 0x0136EC8C; newCode[1] = 0x01329C64; - addEvent(newCode[gv], "onGovernorBuildingDestroyed"); + addEvent(newCode[gv], "onGovernorBuildingDestroyed"); newCode[0] = 0x0136F154; newCode[1] = 0x0132A12C; - addEvent(newCode[gv], "onGovernorThrowGames"); + addEvent(newCode[gv], "onGovernorThrowGames"); newCode[0] = 0x0136F224; newCode[1] = 0x0132A1FC; - addEvent(newCode[gv], "onGovernorThrowRaces"); + addEvent(newCode[gv], "onGovernorThrowRaces"); newCode[0] = 0x013703A4; newCode[1] = 0x0132B37C; - addEvent(newCode[gv], "onCharacterSelected"); + addEvent(newCode[gv], "onCharacterSelected"); newCode[0] = 0x01370474; newCode[1] = 0x0132B44C; - addEvent(newCode[gv], "onEnemyCharacterSelected"); + addEvent(newCode[gv], "onEnemyCharacterSelected"); newCode[0] = 0x0137060C; newCode[1] = 0x0132B5E4; - addEvent(newCode[gv], "onMultiTurnMove"); + addEvent(newCode[gv], "onMultiTurnMove"); newCode[0] = 0x013714F4; newCode[1] = 0x0132C4CC; - addEvent(newCode[gv], "onCharacterPanelOpen"); + addEvent(newCode[gv], "onCharacterPanelOpen"); - //ransomEvent + //standardEvent newCode[0] = 0x0136C8EC; newCode[1] = 0x013278C4; - addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptor"); + addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptor"); newCode[0] = 0x0136C9C4; newCode[1] = 0x0132799C; - addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptive"); + addEvent(newCode[gv], "onGeneralPrisonersRansomedCaptive"); newCode[0] = 0x0136CAA4; newCode[1] = 0x01327A7C; - addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptor"); + addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptor"); newCode[0] = 0x0136CB84; newCode[1] = 0x01327B5C; - addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptive"); + addEvent(newCode[gv], "onFactionLeaderPrisonersRansomedCaptive"); //spyMissionEvent newCode[0] = 0x0136CC94; newCode[1] = 0x01327C6C; - addEvent(newCode[gv], "onSpyMission"); + addEvent(newCode[gv], "onSpyMission"); //missionEvent newCode[0] = 0x0136E0E4; newCode[1] = 0x013290BC; - addEvent(newCode[gv], "onLeaderMissionSuccess"); + addEvent(newCode[gv], "onLeaderMissionSuccess"); newCode[0] = 0x0136DF64; newCode[1] = 0x01328F3C; - addEvent(newCode[gv], "onLeaderMissionFailed"); + addEvent(newCode[gv], "onLeaderMissionFailed"); - //diplomacyMissionEvent + //standardEvent newCode[0] = 0x0136D9B4; newCode[1] = 0x0132898C; - addEvent(newCode[gv], "onBriberyMission"); + addEvent(newCode[gv], "onBriberyMission"); newCode[0] = 0x0136DDAC; newCode[1] = 0x01328D84; - addEvent(newCode[gv], "onDiplomacyMission"); + addEvent(newCode[gv], "onDiplomacyMission"); - //agentMissionEvent + //standardEvent newCode[0] = 0x0136CF0C; newCode[1] = 0x01327EE4; - addEvent(newCode[gv], "onAssassinationMission"); + addEvent(newCode[gv], "onAssassinationMission"); newCode[0] = 0x0136D33C; newCode[1] = 0x01328314; - addEvent(newCode[gv], "onAcquisitionMission"); + addEvent(newCode[gv], "onAcquisitionMission"); newCode[0] = 0x0136D4DC; newCode[1] = 0x013284B4; - addEvent(newCode[gv], "onMarriageMission"); + addEvent(newCode[gv], "onMarriageMission"); newCode[0] = 0x0136D67C; newCode[1] = 0x01328654; - addEvent(newCode[gv], "onDenouncementMission"); + addEvent(newCode[gv], "onDenouncementMission"); newCode[0] = 0x0136D81C; newCode[1] = 0x013287F4; - addEvent(newCode[gv], "onSabotageMission"); + addEvent(newCode[gv], "onSabotageMission"); - //OrderSpyMissionEvent + //standardEvent newCode[0] = 0x0136CE3C; newCode[1] = 0x01327E14; - addEvent(newCode[gv], "onLeaderOrderedSpyingMission"); + addEvent(newCode[gv], "onLeaderOrderedSpyingMission"); - //OrderKillMissionEvent + //standardEvent newCode[0] = 0x0136D194; newCode[1] = 0x0132816C; - addEvent(newCode[gv], "onLeaderOrderedAssassination"); + addEvent(newCode[gv], "onLeaderOrderedAssassination"); - //namedCharacterCrusadeEvent + //standardEvent newCode[0] = 0x0136C3E4; newCode[1] = 0x013273BC; - addEvent(newCode[gv], "onGeneralJoinCrusade"); + addEvent(newCode[gv], "onGeneralJoinCrusade"); newCode[0] = 0x0136C4B4; newCode[1] = 0x0132748C; - addEvent(newCode[gv], "onGeneralAbandonCrusade"); + addEvent(newCode[gv], "onGeneralAbandonCrusade"); newCode[0] = 0x0136C594; newCode[1] = 0x0132756C; - addEvent(newCode[gv], "onGeneralArrivesCrusadeTargetRegion"); + addEvent(newCode[gv], "onGeneralArrivesCrusadeTargetRegion"); newCode[0] = 0x0136C66C; newCode[1] = 0x01327644; - addEvent(newCode[gv], "onGeneralTakesCrusadeTarget"); + addEvent(newCode[gv], "onGeneralTakesCrusadeTarget"); - //namedCharacterSettEvent + //standardEvent newCode[0] = 0x0136C0B4; newCode[1] = 0x0132708C; - addEvent(newCode[gv], "onCharacterTurnEnd"); + addEvent(newCode[gv], "onCharacterTurnEnd"); newCode[0] = 0x0136C18C; newCode[1] = 0x01327164; - addEvent(newCode[gv], "onCharacterTurnEndInSettlement"); + addEvent(newCode[gv], "onCharacterTurnEndInSettlement"); - //namedCharacterTargetSettEvents + //standardEvents newCode[0] = 0x01369FE4; newCode[1] = 0x01324FBC; - addEvent(newCode[gv], "onGeneralCaptureSettlement"); + addEvent(newCode[gv], "onGeneralCaptureSettlement"); newCode[0] = 0x0136A3E4; newCode[1] = 0x013253BC; - addEvent(newCode[gv], "onGeneralAssaultsResidence"); + addEvent(newCode[gv], "onGeneralAssaultsResidence"); - //settOccupationEvent + //standardEvent newCode[0] = 0x0136F3C4; newCode[1] = 0x0132A39C; - addEvent(newCode[gv], "onOccupySettlement"); + addEvent(newCode[gv], "onOccupySettlement"); newCode[0] = 0x0136F48C; newCode[1] = 0x0132A464; - addEvent(newCode[gv], "onSackSettlement"); + addEvent(newCode[gv], "onSackSettlement"); newCode[0] = 0x0136F55C; newCode[1] = 0x0132A534; - addEvent(newCode[gv], "onExterminatePopulation"); + addEvent(newCode[gv], "onExterminatePopulation"); - //namedCharacterRiotEvents + //standardEvent newCode[0] = 0x0136EEEC; newCode[1] = 0x01329EC4; - addEvent(newCode[gv], "onGovernorCityRiots"); + addEvent(newCode[gv], "onGovernorCityRiots"); newCode[0] = 0x0136F084; newCode[1] = 0x0132A05C; - addEvent(newCode[gv], "onGovernorCityRebels"); + addEvent(newCode[gv], "onGovernorCityRebels"); - //namedCharacterTargetCharEvents + //standardEvents newCode[0] = 0x0136A4B4; newCode[1] = 0x0132548C; - addEvent(newCode[gv], "onGeneralAssaultsGeneral"); + addEvent(newCode[gv], "onGeneralAssaultsGeneral"); newCode[0] = 0x0136C75C; newCode[1] = 0x01327734; - addEvent(newCode[gv], "onCharacterAttacksCrusadingGeneral"); + addEvent(newCode[gv], "onCharacterAttacksCrusadingGeneral"); - //namedCharacterDisasterEvents + //standardEvents newCode[0] = 0x0136A254; newCode[1] = 0x0132522C; - addEvent(newCode[gv], "onCharacterDamagedByDisaster"); + addEvent(newCode[gv], "onCharacterDamagedByDisaster"); - //settlementEvents + //standardEvents newCode[0] = 0x0136E2B4; newCode[1] = 0x0132928C; - addEvent(newCode[gv], "onSettlementTurnStart"); + addEvent(newCode[gv], "onSettlementTurnStart"); newCode[0] = 0x0136F2F4; newCode[1] = 0x0132A2CC; - addEvent(newCode[gv], "onUngarrisonedSettlement"); + addEvent(newCode[gv], "onUngarrisonedSettlement"); newCode[0] = 0x0136F6F4; newCode[1] = 0x0132A6CC; - addEvent(newCode[gv], "onSettlementUpgraded"); + addEvent(newCode[gv], "onSettlementUpgraded"); newCode[0] = 0x0136F7C4; newCode[1] = 0x0132A79C; - addEvent(newCode[gv], "onSettlementConverted"); + addEvent(newCode[gv], "onSettlementConverted"); newCode[0] = 0x0136FA24; newCode[1] = 0x0132A9FC; - addEvent(newCode[gv], "onSiegeEquipmentCompleted"); + addEvent(newCode[gv], "onSiegeEquipmentCompleted"); newCode[0] = 0x0136FADC; newCode[1] = 0x0132AAB4; - addEvent(newCode[gv], "onSettlementTurnEnd"); + addEvent(newCode[gv], "onSettlementTurnEnd"); newCode[0] = 0x01370544; newCode[1] = 0x0132B51C; - addEvent(newCode[gv], "onSettlementSelected"); + addEvent(newCode[gv], "onSettlementSelected"); newCode[0] = 0x013706EC; newCode[1] = 0x0132B6C4; - addEvent(newCode[gv], "onSettlementPanelOpen"); + addEvent(newCode[gv], "onSettlementPanelOpen"); newCode[0] = 0x01370C04; newCode[1] = 0x0132BBDC; - addEvent(newCode[gv], "onRecruitmentPanelOpen"); + addEvent(newCode[gv], "onRecruitmentPanelOpen"); newCode[0] = 0x0132BCAC; newCode[1] = 0x0132BBDC; - addEvent(newCode[gv], "onConstructionPanelOpen"); + addEvent(newCode[gv], "onConstructionPanelOpen"); newCode[0] = 0x01370D9C; newCode[1] = 0x0132BD74; - addEvent(newCode[gv], "onTradePanelOpen"); + addEvent(newCode[gv], "onTradePanelOpen"); newCode[0] = 0x01371264; newCode[1] = 0x0132C23C; - addEvent(newCode[gv], "onSettlementScrollAdviceRequested"); + addEvent(newCode[gv], "onSettlementScrollAdviceRequested"); - //guildEvents + //standardEvents newCode[0] = 0x0136F88C; newCode[1] = 0x0132A864; - addEvent(newCode[gv], "onGuildUpgraded"); + addEvent(newCode[gv], "onGuildUpgraded"); newCode[0] = 0x0136F954; newCode[1] = 0x0132A92C; - addEvent(newCode[gv], "onGuildDestroyed"); + addEvent(newCode[gv], "onGuildDestroyed"); - //targetSettlementEvents + //standardEvents newCode[0] = 0x0136ED54; newCode[1] = 0x01329D2C; - addEvent(newCode[gv], "onCityRiots"); + addEvent(newCode[gv], "onCityRiots"); newCode[0] = 0x0136EE1C; newCode[1] = 0x01329DF4; - addEvent(newCode[gv], "onGiveSettlement"); + addEvent(newCode[gv], "onGiveSettlement"); newCode[0] = 0x0136EFB4; newCode[1] = 0x01329F8C; - addEvent(newCode[gv], "onCityRebels"); + addEvent(newCode[gv], "onCityRebels"); newCode[0] = 0x0136F624; newCode[1] = 0x0132A5FC; - addEvent(newCode[gv], "onCitySacked"); + addEvent(newCode[gv], "onCitySacked"); //gameEvents newCode[0] = 0x0135E30C; newCode[1] = 0x013192E4; - addEvent(newCode[gv], "onAbandonShowMe"); + addEvent(newCode[gv], "onAbandonShowMe"); newCode[0] = 0x013319E4; newCode[1] = 0x012EC9C4; - addEvent(newCode[gv], "onGameReloaded"); + addEvent(newCode[gv], "onGameReloaded"); newCode[0] = 0x01367F5C; newCode[1] = 0x01322F34; - addEvent(newCode[gv], "onBattleWinningPlaza"); + addEvent(newCode[gv], "onBattleWinningPlaza"); newCode[0] = 0x01368044; newCode[1] = 0x0132301C; - addEvent(newCode[gv], "onBattleStopsWinningPlaza"); + addEvent(newCode[gv], "onBattleStopsWinningPlaza"); newCode[0] = 0x01368124; newCode[1] = 0x013230FC; - addEvent(newCode[gv], "onBattleDominatingPlaza"); + addEvent(newCode[gv], "onBattleDominatingPlaza"); newCode[0] = 0x013681F4; newCode[1] = 0x013231CC; - addEvent(newCode[gv], "onBattngineUnmanned"); + addEvent(newCode[gv], "onBattngineUnmanned"); newCode[0] = 0x013682E4; newCode[1] = 0x013232BC; - addEvent(newCode[gv], "onBattlePlayerArmyHalfDestroyed"); + addEvent(newCode[gv], "onBattlePlayerArmyHalfDestroyed"); newCode[0] = 0x013683BC; newCode[1] = 0x01323394; - addEvent(newCode[gv], "onBattnemyArmyHalfDestroyed"); + addEvent(newCode[gv], "onBattnemyArmyHalfDestroyed"); newCode[0] = 0x01368584; newCode[1] = 0x0132355C; - addEvent(newCode[gv], "onBattleTideofBattle"); + addEvent(newCode[gv], "onBattleTideofBattle"); newCode[0] = 0x01368DA4; newCode[1] = 0x01323D7C; - addEvent(newCode[gv], "onBattleFinished"); + addEvent(newCode[gv], "onBattleFinished"); newCode[0] = 0x01368E5C; newCode[1] = 0x01323E34; - addEvent(newCode[gv], "onBattleArmyHalfDestroyed"); + addEvent(newCode[gv], "onBattleArmyHalfDestroyed"); newCode[0] = 0x0139622C; newCode[1] = 0x013511FC; - addEvent(newCode[gv], "onEscPressed"); + addEvent(newCode[gv], "onEscPressed"); newCode[0] = 0x0139552C; newCode[1] = 0x013504FC; - addEvent(newCode[gv], "onScriptedAdvice"); + addEvent(newCode[gv], "onScriptedAdvice"); newCode[0] = 0x013DB05C; newCode[1] = 0x01395DF4; - addEvent(newCode[gv], "onNavalPreBattleScrollAdviceRequested"); + addEvent(newCode[gv], "onNavalPreBattleScrollAdviceRequested"); newCode[0] = 0x013DB114; newCode[1] = 0x01395EAC; - addEvent(newCode[gv], "onPreBattleScrollAdviceRequested"); + addEvent(newCode[gv], "onPreBattleScrollAdviceRequested"); newCode[0] = 0x013D9004; newCode[1] = 0x01393D9C; - addEvent(newCode[gv], "onCollegeOfCardinalsPanelOpen"); + addEvent(newCode[gv], "onCollegeOfCardinalsPanelOpen"); newCode[0] = 0x013D2074; newCode[1] = 0x0138CE0C; - addEvent(newCode[gv], "onDiplomaticStandingPanelOpen"); + addEvent(newCode[gv], "onDiplomaticStandingPanelOpen"); newCode[0] = 0x01368FCC; newCode[1] = 0x0132355C; - addEvent(newCode[gv], "onBattleWinningCombat"); + addEvent(newCode[gv], "onBattleWinningCombat"); newCode[0] = 0x01368F14; newCode[1] = 0x01323EEC; - addEvent(newCode[gv], "onBattleArmyTired"); + addEvent(newCode[gv], "onBattleArmyTired"); - //crusadeEvents + //standardEvents newCode[0] = 0x013321D4; newCode[1] = 0x012ED1B4; - addEvent(newCode[gv], "onCrusadeCalled"); + addEvent(newCode[gv], "onCrusadeCalled"); newCode[0] = 0x0133778C; newCode[1] = 0x012F276C; - addEvent(newCode[gv], "onPopeAcceptsCrusadeTarget"); + addEvent(newCode[gv], "onPopeAcceptsCrusadeTarget"); newCode[0] = 0x01337844; newCode[1] = 0x012F2824; - addEvent(newCode[gv], "onPopeRejectsCrusadeTarget"); + addEvent(newCode[gv], "onPopeRejectsCrusadeTarget"); newCode[0] = 0x0133228C; newCode[1] = 0x012ED26C; - addEvent(newCode[gv], "onCrusadeEnds"); + addEvent(newCode[gv], "onCrusadeEnds"); - //factionCrusadeEvents + //standardEvents newCode[0] = 0x0136AEAC; newCode[1] = 0x01325E84; - addEvent(newCode[gv], "onUnitsDesertCrusade"); + addEvent(newCode[gv], "onUnitsDesertCrusade"); - //crusadeTargetEvents + //standardEvents newCode[0] = 0x0136AF7C; newCode[1] = 0x01325F54; - addEvent(newCode[gv], "onArmyTakesCrusadeTarget"); + addEvent(newCode[gv], "onArmyTakesCrusadeTarget"); - //transgressionEvents + //standardEvents newCode[0] = 0x0136B044; newCode[1] = 0x0132601C; - addEvent(newCode[gv], "onTransgression"); + addEvent(newCode[gv], "onTransgression"); newCode[0] = 0x0136B1DC; newCode[1] = 0x013261B4; - addEvent(newCode[gv], "onForgiveness"); + addEvent(newCode[gv], "onForgiveness"); - //factionEvents + //standardEvents newCode[0] = 0x01366E24; newCode[1] = 0x01321DFC; - addEvent(newCode[gv], "onBattleAiCommenced"); + addEvent(newCode[gv], "onBattleAiCommenced"); newCode[0] = 0x01366EF8; newCode[1] = 0x01321ED4; - addEvent(newCode[gv], "onBattleDelayPhaseCommenced"); + addEvent(newCode[gv], "onBattleDelayPhaseCommenced"); newCode[0] = 0x01366FD4; newCode[1] = 0x01321FAC; - addEvent(newCode[gv], "onBattleDeploymentPhaseCommenced"); + addEvent(newCode[gv], "onBattleDeploymentPhaseCommenced"); newCode[0] = 0x013670AC; newCode[1] = 0x01322084; - addEvent(newCode[gv], "onBattleConflictPhaseCommenced"); + addEvent(newCode[gv], "onBattleConflictPhaseCommenced"); newCode[0] = 0x0136931C; newCode[1] = 0x013242F4; - addEvent(newCode[gv], "onFactionTurnStart"); + addEvent(newCode[gv], "onFactionTurnStart"); newCode[0] = 0x013694BC; newCode[1] = 0x01324494; - addEvent(newCode[gv], "onFactionNewCapital"); + addEvent(newCode[gv], "onFactionNewCapital"); newCode[0] = 0x013693EC; newCode[1] = 0x013243C4; - addEvent(newCode[gv], "onPreFactionTurnStart"); + addEvent(newCode[gv], "onPreFactionTurnStart"); newCode[0] = 0x01369A5C; newCode[1] = 0x01324A34; - addEvent(newCode[gv], "onVotedForPope"); + addEvent(newCode[gv], "onVotedForPope"); newCode[0] = 0x01369B14; newCode[1] = 0x01324AEC; - addEvent(newCode[gv], "onFactionExcommunicated"); + addEvent(newCode[gv], "onFactionExcommunicated"); newCode[0] = 0x01369CAC; newCode[1] = 0x01324C84; - addEvent(newCode[gv], "onHordeFormed"); + addEvent(newCode[gv], "onHordeFormed"); newCode[0] = 0x01369D74; newCode[1] = 0x01324D4C; - addEvent(newCode[gv], "onFactionTurnEnd"); + addEvent(newCode[gv], "onFactionTurnEnd"); newCode[0] = 0x0136BD74; newCode[1] = 0x01326D4C; - addEvent(newCode[gv], "onCardinalRemoved"); + addEvent(newCode[gv], "onCardinalRemoved"); newCode[0] = 0x0136BE44; newCode[1] = 0x01326E1C; - addEvent(newCode[gv], "onInquisitorAppointed"); + addEvent(newCode[gv], "onInquisitorAppointed"); newCode[0] = 0x0136D0BC; newCode[1] = 0x01328094; - addEvent(newCode[gv], "onAssassinCaughtAttackingPope"); + addEvent(newCode[gv], "onAssassinCaughtAttackingPope"); newCode[0] = 0x013707BC; newCode[1] = 0x0132B794; - addEvent(newCode[gv], "onFinancesPanelOpen"); + addEvent(newCode[gv], "onFinancesPanelOpen"); newCode[0] = 0x0137088C; newCode[1] = 0x0132B864; - addEvent(newCode[gv], "onFactionSummaryPanelOpen"); + addEvent(newCode[gv], "onFactionSummaryPanelOpen"); newCode[0] = 0x0137095C; newCode[1] = 0x0132B934; - addEvent(newCode[gv], "onFamilyTreePanelOpen"); + addEvent(newCode[gv], "onFamilyTreePanelOpen"); newCode[0] = 0x01370A64; newCode[1] = 0x0132BA3C; - addEvent(newCode[gv], "onDiplomacyPanelOpen"); + addEvent(newCode[gv], "onDiplomacyPanelOpen"); newCode[0] = 0x01370B34; newCode[1] = 0x0132BB0C; - addEvent(newCode[gv], "onPreBattlePanelOpen"); + addEvent(newCode[gv], "onPreBattlePanelOpen"); newCode[0] = 0x01371364; newCode[1] = 0x0132C33C; - addEvent(newCode[gv], "onDeclineAutomatedSettlementManagement"); + addEvent(newCode[gv], "onDeclineAutomatedSettlementManagement"); - //diplomacyEvents + //standardEvents newCode[0] = 0x0136958C; newCode[1] = 0x01324564; - addEvent(newCode[gv], "onFactionWarDeclared"); + addEvent(newCode[gv], "onFactionWarDeclared"); newCode[0] = 0x0136965C; newCode[1] = 0x01324634; - addEvent(newCode[gv], "onFactionAllianceDeclared"); + addEvent(newCode[gv], "onFactionAllianceDeclared"); newCode[0] = 0x0136972C; newCode[1] = 0x01324704; - addEvent(newCode[gv], "onInterFactionMarriage"); + addEvent(newCode[gv], "onInterFactionMarriage"); newCode[0] = 0x01369804; newCode[1] = 0x013247DC; - addEvent(newCode[gv], "onFactionTradeAgreementMade"); + addEvent(newCode[gv], "onFactionTradeAgreementMade"); newCode[0] = 0x01369994; newCode[1] = 0x0132496C; - addEvent(newCode[gv], "onPopeElected"); + addEvent(newCode[gv], "onPopeElected"); newCode[0] = 0x01369BE4; newCode[1] = 0x01324BBC; - addEvent(newCode[gv], "onFactionBreakAlliance"); + addEvent(newCode[gv], "onFactionBreakAlliance"); newCode[0] = 0x0136B2A4; newCode[1] = 0x0132627C; - addEvent(newCode[gv], "onUpdateAttitude"); + addEvent(newCode[gv], "onUpdateAttitude"); - //diplomacyMoneyEvents + //standardEvents newCode[0] = 0x013698CC; newCode[1] = 0x013248A4; - addEvent(newCode[gv], "onGiveMoney"); + addEvent(newCode[gv], "onGiveMoney"); newCode[0] = 0x0136B36C; newCode[1] = 0x01326344; - addEvent(newCode[gv], "onDemeanour"); + addEvent(newCode[gv], "onDemeanour"); - //armyEvent + //standardEvent newCode[0] = 0x013686FC; newCode[1] = 0x013236D4; - addEvent(newCode[gv], "onBattleArmyRouted"); + addEvent(newCode[gv], "onBattleArmyRouted"); newCode[0] = 0x0136886C; newCode[1] = 0x01323844; - addEvent(newCode[gv], "onBattleReinforcementsArrive"); + addEvent(newCode[gv], "onBattleReinforcementsArrive"); newCode[0] = 0x0137171C; newCode[1] = 0x0132C6F4; - addEvent(newCode[gv], "onRequestMercenariesAdvice"); + addEvent(newCode[gv], "onRequestMercenariesAdvice"); - //characterEvent + //standardEvent newCode[0] = 0x013687B4; newCode[1] = 0x0132378C; - addEvent(newCode[gv], "onBattleGeneralRouted"); + addEvent(newCode[gv], "onBattleGeneralRouted"); newCode[0] = 0x0136914C; newCode[1] = 0x01324124; - addEvent(newCode[gv], "onBattleGeneralKilled"); + addEvent(newCode[gv], "onBattleGeneralKilled"); - //stratUnitEvent + //standardEvent newCode[0] = 0x0136B434; newCode[1] = 0x0132640C; - addEvent(newCode[gv], "onUnitDisbanded"); + addEvent(newCode[gv], "onUnitDisbanded"); - //stratUnitSettEvent + //standardEvent newCode[0] = 0x0136E45C; newCode[1] = 0x01329434; - addEvent(newCode[gv], "onUnitTrained"); + addEvent(newCode[gv], "onUnitTrained"); - //stratUnitSettEvent + //standardEvent newCode[0] = 0x0136E52C; newCode[1] = 0x01329504; - addEvent(newCode[gv], "onGovernorUnitTrained"); + addEvent(newCode[gv], "onGovernorUnitTrained"); - //characterBuildingEvent + //standardEvent newCode[0] = 0x0136E614; newCode[1] = 0x013295EC; - addEvent(newCode[gv], "onGovernorBuildingCompleted"); + addEvent(newCode[gv], "onGovernorBuildingCompleted"); - //buildingEvent + //standardEvent newCode[0] = 0x0136EA14; newCode[1] = 0x013299EC; - addEvent(newCode[gv], "onBuildingDestroyed"); + addEvent(newCode[gv], "onBuildingDestroyed"); newCode[0] = 0x0136EAE4; newCode[1] = 0x01329ABC; - addEvent(newCode[gv], "onAddedToBuildingQueue"); + addEvent(newCode[gv], "onAddedToBuildingQueue"); newCode[0] = 0x0136EBB4; newCode[1] = 0x01329B8C; - addEvent(newCode[gv], "onAddedToTrainingQueue"); + addEvent(newCode[gv], "onAddedToTrainingQueue"); newCode[0] = 0x013715AC; newCode[1] = 0x0132C584; - addEvent(newCode[gv], "onRequestBuildingAdvice"); + addEvent(newCode[gv], "onRequestBuildingAdvice"); newCode[0] = 0x01371664; newCode[1] = 0x0132C63C; - addEvent(newCode[gv], "onRequestTrainingAdvice"); + addEvent(newCode[gv], "onRequestTrainingAdvice"); - //buildingCompletedEvents + //standardEvents newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; - addEvent(newCode[gv], "onBuildingCompleted"); + addEvent(newCode[gv], "onBuildingCompleted"); - //agentCreatedEvent + //standardEvent newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; - addEvent(newCode[gv], "onAgentCreated"); + addEvent(newCode[gv], "onAgentCreated"); newCode[0] = 0x0136E944; newCode[1] = 0x0132991C; - addEvent(newCode[gv], "onGovernorAgentCreated"); + addEvent(newCode[gv], "onGovernorAgentCreated"); - //battleUnitEvent + //standardEvent newCode[0] = 0x0136863C; newCode[1] = 0x01323614; - addEvent(newCode[gv], "onBattleUnitGoesBerserk"); + addEvent(newCode[gv], "onBattleUnitGoesBerserk"); newCode[0] = 0x01368924; newCode[1] = 0x013238FC; - addEvent(newCode[gv], "onBattleSiegeEngineDestroyed"); + addEvent(newCode[gv], "onBattleSiegeEngineDestroyed"); newCode[0] = 0x013689E4; newCode[1] = 0x013239BC; - addEvent(newCode[gv], "onBattleSiegeEngineDocksWall"); + addEvent(newCode[gv], "onBattleSiegeEngineDocksWall"); newCode[0] = 0x01368AA4; newCode[1] = 0x01323A7C; - addEvent(newCode[gv], "onBattleGatesAttackedByEngine"); + addEvent(newCode[gv], "onBattleGatesAttackedByEngine"); newCode[0] = 0x01368B64; newCode[1] = 0x01323B3C; - addEvent(newCode[gv], "onBattleGatesDestroyedByEngine"); + addEvent(newCode[gv], "onBattleGatesDestroyedByEngine"); newCode[0] = 0x01368C24; newCode[1] = 0x01323BFC; - addEvent(newCode[gv], "onBattleWallsBreachedByEngine"); + addEvent(newCode[gv], "onBattleWallsBreachedByEngine"); newCode[0] = 0x0136908C; newCode[1] = 0x01324064; - addEvent(newCode[gv], "onBattleUnitRouts"); + addEvent(newCode[gv], "onBattleUnitRouts"); - //battleUnitEvent2 + //standardEvent newCode[0] = 0x01368CE4; newCode[1] = 0x01323CBC; - addEvent(newCode[gv], "onBattleWallsCaptured"); + addEvent(newCode[gv], "onBattleWallsCaptured"); - //battlePlayerArmyUnitEvent + //standardEvent newCode[0] = 0x013684A4; newCode[1] = 0x0132347C; - addEvent(newCode[gv], "onBattlePlayerUnderAttackIdle"); + addEvent(newCode[gv], "onBattlePlayerUnderAttackIdle"); - //battlePlayerUnitEvents + //standardEvents newCode[0] = 0x0136718C; newCode[1] = 0x01322164; - addEvent(newCode[gv], "onBattlePlayerUnitAttacksEnemyUnit"); + addEvent(newCode[gv], "onBattlePlayerUnitAttacksEnemyUnit"); newCode[0] = 0x013675D4; newCode[1] = 0x013225AC; - addEvent(newCode[gv], "onBattlePlayerUnitGoesBerserk"); + addEvent(newCode[gv], "onBattlePlayerUnitGoesBerserk"); newCode[0] = 0x0136778C; newCode[1] = 0x01322764; - addEvent(newCode[gv], "onBattlePlayerUnitRouts"); + addEvent(newCode[gv], "onBattlePlayerUnitRouts"); newCode[0] = 0x0136793C; newCode[1] = 0x01322914; - addEvent(newCode[gv], "onBattlePlayerSiegeEngineDestroyed"); + addEvent(newCode[gv], "onBattlePlayerSiegeEngineDestroyed"); newCode[0] = 0x01367C64; newCode[1] = 0x01322C3C; - addEvent(newCode[gv], "onBattleGatesAttackedByPlayerEngine"); + addEvent(newCode[gv], "onBattleGatesAttackedByPlayerEngine"); - //battleAIUnitEvents + //standardEvents newCode[0] = 0x0136726C; newCode[1] = 0x01322244; - addEvent(newCode[gv], "onBattleEnemyUnitAttacksPlayerUnit"); + addEvent(newCode[gv], "onBattleEnemyUnitAttacksPlayerUnit"); newCode[0] = 0x013676AC; newCode[1] = 0x01322684; - addEvent(newCode[gv], "onBattleEnemyUnitGoesBerserk"); + addEvent(newCode[gv], "onBattleEnemyUnitGoesBerserk"); newCode[0] = 0x0136785C; newCode[1] = 0x01322834; - addEvent(newCode[gv], "onBattnemyUnitRouts"); + addEvent(newCode[gv], "onBattnemyUnitRouts"); newCode[0] = 0x01367A14; newCode[1] = 0x013229EC; - addEvent(newCode[gv], "onBattnemySiegeEngineDestroyed"); + addEvent(newCode[gv], "onBattnemySiegeEngineDestroyed"); newCode[0] = 0x01367D44; newCode[1] = 0x01322D1C; - addEvent(newCode[gv], "onBattleGatesAttackedByEnemyEngine"); + addEvent(newCode[gv], "onBattleGatesAttackedByEnemyEngine"); - //disasterEvents + //standardEvents newCode[0] = 0x0136A17C; newCode[1] = 0x01325154; - addEvent(newCode[gv], "onDisaster"); + addEvent(newCode[gv], "onDisaster"); - //eventCounterEvents + //standardEvents newCode[0] = 0x0136A30C; newCode[1] = 0x013252E4; - addEvent(newCode[gv], "onEventCounter"); + addEvent(newCode[gv], "onEventCounter"); - //fortEvents + //standardEvents newCode[0] = 0x0136AC04; newCode[1] = 0x01325BDC; - addEvent(newCode[gv], "onUngarrisonedFort"); + addEvent(newCode[gv], "onUngarrisonedFort"); - //uiEvents + //standardEvents newCode[0] = 0x013717D4; newCode[1] = 0x0132C7AC; - addEvent(newCode[gv], "onButtonPressed"); + addEvent(newCode[gv], "onButtonPressed"); newCode[0] = 0x0137188C; newCode[1] = 0x0132C864; - addEvent(newCode[gv], "onShortcutTriggered"); + addEvent(newCode[gv], "onShortcutTriggered"); newCode[0] = 0x01371944; newCode[1] = 0x0132C91C; - addEvent(newCode[gv], "onUIElementVisible"); + addEvent(newCode[gv], "onUIElementVisible"); newCode[0] = 0x013719FC; newCode[1] = 0x0132C9D4; - addEvent(newCode[gv], "onScrollOpened"); + addEvent(newCode[gv], "onScrollOpened"); newCode[0] = 0x01371AB4; newCode[1] = 0x0132CA8C; - addEvent(newCode[gv], "onScrollClosed"); + addEvent(newCode[gv], "onScrollClosed"); newCode[0] = 0x01371B6C; newCode[1] = 0x0132CB44; - addEvent(newCode[gv], "onScrollAdviceRequested"); + addEvent(newCode[gv], "onScrollAdviceRequested"); newCode[0] = 0x01371144; newCode[1] = 0x0132C11C; - addEvent(newCode[gv], "onAdviceSupressed"); + addEvent(newCode[gv], "onAdviceSupressed"); - //closeMessageEvents + //standardEvents newCode[0] = 0x0137102C; newCode[1] = 0x0132C004; - addEvent(newCode[gv], "onMessageClosed"); + addEvent(newCode[gv], "onMessageClosed"); - //factionUiEvents + //standardEvents newCode[0] = 0x01370E9C; newCode[1] = 0x0132BE74; - addEvent(newCode[gv], "onIncomingMessage"); + addEvent(newCode[gv], "onIncomingMessage"); newCode[0] = 0x01370F64; newCode[1] = 0x0132BF3C; - addEvent(newCode[gv], "onMessageOpen"); + addEvent(newCode[gv], "onMessageOpen"); - //tileEvents + //standardEvents newCode[0] = 0x0136ACCC; newCode[1] = 0x01325CA4; - addEvent(newCode[gv], "onTileSeen"); + addEvent(newCode[gv], "onTileSeen"); - //objEvents + //standardEvents newCode[0] = 0x0136AD8C; newCode[1] = 0x01325D64; - addEvent(newCode[gv], "onObjSeen"); + addEvent(newCode[gv], "onObjSeen"); } template void addEvent(const DWORD key, const char* name) @@ -705,6 +690,14 @@ void onReadGameDbsAtStart() } } +void onGameInit() +{ + if (plugData::data.luaAll.onGameInit != nullptr) + { + tryLua((*plugData::data.luaAll.onGameInit)()); + } +} + void onEndSiege(int x, int y) { if (plugData::data.luaAll.onEndSiege != nullptr) diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h index f2cfe2708..f5da7d6d7 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -5,6 +5,7 @@ using namespace std; extern "C" PLUGINM2TWEOP_API void onReadGameDbsAtStart(); +extern "C" PLUGINM2TWEOP_API void onGameInit(); extern "C" PLUGINM2TWEOP_API void onEndSiege(int x, int y); extern "C" PLUGINM2TWEOP_API void onStartSiege(int x, int y); std::unordered_map religionNames = { @@ -21,106 +22,14 @@ extern "C" PLUGINM2TWEOP_API void onLoadGamePl(std::vector*saveFile extern "C" PLUGINM2TWEOP_API std::vector*onSaveGamePl(UNICODE_STRING * *&savePath); extern "C" PLUGINM2TWEOP_API void onEventWrapper(DWORD eventAddr, DWORD * *vTab, DWORD arg2); -std::unordered_map characterTypes = { - {0,"spy"}, - {1,"assassin"}, - {2,"diplomat"}, - {3,"admiral"}, - {4,"merchant"}, - {5,"priest"}, - {6,"general"}, - {7,"named_character"}, - {8,"princess"}, - {9,"heretic"}, - {10,"witch"}, - {11,"inquisitor"}, - {13,"pope"} -}; -std::unordered_map disasterTypes = { - {0,"earthquake"}, - {1,"flood"}, - {2,"horde"}, - {3,"storm"}, - {4,"volcano"}, - {5,"dustbowl"}, - {6,"locusts"}, - {7,"famine"}, - {8,"plague"}, - {9,"riot"}, - {10,"fire"} -}; -std::unordered_map ransomTypes = { - {0,"ransom"}, - {1,"execute"}, - {2,"release"}, - {3,"cannot_pay_ransom"} -}; -std::unordered_map missionSuccessLvl = { - {0,"not_successful"}, - {1,"slightly_successful"}, - {2,"partly_successful"}, - {3,"highly_successful"} -}; - void checkLuaFunc(sol::function** lRef); -void initReligionNames(); namespace gameEvents { regionStruct* getCharacterRegion(const namedCharacter* character); enum class EventType { - namedCharacterEvent = 1, - gameEvent = 2, - crusadeEvent = 3, - crusadeEventEnds = 4, - factionEvent = 5, - battlePlayerUnitAttackEvent = 6, - battleAiUnitAttackEvent = 7, - battlePlayerUnitEvent = 8, - battleAiUnitEvent = 9, - battlePlayerArmyUnitEvent = 10, - battleUnitEvent = 11, - armyEvent = 12, - characterEvent = 13, - battleUnitEvent2 = 14, - diplomacyEvent = 15, - diplomacyMoneyEvent = 16, - namedCharacterTargetSettEvent = 17, - disasterEvent = 18, - namedCharacterDisasterEvent = 19, - eventCounterEvent = 20, - namedCharacterTargetCharEvent = 21, - fortEvent = 22, - tileEvent = 23, - objEvent = 24, - factionCrusadeEvent = 25, - crusadeTargetEvent = 26, - transgressionEvent = 27, - stratUnitEvent = 28, - namedCharacterSettEvent = 29, - namedCharacterCrusadeEvent = 30, - ransomEvent = 31, - spyMissionEvent = 32, - orderSpyMissionEvent = 33, - agentMissionEvent = 34, - orderKillMissionEvent = 35, - diplomacyMissionEvent = 36, - missionEvent = 37, - settlementEvent = 38, - stratUnitSettEvent = 39, - characterUnitSettEvent = 40, - characterBuildingEvent = 41, - agentCreatedEvent = 42, - buildingEvent = 43, - targetSettlementEvent = 44, - namedCharacterRiotEvents = 45, - settOccupationEvent = 46, - guildEvent = 47, - uiEvent = 48, - factionUiEvent = 49, - buildingCompletedEvent = 50, - closeMessageEvent = 51 + standardEvent = 1 }; class EventBase @@ -139,755 +48,16 @@ namespace gameEvents Event(const std::string& luaFunctionName, sol::state& luaState) : funk(new sol::function(luaState[luaFunctionName])) {} - static const char* getType(const namedCharacter* character) - { - if (character->gen != nullptr) - { - const auto charType = characterTypes.find(character->gen->genType->type); - if (charType != characterTypes.end()) - { - return charType->second; - } - } - return "unknown"; - } - static const char* getTypeInteger(int type) - { - const auto charType = characterTypes.find(type); - if (charType != characterTypes.end()) - { - return charType->second; - } - return "unknown"; - } - static const regionStruct* getRegion(const namedCharacter* character) - { - if (character->gen != nullptr) - { - return getCharacterRegion(character); - } - return nullptr; - } - static const char* getReligion(const int index) - { - if (index == -1) - { - return "unknown"; - } - const auto name = religionNames.find(index); - if (name != religionNames.end()) - { - return name->second; - } - return "unknown"; - } int callEvent(DWORD** vTab) override { - if (EvType == EventType::namedCharacterEvent) + if (EvType == EventType::standardEvent) { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - const char* characterType = getType(character); - const regionStruct* region = getRegion(character); - const char* religion = getReligion(faction->religion); + auto eventData = reinterpret_cast(vTab); if (&(*funk) != nullptr) { - (*funk)(character, faction, region, characterType, religion); + (*funk)(eventData); } return 1; } - else if (EvType == EventType::gameEvent) - { - if (&(*funk) != nullptr) { - (*funk)(); - } - return 2; - } - else if (EvType == EventType::crusadeEvent) - { - auto targetSettlement = reinterpret_cast(vTab[2]); - factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(targetSettlement, targetFaction, targetRegion, targetReligion); - } - return 3; - } - else if (EvType == EventType::crusadeEventEnds) - { - auto targetSettlement = reinterpret_cast(vTab[2]); - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); - if (&(*funk) != nullptr) { - (*funk)(targetSettlement, targetRegion); - } - return 4; - } - else if (EvType == EventType::factionEvent) - { - auto faction = reinterpret_cast(vTab[1]); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, religion); - } - return 5; - } - else if (EvType == EventType::battlePlayerUnitAttackEvent) - { - auto attackingUnit = reinterpret_cast(vTab[1]); - auto defendingUnit = reinterpret_cast(vTab[2]); - auto playerUnit = reinterpret_cast(vTab[1]); - auto enemyUnit = reinterpret_cast(vTab[2]); - if (&(*funk) != nullptr) { - (*funk)(attackingUnit, defendingUnit, playerUnit, enemyUnit); - } - return 6; - } - else if (EvType == EventType::battleAiUnitAttackEvent) - { - auto attackingUnit = reinterpret_cast(vTab[1]); - auto defendingUnit = reinterpret_cast(vTab[2]); - auto playerUnit = reinterpret_cast(vTab[2]); - auto enemyUnit = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(attackingUnit, defendingUnit, playerUnit, enemyUnit); - } - return 7; - } - else if (EvType == EventType::battlePlayerUnitEvent) - { - auto playerUnit = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(playerUnit); - } - return 8; - } - else if (EvType == EventType::battleAiUnitEvent) - { - auto enemyUnit = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(enemyUnit); - } - return 9; - } - else if (EvType == EventType::battlePlayerArmyUnitEvent) - { - auto playerUnit = reinterpret_cast(vTab[20]); - auto army = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(army, playerUnit); - } - return 10; - } - else if (EvType == EventType::battleUnitEvent) - { - auto playerUnit = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(playerUnit); - } - return 11; - } - else if (EvType == EventType::armyEvent) - { - auto army = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(army); - } - return 12; - } - else if (EvType == EventType::characterEvent) - { - auto gen = reinterpret_cast(vTab[1]); - namedCharacter* namedChar = gen->genChar; - if (&(*funk) != nullptr) { - (*funk)(gen, namedChar); - } - return 13; - } - else if (EvType == EventType::battleUnitEvent2) - { - auto playerUnit = reinterpret_cast(vTab[2]); - if (&(*funk) != nullptr) { - (*funk)(playerUnit); - } - return 14; - } - else if (EvType == EventType::diplomacyEvent) - { - auto faction = reinterpret_cast(vTab[1]); - const char* religion = getReligion(faction->religion); - auto targetFaction = reinterpret_cast(vTab[2]); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, religion, targetFaction, targetReligion); - } - return 15; - } - else if (EvType == EventType::diplomacyMoneyEvent) - { - auto faction = reinterpret_cast(vTab[1]); - const char* religion = getReligion(faction->religion); - auto targetFaction = reinterpret_cast(vTab[2]); - const char* targetReligion = getReligion(targetFaction->religion); - float amount = *reinterpret_cast((DWORD)&vTab[3]); - if (&(*funk) != nullptr) { - (*funk)(faction, religion, targetFaction, targetReligion, amount); - } - return 16; - } - else if (EvType == EventType::namedCharacterTargetSettEvent) - { - auto character = reinterpret_cast(vTab[1]); - auto settlement = reinterpret_cast(vTab[2]); - fortStruct* fort = nullptr; - factionStruct* faction = character->faction; - factionStruct* targetFaction = settlement->faction; - if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) - { - fort = reinterpret_cast(vTab[2]); - targetFaction = fort->faction; - } - const char* characterType = getType(character); - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - if (!fort) - { - (*funk)(character, settlement, faction, targetFaction, region, characterType, religion, targetReligion, false); - } - else - { - (*funk)(character, fort, faction, targetFaction, region, characterType, religion, targetReligion, true); - } - } - return 17; - } - else if (EvType == EventType::disasterEvent) - { - auto eventType = "unknown"; - if (disasterTypes.find(reinterpret_cast(vTab[1])) != disasterTypes.end()) { - eventType = disasterTypes.at(reinterpret_cast(vTab[1])); - } - if (&(*funk) != nullptr) { - (*funk)(eventType); - } - return 18; - } - else if (EvType == EventType::namedCharacterDisasterEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - const char* characterType = getType(character); - const regionStruct* region = getRegion(character); - const char* religion = getReligion(faction->religion); - auto eventType = "unknown"; - if (disasterTypes.find(reinterpret_cast(vTab[2])) != disasterTypes.end()) { - eventType = disasterTypes.at(reinterpret_cast(vTab[2])); - } - if (&(*funk) != nullptr) { - (*funk)(eventType, character, faction, region, characterType, religion); - } - return 19; - } - else if (EvType == EventType::eventCounterEvent) - { - - const char* counter = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(counter); - } - return 20; - } - else if (EvType == EventType::namedCharacterTargetCharEvent) - { - auto character = reinterpret_cast(vTab[1]); - auto targetCharacter = reinterpret_cast(vTab[2]); - factionStruct* faction = character->faction; - factionStruct* targetFaction = character->faction; - const char* characterType = getType(character); - const regionStruct* region = getRegion(character); - const char* religion = getReligion(faction->religion); - const char* targetCharacterType = getType(targetCharacter); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - - (*funk)(character, targetCharacter, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion); - } - return 21; - } - else if (EvType == EventType::fortEvent) - { - auto fort = reinterpret_cast(vTab[1]); - factionStruct* faction = fort->faction; - regionStruct* region = gameHelpers::getRegion(fort->regionID); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(fort, faction, region, religion); - } - return 22; - } - else if (EvType == EventType::tileEvent) - { - auto faction = reinterpret_cast(vTab[1]); - int x = reinterpret_cast(vTab[2]); - int y = reinterpret_cast(vTab[3]); - regionStruct* region = gameHelpers::getRegion(m2tweopHelpers::getTileRegionID(x, y)); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, x, y, region, religion); - } - return 23; - } - else if (EvType == EventType::objEvent) - { - auto faction = reinterpret_cast(vTab[1]); - auto targetFaction = reinterpret_cast(vTab[2]); - int x = reinterpret_cast(vTab[3]); - int y = reinterpret_cast(vTab[4]); - regionStruct* region = gameHelpers::getRegion(m2tweopHelpers::getTileRegionID(x, y)); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, targetFaction, x, y, region, religion); - } - return 24; - } - else if (EvType == EventType::factionCrusadeEvent) - { - auto targetSettlement = reinterpret_cast(vTab[2]); - auto faction = reinterpret_cast(vTab[3]); - factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(targetSettlement, faction, targetFaction, targetRegion, religion, targetReligion); - } - return 25; - } - else if (EvType == EventType::factionCrusadeEvent) - { - auto targetSettlement = reinterpret_cast(vTab[2]); - auto army = reinterpret_cast(vTab[3]); - factionStruct* faction = army->faction; - factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(targetSettlement, army, faction, targetFaction, targetRegion, religion, targetReligion); - } - return 26; - } - else if (EvType == EventType::transgressionEvent) - { - auto faction = reinterpret_cast(vTab[1]); - auto targetFaction = reinterpret_cast(vTab[4]); - const char* transgression = reinterpret_cast(vTab[2]); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, targetFaction, transgression, religion, targetReligion); - } - return 27; - } - else if (EvType == EventType::stratUnitEvent) - { - auto faction = reinterpret_cast(vTab[1]); - auto playerUnit = reinterpret_cast(vTab[2]); - eduEntry* edu = playerUnit->eduEntry; - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, playerUnit, edu, religion); - } - return 28; - } - else if (EvType == EventType::namedCharacterSettEvent) - { - auto character = reinterpret_cast(vTab[1]); - auto settlement = reinterpret_cast(vTab[2]); - factionStruct* faction = character->faction; - const char* characterType = getType(character); - regionStruct* region; - if (settlement) - { - region = gameHelpers::getRegion(settlement->regionID); - } - else - { - region = const_cast(getRegion(character)); - } - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, settlement, faction, region, characterType, religion); - } - return 29; - } - else if (EvType == EventType::namedCharacterCrusadeEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto crusadeActive = reinterpret_cast(vTab[2]); - auto targetSettlement = crusadeActive->targetSettlement; - factionStruct* targetFaction = targetSettlement->faction; - regionStruct* targetRegion = gameHelpers::getRegion(targetSettlement->regionID); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion); - } - return 30; - } - else if (EvType == EventType::ransomEvent) - { - auto character = reinterpret_cast(vTab[1]); - auto capInfo = reinterpret_cast(vTab[2]); - auto ransomType = "unknown"; - if (ransomTypes.find(reinterpret_cast(vTab[3])) != ransomTypes.end()) { - ransomType = ransomTypes.at(reinterpret_cast(vTab[3])); - } - factionStruct* faction = character->faction; - factionStruct* targetFaction = gameHelpers::getFaction(capInfo->targetFactionID); - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion); - } - return 31; - } - else if (EvType == EventType::spyMissionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto targetFaction = reinterpret_cast(vTab[2]); - auto missionSuccess = "unknown"; - if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { - missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); - } - int missionProbability = reinterpret_cast(vTab[4]); - settlementStruct* targetSettlement = nullptr; - fortStruct* targetFort = nullptr; - if (vTab[5] != nullptr) - { - targetSettlement = reinterpret_cast(vTab[5]); - if ((DWORD)(*targetSettlement).vTable != 0x012FCF34 && (DWORD)(*targetSettlement).vTable != 0x01341F54) - { - targetFort = reinterpret_cast(vTab[5]); - } - } - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - if (!targetFort) - { - (*funk)(character, missionSuccess, missionProbability, targetSettlement, faction, targetFaction, region, characterType, religion, targetReligion); - } - else - { - (*funk)(character, missionSuccess, missionProbability, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); - } - } - return 32; - } - else if (EvType == EventType::orderSpyMissionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto targetFaction = reinterpret_cast(vTab[2]); - auto missionSuccess = "unknown"; - if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { - missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); - } - settlementStruct* targetSettlement = nullptr; - fortStruct* targetFort = nullptr; - if (vTab[4] != nullptr) - { - targetSettlement = reinterpret_cast(vTab[4]); - if ((DWORD)(*targetSettlement).vTable != 0x012FCF34 && (DWORD)(*targetSettlement).vTable != 0x01341F54) - { - targetFort = reinterpret_cast(vTab[4]); - } - } - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - if (!targetFort) - { - (*funk)(character, missionSuccess, targetSettlement, faction, targetFaction, region, characterType, religion, targetReligion); - } - else - { - (*funk)(character, missionSuccess, targetFort, faction, targetFaction, region, characterType, religion, targetReligion); - } - } - return 33; - } - else if (EvType == EventType::agentMissionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto missionSuccess = "unknown"; - if (missionSuccessLvl.find(reinterpret_cast(vTab[2])) != missionSuccessLvl.end()) { - missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[2])); - } - int missionProbability = reinterpret_cast(vTab[3]); - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - - (*funk)(character, missionSuccess, missionProbability, faction, region, characterType, religion); - - } - return 34; - } - else if (EvType == EventType::orderKillMissionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto targetCharacter = reinterpret_cast(vTab[2]); - auto missionSuccess = "unknown"; - if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { - missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); - } - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - - (*funk)(character, missionSuccess, targetCharacter, faction, region, characterType, religion); - - } - return 35; - } - else if (EvType == EventType::diplomacyMissionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto targetFaction = reinterpret_cast(vTab[2]); - auto missionSuccess = "unknown"; - if (missionSuccessLvl.find(reinterpret_cast(vTab[3])) != missionSuccessLvl.end()) { - missionSuccess = missionSuccessLvl.at(reinterpret_cast(vTab[3])); - } - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - - (*funk)(character, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion); - - } - return 36; - } - else if (EvType == EventType::missionEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - const char* missionName = reinterpret_cast(vTab[2]); - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - - (*funk)(character, faction, missionName, region, characterType, religion); - - } - return 37; - } - else if (EvType == EventType::settlementEvent) - { - auto settlement = reinterpret_cast(vTab[1]); - fortStruct* fort; - factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - bool isFort = false; - if ((DWORD)(*settlement).vTable != 0x012FCF34 && (DWORD)(*settlement).vTable != 0x01341F54) - { - fort = (*(*plugData::data.funcs.findFort))(settlement->xCoord, settlement->yCoord); - isFort = true; - faction = fort->faction; - region = gameHelpers::getRegion(fort->regionID); - } - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - if (!isFort) - { - (*funk)(settlement, faction, region, religion); - } - else - { - (*funk)(fort, faction, region, religion); - } - } - return 38; - } - else if (EvType == EventType::stratUnitSettEvent) - { - auto faction = reinterpret_cast(vTab[1]); - auto settlement = reinterpret_cast(vTab[2]); - auto playerUnit = reinterpret_cast(vTab[3]); - eduEntry* edu = playerUnit->eduEntry; - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, settlement, playerUnit, edu, religion); - } - return 39; - } - else if (EvType == EventType::characterUnitSettEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto settlement = reinterpret_cast(vTab[2]); - auto playerUnit = reinterpret_cast(vTab[3]); - const regionStruct* region = getRegion(character); - eduEntry* edu = playerUnit->eduEntry; - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, settlement, playerUnit, edu, region, characterType, religion); - } - return 40; - } - else if (EvType == EventType::characterBuildingEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto settlement = reinterpret_cast(vTab[2]); - building* building = settlement->buildings[settlement->buildingsNum - 1]; - const regionStruct* region = getRegion(character); - const char* characterType = getType(character); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, settlement, building, region, characterType, religion); - } - return 41; - } - else if (EvType == EventType::agentCreatedEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto settlement = reinterpret_cast(vTab[3]); - const char* characterType = getTypeInteger(reinterpret_cast(vTab[2])); - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, settlement, region, characterType, religion); - } - return 42; - } - else if (EvType == EventType::buildingEvent) - { - auto settlement = reinterpret_cast(vTab[1]); - factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* build = reinterpret_cast(vTab[2]); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(settlement, faction, build, region, religion); - } - return 43; - } - else if (EvType == EventType::targetSettlementEvent) - { - auto settlement = reinterpret_cast(vTab[1]); - factionStruct* faction = settlement->faction; - factionStruct* targetFaction = reinterpret_cast(vTab[2]); - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* religion = getReligion(faction->religion); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(settlement, faction, region, religion, targetFaction, targetReligion); - } - return 44; - } - else if (EvType == EventType::namedCharacterRiotEvents) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - auto settlement = reinterpret_cast(vTab[2]); - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* religion = getReligion(faction->religion); - factionStruct* targetFaction = reinterpret_cast(vTab[3]); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, settlement, region, religion, targetFaction, targetReligion); - } - return 45; - } - else if (EvType == EventType::settOccupationEvent) - { - auto character = reinterpret_cast(vTab[1]); - factionStruct* faction = character->faction; - const regionStruct* region = getRegion(character); - const char* religion = getReligion(faction->religion); - factionStruct* targetFaction = reinterpret_cast(vTab[2]); - const char* targetReligion = getReligion(targetFaction->religion); - if (&(*funk) != nullptr) { - (*funk)(character, faction, region, religion, targetFaction, targetReligion); - } - return 46; - } - else if (EvType == EventType::guildEvent) - { - auto settlement = reinterpret_cast(vTab[1]); - factionStruct* faction = settlement->faction; - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - const char* religion = getReligion(faction->religion); - auto guild_handler = reinterpret_cast< guild* >(vTab[2]); - if (&(*funk) != nullptr) { - - (*funk)(settlement, faction, region, religion, guild_handler); - - } - return 47; - } - else if (EvType == EventType::uiEvent) - { - auto name = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - - (*funk)(name); - - } - return 48; - } - else if (EvType == EventType::factionUiEvent) - { - auto faction = reinterpret_cast(vTab[1]); - int name = reinterpret_cast(vTab[2]); - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(faction, religion, name); - } - return 49; - } - else if (EvType == EventType::buildingCompletedEvent) - { - auto faction = reinterpret_cast(vTab[1]); - auto settlement = reinterpret_cast(vTab[2]); - regionStruct* region = gameHelpers::getRegion(settlement->regionID); - building* building = settlement->buildings[settlement->buildingsNum - 1]; - const char* religion = getReligion(faction->religion); - if (&(*funk) != nullptr) { - (*funk)(settlement, faction, building, region, religion); - } - return 50; - } - else if (EvType == EventType::closeMessageEvent) - { - int name = reinterpret_cast(vTab[1]); - if (&(*funk) != nullptr) { - (*funk)(name); - } - return 51; - } else { return 0; @@ -1103,4 +273,3 @@ sol::function* onNavalPreBattleScrollAdviceRequested = nullptr; sol::function* onPreBattleScrollAdviceRequested = nullptr; sol::function* onCollegeOfCardinalsPanelOpen = nullptr; sol::function* onDiplomaticStandingPanelOpen = nullptr; - diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h index 949931002..08dd4bee0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h @@ -144,9 +144,11 @@ class basicFuncs ProcLoader changeFactionName; ProcLoader getFactionName; ProcLoader changeRegionName; + ProcLoader condition; ProcLoader changeRebelsName; ProcLoader deleteFort; ProcLoader createFortXY; + ProcLoader allocateGameMem; ProcLoader createFort; ProcLoader getGameDataAll; @@ -253,7 +255,7 @@ class basicFuncs ProcLoaderremoveBuildingCapability; ProcLoadergetBuildingCapability; ProcLoadergetBuildingCapabilityNum; - ProcLoaderaddBuildingPool; + ProcLoaderaddBuildingPool; ProcLoaderremoveBuildingPool; ProcLoadergetBuildingPool; ProcLoadergetBuildingPoolNum; diff --git a/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.cpp index 008e1af7a..e6f291ba3 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.cpp @@ -102,9 +102,9 @@ namespace buildingStructHelpers return (*(*plugData::data.funcs.getBuildingCapabilityNum))(entry, level); } - void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp) + void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp, const char* condition) { - return (*(*plugData::data.funcs.addBuildingPool))(entry, level, eduIndex, initialSize, gainPerTurn, maxSize, exp); + return (*(*plugData::data.funcs.addBuildingPool))(entry, level, eduIndex, initialSize, gainPerTurn, maxSize, exp, condition); } void removeBuildingPool(edbEntry* entry, int level, int index) diff --git a/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.h index bb6db38e9..c00eebd40 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/buildingStructHelpers.h @@ -87,7 +87,7 @@ namespace buildingStructHelpers void removeBuildingCapability(edbEntry* entry, int level, int index); BuildingLvlCapability* getBuildingCapability(edbEntry* entry, int level, int index); int getBuildingCapabilityNum(edbEntry* entry, int level); - void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp); + void addBuildingPool(edbEntry* entry, int level, int eduIndex, float initialSize, float gainPerTurn, float maxSize, int32_t exp, const char* condition); void removeBuildingPool(edbEntry* entry, int level, int index); recruitPool* getBuildingPool(edbEntry* entry, int level, int index); int getBuildingPoolNum(edbEntry* entry, int level); diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index 45c2dfafc..b43dd1b7d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -123,6 +123,271 @@ namespace gameHelpers return ®ion->neighbourRegions[index]; } + //1 never impelemnted + + unit* getEventAttackingUnit(eventTrigger* eventData) + { + return CallVFunc<2, unit*>(eventData); + } + + unit* getEventDefendingUnit(eventTrigger* eventData) + { + return CallVFunc<3, unit*>(eventData); + } + + general* getEventCharacter(eventTrigger* eventData) + { + return CallVFunc<4, general*>(eventData); + } + + namedCharacter* getEventNamedCharacter(eventTrigger* eventData) + { + return CallVFunc<5, namedCharacter*>(eventData); + } + + namedCharacter* getEventNamedCharacter2(eventTrigger* eventData) + { + return CallVFunc<6, namedCharacter*>(eventData); + } + + //7 status thing + + namedCharacter* getEventTargetNamedCharacter(eventTrigger* eventData) + { + return CallVFunc<8, namedCharacter*>(eventData); + } + + settlementStruct* getEventSettlement(eventTrigger* eventData) + { + return CallVFunc<9, settlementStruct*>(eventData); + } + + settlementStruct* getEventTargetSettlement(eventTrigger* eventData) + { + return CallVFunc<10, settlementStruct*>(eventData); + } + + fortStruct* getEventFort(eventTrigger* eventData) + { + return CallVFunc<11, fortStruct*>(eventData); + } + + factionStruct* getEventFaction(eventTrigger* eventData) + { + return CallVFunc<12, factionStruct*>(eventData); + } + + factionStruct* getEventTargetFaction(eventTrigger* eventData) + { + return CallVFunc<13, factionStruct*>(eventData); + } + + stackStruct* getEventArmy(eventTrigger* eventData) + { + return CallVFunc<14, stackStruct*>(eventData); + } + + int getEventRegion(eventTrigger* eventData) + { + return CallVFunc<15, int>(eventData); + } + + int getEventTargetRegion(eventTrigger* eventData) + { + return CallVFunc<16, int>(eventData); + } + + unit* getEventPlayerUnit(eventTrigger* eventData) + { + return CallVFunc<17, unit*>(eventData); + } + + unit* getEventEnemyUnit(eventTrigger* eventData) + { + return CallVFunc<18, unit*>(eventData); + } + + //19 building_battle + buildingBattle* getBuildingBattle(eventTrigger* eventData) + { + return CallVFunc<19, buildingBattle*>(eventData); + } + + //20 prior_build + buildingInQueue* getPriorBuild(eventTrigger* eventData) + { + return CallVFunc<20, buildingInQueue*>(eventData); + } + + //21 advised_build + + //22 best_finance_option + + //23 resource_description + const char* getResourceDescription(eventTrigger* eventData) + { + return CallVFunc<23, const char*>(eventData); + } + + eduEntry* getEduEntry(eventTrigger* eventData) + { + return CallVFunc<23, eduEntry*>(eventData); + } + + int getEventCharacterType(eventTrigger* eventData) + { + return CallVFunc<24, int>(eventData); + } + + int getEventTargetCharacterType(eventTrigger* eventData) + { + return CallVFunc<25, int>(eventData); + } + + std::unordered_map disasterTypes = { + {0,"earthquake"}, + {1,"flood"}, + {2,"horde"}, + {3,"storm"}, + {4,"volcano"}, + {5,"dustbowl"}, + {6,"locusts"}, + {7,"famine"}, + {8,"plague"}, + {9,"riot"}, + {10,"fire"} + }; + std::unordered_map ransomTypes = { + {0,"ransom"}, + {1,"execute"}, + {2,"release"}, + {3,"cannot_pay_ransom"} + }; + std::unordered_map missionSuccessLvl = { + {0,"not_successful"}, + {1,"slightly_successful"}, + {2,"partly_successful"}, + {3,"highly_successful"} + }; + + const char* getEventType(eventTrigger* eventData) + { + auto eventType = "unknown"; + auto eventNumber = CallVFunc<26, int>(eventData); + if (disasterTypes.find(eventNumber) != disasterTypes.end()) { + eventType = disasterTypes.at(eventNumber); + } + return eventType; + } + + const char* getMissionSuccessLevel(eventTrigger* eventData) + { + auto level = "unknown"; + auto levelNumber = CallVFunc<27, int>(eventData); + if (disasterTypes.find(levelNumber) != disasterTypes.end()) { + level = disasterTypes.at(levelNumber); + } + return level; + } + + int getMissionProbability(eventTrigger* eventData) + { + return CallVFunc<28, int>(eventData);; + } + + //29 mission_details + const char* getMissionDetails(eventTrigger* eventData) + { + return CallVFunc<29, const char*>(eventData); + } + + //30 character_action_advice + + //31 event + int getEventID(eventTrigger* eventData) + { + return CallVFunc<31, int>(eventData);; + } + + //32 unk + + //33 unk2 + + //34 guild handler + guild* getEventGuild(eventTrigger* eventData) + { + return CallVFunc<34, guild*>(eventData); + } + + //35 event_counter + const char* getEventCounter(eventTrigger* eventData) + { + return CallVFunc<35, const char*>(eventData); + } + + //36 sm_position + coordPair* getPosition(eventTrigger* eventData) + { + return CallVFunc<36, coordPair*>(eventData); + } + + //37 get religion + int getReligion(eventTrigger* eventData) + { + return CallVFunc<37, int>(eventData);; + } + + //38 get target religion + int getTargetReligion(eventTrigger* eventData) + { + return CallVFunc<38, int>(eventData);; + } + + //39 amount + float getAmount(eventTrigger* eventData) + { + return CallVFunc<39, float>(eventData);; + } + + //40 crusade + crusade* getCrusade(eventTrigger* eventData) + { + return CallVFunc<40, crusade*>(eventData);; + } + + //41 captured faction info + capturedFactionInfo* getCapturedFactionInfo(eventTrigger* eventData) + { + return CallVFunc<41, capturedFactionInfo*>(eventData);; + } + + //42 ransom type + const char* getRansomType(eventTrigger* eventData) + { + auto ransomType = "unknown"; + auto ransom = CallVFunc<42, int>(eventData); + if (ransomTypes.find(ransom) != ransomTypes.end()) { + ransomType = ransomTypes.at(ransom); + } + return ransomType; + } + + //43 unk + + //44 unk + + //45 unit + unit* getUnit(eventTrigger* eventData) + { + return CallVFunc<45, unit*>(eventData);; + } + + bool condition(const char* condition, const eventTrigger* eventData) + { + return (*(*plugData::data.funcs.condition))(condition, eventData); + } + + bool gameHelpers::getHiddenResource(regionStruct* region, int index) { int resources; @@ -204,7 +469,7 @@ namespace gameHelpers mercPoolUnit* gameHelpers::addMercUnit(mercPool* mercPool, const int idx, const int exp, const int cost, const float repmin, const float repmax, const int maxunits, const float startpool, const float startyear, const float endyear, const int crusading) { - auto* newMerc = new mercPoolUnit; + auto* newMerc = reinterpret_cast(technicalHelpers::allocateGameMem(sizeof(mercPoolUnit))); *newMerc = mercPool->firstUnits.mercPoolUnits[0]; int mercUnitNum = gameHelpers::getMercUnitNum(mercPool); eduEntry* entry = eopEduHelpers::getEduEntry(idx); @@ -224,7 +489,7 @@ namespace gameHelpers newMerc->eventsListEnd = nullptr; newMerc->eventsListEnd2 = nullptr; newMerc->crusading = crusading; - newMerc->mercPoolUnitIndex = (int16_t)mercUnitNum; + newMerc->mercPoolUnitIndex = static_cast(mercUnitNum); newMerc->mercPool = mercPool; mercPoolUnitsPtr* unitptr = &mercPool->firstUnits; int currunits = unitptr->currentPool; @@ -237,8 +502,8 @@ namespace gameHelpers } if ((maxunitsP - currunits) == 0) { - auto* newPtr = new mercPoolUnitsPtr; - newPtr->Maxpool = (unitptr->Maxpool) * 2; + const auto newPtr = reinterpret_cast(technicalHelpers::allocateGameMem(sizeof(mercPoolUnitsPtr))); + newPtr->Maxpool = unitptr->Maxpool * 2; newPtr->currentPool = 0; newPtr->nextUnitsPtr = nullptr; newPtr->prevPoolUnits = unitptr->mercPoolUnits; @@ -246,7 +511,7 @@ namespace gameHelpers unitptr = unitptr->nextUnitsPtr; currunits = 0; } - auto* newArray = new mercPoolUnit[currunits + 1]; + const auto newArray = reinterpret_cast(technicalHelpers::allocateGameMem(sizeof(mercPoolUnitsPtr) * unitptr->Maxpool)); for (int i = 0; i < currunits; i++) { newArray[i] = unitptr->mercPoolUnits[i]; } diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index 0e719ec29..40d35af71 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -11,6 +11,43 @@ namespace gameHelpers std::string callConsole(std::string cmdName, sol::variadic_args va); factionStruct* getFaction(int index); guild* getGuild(unsigned char index); + unit* getEventAttackingUnit(eventTrigger* eventData); + unit* getEventDefendingUnit(eventTrigger* eventData); + namedCharacter* getEventNamedCharacter(eventTrigger* eventData); + namedCharacter* getEventNamedCharacter2(eventTrigger* eventData); + namedCharacter* getEventTargetNamedCharacter(eventTrigger* eventData); + settlementStruct* getEventSettlement(eventTrigger* eventData); + settlementStruct* getEventTargetSettlement(eventTrigger* eventData); + fortStruct* getEventFort(eventTrigger* eventData); + factionStruct* getEventFaction(eventTrigger* eventData); + factionStruct* getEventTargetFaction(eventTrigger* eventData); + stackStruct* getEventArmy(eventTrigger* eventData); + int getEventRegion(eventTrigger* eventData); + int getEventTargetRegion(eventTrigger* eventData); + unit* getEventPlayerUnit(eventTrigger* eventData); + unit* getEventEnemyUnit(eventTrigger* eventData); + buildingBattle* getBuildingBattle(eventTrigger* eventData); + buildingInQueue* getPriorBuild(eventTrigger* eventData); + const char* getResourceDescription(eventTrigger* eventData); + int getEventCharacterType(eventTrigger* eventData); + int getEventTargetCharacterType(eventTrigger* eventData); + const char* getEventType(eventTrigger* eventData); + const char* getMissionSuccessLevel(eventTrigger* eventData); + int getMissionProbability(eventTrigger* eventData); + const char* getMissionDetails(eventTrigger* eventData); + int getEventID(eventTrigger* eventData); + guild* getEventGuild(eventTrigger* eventData); + const char* getEventCounter(eventTrigger* eventData); + coordPair* getPosition(eventTrigger* eventData); + int getReligion(eventTrigger* eventData); + int getTargetReligion(eventTrigger* eventData); + float getAmount(eventTrigger* eventData); + crusade* getCrusade(eventTrigger* eventData); + capturedFactionInfo* getCapturedFactionInfo(eventTrigger* eventData); + const char* getRansomType(eventTrigger* eventData); + unit* getUnit(eventTrigger* eventData); + bool condition(const char* condition, const eventTrigger* eventData); + eduEntry* getEduEntry(eventTrigger* eventData); general* createCharacter(const char* type, factionStruct* fac, int age, const char* name, const char* name2, int subFaction, const char* portrait, int x, int y); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp index f46d7b221..9f089aaa0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp @@ -506,7 +506,7 @@ void luaP::initEopEdu() EDB.addBuildingCapability(eopBuilding, 0, 55, 500, true) -- Add a recruit pool - EDB.addBuildingPool(eopBuilding, 0, 55, 1, 0.1, 2, 0); + EDB.addBuildingPool(eopBuilding, 0, 55, 1, 0.1, 2, 0, ""); -- Create a dummy building and get it sett:createBuilding("market");; --just assuming you have got a sett with some loop or function @@ -733,9 +733,10 @@ void luaP::initEopEdu() @tparam float gainPerTurn Replenishment per turn. @tparam float maxSize Maximum size. @tparam int exp Initial experience. + @tparam string condition Like in export_descr_buildings but without "requires". @usage building = EDB.getBuildingByName("market") - EDB.addBuildingPool(building, 0, 55, 1, 0.1, 2, 0); + EDB.addBuildingPool(building, 0, 55, 1, 0.1, 2, 0, "region_religion catholic 34"); */ tables.EDB.set_function("addBuildingPool", &buildingStructHelpers::addBuildingPool); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index 6ec997a20..e17ce895e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -225,6 +225,7 @@ void luaP::onPluginLoadF() @tfield onLoadingFonts onLoadingFonts @tfield onNewGameStart onNewGameStart @tfield onReadGameDbsAtStart onReadGameDbsAtStart + @tfield onGameInit onGameInit @tfield onClickAtTile onClickAtTile @tfield onCampaignMapLoaded onCampaignMapLoaded @tfield onCreateSaveFile onCreateSaveFile @@ -245,727 +246,592 @@ void luaP::onPluginLoadF() /*** Called at a character's turn start. + Exports: character, faction, regionID, characterType, religion @function onCharacterTurnStart - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterTurnStart(namedChar, faction, region, characterType, religion) + function onCharacterTurnStart(eventData) --something here end */ /*** A captured character has been successfully ransomed back from the enemy. + Exports: character, faction, regionID, characterType, religion @function onCapturedCharacterRansomed - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCapturedCharacterRansomed(namedChar, faction, region, characterType, religion) + function onCapturedCharacterRansomed(eventData) --something here end */ /*** A captured character has been released by the enemy. + Exports: character, faction, regionID, characterType, religion @function onCapturedCharacterReleased - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCapturedCharacterReleased(namedChar, faction, region, characterType, religion) + function onCapturedCharacterReleased(eventData) --something here end */ /*** A character father died of natural causes. + Exports: character, faction, regionID, characterType, religion @function onFatherDiesNatural - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onFatherDiesNatural(namedChar, faction, region, characterType, religion) + function onFatherDiesNatural(eventData) --something here end */ /*** When a battle is about to start but one of the armies withdraws. + Exports: character, faction, regionID, characterType, religion @function onPreBattleWithdrawal - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onPreBattleWithdrawal(namedChar, faction, region, characterType, religion) + function onPreBattleWithdrawal(eventData) --something here end */ /*** When a battle has finished. + Exports: character, faction, regionID, characterType, religion @function onPostBattle - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onPostBattle(namedChar, faction, region, characterType, religion) + function onPostBattle(eventData) --something here end */ /*** A General has hired some mercenaries. + Exports: character, faction, regionID, characterType, religion @function onHireMercenaries - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onHireMercenaries(namedChar, faction, region, characterType, religion) + function onHireMercenaries(eventData) --something here end */ /*** A General has captured a residence such as a fort or watchtower. + Exports: character, faction, regionID, characterType, religion @function onGeneralCaptureResidence - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGeneralCaptureResidence(namedChar, faction, region, characterType, religion) + function onGeneralCaptureResidence(eventData) --something end */ /*** A faction has been destroyed. + Exports: character, faction, regionID, characterType, religion @function onLeaderDestroyedFaction - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderDestroyedFaction(namedChar, faction, region, characterType, religion) + function onLeaderDestroyedFaction(eventData) --something end */ /*** An adoption has been proposed. + Exports: character, faction, regionID, characterType, religion @function onOfferedForAdoption - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onOfferedForAdoption(namedChar, faction, region, characterType, religion) + function onOfferedForAdoption(eventData) --something end */ /*** A lesser general adoption has been proposed (man of the hour event). + Exports: character, faction, regionID, characterType, religion @function onLesserGeneralOfferedForAdoption - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLesserGeneralOfferedForAdoption(namedChar, faction, region, characterType, religion) + function onLesserGeneralOfferedForAdoption(eventData) --something end */ /*** A marriage offer has been proposed. + Exports: character, faction, regionID, characterType, religion @function onOfferedForMarriage - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onOfferedForMarriage(namedChar, faction, region, characterType, religion) + function onOfferedForMarriage(eventData) --something end */ /*** A brother has been adopted. + Exports: character, faction, regionID, characterType, religion @function onBrotherAdopted - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onBrotherAdopted(namedChar, faction, region, characterType, religion) + function onBrotherAdopted(eventData) --something end */ /*** A child is born to the faction leader. + Exports: character, faction, regionID, characterType, religion @function onBirth - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onBirth(namedChar, faction, region, characterType, religion) + function onBirth(eventData) --something end */ /*** A character has come of age. + Exports: character, faction, regionID, characterType, religion @function onCharacterComesOfAge - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterComesOfAge(namedChar, faction, region, characterType, religion) + function onCharacterComesOfAge(eventData) --something end */ /*** A character has married. + Exports: character, faction, regionID, characterType, religion @function onCharacterMarries - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterMarries(namedChar, faction, region, characterType, religion) + function onCharacterMarries(eventData) --something end */ /*** A character has married a princess. + Exports: character, faction, regionID, characterType, religion @function onCharacterMarriesPrincess - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterMarriesPrincess(namedChar, faction, region, characterType, religion) + function onCharacterMarriesPrincess(eventData) --something end */ /*** A marriage alliance is possible. + Exports: character, faction, regionID, characterType, religion @function onMarriageAlliancePossible - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onMarriageAlliancePossible(namedChar, faction, region, characterType, religion) + function onMarriageAlliancePossible(eventData) --something end */ /*** A marriage alliance has been offered. + Exports: character, faction, regionID, characterType, religion @function onMarriageAllianceOffered - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onMarriageAllianceOffered(namedChar, faction, region, characterType, religion) + function onMarriageAllianceOffered(eventData) --something end */ /*** A priest has gone mad. + Exports: character, faction, regionID, characterType, religion @function onPriestBecomesHeretic - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onPriestBecomesHeretic(namedChar, faction, region, characterType, religion) + function onPriestBecomesHeretic(eventData) --something end */ /*** A character is adjacent to a heretic. + Exports: character, faction, regionID, characterType, religion @function onCharacterNearHeretic - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterNearHeretic(namedChar, faction, region, characterType, religion) + function onCharacterNearHeretic(eventData) --something end */ /*** A character is adjacent to a witch. + Exports: character, faction, regionID, characterType, religion @function onCharacterNearWitch - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterNearWitch(namedChar, faction, region, characterType, religion) + function onCharacterNearWitch(eventData) --something end */ /*** A character has been promoted to a cardinal. + Exports: character, faction, regionID, characterType, religion @function onCardinalPromoted - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCardinalPromoted(namedChar, faction, region, characterType, religion) + function onCardinalPromoted(eventData) --something end */ /*** A character has become a father. + Exports: character, faction, regionID, characterType, religion @function onCharacterBecomesAFather - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterBecomesAFather(namedChar, faction, region, characterType, religion) + function onCharacterBecomesAFather(eventData) --something end */ /*** A General and his army has devastated an enemy's fertile land. + Exports: character, faction, regionID, characterType, religion @function onGeneralDevastatesTile - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGeneralDevastatesTile(namedChar, faction, region, characterType, religion) + function onGeneralDevastatesTile(eventData) --something end */ /*** A spying mission has failed and the spy is executed by the target. + Exports: character, faction, regionID, characterType, religion @function onExecutesASpyOnAMission - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onExecutesASpyOnAMission(namedChar, faction, region, characterType, religion) + function onExecutesASpyOnAMission(eventData) --something end */ /*** An assassination mission has failed and the assassin is executed by the target. + Exports: character, faction, regionID, characterType, religion @function onExecutesAnAssassinOnAMission - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onExecutesAnAssassinOnAMission(namedChar, faction, region, characterType, religion) + function onExecutesAnAssassinOnAMission(eventData) --something end */ /*** Someone has had an attempt on their life. + Exports: character, faction, regionID, characterType, religion @function onSufferAssassinationAttempt - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onSufferAssassinationAttempt(namedChar, faction, region, characterType, religion) + function onSufferAssassinationAttempt(eventData) --something end */ /*** Someone has had an attempt on their assets. + Exports: character, faction, regionID, characterType, religion @function onSufferAcquisitionAttempt - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onSufferAcquisitionAttempt(namedChar, faction, region, characterType, religion) + function onSufferAcquisitionAttempt(eventData) --something end */ /*** Someone has had an attempt on their bachelorhood. + Exports: character, faction, regionID, characterType, religion @function onSufferMarriageAttempt - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onSufferMarriageAttempt(namedChar, faction, region, characterType, religion) + function onSufferMarriageAttempt(eventData) --something end */ /*** Someone has had a denouncement attempt. + Exports: character, faction, regionID, characterType, religion @function onSufferDenouncementAttempt - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onSufferDenouncementAttempt(namedChar, faction, region, characterType, religion) + function onSufferDenouncementAttempt(eventData) --something end */ /*** A Faction leader has ordered a sabotage mission. + Exports: character, faction, regionID, characterType, religion @function onLeaderOrderedSabotage - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderOrderedSabotage(namedChar, faction, region, characterType, religion) + function onLeaderOrderedSabotage(eventData) --something end */ /*** Someone has been bribed. + Exports: character, faction, regionID, characterType, religion @function onAcceptBribe - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onAcceptBribe(namedChar, faction, region, characterType, religion) + function onAcceptBribe(eventData) --something end */ /*** Someone has refused a bribe. + Exports: character, faction, regionID, characterType, religion @function onRefuseBribe - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onRefuseBribe(namedChar, faction, region, characterType, religion) + function onRefuseBribe(eventData) --something end */ /*** Insurgence has been provoked. + Exports: character, faction, regionID, characterType, religion @function onInsurrection - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onInsurrection(namedChar, faction, region, characterType, religion) + function onInsurrection(eventData) --something end */ /*** A Faction leader has ordered a diplomacy mission. + Exports: character, faction, regionID, characterType, religion @function onLeaderOrderedDiplomacy - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderOrderedDiplomacy(namedChar, faction, region, characterType, religion) + function onLeaderOrderedDiplomacy(eventData) --something end */ /*** A new admiral has been created for a new ship. + Exports: stratCharacter, character, faction, regionID, characterType, religion @function onNewAdmiralCreated - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onNewAdmiralCreated(namedChar, faction, region, characterType, religion) + function onNewAdmiralCreated(eventData) --something end */ /*** A building has been destroyed. + Exports: character, faction, regionID, characterType, religion @function onGovernorBuildingDestroyed - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorBuildingDestroyed(namedChar, faction, region, characterType, religion) + function onGovernorBuildingDestroyed(eventData) --something end */ /*** Games have been thrown. + Exports: character, faction, regionID, characterType, religion @function onGovernorThrowGames - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorThrowGames(namedChar, faction, region, characterType, religion) + function onGovernorThrowGames(eventData) --something end */ /*** Races have been thrown. + Exports: character, faction, regionID, characterType, religion @function onGovernorThrowRaces - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorThrowRaces(namedChar, faction, region, characterType, religion) + function onGovernorThrowRaces(eventData) --something end */ /*** The player has selected a character. + Exports: character, targetSettlement, faction, regionID, characterType, religion @function onCharacterSelected - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterSelected(namedChar, faction, region, characterType, religion) + function onCharacterSelected(eventData) --something end */ /*** The player has selected an enemy character. + Exports: character, faction, regionID, characterType, religion @function onEnemyCharacterSelected - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onEnemyCharacterSelected(namedChar, faction, region, characterType, religion) + function onEnemyCharacterSelected(eventData) --something end */ /*** The player has selected a position beyond the character's extents. + Exports: character, faction, regionID, characterType, religion @function onMultiTurnMove - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onMultiTurnMove(namedChar, faction, region, characterType, religion) + function onMultiTurnMove(eventData) --something end */ /*** The player has opened the panel for the selected character. + Exports: character, faction, regionID, characterType, religion @function onCharacterPanelOpen - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterPanelOpen(namedChar, faction, region, characterType, religion) + function onCharacterPanelOpen(eventData) --something end */ /*** A mission has been completed. + Exports: character, faction, regionID, characterType, missionDetails, religion @function onLeaderMissionSuccess - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam string missionName - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderMissionSuccess(namedChar, faction, missionName, region, characterType, religion) + function onLeaderMissionSuccess(eventData) --something end */ /*** A mission has failed. + Exports: character, faction, regionID, characterType, missionDetails, religion @function onLeaderMissionFailed @tparam namedCharacter namedChar @@ -983,921 +849,690 @@ void luaP::onPluginLoadF() /*** A General has been sent on Crusade/Jihad. + Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade @function onGeneralJoinCrusade - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralJoinCrusade(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) + function onGeneralJoinCrusade(eventData) --something end */ /*** A General has left a Crusade/Jihad. + Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade @function onGeneralAbandonCrusade - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralAbandonCrusade(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) + function onGeneralAbandonCrusade(eventData) --something end */ /*** A General has arrived in the Crusade/Jihad target region. + Exports: character, targetSettlement, faction, targetFaction, army, regionID, targetRegionID, characterType, religion, targetReligion, crusade @function onGeneralArrivesCrusadeTargetRegion - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralArrivesCrusadeTargetRegion(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) + function onGeneralArrivesCrusadeTargetRegion(eventData) --something end */ /*** A General has taken the Crusade/Jihad target settlement. + Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade @function onGeneralTakesCrusadeTarget - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralTakesCrusadeTarget(namedChar, faction, targetSettlement, targetFaction, targetRegion, characterType, religion, targetReligion) + function onGeneralTakesCrusadeTarget(eventData) --something end */ /*** A Character has finished its turn. + Exports: character, settlement, faction, regionID, characterType, religion @function onCharacterTurnEnd - @tparam namedCharacter namedChar - @tparam settlementStruct|nil settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterTurnEnd(namedChar, faction, region, characterType, religion) + function onCharacterTurnEnd(eventData) --something end */ /*** A Character has finished its turn in a settlement. + Exports: character, settlement, faction, regionID, characterType, religion @function onCharacterTurnEndInSettlement - @tparam namedCharacter namedChar - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterTurnEndInSettlement(namedChar, settlement, faction, region, characterType, religion) + function onCharacterTurnEndInSettlement(eventData) --something end */ /*** The character has been made the faction leader. + Exports: character, faction, regionID, characterType, religion @function onBecomesFactionLeader - @tparam namedCharacter leader - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onBecomesFactionLeader(leader, faction, region, characterType, religion) - print("Function: onBecomesFactionLeader()\n\tLeader: "..leader.fullName) + function onBecomesFactionLeader(eventData) + print("Function: onBecomesFactionLeader()\n\tLeader: ".. eventData.character.fullName) end */ /*** The character is no longer faction leader. + Exports: character, faction, regionID, characterType, religion @function onCeasedFactionLeader - @tparam namedCharacter leader - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCeasedFactionLeader(leader, faction, region, characterType, religion) + function onCeasedFactionLeader(eventData) --something end */ /*** The character has been made a faction heir. + Exports: character, faction, regionID, characterType, religion @function onBecomesFactionHeir - @tparam namedCharacter heir - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onBecomesFactionHeir(heir, faction, region, characterType, religion) - print("Function: onBecomesFactionHeir()\n\tHeir: "..heir.fullName) + function onBecomesFactionHeir(eventData) + print("Function: onBecomesFactionHeir()\n\tHeir: ".. eventData.character.fullName) end */ /*** The character is no longer faction heir. + Exports: character, faction, regionID, characterType, religion @function onCeasedFactionHeir - @tparam namedCharacter heir - @tparam factionStruct faction - @tparam regionStruct region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCeasedFactionHeir(heir, faction, region, characterType, religion) - print("Function: onCeasedFactionHeir()\n\tHeir: "..heir.fullName) + function onCeasedFactionHeir(eventData) + print("Function: onCeasedFactionHeir()\n\tHeir: ".. eventData.character.fullName) end */ /*** A character has been injured by a disaster. + Exports: character, faction, regionID, disasterType, characterType, religion + disasterTypes = earthquake, flood, horde, storm, volcano, dustbowl, locusts, famine, plague, riot, fire @function onCharacterDamagedByDisaster - @tparam string eventType (earthquake, flood, horde, storm, volcano, dustbowl, locusts, famine, plague, riot, fire) - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onCharacterDamagedByDisaster(eventType, namedChar, faction, region, characterType, religion) + function onCharacterDamagedByDisaster(eventData) --something end */ /*** A General has captured a settlement. + Exports: character, settlement, targetSettlement, faction, targetFaction, regionID, characterType, religion @function onGeneralCaptureSettlement - @tparam namedCharacter namedChar - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralCaptureSettlement(namedChar, settlement, faction, targetFaction, region, characterType, religion, targetReligion) + function onGeneralCaptureSettlement(eventData) --something end */ /*** An assault has taken place. + Exports: character, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion @function onGeneralAssaultsResidence - @tparam namedCharacter namedChar - @tparam settlementStruct|fortStruct residence - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct region - @tparam string characterType - @tparam string religion - @tparam string targetReligion - @tparam bool isFort + @tparam eventTrigger eventData @usage - function onGeneralAssaultsResidence(namedChar, residence, faction, targetFaction, region, characterType, religion, targetReligion, isFort) + function onGeneralAssaultsResidence(eventData) --something end */ /*** An assault has taken place. + Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion @function onGeneralAssaultsGeneral - @tparam namedCharacter namedChar - @tparam namedCharacter targetNamedChar - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string targetCharacterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralAssaultsGeneral(namedChar, targetNamedChar, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion) + function onGeneralAssaultsGeneral(eventData) --something end */ /*** - A general on crusade/jihad has been attacked by other character (it includes crusading generals attacked in a residence or on navy and generals attacked by spotted and killed assassin). - - @function onCharacterAttacksCrusadingGeneral - @tparam namedCharacter namedChar - @tparam namedCharacter targetNamedChar - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string targetCharacterType - @tparam string religion - @tparam string targetReligion + A general on crusade/jihad has been attacked by other character (it includes crusading generals attacked in a residence or on navy and generals attacked by spotted and killed assassin). + Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion + + @function onCharacterAttacksCrusadingGeneral + @tparam eventTrigger eventData @usage - function onCharacterAttacksCrusadingGeneral(namedChar, targetNamedChar, faction, targetFaction, region, characterType, targetCharacterType, religion, targetReligion) + function onCharacterAttacksCrusadingGeneral(eventData) --something end */ /*** A General of a captor faction has made a ransom decision. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType @function onGeneralPrisonersRansomedCaptor - @tparam namedCharacter namedChar - @tparam capturedFactionInfo capInfo - @tparam string ransomType - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralPrisonersRansomedCaptor(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + function onGeneralPrisonersRansomedCaptor(eventData) --something end */ /*** A General of a captive faction has made a ransom decision. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType @function onGeneralPrisonersRansomedCaptive - @tparam namedCharacter namedChar - @tparam capturedFactionInfo capInfo - @tparam string ransomType - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGeneralPrisonersRansomedCaptive(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + function onGeneralPrisonersRansomedCaptive(eventData) --something end */ /*** A captor faction has made a ransom decision. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType @function onFactionLeaderPrisonersRansomedCaptor - @tparam namedCharacter namedChar - @tparam capturedFactionInfo capInfo - @tparam string ransomType - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionLeaderPrisonersRansomedCaptor(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + function onFactionLeaderPrisonersRansomedCaptor(eventData) --something end */ /*** A captive faction has made a ransom decision. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion, captureInfo, ransomType @function onFactionLeaderPrisonersRansomedCaptive - @tparam namedCharacter namedChar - @tparam capturedFactionInfo capInfo - @tparam string ransomType - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionLeaderPrisonersRansomedCaptive(character, capInfo, ransomType, faction, targetFaction, region, characterType, religion, targetReligion) + function onFactionLeaderPrisonersRansomedCaptive(eventData) --something end */ /*** A spy mission has completed. May also export fort or settlement if target was a garrison residence. + Exports: character, settlement, fort, faction, targetFaction, regionID, characterType, missionSuccessLevel, missionProbability, religion, targetReligion @function onSpyMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam settlementStruct|fortStruct|nil targetResidence - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onSpyMission(namedChar, missionSuccess, missionProbability, targetResidence, faction, targetFaction, region, characterType, religion, targetReligion) + function onSpyMission(eventData) --something end */ /*** An assassination mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion @function onAssassinationMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onAssassinationMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + function onAssassinationMission(eventData) --something end */ /*** An acquisition mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion @function onAcquisitionMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onAcquisitionMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + function onAcquisitionMission(eventData) --something end */ /*** A marriage mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion @function onMarriageMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onMarriageMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + function onMarriageMission(eventData) --something end */ /*** A denouncement mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion @function onDenouncementMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onDenouncementMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + function onDenouncementMission(eventData) --something end */ /*** A sabotage mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion @function onSabotageMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam int missionProbability - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onSabotageMission(namedChar, missionSuccess, missionProbability, faction, region, characterType, religion) + function onSabotageMission(eventData) --something end */ /*** A bribery mission has completed. + Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion @function onBriberyMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onBriberyMission(namedChar, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion) + function onBriberyMission(eventData) --something end */ /*** - A bribery mission has completed. + A diplomacy mission has completed. + Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion @function onDiplomacyMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onDiplomacyMission(namedChar, missionSuccess, faction, targetFaction, region, characterType, religion, targetReligion) + function onDiplomacyMission(eventData) --something end */ /*** A Faction leader has ordered a spying mission. + Exports: character, settlement, fort, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion @function onLeaderOrderedSpyingMission - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam settlementStruct|fortStruct|nil targetResidence - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onLeaderOrderedSpyingMission(namedChar, missionSuccess, targetResidence, faction, targetFaction, region, characterType, religion, targetReligion) + function onLeaderOrderedSpyingMission(eventData) --something end */ /*** A Faction leader has ordered an assassination mission. + Exports: character, targetCharacter, faction, regionID, characterType, missionSuccessLevel, religion @function onLeaderOrderedAssassination - @tparam namedCharacter namedChar - @tparam string missionSuccess - @tparam namedCharacter targetCharacter - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderOrderedAssassination(namedChar, missionSuccess, targetCharacter, faction, region, characterType, religion) + function onLeaderOrderedAssassination(eventData) --something end */ /*** A Faction leader has ordered a bribery mission. + Exports: character, faction, regionID, characterType, religion @function onLeaderOrderedBribery - @tparam namedCharacter namedChar - @tparam namedCharacter targetCharacter - @tparam factionStruct faction - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderOrderedBribery(namedChar, missionSuccess, targetCharacter, faction, region, characterType, religion) + function onLeaderOrderedBribery(eventData) --something end */ /*** A settlement is being processed for the start of its faction's turn. + Exports: settlement, faction, regionID, religion @function onSettlementTurnStart - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementTurnStart(settlement, faction, region, religion) + function onSettlementTurnStart(eventData) --something end */ /*** A settlement is no longer garrisoned. + Exports: settlement, faction, regionID, religion @function onUngarrisonedSettlement - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onUngarrisonedSettlement(settlement, faction, region, religion) + function onUngarrisonedSettlement(eventData) --something end */ /*** A settlement has been upgraded. + Exports: settlement, faction, regionID, religion @function onSettlementUpgraded - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementUpgraded(settlement, faction, region, religion) + function onSettlementUpgraded(eventData) --something end */ /*** A settlement has been converted. + Exports: settlement, faction, regionID, religion @function onSettlementConverted - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementConverted(settlement, faction, region, religion) + function onSettlementConverted(eventData) --something end */ /*** Siege equipment has been completed by one of the besieging armies. + Exports: settlement, faction, regionID, religion @function onSiegeEquipmentCompleted - @tparam settlementStruct|fortStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSiegeEquipmentCompleted(settlement, faction, region, religion) + function onSiegeEquipmentCompleted(eventData) --something end */ /*** A Settlement is being processed for the end of its faction's turn. + Exports: settlement, faction, regionID, religion @function onSettlementTurnEnd - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementTurnEnd(settlement, faction, region, religion) + function onSettlementTurnEnd(eventData) --something end */ /*** The player has selected a settlement. + Exports: settlement, faction, regionID, religion @function onSettlementSelected - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementSelected(settlement, faction, region, religion) + function onSettlementSelected(eventData) --something end */ /*** The player has opened the panel for the selected settlement. + Exports: settlement, faction, regionID, religion @function onSettlementPanelOpen - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementPanelOpen(settlement, faction, region, religion) + function onSettlementPanelOpen(eventData) --something end */ /*** The player has opened a recruitment panel. + Exports: settlement, faction, regionID, religion @function onRecruitmentPanelOpen - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onRecruitmentPanelOpen(settlement, faction, region, religion) + function onRecruitmentPanelOpen(eventData) --something end */ /*** The player has opened a construction panel. + Exports: settlement, faction, regionID, religion @function onConstructionPanelOpen - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onConstructionPanelOpen(settlement, faction, region, religion) + function onConstructionPanelOpen(eventData) --something end */ /*** The player has opened a trade panel. + Exports: settlement, faction, regionID, religion @function onTradePanelOpen - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onTradePanelOpen(settlement, faction, region, religion) + function onTradePanelOpen(eventData) --something end */ /*** The player has requested advice on the settlement scroll. + Exports: settlement, faction, regionID, resourceDescription, religion @function onSettlementScrollAdviceRequested - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onSettlementScrollAdviceRequested(settlement, faction, region, religion) + function onSettlementScrollAdviceRequested(eventData) --something end */ /*** A guild has been created/upgraded. + Exports: settlement, faction, regionID, resourceDescription, guild, religion @function onGuildUpgraded - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam guild guild + @tparam eventTrigger eventData @usage - function onGuildUpgraded(settlement, faction, region, religion, guild) + function onGuildUpgraded(eventData) --something end */ /*** A guild has been destroyed. + Exports: settlement, faction, regionID, guild, religion @function onGuildDestroyed - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam guild guild + @tparam eventTrigger eventData @usage - function onGuildDestroyed(settlement, faction, region, religion, guild) + function onGuildDestroyed(eventData) --something end */ /*** A settlement has been captured and occupied. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion @function onOccupySettlement - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onOccupySettlement(namedChar, faction, region, religion, targetFaction, targetReligion) + function onOccupySettlement(eventData) --something end */ /*** A settlement has been captured and sacked. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion @function onSackSettlement - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onSackSettlement(namedChar, faction, region, religion, targetFaction, targetReligion) + function onSackSettlement(eventData) --something end */ /*** A settlement has been captured and some of its population has been decimated. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion @function onExterminatePopulation - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion - + @tparam eventTrigger eventData + @usage - function onExterminatePopulation(namedChar, faction, region, religion, targetFaction, targetReligion) + function onExterminatePopulation(eventData) --something end */ /*** A settlement has rioted. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion @function onCityRiots - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onCityRiots(settlement, faction, region, religion, targetFaction, targetReligion) + function onCityRiots(eventData) --something end */ /*** A settlement has been given to another faction. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion @function onGiveSettlement - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGiveSettlement(settlement, faction, region, religion, targetFaction, targetReligion) + function onGiveSettlement(eventData) --something end */ /*** A settlement has rebelled. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion @function onCityRebels - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onCityRebels(settlement, faction, region, religion, targetFaction, targetReligion) + function onCityRebels(eventData) --something end */ /*** A settlement has been razed. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion @function onCitySacked - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onCitySacked(settlement, faction, region, religion, targetFaction, targetReligion) + function onCitySacked(eventData) --something end */ /*** A settlement has rioted. + Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion @function onGovernorCityRiots - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGovernorCityRiots(namedChar, faction, settlement, region, religion, targetFaction, targetReligion) + function onGovernorCityRiots(eventData) --something end */ /*** A settlement has rebelled. + Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion @function onGovernorCityRebels - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam regionStruct region - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onGovernorCityRebels(namedChar, faction, settlement, region, religion, targetFaction, targetReligion) + function onGovernorCityRebels(eventData) --something end */ @@ -1906,9 +1541,10 @@ void luaP::onPluginLoadF() The player has abandoned a show me scipt. @function onAbandonShowMe + @tparam eventTrigger eventData @usage - function onAbandonShowMe() + function onAbandonShowMe(eventData) --something here end */ @@ -1917,9 +1553,10 @@ void luaP::onPluginLoadF() A strat map game has been reloaded. @function onGameReloaded + @tparam eventTrigger eventData @usage - function onGameReloaded() + function onGameReloaded(eventData) --something here end */ @@ -1928,9 +1565,10 @@ void luaP::onPluginLoadF() The plaza is being captured. @function onBattleWinningPlaza + @tparam eventTrigger eventData @usage - function onBattleWinningPlaza() + function onBattleWinningPlaza(eventData) --something here end */ @@ -1939,9 +1577,10 @@ void luaP::onPluginLoadF() The plaza capture has been stopped. @function onBattleStopsWinningPlaza + @tparam eventTrigger eventData @usage - function onBattleStopsWinningPlaza() + function onBattleStopsWinningPlaza(eventData) --something here end */ @@ -1950,9 +1589,10 @@ void luaP::onPluginLoadF() The enemy will have captured the plaza in 30s. @function onBattleDominatingPlaza + @tparam eventTrigger eventData @usage - function onBattleDominatingPlaza() + function onBattleDominatingPlaza(eventData) --something here end */ @@ -1961,9 +1601,10 @@ void luaP::onPluginLoadF() A siege engine is now unmanned. @function onBattngineUnmanned + @tparam eventTrigger eventData @usage - function onBattngineUnmanned() + function onBattngineUnmanned(eventData) --something here end */ @@ -1972,9 +1613,10 @@ void luaP::onPluginLoadF() Half of the player's army has been destroyed. @function onBattlePlayerArmyHalfDestroyed + @tparam eventTrigger eventData @usage - function onBattlePlayerArmyHalfDestroyed() + function onBattlePlayerArmyHalfDestroyed(eventData) --something here end */ @@ -1983,9 +1625,10 @@ void luaP::onPluginLoadF() Half of the enemy's army has been destroyed. @function onBattnemyArmyHalfDestroyed + @tparam eventTrigger eventData @usage - function onBattnemyArmyHalfDestroyed() + function onBattnemyArmyHalfDestroyed(eventData) --something here end */ @@ -1994,9 +1637,10 @@ void luaP::onPluginLoadF() The battle has finished. @function onBattleFinished + @tparam eventTrigger eventData @usage - function onBattleFinished() + function onBattleFinished(eventData) --something here end */ @@ -2005,9 +1649,10 @@ void luaP::onPluginLoadF() Half of an army has been destroyed. @function onBattleArmyHalfDestroyed + @tparam eventTrigger eventData @usage - function onBattleArmyHalfDestroyed() + function onBattleArmyHalfDestroyed(eventData) --something here end */ @@ -2016,20 +1661,22 @@ void luaP::onPluginLoadF() The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used. @function onEscPressed + @tparam eventTrigger eventData @usage - function onEscPressed() + function onEscPressed(eventData) --something here end */ /*** - The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used. + The player has been issued with advice by a script. @function onScriptedAdvice + @tparam eventTrigger eventData @usage - function onScriptedAdvice() + function onScriptedAdvice(eventData) --something here end */ @@ -2038,9 +1685,10 @@ void luaP::onPluginLoadF() The player has requested advice on the naval prebattle scroll. @function onNavalPreBattleScrollAdviceRequested + @tparam eventTrigger eventData @usage - function onNavalPreBattleScrollAdviceRequested() + function onNavalPreBattleScrollAdviceRequested(eventData) --something here end */ @@ -2049,9 +1697,10 @@ void luaP::onPluginLoadF() The player has requested advice on the prebattle scroll. @function onPreBattleScrollAdviceRequested + @tparam eventTrigger eventData @usage - function onPreBattleScrollAdviceRequested() + function onPreBattleScrollAdviceRequested(eventData) --something here end */ @@ -2060,9 +1709,10 @@ void luaP::onPluginLoadF() The player has opened the college of cardinals panel. @function onCollegeOfCardinalsPanelOpen + @tparam eventTrigger eventData @usage - function onCollegeOfCardinalsPanelOpen() + function onCollegeOfCardinalsPanelOpen(eventData) --something here end */ @@ -2071,9 +1721,10 @@ void luaP::onPluginLoadF() The player has opened the diplomatic standing panel. @function onDiplomaticStandingPanelOpen + @tparam eventTrigger eventData @usage - function onDiplomaticStandingPanelOpen() + function onDiplomaticStandingPanelOpen(eventData) --something here end */ @@ -2082,11 +1733,10 @@ void luaP::onPluginLoadF() An idle unit is under missile fire. @function onBattlePlayerUnderAttackIdle - @tparam stackStruct army - @tparam unit playerUnit + @tparam eventTrigger eventData @usage - function onBattlePlayerUnderAttackIdle(army, playerUnit) + function onBattlePlayerUnderAttackIdle(eventData) --something here end */ @@ -2095,9 +1745,10 @@ void luaP::onPluginLoadF() A team has gained the advantage in combat. @function onBattleWinningCombat + @tparam eventTrigger eventData @usage - function onBattleWinningCombat() + function onBattleWinningCombat(eventData) --something here end */ @@ -2106,9 +1757,10 @@ void luaP::onPluginLoadF() The whole army is tired. @function onBattleArmyTired + @tparam eventTrigger eventData @usage - function onBattleArmyTired() + function onBattleArmyTired(eventData) --something here end */ @@ -2117,1083 +1769,1038 @@ void luaP::onPluginLoadF() A different team is now the strongest. @function onBattleTideofBattle + @tparam eventTrigger eventData @usage - function onBattleTideofBattle() + function onBattleTideofBattle(eventData) --something here end */ /*** A unit has gone berserk. + Exports: unit @function onBattleUnitGoesBerserk - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleUnitGoesBerserk(unit) + function onBattleUnitGoesBerserk(eventData) --something here end */ /*** A siege engine has been destroyed. + Exports: unit @function onBattleSiegeEngineDestroyed - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleSiegeEngineDestroyed(unit) + function onBattleSiegeEngineDestroyed(eventData) --something here end */ /*** A siege engine has docked with a wall. + Exports: unit @function onBattleSiegeEngineDocksWall - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleSiegeEngineDocksWall(unit) + function onBattleSiegeEngineDocksWall(eventData) --something here end */ /*** An engine has started attacking a gate. + Exports: unit @function onBattleGatesAttackedByEngine - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleGatesAttackedByEngine(unit) + function onBattleGatesAttackedByEngine(eventData) --something here end */ /*** An engine has destroyed a gate. + Exports: unit @function onBattleGatesDestroyedByEngine - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleGatesDestroyedByEngine(unit) + function onBattleGatesDestroyedByEngine(eventData) --something here end */ /*** A siege engine has knocked down a wall. + Exports: unit @function onBattleWallsBreachedByEngine - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleWallsBreachedByEngine(unit) + function onBattleWallsBreachedByEngine(eventData) --something here end */ /*** A wall has been captured. + Exports: unit @function onBattleWallsCaptured - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleWallsCaptured(unit) + function onBattleWallsCaptured(eventData) --something here end */ /*** A unit has routed. + Exports: unit @function onBattleUnitRouts - @tparam unit unit + @tparam eventTrigger eventData @usage - function onBattleUnitRouts(unit) + function onBattleUnitRouts(eventData) --something here end */ /*** A unit has been disbanded. + Exports: faction, playerUnit, eduEntry, religion @function onUnitDisbanded - @tparam factionStruct faction - @tparam unit unit - @tparam eduEntry entry - @tparam string religion + @tparam eventTrigger eventData @usage - function onUnitDisbanded(faction, unit, entry, religion) + function onUnitDisbanded(eventData) --something here end */ /*** A unit has been trained. + Exports: settlement, faction, playerUnit, eduEntry, religion @function onUnitTrained - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam unit unit - @tparam eduEntry entry - @tparam string religion + @tparam eventTrigger eventData @usage - function onUnitTrained(faction, settlement, unit, entry, religion) + function onUnitTrained(eventData) --something here end */ /*** A unit has been trained. + Exports: character, settlement, faction, regionID, playerUnit, eduEntry, characterType, religion @function onGovernorUnitTrained - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam unit unit - @tparam eduEntry entry - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorUnitTrained(namedChar, faction, settlement, unit, entry, region, characterType, religion) + function onGovernorUnitTrained(eventData) --something here end */ /*** A building has been completed. + Exports: character, settlement, faction, regionID, priorBuild, characterType, religion @function onGovernorBuildingCompleted - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam building building - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorBuildingCompleted(namedChar, faction, settlement, building, region, characterType, religion) + function onGovernorBuildingCompleted(eventData) --something here end */ /*** An agent has been trained. + Exports: character, settlement, faction, regionID, characterType, religion @function onAgentCreated - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onAgentCreated(namedChar, faction, settlement, region, characterType, religion) + function onAgentCreated(eventData) --something here end */ /*** An agent has been trained. + Exports: character, settlement, faction, regionID, characterType, religion @function onGovernorAgentCreated - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam settlementStruct settlement - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onGovernorAgentCreated(namedChar, faction, settlement, building, region, characterType, religion) + function onGovernorAgentCreated(eventData) --something here end */ /*** A building has been destroyed. + Exports: settlement, faction, regionID, resourceDescription, religion @function onBuildingDestroyed - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam string buildingName - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onBuildingDestroyed(settlement, faction, buildingName, region, religion) + function onBuildingDestroyed(eventData) --something here end */ /*** A building has been added to the construction queue. + Exports: settlement, faction, regionID, resourceDescription, religion @function onAddedToBuildingQueue - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam string buildingName - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onAddedToBuildingQueue(settlement, faction, buildingName, region, religion) + function onAddedToBuildingQueue(eventData) --something here end */ /*** A building has been completed. + Exports: settlement, faction, priorBuild, religion @function onBuildingCompleted - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam building building - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onBuildingCompleted(settlement, faction, buildingName, region, religion) + function onBuildingCompleted(eventData) --something here end */ /*** The player has requested building advice. + Exports: settlement, faction, regionID, religion @function onRequestBuildingAdvice - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam string buildingName - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onRequestBuildingAdvice(settlement, faction, buildingName, region, religion) + function onRequestBuildingAdvice(eventData) --something here end */ /*** The player has requested training advice. + Exports: settlement, faction, regionID, religion @function onRequestTrainingAdvice - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam string resource - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onRequestTrainingAdvice(settlement, faction, resource, region, religion) + function onRequestTrainingAdvice(eventData) --something here end */ /*** A unit has been added to the training queue. + Exports: settlement, faction, regionID, resourceDescription, religion @function onAddedToTrainingQueue - @tparam settlementStruct settlement - @tparam factionStruct faction - @tparam string unitName - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onAddedToTrainingQueue(settlement, faction, unitName, region, religion) + function onAddedToTrainingQueue(eventData) --something here end */ /*** An army has been entirely routed. + Exports: army @function onBattleArmyRouted - @tparam stackStruct army + @tparam eventTrigger eventData @usage - function onBattleArmyRouted(army) + function onBattleArmyRouted(eventData) --something here end */ /*** A reinforcing army has arrived on the battlefield. + Exports: army @function onBattleReinforcementsArrive - @tparam stackStruct army + @tparam eventTrigger eventData @usage - function onBattleReinforcementsArrive(army) + function onBattleReinforcementsArrive(eventData) --something here end */ /*** The player has requested mercenaries advice. + Exports: army @function onRequestMercenariesAdvice - @tparam stackStruct army + @tparam eventTrigger eventData @usage - function onRequestMercenariesAdvice(army) + function onRequestMercenariesAdvice(eventData) --something here end */ /*** The player has clicked on a button. + Exports: resourceDescription @function onButtonPressed - @tparam string name + @tparam eventTrigger eventData @usage - function onButtonPressed(name) + function onButtonPressed(eventData) --something here end */ /*** The player triggered a keyboard shortcut. + Exports: resourceDescription @function onShortcutTriggered - @tparam string name + @tparam eventTrigger eventData @usage - function onShortcutTriggered(name) + function onShortcutTriggered(eventData) --something here end */ /*** A special UI Element is visible. + Exports: resourceDescription @function onUIElementVisible - @tparam string name + @tparam eventTrigger eventData @usage - function onUIElementVisible(name) + function onUIElementVisible(eventData) --something here end */ /*** The player opened a scroll. + Exports: resourceDescription @function onScrollOpened - @tparam string name + @tparam string eventData @usage - function onScrollOpened(name) + function onScrollOpened(eventData) --something here end */ /*** The player closed a scroll. + Exports: resourceDescription @function onScrollClosed - @tparam string name + @tparam eventTrigger eventData @usage - function onScrollClosed(name) + function onScrollClosed(eventData) --something here end */ /*** The player has requested advice on a scroll. + Exports: resourceDescription @function onScrollAdviceRequested - @tparam string name + @tparam eventTrigger eventData @usage - function onScrollAdviceRequested(name) + function onScrollAdviceRequested(eventData) --something here end */ /*** The player has suppressed a piece of advice. + Exports: resourceDescription @function onAdviceSupressed - @tparam string name + @tparam eventTrigger eventData @usage - function onAdviceSupressed(name) + function onAdviceSupressed(eventData) --something here end */ /*** A general has been routed. + Exports: stratCharacter, character @function onBattleGeneralRouted - @tparam character general - @tparam namedCharacter namedChar + @tparam eventTrigger eventData @usage - function onBattleGeneralRouted(general, namedChar) + function onBattleGeneralRouted(eventData) --something here end */ /*** A general has been killed. + Exports: stratCharacter @function onBattleGeneralKilled - @tparam character general - @tparam namedCharacter namedChar + @tparam eventTrigger eventData @usage - function onBattleGeneralKilled(general, namedChar) + function onBattleGeneralKilled(eventData) --something here end */ /*** A Crusade/Jihad has been called. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade @function onCrusadeCalled - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onCrusadeCalled(targetSettlement, targetFaction, targetRegion, targetReligion) + function onCrusadeCalled(eventData) --something here end */ /*** The Pope has accepted the player's crusade target. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade @function onPopeAcceptsCrusadeTarget - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onPopeAcceptsCrusadeTarget(targetSettlement, targetFaction, targetRegion, targetReligion) + function onPopeAcceptsCrusadeTarget(eventData) --something here end */ /*** The Pope has rejected the player's crusade target. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade @function onPopeRejectsCrusadeTarget - @tparam settlementStruct targetSettlement - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onPopeRejectsCrusadeTarget(targetSettlement, targetFaction, targetRegion, targetReligion) + function onPopeRejectsCrusadeTarget(eventData) --something here end */ /*** A Crusade/Jihad has ended. + Exports: targetSettlement, targetRegionID, crusade @function onCrusadeEnds - @tparam settlementStruct targetSettlement - @tparam regionStruct targetRegion + @tparam eventTrigger eventData @usage - function onCrusadeEnds(targetSettlement, targetRegion) + function onCrusadeEnds(eventData) --something here end */ /*** Called before the faction's turn starts. + Exports: faction, religion @function onPreFactionTurnStart - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onPreFactionTurnStart(faction, religion) + function onPreFactionTurnStart(eventData) --something here end */ /*** Called at a faction's turn start. + Exports: faction, religion @function onFactionTurnStart - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFactionTurnStart(faction, religion) + function onFactionTurnStart(eventData) --something here end */ /*** Called after faction changes to a new capital. + Exports: faction, religion @function onFactionNewCapital - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFactionNewCapital(faction, religion) + function onFactionNewCapital(eventData) newCapital=fac.capital(); end */ /*** Called at a faction's turn end. + Exports: faction, religion @function onFactionTurnEnd - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFactionTurnEnd(faction, religion) + function onFactionTurnEnd(eventData) --something here end */ /*** A Faction has voted for the new pope. + Exports: faction, religion @function onVotedForPope - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onVotedForPope(faction, religion) + function onVotedForPope(eventData) --something here end */ /*** A Faction has been excommunicated. + Exports: faction, religion @function onFactionExcommunicated - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFactionExcommunicated(faction, religion) + function onFactionExcommunicated(eventData) --something here end */ /*** A Faction has formed a horde. + Exports: faction, religion @function onHordeFormed - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onHordeFormed(faction, religion) + function onHordeFormed(eventData) --something here end */ /*** A cardinal has been removed from the game. + Exports: faction, religion @function onCardinalRemoved - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onCardinalRemoved(faction, religion) + function onCardinalRemoved(eventData) --something here end */ /*** An inquisitor has been dispatched to a region. + Exports: faction, religion @function onInquisitorAppointed - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onInquisitorAppointed(faction, religion) + function onInquisitorAppointed(eventData) --something here end */ /*** An assassination mission against the pope has failed and the assassin is executed. + Exports: faction, religion @function onAssassinCaughtAttackingPope - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onAssassinCaughtAttackingPope(faction, religion) + function onAssassinCaughtAttackingPope(eventData) --something here end */ /*** The player has opened his finances panel. + Exports: faction, religion @function onFinancesPanelOpen - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFinancesPanelOpen(faction, religion) + function onFinancesPanelOpen(eventData) --something here end */ /*** The player has opened the faction summary panel. + Exports: faction, religion @function onFactionSummaryPanelOpen - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFactionSummaryPanelOpen(faction, religion) + function onFactionSummaryPanelOpen(eventData) --something here end */ /*** The player has opened the family tree panel. + Exports: faction, religion @function onFamilyTreePanelOpen - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onFamilyTreePanelOpen(faction, religion) + function onFamilyTreePanelOpen(eventData) --something here end */ /*** The player has opened the diplomatic standing panel. + Exports: faction, religion @function onDiplomacyPanelOpen - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onDiplomacyPanelOpen(faction, religion) + function onDiplomacyPanelOpen(eventData) --something here end */ /*** The player has attacked an army or settlement. The decision panel is now open. + Exports: faction, religion @function onPreBattlePanelOpen - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onPreBattlePanelOpen(faction, religion) + function onPreBattlePanelOpen(eventData) --something here end */ /*** A message has arrived for the player. + Exports: faction, eventID, religion @function onIncomingMessage - @tparam factionStruct faction - @tparam string religion - @tparam int eventid + @tparam eventTrigger eventData @usage - function onIncomingMessage(faction, religion, eventid) + function onIncomingMessage(eventData) --something here end */ /*** The player has opened a message. + Exports: faction, eventID, religion @function onMessageOpen - @tparam factionStruct faction - @tparam string religion - @tparam int eventid + @tparam eventTrigger eventData @usage - function onMessageOpen(faction, religion, eventid) + function onMessageOpen(eventData) --something here end */ /*** The player has closed a message. + Exports: eventID @function onMessageClosed - @tparam int eventid + @tparam eventTrigger eventData @usage - function onMessageClosed(eventid) + function onMessageClosed(eventData) --something here end */ /*** The player has declined automated settlement management. + Exports: faction, religion @function onDeclineAutomatedSettlementManagement - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onDeclineAutomatedSettlementManagement(faction, religion) + function onDeclineAutomatedSettlementManagement(eventData) --something here end */ /*** The battle AI has begun processing. + Exports: faction, religion @function onBattleAiCommenced - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onBattleAiCommenced(faction, religion) + function onBattleAiCommenced(eventData) --something here end */ /*** The delay phase has begun. + Exports: faction, religion @function onBattleDelayPhaseCommenced - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onBattleDelayPhaseCommenced(faction, religion) + function onBattleDelayPhaseCommenced(eventData) --something here end */ /*** The deployment phase has begun. + Exports: faction, religion @function onBattleDeploymentPhaseCommenced - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onBattleDeploymentPhaseCommenced(faction, religion) + function onBattleDeploymentPhaseCommenced(eventData) --something here end */ /*** The conflict phase has begun. + Exports: faction, religion @function onBattleConflictPhaseCommenced - @tparam factionStruct faction - @tparam string religion + @tparam eventTrigger eventData @usage - function onBattleConflictPhaseCommenced(faction, religion) + function onBattleConflictPhaseCommenced(eventData) --something here end */ /*** Called after a faction declares a war. + Exports: faction, targetFaction, religion, targetReligion @function onFactionWarDeclared - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionWarDeclared(faction, religion, targetFaction, targetReligion) + function onFactionWarDeclared(eventData) --something end */ /*** Called after a faction declares an alliance. + Exports: faction, targetFaction, religion, targetReligion @function onFactionAllianceDeclared - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionAllianceDeclared(faction, religion, targetFaction, targetReligion) + function onFactionAllianceDeclared(eventData) --something end */ /*** A marriage has occured between two factions. gets fired for both factions involved. + Exports: faction, targetFaction, religion, targetReligion @function onInterFactionMarriage - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onInterFactionMarriage(faction, religion, targetFaction, targetReligion) + function onInterFactionMarriage(eventData) --something end */ /*** Called after a faction makes a trade agreement. + Exports: faction, targetFaction, religion, targetReligion @function onFactionTradeAgreementMade - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionTradeAgreementMade(faction, religion, targetFaction, targetReligion) + function onFactionTradeAgreementMade(eventData) --something end */ /*** A new pope has been elected. + Exports: faction, targetFaction, religion, targetReligion @function onPopeElected - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onPopeElected(faction, religion, targetFaction, targetReligion) + function onPopeElected(eventData) --something end */ /*** Called after a faction breaks an alliance. + Exports: faction, targetFaction, religion, targetReligion @function onFactionBreakAlliance - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onFactionBreakAlliance(faction, religion, targetFaction, targetReligion) + function onFactionBreakAlliance(eventData) --something end */ /*** A faction to faction attitude update has occurred (once every round). + Exports: faction, targetFaction, religion @function onUpdateAttitude - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onUpdateAttitude(faction, religion, targetFaction, targetReligion) + function onUpdateAttitude(eventData) --something end */ /*** A demeanour response has occured in diplomacy talks. + Exports: faction, targetFaction, religion, targetReligion, amount @function onDemeanour - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion - @tparam float amountChange + @tparam eventTrigger eventData @usage - function onDemeanour(faction, religion, targetFaction, targetReligion, amountChange) + function onDemeanour(eventData) --something end */ /*** Called after a faction gives money to another faction. + Exports: faction, targetFaction, religion, targetReligion, amount @function onGiveMoney - @tparam factionStruct faction - @tparam string religion - @tparam factionStruct targetFaction - @tparam string targetReligion - @tparam int amount + @tparam eventTrigger eventData @usage - function onGiveMoney(faction, religion, targetFaction, targetReligion, amount) + function onGiveMoney(eventData) --something end */ /*** A player unit has attacked one of the enemies units. + Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit @function onBattlePlayerUnitAttacksEnemyUnit - @tparam unit attackingUnit - @tparam unit defendingUnit - @tparam unit playerUnit - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattlePlayerUnitAttacksEnemyUnit(attackingUnit, defendingUnit, playerUnit, enemyUnit) + function onBattlePlayerUnitAttacksEnemyUnit(eventData) --something here end */ /*** An enemy unit has attacked one of the players units. + Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit @function onBattleEnemyUnitAttacksPlayerUnit - @tparam unit attackingUnit - @tparam unit defendingUnit - @tparam unit playerUnit - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattleEnemyUnitAttacksPlayerUnit(attackingUnit, defendingUnit, playerUnit, enemyUnit) + function onBattleEnemyUnitAttacksPlayerUnit(eventData) --something here end */ /*** One of the player's units has gone berserk. + Exports: playerUnit @function onBattlePlayerUnitGoesBerserk - @tparam unit playerUnit + @tparam eventTrigger eventData @usage - function onBattlePlayerUnitGoesBerserk(playerUnit) + function onBattlePlayerUnitGoesBerserk(eventData) --something here end */ /*** One of the player's units has routed. + Exports: playerUnit @function onBattlePlayerUnitRouts - @tparam unit playerUnit + @tparam eventTrigger eventData @usage - function onBattlePlayerUnitRouts(playerUnit) + function onBattlePlayerUnitRouts(eventData) --something here end */ /*** A siege engine belonging to the player has been destroyed. + Exports: playerUnit @function onBattlePlayerSiegeEngineDestroyed - @tparam unit playerUnit + @tparam eventTrigger eventData @usage - function onBattlePlayerSiegeEngineDestroyed(playerUnit) + function onBattlePlayerSiegeEngineDestroyed(eventData) --something here end */ /*** A player's engine has started attacking a gate. + Exports: playerUnit @function onBattleGatesAttackedByPlayerEngine - @tparam unit playerUnit + @tparam eventTrigger eventData @usage - function onBattleGatesAttackedByPlayerEngine(playerUnit) + function onBattleGatesAttackedByPlayerEngine(eventData) --something here end */ /*** One of the enemy's units has gone berserk. + Exports: enemyUnit @function onBattleEnemyUnitGoesBerserk - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattleEnemyUnitGoesBerserk(enemyUnit) + function onBattleEnemyUnitGoesBerserk(eventData) --something here end */ /*** One of the enemy's units has routed. + Exports: enemyUnit @function onBattnemyUnitRouts - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattnemyUnitRouts(enemyUnit) + function onBattnemyUnitRouts(eventData) --something here end */ /*** A siege engine belonging to the enemy has been destroyed. + Exports: enemyUnit @function onBattnemySiegeEngineDestroyed - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattnemySiegeEngineDestroyed(enemyUnit) + function onBattnemySiegeEngineDestroyed(eventData) --something here end */ /*** An enemy's engine has started attacking a gate. + Exports: enemyUnit @function onBattleGatesAttackedByEnemyEngine - @tparam unit enemyUnit + @tparam eventTrigger eventData @usage - function onBattleGatesAttackedByEnemyEngine(enemyUnit) + function onBattleGatesAttackedByEnemyEngine(eventData) --something here end */ /*** When a particular disaster has just happened. + Exports: resourceDescription @function onDisaster - @tparam string eventType (earthquake, flood, storm, volcano, plague) + @tparam eventTrigger eventData @usage - function onDisaster(eventType) - if eventType == "earthquake" then + function onDisaster(eventData) + if eventData.resourceDescription == "earthquake" then --something here end end @@ -3201,13 +2808,14 @@ void luaP::onPluginLoadF() /*** An event counter has changed it's value. + Exports: eventCounter @function onEventCounter - @tparam string counter + @tparam eventTrigger eventData @usage - function onEventCounter(counter) - if counter == "my_event_counter" then + function onEventCounter(eventData) + if eventData.eventCounter == "my_event_counter" then --something here end end @@ -3215,113 +2823,93 @@ void luaP::onPluginLoadF() /*** The last unit has been removed from a fort, agents do not count. + Exports: fort, faction, regionID, religion @function onUngarrisonedFort - @tparam fortStruct fort - @tparam factionStruct faction - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onUngarrisonedFort(fort, faction, region, religion) + function onUngarrisonedFort(eventData) --something here end */ /*** An object of the target faction has been seen by the faction. + Exports: faction, targetFaction, regionID, coords, religion @function onObjSeen - @tparam factionStruct fac Faction that saw the object. - @tparam factionStruct targetFac Faction that owns the object. - @tparam int xCoord - @tparam int yCoord + @tparam eventTrigger eventData @usage - function onObjSeen(faction, targetFaction, x, y, region, religion) + function onObjSeen(eventData) --something here end */ /*** The tile has been seen by the faction. + Exports: faction, regionID, coords, religion @function onTileSeen - @tparam factionStruct faction - @tparam int xCoord - @tparam int yCoord - @tparam regionStruct region - @tparam string religion + @tparam eventTrigger eventData @usage - function onTileSeen(faction, x, y, region, religion) + function onTileSeen(eventData) --something here end */ /*** A faction to faction transgression has occurred. + Exports: faction, targetFaction, resourceDescription, religion, targetReligion + transgressions: TC_THREATEN_WAR, TC_DECLARED_WAR, TC_MINOR_ASSASSINATION_ATTEMPT, TC_BROKE_TREATY_TERMS, TC_BROKE_ALLIANCE, TC_INVASION @function onTransgression - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam string transgression (TC_THREATEN_WAR, TC_DECLARED_WAR, TC_MINOR_ASSASSINATION_ATTEMPT, TC_BROKE_TREATY_TERMS, TC_BROKE_ALLIANCE, TC_INVASION) - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onTransgression(faction, targetFaction, transgression, religion, targetReligion) + function onTransgression(eventData) --something here end */ /*** A faction to faction forgiveness has occurred. + Exports: faction, targetFaction, resourceDescription, religion + forgiveness: FC_MILITARY_ASSISTANCE, FC_OBVIOUS_BRIBE @function onForgiveness - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam string forgiveness (not sure what this could be) - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onForgiveness(faction, targetFaction, forgiveness, religion, targetReligion) + function onForgiveness(eventData) --something here end */ /*** An army has taken a crusade or jihad target settlement. + Exports: targetSettlement, faction, targetFaction, army, regionID, targetRegionID, coords, religion, targetReligion, crusade @function onArmyTakesCrusadeTarget - @tparam settlementStruct targetSettlement - @tparam stackStruct army - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onArmyTakesCrusadeTarget(targetSettlement, army, faction, targetFaction, targetRegion, religion, targetReligion) + function onArmyTakesCrusadeTarget(eventData) --something here end */ /*** Units have deserted a crusade or jihad. + Exports: targetSettlement, faction, targetFaction, targetRegionID, religion, targetReligion, crusade @function onUnitsDesertCrusade - @tparam settlementStruct targetSettlement - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam regionStruct targetRegion - @tparam string religion - @tparam string targetReligion + @tparam eventTrigger eventData @usage - function onUnitsDesertCrusade(targetSettlement, faction, targetFaction, targetRegion, religion, targetReligion) + function onUnitsDesertCrusade(eventData) --something here end */ @@ -3398,6 +2986,22 @@ void luaP::onPluginLoadF() onReadGameDbsAtStart = new sol::function(luaState["onReadGameDbsAtStart"]); checkLuaFunc(&onReadGameDbsAtStart); + /*** + Called after the game loads various db`s (edu, etc) at startup. + + @function onGameInit + + @usage + function onGameInit() + --something here + end + */ + + + + onGameInit = new sol::function(luaState["onGameInit"]); + checkLuaFunc(&onGameInit); + /*** Called on clicking the stratmap. diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index d70578234..51bb8d3c6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -129,6 +129,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertyperecruitmentCapability; sol::usertypesettlementRecruitmentPool; sol::usertypebattleFactionCounter; + sol::usertype eventTrigger; }types; luaState = {}; luaPath = modPath + "\\youneuoy_Data\\plugins\\lua"; @@ -266,6 +267,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getRegionOwner getRegionOwner @tfield setEDUUnitsSize setEDUUnitsSize @tfield getReligionName getReligionName + @tfield condition condition @table M2TWEOP */ @@ -525,6 +527,16 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) local options =M2TWEOP.getOptions2(); */ tables.M2TWEOPTable.set_function("getOptions2", &m2tweopHelpers::getOptions2); + /*** + Check game condition. + @function M2TWEOP.condition + @tparam string condition + @tparam eventTrigger eventData + @treturn bool isTrue + @usage + local options =M2TWEOP.condition(); + */ + tables.M2TWEOPTable.set_function("condition", &gameHelpers::condition); /// BattleCamera @@ -2353,7 +2365,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.fortStruct.set("governor", &fortStruct::gubernator); types.fortStruct.set("army", &fortStruct::army); types.fortStruct.set("ownerFaction", &fortStruct::faction); - types.fortStruct.set("siege", &fortStruct::siege); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index 5cb0e38ad..2f89f5c87 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -150,6 +150,7 @@ class luaP sol::function* onCampaignMapLoaded = nullptr; sol::function* onReadGameDbsAtStart = nullptr; + sol::function* onGameInit = nullptr; sol::function* onEndSiege = nullptr; sol::function* onStartSiege = nullptr; sol::function* onSelectWorldpkgdesc = nullptr; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index 7a4105d95..21015ecb3 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -32,6 +32,7 @@ void luaP::initCampaign() sol::usertype roadStruct; sol::usertype seaConnectedRegion; sol::usertype neighbourRegion; + sol::usertype eventTrigger; }typeAll; using namespace campaignEnums; @@ -296,6 +297,91 @@ void luaP::initCampaign() typeAll.options2.set("unitSizeMultiplierMedium", &options2::unitSizeMultiplierMedium); typeAll.options2.set("unitSizeMultiplierLarge", &options2::unitSizeMultiplierLarge); + ///eventTrigger + //@section eventTrigger + + /*** + Basic eventTrigger table + + @tfield unit attackingUnit + @tfield unit defendingUnit + @tfield character stratCharacter + @tfield namedCharacter character + @tfield namedCharacter targetCharacter + @tfield settlementStruct settlement + @tfield settlementStruct targetSettlement + @tfield fortStruct fort + @tfield factionStruct faction + @tfield factionStruct targetFaction + @tfield stackStruct army + @tfield int regionID + @tfield int targetRegionID + @tfield unit playerUnit + @tfield unit enemyUnit + @tfield buildingBattle battleBuilding + @tfield buildingInQueue priorBuild + @tfield string resourceDescription + @tfield eduEntry eduEntry + @tfield int characterType + @tfield int targetCharacterType + @tfield string disasterType + @tfield string missionSuccessLevel + @tfield int missionProbability + @tfield string missionDetails + @tfield int eventID + @tfield guild guild + @tfield string eventCounter + @tfield coordPair coords + @tfield int religion + @tfield int targetReligion + @tfield float amount + @tfield crusadeStruct crusade + @tfield capturedFactionInfo captureInfo + @tfield string ransomType + @tfield unit unit + + + @table eventTrigger + */ + typeAll.eventTrigger = luaState.new_usertype("eventTrigger"); + typeAll.eventTrigger.set("attackingUnit", sol::property(gameHelpers::getEventAttackingUnit)); + typeAll.eventTrigger.set("defendingUnit", sol::property(gameHelpers::getEventDefendingUnit)); + typeAll.eventTrigger.set("character", sol::property(gameHelpers::getEventNamedCharacter)); + typeAll.eventTrigger.set("targetCharacter", sol::property(gameHelpers::getEventTargetNamedCharacter)); + typeAll.eventTrigger.set("settlement", sol::property(gameHelpers::getEventSettlement)); + typeAll.eventTrigger.set("targetSettlement", sol::property(gameHelpers::getEventTargetSettlement)); + typeAll.eventTrigger.set("fort", sol::property(gameHelpers::getEventFort)); + typeAll.eventTrigger.set("faction", sol::property(gameHelpers::getEventFaction)); + typeAll.eventTrigger.set("targetFaction", sol::property(gameHelpers::getEventTargetFaction)); + typeAll.eventTrigger.set("army", sol::property(gameHelpers::getEventArmy)); + typeAll.eventTrigger.set("regionID", sol::property(gameHelpers::getEventRegion)); + typeAll.eventTrigger.set("targetRegionID", sol::property(gameHelpers::getEventTargetRegion)); + typeAll.eventTrigger.set("playerUnit", sol::property(gameHelpers::getEventPlayerUnit)); + typeAll.eventTrigger.set("enemyUnit", sol::property(gameHelpers::getEventEnemyUnit)); + typeAll.eventTrigger.set("battleBuilding", sol::property(gameHelpers::getBuildingBattle)); + typeAll.eventTrigger.set("priorBuild", sol::property(gameHelpers::getPriorBuild)); + typeAll.eventTrigger.set("resourceDescription", sol::property(gameHelpers::getResourceDescription)); + typeAll.eventTrigger.set("eduEntry", sol::property(gameHelpers::getEduEntry)); + typeAll.eventTrigger.set("characterType", sol::property(gameHelpers::getEventCharacterType)); + typeAll.eventTrigger.set("targetCharacterType", sol::property(gameHelpers::getEventTargetCharacterType)); + typeAll.eventTrigger.set("disasterType", sol::property(gameHelpers::getEventType)); + typeAll.eventTrigger.set("missionSuccessLevel", sol::property(gameHelpers::getMissionSuccessLevel)); + typeAll.eventTrigger.set("missionProbability", sol::property(gameHelpers::getMissionProbability)); + typeAll.eventTrigger.set("missionDetails", sol::property(gameHelpers::getMissionDetails)); + typeAll.eventTrigger.set("eventID", sol::property(gameHelpers::getEventID)); + typeAll.eventTrigger.set("guild", sol::property(gameHelpers::getEventGuild)); + typeAll.eventTrigger.set("eventCounter", sol::property(gameHelpers::getEventCounter)); + typeAll.eventTrigger.set("coords", sol::property(gameHelpers::getPosition)); + typeAll.eventTrigger.set("religion", sol::property(gameHelpers::getReligion)); + typeAll.eventTrigger.set("targetReligion", sol::property(gameHelpers::getTargetReligion)); + typeAll.eventTrigger.set("amount", sol::property(gameHelpers::getAmount)); + typeAll.eventTrigger.set("crusade", sol::property(gameHelpers::getCrusade)); + typeAll.eventTrigger.set("captureInfo", sol::property(gameHelpers::getCapturedFactionInfo)); + typeAll.eventTrigger.set("ransomType", sol::property(gameHelpers::getRansomType)); + typeAll.eventTrigger.set("unit", sol::property(gameHelpers::getUnit)); + + + ///uiCardManager //@section uiCardManager diff --git a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp index 524130f9b..ac7fc119d 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp @@ -132,6 +132,12 @@ int initPlugin(std::string* modPath) fName = "changeRegionName"; plugData::data.funcs.changeRegionName.Load(&plPath, &fName); + fName = "condition"; + plugData::data.funcs.condition.Load(&plPath, &fName); + + fName = "allocateGameMem"; + plugData::data.funcs.allocateGameMem.Load(&plPath, &fName); + fName = "changeRebelsName"; plugData::data.funcs.changeRebelsName.Load(&plPath, &fName); diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index 1b9e26fe3..ceb4a48e0 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -40,6 +40,59 @@ struct generalStats struct soldierInBattle* generalBgMount; //0x0004 }; //Size: 0x0008 +struct legioString +{ +public: + char* name; //0x0000 + int32_t nameHash; //0x0004 + struct UNICODE_STRING** localizedLegoName; //0x0008 + int32_t recruitCount; //0x000C + char pad_0010[4]; //0x0010 +}; //Size: 0x0014 + +struct cultureModels +{ +public: + char pad_0000[5584]; //0x0000 +}; //Size: 0x15D0 + +struct cultureAgent +{ +public: + char* cardName; //0x0000 + int32_t cardNameHash; //0x0004 + char* infoCardName; //0x0008 + int32_t infoCardNameHash; //0x000C + char* cardName2; //0x0010 + int32_t cardName2Hash; //0x0014 + int16_t index1; //0x0018 + char pad_001A[2]; //0x001A + int16_t index2; //0x001C + char pad_001E[2]; //0x001E + int16_t cost; //0x0020 + int16_t time; //0x0022 + int16_t popCost; //0x0024 + int16_t someOtherRomeShit; //0x0026 + char pad_0028[4]; //0x0028 +}; //Size: 0x002C + + + +struct culture +{ +public: + int32_t cultureID; //0x0000 + char* cultureName; //0x0004 + int32_t cultureNameHash; //0x0008 + char pad_000C[1072]; //0x000C + int32_t fortCost; //0x043C + int32_t watchTowerCost; //0x0440 + char pad_0444[24]; //0x0444 + struct cultureModels cultureModelCrap; //0x045C + struct cultureAgent cultureAgents[6]; //0x1A2C + char pad_1B34[4]; //0x1B34 +}; //Size: 0x1B38 + struct coordPair { public: @@ -56,7 +109,33 @@ struct movePath }; //Size: 0x000C -class religionDatabase +struct eventTrigger +{ + void* eventTrigger_vtbl; //0x0000 + char pad_0004[28]; //0x0004 +}; + +struct buildingBattle +{ +public: + char pad_0000[24]; //0x0000 + int32_t type; //0x0018 + char pad_001C[8]; //0x001C + float posX; //0x0024 + float posZ; //0x0028 + float posY; //0x002C + char pad_0030[4]; //0x0030 + int32_t endHealth; //0x0034 + int32_t currentHealth; //0x0038 + int32_t startHealth; //0x003C + char pad_0040[4]; //0x0040 + int32_t isDefenderControlled; //0x0044 + char pad_0048[8]; //0x0048 +}; //Size: 0x0050 + + + +struct religionDatabase { public: void* religionDatabase_vtbl;//0x0000 @@ -307,6 +386,16 @@ struct mercPool struct mercPoolUnitsPtr firstUnits; //0x001C }; //Size: 0x0180 +struct mercPoolList +{ +public: + struct mercPool* mercPools; //0x0000 + struct mercPoolList* nextMercPools; //0x0004 + struct mercPoolList* previousMercPools; //0x0008 + int32_t currentSize; //0x000C + int32_t currentCount; //0x0010 +}; //Size: 0x0014 + struct uiElement { undefined field_0x0[16]; int xSize; @@ -491,11 +580,25 @@ struct watchTowerModel { //watchtower struct watchTowerStruct { - undefined field_0x0[12]; + void* watchTowerVtable; //0x0000 + char pad_0004[4]; //0x0004 + struct character* character; //0x0008 int xCoord; int yCoord; - undefined field_0x14[16]; + char pad_0014[4]; //0x0014 + int8_t N000021C7; //0x0018 + char pad_0019[3]; //0x0019 + float N000021C8; //0x001C + int8_t N000021C9; //0x0020 + char pad_0021[3]; //0x0021 struct watchTowerModel* model; + int32_t regionID; //0x0028 + struct factionStruct* faction; //0x002C + struct settlementStruct* settlement; //0x0030 + void* trackedPointerArmyVtable; //0x0034 + struct stackStruct* blockingArmy; //0x0038 + int32_t factionID; //0x003C + char pad_0040[8]; //0x0040 }; struct worldRecord { @@ -597,7 +700,11 @@ struct collegeOfCardinals struct campaign { undefined field0_0x0[4]; - undefined field1_0x4[52]; + undefined field1_0x4[36]; + int32_t type; //0x0024 + char pad_0028[4]; //0x0028 + uint32_t playableFactionsBitmap; //0x002C + char pad_0030[4]; //0x0030 int playerFactionId; undefined field3_0x3c[4]; int hotSeatPlayer2FactionId; @@ -609,7 +716,8 @@ struct campaign { struct factionStruct* factionsSortedByDescrStrat[31]; struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; - char pad_0328[20]; //0x0328 + uint32_t existingFactionsBitMap; //0x0324 + char pad_032A[16]; //0x032A struct collegeOfCardinals* collegeOfCardinals; //0x033C struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; @@ -627,14 +735,33 @@ struct campaign { struct settlementStruct* rome; undefined field29_0x38c[4]; struct settlementStruct* constantinople; - undefined field31_0x394[60]; - int8_t field32_0x3d0; - int8_t field33_0x3d1; - undefined field34_0x3d2[26]; + char pad_0390[12]; //0x0390 + void* unkArray1; //0x039C + int32_t unkArray1Size; //0x03A0 + int32_t unkArray1Count; //0x03A4 + void* unkArray2; //0x03A8 + int32_t unkArray2Size; //0x03AC + int32_t unkArray2Count; //0x03B0 + void* script; //0x03B4 + void* scriptEnd; //0x03B8 + char pad_03BC[8]; //0x03BC + void* pointerToScript; //0x03C4 + void* pointerToScriptEnd; //0x03C8 + int8_t N00001208; //0x03CC + int8_t forceAllowManageAllSetts; //0x03CD + char pad_03CE[18]; //0x03CE + int8_t marianReformsActive; //0x03E0 + int8_t marianReformsDisabled; //0x03E1 + int8_t rebellingCharactersActive; //0x03E2 + int8_t gladiatorUprisingDisabled; //0x03E3 + int8_t nightBattlesEnabled; //0x03E4 + int8_t N00038FC9; //0x03E5 + int8_t N00038FCC; //0x03E6 + char pad_03E7[1]; //0x03E7 float BrigandSpawnValue; float PirateSpawnValue; int8_t N00001211; //0x03F4 - int8_t smthingDateTurnDisplay; //0x03F5 + int8_t showDateAsTurns; //0x03F5 int8_t restrictAutoResolve; //0x03F6 char pad_03F7[1]; //0x03F7 int FreeUpkeepForts; @@ -677,6 +804,10 @@ struct campaign { struct watchTowerStruct** watchtowers; int32_t watchtowersSize; //0x21628 int32_t watchtowersNum; //0x2162C + char pad[16]; //0x21638 + struct mercPoolList allMercPools; //0x2163C + void* unk3; //0x21650 + void* unk4; //0x21654 }; struct uiUnitCard @@ -739,7 +870,10 @@ struct battleUnit int32_t expStart; //0x0034 int32_t expGained; //0x0038 int8_t isGeneral; //0x003C - char pad_003D[11]; //0x003D + int8_t hasWithdrawn; //0x003D + uint16_t N000400D6; //0x003E + int32_t N0001FD2C; //0x0040 + int32_t N0001FDB3; //0x0044 }; //Size: 0x0048 struct options1 @@ -2007,14 +2141,10 @@ struct anchillary { /* structure of ancillary */ undefined field_0x12; undefined field_0x13; char* patchToAnchImage; - undefined field_0x18; - undefined field_0x19; - undefined field_0x1a; - undefined field_0x1b; - undefined field_0x1c; - undefined field_0x1d; - undefined field_0x1e; - undefined field_0x1f; + char pad_0018[4]; //0x0018 + int8_t isUnique; //0x001C + char pad_001D[23]; //0x001D + uint32_t excludedCultures; //0x0034 }; struct trait { /* traits of the character */ @@ -2931,22 +3061,42 @@ struct soldierData { /* one soldier in unit */ //fort struct fortStruct { public: - undefined field_0x0[4]; + void* fortVtable; struct general* gubernator; undefined field_0x8[4]; UINT32 xCoord; UINT32 yCoord; undefined field_0x14[48]; - struct stackStruct* army; - undefined field_0x48[4]; - struct siegeS* siege; - undefined field_0x50[144]; + struct stackStruct* army; + struct oneSiege sieges[8]; + int8_t siegeNum; //0x0088 + char pad_0089[3]; //0x0089 + int32_t N000106CC; //0x008C + int32_t N000106CD; //0x0090 + int32_t N000106CE; //0x0094 + int32_t N000106CF; //0x0098 + int32_t N000106D0; //0x009C + int32_t N000106D1; //0x00A0 + int8_t N000106D2; //0x00A4 + int8_t setZeroAfterInvaded; //0x00A5 + int8_t N000393C1; //0x00A6 + int8_t N000393BF; //0x00A7 + int32_t N000106D3; //0x00A8 + struct descrRebelEntry* descrRebel; //0x00AC + int32_t subFactionID; //0x00B0 + void* spyingInfoBase; //0x00B4 + int8_t spyingInfoFactions[31]; //0x00B8 + char pad_00D7[9]; //0x00D7 struct stratFortMod* stratModel; int regionID; struct factionStruct* faction; - undefined field_0xec[12]; + int32_t factionID; //0x00EC + int32_t cultureID; //0x00F0 + void* localString; //0x00F4 char* fortType; - undefined field_0xfc[28]; + char pad_00FC[4]; //0x00FC + int32_t fortFortificationLevel; //0x0100 + char pad_0104[20]; //0x0104 }; struct traidingResource { diff --git a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp index 5c86922ee..dc2d8ef41 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp @@ -57,5 +57,10 @@ namespace technicalHelpers (*(*plugData::data.funcsTech.createUniString))(newUniStringPointer, nonUniStr); } + DWORD allocateGameMem(size_t amount) + { + return (*(*plugData::data.funcs.allocateGameMem))(amount); + } + }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h index 658d98bdc..32af90f67 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h @@ -13,6 +13,7 @@ namespace technicalHelpers { std::string unitUniStringToStr(unit* unit); void setUnitUniStr(unit* unit, const char* str); + DWORD allocateGameMem(size_t amount); std::string uniStringToStr(UNICODE_STRING**& uniString); From 20f30078bdb8d2c01adca9a50df3c9016497ff33 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Wed, 18 Oct 2023 03:23:33 +0300 Subject: [PATCH 18/22] updating more structs (WIP) --- M2TWEOP Code/M2TWEOP library/fastFuncts.cpp | 10 +- M2TWEOP Code/M2TWEOP library/fastFuncts.h | 6 +- M2TWEOP Code/M2TWEOP library/onlineThings.cpp | 6 +- .../M2TWEOP library/onlineThings2.cpp | 6 +- M2TWEOP Code/M2TWEOP library/realGameTypes.h | 385 +++++++++++++++--- 5 files changed, 336 insertions(+), 77 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp index f06bce51b..f8000c8e6 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp @@ -515,7 +515,7 @@ namespace fastFuncts for (UINT32 i = 0; i < numFac; i++) { - for (int j = 0; j < listFac[i]->wathtowersNum; j++) + for (int j = 0; j < listFac[i]->watchtowersNum; j++) { watchTowerStruct* towS = listFac[i]->watchTowers[j]; if (towS->xCoord == x && towS->yCoord == y) @@ -765,7 +765,7 @@ namespace fastFuncts } } - EOP_EXPORT int addAnchillary(namedCharacter* character, anchillary* anch) + EOP_EXPORT int addAnchillary(namedCharacter* character, ancillary* anch) { if (character == nullptr || anch == nullptr)return 0; @@ -792,7 +792,7 @@ namespace fastFuncts return retr; } - EOP_EXPORT void removeAnchillary(namedCharacter* character, anchillary* anch) + EOP_EXPORT void removeAnchillary(namedCharacter* character, ancillary* anch) { if (character == nullptr || anch == nullptr)return; @@ -817,12 +817,12 @@ namespace fastFuncts return; } - EOP_EXPORT anchillary* findAnchillary(char* anchName) + EOP_EXPORT ancillary* findAnchillary(char* anchName) { if (anchName == nullptr)return 0; DWORD adr = 0; - anchillary* retr = nullptr; + ancillary* retr = nullptr; if (globals::dataS.gamever == 2)//steam { adr = 0x008b1d30; diff --git a/M2TWEOP Code/M2TWEOP library/fastFuncts.h b/M2TWEOP Code/M2TWEOP library/fastFuncts.h index f7f592f9b..a4db0b528 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.h +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.h @@ -88,11 +88,11 @@ namespace fastFuncts //add anchillary to character - NOINLINE EOP_EXPORT int addAnchillary(namedCharacter* character, anchillary* anch); + NOINLINE EOP_EXPORT int addAnchillary(namedCharacter* character, ancillary* anch); //remove anchillary from character - NOINLINE EOP_EXPORT void removeAnchillary(namedCharacter* character, anchillary* anch); + NOINLINE EOP_EXPORT void removeAnchillary(namedCharacter* character, ancillary* anch); //find anchillary in anch list - NOINLINE EOP_EXPORT anchillary* findAnchillary(char* anchName); + NOINLINE EOP_EXPORT ancillary* findAnchillary(char* anchName); //edit unit characteristics NOINLINE EOP_EXPORT void setUnitParams(unit* un, int count, int exp, int armor, int weap); diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp index e0be83eb6..747fbea1d 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp @@ -263,13 +263,13 @@ namespace battleCreator fileStrings.push_back(tempS); } - if (gen->genChar->anchNum != 0) + if (gen->genChar->ancNum != 0) { tempS = "ancillaries"; - UINT32 anchNum = gen->genChar->anchNum; + UINT32 anchNum = gen->genChar->ancNum; for (UINT32 i = 0; i < anchNum; i++) { - tempS.append(" ").append(gen->genChar->anchillaries[i]->dataAnch->anchName).append(" ,"); + tempS.append(" ").append(gen->genChar->ancillaries[i]->dataAnch->ancName).append(" ,"); } fileStrings.push_back(tempS); } diff --git a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp index ac68d3fe9..6bcce7ad3 100644 --- a/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp +++ b/M2TWEOP Code/M2TWEOP library/onlineThings2.cpp @@ -191,14 +191,14 @@ namespace battleCreator } - if (gen->genChar->anchNum != 0) + if (gen->genChar->ancNum != 0) { jsn::json jAncs= jsn::json::array(); - UINT32 anchNum = gen->genChar->anchNum; + UINT32 anchNum = gen->genChar->ancNum; for (UINT32 i = 0; i < anchNum; i++) { - jAncs.push_back(gen->genChar->anchillaries[i]->dataAnch->anchName); + jAncs.push_back(gen->genChar->ancillaries[i]->dataAnch->ancName); } genJson["ancillaries"] = jAncs; diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index e4ac04093..60521bc90 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -211,11 +211,11 @@ struct regionStruct { int settlementNameHash;//0x000C char* legioName; /* null for sea *///0x0010 int legioNameHash;//0x0014 - undefined field4_0x10[4];//0x0018 + struct legioString* legioPointer; //0x0018 int regionID;//0x001C - int32_t N00008C49; //0x0020 - int32_t N00008C4A; //0x0024 - int32_t overOneAllowsFamine; //0x0028 + int32_t roadLevel; //0x0020 + int32_t farmingLevel; //0x0024 + int32_t famineThreat; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -235,22 +235,27 @@ struct regionStruct { int32_t seaConnectedRegionsCount; //0x0064 int32_t loyaltyFactionID; //0x0068 struct seaConnectedRegion* seaExportRegion; //0x006C - char pad_0070[12]; //0x0070 + struct seaConnectedRegion* seaExportRegion2; //0x0070 --disk/dlc only + struct seaConnectedRegion* seaExportRegion3; //0x0074 --disk/dlc only + struct seaConnectedRegion* seaExportRegion4; //0x0078 --disk/dlc only struct seaConnectedRegion** seaImportRegions; //0x007C int32_t seaImportRegionsSize; //0x0080 int32_t seaImportRegionsCount; //0x0084 - int32_t canSeaTrade; //0x0088 + int32_t tradeFleetCount; //0x0088 struct mercPool* mercPool;//0x008C int32_t* regionSeaEdges; //0x0090 int32_t regionSeaEdgesSize; //0x0094 int32_t regionSeaEdgesCount; //0x0098 - char pad_009C[24]; //0x009C + char pad_009C[12]; //0x009C + int32_t* devastatedTiles; //0x00A8 + int32_t devastatedTilesSize; //0x00AC + int32_t devastatedTilesCount; //0x00B0 float* religionsARR;//0x00B4 float* religionHistory[20]; uint32_t* tilesBorderingEdgeOfMap; //0x0108 int32_t tilesBorderingEdgeOfMapSize; //0x010C int32_t tilesBorderingEdgeOfMapCount; //0x0110 - char pad_0114[124]; //0x0114 + int32_t armiesHostileToArrayIndexIDStrength[31]; //0x0114 struct settlementStruct* settlement;//0x0190 int* tiles; //0x0194 int32_t tilesSize; //0x0198 @@ -274,7 +279,10 @@ struct regionStruct { int32_t settlementYCoord; //0x01E0 int32_t portEntranceXCoord; //0x01E4 int32_t portEntranceYCoord; //0x01E8 - char pad_01EC[4]; //0x01EC + uint8_t colorBlue; //0x01EC + uint8_t colorGreen; //0x01ED + uint8_t colorRed; //0x01EE + char pad_01EF[1]; //0x01EF struct factionStruct* factionOwner;//0x01F0 char pad_01F4[4]; //0x01F4 UNICODE_STRING** localizedRegionName; //0x01F8 @@ -282,9 +290,10 @@ struct regionStruct { UNICODE_STRING** localizedRebelsName; //0x0200 char* rebelType; //0x0204 int32_t rebelTypeHash; //0x0208 - int32_t getsCopiedToSettlementAtRebelEndTurn; //0x020C + int32_t harvestSuccess; //0x020C int32_t triumphValue; //0x0210 - char pad_0214[8]; //0x0214 + int32_t N00008CC6; //0x0214 + uint32_t tradeValue; //0x0218 };//Size: 0x021C struct neighbourRegion @@ -293,7 +302,8 @@ struct neighbourRegion struct regionStruct* region; //0x0000 int32_t regionID; //0x0004 float distance; //0x0008 - char pad_000C[4]; //0x000C + int8_t alliedRegion; //0x000C + char pad_000D[3]; //0x000D struct roadStruct* connectingRoad; //0x0010 int32_t tradeValue; //0x0014 int32_t* bordertiles; //0x0018 @@ -311,17 +321,78 @@ struct landMass int32_t regionsNum; //0x000C }; //Size: 0x0010 +struct climate +{ +public: + struct rcString* rcString; //0x0000 + struct UNICODE_STRING*** localizedName; //0x0004 + uint8_t colorBlue; //0x0008 + uint8_t colorGreen; //0x0009 + uint8_t colorRed; //0x000A + char pad_000B[1]; //0x000B + int32_t heatValue; //0x000C + uint8_t hasWinter; //0x0010 + char pad_0011[3]; //0x0011 + void* treeModelsSummerSparse; //0x0014 + int32_t treeModelsSummerSparseSize; //0x0018 + int32_t treeModelsSummerSparseNum; //0x001C + void* treeModelsSummerDense; //0x0020 + int32_t treeModelsSummerDenseSize; //0x0024 + int32_t treeModelsSummerDenseNum; //0x0028 + void* treeModelsSummerCanopy; //0x002C + int32_t treeModelsSummerCanopysize; //0x0030 + int32_t treeModelsSummerCanopyNum; //0x0034 + void* treeModelsWinterSparse; //0x0038 + int32_t treeModelsWinterSparsesize; //0x003C + int32_t treeModelsWinterSparseNum; //0x0040 + void* treeModelsWinterDense; //0x0044 + int32_t treeModelsWinterDensesize; //0x0048 + int32_t treeModelsWinterDenseNum; //0x004C + void* treeModelsWinterCanopy; //0x0050 + int32_t treeModelsWinterCanopySize; //0x0054 + int32_t treeModelsWinterCanopyNum; //0x0058 +}; //Size: 0x005C + +struct climates +{ +public: + char pad_0000[4]; //0x0000 + struct climate* climateArray; //0x0004 + int32_t climatesSize; //0x0008 + int32_t climatesNum; //0x000C +}; //Size: 0x0010 + +struct oneTileDouble +{ +public: + float height; //0x0000 + int8_t climate; //0x0004 + int8_t groundType; //0x0005 + int8_t Nx0006; //0x0006 + int8_t Nx0007; //0x0007 +}; //Size: 0x0008 + struct stratMap { undefined field_0x0[4]; struct UNICODE_STRING** campaignName; //0x0004 struct UNICODE_STRING*** campaignPath; //0x0008 - char pad_000C[28]; //0x000C - void* climates; //0x0028 + float minRoughness; //0x000C + float maxRoughness; //0x0010 + float maxLandHeight; //0x0014 + float minSeaHeight; //0x0018 + float fractalMultiplier; //0x001C + float lattitudeMin; //0x0020 + float lattitudeMax; //0x0024 + climates* climates; //0x0028 int mapWidth; int mapHeight; - undefined field_0x34[20]; + float N00008987; //0x0034 + uint32_t N00008988; //0x0038 + char pad_003C[4]; //0x003C + void* storesMapRoughness; //0x0040 + struct oneTileDouble *climateTileArray; //0x0044 struct oneTile* tilesArr; - DWORD TileListEnd; //0x004C + DWORD arraySmthing; //0x004C undefined field_0x50[20]; struct coordPair* volcanoes; //0x0064 int32_t volcanoesSize; //0x0068 @@ -427,7 +498,7 @@ struct roadStruct }; //Size: 0x0038 struct oneTile { - void* object; + DWORD* object; //can be character, resource, fort, struct roadStruct* road; //0x0004 undefined field_0x8[2]; int8_t isLand; @@ -442,7 +513,7 @@ struct oneTile { int8_t borderingRiver; int8_t borderingSettlement; undefined field_0x1F[1]; - int8_t hasRoad; + int8_t hasRoad; //bit 1 has devastation status int8_t border; undefined field_0x22[2]; int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 @@ -471,11 +542,11 @@ struct holdRegionsWinCondition { public: char pad_0000[4]; //0x0000 - int32_t intSomethingTurns; //0x0004 + uint32_t stratTableStringIndex; //0x0004 struct stringWithHash* regionsToHold; //0x0008 int32_t regionsToHoldSize; //0x000C int32_t regionsToHoldCount; //0x0010 - char pad_0014[4]; //0x0014 + uint32_t factionsToOutliveBitfield; //0x0014 int32_t numberOfRegions; //0x0018 char pad_001C[4]; //0x001C int32_t* holdRegionLengths; //0x0020 @@ -494,6 +565,26 @@ struct battleSettlement char pad_0010[304]; //0x0010 }; //Size: 0x0140 +struct settlementBuildings +{ +public: + struct buildingBattle** buildingList; //0x0000 + int32_t buildingListSize; //0x0004 + int32_t buildingNum; //0x0008 +}; //Size: 0x000C + +struct battleBuildings +{ +public: + char pad_0000[20]; //0x0000 + struct buildingBattle** allBuildings; //0x0014 + int32_t allBuildingsSize; //0x0020 + int32_t allBuildingsNum; //0x0020 + int32_t* allBuildingsInt; //0x0020 + char pad_0024[8]; //0x0024 + struct settlementBuildings *settlementBuildings; //0x002C +}; //Size: 0x0444 + struct battleResidence { public: @@ -501,7 +592,8 @@ struct battleResidence struct settlementStruct* settlement; //0x001C char pad_0020[16]; //0x0020 int32_t isFortBattle; //0x0030 - char pad_0034[8]; //0x0034 + struct battleBuildings* battleBuildings; //0x0034 + char pad_0038[4]; //0x0038 float N000203C6; //0x003C float N000203C7; //0x0040 char pad_0044[40]; //0x0044 @@ -717,7 +809,8 @@ struct campaign { struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; uint32_t existingFactionsBitMap; //0x0324 - char pad_032A[16]; //0x032A + int32_t nonPlayableFactionsNum; //0x0328 + char pad_032C[12]; //0x032C struct collegeOfCardinals* collegeOfCardinals; //0x033C struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; @@ -1529,9 +1622,16 @@ struct portBuildingStruct { int yCoord; undefined field_0x14[28]; struct settlementStruct* settlement; - undefined field_0x34[20]; + undefined field_0x34[4]; + int tradeFleets; + char pad_0040[8]; //0x0040 struct stackStruct* occupantsArmy; /* if port block by army then it here */ - undefined field_0x4c[24]; + int32_t numTurnsBlocked; //0x004C + int32_t N00008216; //0x0050 + int32_t N00008217; //0x0054 + int32_t rallyCoordX; //0x0058 + int32_t rallyCoordY; //0x005C + void* rallyPoint; //0x0060 struct factionStruct* fac; /* blockading faction becomes owner */ undefined field_0x68[12]; struct stratPortModel* portStratModel; @@ -1779,6 +1879,20 @@ struct settlementRecruitmentPool float availablePool; //0x0004 }; //Size: 0x0008 + +struct capabilityStruct +{ +public: + struct settlementCapability settlementCapabilities[57]; //0x0000 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x00E4 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x00FC + struct settlementCapability settlementCapabilitiesAncillaryROME[4]; //0x0114 + struct recruitRome* settlementCapabilitiesRecruitROME[64]; //0x0124 + int32_t recruitCapabilityCount; //0x0324 + struct recruitmentCapability recruitmentCapabilities[64]; //0x0328 + int32_t recruitmentCapabilityCount; //0x0828 +}; //Size: 0x082C + //settlement struct settlementStruct { void* vTable; @@ -1796,10 +1910,14 @@ struct settlementStruct { int populationSiegeStart; undefined pad_8[8]; BYTE plagued; - undefined field8_0xA5[167]; + undefined field8_0xA5[7]; + struct descrRebelEntry* descrRebel; //0x00AC + int32_t subFactionID; //0x00B0 + char pad_00B4[152]; //0x00B4 struct settMod* model; - int descr_culturestxt; - undefined field11_0x154[16]; + int cultureID; + undefined field11_0x154[12]; + struct portBuildingStruct* port; char* name; /* internal name of settlement */ int nameCrypt; UNICODE_STRING** localizedName; @@ -1809,10 +1927,14 @@ struct settlementStruct { int fac_creatorModNum; undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ - undefined field21_0x1a5[3]; + undefined field21_0x1a5[1]; + BYTE turnsOwned; /* start at 10 for settlements owned at game start without specification in descr_strat */ + undefined field21_0x1a7[1]; UINT32 regionID; /* number of region */ - undefined field_0x1ac[12]; - int priceOfUnitsInRecruitmentSlots; + int32_t factionID; //0x01AC + int32_t yearFounded; //0x01B0 + int32_t triumph; //0x01B4 + int queueCost; undefined field24_0xBC[24]; struct unitRQ unitQueue[9]; int startIndexRQ; @@ -1831,24 +1953,20 @@ struct settlementStruct { char pad_0E00[4]; //0x0E00 int8_t scriptRebel; //0x0E04 uchar isProvokedRebellion;//0x0E05 - uchar field31_0xe06[34];//0x0E06 - struct general* governor;//0x0E28 - char pad_0E2C[12]; //0x0E2C + uchar field31_0xe06[10];//0x0E06 + int8_t isCapital; //0x0E10 + char pad_0E11[15]; //0x0E11 + struct general* governor;//0x0E20 + char pad_0E24[16]; //0x0E24 + int32_t somthingPO; //0x0E34 int32_t publicOrderLastTurnEnd; //0x0E38 int32_t populationLastTurnEnd; //0x0E3C - char pad_0E40[4]; //0x0E40 + int32_t harvestSuccess; //0x0E40 struct resStrat** resources; int32_t resourceSize; //0x0E48 int resourcesNum; int32_t settlementTaxLevel; //0x0E50 - struct settlementCapability settlementCapabilities[57]; //0x0E54 - struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 - struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 - struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) - char pad_0F78[4]; //0x0F78 - struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C - struct recruitmentCapability recruitmentCapabilities[64]; //0x117C - int32_t recruitPoolCapabilityCount; //0x167C + struct capabilityStruct capabilities; //0x0E54 int8_t N000089C8; //0x1680 char pad_1681[3]; //0x1681 struct settlementStruct* thisSett; //0x1684 @@ -1866,9 +1984,25 @@ struct settlementStruct { int32_t priestsInRecruitmentQueue; //0x16B8 char pad_16BC[8]; //0x16BC intptr_t guildStandings; - char pad_16C8[56]; //0x16C8 + char pad_16C8[48]; //0x16C8 + int32_t baseFertilityValue; //0x16F8 + int32_t rebelFactionChance; //0x16FC int32_t turmoil; //0x1700 - char pad_1704[116]; //0x1704 + int32_t N00002567; //0x1704 + int32_t N00002568; //0x1708 + int32_t N00002569; //0x170C + int32_t N0000256A; //0x1710 + int32_t N0000256B; //0x1714 + int32_t N0000256C; //0x1718 + int32_t N0000256D; //0x171C + int32_t N0000256E; //0x1720 + int32_t N0000256F; //0x1724 + int32_t N00002570; //0x1728 + int32_t wages; //0x172C + int32_t upkeep; //0x1730 + char pad_1734[20]; //0x1734 + struct settlementStruct* this4; //0x1748 + char pad_174C[44]; //0x174C int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C int32_t PopGrowthBaseFarm; //0x1830 @@ -1923,7 +2057,11 @@ struct settlementStruct { int32_t EntertainmentExpense; //0x18F4 int32_t DevastationExpense; //0x18F8 int32_t TotalIncomeWithoutAdmin; //0x18FC - char pad_1900[268]; //0x1900 + int32_t* religionPercentages; //0x1900 + int32_t religionPercentagesSize; //0x1904 + int32_t religionPercentagesNum; //0x1908 + int32_t majorityReligionID; //0x190C + int32_t alternateTradeCalc; //0x1910 }; struct guild @@ -1957,7 +2095,7 @@ struct CompareCounter { /* I_CompareCounter script command */ //main character data(coordinates, etc) struct general { /* character on the stratmap, who has a unit in a stack */ undefined field0_0x0[4]; - struct settlementStruct* settlement; + void* obj; undefined field2_0x8[4]; int xCoord; /* number of x-coord of unit fosition */ int yCoord; /* number of y-coord of unit fosition */ @@ -1971,7 +2109,10 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int8_t inEnemyZOC; //0x00A6 char pad_00A7[17]; //0x00A7 int ambushState; - undefined field13_0xbc[12]; + char pad_00B9[3]; //0x00B9 + int32_t actionsThisTurn; //0x00BC + char pad_00C0[4]; //0x00C0 + int8_t N000013B1; //0x00C4 int8_t doNotSpendMovePoints; //0x00C5 char pad_00C6[2]; //0x00C6 float movePointsCharacter; @@ -2007,7 +2148,14 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int32_t yCoordLast; //0x0254 int32_t xCoordCurrent; //0x0258 int32_t yCoordCurrent; //0x025C - char pad_0260[332]; //0x0260 + struct settlementStruct* besiegingSettlement; //0x0260 + char pad_0264[12]; //0x0264 + struct character* besiegingCharacter; //0x0270 + int32_t N00032B12; //0x0274 + int32_t N00032B00; //0x0278 + int32_t N00032B13; //0x027C + int32_t N00032B14; //0x0280 + char pad_0284[296]; //0x0284 void* someCoordStruct; //0x03AC int32_t someCoordStructSize; //0x03B0 int32_t someCoordStructCount; //0x03B4 @@ -2101,9 +2249,9 @@ struct namedCharacter { /* many important info about character */ int32_t battleSurgery; //0x01E0 struct traitContainer* traits; /* names at [item number] -0x4-here. Not have number, read it in while(traits != 0){this->m_memory->Read(traits + 0x08, 4).toINT32();} */ undefined field_0x1e8[4]; - struct anchData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ + struct ancData** ancillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ undefined field_0x1f0[4]; - UINT32 anchNum; /* number of character ancillaries */ + UINT32 ancNum; /* number of character ancillaries */ struct general* gen; /* on stratmap */ undefined field_0x1fc[8]; float yearOfBirth; /* yearOfBirth */ @@ -2125,7 +2273,7 @@ struct namedCharacter { /* many important info about character */ }; //ancillary of character -struct anchillary { /* structure of ancillary */ +struct ancillary { /* structure of ancillary */ UINT32 index; undefined field_0x4; undefined field_0x5; @@ -2135,12 +2283,12 @@ struct anchillary { /* structure of ancillary */ undefined field_0x9; undefined field_0xa; undefined field_0xb; - char* anchName; + char* ancName; undefined field_0x10; undefined field_0x11; undefined field_0x12; undefined field_0x13; - char* patchToAnchImage; + char* patchToAncImage; char pad_0018[4]; //0x0018 int8_t isUnique; //0x001C char pad_001D[23]; //0x001D @@ -2469,6 +2617,26 @@ struct unitPositionData int32_t combatStatus; //0x0C38 }; //Size: 0x0C3C +struct rebelUnitName +{ +public: + char* unitName; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + +struct descrRebelEntry +{ +public: + int32_t index; //0x0000 + char* name; //0x0004 + int32_t nameHash; //0x0008 + int32_t category; //0x000C + struct N00022A30* localizedName; //0x0010 + int32_t chance; //0x0014 + struct rebelUnitName unitNames[121]; //0x0018 + int32_t unitCount; //0x0B70 +}; //Size: 0x0B74 + //unit data struct unit { undefined field0_0x0[4]; @@ -2645,6 +2813,10 @@ struct stackStruct { /* structure of stack */ char pad_0134[16]; //0x0134 int32_t battleAllianceOrSomething; //0x0144 int32_t battleDifficulty; //0x0148 + int8_t isHalfDestroyed; //0x014C + char pad_014D[15]; //0x014D + struct descrRebelEntry* descrRebel; //0x015C + int32_t subFactionID; //0x0160 }; struct coords { @@ -2700,6 +2872,77 @@ struct battleFactionCounter int32_t wonLostRatio; //0x0008 }; //Size: 0x000C +struct recruitRome +{ + char pad[8]; +}; + + +struct decisionValuesLTGD +{ +public: + int32_t defendType; //0x0000 + int32_t defendPriority; //0x0004 + int32_t invasionType; //0x0008 + int32_t invadePriority; //0x000C + int8_t atWar; //0x0010 + int8_t wantPeace; //0x0011 + int8_t wantAlly; //0x0012 + int8_t wantBeProtect; //0x0013 + int8_t wantOfferProtect; //0x0014 + char pad_0015[3]; //0x0015 + int32_t allianceAgainst; //0x0018 + int32_t ptsDesire; //0x001C + int32_t ptsAlliance; //0x0020 + int32_t N0002EF7A; //0x0024 + int32_t N0002EF7B; //0x0028 + int8_t canForceInvade; //0x002C + char pad_002D[3]; //0x002D +}; //Size: 0x0030 + +struct aiLongTermGoalDirector +{ +public: + char pad_0000[4]; //0x0000 + struct aiFaction* aiFaction; //0x0004 + struct factionStruct* faction; //0x0008 + uint32_t trustedAllyEnemies; //0x000C --bitfield + int32_t freeStrengthEnemy; //0x0010 + int32_t freeStrengthEnemyBalance; //0x0014 + int8_t consideringNavalInvasion; //0x0018 + char pad_0019[15]; //0x0019 + struct decisionValuesLTGD longTermGoalValues[31]; //0x0028 + int32_t N0002EFB5; //0x05F8 + int32_t freeStrengthBalanceLevel; //0x05FC + char pad_0600[4]; //0x0600 +}; //Size: 0x0604 + +struct aiFaction +{ +public: + char pad_0000[4]; //0x0000 + struct factionStruct* faction; //0x0004 + int32_t FactionId; //0x0008 + char pad_000C[4]; //0x000C + int8_t N00001E8C; //0x0010 + int8_t N0002F25A; //0x0011 + char pad_0012[14]; //0x0012 + struct aiLongTermGoalDirector* aiLongTermGoalDirector; //0x0020 + struct aiDiplomacyManager* aiDiplomacyManager; //0x0024 + struct aiActionRequestController* aiActionRequestController; //0x0028 + struct aiResourceManager* aiResourceManager; //0x002C + struct AiFinanceManager* AiFinanceManager; //0x0030 + struct aiPersonalityValues* aiProductionControllers; //0x0034 + struct aiGlobalStrategyDirector* aiGlobalStrategyDirector; //0x0038 + struct aiSubterFugeController* aiSubterFugeController; //0x003C + struct aiNamedCharacterController* aiNamedCharacterController; //0x0040 + struct aiPriestController* aiPriestController; //0x0044 + struct aiMerchantController* aiMerchantController; //0x0048 + char pad_004C[4]; //0x004C + void* N0001D8FD; //0x0050 + void* N0001D8FE; //0x0054 +}; //Size: 0x0058 + //faction struct factionStruct { undefined field_0x0[180]; @@ -2712,12 +2955,12 @@ struct factionStruct { struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - struct aiFaction* AIFaction; //0x00D8 + struct aiFaction* aiFaction; //0x00D8 int32_t AIPersonalityType; //0x00DC int32_t AIPersonalityName; //0x00E0 char pad_00E4[12]; //0x00E4 struct holdRegionsWinCondition* WinConditions; //0x00F0 - int32_t someInteger; //0x00F4 + int32_t regionsOwnedStart; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ @@ -2738,7 +2981,7 @@ struct factionStruct { int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ int32_t watchtowersSize; //0x0144 - int wathtowersNum; + int watchtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ int32_t portBuildingsSize; //0x0150 int portBuildingsNum; @@ -2746,7 +2989,9 @@ struct factionStruct { int* neighBourRegions; //0x015C int32_t neighBourRegionsSize; //0x0160 int32_t neighBourRegionsNum; //0x0164 - char pad_0168[49]; //0x0168 + char pad_0168[44]; //0x0168 + int32_t deadStatus; //0x0194 3 means until resurrected 4 means until emerged + int8_t reEmergent; //0x0198 int8_t isUndiscovered; //0x0199 char pad_019A[2]; //0x019A factionTileStruct* tilesFac; @@ -2757,15 +3002,29 @@ struct factionStruct { struct factionRanking* factionRankings; //0x01DC int32_t factionRankingsSize; //0x01E0 int32_t factionRankingsCount; //0x01E4 - char pad_01E8[24]; //0x01E8 - int32_t freezeFactionAI; //0x0200 - char pad_0204[2096]; //0x0204 + char pad_01E8[12]; //0x01E8 + int32_t triumphValue; //0x01F4 + uint32_t someBitField; //0x01F8 + float someFloat; //0x01FC + int8_t freezeFactionAI; //0x0200 + char pad_0201[3]; //0x0201 + struct capabilityStruct factionCapabilities; + int8_t hasSettlementsProcessed; //0x0A30 + char pad_0A31[3]; //0x0A31 int32_t treasuryTurnStart; //0x0A34 char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ undefined field_0xa44[16]; int8_t isFactionExcommunicated; //0x0A54 - char pad_0A55[67]; //0x0A55 + char pad_0A55[3]; //0x0A55 + int32_t glory; //0x0A34 + char pad_0A5C[36]; //0x0A5C + float* resourceModifiers; + DWORD resourceModifiersEnd; + DWORD resourceModifiersEnd2; + int32_t factionBannerIndex; //0x0AA0 + int32_t agentNameFactionId[12]; //0x0AA4 + char pad_0AD4[24]; //0x0AD4 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; @@ -3044,8 +3303,8 @@ struct someFactNameStruct { }; //pointer to ancillary -struct anchData { /* data of the ancillary */ - struct anchillary* dataAnch; +struct ancData { /* data of the ancillary */ + struct ancillary* dataAnch; }; //data of one soldier in unit From 0c67fa0a590b4a5bb7af600849d99ee5a04fb8f3 Mon Sep 17 00:00:00 2001 From: FynnTW Date: Thu, 19 Oct 2023 00:31:45 +0300 Subject: [PATCH 19/22] another update (WIP) --- M2TWEOP Code/M2TWEOP library/realGameTypes.h | 55 +- M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h | 6 +- M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp | 111 +++++ M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h | 14 + .../generalCharactericticsHelpers.cpp | 16 +- .../luaPlugin/generalCharactericticsHelpers.h | 6 +- M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h | 28 +- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 21 +- M2TWEOP-luaPlugin/luaPlugin/luaP.h | 2 +- M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 87 +++- M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp | 12 +- M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 469 +++++++++++++++--- .../luaPlugin/settlementHelpers.cpp | 8 +- 13 files changed, 692 insertions(+), 143 deletions(-) diff --git a/M2TWEOP Code/M2TWEOP library/realGameTypes.h b/M2TWEOP Code/M2TWEOP library/realGameTypes.h index 60521bc90..3ded769b7 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -753,7 +753,17 @@ struct factionDiplomacy int trade; /* trade rights(0 or 1) */ int protectorate; /* protectorate or not(15 or 6) */ float factionStanding; //0x0010 - char pad_0014[116]; //0x0014 + char pad_0014[4]; //0x0014 + int32_t numTurnsAllied; //0x0018 + int32_t numTurnsWar; //0x001C + int32_t numTurnsPeace; //0x0020 + int32_t numTurnsTrade; //0x0024 + int32_t numTurnsAccess; //0x0028 + char pad_002C[72]; //0x002C + int32_t turnsSinceMapInfoGiven; //0x0074 -no start at 0 but like 10 on campaign start + char pad_0078[8]; //0x0078 + int32_t turnsSinceMapInfoTaken; //0x0080 -no start at 0 but like 10 on campaign start + int32_t numTurnsCeasefire; //0x0084 }; //Size: 0x0088 struct trackedCharacter @@ -2878,6 +2888,49 @@ struct recruitRome }; +struct militaryValuesLTGD +{ + int32_t totalPopulation; //0x0000 + int32_t tileCount; //0x0004 + int32_t averagePopulation; //0x0008 + int32_t productionValue; //0x000C + int32_t nonAlliedBorderLength; //0x0010 + int32_t enemyBorderLength; //0x0014 + int32_t fleetCount; //0x0018 + int32_t navalPowerPerFleet; //0x001C + int32_t navalStrength; //0x0020 + int32_t armyCount; //0x0024 + int32_t strengthPerArmy; //0x0028 + int32_t totalStrength; //0x002C + int32_t freeStrength; //0x0030 + int32_t neighbourEnemyNum; //0x0034 + int32_t enemyStrength; //0x0038 + int32_t protectorateOf; //0x003C +}; + +struct strategyValuesLTGD +{ + int32_t borderTiles; //0x0000 + int32_t frontLineBalance; //0x0004 + int8_t hasAllianceAgainst; //0x0008 + int8_t isStrongestNeighbour; //0x0009 + int8_t isWeakestNeighbour; //0x000A + char pad_000B[1]; //0x000B + +}; + +struct dataLTGD +{ +public: + struct factionStruct *currentFaction; //0x0000 + char pad_0004[8]; //0x0004 + uint32_t N00024EDA; //0x000C + char pad_0010[4]; //0x0010 + struct militaryValuesLTGD militaryValuesLTGD[31]; //0x0014 + struct strategyValuesLTGD strategyValuesLTGD[31][31]; //0x07D4 +}; + + struct decisionValuesLTGD { public: diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h index 08dd4bee0..095b2d0a9 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h @@ -179,9 +179,9 @@ class basicFuncs ProcLoader attackCharacter; - ProcLoader addAnchillary; - ProcLoader removeAnchillary; - ProcLoader findAnchillary; + ProcLoader addAncillary; + ProcLoader removeAncillary; + ProcLoader findAncillary; ProcLoader addTrait; ProcLoader removeTrait; diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp index b43dd1b7d..bbfb23850 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.cpp @@ -801,12 +801,61 @@ namespace gameHelpers oneTile* getRegionSeaEdge(const regionStruct* region, const int index) { + if (index >= region->regionSeaEdgesCount) + return nullptr; gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); stratMap* map = gameDataAll->stratMap; return &map->tilesArr[region->regionSeaEdges[index]]; } + oneTile* getDevastatedTile(const regionStruct* region, const int index) + { + if (index >= region->devastatedTilesCount) + return nullptr; + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + + return &map->tilesArr[region->devastatedTiles[index]]; + } + + int getHostileArmiesStrength(const regionStruct* region, const int factionID) + { + return region->armiesHostileToArrayIndexIDStrength[factionID]; + } + + bool isDevastated(const oneTile* tile) + { + return tile->hasRoad & 1; + } + + oneTileDouble* tileToDoubleTile(const oneTile* tile) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + int mapWidth = map->mapWidth * 2 + 1; + auto coords = getTileCoords(tile); + return &map->climateTileArray[(coords->yCoord * 2) * mapWidth + (coords->xCoord * 2)]; + } + + float getTileHeight(const oneTile* tile) + { + return tileToDoubleTile(tile)->height; + } + + int getTileClimate(const oneTile* tile) + { + return tileToDoubleTile(tile)->climate; + } + + int getTileHeatValue(const oneTile* tile) + { + gameDataAllStruct* gameDataAll = gameDataAllHelper::get(); + stratMap* map = gameDataAll->stratMap; + auto climate = tileToDoubleTile(tile)->climate; + return map->climates->climateArray[climate].heatValue; + } + float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo) { if (turnsAgo > 19) @@ -874,6 +923,68 @@ namespace gameHelpers return region->resourceTypesBitMap & (1 << resourceType); } + /* + strategy map object types + 0 -> 27 = resource ID + 28 = character + 29 = settlement + 30 = fort + 31 = port + 32 = watchTower + 33 = sundry + 34 = rally point + 35 = floatingGeneral + 36 = battleSiteMarker + */ + + DWORD* getTileObject(const oneTile* tile, int type) + { + DWORD* object = tile->object; + + while (object) + { + int objectType = CallVFunc<4, int>(object); + if (objectType == type || (type == 0 && objectType < 28)) + return object; + object = reinterpret_cast(*(object + 1)); + } + + return nullptr; + } + + resStrat* getTileResource(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 0)); + } + + general* getTileCharacter(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 28)); + } + + settlementStruct* getTileSettlement(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 29)); + } + + fortStruct* getTileFort(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 30)); + } + + portBuildingStruct* getTilePort(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 31)); + } + + watchTowerStruct* getTileWatchtower(const oneTile* tile) + { + return reinterpret_cast(getTileObject(tile, 32)); + } + + + + } diff --git a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h index 40d35af71..5ec86eac9 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/gameHelpers.h @@ -92,11 +92,13 @@ namespace gameHelpers bool tileHasSettlement(const oneTile* tile); bool factionHasArmyNearTile(const oneTile* tile, int factionID); bool factionHasCharacterOnTile(const oneTile* tile, int factionID); + int getHostileArmiesStrength(const regionStruct* region, const int factionID); coordPair* convertTileCoords(DWORD arrayIndex); coordPair* getTileCoords(const oneTile* tile); seaConnectedRegion* getSeaConnectedRegion(const regionStruct* region, const int index); seaConnectedRegion* getSeaImportRegion(const regionStruct* region, const int index); oneTile* getRegionSeaEdge(const regionStruct* region, const int index); + oneTile* getDevastatedTile(const regionStruct* region, const int index); float getReligionHistory(const regionStruct* region, const int religionID, int turnsAgo); oneTile* getTileBorderingEdgeOfMap(const regionStruct* region, const int index); oneTile* getTileRegion(const regionStruct* region, const int index); @@ -104,6 +106,18 @@ namespace gameHelpers bool hasResourceType(const regionStruct* region, const int resourceType); oneTile* getReachableTile(const seaConnectedRegion* region, int index); coordPair* getTradeLaneCoord(const seaConnectedRegion* region, int index); + bool isDevastated(const oneTile* tile); + oneTileDouble* tileToDoubleTile(const oneTile* tile); + float getTileHeight(const oneTile* tile); + int getTileClimate(const oneTile* tile); + int getTileHeatValue(const oneTile* tile); + DWORD* getTileObject(const oneTile* tile, int type); + resStrat* getTileResource(const oneTile* tile); + general* getTileCharacter(const oneTile* tile); + settlementStruct* getTileSettlement(const oneTile* tile); + fortStruct* getTileFort(const oneTile* tile); + portBuildingStruct* getTilePort(const oneTile* tile); + watchTowerStruct* getTileWatchtower(const oneTile* tile); int getMercUnitNum(mercPool* mercPool); mercPoolUnit* getMercUnit(mercPool* pool, int index); diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp index c56dd960b..cf3b28dcf 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp @@ -6,21 +6,21 @@ namespace generalCharactericticsHelpers { return character->traits; } - anchillary* getAnchillary(namedCharacter* character, int index) + ancillary* getAncillary(namedCharacter* character, int index) { - return character->anchillaries[index]->dataAnch; + return character->ancillaries[index]->dataAnc; } - int addAnchillary(namedCharacter* character, std::string anchName) + int addAncillary(namedCharacter* character, std::string ancName) { - anchillary* anch = (*(*plugData::data.funcs.findAnchillary))((char*)anchName.c_str()); - if (anch == nullptr)return 0; + ancillary* anc = (*(*plugData::data.funcs.findAncillary))((char*)ancName.c_str()); + if (anc == nullptr)return 0; - return (*(*plugData::data.funcs.addAnchillary))(character, anch); + return (*(*plugData::data.funcs.addAncillary))(character, anc); } - void removeAnchillary(namedCharacter* character, anchillary* anch) + void removeAncillary(namedCharacter* character, ancillary* anc) { - (*(*plugData::data.funcs.removeAnchillary))(character, anch); + (*(*plugData::data.funcs.removeAncillary))(character, anc); } void addTrait(namedCharacter* character, const char* traitName, int traitLevel) { diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h index 23d5b8236..e6901271f 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.h @@ -5,10 +5,10 @@ namespace generalCharactericticsHelpers { traitContainer* getTraits(namedCharacter* character); - anchillary* getAnchillary(namedCharacter* character, int index); - int addAnchillary(namedCharacter* character, std::string anchName); + ancillary* getAncillary(namedCharacter* character, int index); + int addAncillary(namedCharacter* character, std::string ancName); - void removeAnchillary(namedCharacter* character, anchillary* anch); + void removeAncillary(namedCharacter* character, ancillary* anc); void addTrait(namedCharacter* character, const char* traitName, int traitLevel); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h index 9dfc70d15..88b36022e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h @@ -16,8 +16,8 @@ #define EduEntryStruct_InfoCardTga 4 -#define anchillaryStruct_name 1 -#define anchillaryStruct_imagePath 2 +#define ancillaryStruct_name 1 +#define ancillaryStruct_imagePath 2 #include #include "realGameTypes.h" namespace luaGetSetFuncs @@ -35,19 +35,19 @@ namespace luaGetSetFuncs -#pragma region anchillary - //anchillary +#pragma region ancillary + //ancillary template - std::string getStringPropertyAnc(const anchillary* anch) + std::string getStringPropertyAnc(const ancillary* anc) { char* retS = nullptr; - if (fieldIndex == anchillaryStruct_name) + if (fieldIndex == ancillaryStruct_name) { - retS = anch->anchName; + retS = anc->ancName; } - else if (fieldIndex == anchillaryStruct_imagePath) + else if (fieldIndex == ancillaryStruct_imagePath) { - retS = anch->patchToAnchImage; + retS = anc->patchToAncImage; } if (retS != nullptr) @@ -61,18 +61,18 @@ namespace luaGetSetFuncs } template - void setStringPropertyAnc(anchillary* anch, std::string newS) + void setStringPropertyAnc(ancillary* anc, std::string newS) { char* arg = nullptr; - if (fieldIndex == anchillaryStruct_name) + if (fieldIndex == ancillaryStruct_name) { - arg = reinterpret_cast(&anch->anchName); + arg = reinterpret_cast(&anc->ancName); } - else if (fieldIndex == anchillaryStruct_imagePath) + else if (fieldIndex == ancillaryStruct_imagePath) { - arg = reinterpret_cast(&anch->patchToAnchImage); + arg = reinterpret_cast(&anc->patchToAncImage); } setGameString(arg, newS.c_str()); } diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index 51bb8d3c6..c4abaa2c1 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -102,7 +102,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypecapturedFactionInfo; sol::usertypecapturedUnit; sol::usertypecapturedCharacter; - sol::usertypeancillary; + sol::usertypeancillary; sol::usertypetraitContainerT; sol::usertypeEduEntry; sol::usertypefactionStruct; @@ -1597,7 +1597,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) ourNamedCharacter:removeTrait("GoodCommander"); */ types.namedCharacter.set_function("removeTrait", &generalCharactericticsHelpers::removeTrait); - types.namedCharacter.set("ancNum", &namedCharacter::anchNum); + types.namedCharacter.set("ancNum", &namedCharacter::ancNum); /*** Get the pointer to the ancillary using it's index. You can iterate over a character's ancillaries for example by going from index 0 to ancNum - 1. @function namedCharacter:getAncillary @@ -1606,7 +1606,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @usage ancillary = ourNamedCharacter:getAncillary(2) */ - types.namedCharacter.set_function("getAncillary", &generalCharactericticsHelpers::getAnchillary); + types.namedCharacter.set_function("getAncillary", &generalCharactericticsHelpers::getAncillary); /*** Add an ancillary to the named character using the name per export\_descr\_ancillaries.txt. @function namedCharacter:addAncillary @@ -1614,7 +1614,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @usage ourNamedCharacter:addAncillary("VeryVeryGoodMan"); */ - types.namedCharacter.set_function("addAncillary", &generalCharactericticsHelpers::addAnchillary); + types.namedCharacter.set_function("addAncillary", &generalCharactericticsHelpers::addAncillary); /*** Remove an ancillary from the named character using it's pointer. Use getAncillary function to get the specific ancillary. @function namedCharacter:removeAncillary @@ -1623,7 +1623,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) ourAnc=ourNamedCharacter:getAncillary(2); ourNamedCharacter:removeAncillary(ourAnc); */ - types.namedCharacter.set_function("removeAncillary", &generalCharactericticsHelpers::removeAnchillary); + types.namedCharacter.set_function("removeAncillary", &generalCharactericticsHelpers::removeAncillary); types.namedCharacter.set("level", &namedCharacter::level); types.namedCharacter.set("authority", &namedCharacter::leaderAutority); types.namedCharacter.set("command", &namedCharacter::authority); @@ -1779,13 +1779,13 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @table ancillary */ - types.ancillary = luaState.new_usertype("ancillary"); - types.ancillary.set("index", &anchillary::index); + types.ancillary = luaState.new_usertype("ancillary"); + types.ancillary.set("index", &ancillary::index); types.ancillary.set("name", sol::property( - &luaGetSetFuncs::getStringPropertyAnc, &luaGetSetFuncs::setStringPropertyAnc + &luaGetSetFuncs::getStringPropertyAnc, &luaGetSetFuncs::setStringPropertyAnc )); types.ancillary.set("imagePath", sol::property( - &luaGetSetFuncs::getStringPropertyAnc, &luaGetSetFuncs::setStringPropertyAnc + &luaGetSetFuncs::getStringPropertyAnc, &luaGetSetFuncs::setStringPropertyAnc )); @@ -2013,7 +2013,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) print(portList) */ types.factionStruct.set_function("getPort", &factionHelpers::getPort); - types.factionStruct.set("watchtowersNum", &factionStruct::wathtowersNum); + types.factionStruct.set("watchtowersNum", &factionStruct::watchtowersNum); /*** Get a watchtower using it's index. @function factionStruct:getWatchtower @@ -2532,7 +2532,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.settlementStruct.set("settlementTaxLevel", &settlementStruct::settlementTaxLevel); types.settlementStruct.set("isProvokedRebellion", &settlementStruct::isProvokedRebellion); types.settlementStruct.set("populationSize", &settlementStruct::populationSize); - types.settlementStruct.set("recruitPoolCapabilityCount", &settlementStruct::recruitPoolCapabilityCount); types.settlementStruct.set("recruitmentPoolCount", &settlementStruct::recruitmentPoolCount); types.settlementStruct.set("freezeRecruitmentPool", &settlementStruct::freezeRecruitmentPool); types.settlementStruct.set("spiesInRecruitmentQueue", &settlementStruct::spiesInRecruitmentQueue); diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.h b/M2TWEOP-luaPlugin/luaPlugin/luaP.h index 2f89f5c87..56fe95b4a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -128,7 +128,7 @@ class luaP sol::usertypeunit; sol::usertypecharacter; sol::usertypenamedCharacter; - sol::usertypeancillary; + sol::usertypeancillary; sol::usertypetraitContainerT; sol::usertypeEduEntry; sol::usertypefactionStruct; diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index 21015ecb3..d511dafab 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -802,6 +802,7 @@ void luaP::initCampaign() @tfield int regionIdStart @tfield int regionIdEnd @tfield getCoord getCoord + @tfield int tradeValue --only counts from 1 side (importer) @table roadStruct */ @@ -809,6 +810,7 @@ void luaP::initCampaign() typeAll.roadStruct.set("coordsNum", &roadStruct::coordsNum); typeAll.roadStruct.set("regionIdStart", &roadStruct::regionIdStart); typeAll.roadStruct.set("regionIdEnd", &roadStruct::regionIdEnd); + typeAll.roadStruct.set("tradeValue", &roadStruct::tradeValue); /*** Get a road coord by index. @@ -846,17 +848,27 @@ void luaP::initCampaign() 14 impassable_land 15 impassable_sea @tfield int regionID + @tfield tradeResource|nil resource + @tfield character|nil character + @tfield settlement|nil settlement + @tfield fortStruct|nil fort + @tfield portStruct|nil port + @tfield watchTowerStruct|nil watchtower + @tfield int height + @tfield int climate + @tfield int heatValue @tfield int factionID @tfield coordPair coords @tfield int objectTypes bitfield, from left to right: unknown, character, ship, watchtower, port, unknown, fort, settlement. @tfield bool hasRiver @tfield bool hasCrossing - @tfield bool tileHasCharacter - @tfield bool tileHasShip - @tfield bool tileHasWatchtower - @tfield bool tileHasPort - @tfield bool tileHasFort - @tfield bool tileHasSettlement + @tfield bool hasCharacter + @tfield bool hasShip + @tfield bool hasWatchtower + @tfield bool hasPort + @tfield bool hasFort + @tfield bool hasSettlement + @tfield bool isDevastated @tfield int borderingSettlement 1 = bordering 2 = settlement. @tfield int border 1 = border, 2 = seaBorder, 3 = sea edge border (point where the region border both another land region and sea). @tfield int armiesNearTile bitfield of faction id's (counts both tile and the 8 tiles around it, if you want only on tile combine with charactersOnTile). @@ -879,12 +891,22 @@ void luaP::initCampaign() typeAll.tileStruct.set("hasRiver", sol::property(gameHelpers::tileHasRiver)); typeAll.tileStruct.set("hasCrossing", sol::property(gameHelpers::tileHasCrossing)); typeAll.tileStruct.set("border", sol::property(gameHelpers::tileBorderType)); - typeAll.tileStruct.set("tileHasCharacter", sol::property(gameHelpers::tileHasCharacter)); - typeAll.tileStruct.set("tileHasShip", sol::property(gameHelpers::tileHasShip)); - typeAll.tileStruct.set("tileHasWatchtower", sol::property(gameHelpers::tileHasWatchtower)); - typeAll.tileStruct.set("tileHasPort", sol::property(gameHelpers::tileHasPort)); - typeAll.tileStruct.set("tileHasFort", sol::property(gameHelpers::tileHasFort)); - typeAll.tileStruct.set("tileHasSettlement", sol::property(gameHelpers::tileHasSettlement)); + typeAll.tileStruct.set("hasCharacter", sol::property(gameHelpers::tileHasCharacter)); + typeAll.tileStruct.set("hasShip", sol::property(gameHelpers::tileHasShip)); + typeAll.tileStruct.set("hasWatchtower", sol::property(gameHelpers::tileHasWatchtower)); + typeAll.tileStruct.set("hasPort", sol::property(gameHelpers::tileHasPort)); + typeAll.tileStruct.set("hasFort", sol::property(gameHelpers::tileHasFort)); + typeAll.tileStruct.set("hasSettlement", sol::property(gameHelpers::tileHasSettlement)); + typeAll.tileStruct.set("isDevastated", sol::property(gameHelpers::isDevastated)); + typeAll.tileStruct.set("height", sol::property(gameHelpers::getTileHeight)); + typeAll.tileStruct.set("climate", sol::property(gameHelpers::getTileClimate)); + typeAll.tileStruct.set("heatValue", sol::property(gameHelpers::getTileHeatValue)); + typeAll.tileStruct.set("resource", sol::property(gameHelpers::getTileResource)); + typeAll.tileStruct.set("character", sol::property(gameHelpers::getTileCharacter)); + typeAll.tileStruct.set("settlement", sol::property(gameHelpers::getTileSettlement)); + typeAll.tileStruct.set("fort", sol::property(gameHelpers::getTileFort)); + typeAll.tileStruct.set("port", sol::property(gameHelpers::getTilePort)); + typeAll.tileStruct.set("watchtower", sol::property(gameHelpers::getTileWatchtower)); typeAll.tileStruct.set("armiesNearTile", &oneTile::armiesNearTile); typeAll.tileStruct.set("charactersOnTile", &oneTile::charactersOnTile); typeAll.tileStruct.set("mpModifier", &oneTile::mpModifier); @@ -920,6 +942,11 @@ void luaP::initCampaign() @tfield string settlementName @tfield string legioName @tfield int regionID + @tfield int roadLevel as set in descr_strat + @tfield int farmingLevel as set in descr_strat + @tfield int famineThreat + @tfield int harvestSuccess + @tfield int totalSeaTradeValue @tfield int stacksNum @tfield int fortsNum @tfield int watchtowersNum @@ -931,9 +958,9 @@ void luaP::initCampaign() @tfield int loyaltyFactionID @tfield seaConnectedRegion seaExportRegion @tfield int seaImportRegionsCount - @tfield int canSeaTrade @tfield int regionSeaEdgesCount (point where the region border both another land region and sea). @tfield int tilesBorderingEdgeOfMapCount + @tfield int devastatedTilesCount @tfield settlementStruct settlement @tfield int tileCount @tfield int fertileTilesCount @@ -964,6 +991,8 @@ void luaP::initCampaign() @tfield getTileBorderingEdgeOfMap getTileBorderingEdgeOfMap @tfield getTile getTile @tfield getFertileTile getFertileTile + @tfield getDevastatedTile getDevastatedTile + @tfield getHostileArmiesStrength getHostileArmiesStrength @tfield hasResourceType hasResourceType @table region @@ -976,9 +1005,13 @@ void luaP::initCampaign() )); typeAll.region.set("legioName", ®ionStruct::legioName); typeAll.region.set("regionID", ®ionStruct::regionID); + typeAll.region.set("roadLevel", ®ionStruct::roadLevel); + typeAll.region.set("farmingLevel", ®ionStruct::farmingLevel); + typeAll.region.set("famineThreat", ®ionStruct::famineThreat); + typeAll.region.set("harvestSuccess", ®ionStruct::harvestSuccess); + typeAll.region.set("totalSeaTradeValue", ®ionStruct::totalSeaTradeValue); typeAll.region.set("seaConnectedRegionsCount", ®ionStruct::seaConnectedRegionsCount); typeAll.region.set("seaImportRegionsCount", ®ionStruct::seaImportRegionsCount); - typeAll.region.set("canSeaTrade", ®ionStruct::canSeaTrade); typeAll.region.set("landMass", ®ionStruct::landMass); typeAll.region.set("roadToPort", ®ionStruct::roadToPort); typeAll.region.set("seaExportRegion", ®ionStruct::seaExportRegion); @@ -1129,6 +1162,18 @@ void luaP::initCampaign() */ typeAll.region.set_function("getRegionSeaEdge", &gameHelpers::getRegionSeaEdge); + /*** + Get a devastated tile. + @function region:getDevastatedTile + @tparam int index + @treturn tileStruct tile + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local tile = region:getDevastatedTile(0) + */ + typeAll.region.set_function("getDevastatedTile", &gameHelpers::getDevastatedTile); + /*** Get a tile that borders the edge of the map. @function region:getTileBorderingEdgeOfMap @@ -1190,6 +1235,18 @@ void luaP::initCampaign() */ typeAll.region.set_function("hasResourceType", &gameHelpers::hasResourceType); + /*** + Get the strength total of all armies in this region that are hostile to a specific faction. + @function region:getHostileArmiesStrength + @tparam int factionID + @treturn int totalStrength + @usage + local sMap = gameDataAll.get().stratMap; + local region = sMap.getRegion(2); + local totalStrength = region:getHostileArmiesStrength(myFac.dipNum) + */ + typeAll.region.set_function("getHostileArmiesStrength", &gameHelpers::getHostileArmiesStrength); + ///neighbourRegion //@section neighbourRegion @@ -1199,6 +1256,7 @@ void luaP::initCampaign() @tfield int regionID @tfield regionStruct region @tfield int tradeValue + @tfield bool alliedRegion @tfield int borderTilesCount @tfield roadStruct connectingRoad @tfield getBorderTile getBorderTile @@ -1212,6 +1270,7 @@ void luaP::initCampaign() typeAll.neighbourRegion.set("region", &neighbourRegion::region); typeAll.neighbourRegion.set("borderTilesCount", &neighbourRegion::borderTilesCount); typeAll.neighbourRegion.set("connectingRoad", &neighbourRegion::connectingRoad); + typeAll.neighbourRegion.set("alliedRegion", &neighbourRegion::alliedRegion); /*** Get a border tile by index. diff --git a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp index ac7fc119d..e536ec6a7 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/pluginM2TWEOP.cpp @@ -176,14 +176,14 @@ int initPlugin(std::string* modPath) fName = "siegeSettlement"; plugData::data.funcs.siegeSettlement.Load(&plPath, &fName); - fName = "addAnchillary"; - plugData::data.funcs.addAnchillary.Load(&plPath, &fName); + fName = "addAncillary"; + plugData::data.funcs.addAncillary.Load(&plPath, &fName); - fName = "removeAnchillary"; - plugData::data.funcs.removeAnchillary.Load(&plPath, &fName); + fName = "removeAncillary"; + plugData::data.funcs.removeAncillary.Load(&plPath, &fName); - fName = "findAnchillary"; - plugData::data.funcs.findAnchillary.Load(&plPath, &fName); + fName = "findAncillary"; + plugData::data.funcs.findAncillary.Load(&plPath, &fName); fName = "addTrait"; plugData::data.funcs.addTrait.Load(&plPath, &fName); diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index ceb4a48e0..ea3295815 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -195,7 +195,7 @@ struct seaConnectedRegion float distance; //0x000C int32_t seaExportValue; //0x0010 int32_t seaImportValue; //0x0014 - struct floatsSeaConnect *tilesReachable; //0x0018 + struct floatsSeaConnect* tilesReachable; //0x0018 int32_t tilesReachableSize; //0x001C int32_t tilesReachableCount; //0x0020 struct coordPair* seaTradeLanePath; //0x0024 @@ -211,11 +211,11 @@ struct regionStruct { int settlementNameHash;//0x000C char* legioName; /* null for sea *///0x0010 int legioNameHash;//0x0014 - undefined field4_0x10[4];//0x0018 + struct legioString* legioPointer; //0x0018 int regionID;//0x001C - int32_t N00008C49; //0x0020 - int32_t N00008C4A; //0x0024 - int32_t overOneAllowsFamine; //0x0028 + int32_t roadLevel; //0x0020 + int32_t farmingLevel; //0x0024 + int32_t famineThreat; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -235,22 +235,27 @@ struct regionStruct { int32_t seaConnectedRegionsCount; //0x0064 int32_t loyaltyFactionID; //0x0068 struct seaConnectedRegion* seaExportRegion; //0x006C - char pad_0070[12]; //0x0070 + struct seaConnectedRegion* seaExportRegion2; //0x0070 --disk/dlc only + struct seaConnectedRegion* seaExportRegion3; //0x0074 --disk/dlc only + struct seaConnectedRegion* seaExportRegion4; //0x0078 --disk/dlc only struct seaConnectedRegion** seaImportRegions; //0x007C int32_t seaImportRegionsSize; //0x0080 int32_t seaImportRegionsCount; //0x0084 - int32_t canSeaTrade; //0x0088 + int32_t tradeFleetCount; //0x0088 struct mercPool* mercPool;//0x008C int32_t* regionSeaEdges; //0x0090 int32_t regionSeaEdgesSize; //0x0094 int32_t regionSeaEdgesCount; //0x0098 - char pad_009C[24]; //0x009C + char pad_009C[12]; //0x009C + int32_t* devastatedTiles; //0x00A8 + int32_t devastatedTilesSize; //0x00AC + int32_t devastatedTilesCount; //0x00B0 float* religionsARR;//0x00B4 float* religionHistory[20]; uint32_t* tilesBorderingEdgeOfMap; //0x0108 int32_t tilesBorderingEdgeOfMapSize; //0x010C int32_t tilesBorderingEdgeOfMapCount; //0x0110 - char pad_0114[124]; //0x0114 + int32_t armiesHostileToArrayIndexIDStrength[31]; //0x0114 struct settlementStruct* settlement;//0x0190 int* tiles; //0x0194 int32_t tilesSize; //0x0198 @@ -274,7 +279,10 @@ struct regionStruct { int32_t settlementYCoord; //0x01E0 int32_t portEntranceXCoord; //0x01E4 int32_t portEntranceYCoord; //0x01E8 - char pad_01EC[4]; //0x01EC + uint8_t colorBlue; //0x01EC + uint8_t colorGreen; //0x01ED + uint8_t colorRed; //0x01EE + char pad_01EF[1]; //0x01EF struct factionStruct* factionOwner;//0x01F0 char pad_01F4[4]; //0x01F4 UNICODE_STRING** localizedRegionName; //0x01F8 @@ -282,9 +290,10 @@ struct regionStruct { UNICODE_STRING** localizedRebelsName; //0x0200 char* rebelType; //0x0204 int32_t rebelTypeHash; //0x0208 - int32_t getsCopiedToSettlementAtRebelEndTurn; //0x020C + int32_t harvestSuccess; //0x020C int32_t triumphValue; //0x0210 - char pad_0214[8]; //0x0214 + int32_t N00008CC6; //0x0214 + uint32_t totalSeaTradeValue; //0x0218 };//Size: 0x021C struct neighbourRegion @@ -293,7 +302,8 @@ struct neighbourRegion struct regionStruct* region; //0x0000 int32_t regionID; //0x0004 float distance; //0x0008 - char pad_000C[4]; //0x000C + int8_t alliedRegion; //0x000C + char pad_000D[3]; //0x000D struct roadStruct* connectingRoad; //0x0010 int32_t tradeValue; //0x0014 int32_t* bordertiles; //0x0018 @@ -311,17 +321,78 @@ struct landMass int32_t regionsNum; //0x000C }; //Size: 0x0010 +struct climate +{ +public: + struct rcString* rcString; //0x0000 + struct UNICODE_STRING*** localizedName; //0x0004 + uint8_t colorBlue; //0x0008 + uint8_t colorGreen; //0x0009 + uint8_t colorRed; //0x000A + char pad_000B[1]; //0x000B + int32_t heatValue; //0x000C + uint8_t hasWinter; //0x0010 + char pad_0011[3]; //0x0011 + void* treeModelsSummerSparse; //0x0014 + int32_t treeModelsSummerSparseSize; //0x0018 + int32_t treeModelsSummerSparseNum; //0x001C + void* treeModelsSummerDense; //0x0020 + int32_t treeModelsSummerDenseSize; //0x0024 + int32_t treeModelsSummerDenseNum; //0x0028 + void* treeModelsSummerCanopy; //0x002C + int32_t treeModelsSummerCanopysize; //0x0030 + int32_t treeModelsSummerCanopyNum; //0x0034 + void* treeModelsWinterSparse; //0x0038 + int32_t treeModelsWinterSparsesize; //0x003C + int32_t treeModelsWinterSparseNum; //0x0040 + void* treeModelsWinterDense; //0x0044 + int32_t treeModelsWinterDensesize; //0x0048 + int32_t treeModelsWinterDenseNum; //0x004C + void* treeModelsWinterCanopy; //0x0050 + int32_t treeModelsWinterCanopySize; //0x0054 + int32_t treeModelsWinterCanopyNum; //0x0058 +}; //Size: 0x005C + +struct climates +{ +public: + char pad_0000[4]; //0x0000 + struct climate* climateArray; //0x0004 + int32_t climatesSize; //0x0008 + int32_t climatesNum; //0x000C +}; //Size: 0x0010 + +struct oneTileDouble +{ +public: + float height; //0x0000 + int8_t climate; //0x0004 + int8_t groundType; //0x0005 + int8_t Nx0006; //0x0006 + int8_t Nx0007; //0x0007 +}; //Size: 0x0008 + struct stratMap { undefined field_0x0[4]; struct UNICODE_STRING** campaignName; //0x0004 struct UNICODE_STRING*** campaignPath; //0x0008 - char pad_000C[28]; //0x000C - void* climates; //0x0028 + float minRoughness; //0x000C + float maxRoughness; //0x0010 + float maxLandHeight; //0x0014 + float minSeaHeight; //0x0018 + float fractalMultiplier; //0x001C + float lattitudeMin; //0x0020 + float lattitudeMax; //0x0024 + climates* climates; //0x0028 int mapWidth; int mapHeight; - undefined field_0x34[20]; + float N00008987; //0x0034 + uint32_t N00008988; //0x0038 + char pad_003C[4]; //0x003C + void* storesMapRoughness; //0x0040 + struct oneTileDouble* climateTileArray; //0x0044 struct oneTile* tilesArr; - DWORD TileListEnd; //0x004C + DWORD arraySmthing; //0x004C undefined field_0x50[20]; struct coordPair* volcanoes; //0x0064 int32_t volcanoesSize; //0x0068 @@ -423,11 +494,12 @@ struct roadStruct int32_t someOtherArrayCount; //0x0014 int32_t regionIdStart; //0x0018 int32_t regionIdEnd; //0x001C - char pad_0020[24]; //0x0020 + int32_t tradeValue; //0x0020 + char pad_0020[20]; //0x0020 }; //Size: 0x0038 struct oneTile { - void* object; + DWORD* object; //can be character, resource, fort, struct roadStruct* road; //0x0004 undefined field_0x8[2]; int8_t isLand; @@ -442,7 +514,7 @@ struct oneTile { int8_t borderingRiver; int8_t borderingSettlement; undefined field_0x1F[1]; - int8_t hasRoad; + int8_t hasRoad; //bit 1 has devastation status int8_t border; undefined field_0x22[2]; int8_t objectTypes; //bit87_character6_ship5_watchtower4_port3_bit32_fort1_settlement0 @@ -471,11 +543,11 @@ struct holdRegionsWinCondition { public: char pad_0000[4]; //0x0000 - int32_t intSomethingTurns; //0x0004 + uint32_t stratTableStringIndex; //0x0004 struct stringWithHash* regionsToHold; //0x0008 int32_t regionsToHoldSize; //0x000C int32_t regionsToHoldCount; //0x0010 - char pad_0014[4]; //0x0014 + uint32_t factionsToOutliveBitfield; //0x0014 int32_t numberOfRegions; //0x0018 char pad_001C[4]; //0x001C int32_t* holdRegionLengths; //0x0020 @@ -494,6 +566,26 @@ struct battleSettlement char pad_0010[304]; //0x0010 }; //Size: 0x0140 +struct settlementBuildings +{ +public: + struct buildingBattle** buildingList; //0x0000 + int32_t buildingListSize; //0x0004 + int32_t buildingNum; //0x0008 +}; //Size: 0x000C + +struct battleBuildings +{ +public: + char pad_0000[20]; //0x0000 + struct buildingBattle** allBuildings; //0x0014 + int32_t allBuildingsSize; //0x0020 + int32_t allBuildingsNum; //0x0020 + int32_t* allBuildingsInt; //0x0020 + char pad_0024[8]; //0x0024 + struct settlementBuildings* settlementBuildings; //0x002C +}; //Size: 0x0444 + struct battleResidence { public: @@ -501,7 +593,8 @@ struct battleResidence struct settlementStruct* settlement; //0x001C char pad_0020[16]; //0x0020 int32_t isFortBattle; //0x0030 - char pad_0034[8]; //0x0034 + struct battleBuildings* battleBuildings; //0x0034 + char pad_0038[4]; //0x0038 float N000203C6; //0x003C float N000203C7; //0x0040 char pad_0044[40]; //0x0044 @@ -581,7 +674,7 @@ struct watchTowerModel { //watchtower struct watchTowerStruct { void* watchTowerVtable; //0x0000 - char pad_0004[4]; //0x0004 + DWORD* object; //0x0004 struct character* character; //0x0008 int xCoord; int yCoord; @@ -661,7 +754,17 @@ struct factionDiplomacy int trade; /* trade rights(0 or 1) */ int protectorate; /* protectorate or not(15 or 6) */ float factionStanding; //0x0010 - char pad_0014[116]; //0x0014 + char pad_0014[4]; //0x0014 + int32_t numTurnsAllied; //0x0018 + int32_t numTurnsWar; //0x001C + int32_t numTurnsPeace; //0x0020 + int32_t numTurnsTrade; //0x0024 + int32_t numTurnsAccess; //0x0028 + char pad_002C[72]; //0x002C + int32_t turnsSinceMapInfoGiven; //0x0074 -no start at 0 but like 10 on campaign start + char pad_0078[8]; //0x0078 + int32_t turnsSinceMapInfoTaken; //0x0080 -no start at 0 but like 10 on campaign start + int32_t numTurnsCeasefire; //0x0084 }; //Size: 0x0088 struct trackedCharacter @@ -717,7 +820,8 @@ struct campaign { struct factionStruct* factionsSortedByID[31]; int numberOfFactionsWithSlave; uint32_t existingFactionsBitMap; //0x0324 - char pad_032A[16]; //0x032A + int32_t nonPlayableFactionsNum; //0x0328 + char pad_032C[12]; //0x032C struct collegeOfCardinals* collegeOfCardinals; //0x033C struct factionStruct* papalFaction; //0x0340 struct factionStruct* currentFactionTurn; @@ -834,7 +938,7 @@ struct uiCardManager struct general* selectedCharacter; //0x0198 char pad_019C[12]; //0x019C struct fortStruct* selectedFort; //0x01A8 -}; +}; struct gameDataAllStruct { undefined field_0x0[40]; @@ -1529,9 +1633,16 @@ struct portBuildingStruct { int yCoord; undefined field_0x14[28]; struct settlementStruct* settlement; - undefined field_0x34[20]; + undefined field_0x34[4]; + int tradeFleets; + char pad_0040[8]; //0x0040 struct stackStruct* occupantsArmy; /* if port block by army then it here */ - undefined field_0x4c[24]; + int32_t numTurnsBlocked; //0x004C + int32_t N00008216; //0x0050 + int32_t N00008217; //0x0054 + int32_t rallyCoordX; //0x0058 + int32_t rallyCoordY; //0x005C + void* rallyPoint; //0x0060 struct factionStruct* fac; /* blockading faction becomes owner */ undefined field_0x68[12]; struct stratPortModel* portStratModel; @@ -1779,6 +1890,20 @@ struct settlementRecruitmentPool float availablePool; //0x0004 }; //Size: 0x0008 + +struct capabilityStruct +{ +public: + struct settlementCapability settlementCapabilities[57]; //0x0000 + struct settlementCapability settlementCapabilitiesAgent[6]; //0x00E4 + struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x00FC + struct settlementCapability settlementCapabilitiesAncillaryROME[4]; //0x0114 + struct recruitRome* settlementCapabilitiesRecruitROME[64]; //0x0124 + int32_t recruitCapabilityCount; //0x0324 + struct recruitmentCapability recruitmentCapabilities[64]; //0x0328 + int32_t recruitmentCapabilityCount; //0x0828 +}; //Size: 0x082C + //settlement struct settlementStruct { void* vTable; @@ -1796,10 +1921,14 @@ struct settlementStruct { int populationSiegeStart; undefined pad_8[8]; BYTE plagued; - undefined field8_0xA5[167]; + undefined field8_0xA5[7]; + struct descrRebelEntry* descrRebel; //0x00AC + int32_t subFactionID; //0x00B0 + char pad_00B4[152]; //0x00B4 struct settMod* model; - int descr_culturestxt; - undefined field11_0x154[16]; + int cultureID; + undefined field11_0x154[12]; + struct portBuildingStruct* port; char* name; /* internal name of settlement */ int nameCrypt; UNICODE_STRING** localizedName; @@ -1809,10 +1938,14 @@ struct settlementStruct { int fac_creatorModNum; undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ - undefined field21_0x1a5[3]; + undefined field21_0x1a5[1]; + BYTE turnsOwned; /* start at 10 for settlements owned at game start without specification in descr_strat */ + undefined field21_0x1a7[1]; UINT32 regionID; /* number of region */ - undefined field_0x1ac[12]; - int priceOfUnitsInRecruitmentSlots; + int32_t factionID; //0x01AC + int32_t yearFounded; //0x01B0 + int32_t triumph; //0x01B4 + int queueCost; undefined field24_0xBC[24]; struct unitRQ unitQueue[9]; int startIndexRQ; @@ -1831,24 +1964,20 @@ struct settlementStruct { char pad_0E00[4]; //0x0E00 int8_t scriptRebel; //0x0E04 uchar isProvokedRebellion;//0x0E05 - uchar field31_0xe06[34];//0x0E06 - struct general* governor;//0x0E28 - char pad_0E2C[12]; //0x0E2C + uchar field31_0xe06[10];//0x0E06 + int8_t isCapital; //0x0E10 + char pad_0E11[15]; //0x0E11 + struct general* governor;//0x0E20 + char pad_0E24[16]; //0x0E24 + int32_t somthingPO; //0x0E34 int32_t publicOrderLastTurnEnd; //0x0E38 int32_t populationLastTurnEnd; //0x0E3C - char pad_0E40[4]; //0x0E40 + int32_t harvestSuccess; //0x0E40 struct resStrat** resources; int32_t resourceSize; //0x0E48 int resourcesNum; int32_t settlementTaxLevel; //0x0E50 - struct settlementCapability settlementCapabilities[57]; //0x0E54 - struct settlementCapability settlementCapabilitiesAgent[6]; //0x0F38 - struct settlementCapability settlementCapabilitiesAgentLimit[6]; //0x0F50 - struct settlementCapability settlementCapabilitiesAncillary[4]; //0x0F68 (ROME - NOT IMPLEMENTED IN MED 2) - char pad_0F78[4]; //0x0F78 - struct recruitCapRome settlementCapabilitiesRecruit[64]; //0x0F7C - struct recruitmentCapability recruitmentCapabilities[64]; //0x117C - int32_t recruitPoolCapabilityCount; //0x167C + struct capabilityStruct capabilities; //0x0E54 int8_t N000089C8; //0x1680 char pad_1681[3]; //0x1681 struct settlementStruct* thisSett; //0x1684 @@ -1866,9 +1995,25 @@ struct settlementStruct { int32_t priestsInRecruitmentQueue; //0x16B8 char pad_16BC[8]; //0x16BC intptr_t guildStandings; - char pad_16C8[56]; //0x16C8 + char pad_16C8[48]; //0x16C8 + int32_t baseFertilityValue; //0x16F8 + int32_t rebelFactionChance; //0x16FC int32_t turmoil; //0x1700 - char pad_1704[116]; //0x1704 + int32_t N00002567; //0x1704 + int32_t N00002568; //0x1708 + int32_t N00002569; //0x170C + int32_t N0000256A; //0x1710 + int32_t N0000256B; //0x1714 + int32_t N0000256C; //0x1718 + int32_t N0000256D; //0x171C + int32_t N0000256E; //0x1720 + int32_t N0000256F; //0x1724 + int32_t N00002570; //0x1728 + int32_t wages; //0x172C + int32_t upkeep; //0x1730 + char pad_1734[20]; //0x1734 + struct settlementStruct* this4; //0x1748 + char pad_174C[44]; //0x174C int32_t populationLastTurn; //0x1778 char pad_177C[180]; //0x177C int32_t PopGrowthBaseFarm; //0x1830 @@ -1923,7 +2068,11 @@ struct settlementStruct { int32_t EntertainmentExpense; //0x18F4 int32_t DevastationExpense; //0x18F8 int32_t TotalIncomeWithoutAdmin; //0x18FC - char pad_1900[268]; //0x1900 + int32_t* religionPercentages; //0x1900 + int32_t religionPercentagesSize; //0x1904 + int32_t religionPercentagesNum; //0x1908 + int32_t majorityReligionID; //0x190C + int32_t alternateTradeCalc; //0x1910 }; struct guild @@ -1957,7 +2106,7 @@ struct CompareCounter { /* I_CompareCounter script command */ //main character data(coordinates, etc) struct general { /* character on the stratmap, who has a unit in a stack */ undefined field0_0x0[4]; - struct settlementStruct* settlement; + void* obj; undefined field2_0x8[4]; int xCoord; /* number of x-coord of unit fosition */ int yCoord; /* number of y-coord of unit fosition */ @@ -1971,7 +2120,10 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int8_t inEnemyZOC; //0x00A6 char pad_00A7[17]; //0x00A7 int ambushState; - undefined field13_0xbc[12]; + char pad_00B9[3]; //0x00B9 + int32_t actionsThisTurn; //0x00BC + char pad_00C0[4]; //0x00C0 + int8_t N000013B1; //0x00C4 int8_t doNotSpendMovePoints; //0x00C5 char pad_00C6[2]; //0x00C6 float movePointsCharacter; @@ -2007,11 +2159,18 @@ struct general { /* character on the stratmap, who has a unit in a stack */ int32_t yCoordLast; //0x0254 int32_t xCoordCurrent; //0x0258 int32_t yCoordCurrent; //0x025C - char pad_0260[332]; //0x0260 + struct settlementStruct* besiegingSettlement; //0x0260 + char pad_0264[12]; //0x0264 + struct character* besiegingCharacter; //0x0270 + int32_t N00032B12; //0x0274 + int32_t N00032B00; //0x0278 + int32_t N00032B13; //0x027C + int32_t N00032B14; //0x0280 + char pad_0284[296]; //0x0284 void* someCoordStruct; //0x03AC int32_t someCoordStructSize; //0x03B0 int32_t someCoordStructCount; //0x03B4 - struct movePath *multiTurnMovePaths; //0x03B8 + struct movePath* multiTurnMovePaths; //0x03B8 int8_t multiTurnMovePathsSize; //0x03BC int8_t multiTurnMovePathsCount; //0x03BD int8_t N00032E71; //0x03BE @@ -2101,9 +2260,9 @@ struct namedCharacter { /* many important info about character */ int32_t battleSurgery; //0x01E0 struct traitContainer* traits; /* names at [item number] -0x4-here. Not have number, read it in while(traits != 0){this->m_memory->Read(traits + 0x08, 4).toINT32();} */ undefined field_0x1e8[4]; - struct anchData** anchillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ + struct ancData** ancillaries; /* pointers to character ancillaries, names at [item number] -0-0c-here) */ undefined field_0x1f0[4]; - UINT32 anchNum; /* number of character ancillaries */ + UINT32 ancNum; /* number of character ancillaries */ struct general* gen; /* on stratmap */ undefined field_0x1fc[8]; float yearOfBirth; /* yearOfBirth */ @@ -2125,7 +2284,7 @@ struct namedCharacter { /* many important info about character */ }; //ancillary of character -struct anchillary { /* structure of ancillary */ +struct ancillary { /* structure of ancillary */ UINT32 index; undefined field_0x4; undefined field_0x5; @@ -2135,12 +2294,12 @@ struct anchillary { /* structure of ancillary */ undefined field_0x9; undefined field_0xa; undefined field_0xb; - char* anchName; + char* ancName; undefined field_0x10; undefined field_0x11; undefined field_0x12; undefined field_0x13; - char* patchToAnchImage; + char* patchToAncImage; char pad_0018[4]; //0x0018 int8_t isUnique; //0x001C char pad_001D[23]; //0x001D @@ -2203,7 +2362,7 @@ struct soldierInBattle { float velocity2; float velocity3; char pad_0054[196]; //0x0054 - struct soldierInBattle *self2; //0x0118 + struct soldierInBattle* self2; //0x0118 char pad_011C[4]; //0x011C float speed; //0x0120 char pad_0124[4]; //0x0124 @@ -2404,7 +2563,7 @@ struct unitPositionData struct battleMapPosition* isOnWalls; //0x0050 int32_t isOnWallsSize; //0x0054 int32_t isOnWallsCount; //0x0058 - struct battleMapPosition *isInTower; //0x005C + struct battleMapPosition* isInTower; //0x005C int32_t isInTowerSize; //0x0060 int32_t isInTowerCount; //0x0064 struct battleMapPosition* isInGateHouse; //0x0068 @@ -2469,6 +2628,26 @@ struct unitPositionData int32_t combatStatus; //0x0C38 }; //Size: 0x0C3C +struct rebelUnitName +{ +public: + char* unitName; //0x0000 + char pad_0004[20]; //0x0004 +}; //Size: 0x0018 + +struct descrRebelEntry +{ +public: + int32_t index; //0x0000 + char* name; //0x0004 + int32_t nameHash; //0x0008 + int32_t category; //0x000C + struct N00022A30* localizedName; //0x0010 + int32_t chance; //0x0014 + struct rebelUnitName unitNames[121]; //0x0018 + int32_t unitCount; //0x0B70 +}; //Size: 0x0B74 + //unit data struct unit { undefined field0_0x0[4]; @@ -2645,6 +2824,10 @@ struct stackStruct { /* structure of stack */ char pad_0134[16]; //0x0134 int32_t battleAllianceOrSomething; //0x0144 int32_t battleDifficulty; //0x0148 + int8_t isHalfDestroyed; //0x014C + char pad_014D[15]; //0x014D + struct descrRebelEntry* descrRebel; //0x015C + int32_t subFactionID; //0x0160 }; struct coords { @@ -2700,6 +2883,120 @@ struct battleFactionCounter int32_t wonLostRatio; //0x0008 }; //Size: 0x000C +struct recruitRome +{ + char pad[8]; +}; + + +struct militaryValuesLTGD +{ + int32_t totalPopulation; //0x0000 + int32_t tileCount; //0x0004 + int32_t averagePopulation; //0x0008 + int32_t productionValue; //0x000C + int32_t nonAlliedBorderLength; //0x0010 + int32_t enemyBorderLength; //0x0014 + int32_t fleetCount; //0x0018 + int32_t navalPowerPerFleet; //0x001C + int32_t navalStrength; //0x0020 + int32_t armyCount; //0x0024 + int32_t strengthPerArmy; //0x0028 + int32_t totalStrength; //0x002C + int32_t freeStrength; //0x0030 + int32_t neighbourEnemyNum; //0x0034 + int32_t enemyStrength; //0x0038 + int32_t protectorateOf; //0x003C +}; + +struct strategyValuesLTGD +{ + int32_t borderTiles; //0x0000 + int32_t frontLineBalance; //0x0004 + int8_t hasAllianceAgainst; //0x0008 + int8_t isStrongestNeighbour; //0x0009 + int8_t isWeakestNeighbour; //0x000A + char pad_000B[1]; //0x000B + +}; + +struct dataLTGD +{ +public: + struct factionStruct* currentFaction; //0x0000 + char pad_0004[8]; //0x0004 + uint32_t N00024EDA; //0x000C + char pad_0010[4]; //0x0010 + struct militaryValuesLTGD militaryValuesLTGD[31]; //0x0014 + struct strategyValuesLTGD strategyValuesLTGD[31][31]; //0x07D4 +}; + + +struct decisionValuesLTGD +{ +public: + int32_t defendType; //0x0000 + int32_t defendPriority; //0x0004 + int32_t invasionType; //0x0008 + int32_t invadePriority; //0x000C + int8_t atWar; //0x0010 + int8_t wantPeace; //0x0011 + int8_t wantAlly; //0x0012 + int8_t wantBeProtect; //0x0013 + int8_t wantOfferProtect; //0x0014 + char pad_0015[3]; //0x0015 + int32_t allianceAgainst; //0x0018 + int32_t ptsDesire; //0x001C + int32_t ptsAlliance; //0x0020 + int32_t N0002EF7A; //0x0024 + int32_t N0002EF7B; //0x0028 + int8_t canForceInvade; //0x002C + char pad_002D[3]; //0x002D +}; //Size: 0x0030 + +struct aiLongTermGoalDirector +{ +public: + char pad_0000[4]; //0x0000 + struct aiFaction* aiFaction; //0x0004 + struct factionStruct* faction; //0x0008 + uint32_t trustedAllyEnemies; //0x000C --bitfield + int32_t freeStrengthEnemy; //0x0010 + int32_t freeStrengthEnemyBalance; //0x0014 + int8_t consideringNavalInvasion; //0x0018 + char pad_0019[15]; //0x0019 + struct decisionValuesLTGD longTermGoalValues[31]; //0x0028 + int32_t N0002EFB5; //0x05F8 + int32_t freeStrengthBalanceLevel; //0x05FC + char pad_0600[4]; //0x0600 +}; //Size: 0x0604 + +struct aiFaction +{ +public: + char pad_0000[4]; //0x0000 + struct factionStruct* faction; //0x0004 + int32_t FactionId; //0x0008 + char pad_000C[4]; //0x000C + int8_t N00001E8C; //0x0010 + int8_t N0002F25A; //0x0011 + char pad_0012[14]; //0x0012 + struct aiLongTermGoalDirector* aiLongTermGoalDirector; //0x0020 + struct aiDiplomacyManager* aiDiplomacyManager; //0x0024 + struct aiActionRequestController* aiActionRequestController; //0x0028 + struct aiResourceManager* aiResourceManager; //0x002C + struct AiFinanceManager* AiFinanceManager; //0x0030 + struct aiPersonalityValues* aiProductionControllers; //0x0034 + struct aiGlobalStrategyDirector* aiGlobalStrategyDirector; //0x0038 + struct aiSubterFugeController* aiSubterFugeController; //0x003C + struct aiNamedCharacterController* aiNamedCharacterController; //0x0040 + struct aiPriestController* aiPriestController; //0x0044 + struct aiMerchantController* aiMerchantController; //0x0048 + char pad_004C[4]; //0x004C + void* N0001D8FD; //0x0050 + void* N0001D8FE; //0x0054 +}; //Size: 0x0058 + //faction struct factionStruct { undefined field_0x0[180]; @@ -2712,12 +3009,12 @@ struct factionStruct { struct namedCharacter* heir; /* faction heir */ struct factionStratMapDescrS* factSmDescr; int isPlayerControlled; /* is faction a controlled by player */ - struct aiFaction* AIFaction; //0x00D8 + struct aiFaction* aiFaction; //0x00D8 int32_t AIPersonalityType; //0x00DC int32_t AIPersonalityName; //0x00E0 char pad_00E4[12]; //0x00E4 struct holdRegionsWinCondition* WinConditions; //0x00F0 - int32_t someInteger; //0x00F4 + int32_t regionsOwnedStart; //0x00F4 struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ int32_t namedCharactersSize; //0x00FC int numOfCharactersAll; /* all characters, died, alive, etc */ @@ -2738,7 +3035,7 @@ struct factionStruct { int fortsNum; struct watchTowerStruct** watchTowers; /* watchtowers */ int32_t watchtowersSize; //0x0144 - int wathtowersNum; + int watchtowersNum; struct portBuildingStruct** portBuildings; /* port buildings */ int32_t portBuildingsSize; //0x0150 int portBuildingsNum; @@ -2746,7 +3043,9 @@ struct factionStruct { int* neighBourRegions; //0x015C int32_t neighBourRegionsSize; //0x0160 int32_t neighBourRegionsNum; //0x0164 - char pad_0168[49]; //0x0168 + char pad_0168[44]; //0x0168 + int32_t deadStatus; //0x0194 3 means until resurrected 4 means until emerged + int8_t reEmergent; //0x0198 int8_t isUndiscovered; //0x0199 char pad_019A[2]; //0x019A factionTileStruct* tilesFac; @@ -2757,15 +3056,29 @@ struct factionStruct { struct factionRanking* factionRankings; //0x01DC int32_t factionRankingsSize; //0x01E0 int32_t factionRankingsCount; //0x01E4 - char pad_01E8[24]; //0x01E8 - int32_t freezeFactionAI; //0x0200 - char pad_0204[2096]; //0x0204 + char pad_01E8[12]; //0x01E8 + int32_t triumphValue; //0x01F4 + uint32_t someBitField; //0x01F8 + float someFloat; //0x01FC + int8_t freezeFactionAI; //0x0200 + char pad_0201[3]; //0x0201 + struct capabilityStruct factionCapabilities; + int8_t hasSettlementsProcessed; //0x0A30 + char pad_0A31[3]; //0x0A31 int32_t treasuryTurnStart; //0x0A34 char pad_0A38[8]; //0x0A38 UINT32 religion; /* number of religion */ undefined field_0xa44[16]; int8_t isFactionExcommunicated; //0x0A54 - char pad_0A55[67]; //0x0A55 + char pad_0A55[3]; //0x0A55 + int32_t glory; //0x0A34 + char pad_0A5C[36]; //0x0A5C + float* resourceModifiers; + DWORD resourceModifiersEnd; + DWORD resourceModifiersEnd2; + int32_t factionBannerIndex; //0x0AA0 + int32_t agentNameFactionId[12]; //0x0AA4 + char pad_0AD4[24]; //0x0AD4 UNICODE_STRING** someString; UNICODE_STRING** localizedName; undefined field_0xaa0[76]; @@ -3044,8 +3357,8 @@ struct someFactNameStruct { }; //pointer to ancillary -struct anchData { /* data of the ancillary */ - struct anchillary* dataAnch; +struct ancData { /* data of the ancillary */ + struct ancillary* dataAnc; }; //data of one soldier in unit @@ -3067,7 +3380,7 @@ struct fortStruct { UINT32 xCoord; UINT32 yCoord; undefined field_0x14[48]; - struct stackStruct* army; + struct stackStruct* army; struct oneSiege sieges[8]; int8_t siegeNum; //0x0088 char pad_0089[3]; //0x0089 @@ -3135,12 +3448,12 @@ struct consoleCommands { struct battleCameraStruct { - public: - float xCoord; //0x0000 - char pad_0004[4]; //0x0004 - float yCoord; //0x0008 - char pad_000C[20]; //0x000C - float zCoord; //0x0020 +public: + float xCoord; //0x0000 + char pad_0004[4]; //0x0004 + float yCoord; //0x0008 + char pad_000C[20]; //0x000C + float zCoord; //0x0020 }; //Size: 0x0024 struct descr_sm_factions_list { diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index 331b144d7..caa72d714 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp @@ -63,19 +63,19 @@ void settlementHelpers::setGuildStanding(settlementStruct* sett, int index, int } settlementCapability* settlementHelpers::getSettlementCapability(settlementStruct* sett, int capabilityType) { - return &sett->settlementCapabilities[capabilityType]; + return &sett->capabilities.settlementCapabilities[capabilityType]; } settlementCapability* settlementHelpers::getAgentCapability(settlementStruct* sett, int agentType) { - return &sett->settlementCapabilitiesAgent[agentType]; + return &sett->capabilities.settlementCapabilitiesAgent[agentType]; } settlementCapability* settlementHelpers::getAgentLimitCapability(settlementStruct* sett, int agentType) { - return &sett->settlementCapabilitiesAgentLimit[agentType]; + return &sett->capabilities.settlementCapabilitiesAgentLimit[agentType]; } recruitmentCapability* settlementHelpers::getRecruitmentCapability(settlementStruct* sett, int index) { - return &sett->recruitmentCapabilities[index]; + return &sett->capabilities.recruitmentCapabilities[index]; } settlementRecruitmentPool* settlementHelpers::getSettlementRecruitmentPool(settlementStruct* sett, int index) { From 6b8be15ec47a64ef1e395f539b731ee018d34d4c Mon Sep 17 00:00:00 2001 From: FynnTW Date: Fri, 20 Oct 2023 11:06:48 +0300 Subject: [PATCH 20/22] enum stuff --- M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp | 2 +- M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp | 9 +- M2TWEOP-luaPlugin/luaPlugin/luaP.cpp | 86 +-- M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp | 531 +++++++++++++++--- M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h | 55 +- .../luaPlugin/settlementHelpers.cpp | 4 + .../luaPlugin/settlementHelpers.h | 1 + documentationGenerator/generateLuaDocs.py | 57 +- 8 files changed, 565 insertions(+), 180 deletions(-) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp index 9f089aaa0..958330051 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp @@ -252,7 +252,7 @@ void luaP::initEopEdu() /*** Get the amount of models in the armour_upg_models line in export_descr_unit. - @function M2TWEOPDU.getArmourUpgradeLevelsNum + @function M2TWEOPDU.getArmourUpgradeModelsNum @tparam int index Entry index (Values lower then 500 look for edu entry, values over 500 look for EOP edu entry). @treturn int ArmourUpgradeLevelsNum @usage diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp index e17ce895e..e10abccae 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -834,15 +834,10 @@ void luaP::onPluginLoadF() Exports: character, faction, regionID, characterType, missionDetails, religion @function onLeaderMissionFailed - @tparam namedCharacter namedChar - @tparam factionStruct faction - @tparam string missionName - @tparam regionStruct|nil region - @tparam string characterType - @tparam string religion + @tparam eventTrigger eventData @usage - function onLeaderMissionFailed(namedChar, faction, missionName, region, characterType, religion) + function onLeaderMissionFailed(eventData) --something end */ diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp index c4abaa2c1..0e335fbaf 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.cpp @@ -174,74 +174,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) return nullptr; } - luaState.new_enum( - "unitBattleProperties", - "guardMode", unitHelpers::guardMode, - "fireAtWill", unitHelpers::fireAtWill, - "skirmish", unitHelpers::skirmish - ); - - //luaState.new_enum( - // "buildingCap", - // "population_growth_bonus", buildingStructHelpers::buildingCap::population_growth_bonus, - // "population_loyalty_bonus", buildingStructHelpers::buildingCap::population_loyalty_bonus, - // "population_health_bonus", buildingStructHelpers::buildingCap::population_health_bonus, - // "trade_base_income_bonus", buildingStructHelpers::buildingCap::trade_base_income_bonus, - // "trade_level_bonus", buildingStructHelpers::buildingCap::trade_level_bonus, - // "trade_fleet", buildingStructHelpers::buildingCap::trade_fleet, - // "taxable_income_bonus", buildingStructHelpers::buildingCap::taxable_income_bonus, - // "mine_resource", buildingStructHelpers::buildingCap::mine_resource, - // "farming_level", buildingStructHelpers::buildingCap::farming_level, - // "road_level", buildingStructHelpers::buildingCap::road_level, - // "gate_strength", buildingStructHelpers::buildingCap::gate_strength, - // "gate_defences", buildingStructHelpers::buildingCap::gate_defences, - // "wall_level", buildingStructHelpers::buildingCap::wall_level, - // "tower_level", buildingStructHelpers::buildingCap::tower_level, - // "armour", buildingStructHelpers::buildingCap::armour, - // "stage_games", buildingStructHelpers::buildingCap::stage_games, - // "stage_races", buildingStructHelpers::buildingCap::stage_races, - // "fire_risk", buildingStructHelpers::buildingCap::fire_risk, - // "weapon_melee_simple", buildingStructHelpers::buildingCap::weapon_melee_simple, - // "weapon_melee_blade", buildingStructHelpers::buildingCap::weapon_melee_blade, - // "weapon_missile_mechanical", buildingStructHelpers::buildingCap::weapon_missile_mechanical, - // "weapon_missile_gunpowder", buildingStructHelpers::buildingCap::weapon_missile_gunpowder, - // "weapon_artillery_mechanical", buildingStructHelpers::buildingCap::weapon_artillery_mechanical, - // "weapon_artillery_gunpowder", buildingStructHelpers::buildingCap::weapon_artillery_gunpowder, - // "weapon_naval_gunpowder", buildingStructHelpers::buildingCap::weapon_naval_gunpowder, - // "upgrade_bodyguard", buildingStructHelpers::buildingCap::upgrade_bodyguard, - // "recruits_morale_bonus", buildingStructHelpers::buildingCap::recruits_morale_bonus, - // "recruits_exp_bonus", buildingStructHelpers::buildingCap::recruits_exp_bonus, - // "happiness_bonus", buildingStructHelpers::buildingCap::happiness_bonus, - // "law_bonus", buildingStructHelpers::buildingCap::law_bonus, - // "construction_cost_bonus_military", buildingStructHelpers::buildingCap::construction_cost_bonus_military, - // "construction_cost_bonus_religious", buildingStructHelpers::buildingCap::construction_cost_bonus_religious, - // "construction_cost_bonus_defensive", buildingStructHelpers::buildingCap::construction_cost_bonus_defensive, - // "construction_cost_bonus_other", buildingStructHelpers::buildingCap::construction_cost_bonus_other, - // "construction_time_bonus_military", buildingStructHelpers::buildingCap::construction_time_bonus_military, - // "construction_time_bonus_religious", buildingStructHelpers::buildingCap::construction_time_bonus_religious, - // "construction_time_bonus_defensive", buildingStructHelpers::buildingCap::construction_time_bonus_defensive, - // "construction_time_bonus_other", buildingStructHelpers::buildingCap::construction_time_bonus_other, - // "construction_cost_bonus_wooden", buildingStructHelpers::buildingCap::construction_cost_bonus_wooden, - // "construction_cost_bonus_stone", buildingStructHelpers::buildingCap::construction_cost_bonus_stone, - // "construction_time_bonus_wooden", buildingStructHelpers::buildingCap::construction_time_bonus_wooden, - // "construction_time_bonus_stone", buildingStructHelpers::buildingCap::construction_time_bonus_stone, - // "free_upkeep", buildingStructHelpers::buildingCap::free_upkeep, - // "pope_approval", buildingStructHelpers::buildingCap::pope_approval, - // "pope_disapproval", buildingStructHelpers::buildingCap::pope_disapproval, - // "religion_level", buildingStructHelpers::buildingCap::religion_level, - // "amplify_religion_level", buildingStructHelpers::buildingCap::amplify_religion_level, - // "archer_bonus", buildingStructHelpers::buildingCap::archer_bonus, - // "cavalry_bonus", buildingStructHelpers::buildingCap::cavalry_bonus, - // "heavy_cavalry_bonus", buildingStructHelpers::buildingCap::heavy_cavalry_bonus, - // "gun_bonus", buildingStructHelpers::buildingCap::gun_bonus, - // "navy_bonus", buildingStructHelpers::buildingCap::navy_bonus, - // "recruitment_cost_bonus_naval", buildingStructHelpers::buildingCap::recruitment_cost_bonus_naval, - // "retrain_cost_bonus", buildingStructHelpers::buildingCap::retrain_cost_bonus, - // "weapon_projectile", buildingStructHelpers::buildingCap::weapon_projectile, - // "income_bonus", buildingStructHelpers::buildingCap::income_bonus, - // "recruitment_slots", buildingStructHelpers::buildingCap::recruitment_slots - //); - ///M2TWEOP //@section m2tweopTable @@ -266,6 +198,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield getTileVisibility getTileVisibility @tfield getRegionOwner getRegionOwner @tfield setEDUUnitsSize setEDUUnitsSize + @tfield setBuildingChainLimit setBuildingChainLimit @tfield getReligionName getReligionName @tfield condition condition @table M2TWEOP @@ -953,7 +886,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int weaponLVL soldiers weapon. You can change it on stratmap and soldiers updated. Use @{setParams} if you need change several parameters at once. @tfield int soldierCountStratMapMax Read only @tfield int soldierCountBattleMap Read only - @tfield int moraleLevel (6 means routing) + @tfield int moraleLevel use moraleStatus enum @tfield int isCloseFormation @tfield int fatigue (battle) @tfield int maxAmmo (battle) @@ -1108,6 +1041,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int targetsToGo dont set @tfield int hasTargets dont set @tfield int isHalted + @tfield int combatStatus use enum: combatStatus @tfield float lastTargetCoord1 dont set @tfield float lastTargetCoord2 dont set @tfield int towersUnderFireFromCount @@ -1128,6 +1062,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) types.unitPositionData.set("additionalTargetsOverOne", &unitPositionData::additionalTargetsOverOne); types.unitPositionData.set("targetsToGo", &unitPositionData::targetsToGo); types.unitPositionData.set("hasTargets", &unitPositionData::hasTargets); + types.unitPositionData.set("combatStatus", &unitPositionData::combatStatus); types.unitPositionData.set("isHalted", &unitPositionData::isHalted); types.unitPositionData.set("lastTargetCoord1", &unitPositionData::lastTargetCoord1); types.unitPositionData.set("lastTargetCoord2", &unitPositionData::lastTargetCoord2); @@ -2286,7 +2221,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int secondaryColorGreen Warning: resets on reload. @tfield int secondaryColorBlue Warning: resets on reload. @tfield int triumphValue Usage unknown. - @tfield int religionID. + @tfield int religionID @tfield int standardIndex Warning: resets on reload. @tfield int logoIndex Warning: resets on reload. @tfield int smallLogoIndex Warning: resets on reload. @@ -2430,6 +2365,16 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) @tfield int level @tfield int isCastle @tfield int settlementTaxLevel + @tfield int recruitmentPoolCount + @tfield int recruitmentCapabilityNum + @tfield bool freezeRecruitmentPool + @tfield int spiesInRecruitmentQueue + @tfield int assassinsInRecruitmentQueue + @tfield int diplomatsInRecruitmentQueue + @tfield int admiralsInRecruitmentQueue + @tfield int merchantsInRecruitmentQueue + @tfield int priestsInRecruitmentQueue + @tfield int turmoil @tfield int isProvokedRebellion @tfield int populationSize @tfield int PopGrowthBaseFarm - Get only @@ -2716,6 +2661,7 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) local capability = settlementStruct:getRecruitmentCapability(0) */ types.settlementStruct.set_function("getRecruitmentCapability", &settlementHelpers::getRecruitmentCapability); + types.settlementStruct.set("recruitmentCapabilityNum", sol::property(settlementHelpers::getRecruitmentCapabilityNum)); /*** Get a recruitment pool by index. @function settlementStruct:getSettlementRecruitmentPool diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp index d511dafab..364b9dc46 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -18,7 +18,7 @@ void luaP::initCampaign() sol::usertype campaignTable; sol::usertype stratMap; sol::usertype tileStruct; - sol::usertype region; + sol::usertype regionStruct; sol::usertype mercPool; sol::usertype mercPoolUnit; sol::usertype collegeOfCardinals; @@ -36,8 +36,8 @@ void luaP::initCampaign() }typeAll; using namespace campaignEnums; - /// CampaignEnums - //@section campaignEnums + ///CampaignEnums + //@section dipRelType /*** Enum with a list of types of diplomatic relations. @@ -65,6 +65,377 @@ void luaP::initCampaign() "trade", dipRelEnum::trade ); + //@section unitBattleProperties + /*** + Enum with a list of types of unit battle properties. + + @tfield int guardMode + @tfield int fireAtWill + @tfield int skirmish + + @table unitBattleProperties + */ + luaState.new_enum( + "unitBattleProperties", + "guardMode", unitHelpers::guardMode, + "fireAtWill", unitHelpers::fireAtWill, + "skirmish", unitHelpers::skirmish + ); + + //@section buildingCapability + /*** + Enum with a list of types of building capabilities. + + @tfield int population_growth_bonus + @tfield int population_loyalty_bonus + @tfield int population_health_bonus + @tfield int trade_base_income_bonus + @tfield int trade_level_bonus + @tfield int trade_fleet + @tfield int taxable_income_bonus + @tfield int mine_resource + @tfield int farming_level + @tfield int road_level + @tfield int gate_strength + @tfield int gate_defences + @tfield int wall_level + @tfield int tower_level + @tfield int armour + @tfield int stage_games + @tfield int stage_races + @tfield int fire_risk + @tfield int weapon_melee_simple + @tfield int weapon_melee_blade + @tfield int weapon_missile_mechanical + @tfield int weapon_missile_gunpowder + @tfield int weapon_artillery_mechanical + @tfield int weapon_artillery_gunpowder + @tfield int weapon_naval_gunpowder + @tfield int upgrade_bodyguard + @tfield int recruits_morale_bonus + @tfield int recruits_exp_bonus + @tfield int happiness_bonus + @tfield int law_bonus + @tfield int construction_cost_bonus_military + @tfield int construction_cost_bonus_religious + @tfield int construction_cost_bonus_defensive + @tfield int construction_cost_bonus_other + @tfield int construction_time_bonus_military + @tfield int construction_time_bonus_religious + @tfield int construction_time_bonus_defensive + @tfield int construction_time_bonus_other + @tfield int construction_cost_bonus_wooden + @tfield int construction_cost_bonus_stone + @tfield int construction_time_bonus_wooden + @tfield int construction_time_bonus_stone + @tfield int free_upkeep + @tfield int pope_approval + @tfield int pope_disapproval + @tfield int religion_level + @tfield int amplify_religion_level + @tfield int archer_bonus + @tfield int cavalry_bonus + @tfield int heavy_cavalry_bonus + @tfield int gun_bonus + @tfield int navy_bonus + @tfield int recruitment_cost_bonus_naval + @tfield int retrain_cost_bonus + @tfield int weapon_projectile + @tfield int income_bonus + @tfield int recruitment_slots + + @table buildingCapability + */ + luaState.new_enum( + "buildingCapability", + "population_growth_bonus", 0, + "population_loyalty_bonus", 1, + "population_health_bonus", 2, + "trade_base_income_bonus", 3, + "trade_level_bonus", 4, + "trade_fleet", 5, + "taxable_income_bonus", 6, + "mine_resource", 7, + "farming_level", 8, + "road_level", 9, + "gate_strength", 10, + "gate_defences", 11, + "wall_level", 12, + "tower_level", 13, + "armour", 14, + "stage_games", 15, + "stage_races", 16, + "fire_risk", 17, + "weapon_melee_simple", 18, + "weapon_melee_blade", 19, + "weapon_missile_mechanical", 20, + "weapon_missile_gunpowder", 21, + "weapon_artillery_mechanical", 22, + "weapon_artillery_gunpowder", 23, + "weapon_naval_gunpowder", 24, + "upgrade_bodyguard", 25, + "recruits_morale_bonus", 26, + "recruits_exp_bonus", 27, + "happiness_bonus", 28, + "law_bonus", 29, + "construction_cost_bonus_military", 30, + "construction_cost_bonus_religious", 31, + "construction_cost_bonus_defensive", 32, + "construction_cost_bonus_other", 33, + "construction_time_bonus_military", 34, + "construction_time_bonus_religious", 35, + "construction_time_bonus_defensive", 36, + "construction_time_bonus_other", 37, + "construction_cost_bonus_wooden", 38, + "construction_cost_bonus_stone", 39, + "construction_time_bonus_wooden", 40, + "construction_time_bonus_stone", 41, + "free_upkeep", 42, + "pope_approval", 43, + "pope_disapproval", 44, + "religion_level", 45, + "amplify_religion_level", 46, + "archer_bonus", 47, + "cavalry_bonus", 48, + "heavy_cavalry_bonus", 49, + "gun_bonus", 50, + "navy_bonus", 51, + "recruitment_cost_bonus_naval", 52, + "retrain_cost_bonus", 53, + "weapon_projectile", 54, + "income_bonus", 55, + "recruitment_slots", 56 + ); + + //@section characterType + /*** + Enum with a list of character types. + + @tfield int spy + @tfield int assassin + @tfield int diplomat + @tfield int admiral + @tfield int merchant + @tfield int priest + @tfield int general + @tfield int named_character + @tfield int princess + @tfield int heretic + @tfield int witch + @tfield int inquisitor + @tfield int pope + + @table characterType + */ + luaState.new_enum( + "characterType", + "spy", 0, + "assassin", 1, + "diplomat", 2, + "admiral", 3, + "merchant", 4, + "priest", 5, + "general", 6, + "named_character", 7, + "princess", 8, + "heretic", 9, + "witch", 10, + "inquisitor", 11, + "pope", 13 + ); + + //@section resourceType + /*** + Enum with a list of resources. + + @tfield int gold + @tfield int silver + @tfield int fish + @tfield int furs + @tfield int grain + @tfield int timber + @tfield int iron + @tfield int ivory + @tfield int wine + @tfield int slaves + @tfield int chocolate + @tfield int marble + @tfield int textiles + @tfield int dyes + @tfield int tobacco + @tfield int silk + @tfield int sugar + @tfield int sulfur + @tfield int tin + @tfield int spices + @tfield int cotton + @tfield int amber + @tfield int coal + @tfield int wool + @tfield int elephants + @tfield int camels + @tfield int dogs + @tfield int generic + + @table resourceType + */ + luaState.new_enum( + "resourceType", + "gold", 0, + "silver", 1, + "fish", 2, + "furs", 3, + "grain", 4, + "timber", 5, + "iron", 6, + "ivory", 7, + "wine", 8, + "slaves", 9, + "chocolate", 10, + "marble", 11, + "textiles", 12, + "dyes", 13, + "tobacco", 14, + "silk", 15, + "sugar", 16, + "sulfur", 17, + "tin", 18, + "spices", 19, + "cotton", 20, + "amber", 21, + "coal", 22, + "wool", 23, + "elephants", 24, + "camels", 25, + "dogs", 26, + "generic", 27 + ); + + //@section moraleStatus + /*** + Enum of unit morale status. + + @tfield int berserk + @tfield int impetuous + @tfield int high + @tfield int firm + @tfield int shaken + @tfield int wavering + @tfield int routing + + @table moraleStatus + */ + luaState.new_enum( + "moraleStatus", + "berserk", 0, + "impetuous", 1, + "high", 2, + "firm", 3, + "shaken", 4, + "wavering", 5, + "routing", 6 + ); + + //@section combatStatus + /*** + Enum of unit combat status. + + @tfield int notInCombat + @tfield int victoryCertain + @tfield int victoryAlmostCertain + @tfield int victoryDistinct + @tfield int balanced + @tfield int defeatDistinct + @tfield int defeatAlmostCertain + @tfield int defeatCertain + + @table combatStatus + */ + luaState.new_enum( + "combatStatus", + "notInCombat", 0, + "victoryCertain", 1, + "victoryAlmostCertain", 2, + "victoryDistinct", 3, + "balanced", 4, + "defeatDistinct", 5, + "defeatAlmostCertain", 6, + "defeatCertain", 7 + ); + + //@section battleSuccess + /*** + Enum of unit combat status. + + @tfield int close + @tfield int average + @tfield int clear + @tfield int crushing + + @table battleSuccess + */ + luaState.new_enum( + "battleSuccess", + "close", 0, + "average", 1, + "clear", 2, + "crushing", 3 + ); + + //@section battleType + /*** + Enum of battle types. + + @tfield int ambushSuccess + @tfield int ambushFail + @tfield int open + @tfield int siege + @tfield int sally + @tfield int naval + @tfield int withdrawal + @tfield int meetEnemy + + @table battleType + */ + luaState.new_enum( + "battleType", + "ambushSuccess", 0, + "ambushFail", 1, + "open", 2, + "siege", 3, + "sally", 4, + "naval", 5, + "withdrawal", 6, + "meetEnemy", 7 + ); + + //@section battleState + /*** + Enum of battle states. + + @tfield int ambushSuccess + @tfield int ambushFail + @tfield int open + @tfield int siege + @tfield int sally + @tfield int naval + @tfield int withdrawal + @tfield int meetEnemy + + @table battleState + */ + luaState.new_enum( + "battleState", + "notInBattle", 0, + "preBattle", 1, + "delay", 2, + "deployment", 3, + "deploymentPlayer2", 4, + "conflict", 5, + "victoryScroll", 6, + "pursuit", 7 + ); + ///options1 //@section options1 @@ -476,7 +847,7 @@ void luaP::initCampaign() @tfield getWatchTower getWatchTower @tfield getSettlementByName getSettlementByName - @table gameDataAll.campaignStruct + @table campaignStruct */ typeAll.campaignTable = luaState.new_usertype("campaignStruct"); typeAll.campaignTable.set("playerFactionId", &campaign::playerFactionId); @@ -700,7 +1071,7 @@ void luaP::initCampaign() @tfield getLandConnection getLandConnection @tfield getLandMass getLandMass - @table gameDataAll.stratMap + @table stratMap */ typeAll.stratMap = luaState.new_usertype("stratMap"); typeAll.stratMap.set("mapWidth", &stratMap::mapWidth); @@ -714,7 +1085,7 @@ void luaP::initCampaign() Get a specific region by index. @function stratMap.getRegion @tparam int index - @treturn region region + @treturn regionStruct region @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); @@ -931,11 +1302,11 @@ void luaP::initCampaign() */ typeAll.roadStruct.set_function("factionHasCharacterOnTile", &gameHelpers::factionHasCharacterOnTile); - ///Region - //@section Region + ///RegionStruct + //@section RegionStruct /*** - Basic region table. + Basic regionStruct table. @tfield string regionName @tfield string localizedName @@ -995,52 +1366,52 @@ void luaP::initCampaign() @tfield getHostileArmiesStrength getHostileArmiesStrength @tfield hasResourceType hasResourceType - @table region + @table regionStruct */ - typeAll.region = luaState.new_usertype("region"); - typeAll.region.set("regionName", ®ionStruct::regionName); - typeAll.region.set("settlementName", ®ionStruct::settlementName); - typeAll.region.set("localizedName", sol::property( + typeAll.regionStruct = luaState.new_usertype("regionStruct"); + typeAll.regionStruct.set("regionName", ®ionStruct::regionName); + typeAll.regionStruct.set("settlementName", ®ionStruct::settlementName); + typeAll.regionStruct.set("localizedName", sol::property( &gameHelpers::getRegionName, &gameHelpers::changeRegionName )); - typeAll.region.set("legioName", ®ionStruct::legioName); - typeAll.region.set("regionID", ®ionStruct::regionID); - typeAll.region.set("roadLevel", ®ionStruct::roadLevel); - typeAll.region.set("farmingLevel", ®ionStruct::farmingLevel); - typeAll.region.set("famineThreat", ®ionStruct::famineThreat); - typeAll.region.set("harvestSuccess", ®ionStruct::harvestSuccess); - typeAll.region.set("totalSeaTradeValue", ®ionStruct::totalSeaTradeValue); - typeAll.region.set("seaConnectedRegionsCount", ®ionStruct::seaConnectedRegionsCount); - typeAll.region.set("seaImportRegionsCount", ®ionStruct::seaImportRegionsCount); - typeAll.region.set("landMass", ®ionStruct::landMass); - typeAll.region.set("roadToPort", ®ionStruct::roadToPort); - typeAll.region.set("seaExportRegion", ®ionStruct::seaExportRegion); - typeAll.region.set("regionSeaEdgesCount", ®ionStruct::regionSeaEdgesCount); - typeAll.region.set("tilesBorderingEdgeOfMapCount", ®ionStruct::tilesBorderingEdgeOfMapCount); - typeAll.region.set("fertileTilesCount", ®ionStruct::fertileTilesCount); - typeAll.region.set("resourceTypesBitMap", ®ionStruct::resourceTypesBitMap); - typeAll.region.set("stacksNum", ®ionStruct::stacksNum); - typeAll.region.set("fortsNum", ®ionStruct::fortsNum); - typeAll.region.set("watchtowersNum", ®ionStruct::watchtowersNum); - typeAll.region.set("isSea", ®ionStruct::isSea); - typeAll.region.set("hasLake", ®ionStruct::hasLake); - typeAll.region.set("mercPool", ®ionStruct::mercPool); - typeAll.region.set("settlement", ®ionStruct::settlement); - typeAll.region.set("tileCount", ®ionStruct::tileCount); - typeAll.region.set("neighbourRegionsNum", ®ionStruct::neighbourRegionsNum); - typeAll.region.set("resourcesNum", ®ionStruct::resourcesNum); - typeAll.region.set("hiddenResources1", ®ionStruct::hiddenResources1); - typeAll.region.set("hiddenResources2", ®ionStruct::hiddenResources2); - typeAll.region.set("settlementXCoord", ®ionStruct::settlementXCoord); - typeAll.region.set("settlementYCoord", ®ionStruct::settlementYCoord); - typeAll.region.set("portEntranceXCoord", ®ionStruct::portEntranceXCoord); - typeAll.region.set("portEntranceYCoord", ®ionStruct::portEntranceYCoord); - typeAll.region.set("faction", ®ionStruct::factionOwner); - typeAll.region.set("rebelType", ®ionStruct::rebelType); - typeAll.region.set("localizedRebelsName", sol::property( + typeAll.regionStruct.set("legioName", ®ionStruct::legioName); + typeAll.regionStruct.set("regionID", ®ionStruct::regionID); + typeAll.regionStruct.set("roadLevel", ®ionStruct::roadLevel); + typeAll.regionStruct.set("farmingLevel", ®ionStruct::farmingLevel); + typeAll.regionStruct.set("famineThreat", ®ionStruct::famineThreat); + typeAll.regionStruct.set("harvestSuccess", ®ionStruct::harvestSuccess); + typeAll.regionStruct.set("totalSeaTradeValue", ®ionStruct::totalSeaTradeValue); + typeAll.regionStruct.set("seaConnectedRegionsCount", ®ionStruct::seaConnectedRegionsCount); + typeAll.regionStruct.set("seaImportRegionsCount", ®ionStruct::seaImportRegionsCount); + typeAll.regionStruct.set("landMass", ®ionStruct::landMass); + typeAll.regionStruct.set("roadToPort", ®ionStruct::roadToPort); + typeAll.regionStruct.set("seaExportRegion", ®ionStruct::seaExportRegion); + typeAll.regionStruct.set("regionSeaEdgesCount", ®ionStruct::regionSeaEdgesCount); + typeAll.regionStruct.set("tilesBorderingEdgeOfMapCount", ®ionStruct::tilesBorderingEdgeOfMapCount); + typeAll.regionStruct.set("fertileTilesCount", ®ionStruct::fertileTilesCount); + typeAll.regionStruct.set("resourceTypesBitMap", ®ionStruct::resourceTypesBitMap); + typeAll.regionStruct.set("stacksNum", ®ionStruct::stacksNum); + typeAll.regionStruct.set("fortsNum", ®ionStruct::fortsNum); + typeAll.regionStruct.set("watchtowersNum", ®ionStruct::watchtowersNum); + typeAll.regionStruct.set("isSea", ®ionStruct::isSea); + typeAll.regionStruct.set("hasLake", ®ionStruct::hasLake); + typeAll.regionStruct.set("mercPool", ®ionStruct::mercPool); + typeAll.regionStruct.set("settlement", ®ionStruct::settlement); + typeAll.regionStruct.set("tileCount", ®ionStruct::tileCount); + typeAll.regionStruct.set("neighbourRegionsNum", ®ionStruct::neighbourRegionsNum); + typeAll.regionStruct.set("resourcesNum", ®ionStruct::resourcesNum); + typeAll.regionStruct.set("hiddenResources1", ®ionStruct::hiddenResources1); + typeAll.regionStruct.set("hiddenResources2", ®ionStruct::hiddenResources2); + typeAll.regionStruct.set("settlementXCoord", ®ionStruct::settlementXCoord); + typeAll.regionStruct.set("settlementYCoord", ®ionStruct::settlementYCoord); + typeAll.regionStruct.set("portEntranceXCoord", ®ionStruct::portEntranceXCoord); + typeAll.regionStruct.set("portEntranceYCoord", ®ionStruct::portEntranceYCoord); + typeAll.regionStruct.set("faction", ®ionStruct::factionOwner); + typeAll.regionStruct.set("rebelType", ®ionStruct::rebelType); + typeAll.regionStruct.set("localizedRebelsName", sol::property( &gameHelpers::getRebelsName, &gameHelpers::changeRebelsName )); - typeAll.region.set("triumphValue", ®ionStruct::triumphValue); + typeAll.regionStruct.set("triumphValue", ®ionStruct::triumphValue); /*** Get an army by it's index. @@ -1052,7 +1423,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local army = region:getStack(0) */ - typeAll.region.set_function("getStack", &gameHelpers::getStack); + typeAll.regionStruct.set_function("getStack", &gameHelpers::getStack); /*** Get a fort by it's index. @@ -1064,7 +1435,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local fort = region:getFort(0) */ - typeAll.region.set_function("getFort", &gameHelpers::getFort); + typeAll.regionStruct.set_function("getFort", &gameHelpers::getFort); /*** Get a watchtower by it's index. @@ -1076,7 +1447,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local watch = region:getWatchtower(0) */ - typeAll.region.set_function("getWatchtower", &gameHelpers::getWatchtower); + typeAll.regionStruct.set_function("getWatchtower", &gameHelpers::getWatchtower); /*** Get a resource by it's index. @@ -1088,7 +1459,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local res = region:getResource(0) */ - typeAll.region.set_function("getResource", &gameHelpers::getResource); + typeAll.regionStruct.set_function("getResource", &gameHelpers::getResource); /*** Get a neighbour region by it's index. @@ -1100,7 +1471,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local nRegion = region:getNeighbour(0) */ - typeAll.region.set_function("getNeighbour", &gameHelpers::getNeighbour); + typeAll.regionStruct.set_function("getNeighbour", &gameHelpers::getNeighbour); /*** Check if a region has a hidden resource. @@ -1112,7 +1483,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); localhr = region:getHiddenResource(0) */ - typeAll.region.set_function("getHiddenResource", &gameHelpers::getHiddenResource); + typeAll.regionStruct.set_function("getHiddenResource", &gameHelpers::getHiddenResource); /*** Set a region's hidden resource (reset on game restart). @@ -1124,7 +1495,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); region:setHiddenResource(0, false) */ - typeAll.region.set_function("setHiddenResource", &gameHelpers::setHiddenResource); + typeAll.regionStruct.set_function("setHiddenResource", &gameHelpers::setHiddenResource); /*** Get a region that is reachable from this region. @@ -1136,7 +1507,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local connectedRegion = region:getSeaConnectedRegion(0) */ - typeAll.region.set_function("getSeaConnectedRegion", &gameHelpers::getSeaConnectedRegion); + typeAll.regionStruct.set_function("getSeaConnectedRegion", &gameHelpers::getSeaConnectedRegion); /*** Get a region this region is importing trade goods from. @@ -1148,7 +1519,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local seaImportRegion = region:getSeaImportRegion(0) */ - typeAll.region.set_function("getSeaImportRegion", &gameHelpers::getSeaImportRegion); + typeAll.regionStruct.set_function("getSeaImportRegion", &gameHelpers::getSeaImportRegion); /*** Get a region sea edge (point where it borders both sea and another land region). @@ -1160,7 +1531,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local edge = region:getRegionSeaEdge(0) */ - typeAll.region.set_function("getRegionSeaEdge", &gameHelpers::getRegionSeaEdge); + typeAll.regionStruct.set_function("getRegionSeaEdge", &gameHelpers::getRegionSeaEdge); /*** Get a devastated tile. @@ -1172,7 +1543,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local tile = region:getDevastatedTile(0) */ - typeAll.region.set_function("getDevastatedTile", &gameHelpers::getDevastatedTile); + typeAll.regionStruct.set_function("getDevastatedTile", &gameHelpers::getDevastatedTile); /*** Get a tile that borders the edge of the map. @@ -1184,7 +1555,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local edge = region:getTileBorderingEdgeOfMap(0) */ - typeAll.region.set_function("getTileBorderingEdgeOfMap", &gameHelpers::getTileBorderingEdgeOfMap); + typeAll.regionStruct.set_function("getTileBorderingEdgeOfMap", &gameHelpers::getTileBorderingEdgeOfMap); /*** Get a tile by index. @@ -1196,7 +1567,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local tile = region:getTile(0) */ - typeAll.region.set_function("getTile", &gameHelpers::getTileRegion); + typeAll.regionStruct.set_function("getTile", &gameHelpers::getTileRegion); /*** Get a fertile tile by index. @@ -1208,7 +1579,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local tile = region:getFertileTile(0) */ - typeAll.region.set_function("getFertileTile", &gameHelpers::getFertileTile); + typeAll.regionStruct.set_function("getFertileTile", &gameHelpers::getFertileTile); /*** Get religion amount from a set number of turns ago. @@ -1221,7 +1592,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local catholicThreeTurnsAgo = region:getReligionHistory(0, 3) */ - typeAll.region.set_function("getReligionHistory", &gameHelpers::getReligionHistory); + typeAll.regionStruct.set_function("getReligionHistory", &gameHelpers::getReligionHistory); /*** Check if region has a resource type. @@ -1233,7 +1604,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local hasResource = region:hasResourceType(16) */ - typeAll.region.set_function("hasResourceType", &gameHelpers::hasResourceType); + typeAll.regionStruct.set_function("hasResourceType", &gameHelpers::hasResourceType); /*** Get the strength total of all armies in this region that are hostile to a specific faction. @@ -1245,7 +1616,7 @@ void luaP::initCampaign() local region = sMap.getRegion(2); local totalStrength = region:getHostileArmiesStrength(myFac.dipNum) */ - typeAll.region.set_function("getHostileArmiesStrength", &gameHelpers::getHostileArmiesStrength); + typeAll.regionStruct.set_function("getHostileArmiesStrength", &gameHelpers::getHostileArmiesStrength); ///neighbourRegion //@section neighbourRegion @@ -1478,6 +1849,7 @@ void luaP::initP2() @tfield get get @tfield battleStruct battleStruct battle data @tfield campaignStruct campaignStruct campaign data + @tfield uiCardManager uiCardManager ui and selected objects data @table gameDataAll */ @@ -1485,7 +1857,7 @@ void luaP::initP2() /*** Call at the start of the script, this is a static object and the pointer to it doesn't change. @function gameDataAll.get - @treturn gameDataAllStruct gameDataAll + @treturn gameDataAll gameDataAll @usage gameData=gameDataAll.get(); battleXCoord=gameData.battleStruct.xCoord; @@ -1493,6 +1865,7 @@ void luaP::initP2() typeAll.gameDataAllTable.set_function("get", &gameDataAllHelper::get); typeAll.gameDataAllTable.set("battleStruct", &gameDataAllStruct::battleHandler); typeAll.gameDataAllTable.set("campaignStruct", &gameDataAllStruct::campaignData); + typeAll.gameDataAllTable.set("uiCardManager", &gameDataAllStruct::uiCardManager); typeAll.gameDataAllTable.set("stratMap", &gameDataAllStruct::stratMap); @@ -1542,7 +1915,7 @@ void luaP::initP2() tfield getPlayerArmy getPlayerArmy @tfield getBattleResidence getBattleResidence - @table gameDataAll.battleStruct + @table battleStruct */ typeAll.battleTable = luaState.new_usertype("battleStruct"); typeAll.battleTable.set("battleState", &battleDataS::battleState); @@ -1601,7 +1974,7 @@ void luaP::initP2() @tfield int alliance @tfield int soldierCount @tfield int factionCount - @tfield int totalStrenght + @tfield int totalStrength @tfield battleAI battleAIPlan @tfield getBattleArmy getBattleArmy @tfield trackedPointerArmy[8] armies Returns a table of trackedPointerArmy. Maximum: 8. @@ -1610,7 +1983,7 @@ void luaP::initP2() - @table battleStruct.battleSide + @table battleSide */ typeAll.battleSideTable = luaState.new_usertype("battleSide"); typeAll.battleSideTable.set("isDefender", &battleSide::isDefender); @@ -1619,7 +1992,7 @@ void luaP::initP2() typeAll.battleSideTable.set("battleSuccess", &battleSide::battleSuccess); typeAll.battleSideTable.set("alliance", &battleSide::alliance); typeAll.battleSideTable.set("soldierCount", &battleSide::soldierCount); - typeAll.battleSideTable.set("totalStrenght", &battleSide::totalStrenght); + typeAll.battleSideTable.set("totalStrength", &battleSide::totalStrength); typeAll.battleSideTable.set("factionCount", &battleSide::factionCount); typeAll.battleSideTable.set("battleAIPlan", &battleSide::battleAIPlan); typeAll.battleSideTable.set("winConditions", sol::property([](battleSide& self) { return std::ref(self.winConditions); })); @@ -1699,7 +2072,7 @@ void luaP::initP2() - @table battleSide.trackedPointerArmy + @table trackedPointerArmy */ typeAll.trackedPointerArmyTable = luaState.new_usertype("trackedPointerArmy"); typeAll.trackedPointerArmyTable.set("army", &trackedPointerArmy::stack); @@ -1774,11 +2147,9 @@ void luaP::initP2() @tfield stackStruct army @tfield character character @tfield int generalNumKillsBattle + @tfield float totalValue @tfield float generalHPRatioLost - @tfield float battleOdds @tfield int numKilledGenerals - @tfield int numDiedGenerals - @tfield int numKilledCaptains @tfield int unitCount @tfield getBattleUnit getBattleUnit @@ -1789,10 +2160,8 @@ void luaP::initP2() typeAll.battleArmy.set("character", &armyAndCharacter::character); typeAll.battleArmy.set("generalNumKillsBattle", &armyAndCharacter::generalNumKillsBattle); typeAll.battleArmy.set("generalHPRatioLost", &armyAndCharacter::generalHPRatioLost); - typeAll.battleArmy.set("battleOdds", &armyAndCharacter::battleOdds); typeAll.battleArmy.set("numKilledGenerals", &armyAndCharacter::numKilledGenerals); - typeAll.battleArmy.set("numDiedGenerals", &armyAndCharacter::generalsDiedCount); - typeAll.battleArmy.set("numKilledCaptains", &armyAndCharacter::killedCaptainsCount); + typeAll.battleArmy.set("totalValue", &armyAndCharacter::totalValue); typeAll.battleArmy.set("unitCount", &armyAndCharacter::unitCount); /*** Get a battle unit by it's index. @@ -1812,6 +2181,7 @@ void luaP::initP2() Basic battleUnit table @tfield unit unit + @tfield float valuePerSoldier @tfield int soldiersLost @tfield int soldiersStart @tfield int unitsRouted @@ -1825,11 +2195,13 @@ void luaP::initP2() @tfield int expStart @tfield int expGained @tfield int isGeneral + @tfield int hasWithdrawn @table battleUnit */ typeAll.battleUnit = luaState.new_usertype("battleUnit"); typeAll.battleUnit.set("unit", &battleUnit::unit); + typeAll.battleUnit.set("valuePerSoldier", &battleUnit::valuePerSoldier); typeAll.battleUnit.set("soldiersLost", &battleUnit::soldiersLost); typeAll.battleUnit.set("soldiersStart", &battleUnit::soldiersStart); typeAll.battleUnit.set("unitsRouted", &battleUnit::unitsRouted); @@ -1843,6 +2215,7 @@ void luaP::initP2() typeAll.battleUnit.set("expStart", &battleUnit::expStart); typeAll.battleUnit.set("expGained", &battleUnit::expGained); typeAll.battleUnit.set("isGeneral", &battleUnit::isGeneral); + typeAll.battleUnit.set("hasWithdrawn", &battleUnit::isGeneral); /// battleResidence //@section battleResidence diff --git a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h index ea3295815..786c8e46c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -960,7 +960,7 @@ struct battleUnit public: struct unit* unit; //0x0000 struct UNICODE_STRING** localizedName; //0x0004 - float someFloat; //0x0008 + float valuePerSoldier; //0x0008 int32_t soldiersLost; //0x000C int32_t soldiersKilled; //0x0010 int32_t takenPrisoner; //0x0014 @@ -1213,7 +1213,7 @@ struct armyAndCharacter { /* in battle leader and leader army */ struct general* character;//0x0004 int32_t generalNumKillsBattle; //0x0008 float generalHPRatioLost; //0x000C - float someFloat; //0x0010 + float totalValue; //0x0010 float battleOdds; //0x0014 char pad_0018[12]; //0x0018 struct general* killedGenerals; //0x0024 @@ -1343,11 +1343,33 @@ struct battleAI char pad_07A4[96]; //0x07A4 }; //Size: 0x0804 +/* +0 not in battle +1 prebattle scroll +2 delay (also for preconflict phase of successful ambushes) +3 deployment +4 +5 conflict (also for pause) +6 victory scroll +7 pursuit +8 +9 postbattle scroll (not for autoresolved battles) +0 succesful ambush +1 failed ambush +2 normal +3 siege +4 sally besieger +5 naval +6 withdrawal? + */ + struct battleSide { bool isDefender;//0x0000 uchar field_0x1;//0x0001 bool isCanDeploy;//0x0002 - undefined field_0x3[9];//0x0003 + char pad_0003[1]; //0x0003 + uint32_t factionBitMap; //0x0004 + char pad_0008[4]; //0x0008 DWORD winConditions[4];//0x000C int32_t winConditionCount; //0x001C char pad_0020[4]; //0x0020 @@ -1366,18 +1388,18 @@ struct battleSide { struct factionStruct* factions[8]; //0x185C int32_t factionCount; //0x187C char pad_1880[4]; //0x1880 - DWORD someArray; //0x1884 - int32_t someArraySize; //0x1888 - int32_t someArrayCount; //0x188C - DWORD someArray2; //0x1890 - int32_t someArraySize2; //0x1894 - int32_t someArrayCount2; //0x1898 + struct unit** units; //0x1884 + int32_t unitSize; //0x1888 + int32_t unitNum; //0x188C + struct stackStruct** armies2; //0x1890 + int32_t armies2Size; //0x1894 + int32_t armies2Num; //0x1898 --often broken dont bind to lua char pad_189C[104]; //0x189C - int32_t totalStrenght; //0x1904 - int32_t autoResolveStrenghtMaybe; //0x1908 + int32_t totalStrength; //0x1904 + int32_t totalValue; //0x1908 char pad_190C[4]; //0x190C - int32_t totalStrenght2; //0x1910 - int32_t totalStrenght3; //0x1914 + int32_t totalStrength2; //0x1910 + int32_t totalStrength3; //0x1914 int32_t soldierCount; //0x1918 float battleOdds; //0x191C float battleOdds2; //0x1920 @@ -1397,7 +1419,8 @@ struct battleDataS { int battleState; /* 0-not in battle,5-active battle,9-results screen,etc 0x0004 */ uint32_t battleType; //0x0008 int32_t isNightBattle; //0x000C - char pad_0010[8]; //0x0010 + char pad_0010[4]; //0x0010 + int32_t battleResult; //0x0014 int xCoord;//0x0018 int yCoord;//0x001C undefined somethingRelatedToBattleType[16];//0x0020 @@ -1421,7 +1444,9 @@ struct battleDataS { struct battleSide sides[8]; //0x009C int32_t factionSide[31]; //0xC9FC int sidesNum;//0xCA78 - char pad_CA7C[44]; //0xCA7C + char pad_CA7C[4]; //0xCA7C + int32_t soldiersLeft; //0xCA80 + char pad_CA84[36]; //0xCA84 struct playerArmy playerArmies[30]; //0xCAA8 char pad_CD78[4]; //0xCD78 int32_t playerArmyCount; //0xCD7C diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index caa72d714..009801d89 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp @@ -77,6 +77,10 @@ recruitmentCapability* settlementHelpers::getRecruitmentCapability(settlementStr { return &sett->capabilities.recruitmentCapabilities[index]; } +int settlementHelpers::getRecruitmentCapabilityNum(settlementStruct* sett) +{ + return sett->capabilities.recruitmentCapabilityCount; +} settlementRecruitmentPool* settlementHelpers::getSettlementRecruitmentPool(settlementStruct* sett, int index) { return &sett->recruitmentPools[index]; diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h index c2861577a..b83d86bd2 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h @@ -24,6 +24,7 @@ namespace settlementHelpers settlementCapability* getAgentLimitCapability(settlementStruct* sett, int agentType); recruitmentCapability* getRecruitmentCapability(settlementStruct* sett, int index); settlementRecruitmentPool* getSettlementRecruitmentPool(settlementStruct* sett, int index); + int getRecruitmentCapabilityNum(settlementStruct* sett); std::string getSettlementName(settlementStruct* sett); diff --git a/documentationGenerator/generateLuaDocs.py b/documentationGenerator/generateLuaDocs.py index 91482ad2b..f1135b0a6 100644 --- a/documentationGenerator/generateLuaDocs.py +++ b/documentationGenerator/generateLuaDocs.py @@ -11,20 +11,35 @@ def fixTypes(field): def writeClass(newClass): outputfile.write("---" + newClass.descr.strip() + "\n") - outputfile.write("---@class " + newClass.name + "\n") + + if newClass.enum is None: + outputfile.write("---@class " + newClass.name + "\n") + else: + outputfile.write("---@enum " + newClass.name + "\n") outputfile.write(newClass.name + " = { \n\n") for field in newClass.tfields: if field.type != "function": - if field.comment != "": - outputfile.write(" ---" + field.comment.strip() + "\n") - fixTypes(field) - outputfile.write(" ---@type " + field.type + "\n") - outputfile.write(" " + field.name + " = nil,\n\n") + if newClass.enum is None: + if field.comment != "": + outputfile.write(" ---" + field.comment.strip() + "\n") + fixTypes(field) + outputfile.write(" ---@type " + field.type + "\n") + outputfile.write(" " + field.name + " = nil,\n\n") + else: + if field.name in newClass.enum.values: + if field.comment != "": + outputfile.write(" ---" + field.comment.strip() + "\n") + fixTypes(field) + outputfile.write(" ---@type " + field.type + "\n") + if newClass.enum.values[field.name] is None: + outputfile.write(" " + field.name + " = " + "nil" + ",\n\n") + else: + outputfile.write(" " + field.name + " = " + newClass.enum.values[field.name] + ",\n\n") outputfile.write("}\n\n") for field in newClass.tfields: if field.type == "function": if field.comment != "": - outputfile.write("---" + field.comment.strip() + "\n") + outputfile.write("---" + field.comment + "\n") nextparams = [] firstParamBool = True firstparam = "" @@ -58,6 +73,7 @@ class luaClass: name = "" tfields = [] descr = "" + enum = None class returnValue: def __init__(self, type, name, comment): @@ -74,6 +90,11 @@ def __init__(self, type, name, comment): params = [] selfCall = False funcEvent = False + +class enum: + def __init__(self): + self.values = {} + values = {} class param: def __init__(self, type, name, comment): @@ -92,6 +113,7 @@ def __init__(self, type, name, comment): funcName = "" nextLineComment = False newSection = False +countEnum = False for name in filenames: file = open(luaPluginPath + name, 'r') for line in file: @@ -165,14 +187,33 @@ def __init__(self, type, name, comment): if re.search(r'@table', line) is not None: newClass.name = re.findall(r'@table\s+(\S+)', line)[0] newSection = False + if re.search(r'luaState.new_enum', line) is not None: + newClass.enum = enum() + countEnum = True + continue + if countEnum: + if re.search(r',', line) is not None: + if re.search(r',\s*\S', line) is not None: + key = re.findall(r'\"(\S*)\"\s*,', line)[0].strip() + if re.search(r',\s*(\d+)', line) is not None: + value = re.findall(r',\s*(\d+)', line)[0].strip() + else: + value = None + newClass.enum.values[key] = value + else: + countEnum = False if re.search(r'\*\*\*', line) is not None: nextLineComment = True continue if nextLineComment == True: + if line.strip() == "": continue if newSection == True: newClass.descr = newClass.descr + line.strip() + " " else: - funcComment = funcComment + line.strip() + " " + if funcComment == "": + funcComment = line.strip() + else: + funcComment += "\n-- " + line.strip() writeClass(newClass) del newClass From 0953f05be1145f4689c8d0ed0a347889980dd36c Mon Sep 17 00:00:00 2001 From: Eddie Eldridge Date: Tue, 24 Oct 2023 15:17:17 +0100 Subject: [PATCH 21/22] Add default value of isPlannedRetreatRoute to battlesCfg.json --- M2TWEOP DataFiles/eopBattles/battlesCfg.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/M2TWEOP DataFiles/eopBattles/battlesCfg.json b/M2TWEOP DataFiles/eopBattles/battlesCfg.json index 924cc27ed..0645df166 100644 --- a/M2TWEOP DataFiles/eopBattles/battlesCfg.json +++ b/M2TWEOP DataFiles/eopBattles/battlesCfg.json @@ -1,4 +1,5 @@ { "enableAutoGeneration": false, - "enableResultsTransfer": false + "enableResultsTransfer": false, + "isPlannedRetreatRoute": false } \ No newline at end of file From e744ef4a34e4fa2d3fe6a830169b091a583ef5bd Mon Sep 17 00:00:00 2001 From: Eddie Eldridge Date: Tue, 24 Oct 2023 15:18:23 +0100 Subject: [PATCH 22/22] Fixup some bad styling on the site --- .../Lib/site-packages/alabaster/static/alabaster.css_t | 3 --- 1 file changed, 3 deletions(-) diff --git a/documentationGenerator/EOPDocs/WPy32-3890/python-3.8.9/Lib/site-packages/alabaster/static/alabaster.css_t b/documentationGenerator/EOPDocs/WPy32-3890/python-3.8.9/Lib/site-packages/alabaster/static/alabaster.css_t index 45597297c..3b1591507 100644 --- a/documentationGenerator/EOPDocs/WPy32-3890/python-3.8.9/Lib/site-packages/alabaster/static/alabaster.css_t +++ b/documentationGenerator/EOPDocs/WPy32-3890/python-3.8.9/Lib/site-packages/alabaster/static/alabaster.css_t @@ -126,7 +126,6 @@ div.relations { div.sphinxsidebar a { color: {{ theme_sidebar_link }}; text-decoration: none; - border-bottom: 1px dotted {{ theme_sidebar_link_underscore }}; } div.sphinxsidebar a:hover { @@ -514,7 +513,6 @@ tt.xref, code.xref, a tt { a.reference { text-decoration: none; - border-bottom: 1px dotted {{ theme_link }}; } /* Don't put an underline on images */ @@ -523,7 +521,6 @@ a.image-reference, a.image-reference:hover { } a.reference:hover { - border-bottom: 1px solid {{ theme_link_hover }}; } a.footnote-reference {