<?xml version='1.0' encoding='utf-8'?>
<CheatTable CheatEngineTableVersion="45">
  <CheatEntries>
    <CheatEntry>
      <ID>1</ID>
      <Description>"Auto-Attach and Version Check"</Description>
      <GroupHeader>1</GroupHeader>
    </CheatEntry>
    <CheatEntry>
      <ID>2</ID>
      <Description>"☕ Fuel the Cheats — Tip Katzy (Toggle to open my Ko-fi page)"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then return end
shellExecute('https://ko-fi.com/katzy')
local record=memrec
createTimer(100,function() record.Active=false end)
{$asm}
[DISABLE]
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>3</ID>
      <Description>"How to use - Katzy"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then return end
showMessage([[Table identification: Katzy.

Start the game, open the table in Cheat Engine and allow its Lua script. Tick the matching MAIN section, then choose your options. Ordinary options can be selected in the menu and carry over between maps. Selected-unit actions require a live match.

Infinite Money
Adds a 30,000-credit allowance. Earnings increase the total; purchases spend the surplus down to the allowance. Turning it off removes the allowance and keeps your unspent normal credits. The Silos Needed message is muted while enabled; harvesting and storage rules still apply.

Infinite Power
Adds power as needed to keep 100 spare. Turning it off removes the extra power and restores normal low-power behavior.

Instant Build
Finishes paid production. Normal prices, prerequisites, placement and factory exit rules still apply. Turning it off restores normal future production; completed items stay completed.

Infinite Aircraft Ammo
Stops your aircraft from spending ammunition normally reloaded at an airfield. Empty aircraft need one normal reload first. Firing speed stays normal. Turning it off restores ammunition use.

Instant Superweapons and Support Powers
Readies your powers and removes their credit costs. Required buildings, upgrades and valid targets still apply. Turning it off restores costs and the existing cooldown schedule.

Invulnerability - Selected Units
Select units you own in a live match, then enable this option to protect that group. A steady selection highlight marks protected units; squad members inherit their squad's protection.
Changing selection does not move protection. Turn it off, select another group and enable again to change targets. Turning it off, Clear All or a map change removes protection. Healing stays normal; scripted removal and damage that bypasses native protection can still kill.

Reveal Map - Full
Grants full map visibility and can trigger discoveries or mission events early. Turning it off cannot undo events already triggered. Use only one Reveal Map mode at a time.

Reveal Map - Visual Only
Shows terrain and objects without granting gameplay sight. Normal scouting, targeting and cloaking rules still apply. Use this mode for campaigns.

Promote Selected Units - Maximum Veterancy (One Shot)
Select units you own in a live match and activate once to grant maximum veterancy to eligible units. Granted ranks remain after Clear All. Units that cannot gain veterancy are skipped. If paused, keep the group selected and resume. Clear All or a map change cancels an unprocessed request.

Clear All
Turns off the options and MAIN. If paused, resume briefly to let cleanup finish. Turn options off before saving, loading, switching processes manually or replacing the table.]])
local record=memrec
createTimer(100,function() record.Active=false end)
{$asm}
[DISABLE]
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>4</ID>
      <Description>"Clear All"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
{$lua}
if syntaxcheck then return end
if CNC3Katzy then CNC3Katzy.clear() end
local record=memrec
createTimer(100,function() record.Active=false end)
{$asm}
[DISABLE]
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>10</ID>
      <Description>"[MAIN] Command &amp; Conquer 3: Tiberium Wars"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
      <Options moHideChildren="1" />
      <CheatEntries>
        <CheatEntry>
          <ID>11</ID>
          <Description>"Infinite Money"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>12</ID>
          <Description>"Infinite Power"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>13</ID>
          <Description>"Instant Build"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>17</ID>
          <Description>"Infinite Aircraft Ammo"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>14</ID>
          <Description>"Instant Superweapons and Support Powers"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>19</ID>
          <Description>"Invulnerability - Selected Units"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>16</ID>
          <Description>"Reveal Map - Full"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>15</ID>
          <Description>"Reveal Map - Visual Only"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>18</ID>
          <Description>"Promote Selected Units - Maximum Veterancy (One Shot)"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
    <CheatEntry>
      <ID>20</ID>
      <Description>"[MAIN] Command &amp; Conquer 3: Kane's Wrath"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
      <Options moHideChildren="1" />
      <CheatEntries>
        <CheatEntry>
          <ID>21</ID>
          <Description>"Infinite Money"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>22</ID>
          <Description>"Infinite Power"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>23</ID>
          <Description>"Instant Build"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>27</ID>
          <Description>"Infinite Aircraft Ammo"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>24</ID>
          <Description>"Instant Superweapons and Support Powers"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>29</ID>
          <Description>"Invulnerability - Selected Units"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>26</ID>
          <Description>"Reveal Map - Full"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>25</ID>
          <Description>"Reveal Map - Visual Only"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>28</ID>
          <Description>"Promote Selected Units - Maximum Veterancy (One Shot)"</Description>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
[DISABLE]
</AssemblerScript>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols />
  <LuaScript>--[[
Table identification: Katzy
Command &amp; Conquer 3 | Tiberium Wars 1.10 / Kane's Wrath 1.3 | v1.24
Player-owned cheats for the supported Steam builds.
Selections persist across maps; Clear All restores captured original code.
]]
if CNC3Katzy and CNC3Katzy.shutdown()==false then
  showMessage('Resume the previous game so its active options can finish turning off, then reload this table.')
  return
end
local S={installed={}, closing=false}
CNC3Katzy=S
local configs={
tw={module='cnc3game.dat', hash='b2f584c0aaecf38a7815d9770acc4d5a', title="Tiberium Wars", version='1.10.0.0', player=0x7EE110, logic=0x7EE574, shroud=0x7F3494, selection=0x7EABE8, owner=0x33C, xp=0x314, objectId=0xE8, settings=0x7F34A0, scripts={controller=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(POWERADD,cnc3game.dat+0xA38F2)
define(SHROUDGLOBAL,cnc3game.dat+0x7F3494)
define(OWNER_OFFSET,0x33C)
define(SELECTIONGLOBAL,cnc3game.dat+0x7EABE8)
define(PROMOTE,cnc3game.dat+0x2116C7)
define(XP_OFFSET,0x314)
define(REVEALADD,cnc3game.dat+0x5E3674)
define(REVEALOFF,cnc3game.dat+0x5E4C31)
define(REFRESH,cnc3game.dat+0x5E36B0)
aobscanmodule(cnc_controller_hook,cnc3game.dat,56 57 6a 14 8d 71 24 5f 8b 0e e8 0a ff ff ff 83 c6 04 4f 75 f3 5f 5e c3)
assert(cnc_controller_hook,56 57 6a 14 8d 71 24)
assert(PROMOTE,55 8b ec 51 53 33 db 39 5d 08 57 8b f9 7f 04 32 c0 eb 43 56 33 f6 39 5d)
alloc(cnc_controller_code,0x800,cnc_controller_hook)
fullaccess(cnc_controller_hook,7)
alloc(cnc_state,0x80)
registersymbol(cnc_state)
label(cnc_controller_return)
label(ctl_money_off)
label(ctl_money_remaining)
label(ctl_power)
label(ctl_power_delta)
label(ctl_reveal)
label(ctl_reveal_update)
label(ctl_reveal_off)
label(ctl_visual_refresh)
label(ctl_promote)
label(ctl_promote_next)
label(ctl_promote_skip)
label(ctl_promote_finish)
label(ctl_invalid)
label(ctl_invalid_state)
label(ctl_done)
label(ctl_retire)
label(ctl_return)
registersymbol(cnc_controller_hook)
cnc_state:
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd (float)100.0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

cnc_controller_code:
pushfd
pushad
cmp dword ptr [cnc_state+1C],1
jne ctl_done
mov eax,[PLAYERGLOBAL]
test eax,eax
je ctl_invalid
mov eax,[eax+1C]
cmp eax,[cnc_state]
jne ctl_invalid
mov ebx,[LOGICGLOBAL]
cmp ebx,[cnc_state+24]
jne ctl_invalid
test ebx,ebx
je ctl_invalid
mov edx,[ebx+38]
cmp edx,[cnc_state+20]
jb ctl_invalid
mov [cnc_state+20],edx
mov ebx,[eax+60]
cmp ebx,[cnc_state+4]
jne ctl_invalid
mov ecx,[eax+80]
cmp ecx,[cnc_state+8]
jne ctl_invalid
mov edx,[SHROUDGLOBAL]
cmp edx,[cnc_state+44]
jne ctl_invalid
mov edx,[cnc_state+0xC]
cmp edx,[cnc_state+10]
je ctl_power
test edx,edx
jz ctl_money_off
add dword ptr [ebx+4],7530
add dword ptr [ebx+8],7530
mov dword ptr [cnc_state+10],1
jmp ctl_power
ctl_money_off:
mov edx,[ebx+4]
sub edx,7530
jnc ctl_money_remaining
xor edx,edx
ctl_money_remaining:
mov [ebx+4],edx
sub dword ptr [ebx+8],7530
mov dword ptr [cnc_state+10],0
ctl_power:
xor edx,edx
cmp dword ptr [cnc_state+14],0
je ctl_power_delta
mov edx,[ecx+8]
add edx,64
sub edx,[ecx+4]
add edx,[cnc_state+18]
jns ctl_power_delta
xor edx,edx
ctl_power_delta:
mov eax,edx
sub edx,[cnc_state+18]
je ctl_reveal
mov [cnc_state+18],eax
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
push edx
call POWERADD
fxrstor [esp]
mov esp,ebp
ctl_reveal:
mov eax,[cnc_state+34]
cmp eax,[cnc_state+38]
jne ctl_reveal_update
mov eax,[cnc_state+3C]
cmp eax,[cnc_state+40]
je ctl_promote
ctl_reveal_update:
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
mov edi,[cnc_state+44]
mov esi,[cnc_state]
mov eax,[cnc_state+34]
cmp eax,[cnc_state+38]
je ctl_visual_refresh
mov ecx,[edi+1C]
push dword ptr [esi+48]
test eax,eax
jz ctl_reveal_off
call REVEALADD
mov dword ptr [cnc_state+38],1
jmp ctl_visual_refresh
ctl_reveal_off:
call REVEALOFF
mov dword ptr [cnc_state+38],0
ctl_visual_refresh:
mov ecx,[edi+1C]
call REFRESH
mov eax,[cnc_state+3C]
mov [cnc_state+40],eax
fxrstor [esp]
mov esp,ebp
jmp ctl_promote
ctl_promote:
cmp dword ptr [cnc_state+54],1
jne ctl_done
mov dword ptr [cnc_state+54],0
mov dword ptr [cnc_state+58],4
mov eax,[SELECTIONGLOBAL]
test eax,eax
je ctl_done
mov ebx,[eax+40]
test ebx,ebx
je ctl_done
cmp ebx,[cnc_state+4C]
jne ctl_done
mov edi,[ebx]
cmp edi,[cnc_state+50]
jne ctl_done
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
mov dword ptr [cnc_state+58],2
ctl_promote_next:
test edi,edi
je ctl_promote_finish
cmp edi,ebx
je ctl_promote_finish
mov eax,[edi+8]
test eax,eax
je ctl_promote_skip
mov esi,[eax+140]
test esi,esi
je ctl_promote_skip
mov eax,[esi+OWNER_OFFSET]
test eax,eax
je ctl_promote_skip
mov eax,[eax+4]
test eax,eax
je ctl_promote_skip
mov eax,[eax+8]
cmp eax,[cnc_state]
jne ctl_promote_skip
mov ecx,[esi+XP_OFFSET]
test ecx,ecx
je ctl_promote_skip
cmp [ecx+3C],esi
jne ctl_promote_skip
push 0
push 1
push 3
call PROMOTE
test al,al
je ctl_promote_skip
mov dword ptr [cnc_state+58],3
ctl_promote_skip:
mov edi,[edi]
jmp ctl_promote_next
ctl_promote_finish:
fxrstor [esp]
mov esp,ebp
jmp ctl_done
ctl_invalid:
cmp dword ptr [cnc_state+54],1
jne ctl_invalid_state
mov dword ptr [cnc_state+54],0
mov dword ptr [cnc_state+58],4
ctl_invalid_state:
mov dword ptr [cnc_state+1C],0
ctl_done:
cmp dword ptr [cnc_state+68],1
jne ctl_return
cmp dword ptr [cnc_state+1C],0
je ctl_retire
cmp dword ptr [cnc_state+10],0
jne ctl_return
cmp dword ptr [cnc_state+18],0
jne ctl_return
cmp dword ptr [cnc_state+38],0
jne ctl_return
cmp dword ptr [cnc_state+40],0
jne ctl_return
ctl_retire:
mov ebx,cnc_controller_return
sub ebx,7
mov eax,[ebx]
and eax,000000FF
cmp eax,000000E9
jne ctl_return
mov eax,cnc_controller_code
lea edx,[ebx+5]
sub eax,edx
cmp [ebx+1],eax
jne ctl_return
mov eax,[ebx+5]
and eax,0000FFFF
cmp eax,9066
jne ctl_return
mov eax,[ebx+4]
and eax,0FF000000
or eax,0024718D
mov [ebx+4],eax
mov dword ptr [ebx],146A5756
mov dword ptr [cnc_state+1C],0
mov dword ptr [cnc_state+68],2
ctl_return:
popad
popfd

push esi
push edi
push 14
lea esi,[ecx+24]
jmp cnc_controller_return
cnc_controller_hook:
jmp cnc_controller_code
nop 2
cnc_controller_return:
[DISABLE]
cnc_controller_hook:
db 56 57 6a 14 8d 71 24
unregistersymbol(cnc_controller_hook)
dealloc(cnc_controller_code)
unregistersymbol(cnc_state)
dealloc(cnc_state)
]==],money=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_money_hook,cnc3game.dat,29 06 8b 53 0c 8b 0d 10 e1 be 00 01 45 50 52 e8 20 37 ff ff 8b 4d 5c 89)
assert(cnc_money_hook,29 06 8b 53 0c)
alloc(cnc_money_code,0x400,cnc_money_hook)
label(cnc_money_return)
label(money_done)
registersymbol(cnc_money_hook)

