<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="26">
  <CheatEntries>
    <CheatEntry>
      <ID>1</ID>
      <Description>"Mod Resources"</Description>
      <Options moHideChildren="1"/>
      <LastState/>
      <Color>008000</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]

{
// ORIGINAL CODE - INJECTION POINT: "LegoRR.exe"+23BB9

"LegoRR.exe"+23B97: EB 04              -  jmp LegoRR.exe+23B9D
"LegoRR.exe"+23B99: 8B 4C 24 44        -  mov ecx,[esp+44]
"LegoRR.exe"+23B9D: 56                 -  push esi
"LegoRR.exe"+23B9E: 50                 -  push eax
"LegoRR.exe"+23B9F: 51                 -  push ecx
"LegoRR.exe"+23BA0: E8 2B 85 03 00     -  call LegoRR.exe+5C0D0
"LegoRR.exe"+23BA5: 83 C4 0C           -  add esp,0C
"LegoRR.exe"+23BA8: E8 43 8A 03 00     -  call LegoRR.exe+5C5F0
"LegoRR.exe"+23BAD: 8B 0D D4 60 55 00  -  mov ecx,[LegoRR.exe+1560D4]
"LegoRR.exe"+23BB3: 8B 81 AC 00 00 00  -  mov eax,[ecx+000000AC]
// ---------- INJECTING HERE ----------
"LegoRR.exe"+23BB9: 8D 14 80           -  lea edx,[eax+eax*4]
"LegoRR.exe"+23BBC: 8B 81 A0 00 00 00  -  mov eax,[ecx+000000A0]
// ---------- DONE INJECTING  ----------
"LegoRR.exe"+23BC2: 8B 0D 28 61 55 00  -  mov ecx,[LegoRR.exe+156128]
"LegoRR.exe"+23BC8: 03 C2              -  add eax,edx
"LegoRR.exe"+23BCA: 50                 -  push eax
"LegoRR.exe"+23BCB: 68 54 2B 4A 00     -  push LegoRR.exe+A2B54
"LegoRR.exe"+23BD0: 6A 01              -  push 01
"LegoRR.exe"+23BD2: 68 D5 01 00 00     -  push 000001D5
"LegoRR.exe"+23BD7: 6A 10              -  push 10
"LegoRR.exe"+23BD9: 51                 -  push ecx
"LegoRR.exe"+23BDA: 6A 05              -  push 05
"LegoRR.exe"+23BDC: E8 7F 68 03 00     -  call LegoRR.exe+5A460
}

aobscanmodule(OreCount_Code,LegoRR.exe,8D 14 80 8B 81 A0 00 00 00) // should be unique
alloc(OreCount_New,2024)
registersymbol(OreCount_New)

alloc(ModOreCount,4)
registersymbol(ModOreCount)
ModOreCount:
  dd #0

alloc(ModCrystalCount,4)
registersymbol(ModCrystalCount)
ModCrystalCount:
  dd #0

alloc(OreCount_Min,4)
registersymbol(OreCount_Min)
OreCount_Min:
  dd #100

alloc(CrystalCount_Min,4)
registersymbol(CrystalCount_Min)
CrystalCount_Min:
  dd #30

alloc(pBase,4)
registersymbol(pBase)

label(OreCount_Return)
label(OreCount_Mod)
label(CrystalCount_Mod)
label(OreCount_Original)

OreCount_New:
  push eax
  mov [pBase],ecx

OreCount_Mod:
  cmp [ModOreCount],#0
  je CrystalCount_Mod
  mov eax, [ecx+000000A0]
  cmp eax, [OreCount_Min]
  jae CrystalCount_Mod
  mov eax, [OreCount_Min]
  mov [ecx+000000A0], eax

CrystalCount_Mod:
  cmp [ModCrystalCount],#0
  je OreCount_Original
  mov eax, [ecx+0000008C]
  cmp eax, [CrystalCount_Min]
  jae OreCount_Original
  mov eax, [CrystalCount_Min]
  mov [ecx+0000008C], eax

