<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="14">
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Enable min/max/avg calculation"</Description>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[enable]
//code locations
alloc(Code,1024)
label(ReturnHere1)
label(HandleSkill1)
label(WriteOneSkillValue)
label(WriteOneSkillValue_DoNotUpdateMaxValue)
label(WriteOneSkillValue_DoNotUpdateMinValue)
label(WriteOneSkillValue_DoNotResetAverage)
label(WriteOneSkillValue_DoNotResetAverage2)

//data
label(AllTimeSum) //array of (sum of all values we wrote to a given skill) //uint AllTimeSum[11];
label(WriteCount) //number of values we wrote in each AllTimeSum           //uint WriteCount[11];
label(Average) //array of average values. //uint Average[11];
               //average has to be a dword for AllSkillAverage calculation because add eax, byte [Average] does not exist
label(MaxValue) //array of max values //uchar MaxValue[11];
label(MinValue) //array of min values //uchar MinValue[11];
label(AllSkillAverage) //average of all skills //uchar AllSkillAverage;
label(AllSkillMaxValue) //max value for all skills //uchar AllSkillMaxValue;
label(AllSkillMinValue) //min value for all skills //uchar AllSkillMinValue;

//symbol registration
registersymbol(Average)
registersymbol(MaxValue)
registersymbol(MinValue)
registersymbol(AllSkillAverage)
registersymbol(AllSkillMaxValue)
registersymbol(AllSkillMinValue)

urw.exe+123B8::
jmp HandleSkill1
ReturnHere1:

Code:
HandleSkill1:
mov byte ptr [urw.exe+1FB9DA02],al //original code
push eax
push 0
call WriteOneSkillValue
jmp ReturnHere1

//stdcall void WriteOneSkillValue(SkillNumber,Value)
//SkillNumber ranges from 0 to 10 (decimal)
WriteOneSkillValue:
  push ecx
  push eax
  push edx
  mov ecx,dword [esp+10] //ecx=SkillNumber
  mov eax,dword [esp+14] //eax=Value
  //update the MaxValue &amp; AllSkillMaxValue if needed
  cmp al,byte [MaxValue+ecx] //if (Value&gt;MaxValue[SkillNumber]) MaxValue[SkillNumber]=Value;
  jbe WriteOneSkillValue_DoNotUpdateMaxValue
    mov byte [MaxValue+ecx],al
    cmp al,byte [AllSkillMaxValue] //update AllSkillMaxValue if Value&gt;AllSkillMaxValue
    jbe WriteOneSkillValue_DoNotUpdateMaxValue
       mov byte [AllSkillMaxValue],al
  WriteOneSkillValue_DoNotUpdateMaxValue:
  //update the MinValue &amp; AllSkillMinValue if needed
  cmp al,byte [MinValue+ecx] //if (Value&lt;MinValue[SkillNumber]) MinValue[SkillNumber]=Value;
  jae WriteOneSkillValue_DoNotUpdateMinValue
    mov byte [MinValue+ecx],al
    cmp al,byte [AllSkillMinValue] //update AllSkillMinValue if Value&lt;AllSkillMinValue
    jae WriteOneSkillValue_DoNotUpdateMaxValue
       mov byte [AllSkillMinValue],al
  WriteOneSkillValue_DoNotUpdateMinValue:
  //update the average and AllSkillAverage
  push ebx
  inc dword [WriteCount+ecx*4]     //and increase the counter of values accumulated in AllTimeSum
  jno WriteOneSkillValue_DoNotResetAverage //in the unlikely event that we updated
    mov dword [AllTimeSum],eax         //WriteCount 2^32 times reset the
    mov dword [WriteCount+ecx*4],1    //average calculation mechanism
  WriteOneSkillValue_DoNotResetAverage:
  mov ebx dword [WriteCount+ecx*4] //load WriteCount
  add eax,dword [AllTimeSum+ecx*4] //eax=AllTimeSum[SkillNumber]+Value
  jno WriteOneSkillValue_DoNotResetAverage2 //if AllTimeSum[SkillNumber] just went past 2^32, reset the average too.
    mov eax, dword [esp+18]          //reload the Value parameter
    mov byte [WriteCount+ecx*4],1
    mov ebx,1
  WriteOneSkillValue_DoNotResetAverage2:
  mov dword [AllTimeSum+ecx*4],eax //update the new AllTimeSum
  xor edx,edx //needed for the division
  div ebx //eax=AllTimeSum[SkillNumber]/ebx
  mov dword [Average+ecx*4],eax


  //now refresh the average for all skills
  mov eax, dword [Average] //do the sum of all averages
  add eax, dword [Average+4]
  add eax, dword [Average+8]
  add eax, dword [Average+c]
  add eax, dword [Average+10]
  add eax, dword [Average+14]
  add eax, dword [Average+18]
  add eax, dword [Average+1c]
  add eax, dword [Average+20]
  add eax, dword [Average+24]
  add eax, dword [Average+28]
  xor edx,edx //needed for the division
  mov ebx,b //b= number of skills
  div ebx //divide that sum by the number of skills (11)
  mov byte [AllSkillAverage],al //and store it !

  pop ebx
  pop edx
  pop eax
  pop ecx
