<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="42">
  <CheatEntries>
    <CheatEntry>
      <ID>4</ID>
      <Description>"Activate for 200 CP for party during battle"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : hnk.exe
  Version: 
  Date   : 2023-07-07
  Author : chausies

  This script does blah blah blah
}

[ENABLE]

aobscanmodule(ReanCPAmtForAlliesDuringBattle,hnk.exe,0F B7 48 0C 41 0F B7 C7 66 41 3B CF 66 0F 43 C1) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  mov word ptr [rax+0C],#200 // New Code
  movzx ecx,word ptr [rax+0C]
  movzx eax,r15w
  cmp cx,r15w
  cmovae ax,cx
  jmp return

ReanCPAmtForAlliesDuringBattle:
  jmp far newmem
  nop 2
return:
registersymbol(ReanCPAmtForAlliesDuringBattle)

[DISABLE]

ReanCPAmtForAlliesDuringBattle:
  db 0F B7 48 0C 41 0F B7 C7 66 41 3B CF 66 0F 43 C1

unregistersymbol(ReanCPAmtForAlliesDuringBattle)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: hnk.exe+C9441

hnk.exe+C9417: 66 44 89 67 02        - mov [rdi+02],r12w
hnk.exe+C941C: 48 8B 4E 50           - mov rcx,[rsi+50]
hnk.exe+C9420: E8 CB 37 02 00        - call hnk.exe+ECBF0
hnk.exe+C9425: 0F B7 48 08           - movzx ecx,word ptr [rax+08]
hnk.exe+C9429: 66 3B 4F 02           - cmp cx,[rdi+02]
hnk.exe+C942D: E9 C6 FE FF FF        - jmp hnk.exe+C92F8
hnk.exe+C9432: 80 7B 1E 1F           - cmp byte ptr [rbx+1E],1F
hnk.exe+C9436: 75 1C                 - jne hnk.exe+C9454
hnk.exe+C9438: 48 8B 4E 50           - mov rcx,[rsi+50]
hnk.exe+C943C: E8 AF 37 02 00        - call hnk.exe+ECBF0
// ---------- INJECTING HERE ----------
hnk.exe+C9441: 0F B7 48 0C           - movzx ecx,word ptr [rax+0C]
// ---------- DONE INJECTING  ----------
hnk.exe+C9445: 41 0F B7 C7           - movzx eax,r15w
hnk.exe+C9449: 66 41 3B CF           - cmp cx,r15w
hnk.exe+C944D: 66 0F 43 C1           - cmovae ax,cx
hnk.exe+C9451: 66 89 07              - mov [rdi],ax
hnk.exe+C9454: 48 8B 85 88 81 00 00  - mov rax,[rbp+00008188]
hnk.exe+C945B: 4C 8B 46 50           - mov r8,[rsi+50]
hnk.exe+C945F: 4C 8B 88 58 03 00 00  - mov r9,[rax+00000358]
hnk.exe+C9466: 4D 3B C1              - cmp r8,r9
hnk.exe+C9469: 0F 84 81 00 00 00     - je hnk.exe+C94F0
hnk.exe+C946F: 4D 85 C9              - test r9,r9
}
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>1</ID>
      <Description>"BP pointer"</Description>
      <VariableType>Byte</VariableType>
      <Address>hnk.exe+16469EA</Address>
    </CheatEntry>
    <CheatEntry>
      <ID>0</ID>
      <Description>"5 BP on checking orders during battle"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : hnk.exe
  Version: 
  Date   : 2023-07-07
  Author : chausies

  This script does blah blah blah
}

[ENABLE]

aobscanmodule(ReadBPOnOrderCheckInBattle,hnk.exe,0F B6 80 0A B0 7B 00 C3 CC CC CC CC CC CC) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  mov byte ptr [rax+007BB00A],#5
  movzx eax,byte ptr [rax+007BB00A]
  ret 
  int 3 
  int 3 
  int 3 
  int 3 
  int 3 
  int 3 
  jmp return