cnc_money_code:
sub [esi],eax
pushfd
push ecx
cmp dword ptr [cnc_state+1C],1
jne money_done
cmp dword ptr [cnc_state+10],1
jne money_done
cmp ebx,[cnc_state+4]
jne money_done
mov ecx,[PLAYERGLOBAL]
test ecx,ecx
je money_done
mov ecx,[ecx+1C]
cmp ecx,[cnc_state]
jne money_done
mov ecx,[LOGICGLOBAL]
cmp ecx,[cnc_state+24]
jne money_done
test ecx,ecx
je money_done
mov ecx,[ecx+38]
cmp ecx,[cnc_state+20]
jb money_done
cmp dword ptr [esi],7530
jae money_done
mov dword ptr [esi],7530
money_done:
pop ecx
popfd
mov edx,[ebx+0xC]

jmp cnc_money_return
cnc_money_hook:
jmp cnc_money_code
cnc_money_return:
[DISABLE]
cnc_money_hook:
db 29 06 8b 53 0c
unregistersymbol(cnc_money_hook)
dealloc(cnc_money_code)
]==],instant=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_instant_hook,cnc3game.dat,f3 0f 10 4b 20 f3 0f 58 4b 1c f3 0f 10 05 54 4e a3 00 0f 2f c1 f3 0f 11)
assert(cnc_instant_hook,f3 0f 10 4b 20)
alloc(cnc_instant_code,0x400,cnc_instant_hook)
label(cnc_instant_return)
label(build_done)
registersymbol(cnc_instant_hook)

cnc_instant_code:
movss xmm1,[ebx+20]
pushfd
push eax
cmp dword ptr [cnc_state+1C],1
jne build_done
cmp dword ptr [cnc_state+28],1
jne build_done
cmp edi,[cnc_state]
jne build_done
mov eax,[PLAYERGLOBAL]
test eax,eax
je build_done
cmp edi,[eax+1C]
jne build_done
mov eax,[LOGICGLOBAL]
cmp eax,[cnc_state+24]
jne build_done
test eax,eax
je build_done
mov eax,[eax+38]
cmp eax,[cnc_state+20]
jb build_done
movss xmm1,[cnc_state+2C]
build_done:
pop eax
popfd

jmp cnc_instant_return
cnc_instant_hook:
jmp cnc_instant_code
cnc_instant_return:
[DISABLE]
cnc_instant_hook:
db f3 0f 10 4b 20
unregistersymbol(cnc_instant_hook)
dealloc(cnc_instant_code)
]==],ready=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
aobscanmodule(cnc_ready_hook,cnc3game.dat,a1 74 e5 be 00 80 b8 a2 00 00 00 00 56 8b f1 75 04 32 c0 5e c3 80 7e 28)
assert(cnc_ready_hook,a1 74 e5 be 00)
alloc(cnc_ready_code,0x400,cnc_ready_hook)
label(cnc_ready_return)
label(ready_normal)
registersymbol(cnc_ready_hook)

cnc_ready_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne ready_normal
cmp dword ptr [cnc_state+30],1
jne ready_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je ready_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne ready_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je ready_normal
cmp ebx,[cnc_state+24]
jne ready_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb ready_normal
mov ebx,[ecx-8]
test ebx,ebx
je ready_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je ready_normal
mov ebx,[ebx+4]
test ebx,ebx
je ready_normal
cmp edx,[ebx+8]
jne ready_normal
pop ebx
pop edx
popfd
mov eax,1
ret
ready_normal:
pop ebx
pop edx
popfd
db a1 74 e5 be 00

jmp cnc_ready_return
cnc_ready_hook:
jmp cnc_ready_code
cnc_ready_return:
[DISABLE]
cnc_ready_hook:
db a1 74 e5 be 00
unregistersymbol(cnc_ready_hook)
dealloc(cnc_ready_code)
]==],progress=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
aobscanmodule(cnc_progress_hook,cnc3game.dat,55 8b ec 51 a1 74 e5 be 00 80 b8 a2 00 00 00 00 53 56 57 8b f1 0f 84 ae)
assert(cnc_progress_hook,55 8b ec 51 a1 74 e5 be 00)
alloc(cnc_progress_code,0x400,cnc_progress_hook)
label(cnc_progress_return)
label(progress_normal)
registersymbol(cnc_progress_hook)

cnc_progress_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne progress_normal
cmp dword ptr [cnc_state+30],1
jne progress_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je progress_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne progress_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je progress_normal
cmp ebx,[cnc_state+24]
jne progress_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb progress_normal
mov ebx,[ecx-8]
test ebx,ebx
je progress_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je progress_normal
mov ebx,[ebx+4]
test ebx,ebx
je progress_normal
cmp edx,[ebx+8]
jne progress_normal
pop ebx
pop edx
popfd
fld1
ret
progress_normal:
pop ebx
pop edx
popfd
db 55 8b ec 51 a1 74 e5 be 00

jmp cnc_progress_return
cnc_progress_hook:
jmp cnc_progress_code
nop 4
cnc_progress_return:
[DISABLE]
cnc_progress_hook:
db 55 8b ec 51 a1 74 e5 be 00
unregistersymbol(cnc_progress_hook)
dealloc(cnc_progress_code)
]==],deadline=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
aobscanmodule(cnc_deadline_hook,cnc3game.dat,56 8b f1 8b 06 57 ff 50 1c 6a 0d 8b c8 e8 35 15 ec ff 84 c0 74 23 8b 4e)
assert(cnc_deadline_hook,56 8b f1 8b 06)
alloc(cnc_deadline_code,0x400,cnc_deadline_hook)
label(cnc_deadline_return)
label(deadline_normal)
registersymbol(cnc_deadline_hook)

cnc_deadline_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne deadline_normal
cmp dword ptr [cnc_state+30],1
jne deadline_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je deadline_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne deadline_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je deadline_normal
cmp ebx,[cnc_state+24]
jne deadline_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb deadline_normal
mov ebx,[ecx-8]
test ebx,ebx
je deadline_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je deadline_normal
mov ebx,[ebx+4]
test ebx,ebx
je deadline_normal
cmp edx,[ebx+8]
jne deadline_normal
pop ebx
pop edx
popfd
mov eax,[LOGICGLOBAL]
mov eax,[eax+38]
ret
deadline_normal:
pop ebx
pop edx
popfd
db 56 8b f1 8b 06

jmp cnc_deadline_return
cnc_deadline_hook:
jmp cnc_deadline_code
cnc_deadline_return:
[DISABLE]
cnc_deadline_hook:
db 56 8b f1 8b 06
unregistersymbol(cnc_deadline_hook)
dealloc(cnc_deadline_code)
]==],afford=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
aobscanmodule(cnc_afford_hook,cnc3game.dat,56 8b 74 24 08 8b 46 18 83 b8 30 01 00 00 00 7c 04 b0 01 eb 2a 80 3d 3a)
assert(cnc_afford_hook,56 8b 74 24 08)
alloc(cnc_afford_code,0x400,cnc_afford_hook)
label(cnc_afford_return)
label(afford_normal)
registersymbol(cnc_afford_hook)

cnc_afford_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne afford_normal
cmp dword ptr [cnc_state+30],1
jne afford_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je afford_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne afford_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je afford_normal
cmp ebx,[cnc_state+24]
jne afford_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb afford_normal
mov ebx,[ecx+0xC]
test ebx,ebx
je afford_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je afford_normal
mov ebx,[ebx+4]
test ebx,ebx
je afford_normal
cmp edx,[ebx+8]
jne afford_normal
pop ebx
pop edx
popfd
mov eax,1
ret 4
afford_normal:
pop ebx
pop edx
popfd
db 56 8b 74 24 08

jmp cnc_afford_return
cnc_afford_hook:
jmp cnc_afford_code
cnc_afford_return:
[DISABLE]
cnc_afford_hook:
db 56 8b 74 24 08
unregistersymbol(cnc_afford_hook)
dealloc(cnc_afford_code)
]==],spcost=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_spcost_hook,cnc3game.dat,8b 80 30 01 00 00 85 c0 8b 75 fc 74 47 8b 57 0c 8b 4e 60 8b 92 e8 00 00)
assert(cnc_spcost_hook,8b 80 30 01 00 00)
alloc(cnc_spcost_code,0x400,cnc_spcost_hook)
label(cnc_spcost_return)
label(spcost_normal)
registersymbol(cnc_spcost_hook)

cnc_spcost_code:
mov eax,[eax+130]
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne spcost_normal
cmp dword ptr [cnc_state+30],1
jne spcost_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je spcost_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne spcost_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je spcost_normal
cmp ebx,[cnc_state+24]
jne spcost_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb spcost_normal
cmp edx,[ebp-4]
jne spcost_normal
test eax,eax
jns spcost_normal
xor eax,eax
spcost_normal:
pop ebx
pop edx
popfd