OreCount_Original:
  pop eax
  lea edx,[eax+eax*4]
  mov eax,[ecx+000000A0]

  jmp OreCount_Return

OreCount_Code:
  jmp OreCount_New
  nop
  nop
  nop
  nop

OreCount_Return:
registersymbol(OreCount_Code)

[DISABLE]

OreCount_Code:
  db 8D 14 80 8B 81 A0 00 00 00

unregistersymbol(OreCount_Code)

dealloc(OreCount_New)
unregistersymbol(OreCount_New)

dealloc(OreCount_Min)
unregistersymbol(OreCount_Min)

dealloc(CrystalCount_Min)
unregistersymbol(CrystalCount_Min)

dealloc(pBase)
unregistersymbol(pBase)

dealloc(ModOreCount)
unregistersymbol(ModOreCount)

dealloc(ModCrystalCount)
unregistersymbol(ModCrystalCount)
</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>11</ID>
          <Description>"Mod Ore Count"</Description>
          <Options moHideChildren="1"/>
          <LastState/>
          <Color>0000FF</Color>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]

ModCrystalCount:
  dd #1

[DISABLE]

ModCrystalCount:
  dd #0
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>12</ID>
          <Description>"Mod Crystal Count"</Description>
          <Options moHideChildren="1"/>
          <LastState/>
          <Color>0000FF</Color>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]

ModOreCount:
  dd #1

[DISABLE]

ModOreCount:
  dd #0
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>2</ID>
          <Description>"Desired Ore Count"</Description>
          <Color>FF8000</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>OreCount_Min</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>4</ID>
          <Description>"Desired Crystal Count"</Description>
          <Color>FF8000</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>CrystalCount_Min</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>10</ID>
          <Description>"Crystal Count"</Description>
          <Color>000000</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>pBase</Address>
          <Offsets>
            <Offset>8C</Offset>
          </Offsets>
        </CheatEntry>
        <CheatEntry>
          <ID>13</ID>
          <Description>"Ore Count"</Description>
          <Color>000000</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>pBase</Address>
          <Offsets>
            <Offset>A0</Offset>
          </Offsets>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
    <CheatEntry>
      <ID>8</ID>
      <Description>"Mod Oxygen"</Description>
      <Options moHideChildren="1"/>
      <LastState/>
      <Color>008000</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]

{
  LegoRR.exe+24588 - D9 44 24 10           - fld dword ptr [esp+10]
  LegoRR.exe+2458C - D8 0D ECE24900        - fmul dword ptr [LegoRR.exe+9E2EC]
  LegoRR.exe+24592 - D8 8E 00020000        - fmul dword ptr [esi+00000200]
  LegoRR.exe+24598 - DEC9                  - fmulp st(1),st(0)
  LegoRR.exe+2459A - D8 86 FC010000        - fadd dword ptr [esi+000001FC]
  LegoRR.exe+245A0 - D8 15 D8E24900        - fcom dword ptr [LegoRR.exe+9E2D8]
  LegoRR.exe+245A6 - D9 9E FC010000        - fstp dword ptr [esi+000001FC]
  LegoRR.exe+245AC - DFE0                  - fnstsw ax
  LegoRR.exe+245AE - F6 C4 41              - test ah,41
}

aobscanmodule(Oxygen_Code,LegoRR.exe,D9 9E FC 01 00 00 DF E0) // should be unique
alloc(Oxygen_New,2024)
registersymbol(Oxygen_New)

alloc(Oxygen_Desired,4)
registersymbol(Oxygen_Desired)
Oxygen_Desired:
  dd (float)100

label(Oxygen_Return)

Oxygen_New:
  fstp dword ptr [esi+000001FC]
  fld dword ptr [Oxygen_Desired]
  fstp dword ptr [esi+000001FC]
  jmp Oxygen_Return

Oxygen_Code:
  jmp Oxygen_New
  nop

