<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="42">
  <CheatEntries>
    <CheatEntry>
      <ID>1</ID>
      <Description>"Get money (Usage: money change)"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : PortRoyale3.exe
  Version: 
  Date   : 2022-08-24
  Author : bbfox@https://opencheattables.com
}

[ENABLE]

aobscanmodule(INJECT_GET_MONEY,PortRoyale3.exe,8B 81 E4 02 00 00 56 8D) // should be unique
alloc(newmem,$1000)

label(code)
label(return)
label(i_money_base_addr)
newmem:
  mov [i_money_base_addr], ecx

code:
  mov eax,[ecx+000002E4]
  jmp return
align 10 cc
  i_money_base_addr:
  dd 0

INJECT_GET_MONEY:
  jmp newmem
  nop
return:
registersymbol(INJECT_GET_MONEY)
registersymbol(i_money_base_addr)
[DISABLE]

INJECT_GET_MONEY:
  db 8B 81 E4 02 00 00

unregistersymbol(*)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: PortRoyale3.exe+35A358

PortRoyale3.exe+35A32B: FF 24 85 F8 A3 75 00           - jmp dword ptr [eax*4+PortRoyale3.exe+35A3F8]
PortRoyale3.exe+35A332: 01 91 54 01 00 00              - add [ecx+00000154],edx
PortRoyale3.exe+35A338: EB 1E                          - jmp PortRoyale3.exe+35A358
PortRoyale3.exe+35A33A: 01 91 50 01 00 00              - add [ecx+00000150],edx
PortRoyale3.exe+35A340: EB 16                          - jmp PortRoyale3.exe+35A358
PortRoyale3.exe+35A342: 01 91 58 01 00 00              - add [ecx+00000158],edx
PortRoyale3.exe+35A348: EB 0E                          - jmp PortRoyale3.exe+35A358
PortRoyale3.exe+35A34A: 01 91 70 01 00 00              - add [ecx+00000170],edx
PortRoyale3.exe+35A350: EB 06                          - jmp PortRoyale3.exe+35A358
PortRoyale3.exe+35A352: 01 91 6C 01 00 00              - add [ecx+0000016C],edx
// ---------- INJECTING HERE ----------
PortRoyale3.exe+35A358: 8B 81 E4 02 00 00              - mov eax,[ecx+000002E4]
// ---------- DONE INJECTING  ----------
PortRoyale3.exe+35A35E: 56                             - push esi
PortRoyale3.exe+35A35F: 8D 34 10                       - lea esi,[eax+edx]
PortRoyale3.exe+35A362: 89 B1 E4 02 00 00              - mov [ecx+000002E4],esi
PortRoyale3.exe+35A368: 85 D2                          - test edx,edx
PortRoyale3.exe+35A36A: 7E 14                          - jle PortRoyale3.exe+35A380
PortRoyale3.exe+35A36C: 85 C0                          - test eax,eax
PortRoyale3.exe+35A36E: 7E 22                          - jle PortRoyale3.exe+35A392
PortRoyale3.exe+35A370: 85 F6                          - test esi,esi
PortRoyale3.exe+35A372: 79 1E                          - jns PortRoyale3.exe+35A392
PortRoyale3.exe+35A374: C7 81 E4 02 00 00 FF FF FF 7F  - mov [ecx+000002E4],7FFFFFFF
}
</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>2</ID>
          <Description>"Money"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>i_money_base_addr</Address>
          <Offsets>
            <Offset>2E4</Offset>
          </Offsets>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
    <CheatEntry>
      <ID>31</ID>
      <Description>"Warehouse (Buy to activate and buy after editing)"</Description>
      <Options moHideChildren="1"/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : Port Royale 3
  Version: 
  Date   : 2022-08-27
  Author : mooni

  This script does blah blah blah
}

[ENABLE]
aobscanmodule(getdock,PortRoyale3.exe,8B 47 B0 89 45 F4)
alloc(newmem,$1000)
label(docks)
label(return)
registersymbol(docks)

newmem:
  mov [docks],eax
  mov eax,[edi-50]
  mov [ebp-0C],eax
  mov [docks+18],#9999
  jmp return

docks:
dd 00

getdock:
  jmp newmem
  nop
return:
registersymbol(getdock)

[DISABLE]
getdock:
  db 8B 47 B0 89 45 F4