jmp cnc_spcost_return
cnc_spcost_hook:
jmp cnc_spcost_code
nop 1
cnc_spcost_return:
[DISABLE]
cnc_spcost_hook:
db 8b 80 30 01 00 00
unregistersymbol(cnc_spcost_hook)
dealloc(cnc_spcost_code)
]==],notify=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_notify_hook,cnc3game.dat,55 8b ec 83 ec 18 ff 75 10 33 c9 ff 75 0c b8 96 e2 5a 00 ff 75 08 51 50 8d 45 e8 50 e8 9a f9 ff ff 83 c4 18 50 e8 9f ff)
assert(cnc_notify_hook,55 8b ec 83 ec 18)
alloc(cnc_notify_code,0x400,cnc_notify_hook)
label(cnc_notify_return)
label(notify_normal)
registersymbol(cnc_notify_hook)

cnc_notify_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne notify_normal
cmp dword ptr [cnc_state+3C],1
jne notify_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je notify_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne notify_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je notify_normal
cmp ebx,[cnc_state+24]
jne notify_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb notify_normal
mov dword ptr [esp+18],1
notify_normal:
pop ebx
pop edx
popfd
db 55 8b ec 83 ec 18

jmp cnc_notify_return
cnc_notify_hook:
jmp cnc_notify_code
nop 1
cnc_notify_return:
[DISABLE]
cnc_notify_hook:
db 55 8b ec 83 ec 18
unregistersymbol(cnc_notify_hook)
dealloc(cnc_notify_code)
]==],drawcull=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_drawcull_hook,cnc3game.dat,83 f8 03 89 45 ec 7c 5e 83 be 28 02 00 00 00 74 55 d9 05 40 4f a3 00 6a)
assert(cnc_drawcull_hook,83 f8 03 89 45 ec)
alloc(cnc_drawcull_code,0x400,cnc_drawcull_hook)
label(cnc_drawcull_return)
label(drawcull_normal)
registersymbol(cnc_drawcull_hook)

cnc_drawcull_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne drawcull_normal
cmp dword ptr [cnc_state+3C],1
jne drawcull_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je drawcull_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne drawcull_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je drawcull_normal
cmp ebx,[cnc_state+24]
jne drawcull_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb drawcull_normal
mov ebx,[ebp-0xC]
cmp ebx,[edx+48]
jne drawcull_normal
mov eax,1
drawcull_normal:
pop ebx
pop edx
popfd
db 83 f8 03 89 45 ec

jmp cnc_drawcull_return
cnc_drawcull_hook:
jmp cnc_drawcull_code
nop 1
cnc_drawcull_return:
[DISABLE]
cnc_drawcull_hook:
db 83 f8 03 89 45 ec
unregistersymbol(cnc_drawcull_hook)
dealloc(cnc_drawcull_code)
]==],drawshade=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_drawshade_hook,cnc3game.dat,83 f8 01 89 45 fc 75 10 a1 74 e5 be 00 8b 40 38 89 87 28 02 00 00 eb 66)
assert(cnc_drawshade_hook,83 f8 01 89 45 fc)
alloc(cnc_drawshade_code,0x400,cnc_drawshade_hook)
label(cnc_drawshade_return)
label(drawshade_normal)
registersymbol(cnc_drawshade_hook)

cnc_drawshade_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne drawshade_normal
cmp dword ptr [cnc_state+3C],1
jne drawshade_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je drawshade_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne drawshade_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je drawshade_normal
cmp ebx,[cnc_state+24]
jne drawshade_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb drawshade_normal
mov ebx,[ebp+10]
cmp ebx,[edx+48]
jne drawshade_normal
mov eax,1
drawshade_normal:
pop ebx
pop edx
popfd
db 83 f8 01 89 45 fc

jmp cnc_drawshade_return
cnc_drawshade_hook:
jmp cnc_drawshade_code
nop 1
cnc_drawshade_return:
[DISABLE]
cnc_drawshade_hook:
db 83 f8 01 89 45 fc
unregistersymbol(cnc_drawshade_hook)
dealloc(cnc_drawshade_code)
]==],silos=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
aobscanmodule(cnc_silos_hook,cnc3game.dat,50 50 50 6a 1c e8 d8 8f e7 ff e9 80 00 00 00 8b 45 08 8b 80 e8 00 00 00)
assert(cnc_silos_hook,50 50 50 6a 1c)
alloc(cnc_silos_code,0x400,cnc_silos_hook)
label(cnc_silos_return)
label(silos_normal)
registersymbol(cnc_silos_hook)

cnc_silos_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne silos_normal
cmp dword ptr [cnc_state+C],1
jne silos_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je silos_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne silos_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je silos_normal
cmp ebx,[cnc_state+24]
jne silos_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb silos_normal
cmp edx,[esp]
jne silos_normal
pop ebx
pop edx
popfd
jmp cnc_silos_hook+0A
silos_normal:
pop ebx
pop edx
popfd
db 50 50 50 6a 1c

jmp cnc_silos_return
cnc_silos_hook:
jmp cnc_silos_code
cnc_silos_return:
[DISABLE]
cnc_silos_hook:
db 50 50 50 6a 1c
unregistersymbol(cnc_silos_hook)
dealloc(cnc_silos_code)
]==],ammo=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
aobscanmodule(cnc_ammo_hook,cnc3game.dat,ff 4b 18 ff 4b 20 ff 4b 28 39 7b 28 7f 2e ff 73 14 8b 45 08 ff 43 24 ff)
assert(cnc_ammo_hook,ff 4b 18 ff 4b 20)
alloc(cnc_ammo_code,0x400,cnc_ammo_hook)
label(cnc_ammo_return)
label(ammo_normal)
registersymbol(cnc_ammo_hook)

cnc_ammo_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne ammo_normal
cmp dword ptr [cnc_state+48],1
jne ammo_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je ammo_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne ammo_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je ammo_normal
cmp ebx,[cnc_state+24]
jne ammo_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb ammo_normal
mov ebx,[ebp+8]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
test dword ptr [ebx+124],4000
je ammo_normal
mov ebx,[ebp+8]
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
cmp edx,[ebx+8]
jne ammo_normal
mov ebx,[esp]
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
cmp dword ptr [ebx+0xE4],2
jne ammo_normal
pop ebx
pop edx
popfd
dec dword ptr [ebx+20]
jmp cnc_ammo_return
ammo_normal:
pop ebx
pop edx
popfd
db ff 4b 18 ff 4b 20

jmp cnc_ammo_return
cnc_ammo_hook:
jmp cnc_ammo_code
nop 1
cnc_ammo_return:
[DISABLE]
cnc_ammo_hook:
db ff 4b 18 ff 4b 20
unregistersymbol(cnc_ammo_hook)
dealloc(cnc_ammo_code)
]==],invulnerability=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
define(OBJECT_ID,0xE8)
define(HORDEROOT,cnc3game.dat+0x20758F)
aobscanmodule(cnc_invulnerability_hook,cnc3game.dat,8b 44 24 04 83 78 10 08 75 04 32 c0 eb 32 80 b9 df 00 00 00 00 75 27 8b)
assert(cnc_invulnerability_hook,8b 44 24 04 83 78 10 08)
assert(HORDEROOT,57 8b f9 8b 47 04 8b 80 30 01 00 00 c1 e8 0f a8 01 74 04 8b c7 eb 75 8b)
alloc(cnc_invulnerability_code,0x400,cnc_invulnerability_hook)
label(cnc_invulnerability_return)
label(invulnerability_retry)
label(invulnerability_search)
label(invulnerability_lower)
label(invulnerability_parent)
label(invulnerability_found)
label(invulnerability_normal)
registersymbol(cnc_invulnerability_hook)

cnc_invulnerability_code:
pushfd
push edx
push ebx
push ecx
push esi
push edi
push ebp
cmp dword ptr [cnc_state+1C],1
jne invulnerability_normal
cmp dword ptr [cnc_state+5C],1
jne invulnerability_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je invulnerability_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne invulnerability_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je invulnerability_normal
cmp ebx,[cnc_state+24]
jne invulnerability_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb invulnerability_normal
mov ebx,[ecx+0xC]
test ebx,ebx
je invulnerability_normal
mov ebp,ebx
invulnerability_retry:
mov edi,[cnc_state+60]
test edi,edi
je invulnerability_normal
mov ecx,[edi]
add edi,10
xor esi,esi
invulnerability_search:
cmp esi,ecx
jae invulnerability_parent
mov edx,esi
add edx,ecx
shr edx,1
cmp ebx,[edi+edx*8]
je invulnerability_found
jb invulnerability_lower
lea esi,[edx+1]
jmp invulnerability_search
invulnerability_lower:
mov ecx,edx
jmp invulnerability_search
invulnerability_parent:
cmp ebx,ebp
jne invulnerability_normal
mov ecx,[ebp+OWNER_OFFSET]
test ecx,ecx
je invulnerability_normal
mov ecx,[ecx+4]
test ecx,ecx
je invulnerability_normal
mov ecx,[ecx+8]
cmp ecx,[cnc_state]
jne invulnerability_normal
push eax
mov ecx,ebp
push 0
call HORDEROOT
mov ebx,eax
pop eax
test ebx,ebx
je invulnerability_normal
cmp ebx,ebp
je invulnerability_normal
jmp invulnerability_retry
invulnerability_found:
mov esi,[ebx+OBJECT_ID]
cmp esi,[edi+edx*8+4]
jne invulnerability_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je invulnerability_normal
mov ebx,[ebx+4]
test ebx,ebx
je invulnerability_normal
mov edx,[cnc_state]
cmp edx,[ebx+8]
jne invulnerability_normal
mov ebx,[esp+20]
test ebx,ebx
je invulnerability_normal
cmp dword ptr [ebx+10],8
je invulnerability_normal
cmp dword ptr [ebx+2C],0
jle invulnerability_normal
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
mov al,1
ret 4
invulnerability_normal:
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
db 8b 44 24 04 83 78 10 08

jmp cnc_invulnerability_return
cnc_invulnerability_hook:
jmp cnc_invulnerability_code
nop 3
cnc_invulnerability_return:
[DISABLE]
cnc_invulnerability_hook:
db 8b 44 24 04 83 78 10 08
unregistersymbol(cnc_invulnerability_hook)
dealloc(cnc_invulnerability_code)
]==],protectionhighlight=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3game.dat+0x7EE110)
define(LOGICGLOBAL,cnc3game.dat+0x7EE574)
define(OWNER_OFFSET,0x33C)
define(OBJECT_ID,0xE8)
define(HORDEROOT,cnc3game.dat+0x20758F)
aobscanmodule(cnc_protectionhighlight_hook,cnc3game.dat,5f 5e c2 04 00 55 8b ec 51 57 8b f9 f3 0f 10 87 e0 01 00 00 8d 87 d0 01)
assert(cnc_protectionhighlight_hook,5f 5e c2 04 00)
assert(HORDEROOT,57 8b f9 8b 47 04 8b 80 30 01 00 00 c1 e8 0f a8 01 74 04 8b c7 eb 75 8b)
alloc(cnc_protectionhighlight_code,0x400,cnc_protectionhighlight_hook)
label(cnc_protectionhighlight_return)
label(protectionhighlight_retry)
label(protectionhighlight_search)
label(protectionhighlight_lower)
label(protectionhighlight_parent)
label(protectionhighlight_found)
label(protectionhighlight_normal)
registersymbol(cnc_protectionhighlight_hook)