ReadBPOnOrderCheckInBattle:
  jmp far newmem
return:
registersymbol(ReadBPOnOrderCheckInBattle)

[DISABLE]

ReadBPOnOrderCheckInBattle:
  db 0F B6 80 0A B0 7B 00 C3 CC CC CC CC CC CC

unregistersymbol(ReadBPOnOrderCheckInBattle)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: hnk.exe+6488D1

hnk.exe+6488AA: 48 8B 05 1F F9 83 00  - mov rax,[hnk.exe+E881D0]
hnk.exe+6488B1: 8B 88 7C 40 00 00     - mov ecx,[rax+0000407C]
hnk.exe+6488B7: 83 F9 04              - cmp ecx,04
hnk.exe+6488BA: 75 08                 - jne hnk.exe+6488C4
hnk.exe+6488BC: 0F B6 80 0B B0 7B 00  - movzx eax,byte ptr [rax+007BB00B]
hnk.exe+6488C3: C3                    - ret 
hnk.exe+6488C4: 83 F9 01              - cmp ecx,01
hnk.exe+6488C7: 75 08                 - jne hnk.exe+6488D1
hnk.exe+6488C9: 0F B6 80 09 B0 7B 00  - movzx eax,byte ptr [rax+007BB009]
hnk.exe+6488D0: C3                    - ret 
// ---------- INJECTING HERE ----------
hnk.exe+6488D1: 0F B6 80 0A B0 7B 00  - movzx eax,byte ptr [rax+007BB00A]
// ---------- DONE INJECTING  ----------
hnk.exe+6488D8: C3                    - ret 
hnk.exe+6488D9: CC                    - int 3 
hnk.exe+6488DA: CC                    - int 3 
hnk.exe+6488DB: CC                    - int 3 
hnk.exe+6488DC: CC                    - int 3 
hnk.exe+6488DD: CC                    - int 3 
hnk.exe+6488DE: CC                    - int 3 
hnk.exe+6488DF: CC                    - int 3 
hnk.exe+6488E0: 48 8B C4              - mov rax,rsp
hnk.exe+6488E3: 48 89 58 10           - mov [rax+10],rbx
}
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>2</ID>
      <Description>"14 of item upon usage in battle"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : hnk.exe
  Version: 
  Date   : 2023-07-07
  Author : chausies

  This script does blah blah blah
}

[ENABLE]

aobscanmodule(ReadItmAmtOnUsageInBattle,hnk.exe,41 8B 44 D1 04 2B C6 85 C0 44 0F 4F D0 45 89 54 D1 04) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  mov word ptr [r9+rdx*8+04],#15 // new code
  mov eax,[r9+rdx*8+04]
  sub eax,esi
  test eax,eax
  cmovg r10d,eax
  mov [r9+rdx*8+04],r10d
  jmp return

ReadItmAmtOnUsageInBattle:
  jmp far newmem
  nop 4
return:
registersymbol(ReadItmAmtOnUsageInBattle)

[DISABLE]

ReadItmAmtOnUsageInBattle:
  db 41 8B 44 D1 04 2B C6 85 C0 44 0F 4F D0 45 89 54 D1 04

unregistersymbol(ReadItmAmtOnUsageInBattle)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: hnk.exe+3F763A