unregistersymbol(*)
dealloc(*)

{
// ORIGINAL CODE - INJECTION POINT: PortRoyale3.exe+37DBB5

PortRoyale3.exe+37DB94: 83 C7 68              - add edi,68
PortRoyale3.exe+37DB97: EB 07                 - jmp PortRoyale3.exe+37DBA0
PortRoyale3.exe+37DB99: 8D A4 24 00 00 00 00  - lea esp,[esp+00000000]
PortRoyale3.exe+37DBA0: 8B 45 08              - mov eax,[ebp+08]
PortRoyale3.exe+37DBA3: BA 01 00 00 00        - mov edx,00000001
PortRoyale3.exe+37DBA8: 8B CB                 - mov ecx,ebx
PortRoyale3.exe+37DBAA: D3 E2                 - shl edx,cl
PortRoyale3.exe+37DBAC: 85 50 0C              - test [eax+0C],edx
PortRoyale3.exe+37DBAF: 74 7C                 - je PortRoyale3.exe+37DC2D
PortRoyale3.exe+37DBB1: 80 7E 0C 00           - cmp byte ptr [esi+0C],00
// ---------- INJECTING HERE ----------
PortRoyale3.exe+37DBB5: 8B 47 B0              - mov eax,[edi-50]
// ---------- DONE INJECTING  ----------
PortRoyale3.exe+37DBB8: 89 45 F4              - mov [ebp-0C],eax
PortRoyale3.exe+37DBBB: 6A 04                 - push 04
PortRoyale3.exe+37DBBD: 75 10                 - jne PortRoyale3.exe+37DBCF
PortRoyale3.exe+37DBBF: 8B 4E 08              - mov ecx,[esi+08]
PortRoyale3.exe+37DBC2: 8B 11                 - mov edx,[ecx]
PortRoyale3.exe+37DBC4: 8B 52 14              - mov edx,[edx+14]
PortRoyale3.exe+37DBC7: 8D 45 F4              - lea eax,[ebp-0C]
PortRoyale3.exe+37DBCA: 50                    - push eax
PortRoyale3.exe+37DBCB: FF D2                 - call edx
PortRoyale3.exe+37DBCD: EB 20                 - jmp PortRoyale3.exe+37DBEF
}
</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>33</ID>
          <Description>"Wood"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+18</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>34</ID>
          <Description>"Adobe Bricks"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+1C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>35</ID>
          <Description>"Wheat"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+20</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>36</ID>
          <Description>"Fruits"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+24</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>37</ID>
          <Description>"Corn"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+28</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>38</ID>
          <Description>"Sugar"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+2C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>39</ID>
          <Description>"Hemp"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+30</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>40</ID>
          <Description>"Metal"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+34</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>41</ID>
          <Description>"Textiles"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+38</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>42</ID>
          <Description>"Cotton"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+3C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>43</ID>
          <Description>"Metal Goods"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+40</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>44</ID>
          <Description>"Dye"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+44</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>45</ID>
          <Description>"Coffee"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+48</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>46</ID>
          <Description>"Cacao"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+4C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>47</ID>
          <Description>"Tabacco"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+50</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>48</ID>
          <Description>"Meat"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+54</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>49</ID>
          <Description>"Clothing"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+58</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>50</ID>
          <Description>"Ropes"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+5C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>51</ID>
          <Description>"Rum"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+60</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>52</ID>
          <Description>"Bread"</Description>
          <ShowAsSigned>0</ShowAsSigned>
          <VariableType>4 Bytes</VariableType>
          <Address>[docks]+64</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
  <CheatCodes>
    <CodeEntry>
      <Description>Dock Values</Description>
      <AddressString>PortRoyale3.exe+37DBB5</AddressString>
      <Before>
        <Byte>7C</Byte>
        <Byte>80</Byte>
        <Byte>7E</Byte>
        <Byte>0C</Byte>
        <Byte>00</Byte>
      </Before>
      <Actual>
        <Byte>8B</Byte>
        <Byte>47</Byte>
        <Byte>B0</Byte>
      </Actual>
      <After>
        <Byte>89</Byte>
        <Byte>45</Byte>
        <Byte>F4</Byte>
        <Byte>6A</Byte>
        <Byte>04</Byte>
      </After>
    </CodeEntry>
  </CheatCodes>
  <UserdefinedSymbols/>
</CheatTable>