cnc_protectionhighlight_code:
pushfd
push edx
push ebx
push ecx
push esi
push edi
push ebp
cmp dword ptr [cnc_state+1C],1
jne protectionhighlight_normal
cmp dword ptr [cnc_state+5C],1
jne protectionhighlight_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je protectionhighlight_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne protectionhighlight_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je protectionhighlight_normal
cmp ebx,[cnc_state+24]
jne protectionhighlight_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb protectionhighlight_normal
mov ebx,[edi+140]
test ebx,ebx
je protectionhighlight_normal
mov ebp,ebx
protectionhighlight_retry:
mov edi,[cnc_state+60]
test edi,edi
je protectionhighlight_normal
mov ecx,[edi]
add edi,10
xor esi,esi
protectionhighlight_search:
cmp esi,ecx
jae protectionhighlight_parent
mov edx,esi
add edx,ecx
shr edx,1
cmp ebx,[edi+edx*8]
je protectionhighlight_found
jb protectionhighlight_lower
lea esi,[edx+1]
jmp protectionhighlight_search
protectionhighlight_lower:
mov ecx,edx
jmp protectionhighlight_search
protectionhighlight_parent:
cmp ebx,ebp
jne protectionhighlight_normal
mov ecx,[ebp+OWNER_OFFSET]
test ecx,ecx
je protectionhighlight_normal
mov ecx,[ecx+4]
test ecx,ecx
je protectionhighlight_normal
mov ecx,[ecx+8]
cmp ecx,[cnc_state]
jne protectionhighlight_normal
push eax
mov ecx,ebp
push 0
call HORDEROOT
mov ebx,eax
pop eax
test ebx,ebx
je protectionhighlight_normal
cmp ebx,ebp
je protectionhighlight_normal
jmp protectionhighlight_retry
protectionhighlight_found:
mov esi,[ebx+OBJECT_ID]
cmp esi,[edi+edx*8+4]
jne protectionhighlight_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je protectionhighlight_normal
mov ebx,[ebx+4]
test ebx,ebx
je protectionhighlight_normal
mov edx,[cnc_state]
cmp edx,[ebx+8]
jne protectionhighlight_normal
mov ecx,[esp+8]
mov edx,[edi-0xC]
mov [ecx],edx
mov edx,[edi-8]
mov [ecx+4],edx
mov edx,[edi-4]
mov [ecx+8],edx
protectionhighlight_normal:
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
db 5f 5e c2 04 00

jmp cnc_protectionhighlight_return
cnc_protectionhighlight_hook:
jmp cnc_protectionhighlight_code
cnc_protectionhighlight_return:
[DISABLE]
cnc_protectionhighlight_hook:
db 5f 5e c2 04 00
unregistersymbol(cnc_protectionhighlight_hook)
dealloc(cnc_protectionhighlight_code)
]==]}},
kw={module='cnc3ep1.dat', hash='99072ea8b1c3aa09ff72d1f625f86985', title="Kane's Wrath", version='1.3.0.0', player=0x7F7B10, logic=0x7F7F98, shroud=0x7FBF18, selection=0x7F45B0, owner=0x348, xp=0x320, objectId=0xEC, settings=0x7FBF24, scripts={controller=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(POWERADD,cnc3ep1.dat+0xEA20B)
define(SHROUDGLOBAL,cnc3ep1.dat+0x7FBF18)
define(OWNER_OFFSET,0x348)
define(SELECTIONGLOBAL,cnc3ep1.dat+0x7F45B0)
define(PROMOTE,cnc3ep1.dat+0x276CA3)
define(XP_OFFSET,0x320)
define(REVEALADD,cnc3ep1.dat+0x56A5A9)
define(REVEALOFF,cnc3ep1.dat+0x56BB5C)
define(REFRESH,cnc3ep1.dat+0x56A5E5)
aobscanmodule(cnc_controller_hook,cnc3ep1.dat,56 57 6a 1a 8d 71 24 5f 8b 0e e8 0a ff ff ff 83 c6 04 4f 75 f3 5f 5e c3)
assert(cnc_controller_hook,56 57 6a 1a 8d 71 24)
assert(PROMOTE,55 8b ec 51 53 33 db 39 5d 08 57 8b f9 7f 04 32 c0 eb 43 56 33 f6 39 5d)
alloc(cnc_controller_code,0x800,cnc_controller_hook)
fullaccess(cnc_controller_hook,7)
alloc(cnc_state,0x80)
registersymbol(cnc_state)
label(cnc_controller_return)
label(ctl_money_off)
label(ctl_money_remaining)
label(ctl_power)
label(ctl_power_delta)
label(ctl_reveal)
label(ctl_reveal_update)
label(ctl_reveal_off)
label(ctl_visual_refresh)
label(ctl_promote)
label(ctl_promote_next)
label(ctl_promote_skip)
label(ctl_promote_finish)
label(ctl_invalid)
label(ctl_invalid_state)
label(ctl_done)
label(ctl_retire)
label(ctl_return)
registersymbol(cnc_controller_hook)
cnc_state:
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd (float)100.0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

cnc_controller_code:
pushfd
pushad
cmp dword ptr [cnc_state+1C],1
jne ctl_done
mov eax,[PLAYERGLOBAL]
test eax,eax
je ctl_invalid
mov eax,[eax+1C]
cmp eax,[cnc_state]
jne ctl_invalid
mov ebx,[LOGICGLOBAL]
cmp ebx,[cnc_state+24]
jne ctl_invalid
test ebx,ebx
je ctl_invalid
mov edx,[ebx+38]
cmp edx,[cnc_state+20]
jb ctl_invalid
mov [cnc_state+20],edx
mov ebx,[eax+60]
cmp ebx,[cnc_state+4]
jne ctl_invalid
mov ecx,[eax+80]
cmp ecx,[cnc_state+8]
jne ctl_invalid
mov edx,[SHROUDGLOBAL]
cmp edx,[cnc_state+44]
jne ctl_invalid
mov edx,[cnc_state+0xC]
cmp edx,[cnc_state+10]
je ctl_power
test edx,edx
jz ctl_money_off
add dword ptr [ebx+4],7530
add dword ptr [ebx+8],7530
mov dword ptr [cnc_state+10],1
jmp ctl_power
ctl_money_off:
mov edx,[ebx+4]
sub edx,7530
jnc ctl_money_remaining
xor edx,edx
ctl_money_remaining:
mov [ebx+4],edx
sub dword ptr [ebx+8],7530
mov dword ptr [cnc_state+10],0
ctl_power:
xor edx,edx
cmp dword ptr [cnc_state+14],0
je ctl_power_delta
mov edx,[ecx+8]
add edx,64
sub edx,[ecx+4]
add edx,[cnc_state+18]
jns ctl_power_delta
xor edx,edx
ctl_power_delta:
mov eax,edx
sub edx,[cnc_state+18]
je ctl_reveal
mov [cnc_state+18],eax
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
push edx
call POWERADD
fxrstor [esp]
mov esp,ebp
ctl_reveal:
mov eax,[cnc_state+34]
cmp eax,[cnc_state+38]
jne ctl_reveal_update
mov eax,[cnc_state+3C]
cmp eax,[cnc_state+40]
je ctl_promote
ctl_reveal_update:
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
mov edi,[cnc_state+44]
mov esi,[cnc_state]
mov eax,[cnc_state+34]
cmp eax,[cnc_state+38]
je ctl_visual_refresh
mov ecx,[edi+1C]
push dword ptr [esi+48]
test eax,eax
jz ctl_reveal_off
call REVEALADD
mov dword ptr [cnc_state+38],1
jmp ctl_visual_refresh
ctl_reveal_off:
call REVEALOFF
mov dword ptr [cnc_state+38],0
ctl_visual_refresh:
mov ecx,[edi+1C]
call REFRESH
mov eax,[cnc_state+3C]
mov [cnc_state+40],eax
fxrstor [esp]
mov esp,ebp
jmp ctl_promote
ctl_promote:
cmp dword ptr [cnc_state+54],1
jne ctl_done
mov dword ptr [cnc_state+54],0
mov dword ptr [cnc_state+58],4
mov eax,[SELECTIONGLOBAL]
test eax,eax
je ctl_done
mov ebx,[eax+40]
test ebx,ebx
je ctl_done
cmp ebx,[cnc_state+4C]
jne ctl_done
mov edi,[ebx]
cmp edi,[cnc_state+50]
jne ctl_done
mov ebp,esp
sub esp,220
and esp,-10
fxsave [esp]
mov dword ptr [cnc_state+58],2
ctl_promote_next:
test edi,edi
je ctl_promote_finish
cmp edi,ebx
je ctl_promote_finish
mov eax,[edi+8]
test eax,eax
je ctl_promote_skip
mov esi,[eax+140]
test esi,esi
je ctl_promote_skip
mov eax,[esi+OWNER_OFFSET]
test eax,eax
je ctl_promote_skip
mov eax,[eax+4]
test eax,eax
je ctl_promote_skip
mov eax,[eax+8]
cmp eax,[cnc_state]
jne ctl_promote_skip
mov ecx,[esi+XP_OFFSET]
test ecx,ecx
je ctl_promote_skip
cmp [ecx+3C],esi
jne ctl_promote_skip
push 0
push 1
push 3
call PROMOTE
test al,al
je ctl_promote_skip
mov dword ptr [cnc_state+58],3
ctl_promote_skip:
mov edi,[edi]
jmp ctl_promote_next
ctl_promote_finish:
fxrstor [esp]
mov esp,ebp
jmp ctl_done
ctl_invalid:
cmp dword ptr [cnc_state+54],1
jne ctl_invalid_state
mov dword ptr [cnc_state+54],0
mov dword ptr [cnc_state+58],4
ctl_invalid_state:
mov dword ptr [cnc_state+1C],0
ctl_done:
cmp dword ptr [cnc_state+68],1
jne ctl_return
cmp dword ptr [cnc_state+1C],0
je ctl_retire
cmp dword ptr [cnc_state+10],0
jne ctl_return
cmp dword ptr [cnc_state+18],0
jne ctl_return
cmp dword ptr [cnc_state+38],0
jne ctl_return
cmp dword ptr [cnc_state+40],0
jne ctl_return
ctl_retire:
mov ebx,cnc_controller_return
sub ebx,7
mov eax,[ebx]
and eax,000000FF
cmp eax,000000E9
jne ctl_return
mov eax,cnc_controller_code
lea edx,[ebx+5]
sub eax,edx
cmp [ebx+1],eax
jne ctl_return
mov eax,[ebx+5]
and eax,0000FFFF
cmp eax,9066
jne ctl_return
mov eax,[ebx+4]
and eax,0FF000000
or eax,0024718D
mov [ebx+4],eax
mov dword ptr [ebx],1A6A5756
mov dword ptr [cnc_state+1C],0
mov dword ptr [cnc_state+68],2
ctl_return:
popad
popfd

push esi
push edi
push 1A
lea esi,[ecx+24]
jmp cnc_controller_return
cnc_controller_hook:
jmp cnc_controller_code
nop 2
cnc_controller_return:
[DISABLE]
cnc_controller_hook:
db 56 57 6a 1a 8d 71 24
unregistersymbol(cnc_controller_hook)
dealloc(cnc_controller_code)
unregistersymbol(cnc_state)
dealloc(cnc_state)
]==],money=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_money_hook,cnc3ep1.dat,29 06 8b 53 0c 8b 0d 10 7b bf 00 01 45 50 52 e8 54 32 ff ff 8b 4d 5c 89)
assert(cnc_money_hook,29 06 8b 53 0c)
alloc(cnc_money_code,0x400,cnc_money_hook)
label(cnc_money_return)
label(money_done)
registersymbol(cnc_money_hook)