hnk.exe+3F7620: 8B C1                    - mov eax,ecx
hnk.exe+3F7622: 48 03 C0                 - add rax,rax
hnk.exe+3F7625: 8B D1                    - mov edx,ecx
hnk.exe+3F7627: 66 45 39 1C C1           - cmp [r9+rax*8],r11w
hnk.exe+3F762C: 74 09                    - je hnk.exe+3F7637
hnk.exe+3F762E: FF C1                    - inc ecx
hnk.exe+3F7630: 41 3B C8                 - cmp ecx,r8d
hnk.exe+3F7633: 72 EB                    - jb hnk.exe+3F7620
hnk.exe+3F7635: EB 15                    - jmp hnk.exe+3F764C
hnk.exe+3F7637: 48 03 D2                 - add rdx,rdx
// ---------- INJECTING HERE ----------
hnk.exe+3F763A: 41 8B 44 D1 04           - mov eax,[r9+rdx*8+04]
// ---------- DONE INJECTING  ----------
hnk.exe+3F763F: 2B C6                    - sub eax,esi
hnk.exe+3F7641: 85 C0                    - test eax,eax
hnk.exe+3F7643: 44 0F 4F D0              - cmovg r10d,eax
hnk.exe+3F7647: 45 89 54 D1 04           - mov [r9+rdx*8+04],r10d
hnk.exe+3F764C: 80 BC 24 50 04 00 00 00  - cmp byte ptr [rsp+00000450],00
hnk.exe+3F7654: 74 34                    - je hnk.exe+3F768A
hnk.exe+3F7656: 48 8B D7                 - mov rdx,rdi
hnk.exe+3F7659: E8 B2 00 00 00           - call hnk.exe+3F7710
hnk.exe+3F765E: EB 2A                    - jmp hnk.exe+3F768A
hnk.exe+3F7660: 41 B8 FF 03 00 00        - mov r8d,000003FF
}
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>3</ID>
      <Description>"200 CP upon change (friend or foe)"</Description>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{ Game   : hnk.exe
  Version: 
  Date   : 2023-07-07
  Author : chausies

  This script does blah blah blah
}

[ENABLE]

aobscanmodule(WriteToCPUponUsage,hnk.exe,66 89 93 30 04 00 00 48 8B 5C 24 30 48 83 C4 20) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
  mov dx,#200
  mov [rbx+00000430],dx
  mov rbx,[rsp+30]
  add rsp,20
  jmp return

WriteToCPUponUsage:
  jmp far newmem
  nop 2
return:
registersymbol(WriteToCPUponUsage)

[DISABLE]

WriteToCPUponUsage:
  db 66 89 93 30 04 00 00 48 8B 5C 24 30 48 83 C4 20

unregistersymbol(WriteToCPUponUsage)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: hnk.exe+F1031

hnk.exe+F100F: 48 8B D8              - mov rbx,rax
hnk.exe+F1012: 75 DC                 - jne hnk.exe+F0FF0
hnk.exe+F1014: 0F B7 83 30 04 00 00  - movzx eax,word ptr [rbx+00000430]
hnk.exe+F101B: 33 C9                 - xor ecx,ecx
hnk.exe+F101D: 0F B7 93 32 04 00 00  - movzx edx,word ptr [rbx+00000432]
hnk.exe+F1024: 2B C7                 - sub eax,edi
hnk.exe+F1026: 85 C0                 - test eax,eax
hnk.exe+F1028: 0F 4F C8              - cmovg ecx,eax
hnk.exe+F102B: 3B CA                 - cmp ecx,edx
hnk.exe+F102D: 66 0F 4C D1           - cmovl dx,cx
// ---------- INJECTING HERE ----------
hnk.exe+F1031: 66 89 93 30 04 00 00  - mov [rbx+00000430],dx
// ---------- DONE INJECTING  ----------
hnk.exe+F1038: 48 8B 5C 24 30        - mov rbx,[rsp+30]
hnk.exe+F103D: 48 83 C4 20           - add rsp,20
hnk.exe+F1041: 5F                    - pop rdi
hnk.exe+F1042: C3                    - ret 
hnk.exe+F1043: CC                    - int 3 
hnk.exe+F1044: CC                    - int 3 
hnk.exe+F1045: CC                    - int 3 
hnk.exe+F1046: CC                    - int 3 
hnk.exe+F1047: CC                    - int 3 
hnk.exe+F1048: CC                    - int 3 
}
</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
</CheatTable>