ret 8

//DataBuffer:
WriteCount:
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
AllTimeSum:
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
Average:
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
AllSkillAverage:
db 0
MaxValue:
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
AllSkillMaxValue:
db 0
MinValue:
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
db 0
AllSkillMinValue:
db 0


[disable]
urw.exe+123B8:
mov byte ptr [urw.exe+1FB9DA02],al //original code

registersymbol(Average)
registersymbol(MaxValue)
registersymbol(MinValue)
registersymbol(AllSkillAverage)
registersymbol(AllSkillMaxValue)
registersymbol(AllSkillMinValue)

dealloc(Code)
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>52</ID>
      <Description>"Average"</Description>
      <Color>80000008</Color>
      <GroupHeader>1</GroupHeader>
      <CheatEntries>
        <CheatEntry>
          <ID>6</ID>
          <Description>"All skill average"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>AllSkillAverage</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>7</ID>
          <Description>"Skill 1 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+0</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>8</ID>
          <Description>"Skill 2 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+4</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>9</ID>
          <Description>"Skill 3 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+8</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>10</ID>
          <Description>"Skill 4 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>11</ID>
          <Description>"Skill 5 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+10</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>12</ID>
          <Description>"Skill 6 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+14</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>13</ID>
          <Description>"Skill 7 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+18</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>14</ID>
          <Description>"Skill 8 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+1C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>15</ID>
          <Description>"Skill 9 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+20</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>16</ID>
          <Description>"Skill 10 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+24</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>17</ID>
          <Description>"Skill 11 average"</Description>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>Average+28</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
    <CheatEntry>
      <ID>53</ID>
      <Description>"Minimums"</Description>
      <Color>80000008</Color>
      <GroupHeader>1</GroupHeader>
      <CheatEntries>
        <CheatEntry>
          <ID>5</ID>
          <Description>"All skill minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>AllSkillMinValue</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>22</ID>
          <Description>"Skill 1 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+0</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>23</ID>
          <Description>"Skill 2 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+4</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>24</ID>
          <Description>"Skill 3 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+8</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>25</ID>
          <Description>"Skill 4 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>26</ID>
          <Description>"Skill 5 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+10</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>27</ID>
          <Description>"Skill 6 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+14</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>28</ID>
          <Description>"Skill 7 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+18</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>29</ID>
          <Description>"Skill 8 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+1C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>30</ID>
          <Description>"Skill 9 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+20</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>31</ID>
          <Description>"Skill 10 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+24</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>32</ID>
          <Description>"Skill 11 minimum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MinValue+28</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
    <CheatEntry>
      <ID>54</ID>
      <Description>"Maximums"</Description>
      <Color>80000008</Color>
      <GroupHeader>1</GroupHeader>
      <CheatEntries>
        <CheatEntry>
          <ID>4</ID>
          <Description>"All skill maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>AllSkillMaxValue</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>37</ID>
          <Description>"Skill 1 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+0</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>38</ID>
          <Description>"Skill 2 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+4</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>39</ID>
          <Description>"Skill 3 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+8</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>40</ID>
          <Description>"Skill 4 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>41</ID>
          <Description>"Skill 5 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+10</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>42</ID>
          <Description>"Skill 6 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+14</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>43</ID>
          <Description>"Skill 7 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+18</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>44</ID>
          <Description>"Skill 8 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+1C</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>45</ID>
          <Description>"Skill 9 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+20</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>46</ID>
          <Description>"Skill 10 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+24</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>47</ID>
          <Description>"Skill 11 maximum"</Description>
          <Color>80000008</Color>
          <VariableType>Byte</VariableType>
          <Address>MaxValue+28</Address>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
</CheatTable>