cnc_money_code:
sub [esi],eax
pushfd
push ecx
cmp dword ptr [cnc_state+1C],1
jne money_done
cmp dword ptr [cnc_state+10],1
jne money_done
cmp ebx,[cnc_state+4]
jne money_done
mov ecx,[PLAYERGLOBAL]
test ecx,ecx
je money_done
mov ecx,[ecx+1C]
cmp ecx,[cnc_state]
jne money_done
mov ecx,[LOGICGLOBAL]
cmp ecx,[cnc_state+24]
jne money_done
test ecx,ecx
je money_done
mov ecx,[ecx+38]
cmp ecx,[cnc_state+20]
jb money_done
cmp dword ptr [esi],7530
jae money_done
mov dword ptr [esi],7530
money_done:
pop ecx
popfd
mov edx,[ebx+0xC]

jmp cnc_money_return
cnc_money_hook:
jmp cnc_money_code
cnc_money_return:
[DISABLE]
cnc_money_hook:
db 29 06 8b 53 0c
unregistersymbol(cnc_money_hook)
dealloc(cnc_money_code)
]==],instant=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_instant_hook,cnc3ep1.dat,f3 0f 10 4b 20 f3 0f 58 4b 1c f3 0f 10 05 a4 73 a1 00 0f 2f c1 f3 0f 11)
assert(cnc_instant_hook,f3 0f 10 4b 20)
alloc(cnc_instant_code,0x400,cnc_instant_hook)
label(cnc_instant_return)
label(build_done)
registersymbol(cnc_instant_hook)

cnc_instant_code:
movss xmm1,[ebx+20]
pushfd
push eax
cmp dword ptr [cnc_state+1C],1
jne build_done
cmp dword ptr [cnc_state+28],1
jne build_done
cmp edi,[cnc_state]
jne build_done
mov eax,[PLAYERGLOBAL]
test eax,eax
je build_done
cmp edi,[eax+1C]
jne build_done
mov eax,[LOGICGLOBAL]
cmp eax,[cnc_state+24]
jne build_done
test eax,eax
je build_done
mov eax,[eax+38]
cmp eax,[cnc_state+20]
jb build_done
movss xmm1,[cnc_state+2C]
build_done:
pop eax
popfd

jmp cnc_instant_return
cnc_instant_hook:
jmp cnc_instant_code
cnc_instant_return:
[DISABLE]
cnc_instant_hook:
db f3 0f 10 4b 20
unregistersymbol(cnc_instant_hook)
dealloc(cnc_instant_code)
]==],ready=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
aobscanmodule(cnc_ready_hook,cnc3ep1.dat,a1 98 7f bf 00 80 b8 a2 00 00 00 00 56 8b f1 75 04 32 c0 5e c3 80 7e 28)
assert(cnc_ready_hook,a1 98 7f bf 00)
alloc(cnc_ready_code,0x400,cnc_ready_hook)
label(cnc_ready_return)
label(ready_normal)
registersymbol(cnc_ready_hook)

cnc_ready_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne ready_normal
cmp dword ptr [cnc_state+30],1
jne ready_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je ready_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne ready_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je ready_normal
cmp ebx,[cnc_state+24]
jne ready_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb ready_normal
mov ebx,[ecx-8]
test ebx,ebx
je ready_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je ready_normal
mov ebx,[ebx+4]
test ebx,ebx
je ready_normal
cmp edx,[ebx+8]
jne ready_normal
pop ebx
pop edx
popfd
mov eax,1
ret
ready_normal:
pop ebx
pop edx
popfd
db a1 98 7f bf 00

jmp cnc_ready_return
cnc_ready_hook:
jmp cnc_ready_code
cnc_ready_return:
[DISABLE]
cnc_ready_hook:
db a1 98 7f bf 00
unregistersymbol(cnc_ready_hook)
dealloc(cnc_ready_code)
]==],progress=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
aobscanmodule(cnc_progress_hook,cnc3ep1.dat,55 8b ec 51 a1 98 7f bf 00 80 b8 a2 00 00 00 00 53 56 57 8b f1 0f 84 ba)
assert(cnc_progress_hook,55 8b ec 51 a1 98 7f bf 00)
alloc(cnc_progress_code,0x400,cnc_progress_hook)
label(cnc_progress_return)
label(progress_normal)
registersymbol(cnc_progress_hook)

cnc_progress_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne progress_normal
cmp dword ptr [cnc_state+30],1
jne progress_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je progress_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne progress_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je progress_normal
cmp ebx,[cnc_state+24]
jne progress_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb progress_normal
mov ebx,[ecx-8]
test ebx,ebx
je progress_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je progress_normal
mov ebx,[ebx+4]
test ebx,ebx
je progress_normal
cmp edx,[ebx+8]
jne progress_normal
pop ebx
pop edx
popfd
fld1
ret
progress_normal:
pop ebx
pop edx
popfd
db 55 8b ec 51 a1 98 7f bf 00

jmp cnc_progress_return
cnc_progress_hook:
jmp cnc_progress_code
nop 4
cnc_progress_return:
[DISABLE]
cnc_progress_hook:
db 55 8b ec 51 a1 98 7f bf 00
unregistersymbol(cnc_progress_hook)
dealloc(cnc_progress_code)
]==],deadline=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
aobscanmodule(cnc_deadline_hook,cnc3ep1.dat,56 8b f1 8b 06 57 ff 50 1c 6a 0d 8b c8 e8 5f ee e9 ff 84 c0 74 23 8b 4e)
assert(cnc_deadline_hook,56 8b f1 8b 06)
alloc(cnc_deadline_code,0x400,cnc_deadline_hook)
label(cnc_deadline_return)
label(deadline_normal)
registersymbol(cnc_deadline_hook)

cnc_deadline_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne deadline_normal
cmp dword ptr [cnc_state+30],1
jne deadline_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je deadline_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne deadline_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je deadline_normal
cmp ebx,[cnc_state+24]
jne deadline_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb deadline_normal
mov ebx,[ecx-8]
test ebx,ebx
je deadline_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je deadline_normal
mov ebx,[ebx+4]
test ebx,ebx
je deadline_normal
cmp edx,[ebx+8]
jne deadline_normal
pop ebx
pop edx
popfd
mov eax,[LOGICGLOBAL]
mov eax,[eax+38]
ret
deadline_normal:
pop ebx
pop edx
popfd
db 56 8b f1 8b 06

jmp cnc_deadline_return
cnc_deadline_hook:
jmp cnc_deadline_code
cnc_deadline_return:
[DISABLE]
cnc_deadline_hook:
db 56 8b f1 8b 06
unregistersymbol(cnc_deadline_hook)
dealloc(cnc_deadline_code)
]==],afford=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
aobscanmodule(cnc_afford_hook,cnc3ep1.dat,56 8b 74 24 08 8b 46 1c 83 b8 40 01 00 00 00 7c 04 b0 01 eb 2a 80 3d 3a)
assert(cnc_afford_hook,56 8b 74 24 08)
alloc(cnc_afford_code,0x400,cnc_afford_hook)
label(cnc_afford_return)
label(afford_normal)
registersymbol(cnc_afford_hook)

cnc_afford_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne afford_normal
cmp dword ptr [cnc_state+30],1
jne afford_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je afford_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne afford_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je afford_normal
cmp ebx,[cnc_state+24]
jne afford_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb afford_normal
mov ebx,[ecx+0xC]
test ebx,ebx
je afford_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je afford_normal
mov ebx,[ebx+4]
test ebx,ebx
je afford_normal
cmp edx,[ebx+8]
jne afford_normal
pop ebx
pop edx
popfd
mov eax,1
ret 4
afford_normal:
pop ebx
pop edx
popfd
db 56 8b 74 24 08

jmp cnc_afford_return
cnc_afford_hook:
jmp cnc_afford_code
cnc_afford_return:
[DISABLE]
cnc_afford_hook:
db 56 8b 74 24 08
unregistersymbol(cnc_afford_hook)
dealloc(cnc_afford_code)
]==],spcost=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_spcost_hook,cnc3ep1.dat,8b 80 40 01 00 00 85 c0 8b 75 fc 74 47 8b 57 0c 8b 4e 60 8b 92 ec 00 00)
assert(cnc_spcost_hook,8b 80 40 01 00 00)
alloc(cnc_spcost_code,0x400,cnc_spcost_hook)
label(cnc_spcost_return)
label(spcost_normal)
registersymbol(cnc_spcost_hook)

cnc_spcost_code:
mov eax,[eax+140]
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne spcost_normal
cmp dword ptr [cnc_state+30],1
jne spcost_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je spcost_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne spcost_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je spcost_normal
cmp ebx,[cnc_state+24]
jne spcost_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb spcost_normal
cmp edx,[ebp-4]
jne spcost_normal
test eax,eax
jns spcost_normal
xor eax,eax
spcost_normal:
pop ebx
pop edx
popfd

jmp cnc_spcost_return
cnc_spcost_hook:
jmp cnc_spcost_code
nop 1
cnc_spcost_return:
[DISABLE]
cnc_spcost_hook:
db 8b 80 40 01 00 00
unregistersymbol(cnc_spcost_hook)
dealloc(cnc_spcost_code)
]==],notify=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_notify_hook,cnc3ep1.dat,55 8b ec 83 ec 18 ff 75 10 33 c9 ff 75 0c b8 28 f0 78 00 ff 75 08 51 50 8d 45 e8 50 e8 9a f9 ff ff 83 c4 18 50 e8 9f ff)
assert(cnc_notify_hook,55 8b ec 83 ec 18)
alloc(cnc_notify_code,0x400,cnc_notify_hook)
label(cnc_notify_return)
label(notify_normal)
registersymbol(cnc_notify_hook)

cnc_notify_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne notify_normal
cmp dword ptr [cnc_state+3C],1
jne notify_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je notify_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne notify_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je notify_normal
cmp ebx,[cnc_state+24]
jne notify_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb notify_normal
mov dword ptr [esp+18],1
notify_normal:
pop ebx
pop edx
popfd
db 55 8b ec 83 ec 18

jmp cnc_notify_return
cnc_notify_hook:
jmp cnc_notify_code
nop 1
cnc_notify_return:
[DISABLE]
cnc_notify_hook:
db 55 8b ec 83 ec 18
unregistersymbol(cnc_notify_hook)
dealloc(cnc_notify_code)
]==],drawcull=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_drawcull_hook,cnc3ep1.dat,83 f8 03 89 45 ec 7c 5e 83 be 28 02 00 00 00 74 55 d9 05 08 6c a1 00 6a)
assert(cnc_drawcull_hook,83 f8 03 89 45 ec)
alloc(cnc_drawcull_code,0x400,cnc_drawcull_hook)
label(cnc_drawcull_return)
label(drawcull_normal)
registersymbol(cnc_drawcull_hook)

