From df875364e58e7d36433533aa532c9b4126d59a61 Mon Sep 17 00:00:00 2001 From: gynt Date: Mon, 26 Feb 2024 18:00:58 +0100 Subject: [PATCH] [MODULES/UCP-LEGACY] add resources rebuy feature --- assembly/change-ai-buywood.lua | 16 -- assembly/change-ai-wall-defenses.lua | 48 ----- assembly/change-engineer-tent-no-deselect.lua | 6 - assembly/change-fire-cooldown.lua | 30 --- assembly/change-free-trader-post.lua | 6 - assembly/change-healer.lua | 174 ---------------- .../change-increase-path-update-tick-rate.lua | 6 - assembly/change-moat-visibility.lua | 6 - assembly/change-responsive-gates.lua | 11 -- assembly/change-spearmen-run.lua | 6 - ...-ai-demolishing-inaccessible-buildings.lua | 7 - assembly/fix-ai-ox-tether-spam.lua | 6 - .../fix-ai-tower-engine-replenishment.lua | 6 - assembly/fix-ai-wood-buying.lua | 15 -- assembly/fix-baker-disappear-bug.lua | 5 - assembly/fix-fireballista.lua | 30 --- assembly/fix-fletcher-bug.lua | 5 - assembly/fix-ladderclimb.lua | 108 ---------- assembly/o-gamespeed.lua | 133 ------------- assembly/o_extreme.lua | 36 ---- assembly/o_keys.lua | 186 ------------------ init.lua | 1 + options.yml | 48 +++++ port/ai_resources_rebuy.lua | 36 ++++ 24 files changed, 85 insertions(+), 846 deletions(-) delete mode 100644 assembly/change-ai-buywood.lua delete mode 100644 assembly/change-ai-wall-defenses.lua delete mode 100644 assembly/change-engineer-tent-no-deselect.lua delete mode 100644 assembly/change-fire-cooldown.lua delete mode 100644 assembly/change-free-trader-post.lua delete mode 100644 assembly/change-healer.lua delete mode 100644 assembly/change-increase-path-update-tick-rate.lua delete mode 100644 assembly/change-moat-visibility.lua delete mode 100644 assembly/change-responsive-gates.lua delete mode 100644 assembly/change-spearmen-run.lua delete mode 100644 assembly/fix-ai-demolishing-inaccessible-buildings.lua delete mode 100644 assembly/fix-ai-ox-tether-spam.lua delete mode 100644 assembly/fix-ai-tower-engine-replenishment.lua delete mode 100644 assembly/fix-ai-wood-buying.lua delete mode 100644 assembly/fix-baker-disappear-bug.lua delete mode 100644 assembly/fix-fireballista.lua delete mode 100644 assembly/fix-fletcher-bug.lua delete mode 100644 assembly/fix-ladderclimb.lua delete mode 100644 assembly/o-gamespeed.lua delete mode 100644 assembly/o_extreme.lua delete mode 100644 assembly/o_keys.lua create mode 100644 port/ai_resources_rebuy.lua diff --git a/assembly/change-ai-buywood.lua b/assembly/change-ai-buywood.lua deleted file mode 100644 index d155331..0000000 --- a/assembly/change-ai-buywood.lua +++ /dev/null @@ -1,16 +0,0 @@ - -return { - init = function(self, config) - self.ai_buywood = core.AOBScan("3B 9E ? ? ? ? 7E 58 8B 44 24 10 5F 89 9E ? ? ? ? 5E 5D 5B 83 C4 18 C2 0C 00") - self.offset = core.readInteger(self.ai_buywood + 2) - end, - enable = function(self, config) - self.hook = core.insertCode(self.ai_buywood, 6, { - 0x83, 0xC3, 0x02, -- add ebx, 2 - 0x3B, 0x9E, self.offset, - }) - end, - disable = function(self, config) - - end, -} \ No newline at end of file diff --git a/assembly/change-ai-wall-defenses.lua b/assembly/change-ai-wall-defenses.lua deleted file mode 100644 index fe7d185..0000000 --- a/assembly/change-ai-wall-defenses.lua +++ /dev/null @@ -1,48 +0,0 @@ -return { - init = function(self, config) - self.ai_defense_group = core.AOBScan("55 E8 ? ? ? ? 8B CE 69 C9 7D 0E 00 00 03 C8 83 3C 8D ? ? ? ? 00 66 C7 83 ? ? ? ? 01") - self.groupVar = core.readInteger(self.ai_defense_group + 0x1B) - self.ai_defense_reset = core.AOBScan("B8 ? ? ? ? 8B FF 3B CA 89 90 78 05 00 00 89 10 89 90 7C 05 00 00 89 90 80 05 00 00 89 90 84 05 00 00 89 90 D0 0D") - self.somevar = core.readInteger(self.ai_defense_reset + 1) - self.defNum = core.allocate(9 * 4) - self.ai_defense_count = core.AOBScan("69 FF F4 39 00 00 8D 8F ? ? ? ? BB 01 00 00 00 01 19 E9 6B 01 00 00 69 FF F4 39 00 00 8D 8F") - self.ai_defense_check = core.AOBScan("8B 96 ? ? ? ? 3B 91 80 01 00 00 50 8B CF 7C 07 E8 ? ? ? ? EB 28 E8 ? ? ? ? EB 21 83") - end, - enable = function(self, config) - self.hook1 = core.insertCode(self.ai_defense_reset, 5, { - 0x31, 0xC0, -- xor eax, eax - 0x89, 0x14, 0x85, self.defNum, -- mov [eax*4 + defNum],edx - 0x40, -- inc eax - 0x83, 0xF8, 0x08, -- cmp eax, 8 - 0x7E, 0xF3, -- jle beneath xor - - -- original code - 0xB8, self.somevar, - }) - - self.hook2 = core.insertCode(self.ai_defense_count, 6, { - 0x8B, 0xCD, -- mov ecx, ebp - 0x69, 0xC9, 0x90, 0x04, 0x00, 0x00, -- imul ecx,ecx, 490 - 0x0F, 0xB6, 0x89, self.groupVar, -- movzx ecx,byte ptr [ecx+01388976] - - -- check if it's a wall defense unit - 0x83, 0xF9, 0x01, -- cmp ecx,01 - 0x75, 0x09, -- jne to ori code - - -- increase wall defense count for this AI - 0x8D, 0x0C, 0xBD, self.defNum, -- lea ecx,[edi*4 + ai_defNum] - 0xFF, 0x01, -- inc [ecx] - - -- ori code - 0x69, 0xFF, 0xF4, 0x39, 0x00, 0x00, -- imul edi, edi, 39F4 - }) - - self.hook3 = core.insertCode(self.ai_defense_check, 6, { - 0x8B, 0x54, 0x24, 0x04, -- mov edx,[esp+04] - 0x8B, 0x14, 0x95, self.defNum, -- mov edx,[edx*4 + defNum] - }) - end, - disable = function(self, config) - end, - -} \ No newline at end of file diff --git a/assembly/change-engineer-tent-no-deselect.lua b/assembly/change-engineer-tent-no-deselect.lua deleted file mode 100644 index 718613f..0000000 --- a/assembly/change-engineer-tent-no-deselect.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x0044612B -writeCode(scanForAOB("89 2D ? ? ? ? 5D 5B 83 C4 08 C3 57 55 B9 ? ? ? ? C7 05 ? ? ? ? 02 00 00 00 E8"), {0x90, 0x90, 0x90, 0x90, 0x90, 0x90}) \ No newline at end of file diff --git a/assembly/change-fire-cooldown.lua b/assembly/change-fire-cooldown.lua deleted file mode 100644 index da9e7e7..0000000 --- a/assembly/change-fire-cooldown.lua +++ /dev/null @@ -1,30 +0,0 @@ -local writeCode = core.writeCode -local readSmallInteger = core.readSmallInteger -local smallIntegerToBytes = utils.smallIntegerToBytes -local AOBScan = core.AOBScan - -return { - - init = function(self, config) - local address = AOBScan("66 C7 84 30 D8 02 00 00 D0 07 0F B7 80 ? ? ? ? 66 3D 1E 00 89 4C 24 18 75 05 8D 5F 09 EB 25") - - self.target_address = address + 8 - self.originalValue = readSmallInteger(self.target_address) - - end, - - enable = function(self, config) - -- o_firecooldown={ o_firecooldown={False;2000} } - if config.o_firecooldown.o_firecooldown[1] then - local value = config.o_firecooldown.o_firecooldown[2] - writeCode(self.target_address, smallIntegerToBytes(value)) - else - writeCode(self.target_address, smallIntegerToBytes(self.originalValue)) - end - end, - - disable = function(self, config) - writeCode(self.target_address, smallIntegerToBytes(self.originalValue)) - end, - -} \ No newline at end of file diff --git a/assembly/change-free-trader-post.lua b/assembly/change-free-trader-post.lua deleted file mode 100644 index 8b1baac..0000000 --- a/assembly/change-free-trader-post.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x005C23D8 -writeCode(scanForAOB("05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 64 00 00 00 0A 00 00 00"), {0x00}) \ No newline at end of file diff --git a/assembly/change-healer.lua b/assembly/change-healer.lua deleted file mode 100644 index adbecc6..0000000 --- a/assembly/change-healer.lua +++ /dev/null @@ -1,174 +0,0 @@ -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB -local readInteger = core.readInteger -local allocateCode = core.allocateCode -local allocate = core.allocate -local calculateCodeSize = core.calculateCodeSize -local compile = core.compile -local insertCode = core.insertCode - -local itob = utils.itob -local getRelativeAddress = core.getRelativeAddress - --- TODO: part 2 - ----[[ - -local random_block = "0F BF 05 ? ? ? ? 99 F7 FF B9 ? ? ? ? 8B FA E8 ? ? ? ? 8B 76 08 B8 01 00 00 00 3B F0 7E 3B 8B 6C 24 14 8B CB 8B 5C 24 18 90 0F B7 11 66 85 D2" -local random_address = scanForAOB(random_block) -local random_random = readInteger(random_address + 3) -local random_randomecx = readInteger(random_address + 0xB) -local random_randomcall = (random_address + 0x12 - 1) + readInteger(random_address + 0x12) + 5 - -local GetRandomShort_code = { - 0xB9, itob(random_randomecx), -- mov ecx, randomecx - 0xE8, function(index) - return itob(getRelativeAddress(index, random_randomcall, -5 + 1)) - end, -- call refreshrandom - 0x0F, 0xBf, 0x05, itob(random_random), -- movsx eax,[random] - 0xC3 -- ret -} - -local GetRandomShort = allocateCode(calculateCodeSize(GetRandomShort_code)) -writeCode(GetRandomShort, compile(GetRandomShort_code, GetRandomShort)) - -local o_healer_plague_block = "83 EC 08 53 55 57 8B 7C 24 18 69 FF 90 04 00 00 8B 97 ? ? ? ? 0F BF 14 55 ? ? ? ? 33 C0" -local o_healer_plague_address = scanForAOB(o_healer_plague_block) -local pvar1 = readInteger(o_healer_plague_address + 0xFF) -local pvar2 = readInteger(o_healer_plague_address + 0x119) -local pvar3 = readInteger(o_healer_plague_address + 0x120) -local presult = readInteger(o_healer_plague_address + 0x133) - -local o_healer_find_block = "83 EC 08 53 55 33 C0 8B E9 BB 01 00 00 00 39 5D 00 89 44 24 0C 89 44 24 08 0F 8E F9 00 00 00 56" - -local o_healer_find_address = scanForAOB(o_healer_find_block) -local fvar2 = readInteger(o_healer_find_address + 0xBB) -local distfunc = (o_healer_find_address + 0xC0 - 1) + readInteger(o_healer_find_address + 0xC0) + 5 - -local healerbool_address = allocate(1) - -local healer_find_code = { - 0x83, 0xEC, 0x08, -- - sub esp,08 { 8 } - 0x53, -- - push ebx - 0x55, -- - push ebp - 0x33, 0xC0, -- - xor eax,eax - 0x8B, 0xE9, -- - mov ebp,ecx - 0xBB, 0x01, 0x00, 0x00, 0x00, -- - mov ebx,00000001 { 1 } - 0x39, 0x5D, 0x00, -- - cmp [ebp+00],ebx - 0x89, 0x44, 0x24, 0x0C, -- - mov [esp+0C],eax - 0xC7, 0x44, 0x24, 0x08, 0xFF, 0xFF, 0xFF, 0x7F, -- - mov [esp+08],0x7FFFFFFF - 0x0F, 0x8E, 0xEB, 0x00, 0x00, 0x00, -- - jng end - - 0x56, -- - push esi - 0x57, -- - push edi - 0x8D, 0xBD, 0x44, 0x0D, 0x00, 0x00, -- - lea edi,[ebp+00000D44] - - -- CHECK NPC - 0x66, 0x83, 0xBF, 0xEC, 0xFD, 0xFF, 0xFF, 0x02, -- - cmp word ptr [edi-00000214],02 { 2 } - 0x0F, 0x85, 0x9C, 0x00, 0x00, 0x00, -- - jne 0053467F - - - -- CHECK ALIVE? - 0x66, 0x83, 0x3F, 0x00, -- - cmp word ptr [edi],00 { 0 } - 0x0F, 0x85, 0x92, 0x00, 0x00, 0x00, -- - jne 0053467F - - -- CHECK TEAM - 0x0F, 0xBF, 0x87, 0xF6, 0xFD, 0xFF, 0xFF, -- - movsx eax,word ptr [edi-0000020A] - 0x3B, 0x44, 0x24, 0x20, -- - cmp eax,[esp+20] - 0x0F, 0x85, 0x81, 0x00, 0x00, 0x00, -- - jne 0053467F - - -- CHECK HEALTH - 0x8B, 0x87, 0x28, 0x01, 0x00, 0x00, -- mov eax, [edi+128] - 0x3B, 0x87, 0x2C, 0x01, 0x00, 0x00, -- cmp eax, [edi+12C] - 0x7D, 0x73, -- jge end - - -- CHECK EXCLUDE - 0x8B, 0x44, 0x24, 0x1C, -- mov eax, [esp+1C] - 0x39, 0xC3, -- - cmp ebx,eax - 0x74, 0x6B, -- - je 0053467F - - -- CHECK DISTANCE - 0x69, 0xC0, 0x90, 0x04, 0x00, 0x00, -- - imul eax,eax,490 - 0x0F, 0xBF, 0x80, itob(pvar1), -- movsx, eax, word ptr [eax+pvar1] - 0x85, 0xC0, -- test eax, eax - 0x74, 0x3B, -- je skip dist check - - -- self pos - 0x0F, 0xBF, 0x8F, 0x26, 0xFE, 0xFF, 0xFF, -- movsx ecx,word ptr [edi-000001DA] - 0x0F, 0xBF, 0x97, 0x24, 0xFE, 0xFF, 0xFF, -- movsx edx,word ptr [edi-000001DC] - - 0x51, -- - push ecx - 0x52, -- - push edx - - 0x69, 0xC0, 0x2C, 0x03, 0x00, 0x00, -- - imul eax,eax,0000032C { 812 } - 0x0F, 0xBF, 0x90, itob(pvar2), -- movsx edx,word ptr [eax+00F98624] - 0x0F, 0xBF, 0x80, itob(pvar3), -- - movsx eax,word ptr [eax+00F98622] - 0x52, -- - push edx - 0x50, -- - push eax - 0xB9, itob(fvar2), -- - mov ecx,00EE23BC { [00000000] } - 0xE8, function(index) - return itob(getRelativeAddress(index, distfunc, -5 + 1)) - end, -- - call 0046CC80. - 0x8B, 0x35, itob(presult), -- mov esi, [presult] - 0x83, 0xFE, 0x28, -- cmp esi, 28 - 0x7F, 0x1F, -- - jg 0040184D -- too far away - - -- first time ? jump over - 0x83, 0x7C, 0x24, 0x2C, 0x00, -- - cmp dword ptr [esp+2C],00 - 0x74, 0x0A, -- - je 00534671 - - -- continued ? add some randomness - 0xE8, function(index) - return itob(getRelativeAddress(index, GetRandomShort, -5 + 1)) - end, -- call getrandomshort. - 0xC1, 0xF8, 0x0C, -- sar eax, C - 0x01, 0xC6, -- add esi, eax - - - 0x3B, 0x74, 0x24, 0x10, -- - cmp esi,[esp+10] - 0x7D, 0x08, -- - jge 0053467F - 0x89, 0x74, 0x24, 0x10, -- - mov [esp+10],esi - 0x89, 0x5C, 0x24, 0x14, -- - mov [esp+14],ebx - - 0x83, 0xC3, 0x01, -- - add ebx,01 { 1 } - 0x81, 0xC7, 0x90, 0x04, 0x00, 0x00, -- - add edi,00000490 { 1168 } - 0x3B, 0x5D, 0x00, -- - cmp ebx,[ebp+00] - 0x0F, 0x8C, 0x44, 0xFF, 0xFF, 0xFF, -- - jl 005345D0 - - 0x8B, 0x44, 0x24, 0x14, -- - mov eax,[esp+14] - 0x85, 0xC0, -- - test eax,eax - 0x5F, -- - pop edi - 0x5E, -- - pop esi - 0x74, 0x1D, -- - je 005346B8 - 0x8B, 0x15, 0xA8, 0x7D, 0xFE, 0x01, -- - mov edx,[01FE7DA8] { [0000F19D] } - 0x8B, 0xC8, -- - mov ecx,eax - 0x69, 0xC9, 0x90, 0x04, 0x00, 0x00, -- - imul ecx,ecx,00000490 { 1168 } - 0x89, 0x94, 0x29, 0x44, 0x09, 0x00, 0x00, -- - mov [ecx+ebp+00000944],edx - 0x5D, -- - pop ebp - 0x5B, --- pop ebx - 0x83, 0xC4, 0x08, --- add esp,08 { 8 } - 0xC2, 0x18, 0x00, --- ret 0018 { 24 } - 0x5D, --- pop ebp - 0x33, 0xC0, -- - xor eax,eax - 0x5B, -- - pop ebx - 0x83, 0xC4, 0x08, -- - add esp,08 { 8 } - 0xC2, 0x18, 0x00, -- - ret 0018 { 24 } -} - -local healer_find_address = allocateCode(calculateCodeSize(healer_find_code)) -local c = compile(healer_find_code, healer_find_address) - -writeCode(healer_find_address, c) - -local hook_address = insertCode(o_healer_find_address, 5, { - 0x80, 0x3D, itob(healerbool_address), 0x01, -- cmp [healerbool], 1 - -- this relative jump is bullshit. `index` is not a proper memory address, while `healer_find_address` is. - 0x0F, 0x84, function(index) - return itob(getRelativeAddress(index, healer_find_address, -6 + 2)) - end, -- je - 0x83, 0xEC, 0x08, -- sub esp, 0x8 - 0x53, -- push ebx - 0x55, -- push ebp -}) - ---]] \ No newline at end of file diff --git a/assembly/change-increase-path-update-tick-rate.lua b/assembly/change-increase-path-update-tick-rate.lua deleted file mode 100644 index c55606c..0000000 --- a/assembly/change-increase-path-update-tick-rate.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x00499605 -writeCode(scanForAOB("3B C1 A3 ? ? ? ? 7E 0A 5E 33 C0 5B 8B E5 5D C2 04 00 C7 05 ? ? ? ? C8 00 00 00 39 4E 6C")+25, {0x32}) \ No newline at end of file diff --git a/assembly/change-moat-visibility.lua b/assembly/change-moat-visibility.lua deleted file mode 100644 index bd88807..0000000 --- a/assembly/change-moat-visibility.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x004EC86C -writeCode(scanForAOB("8B CB C7 05 ? ? ? ? FF FF FF FF E8 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 5F 5E 89 2D ? ? ? ? 89 2D ? ? ? ? 5D 5B 83 C4 64 C3") + 36, {0x15}) \ No newline at end of file diff --git a/assembly/change-responsive-gates.lua b/assembly/change-responsive-gates.lua deleted file mode 100644 index 639c138..0000000 --- a/assembly/change-responsive-gates.lua +++ /dev/null @@ -1,11 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- Gates closing distance to enemy = 200 --- 0x422ACC + 2 -writeCode(scanForAOB("C8 00 00 00 7C 61 8B 4C 24 28 8B 44 24 2C 83 C6 01 83 C0 02 83 C5 04 3B F1 89 44 24 2C 7C 83 66"), {0x8C, 0x00, 0x00, 0x00}) - --- Gates closing time after enemy leaves = 1200 --- 0x422B35 + 7 (ushort) -writeCode(scanForAOB("B0 04 80 BF ? ? ? ? 00 75 CE 6A 00 C6 87 ? ? ? ? 0A 66 C7 87 ? ? ? ? 0A 00 6A 00 EB"), {0x64, 0x00}) \ No newline at end of file diff --git a/assembly/change-spearmen-run.lua b/assembly/change-spearmen-run.lua deleted file mode 100644 index bc88718..0000000 --- a/assembly/change-spearmen-run.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x0055E07E -writeCode(scanForAOB("74 13 C7 86 ? ? ? ? 81 00 00 00 66 89 86 ? ? ? ? EB 0D 89 86 ? ? ? ? 66 89 BE"), {0x90, 0x90}) -- remove je \ No newline at end of file diff --git a/assembly/fix-ai-demolishing-inaccessible-buildings.lua b/assembly/fix-ai-demolishing-inaccessible-buildings.lua deleted file mode 100644 index e22c0c6..0000000 --- a/assembly/fix-ai-demolishing-inaccessible-buildings.lua +++ /dev/null @@ -1,7 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - - --- 0x004242C3 -writeCode(scanForAOB("75 07 66 C7 06 03 00 EB 12 83 F8 02 75 07 66 C7 06 03 00 EB 06 66 83 3E 03 75 14 0F BF 56 20 0F"), {0xEB}) \ No newline at end of file diff --git a/assembly/fix-ai-ox-tether-spam.lua b/assembly/fix-ai-ox-tether-spam.lua deleted file mode 100644 index c196d25..0000000 --- a/assembly/fix-ai-ox-tether-spam.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x004EFF9A -writeCode(scanForAOB("0F 85 B0 00 00 00 8B 86 ? ? ? ? 8B 8E ? ? ? ? 8B 15 ? ? ? ? 50 51 8B CE 89 54 24 18"), {0x90, 0xE9}) \ No newline at end of file diff --git a/assembly/fix-ai-tower-engine-replenishment.lua b/assembly/fix-ai-tower-engine-replenishment.lua deleted file mode 100644 index d13bcb4..0000000 --- a/assembly/fix-ai-tower-engine-replenishment.lua +++ /dev/null @@ -1,6 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - --- 0x004D20A2 -writeCode(scanForAOB("7E 0A C7 44 24 24 03 00 00 00 EB 12 3B FD 0F 8E 0B 03 00 00 EB 08 8D A4 24 00 00 00 00 90 8B 80"), {0xEB}) \ No newline at end of file diff --git a/assembly/fix-ai-wood-buying.lua b/assembly/fix-ai-wood-buying.lua deleted file mode 100644 index 6c7b018..0000000 --- a/assembly/fix-ai-wood-buying.lua +++ /dev/null @@ -1,15 +0,0 @@ -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - - --- 0x00457DF4 -local hook1Address = scanForAOB("3B 9E ? ? ? ? 7E 58 8B 44 24 10 5F 89 9E ? ? ? ? 5E 5D 5B 83 C4 18 C2 0C 00") -local offset = hook1Address + 2 - --- allocate 12 bytes and hook with 6 bytes at hook1Address -local newCodeAddress = assemblyHook(hook1Address, 12, 6) - -writeCode(newCodeAddress, { - 0x81, 0xC3, 0x02, 0x00, 0x00, 0x00, -- add ebx,02 - 0x3B, 0x9E, offset -- cmp ebx, DWORD PTR[esi+offset] -}) \ No newline at end of file diff --git a/assembly/fix-baker-disappear-bug.lua b/assembly/fix-baker-disappear-bug.lua deleted file mode 100644 index a84727d..0000000 --- a/assembly/fix-baker-disappear-bug.lua +++ /dev/null @@ -1,5 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - -writeCode(scanForAOB("5E 5D 5B C3 8B 0D ? ? ? ? 69 C9 90 04 00 00 5F 5E 5D 66 C7 81 ? ? ? ? 03 00 5B C3")+19, {0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}) \ No newline at end of file diff --git a/assembly/fix-fireballista.lua b/assembly/fix-fireballista.lua deleted file mode 100644 index d3a21b0..0000000 --- a/assembly/fix-fireballista.lua +++ /dev/null @@ -1,30 +0,0 @@ -local byteRelTo = core.byteRelTo -local writeCode = core.writeCode -local insertCode = core.insertCode -local AOBScan = core.AOBScan - -return { - init = function(self, config) - self.u_fireballistatunneler = AOBScan("83 F8 25 75 4C") + 13 - self.u_fireballistamonk = AOBScan("04 04 02 02 02 04 04 04 04 04 04 04 04 04 04 04 04 04 03 04 04 02 02 02 02 04 04 04 04 04 04 04") - end, - enable = function(self, config) - local hookCode = { - 0x83, 0xF8, 5, -- cmp eax, 5 - 0x9C, -- pushf - 0x83, 0xc0, 0xea, -- add eax, 0xffffffea - 0x9d, --popf - 0x75, byteRelTo("label_1", -2 + 1), -- jne 5 - 0xB8, 0x05, 0x00, 0x00, 0x00, -- mov eax, 0x5 - "label_1", - 0x83, 0xF8, 0x25, -- cmp eax, 0x25 - } - self.hookAddress = insertCode(self.u_fireballistatunneler, 6, hookCode) - - self.patch = writeCode(self.u_fireballistamonk, { 0x00 }) - end, - - disable = function(self, config) - end, - -} \ No newline at end of file diff --git a/assembly/fix-fletcher-bug.lua b/assembly/fix-fletcher-bug.lua deleted file mode 100644 index 9eeea9b..0000000 --- a/assembly/fix-fletcher-bug.lua +++ /dev/null @@ -1,5 +0,0 @@ - -local writeCode = core.writeCode -local scanForAOB = core.scanForAOB - -writeCode(scanForAOB("E8 ? ? ? ? 85 C0 74 19 A1 ? ? ? ? 69 C0 90 04 00 00 5F 5E 5D 66 C7 80 ? ? ? ? 03 00 5B C3")+30, {0x01}) \ No newline at end of file diff --git a/assembly/fix-ladderclimb.lua b/assembly/fix-ladderclimb.lua deleted file mode 100644 index be00792..0000000 --- a/assembly/fix-ladderclimb.lua +++ /dev/null @@ -1,108 +0,0 @@ -local scanForAOB = core.scanForAOB -local insertCode = core.insertCode -local allocate = core.allocate -local allocateCode = core.allocateCode - -return { - init = function(self, config) - - self.currentUnitMoved = allocate(4) - self.savedUnitDestinationForClimbing = allocate(120000) - - -- 0x0053D3D0 + 9 - self.hook1Address = scanForAOB("83 EC 08 8B 44 24 0C 8B D0 69 D2 90 04 00 00") + 9 - - -- 0x0053D688 + 12 - self.hook2Address = scanForAOB("50 52 B9 ? ? ? ? E8 ? ? ? ? 66 3B C3 66 89 86 BC 08 00 00 74") + 12 - -- 0x005790CB - self.hook3Address = scanForAOB("66 89 8C 37 00 07 00 00 66 89 94 37 02 07 00 00") - - -- 0x0053D900 - self.hook4Address = scanForAOB("53 8B 5C 24 08 8B C3 55 69 C0") - - -- 0x0054C3E5 - self.hook5Address = scanForAOB("0F BF 96 02 07 00 00 0F BF 86 00 07 00 00 66 8B 8E 8A 09 00 00") - - end, - enable = function(self, config) - - -- allocate 12 bytes and hook with 6 bytes at hook1Address - self.hook1NewCodeAddress = insertCode(self.hook1Address, 6, { - 0x89, 0x15, self.currentUnitMoved, -- mov [currentUnitMoved],edx - 0x69, 0xD2, 0x90, 0x04, 0x00, 0x00 - }) - - - -- allocate 54 bytes and hook with 10 bytes at hook2Address - self.hook2NewCodeAddress = insertCode(self.hook2Address, 10, { - 0x50, -- push eax - 0xA1, self.currentUnitMoved, -- mov eax,[currentUnitMoved] - 0x83, 0xF8, 0x00, -- cmp eax,00 - 0x74, 0x20, -- je short 20 - 0x48, -- dec eax - 0x6B, 0xC0, 0x0C, -- imul eax,eax,0C - 0x89, 0xA8, self.savedUnitDestinationForClimbing, -- mov [eax+savedUnitDestinationForClimbing],ebp - 0x83, 0xC0, 0x04, -- add eax,04 - 0x89, 0xB8, self.savedUnitDestinationForClimbing, -- mov [eax+savedUnitDestinationForClimbing],edi - 0x83, 0xC0, 0x04, -- add eax,04 - 0xC7, 0x80, self.savedUnitDestinationForClimbing, 0x01, 0x00, 0x00, 0x00, -- mov [eax+savedUnitDestinationForClimbing],01 - 0x58, -- pop eax - 0x66, 0x39, 0xD8, -- cmp ax,bx - 0x66, 0x89, 0x86, 0xBC, 0x08, 0x00, 0x00, -- mov [esi+8BC],ax - }) - - - -- allocate 52 bytes and hook with 16 bytes at hook3Address - self.hook3NewCodeAddress = insertCode(self.hook3Address, 16, { - 0x50, -- push eax - 0x8B, 0xC3, -- mov eax,ebx - 0x48, -- dec eax - 0x6B, 0xC0, 0x0C, -- imul eax,eax,0C - 0x83, 0xC0, 0x08, -- add eax,08 - 0x83, 0xB8, self.savedUnitDestinationForClimbing, 0x00, -- cmp dword ptr [eax+savedUnitDestinationForClimbing],00 - 0x75, 0x13, -- jne short 0x13 - 0x58, -- pop eax - 0x66, 0x89, 0x8C, 0x3E, 0x00, 0x07, 0x00, 0x00, -- mov [esi+edi+00000700],cx - 0x66, 0x89, 0x94, 0x3E, 0x02, 0x07, 0x00, 0x00, -- mov [esi+edi+00000702],dx - 0xEB, 0x0B, -- jmp short exit - 0xC7, 0x80, self.savedUnitDestinationForClimbing, 0x00, 0x00, 0x00, 0x00, -- mov [eax+savedUnitDestinationForClimbing],00000000 - 0x58-- pop eax - }) - - - -- allocate 26 bytes and hook with 5 bytes at hook4Address - self.hook4NewCodeAddress = insertCode(self.hook4Address, 5, { - 0x50, -- push eax - 0x8B, 0xC3, -- mov eax,ebx - 0x48, -- dec eax - 0x6B, 0xC0, 0x0C, -- imul eax,eax,0C - 0x83, 0xC0, 0x08, -- add eax,08, - 0xC7, 0x80, self.savedUnitDestinationForClimbing, 0x01, 0x00, 0x00, 0x00, -- mov [eax+savedUnitDestinationForClimbing],00000000 - 0x58, -- pop eax - 0x53, -- push ebx - 0x8B, 0x5C, 0x24, 0x08, -- mov ebx,[esp+08] - }) - - - -- allocate 54 bytes and hook with 14 bytes at hook5Address - self.hook5NewCodeAddress = insertCode(self.hook5Address, 14, { - 0x57, -- push edi - 0x31, 0xFF, -- xor edi,edi - 0x66, 0x8B, 0x7C, 0x24, 0x18, -- mov di,[esp+18] - 0x4F, -- dec edi - 0x6B, 0xFF, 0x0C, -- imul edi,edi,0C - 0x8B, 0x87, self.savedUnitDestinationForClimbing, -- mov eax,[edi+savedUnitDestinationForClimbing] - 0x83, 0xC7, 0x04, -- add edi,04 - 0x8B, 0x97, self.savedUnitDestinationForClimbing, -- mov edx,[edi+savedUnitDestinationForClimbing] - 0x89, 0x86, 0x00, 0x07, 0x00, 0x00, -- mov [esi+00000700],eax - 0x89, 0x96, 0x02, 0x07, 0x00, 0x00, -- mov [esi+00000702],edx - 0x0F, 0xBF, 0x96, 0x02, 0x07, 0x00, 0x00, -- movsx edx,word ptr [esi+00000702] - 0x0F, 0xBF, 0x86, 0x00, 0x07, 0x00, 0x00, -- movsx edx,word ptr [esi+00000702] - 0x5F, -- pop edi - }) - - end, - disable = function(self, config) - error("not implemented") - end, -} diff --git a/assembly/o-gamespeed.lua b/assembly/o-gamespeed.lua deleted file mode 100644 index b49563a..0000000 --- a/assembly/o-gamespeed.lua +++ /dev/null @@ -1,133 +0,0 @@ -local writeCode = core.writeCode -local AOBScan = core.AOBScan -local compile = core.compile -local calculateCodeSize = core.calculateCodeSize -local allocateCode = core.allocateCode -local itob = utils.itob -local getRelativeAddress = core.getRelativeAddress -local relTo = core.relTo -local byteRelTo = core.byteRelTo - ---[[ - /* - * EXTENDED GAME SPEED - */ - - new Change("o_gamespeed", ChangeType.Other) - { - new DefaultHeader("o_gamespeed") - { - // 4B4748 - new BinaryEdit("o_gamespeed_up") - { - CMP(EAX, 10000), // cmp eax, 10000 - - JMP(GREATERTHANEQUALS, 0x19), // jge to end - - MOV(EDI, EAX), // mov edi, eax - - CMP(EAX, 200), // cmp eax, 200 - new BinHook("label1", 0x0F, 0x8C) // jl hook - { - CMP(EAX, 90), // cmp eax, 90 - JMP(LESS, 0x03), // jl to end - ADD(EDI, 5), // add edi, 5 - }, - ADD(EDI, 0x5F), // add edi, 95 - new BinLabel("label1"), - ADD(EDI, 5), // add edi, 5 - JMP(UNCONDITIONAL, 0x75), // jmp to gamespeed_down set value - new BinBytes(0x90, 0x90, 0x90, 0x90), - }, - - // 004B47C2 - new BinaryEdit("o_gamespeed_down") - { - JMP(LESSTHANEQUALS, 0x1B), // jle to end - - MOV(EDI, EAX), // mov edi, eax - - CMP(EAX, 200), // cmp eax, 200 - new BinHook("label2", 0x0F, 0x8E) // jle hook - { - CMP(EAX, 0x5A), // cmp eax, 90 - JMP(LESSTHANEQUALS, 0x03), // jle to end - SUB(EDI, 0x05), // sub edi, 5 - }, - SUB(EDI, 0x5F), // sub edi, 95 - new BinLabel("label2"), - SUB(EDI, 5), // sub edi, 5 - new BinBytes(0x90, 0x90), - } - } - }, ---]] - -return { - - init = function(self, config) - self.o_gamespeed_up = AOBScan("83 F8 5A 0F 8D ? ? ? ? 83 C0 05 83 F8 5A A3 ? ? ? ? 7E 0A C7 05 ? ? ? ? 5A 00 00 00") - self.o_gamespeed_down = AOBScan("0F 8E 0B F4 FF FF 83 E8 05 BF 14 00 00 00 3B C7 A3 ? ? ? ? 7D 8F 89 3D ? ? ? ? EB 87 3D") - end, - - enable = function(self, config) - local code_up = { - 0x3D, 0x10, 0x27, 0x00, 0x00, -- cmp eax, 10000 - 0x7D, byteRelTo("end", -2 + 1), -- 0x7D, 0x19, -- jge end - 0x89, 0xc7, -- mov edi, eax - 0x3d, 0xc8, 0x00, 0x00, 0x00, -- cmp eax, 200 - 0x0f, 0x8c, function(address, index, labels) - -- jl hook - local hook = { - 0x83, 0xf8, 0x5a, -- cmp eax, 0x5A - 0x7C, byteRelTo("endOfHook", -2 + 1), -- 0x7C, 0x03, -- jl endOfHook; jump 3 bytes - 0x83, 0xc7, 0x05, -- add edi, 0x05 - "endOfHook", - 0xe9, relTo(labels["label1"], -5 + 1), -- jmp label1, 'labels["label1"]' is the absolute address of label1; JMP (0xe9) does 5 bytes "too many", so we need to adjust 4 of them. - } - local hookSize = calculateCodeSize(hook) - local hookAddress = allocateCode(hookSize) - writeCode(hookAddress, hook) -- compiled by writeCode - return itob(getRelativeAddress(address, hookAddress, -6 + 2)) -- return the relative address for the 'jl hook' statement; ; JL (0x0f, 0x8c) does 6 bytes too many, so we need to adjust 4 of them. - end, - 0x83, 0xC7, 0x5F, -- add edi, 95 - "label1", - 0x83, 0xc7, 0x05, -- add edi, 5 - 0xEB, 0x75, -- jmp to gamespeed_down set value - 0x90, 0x90, 0x90, 0x90, -- nop nop nop nop - "end" - } - writeCode(self.o_gamespeed_up, code_up) - - local code_down = { - 0x7E, byteRelTo("end", -2 + 1), -- 0x7E, 0x1B, -- jle end - 0x89, 0xc7, -- mov edi, eax - 0x3D, 0xC8, 0x00, 0x00, 0x00, -- cmp eax, 200 - 0x0F, 0x8E, function(address, index, labels) - -- jle hook - local hook = { - 0x83, 0xf8, 0x5a, -- cmp eax, 90 - 0x7E, byteRelTo("endOfHook", -2 + 1), -- 0x7E, 0x03, -- jle endOfHook; jump 3 bytes - 0x83, 0xEF, 0x05, -- sub edi, 0x05 - "endOfHook", - 0xe9, relTo(labels["label2"], -5 + 1), - } - local hookSize = calculateCodeSize(hook) - local hookAddress = allocateCode(hookSize) - writeCode(hookAddress, hook) -- compiled by writeCode - return itob(getRelativeAddress(address, hookAddress, -6 + 2)) - end, - 0x83, 0xEF, 0x5F, -- sub edi, 95 - "label2", - 0x83, 0xEF, 0x05, -- sub edi, 5 - 0x90, 0x90, -- nop nop - "end" - } - writeCode(self.o_gamespeed_down, code_down) - end, - - disable = function(self, config) - error("not implemented") - end, - -} \ No newline at end of file diff --git a/assembly/o_extreme.lua b/assembly/o_extreme.lua deleted file mode 100644 index 38e23f4..0000000 --- a/assembly/o_extreme.lua +++ /dev/null @@ -1,36 +0,0 @@ -local writeCode = core.writeCode -local readBytes = core.readBytes -local AOBScan = core.AOBScan - -return { - - init = function(self, config) - if config.o_xtreme.o_xtreme[1] then - self.extreme_bar_1 = AOBScan("B9 ? ? ? ? E8 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 53 B9 ? ? ? ? E8 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? 53 B9 ? ? ? ? E8 ? ? ? ? B9") - self.extreme_bar_2 = AOBScan("A1 ? ? ? ? 85 C0 74 12 83 F8 63 74 0D 83 3D ? ? ? ? 00 0F 85 F2 00 00 00 A1") - end - end, - - enable = function(self, config) - if config.o_xtreme.o_xtreme[1] then - self.o1 = readBytes(self.extreme_bar_1, 10) - - local nops = {} - for i = 1, 10 do - table.insert(nops, 0x90) - end - writeCode(self.extreme_bar_1, nops) - - self.o2 = readBytes(self.extreme_bar_2, 1) - - writeCode(self.extreme_bar_2, { 0xC3 }) - end - end, - - disable = function(self, config) - writeCode(self.extreme_bar_1, self.o1) - writeCode(self.extreme_bar_2, self.o2) - end, - - -} \ No newline at end of file diff --git a/assembly/o_keys.lua b/assembly/o_keys.lua deleted file mode 100644 index d7ea336..0000000 --- a/assembly/o_keys.lua +++ /dev/null @@ -1,186 +0,0 @@ -local parts = { - o_keys_savefunc = { - - init = function(self, config, root) - self.o_keys_savefunc = AOBScan("8B 44 24 04 F7 D8 1B C0 83 E0 0E 83 C0 20 6A 0E B9 ? ? ? ? A3 ? ? ? ? E8 ? ? ? ? C7") - self.self = self.o_keys_savefunc + 17 - self.c1 = self.o_keys_savefunc + 22 - self.func = readInteger(self.o_keys_savefunc + 27) + (self.o_keys_savefunc + 27) -- relative address - self.savefunc = readInteger(self.o_keys_savefunc + 50) + (self.o_keys_savefunc + 50) -- relative address - end, - - enable = function(self, config, root) - local code = { - 0x8B, 0x44, 0x24, 0x04, -- mov eax, [esp+4] - 0xA3, self.c1, -- mov [c1], eax - 0xB9, self.self, -- mov ecx, self - 0x6A, 0x0E, -- push E - 0xE8, relTo(self.func), -- call func - 0xE9, relTo(self.savefunc), -- jmp to save - } - local codeSize = calculateCodeSize(code) - self.DoSave = allocateCode(codeSize) - writeCode(self.DoSave, compile(code, self.DoSave)) - - end, - - disable = function(self, config, root) - end, - - }, - o_keys_savename = { - - init = function(self, config, root) - self.o_keys_savename = AOBScan("83 79 04 00 75 03 33 C0 C3 8B 01 69 C0 ? ? ? ? 8D 84 08 ? ? ? ? C3") - self.namebool = allocate(1, true) - local namedata = string.byte("Quicksave", 1, -1) - table.insert(namedata, 0) - self.name = allocate(#namedata) - writeBytes(self.name, namedata) - end, - - enable = function(self, config, root) - local code = { - 0x80, 0x3D, self.namebool, 0x00, -- cmp byte ptr [namebool], 0 - 0x74, 0x06, -- je to ori code - 0xB8, self.name, -- mov eax, quicksave - 0xC3, -- ret - -- ori code: - 0x83, 0x79, 0x04, 0x00, 0x75, 0x03, 0x33, 0xC0, 0xC3, - } - self.binhook = insertCode(self.o_keys_savename, 9, code) - end, - - disable = function(self, config, root) - end, - - }, - o_keys_s = { - init = function(self, config, root) - self.address = scanForAOB("A1 ? ? ? ? 8B 0C 85 ? ? ? ? 3B CB 74 2B 8B C1 69 C0 2C 03 00 00 0F BF 88") - self.ctrl = self.address + 0x106 - end, - - enable = function(self, config, root) - self.writeCode(self.address, compile({ - 0x39, 0x1D, self.ctrl, -- cmp [ctrlpressed], ebx = 0 - 0x0F, 0x84, 0xFA, 0xF3, 0xFF, 0xFF, -- jmp to move if equal - - 0xC6, 0x05, root.o_keys_savename.namebool, 0x01, - - 0x6A, 0x20, -- push 0x20 - 0xE8, relTo(root.o_keys_savefunc.DoSave, -5 + 1), -- call save func - - - 0xC6, 0x05, root.o_keys_savename.namebool, 0x00, - - 0x58, -- pop eax - 0xEB, 0x53 -- jmp to default/end 4B3BD3 - })) - end, - - disable = function(self, config, root) - - end, - - }, - o_keys_loadname = { - init = function(self, config, root) - self.address = AOBScan("8B 44 24 04 3D F4 01 00 00 7C 05 33 C0 C2 04 00 69 C0 ? ? ? ? 8D 84 08 ? ? ? ? C2 04 00") - self.someoffset = self.address + 25 - - end, - - enable = function(self, config, root) - self.hook = insertCode(self.address, 9, { - 0x80, 0x3D, root.o_keys_savename.namebool, 0x00, -- cmp byte ptr [namebool], 0 - 0x74, 0x08, -- je to ori code - 0xB8, root.o_keys_savename.name, -- mov eax, quicksave - 0xC2, 0x04, 0x00, -- ret - - -- ori code: - 0x8B, 0x44, 0x24, 0x04, 0x3D, 0xF4, 0x01, 0x00, 0x00, - - }) - end, - - disable = function(self, config, root) - - end, - - }, - o_keys_l = { - init = function(self, config, root) - self.address = AOBScan("39 1D ? ? ? ? 75 63 8B 0D ? ? ? ? 8B C1 69 C0 F4 39 00 00 8B 80 ? ? ? ? 3B C3") - self.somevar = self.address + 0x02 - self.default = readInteger(self.address + 0x20) + (self.address + 0x20) -- relative address - end, - - enable = function(self, config, root) - self.hook = insertCode(self.address, 6, { - 0x39, 0x1D, root.o_keys_s.ctrl, -- cmp [ctrlpressed], ebx = 0 - 0x74, 0x1B, -- je to ori code - - 0xC6, 0x05, root.o_keys_savename.namebool, 0x01, - - 0x6A, 0x1F, -- push 0x1F - 0xE8, relTo(root.o_keys_savefunc.DoSave, -5 + 1), -- call save func - - 0xC6, 0x05, root.o_keys_savename.namebool, 0x00, - - 0x58, -- pop eax - - 0xE9, relTo(self.default, -5 + 1), -- jump awayy - - -- ori code - 0x39, 0x1D, self.somevar, - - }) - end, - - disable = function(self, config, root) - - end, - - }, - o_keys_down = { - init = function(self, config, root) - self.address = AOBScan("10 11 12 28 13 28 14 15 16 28 28 17 18 19 28 1A 1B 28 1C 1D 28 1E 1F 20 28 21 28 28 28 28 28 22") - end, - - enable = function(self, config, root) - writeCode(self.address, { 0x09 }) - writeCode(self.address + 1 + 2, { 0x0B }) - writeCode(self.address + 1 + 2 + 1 + 0x03 + 0x0E + 1, { 0x0A }) - end, - - disable = function(self, config, root) - - end, - - }, - o_keys_up = {}, - o_keys_menu = {}, -} - -return { - - init = function(self, config) - for k, part in pairs(parts) do - part:init(config, self) - end - end, - - enable = function(self, config) - for k, part in pairs(parts) do - part:enable(config, self) - end - end, - - disable = function(self, config) - for k, part in pairs(parts) do - part:disable(config, self) - end - end, - -} \ No newline at end of file diff --git a/init.lua b/init.lua index dc08897..76b749a 100644 --- a/init.lua +++ b/init.lua @@ -16,6 +16,7 @@ local changes = { ["ai_rebuild"] = "port/ai_rebuild", ["ai_recruitinterval"] = "port/ai_recruitinterval", ["ai_recruitstate_initialtimer"] = "port/ai_recruitstate_initialtimer", + ["ai_resources_rebuy"] = "port/ai_resources_rebuy", ["ai_tethers"] = "port/ai_tethers", ["ai_towerengines"] = "port/ai_towerengines", ["fix_apple_orchard_build_size"] = "port/fix_apple_orchard_build_size", diff --git a/options.yml b/options.yml index f4480f4..585cb72 100644 --- a/options.yml +++ b/options.yml @@ -47,6 +47,54 @@ options: contents: value: false type: boolean +- category: ['{{ai}}', '{{improvements}}'] + name: ai_resources_rebuy + header: '{{ai_resources_rebuy}}' + text: '{{ai_resources_rebuy_descr}}' + display: GroupBox + children: + - name: ai_resources_rebuy_group_style + display: Group + style: + css: + paddingLeft: 1.0rem + children: + - display: UCP2Slider + header: '{{ai_noflour_maxtime_descr}}' + hasHeader: true + url: ucp2-legacy.ai_resources_rebuy.flour + contents: + min: 0 + max: 72 + step: 1 + decimals: 0 + value: + enabled: false + sliderValue: 36 + - display: UCP2Slider + header: '{{ai_noiron_maxtime_descr}}' + hasHeader: true + url: ucp2-legacy.ai_resources_rebuy.iron + contents: + min: 0 + max: 72 + step: 1 + decimals: 0 + value: + enabled: false + sliderValue: 36 + - display: UCP2Slider + header: '{{ai_nowood_maxtime_descr}}' + hasHeader: true + url: ucp2-legacy.ai_resources_rebuy.wood + contents: + min: 0 + max: 72 + step: 1 + decimals: 0 + value: + enabled: false + sliderValue: 36 - category: ['{{ai}}', '{{improvements}}'] display: GroupBox name: ai_demolish_group diff --git a/port/ai_resources_rebuy.lua b/port/ai_resources_rebuy.lua new file mode 100644 index 0000000..8c0377a --- /dev/null +++ b/port/ai_resources_rebuy.lua @@ -0,0 +1,36 @@ +local writeCode = core.writeCode +local AOBScan = core.AOBScan + +-- /* +-- ENABLE ADJUSTABLE PERIODICAL RESTOCKING OF GOODS THAT ARE NEEDE FOR PRODUCTION +-- */ +-- Extreme adresses: +-- 004cc010 +-- 004cc02B +-- 004cc04E +--____NEW CHANGES: ai_noflour_maxtime, ai_noiron_maxtime, ai_nowood_maxtime +return { + init = function(self, config) + self.ai_noflour_maxtime = AOBScan("24 7E 0E 39 9E ? ? ? ? 75 06 89 86 ? ? ? ? 83 BE ? ? ? ? 48 7E 0E 39 9E ? ? ? ? 75 06 89 86") + self.ai_noiron_maxtime = AOBScan("24 7E 15 39 9E ? ? ? ? 75 0D B8 02 00 00 00 89 86 ? ? ? ? EB 05 B8 02 00 00 00 83 BE ? ? ? ? 24") + self.ai_nowood_maxtime = AOBScan("24 7E 12 39 9E ? ? ? ? 75 0A C7 86 ? ? ? ? 05 00 00 00 83 BE ? ? ? ? 24 7E 15 39 9E") + end, + + enable = function(self, config) + if config.flour.enabled then + writeCode(self.ai_noflour_maxtime, {config.flour.sliderValue}) + end + + if config.iron.enabled then + writeCode(self.ai_noiron_maxtime, {config.iron.sliderValue}) + end + + if config.wood.enabled then + writeCode(self.ai_nowood_maxtime, {config.wood.sliderValue}) + end + end, + + disable = function(self, config) + error("not implemented") + end, +}