Oxygen_Return:
  registersymbol(Oxygen_Code)

[DISABLE]

Oxygen_Code:
  db D9 9E FC 01 00 00 DF E0
{
  LegoRR.exe+245A6 - D9 9E FC010000        - fstp dword ptr [esi+000001FC]
  LegoRR.exe+245AC - DFE0                  - fnstsw ax
}

unregistersymbol(Oxygen_Code)

dealloc(Oxygen_New)
unregistersymbol(Oxygen_New)

dealloc(Oxygen_Desired)
unregistersymbol(Oxygen_Desired)
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>6</ID>
      <Description>"Mod Health"</Description>
      <Options moHideChildren="1"/>
      <LastState/>
      <Color>008000</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]

{
  LegoRR.exe+3F750 - D9 86 40030000        - fld dword ptr [esi+00000340]
  LegoRR.exe+3F756 - D8 64 24 14           - fsub dword ptr [esp+14]
  LegoRR.exe+3F75A - 8B 44 24 18           - mov eax,[esp+18]
  LegoRR.exe+3F75E - 85 C0                 - test eax,eax
  LegoRR.exe+3F760 - D9 9E 40030000        - fstp dword ptr [esi+00000340]
  LegoRR.exe+3F766 - 74 39                 - je LegoRR.exe+3F7A1
  LegoRR.exe+3F768 - D9 44 24 14           - fld dword ptr [esp+14]
  LegoRR.exe+3F76C - D8 1D A4E34900        - fcomp dword ptr [LegoRR.exe+9E3A4]
  LegoRR.exe+3F772 - DFE0                  - fnstsw ax
  LegoRR.exe+3F774 - F6 C4 41              - test ah,41
}

aobscanmodule(Health_Code,LegoRR.exe,85 C0 D9 9E 40 03 00 00) // should be unique
alloc(Health_New,2024)
registersymbol(Health_New)

alloc(KillMonsters,4)
registersymbol(KillMonsters)

alloc(Health_Desired,4)
registersymbol(Health_Desired)
Health_Desired:
  dd (float)100

label(Health_Return)
label(Health_SetMax)

Health_New:
  test eax,eax
  fstp dword ptr [esi+00000340]

  cmp [esi],#3 // 2 - rock raider, 4 - building, 3 - monster
  jne Health_SetMax
  cmp [KillMonsters],#0
  je Health_Return

  fldz
  fstp dword ptr [esi+00000340]
  jmp Health_Return
Health_SetMax:
  fld dword ptr [Health_Desired]
  fstp dword ptr [esi+00000340]
  jmp Health_Return

Health_Code:
  jmp Health_New
  nop
  nop
  nop

Health_Return:
  registersymbol(Health_Code)

[DISABLE]

Health_Code:
  db 85 C0 D9 9E 40 03 00 00
{
  LegoRR.exe+3F75E - 85 C0                 - test eax,eax
  LegoRR.exe+3F760 - D9 9E 40030000        - fstp dword ptr [esi+00000340]
}

unregistersymbol(Health_Code)

dealloc(Health_New)
unregistersymbol(Health_New)

dealloc(Health_Desired)
unregistersymbol(Health_Desired)

dealloc(KillMonsters)
unregistersymbol(KillMonsters)
</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>14</ID>
          <Description>"Kill appearing monsters"</Description>
          <Options moHideChildren="1"/>
          <LastState/>
          <Color>0000FF</Color>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]

KillMonsters:
  dd #1

[DISABLE]

KillMonsters:
  dd #0
</AssemblerScript>
        </CheatEntry>
        <CheatEntry>
          <ID>9</ID>
          <Description>"Desired Health"</Description>
          <Color>FF8000</Color>
          <VariableType>Float</VariableType>
          <Address>Health_Desired</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
  <Comments>Game   : Lego Rock Raiders
Date   : 2017-12-22
Author : mece
</Comments>
</CheatTable>