cnc_drawcull_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne drawcull_normal
cmp dword ptr [cnc_state+3C],1
jne drawcull_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je drawcull_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne drawcull_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je drawcull_normal
cmp ebx,[cnc_state+24]
jne drawcull_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb drawcull_normal
mov ebx,[ebp-0xC]
cmp ebx,[edx+48]
jne drawcull_normal
mov eax,1
drawcull_normal:
pop ebx
pop edx
popfd
db 83 f8 03 89 45 ec

jmp cnc_drawcull_return
cnc_drawcull_hook:
jmp cnc_drawcull_code
nop 1
cnc_drawcull_return:
[DISABLE]
cnc_drawcull_hook:
db 83 f8 03 89 45 ec
unregistersymbol(cnc_drawcull_hook)
dealloc(cnc_drawcull_code)
]==],drawshade=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_drawshade_hook,cnc3ep1.dat,83 f8 01 89 45 fc 75 10 a1 98 7f bf 00 8b 40 38 89 87 28 02 00 00 eb 66)
assert(cnc_drawshade_hook,83 f8 01 89 45 fc)
alloc(cnc_drawshade_code,0x400,cnc_drawshade_hook)
label(cnc_drawshade_return)
label(drawshade_normal)
registersymbol(cnc_drawshade_hook)

cnc_drawshade_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne drawshade_normal
cmp dword ptr [cnc_state+3C],1
jne drawshade_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je drawshade_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne drawshade_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je drawshade_normal
cmp ebx,[cnc_state+24]
jne drawshade_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb drawshade_normal
mov ebx,[ebp+10]
cmp ebx,[edx+48]
jne drawshade_normal
mov eax,1
drawshade_normal:
pop ebx
pop edx
popfd
db 83 f8 01 89 45 fc

jmp cnc_drawshade_return
cnc_drawshade_hook:
jmp cnc_drawshade_code
nop 1
cnc_drawshade_return:
[DISABLE]
cnc_drawshade_hook:
db 83 f8 01 89 45 fc
unregistersymbol(cnc_drawshade_hook)
dealloc(cnc_drawshade_code)
]==],silos=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
aobscanmodule(cnc_silos_hook,cnc3ep1.dat,50 50 50 6a 1c e8 93 83 e5 ff e9 80 00 00 00 8b 45 08 8b 80 ec 00 00 00)
assert(cnc_silos_hook,50 50 50 6a 1c)
alloc(cnc_silos_code,0x400,cnc_silos_hook)
label(cnc_silos_return)
label(silos_normal)
registersymbol(cnc_silos_hook)

cnc_silos_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne silos_normal
cmp dword ptr [cnc_state+C],1
jne silos_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je silos_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne silos_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je silos_normal
cmp ebx,[cnc_state+24]
jne silos_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb silos_normal
cmp edx,[esp]
jne silos_normal
pop ebx
pop edx
popfd
jmp cnc_silos_hook+0A
silos_normal:
pop ebx
pop edx
popfd
db 50 50 50 6a 1c

jmp cnc_silos_return
cnc_silos_hook:
jmp cnc_silos_code
cnc_silos_return:
[DISABLE]
cnc_silos_hook:
db 50 50 50 6a 1c
unregistersymbol(cnc_silos_hook)
dealloc(cnc_silos_code)
]==],ammo=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
aobscanmodule(cnc_ammo_hook,cnc3ep1.dat,ff 4b 18 ff 4b 20 ff 4b 28 39 7b 28 7f 2e ff 73 14 8b 45 08 ff 43 24 ff)
assert(cnc_ammo_hook,ff 4b 18 ff 4b 20)
alloc(cnc_ammo_code,0x400,cnc_ammo_hook)
label(cnc_ammo_return)
label(ammo_normal)
registersymbol(cnc_ammo_hook)

cnc_ammo_code:
pushfd
push edx
push ebx
cmp dword ptr [cnc_state+1C],1
jne ammo_normal
cmp dword ptr [cnc_state+48],1
jne ammo_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je ammo_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne ammo_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je ammo_normal
cmp ebx,[cnc_state+24]
jne ammo_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb ammo_normal
mov ebx,[ebp+8]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
test dword ptr [ebx+124],4000
je ammo_normal
mov ebx,[ebp+8]
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
cmp edx,[ebx+8]
jne ammo_normal
mov ebx,[esp]
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
mov ebx,[ebx+4]
test ebx,ebx
je ammo_normal
cmp dword ptr [ebx+0xF0],2
jne ammo_normal
pop ebx
pop edx
popfd
dec dword ptr [ebx+20]
jmp cnc_ammo_return
ammo_normal:
pop ebx
pop edx
popfd
db ff 4b 18 ff 4b 20

jmp cnc_ammo_return
cnc_ammo_hook:
jmp cnc_ammo_code
nop 1
cnc_ammo_return:
[DISABLE]
cnc_ammo_hook:
db ff 4b 18 ff 4b 20
unregistersymbol(cnc_ammo_hook)
dealloc(cnc_ammo_code)
]==],invulnerability=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
define(OBJECT_ID,0xEC)
define(HORDEROOT,cnc3ep1.dat+0x26E6D1)
aobscanmodule(cnc_invulnerability_hook,cnc3ep1.dat,8b 44 24 04 83 78 10 08 75 04 32 c0 eb 32 80 b9 df 00 00 00 00 75 27 8b)
assert(cnc_invulnerability_hook,8b 44 24 04 83 78 10 08)
assert(HORDEROOT,57 8b f9 8b 47 04 8b 80 30 01 00 00 c1 e8 0f a8 01 74 04 8b c7 eb 75 8b)
alloc(cnc_invulnerability_code,0x400,cnc_invulnerability_hook)
label(cnc_invulnerability_return)
label(invulnerability_retry)
label(invulnerability_search)
label(invulnerability_lower)
label(invulnerability_parent)
label(invulnerability_found)
label(invulnerability_normal)
registersymbol(cnc_invulnerability_hook)

cnc_invulnerability_code:
pushfd
push edx
push ebx
push ecx
push esi
push edi
push ebp
cmp dword ptr [cnc_state+1C],1
jne invulnerability_normal
cmp dword ptr [cnc_state+5C],1
jne invulnerability_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je invulnerability_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne invulnerability_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je invulnerability_normal
cmp ebx,[cnc_state+24]
jne invulnerability_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb invulnerability_normal
mov ebx,[ecx+0xC]
test ebx,ebx
je invulnerability_normal
mov ebp,ebx
invulnerability_retry:
mov edi,[cnc_state+60]
test edi,edi
je invulnerability_normal
mov ecx,[edi]
add edi,10
xor esi,esi
invulnerability_search:
cmp esi,ecx
jae invulnerability_parent
mov edx,esi
add edx,ecx
shr edx,1
cmp ebx,[edi+edx*8]
je invulnerability_found
jb invulnerability_lower
lea esi,[edx+1]
jmp invulnerability_search
invulnerability_lower:
mov ecx,edx
jmp invulnerability_search
invulnerability_parent:
cmp ebx,ebp
jne invulnerability_normal
mov ecx,[ebp+OWNER_OFFSET]
test ecx,ecx
je invulnerability_normal
mov ecx,[ecx+4]
test ecx,ecx
je invulnerability_normal
mov ecx,[ecx+8]
cmp ecx,[cnc_state]
jne invulnerability_normal
push eax
mov ecx,ebp
push 0
call HORDEROOT
mov ebx,eax
pop eax
test ebx,ebx
je invulnerability_normal
cmp ebx,ebp
je invulnerability_normal
jmp invulnerability_retry
invulnerability_found:
mov esi,[ebx+OBJECT_ID]
cmp esi,[edi+edx*8+4]
jne invulnerability_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je invulnerability_normal
mov ebx,[ebx+4]
test ebx,ebx
je invulnerability_normal
mov edx,[cnc_state]
cmp edx,[ebx+8]
jne invulnerability_normal
mov ebx,[esp+20]
test ebx,ebx
je invulnerability_normal
cmp dword ptr [ebx+10],8
je invulnerability_normal
cmp dword ptr [ebx+2C],0
jle invulnerability_normal
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
mov al,1
ret 4
invulnerability_normal:
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
db 8b 44 24 04 83 78 10 08

jmp cnc_invulnerability_return
cnc_invulnerability_hook:
jmp cnc_invulnerability_code
nop 3
cnc_invulnerability_return:
[DISABLE]
cnc_invulnerability_hook:
db 8b 44 24 04 83 78 10 08
unregistersymbol(cnc_invulnerability_hook)
dealloc(cnc_invulnerability_code)
]==],protectionhighlight=[==[[ENABLE]
define(PLAYERGLOBAL,cnc3ep1.dat+0x7F7B10)
define(LOGICGLOBAL,cnc3ep1.dat+0x7F7F98)
define(OWNER_OFFSET,0x348)
define(OBJECT_ID,0xEC)
define(HORDEROOT,cnc3ep1.dat+0x26E6D1)
aobscanmodule(cnc_protectionhighlight_hook,cnc3ep1.dat,5f 5e c2 04 00 55 8b ec 51 57 8b f9 f3 0f 10 87 e0 01 00 00 8d 87 d0 01)
assert(cnc_protectionhighlight_hook,5f 5e c2 04 00)
assert(HORDEROOT,57 8b f9 8b 47 04 8b 80 30 01 00 00 c1 e8 0f a8 01 74 04 8b c7 eb 75 8b)
alloc(cnc_protectionhighlight_code,0x400,cnc_protectionhighlight_hook)
label(cnc_protectionhighlight_return)
label(protectionhighlight_retry)
label(protectionhighlight_search)
label(protectionhighlight_lower)
label(protectionhighlight_parent)
label(protectionhighlight_found)
label(protectionhighlight_normal)
registersymbol(cnc_protectionhighlight_hook)

cnc_protectionhighlight_code:
pushfd
push edx
push ebx
push ecx
push esi
push edi
push ebp
cmp dword ptr [cnc_state+1C],1
jne protectionhighlight_normal
cmp dword ptr [cnc_state+5C],1
jne protectionhighlight_normal
mov edx,[PLAYERGLOBAL]
test edx,edx
je protectionhighlight_normal
mov edx,[edx+1C]
cmp edx,[cnc_state]
jne protectionhighlight_normal
mov ebx,[LOGICGLOBAL]
test ebx,ebx
je protectionhighlight_normal
cmp ebx,[cnc_state+24]
jne protectionhighlight_normal
mov ebx,[ebx+38]
cmp ebx,[cnc_state+20]
jb protectionhighlight_normal
mov ebx,[edi+140]
test ebx,ebx
je protectionhighlight_normal
mov ebp,ebx
protectionhighlight_retry:
mov edi,[cnc_state+60]
test edi,edi
je protectionhighlight_normal
mov ecx,[edi]
add edi,10
xor esi,esi
protectionhighlight_search:
cmp esi,ecx
jae protectionhighlight_parent
mov edx,esi
add edx,ecx
shr edx,1
cmp ebx,[edi+edx*8]
je protectionhighlight_found
jb protectionhighlight_lower
lea esi,[edx+1]
jmp protectionhighlight_search
protectionhighlight_lower:
mov ecx,edx
jmp protectionhighlight_search
protectionhighlight_parent:
cmp ebx,ebp
jne protectionhighlight_normal
mov ecx,[ebp+OWNER_OFFSET]
test ecx,ecx
je protectionhighlight_normal
mov ecx,[ecx+4]
test ecx,ecx
je protectionhighlight_normal
mov ecx,[ecx+8]
cmp ecx,[cnc_state]
jne protectionhighlight_normal
push eax
mov ecx,ebp
push 0
call HORDEROOT
mov ebx,eax
pop eax
test ebx,ebx
je protectionhighlight_normal
cmp ebx,ebp
je protectionhighlight_normal
jmp protectionhighlight_retry
protectionhighlight_found:
mov esi,[ebx+OBJECT_ID]
cmp esi,[edi+edx*8+4]
jne protectionhighlight_normal
mov ebx,[ebx+OWNER_OFFSET]
test ebx,ebx
je protectionhighlight_normal
mov ebx,[ebx+4]
test ebx,ebx
je protectionhighlight_normal
mov edx,[cnc_state]
cmp edx,[ebx+8]
jne protectionhighlight_normal
mov ecx,[esp+8]
mov edx,[edi-0xC]
mov [ecx],edx
mov edx,[edi-8]
mov [ecx+4],edx
mov edx,[edi-4]
mov [ecx+8],edx
protectionhighlight_normal:
pop ebp
pop edi
pop esi
pop ecx
pop ebx
pop edx
popfd
db 5f 5e c2 04 00

jmp cnc_protectionhighlight_return
cnc_protectionhighlight_hook:
jmp cnc_protectionhighlight_code
cnc_protectionhighlight_return:
[DISABLE]
cnc_protectionhighlight_hook:
db 5f 5e c2 04 00
unregistersymbol(cnc_protectionhighlight_hook)
dealloc(cnc_protectionhighlight_code)
]==]}}
}
local list=getAddressList()
local status=list.getMemoryRecordByID(1)
local mains={tw=list.getMemoryRecordByID(10),kw=list.getMemoryRecordByID(20)}
local hookOrder={'controller','money','instant','ready','progress','deadline','afford','spcost','notify','drawcull','drawshade','silos','ammo','invulnerability','protectionhighlight'}
local hookSizes={controller=7,money=5,instant=5,ready=5,progress=9,deadline=5,afford=5,spcost=6,notify=6,drawcull=6,drawshade=6,silos=5,ammo=6,invulnerability=8,protectionhighlight=5}
local ids={money=1,power=2,instant=3,super=4,visual=5,full=6,ammo=7}
local flagOffsets={money=0xC,power=0x14,instant=0x28,super=0x30,visual=0x3C,full=0x34,ammo=0x48,invulnerability=0x5C}
local suppress=false
local function report(message)
  if not S.recordsRemoved and S.lastStatus~=message then
    status.Description='Auto-Attach and Version Check — '..message
    S.lastStatus=message
  end
