diff --git a/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj b/M2TWEOP Code/M2TWEOP GUI/M2TWEOP GUI.vcxproj index c2c17479b..a2b6997cf 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 Code/M2TWEOP GUI/helpers.cpp b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp index 9d6e58844..cb09e0fe1 100644 --- a/M2TWEOP Code/M2TWEOP GUI/helpers.cpp +++ b/M2TWEOP Code/M2TWEOP GUI/helpers.cpp @@ -356,18 +356,125 @@ 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 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(modPathCheck.begin(), modPathCheck.end(), '/', '\\'); + std::transform(expectedPath.begin(), expectedPath.end(), expectedPath.begin(), ::tolower); + std::transform(modPathCheck.begin(), modPathCheck.end(), modPathCheck.begin(), ::tolower); + + return modPathCheck == 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); diff --git a/M2TWEOP Code/M2TWEOP library/Injects.cpp b/M2TWEOP Code/M2TWEOP library/Injects.cpp index a809a5c47..4dddeab50 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); @@ -2479,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) { @@ -2965,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; +} + - a->mov(ecx, (int)&fakeEDBPointer); - a->mov(dword_ptr(ecx), esi); - 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 +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->pushf(); + + 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); @@ -3104,49 +3218,59 @@ void OnCreateMercUnit::SetNewCode() delete a; } -OnQuickSave::OnQuickSave(MemWork* mem, LPVOID addr, int ver) +OnGetRecruitPoolUnitEntry::OnGetRecruitPoolUnitEntry(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x00c30a83; - + { + m_adress = 0x005E61A6; + } else if (ver == 1)//kingdoms - m_adress = 0x00c366b3; + { + m_adress = 0x005E5D46; + } } -OnQuickSave::~OnQuickSave() +OnGetRecruitPoolUnitEntry::~OnGetRecruitPoolUnitEntry() { } -void OnQuickSave::SetOriginialCode() +void OnGetRecruitPoolUnitEntry::SetOriginialCode() { Assembler* a = new Assembler(); - //push pointer to "%S.sav" string - a->ret(); m_originalBytes = (unsigned char*)a->make(); m_originalSize = m_memory->GetASMSize(m_originalBytes); delete a; } - -void OnQuickSave::SetNewCode() +void OnGetRecruitPoolUnitEntry::SetNewCode() { Assembler* a = new Assembler(); + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); - a->pushad(); a->pushf(); + a->mov(ecx, eax); a->mov(eax, (DWORD)funcAddress); a->call(eax); + a->lea(esi, dword_ptr(eax)); - a->mov(dword_ptr(esp, 0x20), eax);//move eax to stored eax a->popf(); - a->popad(); - a->push(eax); + a->pop(edi); + a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + a->ret(); m_cheatBytes = (unsigned char*)a->make(); @@ -3154,49 +3278,62 @@ void OnQuickSave::SetNewCode() delete a; } -OnAutoSave::OnAutoSave(MemWork* mem, LPVOID addr, int ver) + + +loadRecruitQueue::loadRecruitQueue(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x0047cd72; - + { + m_adress = 0x005D82F5; + } else if (ver == 1)//kingdoms - m_adress = 0x0047c992; + { + m_adress = 0x005D7E65; + } } -OnAutoSave::~OnAutoSave() +loadRecruitQueue::~loadRecruitQueue() { } -void OnAutoSave::SetOriginialCode() +void loadRecruitQueue::SetOriginialCode() { Assembler* a = new Assembler(); - //push pointer to "%s%S%s%S.sav" string - a->ret(); m_originalBytes = (unsigned char*)a->make(); m_originalSize = m_memory->GetASMSize(m_originalBytes); delete a; } - -void OnAutoSave::SetNewCode() +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->pushad(); a->pushf(); + a->mov(ecx, eax); a->mov(eax, (DWORD)funcAddress); a->call(eax); - a->mov(dword_ptr(esp, 0x20), eax);//move eax to stored eax a->popf(); - a->popad(); - a->push(eax); + 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(); @@ -3204,40 +3341,61 @@ void OnAutoSave::SetNewCode() delete a; } -blockLaunchWithoutEop::blockLaunchWithoutEop(MemWork* mem, int ver) - :AATemplate(mem) + +loadRecruitQueue2::loadRecruitQueue2(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x008efe32; - + { + m_adress = 0x005D835D; + } else if (ver == 1)//kingdoms - m_adress = 0x008ef3b2; + { + m_adress = 0x005D7ECD; + } } -blockLaunchWithoutEop::~blockLaunchWithoutEop() +loadRecruitQueue2::~loadRecruitQueue2() { } -void blockLaunchWithoutEop::SetOriginialCode() +void loadRecruitQueue2::SetOriginialCode() { Assembler* a = new Assembler(); - //push pointer to "type" string - a->ret(); m_originalBytes = (unsigned char*)a->make(); m_originalSize = m_memory->GetASMSize(m_originalBytes); delete a; } - -void blockLaunchWithoutEop::SetNewCode() +void loadRecruitQueue2::SetNewCode() { - static char newTypeString[] = "eopOnlyType"; Assembler* a = new Assembler(); - a->mov(ecx, (int)newTypeString); + 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(); @@ -3245,56 +3403,58 @@ void blockLaunchWithoutEop::SetNewCode() delete a; } -/* -OntryFindTypeIdInListRecruitPoolEDB::OntryFindTypeIdInListRecruitPoolEDB(MemWork* mem, LPVOID addr, int ver) +OnGetRecruitPoolUnitEntry2::OnGetRecruitPoolUnitEntry2(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x0046e0e8; - + { + m_adress = 0x00AB92A8; + } else if (ver == 1)//kingdoms - m_adress = 0x0046dd28; + { + m_adress = 0x00AB8278; + } } -OntryFindTypeIdInListRecruitPoolEDB::~OntryFindTypeIdInListRecruitPoolEDB() +OnGetRecruitPoolUnitEntry2::~OnGetRecruitPoolUnitEntry2() { } -void OntryFindTypeIdInListRecruitPoolEDB::SetOriginialCode() +void OnGetRecruitPoolUnitEntry2::SetOriginialCode() { Assembler* a = new Assembler(); - a->pop(edi); - a->pop(esi); - a->pop(ebp); - a->xor_(eax,eax); - //push pointer to "%S.sav" string - a->ret(); m_originalBytes = (unsigned char*)a->make(); m_originalSize = m_memory->GetASMSize(m_originalBytes); delete a; } - -void OntryFindTypeIdInListRecruitPoolEDB::SetNewCode() +void OnGetRecruitPoolUnitEntry2::SetNewCode() { Assembler* a = new Assembler(); - a->pushad(); + a->push(edx); + a->push(ecx); + a->push(ebx); + a->push(ebp); + a->push(edi); + a->pushf(); - a->mov(ecx, ebp);//just to indicate - string pointer in ebp + a->mov(ecx, eax); a->mov(eax, (DWORD)funcAddress); a->call(eax); a->popf(); - a->mov(dword_ptr(esp, 0x1c), eax);//move eax to stored eax - a->popad(); a->pop(edi); - a->pop(esi); a->pop(ebp); + a->pop(ebx); + a->pop(ecx); + a->pop(edx); + + a->ret(); m_cheatBytes = (unsigned char*)a->make(); @@ -3302,12 +3462,387 @@ void OntryFindTypeIdInListRecruitPoolEDB::SetNewCode() delete a; } -OnrecruitPoolFillFromFile::OnrecruitPoolFillFromFile(MemWork* mem, LPVOID addr, int ver) +OnFindUnitStrings::OnFindUnitStrings(MemWork* mem, LPVOID addr, int ver) :AATemplate(mem), funcAddress(addr) { if (ver == 2)//steam - m_adress = 0x008a9ce5; - + { + 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) +{ + if (ver == 2)//steam + { + m_adress = 0x008EC39F; + } + else if (ver == 1)//kingdoms + { + m_adress = 0x008EB91F; + } +} + +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) +{ + if (ver == 2)//steam + m_adress = 0x00c30a83; + + else if (ver == 1)//kingdoms + m_adress = 0x00c366b3; +} + +OnQuickSave::~OnQuickSave() +{ +} + +void OnQuickSave::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + //push pointer to "%S.sav" string + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnQuickSave::SetNewCode() +{ + Assembler* a = new Assembler(); + + + a->pushad(); + a->pushf(); + + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->mov(dword_ptr(esp, 0x20), eax);//move eax to stored eax + a->popf(); + a->popad(); + + a->push(eax); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +OnAutoSave::OnAutoSave(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + m_adress = 0x0047cd72; + + else if (ver == 1)//kingdoms + m_adress = 0x0047c992; +} + +OnAutoSave::~OnAutoSave() +{ +} + +void OnAutoSave::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + //push pointer to "%s%S%s%S.sav" string + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OnAutoSave::SetNewCode() +{ + Assembler* a = new Assembler(); + + + a->pushad(); + a->pushf(); + + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->mov(dword_ptr(esp, 0x20), eax);//move eax to stored eax + a->popf(); + a->popad(); + + a->push(eax); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +blockLaunchWithoutEop::blockLaunchWithoutEop(MemWork* mem, int ver) + :AATemplate(mem) +{ + if (ver == 2)//steam + m_adress = 0x008efe32; + + else if (ver == 1)//kingdoms + m_adress = 0x008ef3b2; +} + +blockLaunchWithoutEop::~blockLaunchWithoutEop() +{ +} + +void blockLaunchWithoutEop::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + //push pointer to "type" string + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void blockLaunchWithoutEop::SetNewCode() +{ + static char newTypeString[] = "eopOnlyType"; + Assembler* a = new Assembler(); + + a->mov(ecx, (int)newTypeString); + a->push(ecx); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +/* +OntryFindTypeIdInListRecruitPoolEDB::OntryFindTypeIdInListRecruitPoolEDB(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + m_adress = 0x0046e0e8; + + else if (ver == 1)//kingdoms + m_adress = 0x0046dd28; +} + +OntryFindTypeIdInListRecruitPoolEDB::~OntryFindTypeIdInListRecruitPoolEDB() +{ +} + +void OntryFindTypeIdInListRecruitPoolEDB::SetOriginialCode() +{ + Assembler* a = new Assembler(); + + a->pop(edi); + a->pop(esi); + a->pop(ebp); + a->xor_(eax,eax); + //push pointer to "%S.sav" string + + a->ret(); + m_originalBytes = (unsigned char*)a->make(); + m_originalSize = m_memory->GetASMSize(m_originalBytes); + + delete a; +} + +void OntryFindTypeIdInListRecruitPoolEDB::SetNewCode() +{ + Assembler* a = new Assembler(); + + a->pushad(); + a->pushf(); + + a->mov(ecx, ebp);//just to indicate - string pointer in ebp + a->mov(eax, (DWORD)funcAddress); + a->call(eax); + + a->popf(); + a->mov(dword_ptr(esp, 0x1c), eax);//move eax to stored eax + a->popad(); + + a->pop(edi); + a->pop(esi); + a->pop(ebp); + + a->ret(); + m_cheatBytes = (unsigned char*)a->make(); + + delete a; +} + +OnrecruitPoolFillFromFile::OnrecruitPoolFillFromFile(MemWork* mem, LPVOID addr, int ver) + :AATemplate(mem), funcAddress(addr) +{ + if (ver == 2)//steam + m_adress = 0x008a9ce5; + else if (ver == 1)//kingdoms m_adress = 0x008a9305; } @@ -3530,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() @@ -3562,9 +4096,92 @@ 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 7cef08b0a..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 { @@ -806,6 +832,71 @@ 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 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 { @@ -956,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/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) { 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/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/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/fastFuncts.cpp b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp index 2f715621c..f8000c8e6 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.cpp @@ -298,7 +298,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) @@ -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) @@ -646,7 +646,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; @@ -707,7 +707,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; @@ -765,7 +765,7 @@ namespace fastFuncts } } - EOP_EXPORT int addAnchillary(generalCharacterictics* 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(generalCharacterictics* 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; @@ -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/fastFuncts.h b/M2TWEOP Code/M2TWEOP library/fastFuncts.h index 3b8907cbe..a4db0b528 100644 --- a/M2TWEOP Code/M2TWEOP library/fastFuncts.h +++ b/M2TWEOP Code/M2TWEOP library/fastFuncts.h @@ -24,8 +24,8 @@ namespace fastFuncts 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); @@ -39,7 +39,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(); @@ -80,19 +80,19 @@ namespace fastFuncts factionStratMapDescrS* GetFactSmDescrById(int id); //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, ancillary* anch); //remove anchillary from character - NOINLINE EOP_EXPORT void removeAnchillary(generalCharacterictics* 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); @@ -108,13 +108,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 @@ -126,7 +126,7 @@ namespace fastFuncts NOINLINE EOP_EXPORT bool StopSiege(stackStruct* army); NOINLINE EOP_EXPORT bool StopBlockPort(stackStruct* army); 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 void AddToSettlement(stackStruct*army,settlementStruct* set); @@ -147,7 +147,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 3e37e8ee7..148b6f81f 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 ee4004c74..115be867e 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/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 f9628866a..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); @@ -471,6 +488,47 @@ 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 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/onlineThings.cpp b/M2TWEOP Code/M2TWEOP library/onlineThings.cpp index 3d384b85c..747fbea1d 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) { @@ -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); } @@ -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..6bcce7ad3 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; @@ -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; @@ -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/patchesForGame.cpp b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp index 6a9338e0d..7445900c7 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.cpp @@ -83,7 +83,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) @@ -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) @@ -126,19 +143,41 @@ 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; } 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; +} + +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" }; @@ -306,6 +345,11 @@ void __stdcall patchesForGame::afterEDUread() #endif } +void __stdcall patchesForGame::onGameInit() +{ + plugins::onGameInit(); +} + void __stdcall patchesForGame::onChangeTurnNum() { #if defined TESTPATCHES @@ -427,7 +471,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); @@ -435,7 +479,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) @@ -549,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 06a28a634..638a997f0 100644 --- a/M2TWEOP Code/M2TWEOP library/patchesForGame.h +++ b/M2TWEOP Code/M2TWEOP library/patchesForGame.h @@ -11,12 +11,15 @@ 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 char* __fastcall onSaveEDUStringS(eduEntry* eduEntry); + 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 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); @@ -31,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 @@ -64,7 +68,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); @@ -98,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 9fab1db63..465a8b640 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.cpp +++ b/M2TWEOP Code/M2TWEOP library/plugins.cpp @@ -11,7 +11,6 @@ #include "PlannedRetreatRoute.h" plugins::configT plugins::pluginsCfg; -vector* plugins::eventNames; void plugins::init() { @@ -20,8 +19,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" @@ -39,7 +37,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; @@ -50,8 +48,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]); @@ -68,583 +73,6 @@ void __fastcall plugins::onEvent(DWORD** vTab) battleCreator::onHotseatScreen(); } } - else if (strcmp(event, "FactionTurnStart") == 0) - { - factionStruct* fac = reinterpret_cast(vTab[1]); - - discordManager::OnFactionTurnStart(fac); - PlannedRetreatRoute::OnFactionTurnStart(fac); - } - - - /*if (strcmp(event, "CharacterSelected") == 0) - { - - generalCharacterictics* 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->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)) - { - 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]); - - (*(*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)) - { - 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->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]); - - (*(*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)) - { - generalCharacterictics* 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]); - 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]); - 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->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]); - (*(*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->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]); - 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)) - { - generalCharacterictics* 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]); - (*(*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)) - { - generalCharacterictics* 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->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]); - (*(*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->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]); - /*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->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]); - 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->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]); - 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]); - (*(*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); - } - } } @@ -799,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) @@ -870,118 +306,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) @@ -1002,476 +326,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]; - - - //onCharacterSelected - fName = "onCharacterSelected"; - onCharacterSelected.Load(&plPath, &fName); - 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); - 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]; - - - //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); - onAssassinCaughtAttackingPope.strCmp = (*plugins::eventNames)[AssassinCaughtAttackingPopeCode]; - - //onAddedToTrainingQueue - fName = "onAddedToTrainingQueue"; - 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); - onUnitTrained.strCmp = (*plugins::eventNames)[UnitTrainedCode]; - - - //onAgentCreated - fName = "onAgentCreated"; - 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); - 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]; - - //onTileSeen - fName = "onTileSeen"; - onTileSeen.Load(&plPath, &fName); - onTileSeen.strCmp = (*plugins::eventNames)[TileSeenCode]; - - //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]; - - //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]; - - //onGuildUpgraded - fName = "onGuildUpgraded"; - onGuildUpgraded.Load(&plPath, &fName); - onGuildUpgraded.strCmp = (*plugins::eventNames)[GuildUpgradedCode]; - - //onGuildDestroyed - fName = "onGuildDestroyed"; - 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); - onNewAdmiralCreated.strCmp = (*plugins::eventNames)[NewAdmiralCreatedCode]; - - //onShortcutTriggered - fName = "onShortcutTriggered"; - 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]; + //onEvent + fName = "onEventWrapper"; + onEventWrapper.Load(&plPath, &fName); //drawOnEndScene fName = "drawOnEndScene"; @@ -1525,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 f77c33147..a52283d3d 100644 --- a/M2TWEOP Code/M2TWEOP library/plugins.h +++ b/M2TWEOP Code/M2TWEOP library/plugins.h @@ -86,131 +86,7 @@ class plugin ProcLoader onChangeTurnNum; - - 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 onSiegeEquipmentCompleted; - ProcLoader onPostBattle; - - ProcLoader onSettlementSelected; - ProcLoader onSettlementUpgraded; - ProcLoader onSettlementConverted; - - ProcLoader onCityRiots; - - ProcLoader onUngarrisonedSettlement; - ProcLoader onUngarrisonedFort; - - ProcLoader onGiveSettlement; - - 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 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 onGameReloaded; - - ProcLoader onTransgression; - - ProcLoader onGuildUpgraded; - ProcLoader onGuildDestroyed; - - ProcLoader onBrotherAdopted; - ProcLoader onBirth; - ProcLoader onCharacterComesOfAge; - ProcLoader onCharacterMarries; - ProcLoader onCharacterBecomesAFather; - - ProcLoader onNewAdmiralCreated; - - ProcLoader onShortcutTriggered; - ProcLoader onCharacterMarriesPrincess; - ProcLoader onBecomesFactionLeader; - ProcLoader onBecomesFactionHeir; + ProcLoader onEventWrapper; ProcLoader drawOnEndScene; ProcLoader onReset; @@ -221,6 +97,7 @@ class plugin ProcLoader onWndProc; ProcLoader onReadGameDbsAtStart; + ProcLoader onGameInit; ProcLoader onEndSiege; ProcLoader onStartSiege; @@ -242,7 +119,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 @@ -260,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); @@ -267,14 +145,10 @@ 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); 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 7768aa72a..3ded769b7 100644 --- a/M2TWEOP Code/M2TWEOP library/realGameTypes.h +++ b/M2TWEOP Code/M2TWEOP library/realGameTypes.h @@ -16,12 +16,194 @@ 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 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: + 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 + + +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 + 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 @@ -29,9 +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 - char pad_0020[12]; //0x0020 + int32_t roadLevel; //0x0020 + int32_t farmingLevel; //0x0024 + int32_t famineThreat; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -43,23 +227,51 @@ 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 + 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 tradeFleetCount; //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[12]; //0x009C + int32_t* devastatedTiles; //0x00A8 + int32_t devastatedTilesSize; //0x00AC + int32_t devastatedTilesCount; //0x00B0 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 + int32_t armiesHostileToArrayIndexIDStrength[31]; //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 @@ -67,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 @@ -75,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 @@ -86,26 +302,113 @@ struct neighbourRegion struct regionStruct* region; //0x0000 int32_t regionID; //0x0004 float distance; //0x0008 - char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + int8_t alliedRegion; //0x000C + char pad_000D[3]; //0x000D + 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 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[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + 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; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD arraySmthing; //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 { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t experience; //0x0004 int32_t cost; //0x0008 float replenishMin; //0x000C @@ -154,6 +457,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; @@ -170,9 +483,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]; + DWORD* object; //can be character, resource, fort, + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -185,12 +513,16 @@ 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; + 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 +531,98 @@ 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 + uint32_t stratTableStringIndex; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + uint32_t factionsToOutliveBitfield; //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 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: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + struct battleBuildings* battleBuildings; //0x0034 + char pad_0038[4]; //0x0038 + 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 +643,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 { @@ -243,11 +672,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 { @@ -262,31 +705,132 @@ 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[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 +{ +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]; + 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; 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]; + uint32_t existingFactionsBitMap; //0x0324 + int32_t nonPlayableFactionsNum; //0x0328 + char pad_032C[12]; //0x032C + 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; @@ -294,23 +838,47 @@ 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; - undefined field37_0x3f4[4]; + int8_t N00001211; //0x03F4 + int8_t showDateAsTurns; //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 +890,53 @@ 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 + char pad[16]; //0x21638 + struct mercPoolList allMercPools; //0x2163C + void* unk3; //0x21650 + void* unk4; //0x21654 +}; + +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 +947,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 @@ -354,14 +961,251 @@ 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 + int8_t hasWithdrawn; //0x003D + uint16_t N000400D6; //0x003E + int32_t N0001FD2C; //0x0040 + int32_t N0001FDB3; //0x0044 }; //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 @@ -370,11 +1214,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 @@ -533,6 +1384,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 */ @@ -551,11 +1409,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 { @@ -753,9 +1632,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; @@ -943,7 +1829,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 @@ -973,6 +1859,50 @@ 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 + + +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; @@ -990,23 +1920,31 @@ 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; - 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; undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ - undefined field21_0x1a5[3]; - UINT32 regionNumber; /* number of region */ - undefined field_0x1ac[12]; - int priceOfUnitsInRecruitmentSlots; + 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 */ + int32_t factionID; //0x01AC + int32_t yearFounded; //0x01B0 + int32_t triumph; //0x01B4 + int queueCost; undefined field24_0xBC[24]; struct unitRQ unitQueue[9]; int startIndexRQ; @@ -1017,20 +1955,64 @@ 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[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 + int32_t harvestSuccess; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct capabilityStruct capabilities; //0x0E54 + 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 - char pad_1704[116]; //0x1704 + char pad_16C8[48]; //0x16C8 + int32_t baseFertilityValue; //0x16F8 + int32_t rebelFactionChance; //0x16FC + int32_t turmoil; //0x1700 + 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 @@ -1085,7 +2067,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 @@ -1119,38 +2105,80 @@ 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 */ 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]; 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; + 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; 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 + 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 + 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) -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 */ @@ -1231,9 +2259,9 @@ 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** 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 */ @@ -1241,9 +2269,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]; @@ -1255,7 +2283,7 @@ struct generalCharacterictics { /* 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; @@ -1265,20 +2293,16 @@ 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; - 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* patchToAncImage; + char pad_0018[4]; //0x0018 + int8_t isUnique; //0x001C + char pad_001D[23]; //0x001D + uint32_t excludedCultures; //0x0034 }; struct trait { /* traits of the character */ @@ -1314,34 +2338,431 @@ 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 + +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]; 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]; + struct eduEntry* eduEntry; + 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; @@ -1358,27 +2779,54 @@ 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 + int8_t isHalfDestroyed; //0x014C + char pad_014D[15]; //0x014D + struct descrRebelEntry* descrRebel; //0x015C + int32_t subFactionID; //0x0160 }; struct coords { @@ -1396,56 +2844,259 @@ 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 + +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]; 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 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 */ - undefined field_0xfc[4]; + struct aiFaction* aiFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t regionsOwnedStart; //0x00F4 + struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ + 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]; - int wathtowersNum; + int32_t watchtowersSize; //0x0144 + int watchtowersNum; 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[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; - 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[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[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + 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]; 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 @@ -1492,7 +3143,7 @@ struct ArmourUpgModels //type of unit from EDU -struct EduEntry { +struct eduEntry { char* Type; uint32_t typeHash; DWORD Index; @@ -1673,8 +3324,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; @@ -1691,7 +3342,7 @@ struct EduEntry { struct eduEntryes { /* structure with all edu entries */ UINT32 qq; - struct EduEntry unitTupes[500]; + struct eduEntry unitTupes[500]; UINT32 numberOfTupes; }; @@ -1705,8 +3356,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 @@ -1722,22 +3373,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 { @@ -1774,21 +3445,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 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 Code/M2TWEOP library/stratModelsChange.cpp b/M2TWEOP Code/M2TWEOP library/stratModelsChange.cpp index c6f5c14f2..7a265294a 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" @@ -32,14 +35,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; } @@ -63,13 +65,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 @@ -81,7 +79,7 @@ namespace stratModelsChange i--; } } - stratModelChangeRecord* rec = new stratModelChangeRecord(); + auto* rec = new stratModelChangeRecord(); rec->modelId = modelId; rec->modelId2 = modelId2; rec->x = x; @@ -93,7 +91,7 @@ namespace stratModelsChange changeModelsNeededNow = modelsChangeStatus::needChange; } - stratModelRecord* findStratModel(UINT32 modelId) + stratModelRecord* findStratModel(const UINT32 modelId) { try { @@ -103,13 +101,10 @@ namespace stratModelsChange { return nullptr; } - - - return nullptr; } - model_Rigid* getModel(UINT32 modelId) + model_Rigid* getModel(const UINT32 modelId) { try { @@ -119,9 +114,6 @@ namespace stratModelsChange { return nullptr; } - - - return nullptr; } struct visibilityCrashFixS { @@ -187,7 +179,7 @@ namespace stratModelsChange } } - for (stratModelCharacterRecordChange* changeMod : stratModelCharacterChangeList) //character models + for (const stratModelCharacterRecordChange* changeMod : stratModelCharacterChangeList) //character models { changeStratModel(changeMod->gen, changeMod->modelId); } @@ -215,9 +207,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; changeModelsNeededNow = modelsChangeStatus::needChange; @@ -250,9 +242,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; @@ -260,9 +252,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) @@ -272,9 +264,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); @@ -302,13 +294,36 @@ namespace stratModelsChange 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) + stratModelArrayEntry* modelentry = findCharacterStratModel(model); //get eop strat model from vector + if (!modelentry) + { + modelentry = getStratModelEntry(model); //get vanilla strat model from 255 array + } + if (!modelentry) { - char* modelNameCopy = new char[stringsize]; - strcpy(modelNameCopy, model); - characterFacEntry->stratInfo->stratModelsArray[i].modelName = modelNameCopy; - characterFacEntry->stratInfo->stratModelsArray[i].stratModelEntry = 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 @@ -318,7 +333,7 @@ namespace stratModelsChange 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; @@ -330,7 +345,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) @@ -369,13 +384,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 { @@ -420,13 +430,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 @@ -460,21 +469,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); @@ -485,43 +494,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; @@ -531,16 +549,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 057c51ee0..015fe9e87 100644 --- a/M2TWEOP Code/M2TWEOP library/stratModelsChange.h +++ b/M2TWEOP Code/M2TWEOP library/stratModelsChange.h @@ -29,6 +29,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 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 diff --git a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp index 5f07bd46f..d1ff88be6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.cpp @@ -1,13 +1,703 @@ #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); +} + +namespace gameEvents +{ + + void initEvents() + { + const int gv = (m2tweopHelpers::getGameVersion()) - 1; + 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"); + + 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"); + + newCode[0] = 0x0137060C; newCode[1] = 0x0132B5E4; + addEvent(newCode[gv], "onMultiTurnMove"); + + newCode[0] = 0x013714F4; newCode[1] = 0x0132C4CC; + addEvent(newCode[gv], "onCharacterPanelOpen"); + + //standardEvent + 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"); + + //standardEvent + newCode[0] = 0x0136D9B4; newCode[1] = 0x0132898C; + addEvent(newCode[gv], "onBriberyMission"); + + newCode[0] = 0x0136DDAC; newCode[1] = 0x01328D84; + addEvent(newCode[gv], "onDiplomacyMission"); + + //standardEvent + 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"); + + //standardEvent + newCode[0] = 0x0136CE3C; newCode[1] = 0x01327E14; + addEvent(newCode[gv], "onLeaderOrderedSpyingMission"); + + //standardEvent + newCode[0] = 0x0136D194; newCode[1] = 0x0132816C; + addEvent(newCode[gv], "onLeaderOrderedAssassination"); + + //standardEvent + 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"); + + //standardEvent + newCode[0] = 0x0136C0B4; newCode[1] = 0x0132708C; + addEvent(newCode[gv], "onCharacterTurnEnd"); + + newCode[0] = 0x0136C18C; newCode[1] = 0x01327164; + addEvent(newCode[gv], "onCharacterTurnEndInSettlement"); + + //standardEvents + newCode[0] = 0x01369FE4; newCode[1] = 0x01324FBC; + addEvent(newCode[gv], "onGeneralCaptureSettlement"); + + newCode[0] = 0x0136A3E4; newCode[1] = 0x013253BC; + addEvent(newCode[gv], "onGeneralAssaultsResidence"); + + //standardEvent + 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"); + + //standardEvent + newCode[0] = 0x0136EEEC; newCode[1] = 0x01329EC4; + addEvent(newCode[gv], "onGovernorCityRiots"); + newCode[0] = 0x0136F084; newCode[1] = 0x0132A05C; + addEvent(newCode[gv], "onGovernorCityRebels"); + + //standardEvents + newCode[0] = 0x0136A4B4; newCode[1] = 0x0132548C; + addEvent(newCode[gv], "onGeneralAssaultsGeneral"); + newCode[0] = 0x0136C75C; newCode[1] = 0x01327734; + addEvent(newCode[gv], "onCharacterAttacksCrusadingGeneral"); + + //standardEvents + newCode[0] = 0x0136A254; newCode[1] = 0x0132522C; + addEvent(newCode[gv], "onCharacterDamagedByDisaster"); + + //standardEvents + 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"); + 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"); + + //standardEvents + newCode[0] = 0x0136F88C; newCode[1] = 0x0132A864; + addEvent(newCode[gv], "onGuildUpgraded"); + newCode[0] = 0x0136F954; newCode[1] = 0x0132A92C; + addEvent(newCode[gv], "onGuildDestroyed"); + + //standardEvents + 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; + 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"); + + 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"); + + newCode[0] = 0x01368FCC; newCode[1] = 0x0132355C; + addEvent(newCode[gv], "onBattleWinningCombat"); + + newCode[0] = 0x01368F14; newCode[1] = 0x01323EEC; + addEvent(newCode[gv], "onBattleArmyTired"); + + //standardEvents + 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"); + + //standardEvents + newCode[0] = 0x0136AEAC; newCode[1] = 0x01325E84; + addEvent(newCode[gv], "onUnitsDesertCrusade"); + + //standardEvents + newCode[0] = 0x0136AF7C; newCode[1] = 0x01325F54; + addEvent(newCode[gv], "onArmyTakesCrusadeTarget"); + + //standardEvents + newCode[0] = 0x0136B044; newCode[1] = 0x0132601C; + addEvent(newCode[gv], "onTransgression"); + + newCode[0] = 0x0136B1DC; newCode[1] = 0x013261B4; + addEvent(newCode[gv], "onForgiveness"); + + //standardEvents + 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"); + + 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] = 0x01371364; newCode[1] = 0x0132C33C; + addEvent(newCode[gv], "onDeclineAutomatedSettlementManagement"); + + //standardEvents + 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"); + + //standardEvents + newCode[0] = 0x013698CC; newCode[1] = 0x013248A4; + addEvent(newCode[gv], "onGiveMoney"); + + newCode[0] = 0x0136B36C; newCode[1] = 0x01326344; + addEvent(newCode[gv], "onDemeanour"); + + //standardEvent + newCode[0] = 0x013686FC; newCode[1] = 0x013236D4; + addEvent(newCode[gv], "onBattleArmyRouted"); + + newCode[0] = 0x0136886C; newCode[1] = 0x01323844; + addEvent(newCode[gv], "onBattleReinforcementsArrive"); + + newCode[0] = 0x0137171C; newCode[1] = 0x0132C6F4; + addEvent(newCode[gv], "onRequestMercenariesAdvice"); + + //standardEvent + newCode[0] = 0x013687B4; newCode[1] = 0x0132378C; + addEvent(newCode[gv], "onBattleGeneralRouted"); + + newCode[0] = 0x0136914C; newCode[1] = 0x01324124; + addEvent(newCode[gv], "onBattleGeneralKilled"); + + //standardEvent + newCode[0] = 0x0136B434; newCode[1] = 0x0132640C; + addEvent(newCode[gv], "onUnitDisbanded"); + + //standardEvent + newCode[0] = 0x0136E45C; newCode[1] = 0x01329434; + addEvent(newCode[gv], "onUnitTrained"); + + //standardEvent + newCode[0] = 0x0136E52C; newCode[1] = 0x01329504; + addEvent(newCode[gv], "onGovernorUnitTrained"); + + //standardEvent + newCode[0] = 0x0136E614; newCode[1] = 0x013295EC; + addEvent(newCode[gv], "onGovernorBuildingCompleted"); + + //standardEvent + 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"); + + newCode[0] = 0x013715AC; newCode[1] = 0x0132C584; + addEvent(newCode[gv], "onRequestBuildingAdvice"); + + newCode[0] = 0x01371664; newCode[1] = 0x0132C63C; + addEvent(newCode[gv], "onRequestTrainingAdvice"); + + + //standardEvents + newCode[0] = 0x0136FBB4; newCode[1] = 0x0132AB8C; + addEvent(newCode[gv], "onBuildingCompleted"); + + //standardEvent + newCode[0] = 0x0136E874; newCode[1] = 0x0132984C; + addEvent(newCode[gv], "onAgentCreated"); + + newCode[0] = 0x0136E944; newCode[1] = 0x0132991C; + addEvent(newCode[gv], "onGovernorAgentCreated"); + + //standardEvent + 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"); + + //standardEvent + newCode[0] = 0x01368CE4; newCode[1] = 0x01323CBC; + addEvent(newCode[gv], "onBattleWallsCaptured"); + + //standardEvent + newCode[0] = 0x013684A4; newCode[1] = 0x0132347C; + addEvent(newCode[gv], "onBattlePlayerUnderAttackIdle"); + + //standardEvents + 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"); + + //standardEvents + 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"); + + //standardEvents + newCode[0] = 0x0136A17C; newCode[1] = 0x01325154; + addEvent(newCode[gv], "onDisaster"); + + //standardEvents + newCode[0] = 0x0136A30C; newCode[1] = 0x013252E4; + addEvent(newCode[gv], "onEventCounter"); + + //standardEvents + newCode[0] = 0x0136AC04; newCode[1] = 0x01325BDC; + addEvent(newCode[gv], "onUngarrisonedFort"); + + //standardEvents + 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"); + + //standardEvents + newCode[0] = 0x0137102C; newCode[1] = 0x0132C004; + addEvent(newCode[gv], "onMessageClosed"); + + //standardEvents + newCode[0] = 0x01370E9C; newCode[1] = 0x0132BE74; + addEvent(newCode[gv], "onIncomingMessage"); + newCode[0] = 0x01370F64; newCode[1] = 0x0132BF3C; + addEvent(newCode[gv], "onMessageOpen"); + + //standardEvents + newCode[0] = 0x0136ACCC; newCode[1] = 0x01325CA4; + addEvent(newCode[gv], "onTileSeen"); + + //standardEvents + 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 onReadGameDbsAtStart() { + gameEvents::initEvents(); if (plugData::data.luaAll.onReadGameDbsAtStart != nullptr) { tryLua((*plugData::data.luaAll.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) @@ -92,13 +782,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 +806,6 @@ void onCampaignMapLoaded() void onLoadGamePl(std::vector* saveFiles) { - if (plugData::data.luaAll.onLoadSaveFile != nullptr) { sol::as_table_t> wrapped_vec = *saveFiles; @@ -145,100 +835,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..f5da7d6d7 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicEvents.h @@ -1,10 +1,15 @@ #pragma once #include "pluginM2TWEOP.h" - +#include +#include +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 = { +}; extern "C" PLUGINM2TWEOP_API void onClickAtTile(int x, int y); @@ -15,33 +20,256 @@ 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); +void checkLuaFunc(sol::function** lRef); +namespace gameEvents +{ + regionStruct* getCharacterRegion(const namedCharacter* character); + enum class EventType + { + standardEvent = 1 + }; -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); + int callEvent(DWORD** vTab) override + { + if (EvType == EventType::standardEvent) + { + auto eventData = reinterpret_cast(vTab); + if (&(*funk) != nullptr) { + (*funk)(eventData); + } + return 1; + } + else + { + return 0; + } + } + }; -//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); + 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; +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* 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; +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/basicFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h index 7eba270b0..095b2d0a9 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/basicFuncs.h @@ -38,14 +38,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) { @@ -85,7 +85,7 @@ class ProcLoader ProcLoader& operator = (ProcLoader&) { return *this; - }; + } }; class battleFuncs @@ -144,15 +144,17 @@ class basicFuncs ProcLoader changeFactionName; ProcLoader getFactionName; ProcLoader changeRegionName; + ProcLoader condition; ProcLoader changeRebelsName; ProcLoader deleteFort; ProcLoader createFortXY; + ProcLoader allocateGameMem; ProcLoader createFort; ProcLoader getGameDataAll; ProcLoader setEDUUnitsSize; - ProcLoader setHeir; + ProcLoader setHeir; ProcLoader setAncLimit; @@ -177,12 +179,12 @@ class basicFuncs ProcLoader attackCharacter; - ProcLoader addAnchillary; - ProcLoader removeAnchillary; - ProcLoader findAnchillary; + ProcLoader addAncillary; + ProcLoader removeAncillary; + ProcLoader findAncillary; - ProcLoader addTrait; - ProcLoader removeTrait; + ProcLoader addTrait; + ProcLoader removeTrait; @@ -224,7 +226,7 @@ class basicFuncs ProcLoader setCharacterType; - ProcLoader getGameVersion; + ProcLoader getGameVersion; ProcLoader saveGame; ProcLoader mergeArmies; @@ -253,7 +255,7 @@ class basicFuncs ProcLoaderremoveBuildingCapability; ProcLoadergetBuildingCapability; ProcLoadergetBuildingCapabilityNum; - ProcLoaderaddBuildingPool; + ProcLoaderaddBuildingPool; ProcLoaderremoveBuildingPool; ProcLoadergetBuildingPool; ProcLoadergetBuildingPoolNum; @@ -267,11 +269,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/battleHandlerHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/battleHandlerHelpers.cpp index e2a4f6dd5..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 { @@ -21,11 +23,32 @@ 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]; + } + + 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/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/eopEduHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/eopEduHelpers.cpp index 80d101762..a575cded8 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) { @@ -91,9 +91,23 @@ 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); + eduEntry* eduEn = eopEduHelpers::getEduEntry(idx); return (eduEn->ArmorUpgradesEnd - eduEn->ArmorUpgradeLevels); } @@ -103,7 +117,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 +134,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 +147,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 +159,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 +170,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 +191,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 +218,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 +251,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 +279,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 +298,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 +321,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 +349,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..246322735 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); @@ -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); @@ -72,8 +73,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..f1f05738c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/factionHelpers.cpp @@ -2,12 +2,14 @@ #include "plugData.h" #include +#include "gameDataAllHelper.h" + 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]; } @@ -37,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]; @@ -47,6 +54,53 @@ 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(); + 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; +} + +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(); + 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); @@ -62,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 b2258d434..66c4b1947 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); @@ -19,9 +19,18 @@ 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); - + 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 6619f25af..bbfb23850 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,51 +79,315 @@ 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) + neighbourRegion* gameHelpers::getNeighbour(regionStruct* region, const int index) { - neighbourRegion* nregion = ®ion->neighbourRegions[index]; - return nregion->region; + 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; @@ -142,7 +406,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 +467,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 = reinterpret_cast(technicalHelpers::allocateGameMem(sizeof(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; @@ -225,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; @@ -238,8 +502,8 @@ namespace gameHelpers } if ((maxunitsP - currunits) == 0) { - mercPoolUnitsPtr* 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; @@ -247,7 +511,7 @@ namespace gameHelpers unitptr = unitptr->nextUnitsPtr; currunits = 0; } - mercPoolUnit* 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]; } @@ -257,7 +521,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 +542,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 +599,392 @@ 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]; + } + + 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; + 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); + 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; + } + + 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) + { + 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) + { + 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); + } + + /* + 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 c1fc235b9..5ec86eac9 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); @@ -25,14 +62,62 @@ 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); 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); + 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); + 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); + 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); + 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); @@ -41,5 +126,8 @@ 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); + unit* getSelectedUnitCard(const uiCardManager* cardManager, const int index); + unit* getUnitCard(const uiCardManager* cardManager, const int index); }; diff --git a/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/generalCharactericticsHelpers.cpp index 8444bbcb0..cf3b28dcf 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) + ancillary* getAncillary(namedCharacter* character, int index) { - return character->anchillaries[index]->dataAnch; + return character->ancillaries[index]->dataAnc; } - int addAnchillary(generalCharacterictics* 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(generalCharacterictics* character, anchillary* anch) + void removeAncillary(namedCharacter* character, ancillary* anc) { - (*(*plugData::data.funcs.removeAnchillary))(character, anch); + (*(*plugData::data.funcs.removeAncillary))(character, anc); } - 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..e6901271f 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); + ancillary* getAncillary(namedCharacter* character, int index); + int addAncillary(namedCharacter* character, std::string ancName); - void removeAnchillary(generalCharacterictics* character, anchillary* anch); + void removeAncillary(namedCharacter* character, ancillary* anc); - 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/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/luaEopEdu.cpp b/M2TWEOP-luaPlugin/luaPlugin/luaEopEdu.cpp index f46d7b221..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 @@ -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 f3c85c8f3..e10abccae 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaEvents.cpp @@ -15,1710 +15,3197 @@ 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 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 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 onSettlementSelected onSettlementSelected + @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 onCityRiots onCityRiots - @tfield onUngarrisonedSettlement onUngarrisonedSettlement - @tfield onUngarrisonedFort onUngarrisonedFort - @tfield onGiveSettlement onGiveSettlement + @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 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 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 onObjSeen onObjSeen - @tfield onTileSeen onTileSeen - @tfield onGameReloaded onGameReloaded - @tfield onTransgression onTransgression - @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget + @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 onCrusadeEnds onCrusadeEnds + @tfield onPopeAcceptsCrusadeTarget onPopeAcceptsCrusadeTarget @tfield onPopeRejectsCrusadeTarget onPopeRejectsCrusadeTarget - @tfield onArmyTakesCrusadeTarget onArmyTakesCrusadeTarget - @tfield onUnitsDesertCrusade onUnitsDesertCrusade - @tfield onPopeElected onPopeElected + @tfield onCrusadeEnds onCrusadeEnds + @tfield onPreFactionTurnStart onPreFactionTurnStart + @tfield onFactionTurnStart onFactionTurnStart + @tfield onFactionNewCapital onFactionNewCapital + @tfield onFactionTurnEnd onFactionTurnEnd @tfield onVotedForPope onVotedForPope - @tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope + @tfield onFactionExcommunicated onFactionExcommunicated + @tfield onHordeFormed onHordeFormed + @tfield onCardinalRemoved onCardinalRemoved @tfield onInquisitorAppointed onInquisitorAppointed - @tfield onSettlementPanelOpen onSettlementPanelOpen + @tfield onAssassinCaughtAttackingPope onAssassinCaughtAttackingPope @tfield onFinancesPanelOpen onFinancesPanelOpen @tfield onFactionSummaryPanelOpen onFactionSummaryPanelOpen - @tfield onFamilyTreePanelOpenFunc onFamilyTreePanelOpenFunc - @tfield onDiplomaticStandingPanelOpen onDiplomaticStandingPanelOpen + @tfield onFamilyTreePanelOpen onFamilyTreePanelOpen @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 onMessageOpen onMessageOpen @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 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 onGameInit onGameInit + @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 + + + + + @table EventsFunctionsList + */ + + + /*** + Called at a character's turn start. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterTurnStart + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onCapturedCharacterRansomed(eventData) + --something here + end + */ + + /*** + A captured character has been released by the enemy. + Exports: character, faction, regionID, characterType, religion + + @function onCapturedCharacterReleased + @tparam eventTrigger eventData + + @usage + function onCapturedCharacterReleased(eventData) + --something here + end + */ + + /*** + A character father died of natural causes. + Exports: character, faction, regionID, characterType, religion + + @function onFatherDiesNatural + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onPreBattleWithdrawal(eventData) + --something here + end + */ + + /*** + When a battle has finished. + Exports: character, faction, regionID, characterType, religion + + @function onPostBattle + @tparam eventTrigger eventData + + @usage + function onPostBattle(eventData) + --something here + end + */ + + /*** + A General has hired some mercenaries. + Exports: character, faction, regionID, characterType, religion + + @function onHireMercenaries + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onGeneralCaptureResidence(eventData) + --something + end + */ + + /*** + A faction has been destroyed. + Exports: character, faction, regionID, characterType, religion + + @function onLeaderDestroyedFaction + @tparam eventTrigger eventData + + @usage + function onLeaderDestroyedFaction(eventData) + --something + end + */ + + /*** + An adoption has been proposed. + Exports: character, faction, regionID, characterType, religion + + @function onOfferedForAdoption + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onLesserGeneralOfferedForAdoption(eventData) + --something + end + */ + + /*** + A marriage offer has been proposed. + Exports: character, faction, regionID, characterType, religion + + @function onOfferedForMarriage + @tparam eventTrigger eventData + + @usage + function onOfferedForMarriage(eventData) + --something + end + */ + + /*** + A brother has been adopted. + Exports: character, faction, regionID, characterType, religion + + @function onBrotherAdopted + @tparam eventTrigger eventData + + @usage + function onBrotherAdopted(eventData) + --something + end + */ + + /*** + A child is born to the faction leader. + Exports: character, faction, regionID, characterType, religion + + @function onBirth + @tparam eventTrigger eventData + + @usage + function onBirth(eventData) + --something + end + */ + + /*** + A character has come of age. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterComesOfAge + @tparam eventTrigger eventData + + @usage + function onCharacterComesOfAge(eventData) + --something + end + */ + + /*** + A character has married. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterMarries + @tparam eventTrigger eventData + + @usage + function onCharacterMarries(eventData) + --something + end + */ + + /*** + A character has married a princess. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterMarriesPrincess + @tparam eventTrigger eventData + + @usage + function onCharacterMarriesPrincess(eventData) + --something + end + */ + + /*** + A marriage alliance is possible. + Exports: character, faction, regionID, characterType, religion + + @function onMarriageAlliancePossible + @tparam eventTrigger eventData + + @usage + function onMarriageAlliancePossible(eventData) + --something + end + */ + + /*** + A marriage alliance has been offered. + Exports: character, faction, regionID, characterType, religion + + @function onMarriageAllianceOffered + @tparam eventTrigger eventData + + @usage + function onMarriageAllianceOffered(eventData) + --something + end + */ + + /*** + A priest has gone mad. + Exports: character, faction, regionID, characterType, religion + + @function onPriestBecomesHeretic + @tparam eventTrigger eventData + + @usage + function onPriestBecomesHeretic(eventData) + --something + end + */ + + /*** + A character is adjacent to a heretic. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterNearHeretic + @tparam eventTrigger eventData + + @usage + function onCharacterNearHeretic(eventData) + --something + end + */ + + /*** + A character is adjacent to a witch. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterNearWitch + @tparam eventTrigger eventData + + @usage + function onCharacterNearWitch(eventData) + --something + end + */ + + /*** + A character has been promoted to a cardinal. + Exports: character, faction, regionID, characterType, religion + + @function onCardinalPromoted + @tparam eventTrigger eventData + + @usage + function onCardinalPromoted(eventData) + --something + end + */ + + /*** + A character has become a father. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterBecomesAFather + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onExecutesAnAssassinOnAMission(eventData) + --something + end + */ + + /*** + Someone has had an attempt on their life. + Exports: character, faction, regionID, characterType, religion + + @function onSufferAssassinationAttempt + @tparam eventTrigger eventData + + @usage + function onSufferAssassinationAttempt(eventData) + --something + end + */ + + /*** + Someone has had an attempt on their assets. + Exports: character, faction, regionID, characterType, religion + + @function onSufferAcquisitionAttempt + @tparam eventTrigger eventData + + @usage + function onSufferAcquisitionAttempt(eventData) + --something + end + */ + + /*** + Someone has had an attempt on their bachelorhood. + Exports: character, faction, regionID, characterType, religion + + @function onSufferMarriageAttempt + @tparam eventTrigger eventData + + @usage + function onSufferMarriageAttempt(eventData) + --something + end + */ + + /*** + Someone has had a denouncement attempt. + Exports: character, faction, regionID, characterType, religion + + @function onSufferDenouncementAttempt + @tparam eventTrigger eventData + + @usage + function onSufferDenouncementAttempt(eventData) + --something + end + */ + + /*** + A Faction leader has ordered a sabotage mission. + Exports: character, faction, regionID, characterType, religion + + @function onLeaderOrderedSabotage + @tparam eventTrigger eventData + + @usage + function onLeaderOrderedSabotage(eventData) + --something + end + */ + + /*** + Someone has been bribed. + Exports: character, faction, regionID, characterType, religion + + @function onAcceptBribe + @tparam eventTrigger eventData + + @usage + function onAcceptBribe(eventData) + --something + end + */ + + /*** + Someone has refused a bribe. + Exports: character, faction, regionID, characterType, religion + + @function onRefuseBribe + @tparam eventTrigger eventData + + @usage + function onRefuseBribe(eventData) + --something + end + */ + + /*** + Insurgence has been provoked. + Exports: character, faction, regionID, characterType, religion + + @function onInsurrection + @tparam eventTrigger eventData + + @usage + function onInsurrection(eventData) + --something + end + */ + + /*** + A Faction leader has ordered a diplomacy mission. + Exports: character, faction, regionID, characterType, religion + + @function onLeaderOrderedDiplomacy + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onNewAdmiralCreated(eventData) + --something + end + */ + + /*** + A building has been destroyed. + Exports: character, faction, regionID, characterType, religion + + @function onGovernorBuildingDestroyed + @tparam eventTrigger eventData + + @usage + function onGovernorBuildingDestroyed(eventData) + --something + end + */ + + /*** + Games have been thrown. + Exports: character, faction, regionID, characterType, religion + + @function onGovernorThrowGames + @tparam eventTrigger eventData + + @usage + function onGovernorThrowGames(eventData) + --something + end + */ + + /*** + Races have been thrown. + Exports: character, faction, regionID, characterType, religion + + @function onGovernorThrowRaces + @tparam eventTrigger eventData + + @usage + function onGovernorThrowRaces(eventData) + --something + end + */ + + /*** + The player has selected a character. + Exports: character, targetSettlement, faction, regionID, characterType, religion + + @function onCharacterSelected + @tparam eventTrigger eventData + + @usage + function onCharacterSelected(eventData) + --something + end + */ + + /*** + The player has selected an enemy character. + Exports: character, faction, regionID, characterType, religion + + @function onEnemyCharacterSelected + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onMultiTurnMove(eventData) + --something + end + */ + + /*** + The player has opened the panel for the selected character. + Exports: character, faction, regionID, characterType, religion + + @function onCharacterPanelOpen + @tparam eventTrigger eventData + + @usage + function onCharacterPanelOpen(eventData) + --something + end + */ + + /*** + A mission has been completed. + Exports: character, faction, regionID, characterType, missionDetails, religion + + @function onLeaderMissionSuccess + @tparam eventTrigger eventData + + @usage + function onLeaderMissionSuccess(eventData) + --something + end + */ + + /*** + A mission has failed. + Exports: character, faction, regionID, characterType, missionDetails, religion + + @function onLeaderMissionFailed + @tparam eventTrigger eventData + + @usage + function onLeaderMissionFailed(eventData) + --something + end + */ + + /*** + A General has been sent on Crusade/Jihad. + Exports: character, targetSettlement, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion, crusade + + @function onGeneralJoinCrusade + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onGeneralTakesCrusadeTarget(eventData) + --something + end + */ + + /*** + A Character has finished its turn. + Exports: character, settlement, faction, regionID, characterType, religion + + @function onCharacterTurnEnd + @tparam eventTrigger eventData + + @usage + function onCharacterTurnEnd(eventData) + --something + end + */ + + /*** + A Character has finished its turn in a settlement. + Exports: character, settlement, faction, regionID, characterType, religion + + @function onCharacterTurnEndInSettlement + @tparam eventTrigger eventData + + @usage + function onCharacterTurnEndInSettlement(eventData) + --something + end + */ + + /*** + The character has been made the faction leader. + Exports: character, faction, regionID, characterType, religion + + @function onBecomesFactionLeader + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onCeasedFactionLeader(eventData) + --something + end + */ + + /*** + The character has been made a faction heir. + Exports: character, faction, regionID, characterType, religion + + @function onBecomesFactionHeir + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onCharacterDamagedByDisaster(eventData) + --something + end + */ + + /*** + A General has captured a settlement. + Exports: character, settlement, targetSettlement, faction, targetFaction, regionID, characterType, religion + + @function onGeneralCaptureSettlement + @tparam eventTrigger eventData + + @usage + function onGeneralCaptureSettlement(eventData) + --something + end + */ + + /*** + An assault has taken place. + Exports: character, faction, targetFaction, regionID, targetRegionID, characterType, religion, targetReligion + + @function onGeneralAssaultsResidence + @tparam eventTrigger eventData + + @usage + function onGeneralAssaultsResidence(eventData) + --something + end + */ + + /*** + An assault has taken place. + Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion + + @function onGeneralAssaultsGeneral + @tparam eventTrigger eventData + + @usage + 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). + Exports: character, targetCharacter, faction, targetFaction, regionID, characterType, targetCharacterType, religion, targetReligion + + @function onCharacterAttacksCrusadingGeneral + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onSpyMission(eventData) + --something + end + */ + + /*** + An assassination mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion + + @function onAssassinationMission + @tparam eventTrigger eventData + + @usage + function onAssassinationMission(eventData) + --something + end + */ + + /*** + An acquisition mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion + + @function onAcquisitionMission + @tparam eventTrigger eventData + + @usage + function onAcquisitionMission(eventData) + --something + end + */ + + /*** + A marriage mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion + + @function onMarriageMission + @tparam eventTrigger eventData + + @usage + function onMarriageMission(eventData) + --something + end + */ + + /*** + A denouncement mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion + + @function onDenouncementMission + @tparam eventTrigger eventData + + @usage + function onDenouncementMission(eventData) + --something + end + */ + + /*** + A sabotage mission has completed. + Exports: character, faction, regionID, characterType, missionSuccessLevel, missionProbability, religion + + @function onSabotageMission + @tparam eventTrigger eventData + + @usage + function onSabotageMission(eventData) + --something + end + */ + + /*** + A bribery mission has completed. + Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion + + @function onBriberyMission + @tparam eventTrigger eventData + + @usage + function onBriberyMission(eventData) + --something + end + */ + + /*** + A diplomacy mission has completed. + Exports: character, faction, targetFaction, regionID, characterType, missionSuccessLevel, religion, targetReligion + + @function onDiplomacyMission + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onLeaderOrderedSpyingMission(eventData) + --something + end + */ + + /*** + A Faction leader has ordered an assassination mission. + Exports: character, targetCharacter, faction, regionID, characterType, missionSuccessLevel, religion + + @function onLeaderOrderedAssassination + @tparam eventTrigger eventData + + @usage + function onLeaderOrderedAssassination(eventData) + --something + end + */ + + /*** + A Faction leader has ordered a bribery mission. + Exports: character, faction, regionID, characterType, religion + + @function onLeaderOrderedBribery + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onSettlementTurnStart(eventData) + --something + end + */ + + /*** + A settlement is no longer garrisoned. + Exports: settlement, faction, regionID, religion + + @function onUngarrisonedSettlement + @tparam eventTrigger eventData + + @usage + function onUngarrisonedSettlement(eventData) + --something + end + */ + + /*** + A settlement has been upgraded. + Exports: settlement, faction, regionID, religion + + @function onSettlementUpgraded + @tparam eventTrigger eventData + + @usage + function onSettlementUpgraded(eventData) + --something + end + */ + + /*** + A settlement has been converted. + Exports: settlement, faction, regionID, religion + + @function onSettlementConverted + @tparam eventTrigger eventData + + @usage + function onSettlementConverted(eventData) + --something + end + */ + + /*** + Siege equipment has been completed by one of the besieging armies. + Exports: settlement, faction, regionID, religion + + @function onSiegeEquipmentCompleted + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onSettlementTurnEnd(eventData) + --something + end + */ + + /*** + The player has selected a settlement. + Exports: settlement, faction, regionID, religion + + @function onSettlementSelected + @tparam eventTrigger eventData + + @usage + function onSettlementSelected(eventData) + --something + end + */ + + /*** + The player has opened the panel for the selected settlement. + Exports: settlement, faction, regionID, religion + + @function onSettlementPanelOpen + @tparam eventTrigger eventData + + @usage + function onSettlementPanelOpen(eventData) + --something + end + */ + + /*** + The player has opened a recruitment panel. + Exports: settlement, faction, regionID, religion + + @function onRecruitmentPanelOpen + @tparam eventTrigger eventData + + @usage + function onRecruitmentPanelOpen(eventData) + --something + end + */ + + /*** + The player has opened a construction panel. + Exports: settlement, faction, regionID, religion + + @function onConstructionPanelOpen + @tparam eventTrigger eventData + + @usage + function onConstructionPanelOpen(eventData) + --something + end + */ + + /*** + The player has opened a trade panel. + Exports: settlement, faction, regionID, religion + + @function onTradePanelOpen + @tparam eventTrigger eventData + + @usage + function onTradePanelOpen(eventData) + --something + end + */ + + /*** + The player has requested advice on the settlement scroll. + Exports: settlement, faction, regionID, resourceDescription, religion + + @function onSettlementScrollAdviceRequested + @tparam eventTrigger eventData + + @usage + function onSettlementScrollAdviceRequested(eventData) + --something + end + */ + + /*** + A guild has been created/upgraded. + Exports: settlement, faction, regionID, resourceDescription, guild, religion + + @function onGuildUpgraded + @tparam eventTrigger eventData + + @usage + function onGuildUpgraded(eventData) + --something + end + */ + + /*** + A guild has been destroyed. + Exports: settlement, faction, regionID, guild, religion + @function onGuildDestroyed + @tparam eventTrigger eventData + @usage + function onGuildDestroyed(eventData) + --something + end + */ + /*** + A settlement has been captured and occupied. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion - @table EventsFunctionsList + @function onOccupySettlement + @tparam eventTrigger eventData + + @usage + function onOccupySettlement(eventData) + --something + end */ + /*** + A settlement has been captured and sacked. + Exports: character, faction, targetFaction, regionID, characterType, religion, targetReligion + + @function onSackSettlement + @tparam eventTrigger eventData + + @usage + 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 eventTrigger eventData + + @usage + function onExterminatePopulation(eventData) + --something + end + */ /*** - Called every time an image is rendered for display + A settlement has rioted. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion - @function draw - @tparam LPDIRECT3DDEVICE9 pDevice + @function onCityRiots + @tparam eventTrigger eventData @usage - function draw(device) - ImGui.Begin("test"); + function onCityRiots(eventData) + --something + end + */ - ImGui.Text("Some test text") + /*** + A settlement has been given to another faction. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion - ImGui.End(); + @function onGiveSettlement + @tparam eventTrigger eventData + + @usage + function onGiveSettlement(eventData) + --something end */ - drawLuaFunc = new sol::function(luaState["draw"]); - checkLuaFunc(&drawLuaFunc); /*** - Called when ImGui backend reload fonts + A settlement has rebelled. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion - @function onLoadingFonts + @function onCityRebels + @tparam eventTrigger eventData @usage - function onLoadingFonts() + function onCityRebels(eventData) + --something + end + */ + + /*** + A settlement has been razed. + Exports: settlement, faction, targetFaction, regionID, religion, targetReligion + + @function onCitySacked + @tparam eventTrigger eventData + + @usage + function onCitySacked(eventData) + --something + end + */ + + /*** + A settlement has rioted. + Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion + + @function onGovernorCityRiots + @tparam eventTrigger eventData + + @usage + function onGovernorCityRiots(eventData) + --something + end + */ + + /*** + A settlement has rebelled. + Exports: character, settlement, faction, targetFaction, regionID, characterType, religion, targetReligion + + @function onGovernorCityRebels + @tparam eventTrigger eventData + + @usage + function onGovernorCityRebels(eventData) + --something + end + */ + + /*** + The player has abandoned a show me scipt. + + @function onAbandonShowMe + @tparam eventTrigger eventData + + @usage + function onAbandonShowMe(eventData) --something here end */ - onLoadingFonts = new sol::function(luaState["onLoadingFonts"]); - checkLuaFunc(&onLoadingFonts); - resetDXFunc = new sol::function(luaState["deinitDX"]); - checkLuaFunc(&resetDXFunc); + /*** + A strat map game has been reloaded. - initDXFunc = new sol::function(luaState["initDX"]); - checkLuaFunc(&initDXFunc); + @function onGameReloaded + @tparam eventTrigger eventData + + @usage + function onGameReloaded(eventData) + --something here + end + */ /*** - Called when a new campaign is started from the menu. + The plaza is being captured. - @function onNewGameStart + @function onBattleWinningPlaza + @tparam eventTrigger eventData @usage - function onNewGameStart() + function onBattleWinningPlaza(eventData) --something here end */ + /*** + The plaza capture has been stopped. + @function onBattleStopsWinningPlaza + @tparam eventTrigger eventData - onNewGameStart = new sol::function(luaState["onNewGameStart"]); - checkLuaFunc(&onNewGameStart); + @usage + function onBattleStopsWinningPlaza(eventData) + --something here + end + */ /*** - Called after the game loads various db`s (edu, etc) at startup. + The enemy will have captured the plaza in 30s. - @function onReadGameDbsAtStart + @function onBattleDominatingPlaza + @tparam eventTrigger eventData @usage - function onReadGameDbsAtStart() + function onBattleDominatingPlaza(eventData) --something here end */ + /*** + A siege engine is now unmanned. + @function onBattngineUnmanned + @tparam eventTrigger eventData - onReadGameDbsAtStart = new sol::function(luaState["onReadGameDbsAtStart"]); - checkLuaFunc(&onReadGameDbsAtStart); + @usage + function onBattngineUnmanned(eventData) + --something here + end + */ /*** - Called on clicking the stratmap. + Half of the player's army has been destroyed. + + @function onBattlePlayerArmyHalfDestroyed + @tparam eventTrigger eventData - @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)); + function onBattlePlayerArmyHalfDestroyed(eventData) + --something here + end + */ - clickAtMap.isClicked=false; - end + /*** + Half of the enemy's army has been destroyed. + + @function onBattnemyArmyHalfDestroyed + @tparam eventTrigger eventData + + @usage + function onBattnemyArmyHalfDestroyed(eventData) + --something here end + */ - function onClickAtTile(x,y) - clickAtMap.isClicked=true; - clickAtMap.xTile=x; - clickAtMap.yTile=y; + /*** + The battle has finished. + + @function onBattleFinished + @tparam eventTrigger eventData + + @usage + function onBattleFinished(eventData) + --something here end */ + /*** + Half of an army has been destroyed. + @function onBattleArmyHalfDestroyed + @tparam eventTrigger eventData - onClickAtTile = new sol::function(luaState["onClickAtTile"]); - checkLuaFunc(&onClickAtTile); + @usage + function onBattleArmyHalfDestroyed(eventData) + --something here + end + */ /*** - Called after loading the campaign map + The escape key has been pressed. This trigger will only fire if the command StealEscKey has been used. - @function onCampaignMapLoaded + @function onEscPressed + @tparam eventTrigger eventData @usage - function onCampaignMapLoaded() + function onEscPressed(eventData) --something here end */ + /*** + The player has been issued with advice by a script. + @function onScriptedAdvice + @tparam eventTrigger eventData - onCampaignMapLoaded = new sol::function(luaState["onCampaignMapLoaded"]); - checkLuaFunc(&onCampaignMapLoaded); + @usage + function onScriptedAdvice(eventData) + --something here + end + */ /*** - Called on plugin load (at game start). + The player has requested advice on the naval prebattle scroll. - @function onPluginLoad + @function onNavalPreBattleScrollAdviceRequested + @tparam eventTrigger eventData @usage - --An example of using this event to perform actions at the beginning of a campaign once: + function onNavalPreBattleScrollAdviceRequested(eventData) + --something here + end + */ - isCampaignLoadedFirstTime=false; - function onNewGameStart() - isCampaignLoadedFirstTime=true; + /*** + The player has requested advice on the prebattle scroll. + + @function onPreBattleScrollAdviceRequested + @tparam eventTrigger eventData + + @usage + function onPreBattleScrollAdviceRequested(eventData) + --something here end + */ - function onCampaignMapLoaded() - if(isCampaignLoadedFirstTime==false) - then - do return end - end + /*** + The player has opened the college of cardinals panel. + @function onCollegeOfCardinalsPanelOpen + @tparam eventTrigger eventData - --here we do our stuff, what works only one time for each campaign - isCampaignLoadedFirstTime=false; + @usage + function onCollegeOfCardinalsPanelOpen(eventData) + --something here end */ + /*** + The player has opened the diplomatic standing panel. + @function onDiplomaticStandingPanelOpen + @tparam eventTrigger eventData - onPluginLoad = new sol::function(luaState["onPluginLoad"]); - checkLuaFunc(&onPluginLoad); + @usage + function onDiplomaticStandingPanelOpen(eventData) + --something here + end + */ + /*** + An idle unit is under missile fire. + + @function onBattlePlayerUnderAttackIdle + @tparam eventTrigger eventData + + @usage + function onBattlePlayerUnderAttackIdle(eventData) + --something here + end + */ /*** - Called on creating a new save file. + A team has gained the advantage in combat. - @function onCreateSaveFile + @function onBattleWinningCombat + @tparam eventTrigger eventData @usage - function onCreateSaveFile() - local savefiles, currentPath = {}, M2TWEOP.getPluginPath() - savefiles[1] = currentPath.."\\testSaveFile1.ourSave" - savefiles[2] = currentPath.."\\testSaveFile2.ourSave" + function onBattleWinningCombat(eventData) + --something here + end + */ - 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() + /*** + The whole army is tired. - return savefiles - end + @function onBattleArmyTired + @tparam eventTrigger eventData + + @usage + function onBattleArmyTired(eventData) + --something here + end */ - onCreateSaveFile = new sol::function(luaState["onCreateSaveFile"]); - checkLuaFunc(&onCreateSaveFile); /*** - Called on loading a save file. + A different team is now the strongest. - @function onLoadSaveFile + @function onBattleTideofBattle + @tparam eventTrigger eventData @usage - function onLoadSaveFile(paths) - lastSaveFiles={}; - for key, value in pairs(paths) do + function onBattleTideofBattle(eventData) + --something here + end + */ - print(key, " -- ", value); + /*** + A unit has gone berserk. + Exports: unit - lastSaveFiles[key]={}; - lastSaveFiles[key][1]=value; - lastSaveFiles[key][2]=readFile(value); + @function onBattleUnitGoesBerserk + @tparam eventTrigger eventData - end + @usage + function onBattleUnitGoesBerserk(eventData) + --something here + end + */ + + /*** + A siege engine has been destroyed. + Exports: unit + + @function onBattleSiegeEngineDestroyed + @tparam eventTrigger eventData + + @usage + function onBattleSiegeEngineDestroyed(eventData) + --something here end + */ + /*** + A siege engine has docked with a wall. + Exports: unit - --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 onBattleSiegeEngineDocksWall + @tparam eventTrigger eventData + + @usage + function onBattleSiegeEngineDocksWall(eventData) + --something here end */ - onLoadSaveFile = new sol::function(luaState["onLoadSaveFile"]); - checkLuaFunc(&onLoadSaveFile); - /*** - Called at the start of a new turn. + An engine has started attacking a gate. + Exports: unit - @function onChangeTurnNum - @tparam int turnNumber + @function onBattleGatesAttackedByEngine + @tparam eventTrigger eventData @usage - function onChangeTurnNum(turnNum) + function onBattleGatesAttackedByEngine(eventData) --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! + An engine has destroyed a gate. + Exports: unit - @function onSelectWorldpkgdesc - @tparam string selectedRecordName - @tparam string selectedRecordGroup - @treturn string newSelectedRecordName + @function onBattleGatesDestroyedByEngine + @tparam eventTrigger eventData @usage - function onSelectWorldpkgdesc(selectedRecord,selectedRecordGroup) + function onBattleGatesDestroyedByEngine(eventData) --something here - - return selectedRecord; end */ - onSelectWorldpkgdesc = new sol::function(luaState["onSelectWorldpkgdesc"]); - checkLuaFunc(&onSelectWorldpkgdesc); + /*** - Called on specified fortificationlevel in a siege of a settlement. + A siege engine has knocked down a wall. + Exports: unit - @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 onBattleWallsBreachedByEngine + @tparam eventTrigger eventData @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 onBattleWallsBreachedByEngine(eventData) + --something here end */ - onfortificationlevelS = new sol::function(luaState["onfortificationlevelS"]); - checkLuaFunc(&onfortificationlevelS); /*** - Called on the completion of the siege (in any way, with any outcome). + A wall has been captured. + Exports: unit - @function onEndSiege - @tparam int xCoord x coordinate of siege(settlement or fort) - @tparam int yCoord y coordinate of siege(settlement or fort) + @function onBattleWallsCaptured + @tparam eventTrigger eventData @usage - function onEndSiege(x,y) + function onBattleWallsCaptured(eventData) --something here end */ - onEndSiege = new sol::function(luaState["onEndSiege"]); - checkLuaFunc(&onEndSiege); + /*** - Called on the starting of the siege (in any way, with any outcome). + A unit has routed. + Exports: unit - @function onStartSiege - @tparam int xCoord x coordinate of siege(settlement or fort) - @tparam int yCoord y coordinate of siege(settlement or fort) + @function onBattleUnitRouts + @tparam eventTrigger eventData @usage - function onStartSiege(x,y) + function onBattleUnitRouts(eventData) --something here end */ - onStartSiege = new sol::function(luaState["onStartSiege"]); - checkLuaFunc(&onStartSiege); + /*** - A character has been selected by any means (including through the UI). + A unit has been disbanded. + Exports: faction, playerUnit, eduEntry, religion - @function onCharacterSelected - @tparam namedCharacter selectedChar + @function onUnitDisbanded + @tparam eventTrigger eventData @usage - function onCharacterSelected(selectedChar) + function onUnitDisbanded(eventData) --something here end */ - onCharacterSelectedFunc = new sol::function(luaState["onCharacterSelected"]); - checkLuaFunc(&onCharacterSelectedFunc); /*** - Called before the faction's turn starts. + A unit has been trained. + Exports: settlement, faction, playerUnit, eduEntry, religion - @function onPreFactionTurnStart - @tparam factionStruct faction + @function onUnitTrained + @tparam eventTrigger eventData @usage - function onPreFactionTurnStart(fac) + function onUnitTrained(eventData) --something here end */ - onPreFactionTurnStartFunc = new sol::function(luaState["onPreFactionTurnStart"]); - checkLuaFunc(&onPreFactionTurnStartFunc); /*** - Called at a faction's turn start. + A unit has been trained. + Exports: character, settlement, faction, regionID, playerUnit, eduEntry, characterType, religion - @function onFactionTurnStart - @tparam factionStruct faction + @function onGovernorUnitTrained + @tparam eventTrigger eventData @usage - function onFactionTurnStart(fac) + function onGovernorUnitTrained(eventData) --something here end */ - onFactionTurnStartFunc = new sol::function(luaState["onFactionTurnStart"]); - checkLuaFunc(&onFactionTurnStartFunc); /*** - Called when a general devastates a tile. + A building has been completed. + Exports: character, settlement, faction, regionID, priorBuild, characterType, religion - @function onGeneralDevastatesTile - @tparam namedCharacter gen + @function onGovernorBuildingCompleted + @tparam eventTrigger eventData @usage - function onGeneralDevastatesTile(gen) + function onGovernorBuildingCompleted(eventData) --something here end */ - onGeneralDevastatesTileFunc = new sol::function(luaState["onGeneralDevastatesTile"]); - checkLuaFunc(&onGeneralDevastatesTileFunc); /*** - Called at a faction's turn end. + An agent has been trained. + Exports: character, settlement, faction, regionID, characterType, religion - @function onFactionTurnEnd - @tparam factionStruct faction + @function onAgentCreated + @tparam eventTrigger eventData @usage - function onFactionTurnEnd(fac) + function onAgentCreated(eventData) --something here end */ - onFactionTurnEndFunc = new sol::function(luaState["onFactionTurnEnd"]); - checkLuaFunc(&onFactionTurnEndFunc); /*** - Called after faction changes to a new capital. + An agent has been trained. + Exports: character, settlement, faction, regionID, characterType, religion - @function onFactionNewCapital - @tparam factionStruct faction + @function onGovernorAgentCreated + @tparam eventTrigger eventData @usage - function onFactionNewCapital(fac) - newCapital=fac.capital(); + function onGovernorAgentCreated(eventData) + --something here end */ - onFactionNewCapitalFunc = new sol::function(luaState["onFactionNewCapital"]); - checkLuaFunc(&onFactionNewCapitalFunc); /*** - Called after a faction declares a war. + A building has been destroyed. + Exports: settlement, faction, regionID, resourceDescription, religion - @function onFactionWarDeclared - @tparam factionStruct faction - @tparam factionStruct targetFaction + @function onBuildingDestroyed + @tparam eventTrigger eventData @usage - function onFactionWarDeclared(faction,targetFaction) - --something + function onBuildingDestroyed(eventData) + --something here end */ - onFactionWarDeclaredFunc = new sol::function(luaState["onFactionWarDeclared"]); - checkLuaFunc(&onFactionWarDeclaredFunc); /*** - Called after a faction declares an alliance. + A building has been added to the construction queue. + Exports: settlement, faction, regionID, resourceDescription, religion - @function onFactionAllianceDeclared - @tparam factionStruct faction - @tparam factionStruct targetFaction + @function onAddedToBuildingQueue + @tparam eventTrigger eventData @usage - function onFactionAllianceDeclared(faction,targetFaction) - --something + function onAddedToBuildingQueue(eventData) + --something here end */ - onFactionAllianceDeclaredFunc = new sol::function(luaState["onFactionAllianceDeclared"]); - checkLuaFunc(&onFactionAllianceDeclaredFunc); - /*** - Called after a faction makes a trade agreement. + A building has been completed. + Exports: settlement, faction, priorBuild, religion - @function onFactionTradeAgreementMade - @tparam factionStruct faction - @tparam factionStruct targetFaction + @function onBuildingCompleted + @tparam eventTrigger eventData @usage - function onFactionTradeAgreementMade(faction,targetFaction) - --something + function onBuildingCompleted(eventData) + --something here end */ - onFactionTradeAgreementMadeFunc = new sol::function(luaState["onFactionTradeAgreementMade"]); - checkLuaFunc(&onFactionTradeAgreementMadeFunc); - /*** - Called after a faction breaks an alliance. + The player has requested building advice. + Exports: settlement, faction, regionID, religion - @function onFactionBreakAlliance - @tparam factionStruct faction - @tparam factionStruct targetFaction + @function onRequestBuildingAdvice + @tparam eventTrigger eventData @usage - function onFactionBreakAlliance(faction,targetFaction) - --something + function onRequestBuildingAdvice(eventData) + --something here end */ + /*** + The player has requested training advice. + Exports: settlement, faction, regionID, religion - onFactionBreakAllianceFunc = new sol::function(luaState["onFactionBreakAlliance"]); - checkLuaFunc(&onFactionBreakAllianceFunc); + @function onRequestTrainingAdvice + @tparam eventTrigger eventData + @usage + function onRequestTrainingAdvice(eventData) + --something here + end + */ /*** - Called after a faction gives money to another faction. + A unit has been added to the training queue. + Exports: settlement, faction, regionID, resourceDescription, religion - @function onGiveMoney - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam int amount + @function onAddedToTrainingQueue + @tparam eventTrigger eventData @usage - function onGiveMoney(faction,targetFaction,amount) - --something + function onAddedToTrainingQueue(eventData) + --something here end */ + /*** + An army has been entirely routed. + Exports: army - onGiveMoneyFunc = new sol::function(luaState["onGiveMoney"]); - checkLuaFunc(&onGiveMoneyFunc); + @function onBattleArmyRouted + @tparam eventTrigger eventData + @usage + function onBattleArmyRouted(eventData) + --something here + end + */ /*** - Called after a faction updates it's attitude towards another faction. + A reinforcing army has arrived on the battlefield. + Exports: army - @function onUpdateAttitude - @tparam factionStruct faction - @tparam factionStruct targetFaction + @function onBattleReinforcementsArrive + @tparam eventTrigger eventData @usage - function onUpdateAttitude(faction,targetFaction) - --something + function onBattleReinforcementsArrive(eventData) + --something here end */ - onUpdateAttitudeFunc = new sol::function(luaState["onUpdateAttitude"]); - checkLuaFunc(&onUpdateAttitudeFunc); - /*** - A demeanour response has occured in diplomacy talks. + The player has requested mercenaries advice. + Exports: army - @function onDemeanour - @tparam factionStruct faction - @tparam factionStruct targetFaction - @tparam float amount + @function onRequestMercenariesAdvice + @tparam eventTrigger eventData @usage - function onDemeanour(faction,targetFaction,amount) - --something + function onRequestMercenariesAdvice(eventData) + --something here end */ - onDemeanourFunc = new sol::function(luaState["onDemeanour"]); - checkLuaFunc(&onDemeanourFunc); - /*** - A general has attacked another general. + The player has clicked on a button. + Exports: resourceDescription - @function onGeneralAssaultsGeneral - @tparam namedCharacter attacker - @tparam namedCharacter defender + @function onButtonPressed + @tparam eventTrigger eventData @usage - function onGeneralAssaultsGeneral(attacker,defender) - --something + function onButtonPressed(eventData) + --something here end */ - onGeneralAssaultsGeneralFunc = new sol::function(luaState["onGeneralAssaultsGeneral"]); - checkLuaFunc(&onGeneralAssaultsGeneralFunc); - /*** - An assault has taken place. + The player triggered a keyboard shortcut. + Exports: resourceDescription - @function onGeneralAssaultsResidence - @tparam namedCharacter attacker - @tparam settlementStruct settlement nil if it is fort - @tparam fortStruct fort nil if it is settlement + @function onShortcutTriggered + @tparam eventTrigger eventData @usage - function onGeneralAssaultsResidence(attacker,settlement,fort) - if(settlement~=nil) - then - -settlement - else - -fort - end - + function onShortcutTriggered(eventData) + --something here end */ - onGeneralAssaultsResidenceFunc = new sol::function(luaState["onGeneralAssaultsResidence"]); - checkLuaFunc(&onGeneralAssaultsResidenceFunc); - /*** - A General has captured a settlement. + A special UI Element is visible. + Exports: resourceDescription - @function onGeneralCaptureSettlement - @tparam namedCharacter attacker - @tparam settlementStruct settlement + @function onUIElementVisible + @tparam eventTrigger eventData @usage - function onGeneralCaptureSettlement(attacker,settlement) - --something + function onUIElementVisible(eventData) + --something here end */ - onGeneralCaptureSettlementFunc = new sol::function(luaState["onGeneralCaptureSettlement"]); - checkLuaFunc(&onGeneralCaptureSettlementFunc); - /*** - A General has captured a residence such as a fort or watchtower. + The player opened a scroll. + Exports: resourceDescription - @function onGeneralCaptureResidence - @tparam namedCharacter attacker + @function onScrollOpened + @tparam string eventData @usage - function onGeneralCaptureResidence(attacker) - --something + function onScrollOpened(eventData) + --something here end */ - onGeneralCaptureResidenceFunc = new sol::function(luaState["onGeneralCaptureResidence"]); - checkLuaFunc(&onGeneralCaptureResidenceFunc); - /*** - Siege equipment has been completed by one of the sieging armies at this residence. + The player closed a scroll. + Exports: resourceDescription - @function onSiegeEquipmentCompleted - @tparam settlementStruct settlement nil if it is fort - @tparam fortStruct fort nil if it is settlement + @function onScrollClosed + @tparam eventTrigger eventData @usage - --something + function onScrollClosed(eventData) + --something here + end */ - onSiegeEquipmentCompletedFunc = new sol::function(luaState["onSiegeEquipmentCompleted"]); - checkLuaFunc(&onSiegeEquipmentCompletedFunc); - /*** - When a battle has finished. + The player has requested advice on a scroll. + Exports: resourceDescription - @function onPostBattle - @tparam namedCharacter character + @function onScrollAdviceRequested + @tparam eventTrigger eventData @usage - --something + function onScrollAdviceRequested(eventData) + --something here + 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. + The player has suppressed a piece of advice. + Exports: resourceDescription - @function onMultiTurnMove - @tparam namedCharacter character + @function onAdviceSupressed + @tparam eventTrigger eventData @usage - --something + function onAdviceSupressed(eventData) + --something here + end */ - onMultiTurnMoveFunc = new sol::function(luaState["onMultiTurnMove"]); - checkLuaFunc(&onMultiTurnMoveFunc); - /*** - A settlement has been selected by any means (including through the UI). + A general has been routed. + Exports: stratCharacter, character - @function onSettlementSelected - @tparam settlementStruct settlement + @function onBattleGeneralRouted + @tparam eventTrigger eventData @usage - function onSettlementSelected(settlement) - print("Function: onSettlementSelected()\n\tSettlement: "..settlement.name) + function onBattleGeneralRouted(eventData) + --something here end */ - onSettlementSelectedFunc = new sol::function(luaState["onSettlementSelected"]); - checkLuaFunc(&onSettlementSelectedFunc); - /*** - A settlement's level has been increased. + A general has been killed. + Exports: stratCharacter - @function onSettlementUpgraded - @tparam settlementStruct settlement + @function onBattleGeneralKilled + @tparam eventTrigger eventData @usage - function onSettlementUpgraded(settlement) - print("Function: onSettlementUpgraded()\n\tSettlement Level: "..settlement.level) + function onBattleGeneralKilled(eventData) + --something here end */ - onSettlementUpgradedFunc = new sol::function(luaState["onSettlementUpgraded"]); - checkLuaFunc(&onSettlementUpgradedFunc); - /*** - A settlement converted between city and castle and vice-versa. + A Crusade/Jihad has been called. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade - @function onSettlementConverted - @tparam settlementStruct settlement + @function onCrusadeCalled + @tparam eventTrigger eventData @usage - function onSettlementConverted(settlement) - if settlement.isCastle == 1 then - --do stuff - end + function onCrusadeCalled(eventData) + --something here end */ - onSettlementConvertedFunc = new sol::function(luaState["onSettlementConverted"]); - checkLuaFunc(&onSettlementConvertedFunc); - /*** - A settlement has rioted. + The Pope has accepted the player's crusade target. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade - @function onCityRiots - @tparam settlementStruct settlement + @function onPopeAcceptsCrusadeTarget + @tparam eventTrigger eventData @usage - --something + function onPopeAcceptsCrusadeTarget(eventData) + --something here + end */ - onCityRiotsFunc = new sol::function(luaState["onCityRiots"]); - checkLuaFunc(&onCityRiotsFunc); - /*** - The last unit has been removed from a settlement, agents do not count. + The Pope has rejected the player's crusade target. + Exports: targetSettlement, targetFaction, targetRegionID, targetReligion, crusade - @function onUngarrisonedSettlement - @tparam settlementStruct settlement + @function onPopeRejectsCrusadeTarget + @tparam eventTrigger eventData @usage - --something + function onPopeRejectsCrusadeTarget(eventData) + --something here + end */ - onUngarrisonedSettlementFunc = new sol::function(luaState["onUngarrisonedSettlement"]); - checkLuaFunc(&onUngarrisonedSettlementFunc); - /*** - The last unit has been removed from a fort, agents do not count. + A Crusade/Jihad has ended. + Exports: targetSettlement, targetRegionID, crusade - @function onUngarrisonedFort - @tparam fortStruct fort + @function onCrusadeEnds + @tparam eventTrigger eventData @usage - --something + function onCrusadeEnds(eventData) + --something here + 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 + Called before the faction's turn starts. + Exports: faction, religion + @function onPreFactionTurnStart + @tparam eventTrigger eventData @usage - --something + function onPreFactionTurnStart(eventData) + --something here + end */ - onGiveSettlementFunc = new sol::function(luaState["onGiveSettlement"]); - checkLuaFunc(&onGiveSettlementFunc); - /*** - A general has captured a settlement and the occupy option has been chosen + Called at a faction's turn start. + Exports: faction, religion - @function onOccupySettlement - @tparam namedCharacter character only generals, event does not fire for captains - @tparam factionStruct targetFaction + @function onFactionTurnStart + @tparam eventTrigger eventData @usage - --something + function onFactionTurnStart(eventData) + --something here + end */ - 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 + Called after faction changes to a new capital. + Exports: faction, religion + @function onFactionNewCapital + @tparam eventTrigger eventData @usage - --something + function onFactionNewCapital(eventData) + newCapital=fac.capital(); + 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 + Called at a faction's turn end. + Exports: faction, religion + @function onFactionTurnEnd + @tparam eventTrigger eventData @usage - --something + function onFactionTurnEnd(eventData) + --something here + end */ - 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 + A Faction has voted for the new pope. + Exports: faction, religion + @function onVotedForPope + @tparam eventTrigger eventData @usage - --something + function onVotedForPope(eventData) + --something here + end */ - onAddedToBuildingQueueFunc = new sol::function(luaState["onAddedToBuildingQueue"]); - checkLuaFunc(&onAddedToBuildingQueueFunc); - /*** - A building has been destroyed. - - @function onBuildingDestroyed - @tparam settlementStruct settlement - @tparam string buildNme level name + A Faction has been excommunicated. + Exports: faction, religion + @function onFactionExcommunicated + @tparam eventTrigger eventData @usage - --something + function onFactionExcommunicated(eventData) + --something here + end */ - onBuildingDestroyedFunc = new sol::function(luaState["onBuildingDestroyed"]); - checkLuaFunc(&onBuildingDestroyedFunc); - /*** - A building has been completed. + A Faction has formed a horde. + Exports: faction, religion - @function onBuildingCompleted - @tparam factionStruct fac - @tparam settlementStruct settlement + @function onHordeFormed + @tparam eventTrigger eventData @usage - --something + function onHordeFormed(eventData) + --something here + end */ - onBuildingCompletedFunc = new sol::function(luaState["onBuildingCompleted"]); - checkLuaFunc(&onBuildingCompletedFunc); - /*** - An event counter has changed it's value. + A cardinal has been removed from the game. + Exports: faction, religion - @function onEventCounter - @tparam string counter + @function onCardinalRemoved + @tparam eventTrigger eventData @usage - --something + function onCardinalRemoved(eventData) + --something here + end */ - onEventCounterFunc = new sol::function(luaState["onEventCounter"]); - checkLuaFunc(&onEventCounterFunc); - /*** - When a faction is excommunicated by the Pope. + An inquisitor has been dispatched to a region. + Exports: faction, religion - @function onFactionExcommunicated - @tparam factionStruct fac + @function onInquisitorAppointed + @tparam eventTrigger eventData @usage - --something + function onInquisitorAppointed(eventData) + --something here + end */ - onFactionExcommunicatedFunc = new sol::function(luaState["onFactionExcommunicated"]); - checkLuaFunc(&onFactionExcommunicatedFunc); - /*** - When a particular disaster has just happened. + An assassination mission against the pope has failed and the assassin is executed. + Exports: faction, religion - @function onDisaster - @tparam int eventType (earthquake, flood, horde, fire, riot, storm, volcano), Don't know enum order! + @function onAssassinCaughtAttackingPope + @tparam eventTrigger eventData @usage - --something + function onAssassinCaughtAttackingPope(eventData) + --something here + end */ - onDisasterFunc = new sol::function(luaState["onDisaster"]); - checkLuaFunc(&onDisasterFunc); - /*** - A Faction has formed a horde. + The player has opened his finances panel. + Exports: faction, religion - @function onHordeFormed - @tparam factionStruct fac + @function onFinancesPanelOpen + @tparam eventTrigger eventData @usage - --something + function onFinancesPanelOpen(eventData) + --something here + end */ - onHordeFormedFunc = new sol::function(luaState["onHordeFormed"]); - checkLuaFunc(&onHordeFormedFunc); - /*** - A unit has been added to the training queue. + The player has opened the faction summary panel. + Exports: faction, religion - @function onAddedToTrainingQueue - @tparam settlementStruct sett - @tparam string unitName + @function onFactionSummaryPanelOpen + @tparam eventTrigger eventData @usage - --something + function onFactionSummaryPanelOpen(eventData) + --something here + end */ - onAddedToTrainingQueueFunc = new sol::function(luaState["onAddedToTrainingQueue"]); - checkLuaFunc(&onAddedToTrainingQueueFunc); - /*** - A unit has been disbanded. + The player has opened the family tree panel. + Exports: faction, religion - @function onUnitDisbanded - @tparam factionStruct fac - @tparam unit unit + @function onFamilyTreePanelOpen + @tparam eventTrigger eventData @usage - --something + function onFamilyTreePanelOpen(eventData) + --something here + end */ - onUnitDisbandedFunc = new sol::function(luaState["onUnitDisbanded"]); - checkLuaFunc(&onUnitDisbandedFunc); - /*** - A unit has been trained. + The player has opened the diplomatic standing panel. + Exports: faction, religion - @function onUnitTrained - @tparam factionStruct fac - @tparam settlementStruct sett - @tparam unit unit + @function onDiplomacyPanelOpen + @tparam eventTrigger eventData @usage - --something + function onDiplomacyPanelOpen(eventData) + --something here + end */ - onUnitTrainedFunc = new sol::function(luaState["onUnitTrained"]); - checkLuaFunc(&onUnitTrainedFunc); - /*** - An agent has been trained. + The player has attacked an army or settlement. The decision panel is now open. + Exports: faction, religion - @function onAgentCreated - @tparam namedCharacter character - @tparam int agentType see @{character:setTypeID} for list of type integers - @tparam settlementStruct sett + @function onPreBattlePanelOpen + @tparam eventTrigger eventData @usage - --something + function onPreBattlePanelOpen(eventData) + --something here + end */ - onAgentCreatedFunc = new sol::function(luaState["onAgentCreated"]); - checkLuaFunc(&onAgentCreatedFunc); - /*** - An object of the target faction has been seen by the faction. + A message has arrived for the player. + Exports: faction, eventID, 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 + @function onIncomingMessage + @tparam eventTrigger eventData @usage - --something + function onIncomingMessage(eventData) + --something here + end */ - onObjSeenFunc = new sol::function(luaState["onObjSeen"]); - checkLuaFunc(&onObjSeenFunc); - /*** - The tile has been seen by the faction. + The player has opened a message. + Exports: faction, eventID, religion - @function onTileSeen - @tparam factionStruct fac - @tparam int xCoord - @tparam int yCoord + @function onMessageOpen + @tparam eventTrigger eventData @usage - --something + function onMessageOpen(eventData) + --something here + end */ - onTileSeenFunc = new sol::function(luaState["onTileSeen"]); - checkLuaFunc(&onTileSeenFunc); - /*** - The game has been reloaded while on the strategy map. + The player has closed a message. + Exports: eventID - @function onGameReloaded - @tparam int something + @function onMessageClosed + @tparam eventTrigger eventData @usage - --something + function onMessageClosed(eventData) + --something here + end */ - onGameReloadedFunc = new sol::function(luaState["onGameReloaded"]); - checkLuaFunc(&onGameReloadedFunc); - /*** - A faction to faction transgression has occurred. + The player has declined automated settlement management. + Exports: faction, religion - @function onTransgression - @tparam factionStruct fac - @tparam string description - @tparam factionStruct targetFac + @function onDeclineAutomatedSettlementManagement + @tparam eventTrigger eventData @usage - --something + function onDeclineAutomatedSettlementManagement(eventData) + --something here + end */ - onTransgressionFunc = new sol::function(luaState["onTransgression"]); - checkLuaFunc(&onTransgressionFunc); - /*** - The Pope has accepted the player's crusade target. Deus Vult! + The battle AI has begun processing. + Exports: faction, religion - @function onPopeAcceptsCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onBattleAiCommenced + @tparam eventTrigger eventData @usage - --something + function onBattleAiCommenced(eventData) + --something here + end */ - onPopeAcceptsCrusadeTargetFunc = new sol::function(luaState["onPopeAcceptsCrusadeTarget"]); - checkLuaFunc(&onPopeAcceptsCrusadeTargetFunc); - /*** - A Crusade or Jihad has been called. + The delay phase has begun. + Exports: faction, religion - @function onCrusadeCalled - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onBattleDelayPhaseCommenced + @tparam eventTrigger eventData @usage - --something + function onBattleDelayPhaseCommenced(eventData) + --something here + end */ - onCrusadeCalledFunc = new sol::function(luaState["onCrusadeCalled"]); - checkLuaFunc(&onCrusadeCalledFunc); - /*** - A Crusade or Jihad has ended. + The deployment phase has begun. + Exports: faction, religion - @function onCrusadeEnds - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onBattleDeploymentPhaseCommenced + @tparam eventTrigger eventData @usage - --something + function onBattleDeploymentPhaseCommenced(eventData) + --something here + end */ - onCrusadeEndsFunc = new sol::function(luaState["onCrusadeEnds"]); - checkLuaFunc(&onCrusadeEndsFunc); - /*** - The Pope has rejected the player's crusade target. + The conflict phase has begun. + Exports: faction, religion - @function onPopeRejectsCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target + @function onBattleConflictPhaseCommenced + @tparam eventTrigger eventData @usage - --something + function onBattleConflictPhaseCommenced(eventData) + --something here + end */ - onPopeRejectsCrusadeTargetFunc = new sol::function(luaState["onPopeRejectsCrusadeTarget"]); - checkLuaFunc(&onPopeRejectsCrusadeTargetFunc); - /*** - An army has taken a crusade or jihad target settlement. + Called after a faction declares a war. + Exports: faction, targetFaction, religion, targetReligion - @function onArmyTakesCrusadeTarget - @tparam crusadeStruct crusade - @tparam settlementStruct target - @tparam stackStruct army + @function onFactionWarDeclared + @tparam eventTrigger eventData @usage + function onFactionWarDeclared(eventData) --something + end */ - onArmyTakesCrusadeTargetFunc = new sol::function(luaState["onArmyTakesCrusadeTarget"]); - checkLuaFunc(&onArmyTakesCrusadeTargetFunc); - /*** - Units have deserted a crusade or jihad. + Called after a faction declares an alliance. + Exports: faction, targetFaction, religion, targetReligion - @function onUnitsDesertCrusade - @tparam crusadeStruct crusade - @tparam settlementStruct target - @tparam factionStruct fac + @function onFactionAllianceDeclared + @tparam eventTrigger eventData @usage + function onFactionAllianceDeclared(eventData) --something + end */ - onUnitsDesertCrusadeFunc = new sol::function(luaState["onUnitsDesertCrusade"]); - checkLuaFunc(&onUnitsDesertCrusadeFunc); - /*** - A new pope has been elected. + A marriage has occured between two factions. gets fired for both factions involved. + Exports: faction, targetFaction, religion, targetReligion - @function onPopeElected - @tparam factionStruct fac - @tparam factionStruct fac2 + @function onInterFactionMarriage + @tparam eventTrigger eventData @usage + function onInterFactionMarriage(eventData) --something + end */ - onPopeElectedFunc = new sol::function(luaState["onPopeElected"]); - checkLuaFunc(&onPopeElectedFunc); - /*** - A Faction has voted for the new pope. + Called after a faction makes a trade agreement. + Exports: faction, targetFaction, religion, targetReligion - @function onVotedForPope - @tparam factionStruct fac + @function onFactionTradeAgreementMade + @tparam eventTrigger eventData @usage + function onFactionTradeAgreementMade(eventData) --something + end */ - onVotedForPopeFunc = new sol::function(luaState["onVotedForPope"]); - checkLuaFunc(&onVotedForPopeFunc); - /*** - An assassination mission against the pope has failed and the assassin is executed. + A new pope has been elected. + Exports: faction, targetFaction, religion, targetReligion - @function onAssassinCaughtAttackingPope - @tparam factionStruct fac + @function onPopeElected + @tparam eventTrigger eventData @usage + function onPopeElected(eventData) --something + end */ - onAssassinCaughtAttackingPopeFunc = new sol::function(luaState["onAssassinCaughtAttackingPope"]); - checkLuaFunc(&onAssassinCaughtAttackingPopeFunc); - /*** - An inquisitor has been dispatched to a region. + Called after a faction breaks an alliance. + Exports: faction, targetFaction, religion, targetReligion - @function onInquisitorAppointed - @tparam factionStruct fac - @tparam settlementStruct sett + @function onFactionBreakAlliance + @tparam eventTrigger eventData @usage + function onFactionBreakAlliance(eventData) --something + end */ - onInquisitorAppointedFunc = new sol::function(luaState["onInquisitorAppointed"]); - checkLuaFunc(&onInquisitorAppointedFunc); - /*** - The player has opened the panel for the selected settlement. + A faction to faction attitude update has occurred (once every round). + Exports: faction, targetFaction, religion - @function onSettlementPanelOpen - @tparam settlementStruct sett + @function onUpdateAttitude + @tparam eventTrigger eventData @usage + function onUpdateAttitude(eventData) --something + end */ - onSettlementPanelOpenFunc = new sol::function(luaState["onSettlementPanelOpen"]); - checkLuaFunc(&onSettlementPanelOpenFunc); - /*** - The player has opened the finances panel. + A demeanour response has occured in diplomacy talks. + Exports: faction, targetFaction, religion, targetReligion, amount - @function onFinancesPanelOpen - @tparam factionStruct fac + @function onDemeanour + @tparam eventTrigger eventData @usage + function onDemeanour(eventData) --something + end */ - onFinancesPanelOpenFunc = new sol::function(luaState["onFinancesPanelOpen"]); - checkLuaFunc(&onFinancesPanelOpenFunc); - /*** - The player has opened the faction summary panel. + Called after a faction gives money to another faction. + Exports: faction, targetFaction, religion, targetReligion, amount - @function onFactionSummaryPanelOpen - @tparam factionStruct fac + @function onGiveMoney + @tparam eventTrigger eventData @usage + function onGiveMoney(eventData) --something + end */ - onFactionSummaryPanelOpenFunc = new sol::function(luaState["onFactionSummaryPanelOpen"]); - checkLuaFunc(&onFactionSummaryPanelOpenFunc); - /*** - The player has opened the family tree panel. + A player unit has attacked one of the enemies units. + Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit - @function onFamilyTreePanelOpenFunc - @tparam factionStruct fac + @function onBattlePlayerUnitAttacksEnemyUnit + @tparam eventTrigger eventData @usage - --something + function onBattlePlayerUnitAttacksEnemyUnit(eventData) + --something here + end */ - onFamilyTreePanelOpenFunc = new sol::function(luaState["onFamilyTreePanelOpenFunc"]); - checkLuaFunc(&onFamilyTreePanelOpenFunc); - /*** - The player has opened the diplomatic standing panel. + An enemy unit has attacked one of the players units. + Exports: attackingUnit, defendingUnit, playerUnit, enemyUnit - @function onDiplomaticStandingPanelOpen - @tparam factionStruct fac + @function onBattleEnemyUnitAttacksPlayerUnit + @tparam eventTrigger eventData @usage - --something + function onBattleEnemyUnitAttacksPlayerUnit(eventData) + --something here + end */ - onDiplomaticStandingPanelOpenFunc = new sol::function(luaState["onDiplomaticStandingPanelOpen"]); - checkLuaFunc(&onDiplomaticStandingPanelOpenFunc); - /*** - The player has opened a diplomacy panel. + One of the player's units has gone berserk. + Exports: playerUnit - @function onDiplomacyPanelOpen - @tparam factionStruct fac + @function onBattlePlayerUnitGoesBerserk + @tparam eventTrigger eventData @usage - --something + function onBattlePlayerUnitGoesBerserk(eventData) + --something here + end */ - onDiplomacyPanelOpenFunc = new sol::function(luaState["onDiplomacyPanelOpen"]); - checkLuaFunc(&onDiplomacyPanelOpenFunc); - /*** - The player has attacked an army or settlement. The decision panel is now open. + One of the player's units has routed. + Exports: playerUnit - @function onPreBattlePanelOpen - @tparam factionStruct fac + @function onBattlePlayerUnitRouts + @tparam eventTrigger eventData @usage - --something + function onBattlePlayerUnitRouts(eventData) + --something here + end */ - onPreBattlePanelOpenFunc = new sol::function(luaState["onPreBattlePanelOpen"]); - checkLuaFunc(&onPreBattlePanelOpenFunc); - /*** - The naval auto resolve panel has opened. + A siege engine belonging to the player has been destroyed. + Exports: playerUnit - @function onNavalAutoResolvePanelOpen + @function onBattlePlayerSiegeEngineDestroyed + @tparam eventTrigger eventData @usage - --something + function onBattlePlayerSiegeEngineDestroyed(eventData) + --something here + end */ - onNavalAutoResolvePanelOpenFunc = new sol::function(luaState["onNavalAutoResolvePanelOpen"]); - checkLuaFunc(&onNavalAutoResolvePanelOpenFunc); - /*** - The player has opened the panel for the selected character. + A player's engine has started attacking a gate. + Exports: playerUnit - @function onCharacterPanelOpen - @tparam namedCharacter selectedChar + @function onBattleGatesAttackedByPlayerEngine + @tparam eventTrigger eventData @usage - --something + function onBattleGatesAttackedByPlayerEngine(eventData) + --something here + end */ - onCharacterPanelOpenFunc = new sol::function(luaState["onCharacterPanelOpen"]); - checkLuaFunc(&onCharacterPanelOpenFunc); - /*** - The player has opened a trade panel. + One of the enemy's units has gone berserk. + Exports: enemyUnit - @function onTradePanelOpen - @tparam settlementStruct sett + @function onBattleEnemyUnitGoesBerserk + @tparam eventTrigger eventData @usage - --something + function onBattleEnemyUnitGoesBerserk(eventData) + --something here + end */ - onTradePanelOpenFunc = new sol::function(luaState["onTradePanelOpen"]); - checkLuaFunc(&onTradePanelOpenFunc); - /*** - The player has requested building advice. + One of the enemy's units has routed. + Exports: enemyUnit - @function onRequestBuildingAdvice - @tparam settlementStruct sett + @function onBattnemyUnitRouts + @tparam eventTrigger eventData @usage - --something + function onBattnemyUnitRouts(eventData) + --something here + end */ - onRequestBuildingAdviceFunc = new sol::function(luaState["onRequestBuildingAdvice"]); - checkLuaFunc(&onRequestBuildingAdviceFunc); - /*** - The player has requested training advice. + A siege engine belonging to the enemy has been destroyed. + Exports: enemyUnit - @function onRequestTrainingAdvice - @tparam settlementStruct sett - @tparam eduEntry recommendedUnitEntry + @function onBattnemySiegeEngineDestroyed + @tparam eventTrigger eventData @usage - --something + function onBattnemySiegeEngineDestroyed(eventData) + --something here + end */ - onRequestTrainingAdviceFunc = new sol::function(luaState["onRequestTrainingAdvice"]); - checkLuaFunc(&onRequestTrainingAdviceFunc); - /*** - The player has opened a message. + An enemy's engine has started attacking a gate. + Exports: enemyUnit - @function onMessageOpen - @tparam factionStruct fac - @tparam int msgType + @function onBattleGatesAttackedByEnemyEngine + @tparam eventTrigger eventData @usage - --something + function onBattleGatesAttackedByEnemyEngine(eventData) + --something here + end */ - onMessageOpenFunc = new sol::function(luaState["onMessageOpen"]); - checkLuaFunc(&onMessageOpenFunc); - /*** - The player has recieved a message. + When a particular disaster has just happened. + Exports: resourceDescription - @function onIncomingMessage - @tparam factionStruct fac - @tparam int msgType + @function onDisaster + @tparam eventTrigger eventData @usage - --something + function onDisaster(eventData) + if eventData.resourceDescription == "earthquake" then + --something here + end + end */ - onIncomingMessageFunc = new sol::function(luaState["onIncomingMessage"]); - checkLuaFunc(&onIncomingMessageFunc); - /*** - The player has closed a message. + An event counter has changed it's value. + Exports: eventCounter - @function onMessageClosed - @tparam int msgType + @function onEventCounter + @tparam eventTrigger eventData @usage - --something + function onEventCounter(eventData) + if eventData.eventCounter == "my_event_counter" then + --something here + end + end */ - onMessageClosedFunc = new sol::function(luaState["onMessageClosed"]); - checkLuaFunc(&onMessageClosedFunc); - /*** - The player has clicked on a button. + The last unit has been removed from a fort, agents do not count. + Exports: fort, faction, regionID, religion - @function onButtonPressed - @tparam string buttonName + @function onUngarrisonedFort + @tparam eventTrigger eventData @usage - --something + function onUngarrisonedFort(eventData) + --something here + end */ - onButtonPressedFunc = new sol::function(luaState["onButtonPressed"]); - checkLuaFunc(&onButtonPressedFunc); - /*** - The player closed a scroll. + An object of the target faction has been seen by the faction. + Exports: faction, targetFaction, regionID, coords, religion - @function onScrollClosed - @tparam string scrollName + @function onObjSeen + @tparam eventTrigger eventData @usage - --something + function onObjSeen(eventData) + --something here + end */ - onScrollClosedFunc = new sol::function(luaState["onScrollClosed"]); - checkLuaFunc(&onScrollClosedFunc); - /*** - The player opened a scroll. + The tile has been seen by the faction. + Exports: faction, regionID, coords, religion - @function onScrollOpened - @tparam string scrollName + @function onTileSeen + @tparam eventTrigger eventData @usage - --something + function onTileSeen(eventData) + --something here + end */ - onScrollOpenedFunc = new sol::function(luaState["onScrollOpened"]); - checkLuaFunc(&onScrollOpenedFunc); - /*** - A special UI Element is visible. + 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 onUIElementVisible - @tparam string elementName + @function onTransgression + @tparam eventTrigger eventData @usage - --something + function onTransgression(eventData) + --something here + end */ - onUIElementVisibleFunc = new sol::function(luaState["onUIElementVisible"]); - checkLuaFunc(&onUIElementVisibleFunc); - /*** - The player has requested advice on a scroll. + A faction to faction forgiveness has occurred. + Exports: faction, targetFaction, resourceDescription, religion + forgiveness: FC_MILITARY_ASSISTANCE, FC_OBVIOUS_BRIBE - @function onScrollAdviceRequested - @tparam string scrollName + @function onForgiveness + @tparam eventTrigger eventData @usage - --something + function onForgiveness(eventData) + --something here + end */ - onScrollAdviceRequestedFunc = new sol::function(luaState["onScrollAdviceRequested"]); - checkLuaFunc(&onScrollAdviceRequestedFunc); - /*** - The player has requested advice on the settlement scroll. + An army has taken a crusade or jihad target settlement. + Exports: targetSettlement, faction, targetFaction, army, regionID, targetRegionID, coords, religion, targetReligion, crusade - @function onSettlementScrollAdviceRequested - @tparam settlementStruct sett - @tparam string scrollName + @function onArmyTakesCrusadeTarget + @tparam eventTrigger eventData @usage - --something + function onArmyTakesCrusadeTarget(eventData) + --something here + end */ - onSettlementScrollAdviceRequestedFunc = new sol::function(luaState["onSettlementScrollAdviceRequested"]); - checkLuaFunc(&onSettlementScrollAdviceRequestedFunc); - /*** - The player has requested advice on the prebattle scroll. + Units have deserted a crusade or jihad. + Exports: targetSettlement, faction, targetFaction, targetRegionID, religion, targetReligion, crusade - @function onPreBattleScrollAdviceRequested + @function onUnitsDesertCrusade + @tparam eventTrigger eventData @usage - --something + function onUnitsDesertCrusade(eventData) + --something here + end */ - onPreBattleScrollAdviceRequestedFunc = new sol::function(luaState["onPreBattleScrollAdviceRequested"]); - checkLuaFunc(&onPreBattleScrollAdviceRequestedFunc); + + /*** - The player has requested advice on the naval prebattle scroll. + Called every time an image is rendered for display - @function onNavalPreBattleScrollAdviceRequested + @function draw + @tparam LPDIRECT3DDEVICE9 pDevice @usage - --something - */ + function draw(device) + ImGui.Begin("test"); + + ImGui.Text("Some test text") - onNavalPreBattleScrollAdviceRequestedFunc = new sol::function(luaState["onNavalPreBattleScrollAdviceRequested"]); - checkLuaFunc(&onNavalPreBattleScrollAdviceRequestedFunc); + ImGui.End(); + end + */ + drawLuaFunc = new sol::function(luaState["draw"]); + checkLuaFunc(&drawLuaFunc); /*** - The player has opened the college of cardinals panel. + Called when ImGui backend reload fonts - @function onCollegeOfCardinalsPanelOpen - @tparam collegeCardinalsStruct college + @function onLoadingFonts @usage - --something + function onLoadingFonts() + --something here + end */ + onLoadingFonts = new sol::function(luaState["onLoadingFonts"]); + checkLuaFunc(&onLoadingFonts); + + resetDXFunc = new sol::function(luaState["deinitDX"]); + checkLuaFunc(&resetDXFunc); - onCollegeOfCardinalsPanelOpenFunc = new sol::function(luaState["onCollegeOfCardinalsPanelOpen"]); - checkLuaFunc(&onCollegeOfCardinalsPanelOpenFunc); + initDXFunc = new sol::function(luaState["initDX"]); + checkLuaFunc(&initDXFunc); /*** - A guild has been created or upgraded. + Called when a new campaign is started from the menu. - @function onGuildUpgraded - @tparam settlementStruct sett - @tparam string guildName + @function onNewGameStart @usage - function onGuildUpgraded(sett, guildName) - print("Function: onGuildUpgraded()\n\tSettlement: "..sett.name.."\n\tGuild: "..guildName) + function onNewGameStart() + --something here end */ - onGuildUpgradedFunc = new sol::function(luaState["onGuildUpgraded"]); - checkLuaFunc(&onGuildUpgradedFunc); + + + onNewGameStart = new sol::function(luaState["onNewGameStart"]); + checkLuaFunc(&onNewGameStart); /*** - A guild has been destroyed. + Called after the game loads various db`s (edu, etc) at startup. - @function onGuildDestroyed - @tparam settlementStruct sett - @tparam int guildID + @function onReadGameDbsAtStart @usage - function onGuildDestroyed(sett, guildID) - print("Function: onGuildDestroyed()\n\tSettlement: "..sett.name.."\n\tID: "..guildID) + function onReadGameDbsAtStart() + --something here end */ - onGuildDestroyedFunc = new sol::function(luaState["onGuildDestroyed"]); - checkLuaFunc(&onGuildDestroyedFunc); + + + onReadGameDbsAtStart = new sol::function(luaState["onReadGameDbsAtStart"]); + checkLuaFunc(&onReadGameDbsAtStart); /*** - A character in the family tree has received a brother by adoption. + Called after the game loads various db`s (edu, etc) at startup. - @function onBrotherAdopted - @tparam namedCharacter character This is the original child, not the newly adopted character. + @function onGameInit @usage - function onBrotherAdopted(character) - print("Function: onBrotherAdopted()\n\tName: "..character.fullName.."\n\tParent: "..character.parent.fullName.."\n\tFaction: "..character.faction:getFactionName()) + function onGameInit() + --something here end */ - onBrotherAdoptedFunc = new sol::function(luaState["onBrotherAdopted"]); - checkLuaFunc(&onBrotherAdoptedFunc); - /*** - A child has been born. - @function onBirth - @tparam namedCharacter child + onGameInit = new sol::function(luaState["onGameInit"]); + checkLuaFunc(&onGameInit); + /*** + Called on clicking the stratmap. + + @function onClickAtTile + @tparam int x + @tparam int y @usage - function onBirth(child) - print("Function: onBirth()\n\tChild Name: "..child.fullName.."\n\tParent: "..child.parent.fullName.."\n\tFaction: "..child.faction:getFactionName()) + 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 */ - onBirthFunc = new sol::function(luaState["onBirth"]); - checkLuaFunc(&onBirthFunc); + + + onClickAtTile = new sol::function(luaState["onClickAtTile"]); + checkLuaFunc(&onClickAtTile); /*** - A character has come of age. + Called after loading the campaign map - @function onCharacterComesOfAge - @tparam namedCharacter character Character's age is equal to age\_of\_manhood in descr\_campaign\_db.xml. + @function onCampaignMapLoaded @usage - function onCharacterComesOfAge(character) - print("Function: onCharacterComesOfAge()\n\tName: "..character.fullName.."\n\tParent: "..character.parent.fullName.."\n\tFaction: "..character.faction:getFactionName()) + function onCampaignMapLoaded() + --something here end */ - onCharacterComesOfAgeFunc = new sol::function(luaState["onCharacterComesOfAge"]); - checkLuaFunc(&onCharacterComesOfAgeFunc); + + + onCampaignMapLoaded = new sol::function(luaState["onCampaignMapLoaded"]); + checkLuaFunc(&onCampaignMapLoaded); /*** - A character has married (someone who isn't a princess). + Called on plugin load (at game start). - @function onCharacterMarries - @tparam namedCharacter husband + @function onPluginLoad @usage - function onCharacterMarries(husband) - print("Function: onCharacterMarries()\n\tName: "..husband.fullName.."\n\tSpouse: "..husband.spouse.fullName.."\n\tFaction: "..husband.faction:getFactionName()) + --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 */ - onCharacterMarriesFunc = new sol::function(luaState["onCharacterMarries"]); - checkLuaFunc(&onCharacterMarriesFunc); + + + onPluginLoad = new sol::function(luaState["onPluginLoad"]); + checkLuaFunc(&onPluginLoad); + /*** - A character has married a princess agent. + Called on creating a new save file. - @function onCharacterMarriesPrincess - @tparam namedCharacter husband + @function onCreateSaveFile @usage - function onCharacterMarriesPrincess(husband) - print("Function: onCharacterMarriesPrincess()\n\tName: "..husband.fullName.."\n\tSpouse: "..husband.spouse.fullName.."\n\tFaction: "..husband.faction:getFactionName()) - end - */ + 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() - onCharacterMarriesPrincessFunc = new sol::function(luaState["onCharacterMarriesPrincess"]); - checkLuaFunc(&onCharacterMarriesPrincessFunc); + return savefiles + end + */ + onCreateSaveFile = new sol::function(luaState["onCreateSaveFile"]); + checkLuaFunc(&onCreateSaveFile); /*** - A child has been born. + Called on loading a save file. - @function onCharacterBecomesAFather - @tparam namedCharacter father Note: this event fires for all child births for this father, not just the first one. + @function onLoadSaveFile @usage - function onCharacterBecomesAFather(father) - local i, children = 1, "" - while father.childs[i] ~= nil do - children, i = children.." "..father.childs[i].fullName..",", i + 1 + 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 - children = children:gsub(",$", "") - print("Function: onCharacterBecomesAFather()\n\tName: "..father.fullName.."\n\tChildren:"..children.."\n\tFaction: "..father.faction:getFactionName()) + 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); - onCharacterBecomesAFatherFunc = new sol::function(luaState["onCharacterBecomesAFather"]); - checkLuaFunc(&onCharacterBecomesAFatherFunc); /*** - A new admiral has been created for a new ship. + Called at the start of a new turn. - @function onNewAdmiralCreated - @tparam namedCharacter admiral - @tparam settlementStruct sett + @function onChangeTurnNum + @tparam int turnNumber @usage - function onNewAdmiralCreated(admiral, sett) - print("Function: onNewAdmiralCreated()\n\tAdmiral: "..admiral.fullName.."\n\tSettlement: "..sett.name) + 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 - onNewAdmiralCreatedFunc = new sol::function(luaState["onNewAdmiralCreated"]); - checkLuaFunc(&onNewAdmiralCreatedFunc); + @usage + function onSelectWorldpkgdesc(selectedRecord,selectedRecordGroup) + --something here + return selectedRecord; + end + */ + onSelectWorldpkgdesc = new sol::function(luaState["onSelectWorldpkgdesc"]); + checkLuaFunc(&onSelectWorldpkgdesc); /*** - The player triggered a keyboard shortcut. + Called on specified fortificationlevel in a siege of a settlement. - @function onShortcutTriggered - @tparam string shortcut + @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 onShortcutTriggered(shortcut) - if shortcut == "strat_ui::mission_button" then - --do stuff + 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 */ - - onShortcutTriggeredFunc = new sol::function(luaState["onShortcutTriggered"]); - checkLuaFunc(&onShortcutTriggeredFunc); + onfortificationlevelS = new sol::function(luaState["onfortificationlevelS"]); + checkLuaFunc(&onfortificationlevelS); /*** - The character has been made the faction leader. + Called on the completion of the siege (in any way, with any outcome). - @function onBecomesFactionLeader - @tparam namedCharacter leader + @function onEndSiege + @tparam int xCoord x coordinate of siege(settlement or fort) + @tparam int yCoord y coordinate of siege(settlement or fort) @usage - function onBecomesFactionLeader(leader) - print("Function: onBecomesFactionLeader()\n\tLeader: "..leader.fullName) + function onEndSiege(x,y) + --something here end */ - - onBecomesFactionLeaderFunc = new sol::function(luaState["onBecomesFactionLeader"]); - checkLuaFunc(&onBecomesFactionLeaderFunc); - + onEndSiege = new sol::function(luaState["onEndSiege"]); + checkLuaFunc(&onEndSiege); /*** - The character has been made a faction heir. + Called on the starting of the siege (in any way, with any outcome). - @function onBecomesFactionHeir - @tparam namedCharacter heir + @function onStartSiege + @tparam int xCoord x coordinate of siege(settlement or fort) + @tparam int yCoord y coordinate of siege(settlement or fort) @usage - function onBecomesFactionHeir(heir) - print("Function: onBecomesFactionHeir()\n\tHeir: "..heir.fullName) + function onStartSiege(x,y) + --something here end */ - - onBecomesFactionHeirFunc = new sol::function(luaState["onBecomesFactionHeir"]); - checkLuaFunc(&onBecomesFactionHeirFunc); + onStartSiege = new sol::function(luaState["onStartSiege"]); + checkLuaFunc(&onStartSiege); if (onPluginLoad != nullptr) diff --git a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h index e8a8682d9..88b36022e 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaGetSetFuncs.h @@ -16,13 +16,13 @@ #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 { - int getTraitLevel(const traitContainer*currTrait); + int getTraitLevel(const traitContainer* currTrait); std::string getTraitName(const traitContainer* currTrait); traitContainer* getNextTrait(const traitContainer* currTrait); @@ -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()); } @@ -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 6100f192f..0e335fbaf 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::usertypeancillary; + sol::usertypenamedCharacter; + sol::usertypecapturedFactionInfo; + sol::usertypecapturedUnit; + sol::usertypecapturedCharacter; + sol::usertypeancillary; sol::usertypetraitContainerT; - sol::usertypeEduEntry; + sol::usertypeEduEntry; sol::usertypefactionStruct; sol::usertypefactionStratMapStruct; sol::usertypewatchtowerStruct; @@ -119,6 +121,15 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) sol::usertypesiege; sol::usertypebuildingLevel; sol::usertypebattleCameraStruct; + sol::usertypeunitPositionData; + sol::usertypefactionEconomy; + sol::usertypefactionRanking; + sol::usertypeholdRegionsWinCondition; + sol::usertypesettlementCapability; + sol::usertyperecruitmentCapability; + sol::usertypesettlementRecruitmentPool; + sol::usertypebattleFactionCounter; + sol::usertype eventTrigger; }types; luaState = {}; luaPath = modPath + "\\youneuoy_Data\\plugins\\lua"; @@ -163,68 +174,6 @@ sol::state* luaP::init(std::string& luaFilePath, std::string& modPath) return nullptr; } - - //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 @@ -249,6 +198,9 @@ 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 */ @@ -483,7 +435,41 @@ 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); + /*** + 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); + /*** + 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 @@ -893,31 +879,60 @@ 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 use moraleStatus enum + @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 unitPositionData unitPositionData @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("unitPositionData", &unit::unitPositionData); 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 @@ -937,6 +952,151 @@ 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 int combatStatus use enum: combatStatus + @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("combatStatus", &unitPositionData::combatStatus); + 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 @@ -984,7 +1144,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 )); @@ -997,38 +1157,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); @@ -1044,11 +1204,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 @@ -1066,9 +1238,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. @@ -1092,6 +1275,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 @@ -1261,9 +1465,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)); @@ -1272,7 +1476,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 @@ -1293,12 +1497,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 @@ -1328,7 +1532,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::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 @@ -1337,7 +1541,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 @@ -1345,7 +1549,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 @@ -1354,70 +1558,149 @@ 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("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_function("removeAncillary", &generalCharactericticsHelpers::removeAncillary); + 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 @@ -1431,13 +1714,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 )); @@ -1470,6 +1753,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 @@ -1477,7 +1762,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 @@ -1495,13 +1791,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 @@ -1529,9 +1836,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. @@ -1629,7 +1948,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 @@ -1665,6 +1984,229 @@ 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); + + /*** + 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 @@ -1679,9 +2221,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 */ @@ -1696,6 +2250,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 @@ -1734,7 +2300,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); @@ -1796,9 +2361,20 @@ 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 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 @@ -1863,6 +2439,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 */ @@ -1877,7 +2458,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 @@ -1890,11 +2471,21 @@ 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("settlementTaxLevel", &settlementStruct::settlementTaxLevel); types.settlementStruct.set("isProvokedRebellion", &settlementStruct::isProvokedRebellion); types.settlementStruct.set("populationSize", &settlementStruct::populationSize); + 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); @@ -2034,8 +2625,103 @@ 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); + types.settlementStruct.set("recruitmentCapabilityNum", sol::property(settlementHelpers::getRecruitmentCapabilityNum)); + /*** + 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 @@ -2306,6 +2992,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 @@ -2330,6 +3020,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. @@ -2556,187 +3250,3 @@ void luaP::onChangeTurnNum(int num) tryLua((*onChangeTurnNumFunc)(num)); } } - -void luaP::onCharacterSelected(generalCharacterictics* gen) -{ - if (onCharacterSelectedFunc != nullptr) - { - tryLua((*onCharacterSelectedFunc)(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) - { - tryLua((*onSiegeEquipmentCompletedFunc)(sett, frt)); - } -} - -void luaP::onPostBattle(generalCharacterictics* gen) -{ - if (onPostBattleFunc != nullptr) - { - tryLua((*onPostBattleFunc)(gen)); - } -} - -void luaP::onMultiTurnMove(generalCharacterictics* gen) -{ - if (onMultiTurnMoveFunc != nullptr) - { - tryLua((*onMultiTurnMoveFunc)(gen)); - } -} - -void luaP::onSettlementSelected(settlementStruct* sett) -{ - if (onSettlementSelectedFunc != nullptr) - { - 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 c261d06c5..56fe95b4a 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP.h +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP.h @@ -88,35 +88,6 @@ 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 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 onSettlementSelected(settlementStruct* sett); - void onSettlementUpgraded(settlementStruct* sett); - void onSettlementConverted(settlementStruct* sett); sol::state luaState; @@ -156,8 +127,8 @@ class luaP { sol::usertypeunit; sol::usertypecharacter; - sol::usertypenamedCharacter; - sol::usertypeancillary; + sol::usertypenamedCharacter; + sol::usertypeancillary; sol::usertypetraitContainerT; sol::usertypeEduEntry; sol::usertypefactionStruct; @@ -179,10 +150,12 @@ 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; sol::function* onfortificationlevelS = nullptr; + sol::function* onChangeTurnNumFunc = nullptr; sol::function* onClickAtTile = nullptr; sol::function* onNewGameStart = nullptr; sol::function* onPluginLoad = nullptr; @@ -193,128 +166,11 @@ class luaP sol::function* resetDXFunc = nullptr; 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; - sol::function* onSettlementSelectedFunc = nullptr; - sol::function* onSettlementUpgradedFunc = nullptr; - sol::function* onSettlementConvertedFunc = nullptr; - sol::function* onCityRiotsFunc = nullptr; - sol::function* onUngarrisonedSettlementFunc = nullptr; - - sol::function* onUngarrisonedFortFunc = 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* 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; - - - - 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* 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 d73a85069..364b9dc46 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/luaP2.cpp @@ -18,14 +18,26 @@ 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; + 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; + sol::usertype eventTrigger; }typeAll; using namespace campaignEnums; - /// CampaignEnums - //@section campaignEnums + ///CampaignEnums + //@section dipRelType /*** Enum with a list of types of diplomatic relations. @@ -53,22 +65,768 @@ 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 + + /*** + 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); + + ///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 + + /*** + 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 /*** 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 fogOfWar + @tfield int factionTurnID + @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 +836,38 @@ 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 + @table 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("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); typeAll.campaignTable.set("timescale", &campaign::TimeScale); typeAll.campaignTable.set("romeSettlement", &campaign::rome); @@ -98,6 +875,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,9 +890,9 @@ void luaP::initCampaign() typeAll.campaignTable.set("daysInBattle", &campaign::daysInBattle); typeAll.campaignTable.set("currentTimeInBattle", &campaign::currentTimeInBattle); - - typeAll.campaignTable.set("campaignDifficulty", &campaign::campaignDifficultyFaction); - typeAll.campaignTable.set("battleDifficulty", &campaign::battleDifficulty07); + 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 @@ -150,6 +929,129 @@ 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); + + ///CollegeofCardinals + //@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); + + /// 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 @@ -160,21 +1062,30 @@ 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 + @table stratMap */ typeAll.stratMap = luaState.new_usertype("stratMap"); 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. @function stratMap.getRegion @tparam int index - @treturn region region + @treturn regionStruct region @usage local sMap = gameDataAll.get().stratMap; local region = sMap.getRegion(2); @@ -192,12 +1103,103 @@ 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 + @tfield int tradeValue --only counts from 1 side (importer) + + @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); + typeAll.roadStruct.set("tradeValue", &roadStruct::tradeValue); + + /*** + 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 @@ -217,43 +1219,125 @@ 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 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 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). + @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("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); - ///Region - //@section Region + /*** + 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); + + ///RegionStruct + //@section RegionStruct /*** - Basic region table. + Basic regionStruct table. @tfield string regionName @tfield string localizedName @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 @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 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 @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 @@ -271,39 +1355,63 @@ 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 getDevastatedTile getDevastatedTile + @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("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. @@ -315,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. @@ -327,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. @@ -339,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. @@ -351,19 +1459,19 @@ 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. @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); + typeAll.regionStruct.set_function("getNeighbour", &gameHelpers::getNeighbour); /*** Check if a region has a hidden resource. @@ -373,9 +1481,9 @@ 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); + typeAll.regionStruct.set_function("getHiddenResource", &gameHelpers::getHiddenResource); /*** Set a region's hidden resource (reset on game restart). @@ -387,7 +1495,209 @@ 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. + @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.regionStruct.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.regionStruct.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.regionStruct.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.regionStruct.set_function("getDevastatedTile", &gameHelpers::getDevastatedTile); + + /*** + 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.regionStruct.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.regionStruct.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.regionStruct.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.regionStruct.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.regionStruct.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.regionStruct.set_function("getHostileArmiesStrength", &gameHelpers::getHostileArmiesStrength); + + ///neighbourRegion + //@section neighbourRegion + + /*** + Basic neighbourRegion table. + + @tfield int regionID + @tfield regionStruct region + @tfield int tradeValue + @tfield bool alliedRegion + @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); + typeAll.neighbourRegion.set("alliedRegion", &neighbourRegion::alliedRegion); + + /*** + 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 @@ -527,6 +1837,7 @@ void luaP::initP2() sol::usertype battleAI; sol::usertype battleArmy; sol::usertype battleUnit; + sol::usertype battleResidence; }typeAll; ///GameDataAll @@ -538,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 */ @@ -545,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; @@ -553,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); @@ -592,11 +1905,17 @@ 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 + @table battleStruct */ typeAll.battleTable = luaState.new_usertype("battleStruct"); typeAll.battleTable.set("battleState", &battleDataS::battleState); @@ -611,9 +1930,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 @@ -629,14 +1973,17 @@ void luaP::initP2() @tfield int armiesNum @tfield int alliance @tfield int soldierCount - @tfield int totalStrenght + @tfield int factionCount + @tfield int totalStrength @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. + + - @table battleStruct.battleSide + @table battleSide */ typeAll.battleSideTable = luaState.new_usertype("battleSide"); typeAll.battleSideTable.set("isDefender", &battleSide::isDefender); @@ -645,7 +1992,8 @@ 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); })); /*** @@ -654,7 +2002,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 @@ -691,16 +2039,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 @@ -714,7 +2072,7 @@ void luaP::initP2() - @table battleSide.trackedPointerArmy + @table trackedPointerArmy */ typeAll.trackedPointerArmyTable = luaState.new_usertype("trackedPointerArmy"); typeAll.trackedPointerArmyTable.set("army", &trackedPointerArmy::stack); @@ -789,8 +2147,8 @@ 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 unitCount @tfield getBattleUnit getBattleUnit @@ -802,13 +2160,12 @@ 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("totalValue", &armyAndCharacter::totalValue); 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 @@ -824,17 +2181,58 @@ void luaP::initP2() Basic battleUnit table @tfield unit unit + @tfield float valuePerSoldier @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 + @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); - 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); + typeAll.battleUnit.set("hasWithdrawn", &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 352fdc375..66f2fa428 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); } bool getTileVisibility(factionStruct* faction, int x, int y) { @@ -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; } } @@ -161,9 +161,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; @@ -173,7 +173,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) { @@ -210,9 +210,27 @@ namespace m2tweopHelpers (*(*plugData::data.funcs.setGuildCooldown))(turns); } - void getGameVersion() + int getGameVersion() { 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 be80b293f..da8f05861 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 { @@ -39,8 +39,8 @@ namespace m2tweopHelpers bool getTileVisibility(factionStruct* faction, 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); @@ -49,7 +49,9 @@ namespace m2tweopHelpers void unlockGameConsoleCommands(); void setEDUUnitsSize(signed short min, signed short max); - void getGameVersion(); + int getGameVersion(); + options1* getOptions1(); + options2* getOptions2(); std::tuple loadTextureToGame(const std::string& path); diff --git a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp index 48eaca693..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.cpp @@ -1,293 +0,0 @@ -#include "otherEvents.h" - -void onMultiTurnMove(generalCharacterictics* gen) -{ - plugData::data.luaAll.onMultiTurnMove(gen); -} - -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 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) - { - tryLua((*plugData::data.luaAll.onGiveSettlementFunc)(sett, fac, fac2)); - } -} - -void onOccupySettlement(generalCharacterictics* gen, factionStruct* fac) -{ - if (plugData::data.luaAll.onOccupySettlementFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onOccupySettlementFunc)(gen, fac)); - } -} - -void onExterminatePopulation(generalCharacterictics* gen, factionStruct* fac) -{ - if (plugData::data.luaAll.onExterminatePopulationFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onExterminatePopulationFunc)(gen, fac)); - } -} - -void onSackSettlement(generalCharacterictics* 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 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) - { - tryLua((*plugData::data.luaAll.onAddedToTrainingQueueFunc)(sett, 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) - { - tryLua((*plugData::data.luaAll.onUnitTrainedFunc)(fac, sett, un)); - } -} - -void onAgentCreated(generalCharacterictics* pers, int type, settlementStruct* sett) -{ - if (plugData::data.luaAll.onAgentCreatedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onAgentCreatedFunc)(pers, type, sett)); - } -} - -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) - { - 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 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) -{ - if (plugData::data.luaAll.onNewAdmiralCreatedFunc != nullptr) - { - tryLua((*plugData::data.luaAll.onNewAdmiralCreatedFunc)(pers, sett)) - } -} - -void onShortcutTriggered(const char* str) -{ - if (plugData::data.luaAll.onShortcutTriggeredFunc != nullptr) - { - 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..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/otherEvents.h @@ -1,60 +0,0 @@ -#pragma once -#include "pluginM2TWEOP.h" -extern "C" PLUGINM2TWEOP_API void onMultiTurnMove(generalCharacterictics * 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 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 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 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 324c6ab88..e536ec6a7 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) { @@ -131,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); @@ -169,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); @@ -481,7 +488,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(); @@ -496,7 +503,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 225d8fc05..786c8e46c 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h +++ b/M2TWEOP-luaPlugin/luaPlugin/realGameTypes.h @@ -16,12 +16,194 @@ 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 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: + 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 + + +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 + 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 @@ -29,9 +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 - char pad_0020[12]; //0x0020 + int32_t roadLevel; //0x0020 + int32_t farmingLevel; //0x0024 + int32_t famineThreat; //0x0028 struct stackStruct** armies; //0x002C int32_t armyCountArraySize; //0x0030 int32_t stacksNum; //0x0034 @@ -43,23 +227,51 @@ 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 + 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 tradeFleetCount; //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[12]; //0x009C + int32_t* devastatedTiles; //0x00A8 + int32_t devastatedTilesSize; //0x00AC + int32_t devastatedTilesCount; //0x00B0 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 + int32_t armiesHostileToArrayIndexIDStrength[31]; //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 @@ -67,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 @@ -75,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 @@ -86,26 +302,113 @@ struct neighbourRegion struct regionStruct* region; //0x0000 int32_t regionID; //0x0004 float distance; //0x0008 - char pad_000C[4]; //0x000C - void* tileStuff; //0x0010 - char pad_0014[68]; //0x0014 + int8_t alliedRegion; //0x000C + char pad_000D[3]; //0x000D + 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 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[44]; + undefined field_0x0[4]; + struct UNICODE_STRING** campaignName; //0x0004 + struct UNICODE_STRING*** campaignPath; //0x0008 + 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; - undefined field_0x4c[4]; - undefined field_0x50[44]; + DWORD arraySmthing; //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 { public: - struct EduEntry* eduEntry; //0x0000 + struct eduEntry* eduEntry; //0x0000 int32_t experience; //0x0004 int32_t cost; //0x0008 float replenishMin; //0x000C @@ -154,6 +457,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; @@ -170,9 +483,25 @@ 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 + int32_t tradeValue; //0x0020 + char pad_0020[20]; //0x0020 +}; //Size: 0x0038 + struct oneTile { - void* object; - undefined field_0x4[6]; + DWORD* object; //can be character, resource, fort, + struct roadStruct* road; //0x0004 + undefined field_0x8[2]; int8_t isLand; undefined field_0xB[1]; int8_t terrainModel; @@ -185,12 +514,16 @@ 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; + 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 +532,98 @@ 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 + uint32_t stratTableStringIndex; //0x0004 + struct stringWithHash* regionsToHold; //0x0008 + int32_t regionsToHoldSize; //0x000C + int32_t regionsToHoldCount; //0x0010 + uint32_t factionsToOutliveBitfield; //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 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: + char pad_0000[28]; //0x0000 + struct settlementStruct* settlement; //0x001C + char pad_0020[16]; //0x0020 + int32_t isFortBattle; //0x0030 + struct battleBuildings* battleBuildings; //0x0034 + char pad_0038[4]; //0x0038 + 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 +644,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 { @@ -243,11 +673,25 @@ struct watchTowerModel { //watchtower struct watchTowerStruct { - undefined field_0x0[12]; + void* watchTowerVtable; //0x0000 + DWORD* object; //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 { @@ -262,31 +706,132 @@ 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[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 +{ +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]; + 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; 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]; + uint32_t existingFactionsBitMap; //0x0324 + int32_t nonPlayableFactionsNum; //0x0328 + char pad_032C[12]; //0x032C + 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; @@ -294,23 +839,47 @@ 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; - undefined field37_0x3f4[4]; + int8_t N00001211; //0x03F4 + int8_t showDateAsTurns; //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 +891,53 @@ 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 + char pad[16]; //0x21638 + struct mercPoolList allMercPools; //0x2163C + void* unk3; //0x21650 + void* unk4; //0x21654 +}; + +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 +948,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 @@ -352,29 +960,273 @@ struct battleUnit public: struct unit* unit; //0x0000 struct UNICODE_STRING** localizedName; //0x0004 - float someFloat; //0x0008 + float valuePerSoldier; //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 + int8_t hasWithdrawn; //0x003D + uint16_t N000400D6; //0x003E + int32_t N0001FD2C; //0x0040 + int32_t N0001FDB3; //0x0044 }; //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 struct general* character;//0x0004 int32_t generalNumKillsBattle; //0x0008 float generalHPRatioLost; //0x000C - float someFloat; //0x0010 + float totalValue; //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 @@ -491,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 @@ -514,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 @@ -533,12 +1407,20 @@ 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 */ 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 @@ -551,11 +1433,34 @@ 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[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 + 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 { @@ -753,9 +1658,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; @@ -943,7 +1855,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 @@ -973,6 +1885,50 @@ 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 + + +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; @@ -990,23 +1946,31 @@ 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; - 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; undefined field19_0x1a0[4]; BYTE isCastle; /* castle or settlement */ - undefined field21_0x1a5[3]; - UINT32 regionNumber; /* number of region */ - undefined field_0x1ac[12]; - int priceOfUnitsInRecruitmentSlots; + 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 */ + int32_t factionID; //0x01AC + int32_t yearFounded; //0x01B0 + int32_t triumph; //0x01B4 + int queueCost; undefined field24_0xBC[24]; struct unitRQ unitQueue[9]; int startIndexRQ; @@ -1017,20 +1981,64 @@ 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[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 + int32_t harvestSuccess; //0x0E40 struct resStrat** resources; - undefined field36_0xe48[4]; + int32_t resourceSize; //0x0E48 int resourcesNum; - undefined field38_0xe50[2164]; + int32_t settlementTaxLevel; //0x0E50 + struct capabilityStruct capabilities; //0x0E54 + 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 - char pad_1704[116]; //0x1704 + char pad_16C8[48]; //0x16C8 + int32_t baseFertilityValue; //0x16F8 + int32_t rebelFactionChance; //0x16FC + int32_t turmoil; //0x1700 + 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 @@ -1085,7 +2093,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 @@ -1119,38 +2131,80 @@ 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 */ 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]; 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; + 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; 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 + 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 + 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) -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 */ @@ -1231,9 +2285,9 @@ 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** 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 */ @@ -1241,9 +2295,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]; @@ -1255,7 +2309,7 @@ struct generalCharacterictics { /* 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; @@ -1265,20 +2319,16 @@ 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; - 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* patchToAncImage; + char pad_0018[4]; //0x0018 + int8_t isUnique; //0x001C + char pad_001D[23]; //0x001D + uint32_t excludedCultures; //0x0034 }; struct trait { /* traits of the character */ @@ -1314,34 +2364,431 @@ 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 + +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]; 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]; + struct eduEntry* eduEntry; + 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; @@ -1358,29 +2805,54 @@ 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 + int8_t isHalfDestroyed; //0x014C + char pad_014D[15]; //0x014D + struct descrRebelEntry* descrRebel; //0x015C + int32_t subFactionID; //0x0160 }; struct coords { @@ -1398,56 +2870,259 @@ 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 + +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]; 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 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 */ - undefined field_0xfc[4]; + struct aiFaction* aiFaction; //0x00D8 + int32_t AIPersonalityType; //0x00DC + int32_t AIPersonalityName; //0x00E0 + char pad_00E4[12]; //0x00E4 + struct holdRegionsWinCondition* WinConditions; //0x00F0 + int32_t regionsOwnedStart; //0x00F4 + struct namedCharacter** charactersAll; /* all characters, died, alive, etc */ + 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]; - int wathtowersNum; + int32_t watchtowersSize; //0x0144 + int watchtowersNum; 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[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; - 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[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[84]; + undefined field_0xa44[16]; + int8_t isFactionExcommunicated; //0x0A54 + 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]; 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 @@ -1494,7 +3169,7 @@ struct ArmourUpgModels //type of unit from EDU -struct EduEntry { +struct eduEntry { char* Type; uint32_t typeHash; DWORD Index; @@ -1675,8 +3350,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; @@ -1693,7 +3368,7 @@ struct EduEntry { struct eduEntryes { /* structure with all edu entries */ UINT32 qq; - struct EduEntry unitTupes[500]; + struct eduEntry unitTupes[500]; UINT32 numberOfTupes; }; @@ -1707,8 +3382,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 @@ -1724,22 +3399,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 { @@ -1778,12 +3473,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/religionEvents.cpp b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp index d742f56b9..0519ecba6 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.cpp @@ -1,81 +1 @@ -#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) -{ - if (plugData::data.luaAll.onAssassinCaughtAttackingPopeFunc != nullptr) - { - 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)); - } -} + \ No newline at end of file diff --git a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h index ef7367c10..e69de29bb 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h +++ b/M2TWEOP-luaPlugin/luaPlugin/religionEvents.h @@ -1,13 +0,0 @@ -#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 diff --git a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.cpp index 9576448a7..009801d89 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) @@ -61,3 +61,27 @@ void settlementHelpers::setGuildStanding(settlementStruct* sett, int index, int { *(int*)((sett->guildStandings) + 0x4 * index) = amount; } +settlementCapability* settlementHelpers::getSettlementCapability(settlementStruct* sett, int capabilityType) +{ + return &sett->capabilities.settlementCapabilities[capabilityType]; +} +settlementCapability* settlementHelpers::getAgentCapability(settlementStruct* sett, int agentType) +{ + return &sett->capabilities.settlementCapabilitiesAgent[agentType]; +} +settlementCapability* settlementHelpers::getAgentLimitCapability(settlementStruct* sett, int agentType) +{ + return &sett->capabilities.settlementCapabilitiesAgentLimit[agentType]; +} +recruitmentCapability* settlementHelpers::getRecruitmentCapability(settlementStruct* sett, int index) +{ + 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 b610340a2..b83d86bd2 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/settlementHelpers.h @@ -19,6 +19,12 @@ 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); + int getRecruitmentCapabilityNum(settlementStruct* sett); std::string getSettlementName(settlementStruct* sett); 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/tableList.txt b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt index 01f2b3a69..b88ffa3b5 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/tableList.txt +++ b/M2TWEOP-luaPlugin/luaPlugin/tableList.txt @@ -1,84 +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 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 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/technicalHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp index 98839f010..dc2d8ef41 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.cpp @@ -33,29 +33,34 @@ 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); } + 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 0e01ac9ac..32af90f67 100644 --- a/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h +++ b/M2TWEOP-luaPlugin/luaPlugin/technicalHelpers.h @@ -11,14 +11,15 @@ namespace technicalHelpers { - std::string unitUniStringToStr(unit*unit); + std::string unitUniStringToStr(unit* unit); void setUnitUniStr(unit* unit, const char* str); + DWORD allocateGameMem(size_t amount); std::string uniStringToStr(UNICODE_STRING**& uniString); template - std::string namedCharUniStringToStr(generalCharacterictics* genChar) + std::string namedCharUniStringToStr(namedCharacter* genChar) { if (fieldIndex == namedChar_localizedFullName) { @@ -44,10 +45,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..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(generalCharacterictics* 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 58c83bc45..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(generalCharacterictics * 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 diff --git a/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp b/M2TWEOP-luaPlugin/luaPlugin/unitHelpers.cpp index a963e86b3..47bf84815 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->targetsDone].targetUnit) + { + return posData->targetArray[posData->targetsDone].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); }; 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 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 { 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