end
local function tell(message) if not S.closing then showMessage(message) end end
local function baseName(path) return (path:match('[^/\\]+$') or path):lower() end
local function run(script,disableInfo)
  local ok,a,b=pcall(autoAssemble,script,false,disableInfo)
  if not ok or not a then S.lastError=tostring(b or a); return false end
  return true,b
end
local function context()
  if not S.base or getOpenedProcessID()~=S.pid then return end
  local c=configs[S.game]
  local players=readInteger(S.base+c.player)
  local logic=readInteger(S.base+c.logic)
  local shroud=readInteger(S.base+c.shroud)
  if not shroud or shroud==0 then return end
  local shroudImpl=readInteger(shroud+0x1C)
  if not shroudImpl or shroudImpl==0 then return end
  if not players or players==0 or not logic or logic==0 then return end
  local p=readInteger(players+0x1C)
  if not p or p==0 then return end
  local money=readInteger(p+0x60)
  local energy=readInteger(p+0x80)
  local id=readInteger(p+0x48)
  if not money or money==0 or not energy or energy==0 or not id then return end
  if readInteger(money+0xC)~=id or readInteger(energy+0x14)~=p then return end
  local frame=readInteger(logic+0x38)
  local cash=readInteger(money+4)
  local cap=readInteger(money+8)
  if not frame or frame==0 or not cash or not cap or cash&gt;1000000000 or cap&gt;1000000000 then return end
  return {p=p,money=money,energy=energy,logic=logic,frame=frame,shroud=shroud}
end
local function owned()
  local c=context()
  return c and S.bound and c.p==S.bound.p and c.money==S.bound.money and
    c.energy==S.bound.energy and c.logic==S.bound.logic and c.shroud==S.bound.shroud and c.frame&gt;=(readInteger(S.state+0x20) or S.bound.frame)
end
local function write(offset,value)
  if not S.state or getOpenedProcessID()~=S.pid then return false end
  if readInteger(S.state+offset)==value then return true end
  return writeInteger(S.state+offset,value) and readInteger(S.state+offset)==value
end
local function uncheck()
  if S.recordsRemoved then return end
  suppress=true
  for _,rec in pairs(mains) do
    for i=0,rec.Count-1 do if rec.Child[i].Active then rec.Child[i].Active=false end end
    if rec.Active then rec.Active=false end
  end
  suppress=false
end
local function forgetExitedProcess()
  if not S.state or getProcesslist()[S.pid] then return false end
  -- The dead process owns no memory to restore or free. Remove only CE symbols.
  for _,kind in ipairs(hookOrder) do unregisterSymbol('cnc_'..kind..'_hook') end
  unregisterSymbol('cnc_state')
  S.installed={}; S.state=nil; S.bound=nil; S.stopping=false; S.offRequested=false
  S.pid=nil; S.base=nil; S.supported=nil
  S.transition=nil; S.candidate=nil
  uncheck()
  return true
end
local function uninstall(keepController)
  if not keepController and S.state and not write(0x1C,0) then return false end
  for i=#hookOrder,1,-1 do
    local kind=hookOrder[i]
    if S.installed[kind] and not (keepController and kind=='controller') then
      local info=S.installed[kind]
      if info.patch then
        for i,byte in ipairs(info.patch) do
          if readBytes(info.hook+i-1,1)~=byte then
            report('Another patch changed the game code; cleanup stopped to avoid overwriting it')
            return false
          end
        end
      end
      if info.patch and info.original then
        -- Restore using captured numeric addresses; no dependency on CE's symbol
        -- or disableInfo bookkeeping surviving a table replacement.
        local ok=pcall(writeBytes,info.hook,info.original)
        for n,byte in ipairs(info.original) do
          if readBytes(info.hook+n-1,1)~=byte then ok=false; break end
        end
        if not ok then report('Code cleanup failed; keep this table open and retry Clear All'); return false end
        unregisterSymbol('cnc_'..kind..'_hook')
        if kind=='controller' then unregisterSymbol('cnc_state') end
        -- Keep detached code allocated until process exit, so an in-flight game
        -- thread can safely finish returning through it. No hooks remain active.
      elseif not run(configs[S.game].scripts[kind],info) then
        report('Cleanup failed; keep this table open and retry Clear All')
        return false
      end
      S.installed[kind]=nil
    end
  end
  if keepController then return write(0x68,1) end
  S.state=nil; S.bound=nil; S.stopping=false; S.offRequested=false
  S.transition=nil; S.candidate=nil
  uncheck()
  return true
end
function S.clear()
  S.menu=nil
  if forgetExitedProcess() then return true end
  if not S.state then
    if next(S.installed) then return uninstall() end
    uncheck(); return true
  end
  if getOpenedProcessID()~=S.pid then
    report('Select the original game process to finish cleanup')
    return false
  end
  if not write(0x54,0) then return false end
  S.stopping=true
  S.offRequested=false
  if not owned() or readInteger(S.state+0x1C)==0 then
    -- The previous match no longer owns these addresses. Never restore into it.
    return uninstall()
  end
  for _,off in pairs(flagOffsets) do if not write(off,0) then return false end end
  S.offRequested=true
  uncheck()
  if readInteger(S.state+0x10)==0 and readInteger(S.state+0x18)==0 and readInteger(S.state+0x38)==0 and readInteger(S.state+0x40)==0 then return uninstall() end
  report('All options unticked — cleanup pending; resume the game to finish')
  return false
end
local function install()
  local ctx=context()
  if not ctx then tell('Enter a mission or skirmish and try again.'); return false end
  S.bound=ctx
  for _,kind in ipairs(hookOrder) do
    local ok,info=run(configs[S.game].scripts[kind])
    if not ok then
      local failure=S.lastError or ''
      uninstall()
      S.lastError=failure
      if failure:find("can't be compiled",1,true) or failure:find('syntax',1,true) then
        tell('The table could not assemble its game code. This is a table error, not leftover cheats or a game-version mismatch.')
      else
        tell('The table could not install its game code. Use the latest table for this game build; another active table can also prevent installation.')
      end
      return false
    end
    S.installed[kind]=info
    local hook=getAddressSafe('cnc_'..kind..'_hook')
    local allocation=info and info.allocs and info.allocs['cnc_'..kind..'_code']
    local displacement=hook and readInteger(hook+1)
    if not allocation or not displacement or readBytes(hook,1)~=0xE9 or
      (hook+5+displacement)%0x100000000~=allocation.address then
      uninstall()
      tell('The game did not accept the patch. Turn off other tables and try MAIN again.')
      return false
    end
    info.hook=hook; info.patch={}; info.original={}
    local original=configs[S.game].scripts[kind]:match('%[DISABLE%]%s*[^\n]+:%s*db ([^\n]+)')
    for byte in original:gmatch('%x%x') do info.original[#info.original+1]=tonumber(byte,16) end
    for i=1,hookSizes[kind] do info.patch[i]=readBytes(hook+i-1,1) end
  end
  S.state=getAddressSafe('cnc_state')
  if not S.state then uninstall(); return false end
  for off,value in pairs({[0]=ctx.p,[4]=ctx.money,[8]=ctx.energy,[0x20]=ctx.frame,[0x24]=ctx.logic,[0x44]=ctx.shroud}) do
    if not write(off,value) then uninstall(); tell('The table could not prepare this match. Try activating MAIN again.'); return false end
  end
  if not write(0x1C,1) then uninstall(); return false end
  return true
end
-- Keep the existing hooks dormant while map objects are being replaced.
-- A new context must advance across two polls before its allowances are applied.
local function sameMatch(a,b)
  return a and b and a.p==b.p and a.money==b.money and a.energy==b.energy and
    a.logic==b.logic and a.shroud==b.shroud
end
local function resumeMatch()
  if not write(0x54,0) then return false end
  if not write(0x1C,0) then return false end
  S.transition=true
  local ctx=context()
  if not ctx then
    S.candidate=nil
    report('Selections saved - waiting for the next map')
    return false
  end
  local previousFrame=readInteger(S.state+0x20)
  local unchanged=sameMatch(ctx,S.bound) and previousFrame and ctx.frame&gt;=previousFrame
  if not unchanged and (not sameMatch(ctx,S.candidate) or ctx.frame&lt;=S.candidate.frame) then
    S.candidate=ctx
    report('Selections saved - waiting for the new map to run')
    return false
  end
  if not unchanged then
    if not write(0x5C,0) then return false end
    suppress=true
    list.getMemoryRecordByID((S.game=='tw' and 10 or 20)+9).Active=false
    suppress=false
    -- Old resources belong to the previous map: never subtract from or restore them.
    for _,off in ipairs({0x10,0x18,0x38,0x40}) do if not write(off,0) then return false end end
    for off,value in pairs({[0]=ctx.p,[4]=ctx.money,[8]=ctx.energy,[0x20]=ctx.frame,
        [0x24]=ctx.logic,[0x44]=ctx.shroud}) do
      if not write(off,value) then return false end
    end
    S.bound=ctx
  end
  if not write(0x1C,1) then return false end
  S.transition=nil; S.candidate=nil
  report(configs[S.game].title..' | '..S.version..' | Selections active')
  return true
end
function S.poll(requested)
  forgetExitedProcess()
  if S.menu then
    if not getProcesslist()[S.menu.pid] then
      S.menu=nil; uncheck()
    elseif requested and requested~=S.menu.game then
      S.menu=nil; uncheck()
    else
      if getOpenedProcessID()~=S.menu.pid then
        report('Return to the selected game process or use Clear All'); return false
      end
      if not context() then report('Options selected - waiting for a mission or skirmish'); return true end
      local choices=S.menu.choices
      if not install() then S.menu=nil; uncheck(); return false end
      S.menu=nil
      for name,on in pairs(choices) do
        if on and not write(flagOffsets[name],1) then S.clear(); return false end
      end
      report(configs[S.game].title..' | '..S.version..' | Selections active')
      return true
    end
  end
  if S.state and S.stopping then
    if not S.clear() then return false end
  end
  if S.state then
    if getOpenedProcessID()~=S.pid then
      report('Return to the original game process and use Clear All before switching')
      return false
    end
    if requested and requested~=S.game then
      if not S.clear() then return false end
    elseif not owned() or readInteger(S.state+0x1C)==0 then
      return resumeMatch()
    else
      local result=readInteger(S.state+0x58)
      if result and result~=0 and write(0x58,0) then
        report(result==3 and 'Selected eligible units promoted to maximum veterancy' or result==2 and 'No selected units needed or supported promotion' or 'Promotion cancelled - selection or match changed')
      end
      return true
    end
  end
  local found={}
  for pid,name in pairs(getProcesslist()) do
    for key,c in pairs(configs) do
      if baseName(name)==c.module and (not requested or key==requested) then found[#found+1]={pid=pid,key=key} end
    end
  end
  local selected
  for _,candidate in ipairs(found) do if candidate.pid==getOpenedProcessID() then selected=candidate; break end end
  if not selected and #found==1 then selected=found[1] end
  if not selected then
    if not requested then report(#found&gt;1 and 'Both games available — tick either MAIN' or 'Waiting for either game') end
    return false
  end
  local c=configs[selected.key]
  local module
  for _,m in ipairs(enumModules(selected.pid) or {}) do
    if baseName(m.PathToFile or m.Name)==c.module then module=m; break end
  end
  if not module then return false end
  if getOpenedProcessID()~=selected.pid then openProcess(selected.pid) end
  if getOpenedProcessID()~=selected.pid then return false end
  if S.pid~=selected.pid or S.game~=selected.key or S.base~=module.Address then
    local _,v=getFileVersion(module.PathToFile)
    S.version=v and string.format('%d.%d.%d.%d',v.major,v.minor,v.release,v.build) or 'Unknown'
    S.supported=S.version==c.version and md5file(module.PathToFile):lower()==c.hash
    S.pid=selected.pid; S.game=selected.key; S.base=module.Address
  end
  report(c.title..' | '..S.version..(S.supported and '' or ' | Unsupported build'))
  return true
end
local function selectedOwnedUnits(game)
  local c=configs[game]
  local selection=readInteger(S.base+c.selection)
  local head=selection and selection~=0 and readInteger(selection+0x40)
  local node=head and head~=0 and readInteger(head)
  local units,seen,objects={},{},{}
  while node and node~=0 and node~=head do
    if seen[node] then return end
    seen[node]=true
    local drawable=readInteger(node+8)
    local object=drawable and drawable~=0 and readInteger(drawable+0x140)
    local team=object and object~=0 and readInteger(object+c.owner)
    local holder=team and team~=0 and readInteger(team+4)
    local owner=holder and holder~=0 and readInteger(holder+8)
    local id=object and object~=0 and readInteger(object+c.objectId)
    if owner==S.bound.p and id and id~=0 and not objects[object] then
      objects[object]=true; units[#units+1]={object,id}
    end
    node=readInteger(node)
  end
  if node~=head or #units==0 then return end
  table.sort(units,function(a,b) return a[1]&lt;b[1] end)
  return units
end
function S.invulnerability(game,enable)
  if not enable then return not S.state or write(0x5C,0) end
  if S.closing or S.stopping or S.game~=game or not S.state or S.transition or not owned() then
    tell('Enter a match, enable the matching MAIN, and select one of your units.'); return false
  end
  local units=selectedOwnedUnits(game)
  if not units then tell('Select your units, then enable invulnerability.'); return false end
  local settings=readInteger(S.base+configs[game].settings)
  local strength=settings and settings~=0 and readFloat(settings+0xC54)
  local house=settings and readBytes(settings+0xC58,1)
  local color=readInteger(S.bound.p+0x8C)
  if not strength or not house or not color then return false end
  local rgb={1,1,1}
  if house~=0 then rgb={(color&gt;&gt;16 &amp; 255)/255,(color&gt;&gt;8 &amp; 255)/255,(color &amp; 255)/255} end
  for i=1,3 do rgb[i]=(rgb[i]-0.5)*strength end
  local group=allocateMemory(16+#units*8)
  if not group or group==0 then tell('Could not store the selected group.'); return false end
  local function store(address,value)
    return writeInteger(address,value) and readInteger(address)==value
  end
  if not store(group,#units) then return false end
  for i,value in ipairs(rgb) do
    if not writeFloat(group+i*4,value) then return false end
  end
  for i,unit in ipairs(units) do
    if not store(group+16+(i-1)*8,unit[1]) or not store(group+20+(i-1)*8,unit[2]) then return false end
  end
  -- Publish an immutable group with one pointer write; retain old groups until process exit
  -- so an in-flight damage/render hook can finish safely after Off or retargeting.
  if not owned() or not write(0x60,group) or not write(0x5C,1) then
    write(0x5C,0); return false
  end
  report('Invulnerability enabled for '..#units..' selected units - selection changes do not move it')
  return true
end
function S.promote(game)
  if S.closing or S.stopping or S.game~=game or not S.state or S.transition or not owned() then
    tell('Enter a match, enable the matching MAIN, and select one of your units.'); return false
  end
  if readInteger(S.state+0x54)==1 then report('Promotion pending - resume the game with the same units selected'); return false end
  local selection=readInteger(S.base+configs[game].selection)
  local head=selection and selection~=0 and readInteger(selection+0x40)
  local first=head and head~=0 and readInteger(head)
  if not first or first==0 or first==head then
    tell('Select your units, then toggle promotion.'); return false
  end
  if not write(0x4C,head) or not write(0x50,first) or not write(0x58,0) or not write(0x54,1) then
    write(0x54,0); tell('The promotion could not be queued. Try again.'); return false
  end
  report('Promotion queued - resume with the same units selected; Clear All cancels a pending promotion')
  return true
end
local function excludeOtherReveal(game,name)
  if name~='visual' and name~='full' then return true end
  local other=name=='visual' and 'full' or 'visual'
  if S.menu then S.menu.choices[other]=false
  elseif not write(flagOffsets[other],0) then return false end
  suppress=true
  list.getMemoryRecordByID((game=='tw' and 10 or 20)+ids[other]).Active=false
  suppress=false
  return true
end
for key,main in pairs(mains) do
  local game=key
  local protection=list.getMemoryRecordByID((game=='tw' and 10 or 20)+9)
  protection.OnActivate=function(_,before)
    if not before or suppress then return true end
    return S.invulnerability(game,true)
  end
  protection.OnDeactivate=function(_,before)
    if not before or suppress then return true end
    return S.invulnerability(game,false)
  end
  local promotion=list.getMemoryRecordByID((game=='tw' and 10 or 20)+8)
  promotion.OnActivate=function(_,before)
    if before and not suppress then S.promote(game) end
    return false
  end
  promotion.OnDeactivate=function() return true end
  main.OnActivate=function(_,before)
    if not before or suppress then return true end
    if S.closing then return false end
    if not S.poll(game) then
      tell(S.stopping and 'Resume the game to finish cleanup, then select the other MAIN.' or 'Start the matching game and try again.')
      return false
    end
    if not S.supported then tell("This table supports the installed Steam Tiberium Wars 1.10 and Kane's Wrath 1.3 builds. This executable is different; leave the options off."); return false end
    if S.state or S.menu then return true end
    if not context() then
      S.menu={game=game,pid=S.pid,choices={}}
      report('Options selected - waiting for a mission or skirmish')
      return true
    end
    return install()
  end
  main.OnDeactivate=function(_,before)
    if not before or suppress then return true end
    local complete=S.clear()
    return complete or S.offRequested==true
  end
  for feature,offset in pairs(ids) do
    local name=feature
    local record=list.getMemoryRecordByID((game=='tw' and 10 or 20)+offset)
    record.OnActivate=function(_,before)
      if not before or suppress then return true end
      if S.menu and S.menu.game==game and not S.closing then
        if not excludeOtherReveal(game,name) then return false end
        S.menu.choices[name]=true
        return true
      end
      if S.closing or S.game~=game or not S.state or S.stopping or (not S.transition and not owned()) then
        tell('Enable the matching MAIN in the current match first.'); return false
      end
      if not excludeOtherReveal(game,name) then return false end
      return write(flagOffsets[name],1)
    end
    record.OnDeactivate=function(_,before)
      if not before or suppress then return true end
      if S.menu and S.menu.game==game then S.menu.choices[name]=false; return true end
      return not S.state or write(flagOffsets[name],0)
    end
  end
end
-- Keep CE from presenting raw Lua exceptions from activation callbacks.
local function guarded(callback)
  return function(sender,before)
    local ok,result=pcall(callback,sender,before)
    if not ok then
      S.lastError=tostring(result)
      tell('The game could not be accessed. Use Clear All, then try again once the match is ready.')
      return false
    end
    return result
  end
end
for _,main in pairs(mains) do
  main.OnActivate=guarded(main.OnActivate)
  main.OnDeactivate=guarded(main.OnDeactivate)
  for i=0,main.Count-1 do
    local child=main.Child[i]
    child.OnActivate=guarded(child.OnActivate)
    child.OnDeactivate=guarded(child.OnDeactivate)
  end
end
local function detachUI()
  if S.timer then S.timer.destroy(); S.timer=nil end
  if S.closeToken then getMainForm().unregisterCloseCallback(S.closeToken); S.closeToken=nil end
  if not S.recordsRemoved then
    for _,main in pairs(mains) do
      main.OnActivate=nil; main.OnDeactivate=nil
      for i=0,main.Count-1 do main.Child[i].OnActivate=nil; main.Child[i].OnDeactivate=nil end
    end
  end
end
function S.shutdown()
  if not S.clear() then
    if not (S.closing and S.offRequested and uninstall(true)) then return false end
  end
  detachUI()
  return true
end
S.closeToken=getMainForm().registerCloseCallback(function(_,action)
  if action==caNone then return action end
  S.closing=true
  local ok,complete=pcall(S.shutdown)
  if not ok then S.lastError=tostring(complete) end
  -- Closure must not depend on game updates, attachment, or cleanup success.
  pcall(detachUI)
  return action
end)
S.timer=createTimer(getMainForm(),false)
S.timer.Interval=200
S.timer.OnTimer=function()
  if S.closing then return end
  if getAddressList().getMemoryRecordByID(10)~=mains.tw then S.recordsRemoved=true; S.shutdown(); return end
  local ok,err=pcall(S.poll)
  if not ok then S.lastError=tostring(err); report('Unable to inspect game; use Clear All before continuing') end
end
S.timer.Enabled=true
S.timer.OnTimer()
</LuaScript>
</CheatTable>