Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help to fix bad ported game (Injustice: GAU/MK9)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Mon Mar 17, 2014 3:02 pm    Post subject: Help to fix bad ported game (Injustice: GAU/MK9) Reply with quote

So, Hello people of cheat engine, I have been playing Injustice: God among us for the last week, and I noticed that it lacks the same feature of Mortal Kombat 9 (which it used the same engine as base), as the game FPS is low, the game speed will be slow as well,
Quote:
let's suppose you're playing at 60FPS, then you're playing the game at 100% speed, but if you got down to 45FPS you will play the game at 75% speed, and if even 30FPS you'll be playing at 50% of the game speed, there's a not very good fix for that, which is editing the game config, to change this static Delta, Delta or DeltaTime is basically the ammount of speed the game needs to increase to always be at 100% speed, which from both games are static, but should be dynamic (that's because its a port from consoles which have static FPS), the fix is virtually simple, you get a static max FPS and then the Actual FPS, and then divide, which will return this speedhack ammount (Ex. 60/45=1,3 | 60/30=2),
the idea is basically that, create a lua script (If possible) to make 60/"Current FPS" and then apply this value to cheat engine's speedhack speed, Thanks for the read and sorry for my english!
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Tue Mar 18, 2014 8:54 am    Post subject: Reply with quote

How is that delta time called in the config files, and in which .ini is it defined?
I found NxTimeStep and NxMaxDeltaTime in PCG-DCFEngine.ini but those are only for the physx stuff and do not seem to affect gameplay speed.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Tue Mar 18, 2014 12:33 pm    Post subject: Reply with quote

It's called "GameSpeed"and there's also "MinDesiredFrameRate" all on Coalesced.ini, Thanks.
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Tue Mar 18, 2014 5:11 pm    Post subject: Reply with quote

I made an AA (NOT lua) script to dynamically adjust gamespeed. Tell me how it goes on your end and if it works well enough I'll add it to my IGAU table.

On my end it's not that good: looks like the engine doesn't like when speed in changed during the course of a move, which causes some moves to wiff (like grundy's forward light->med->med around gamespeed 1.8+).
If result are inconclusive, enable the 10 code lines that have been blued out (they start with //) and fiddle with GRANULARITY.

Code:
[ENABLE]
//define(GRANULARITY,0.0001) //makes sure GameSpeed is always a multiple of GRANULARITY. it might help against attack wiffing
alloc(SpeedAdjuster_Hook,200)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,A1 * * * * 8B 48 68 51 68 * * * * 68)
aobscanmodule(PointerBase_AOB,Injustice.exe,56 8B 31 33 D2 57)
registersymbol(SpeedAdjuster_AOB)

label(PrevTickCount)
label(EightThousand)
//label(Divisor)
label(FrameDelayArrayIndex)
label(FrameDelayArray)
label(PointerBase)

{
finds
  Injustice.exe+4A817B - 56                    - push esi
  Injustice.exe+4A817C - 8B 31                 - mov esi,[ecx]
  Injustice.exe+4A817E - 33 D2                 - xor edx,edx
  Injustice.exe+4A8180 - 57                    - push edi
  Injustice.exe+4A8181 - 8B 3D D03B9E03        - mov edi,[Injustice.exe+3073BD0]
  Injustice.exe+4A8187 - 89 5D FC              - mov [ebp-04],ebx
  Injustice.exe+4A818A - 85 DB                 - test ebx,ebx
and gets "Injustice.exe+3073BD0" from there
}
[PointerBase_AOB+8]:
PointerBase:


SpeedAdjuster_AOB-8:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
       //store that delay in FrameDelayArray
  mov ebx,dword [FrameDelayArrayIndex] //load the index of the last FrameDelayArray we wrote
  inc ebx                              //increment it
  and ebx,7                            //but make sure it stays below 8
  mov dword [FrameDelayArrayIndex],ebx //update FrameDelayArrayIndex
  mov [FrameDelayArray+ebx*4],eax      //update FrameDelayArray
       //get the time it took to render the last 8 frames
  mov eax,dword [FrameDelayArray]
  add eax,dword [FrameDelayArray+4]
  add eax,dword [FrameDelayArray+8]
  add eax,dword [FrameDelayArray+c]
  add eax,dword [FrameDelayArray+10]
  add eax,dword [FrameDelayArray+14]
  add eax,dword [FrameDelayArray+18]
  add eax,dword [FrameDelayArray+1c]
       //calculate new game speed
  imul eax,eax,#60              //multiply time_elapsed_since_last_frame by 60 (desired FPS)
  push eax
  fild dword [esp]              //convert time_elapsed...*60 into a float
  add esp,4                     //undo the previous push
  fdiv dword [EightThousand]      //divide it by 1000(milisec per second)*8(number of frames used to calculate average frame delay)
       //now make sure the game speed is a multiple of GRANULARITY
 // fld dword [Divisor]
 // fld st(1)
 // fprem                         //now st0 is the modulus of gamespeed/GRANULARITY
 // fsub st(2),st(0)              //subtract the modulus from gamespeed
 // fstp st(0)                    //trash 2 temporary variables
 // fstp st(0)

  mov eax, dword [PointerBase] //walk down the pointer to the game's speed
  mov eax, dword [eax+48]
  mov eax, dword [eax+38]
  mov eax, dword [eax]
  fstp dword [eax+2dc]          //update gamespeed
  popad                         //restore all registers

  mov esi,1                     //original code
retn

PrevTickCount:
dd 0
EightThousand:
dd (float)8000.0
//Divisor:
//dd (float)GRANULARITY
FrameDelayArrayIndex:
dd 0
FrameDelayArray: //holds the time it took to render the last 8 frames
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook,200)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-8:
mov esi,1

_________________
DO NOT PM me if you want help on making/fixing/using a hack.


Last edited by Gniarf on Tue Mar 18, 2014 9:49 pm; edited 2 times in total
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Tue Mar 18, 2014 7:45 pm    Post subject: Reply with quote

It's crashing for me, sorry but, can you tell me If I'm doing it right? Open CE(6.3, with admin privileges), select the game process, then open memory viewer, Ctrl+A, paste the code, Execute buton, then it crash right after the message:
"The code injection was successful
SpeedAdjuster_Hook=Address"
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Tue Mar 18, 2014 9:47 pm    Post subject: Reply with quote

Don't use the "execute" button with scripts that have the [enable] and [disable] tags. Instead use file->assign to cheat table.

But using the execute button didn't cause the game to crash on my end, so I made a little update to my script (previous post updated). It'll give error on line 26 but just say that "you wan't to edit it".
Hope it works this time.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Thu Mar 20, 2014 2:51 pm    Post subject: Reply with quote

It is still crashing, Maybe it is because our game versions may not the same?
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Thu Mar 20, 2014 4:50 pm    Post subject: Reply with quote

Wtf?! Shocked

Ok here is a diagnostic table, paste it in CE's main window.
1-Activate Pointerfinder (1/2).
+Is "base of gamespeed ptr" non-zero and not a bunch of question marks ?
+Does "gamespeed ptr 1" point toward your gamespeed ? (I'm expecting a "no I've got a lot of ??? here").
2-Activate Pointerfinder (2/2)
+Does "gamespeed ptr 2" point toward your gamespeed ?
+Is "Terminal offset" equal to 2DC? If not report its value, edit "gamespeed ptr 2", replace its 2DC by your terminal offset and see if "gamespeed ptr 2" works now.


Note: the forum adds an extra space after [enable] and [disable] which CE doesn't like, preventing you from activating the scripts. Either edit the scripts after pasting in CE, or click on quote post and copy from there.
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>114</ID>
      <Description>"Pointerfinder (1/2)"</Description>
      <Options moHideChildren="1"/>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
aobscanmodule(PointerBase_AOB,Injustice.exe,56 8B 31 33 D2 57)

label(PointerBase)
registersymbol(PointerBase)

[PointerBase_AOB+8]:
PointerBase:





 
[DISABLE]
unregistersymbol(PointerBase)


</AssemblerScript>
      <CheatEntries>
        <CheatEntry>
          <ID>115</ID>
          <Description>"base of gamespeed ptr"</Description>
          <LastState Value="12E6AEC0" Activated="0" RealAddress="04389AB0"/>
          <ShowAsHex>1</ShowAsHex>
          <Color>80000008</Color>
          <VariableType>4 Bytes</VariableType>
          <Address>PointerBase</Address>
        </CheatEntry>
        <CheatEntry>
          <ID>116</ID>
          <Description>"gamespeed ptr 1"</Description>
          <LastState Value="1" Activated="0" RealAddress="11FE9E3C"/>
          <Color>80000008</Color>
          <VariableType>Float</VariableType>
          <Address>PointerBase</Address>
          <Offsets>
            <Offset>2DC</Offset>
            <Offset>0</Offset>
            <Offset>38</Offset>
            <Offset>48</Offset>
          </Offsets>
        </CheatEntry>
        <CheatEntry>
          <ID>118</ID>
          <Description>"Pointerfinder (2/2)"</Description>
          <Options moHideChildren="1"/>
          <LastState Activated="0"/>
          <Color>80000008</Color>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>[ENABLE]
alloc(PointerFinder,200)
aobscanmodule(PointerWalker_AOB,Injustice.exe,51 F3 0F 11 04 24 FF D2 8B CE e8 * * * * 8b)
registersymbol(PointerWalker_AOB)

label(GamespeedPtr)
registersymbol(GamespeedPtr)

PointerFinder:
  mov ecx,dword [PointerBase]
  reassemble(PointerWalker_AOB+a)
  mov dword [GamespeedPtr],eax
retn
GamespeedPtr:
dd 0

createthread(PointerFinder)
 
 
[DISABLE]
unregistersymbol(PointerWalker_AOB)
unregistersymbol(GamespeedPtr)
dealloc(PointerFinder)
</AssemblerScript>
          <CheatEntries>
            <CheatEntry>
              <ID>117</ID>
              <Description>"gamespeed ptr 2"</Description>
              <LastState Value="??" Activated="0" RealAddress="00000000"/>
              <Color>80000008</Color>
              <VariableType>Float</VariableType>
              <Address>GamespeedPtr</Address>
              <Offsets>
                <Offset>2DC</Offset>
              </Offsets>
            </CheatEntry>
            <CheatEntry>
              <ID>119</ID>
              <Description>"Terminal offset"</Description>
              <LastState Value="000002DC" Activated="0" RealAddress="017AA7C7"/>
              <ShowAsHex>1</ShowAsHex>
              <Color>80000008</Color>
              <VariableType>4 Bytes</VariableType>
              <Address>PointerWalker_AOB+1e</Address>
            </CheatEntry>
          </CheatEntries>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
</CheatTable>

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Thu Mar 20, 2014 5:11 pm    Post subject: Reply with quote

Hmmm, "base of gamespeed ptr" is a non-zero value (0E861340), and "gamespeed ptr 1" is my current game speed, but I'm really not being able to enable PointerFinder(2/2), copied from quote, tried from the forum editing out the spaces, but nothing.
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Fri Mar 21, 2014 12:51 am    Post subject: Reply with quote

If you couldn't activate "PointerFinder(2/2)" it's not a big deal: it means my alternate overly complicated way to locate gamespeed doesn't work, which isn't a problem since "gamespeed ptr 1" works.
Since all my scripts used "gamespeed ptr 1" so far we can deduce that this is not the cause of the crash, hence a new batch of tests.

The goal is to know if you can activate Test 1 and which test(s) cause a crash.
Only one test must be active at a given time.
The included "Dynamic gamespeed" hacks are slightly different from the ones I posted earlier.

If "Test 2" causes a crash, activate "Locator", click on "Memory view", click in the upper pane, press ctrl+G, enter FrameCounter, and copy-paste here from 10 lines before the highlighted line to 10 lines after (or just a big screenful centered on this line).

Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>121</ID>
      <Description>"Test 1"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
aobscanmodule(Dummy,Injustice.exe,A1 * * * * BE 01 00 00 00 01 70 68 * * * * * 8B 48 68 51 68 * * * * 68)

 
 
[DISABLE]

</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>117</ID>
      <Description>"Test 2"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
alloc(SpeedAdjuster_Hook,300)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
registersymbol(SpeedAdjuster_AOB)


SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
  popad                         //restore all registers
retn

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook,200)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>118</ID>
      <Description>"Test 3"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
//define(GRANULARITY,0.0001) //makes sure GameSpeed is always a multiple of GRANULARITY. it might help against attack wiffing
alloc(SpeedAdjuster_Hook,300)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
registersymbol(SpeedAdjuster_AOB)

label(PrevTickCount)

SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
  popad                         //restore all registers
retn

PrevTickCount:
dd 0
 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>119</ID>
      <Description>"Test 4"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
alloc(SpeedAdjuster_Hook,300)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
aobscanmodule(PointerBase_AOB,Injustice.exe,56 8B 31 33 D2 57)
registersymbol(SpeedAdjuster_AOB)

label(PrevTickCount)
label(FrameDelayArrayIndex)
label(FrameDelayArray)



SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
       //store that delay in FrameDelayArray
  mov ebx,dword [FrameDelayArrayIndex] //load the index of the last FrameDelayArray we wrote
  inc ebx                              //increment it
  and ebx,7                            //but make sure it stays below 8
  mov dword [FrameDelayArrayIndex],ebx //update FrameDelayArrayIndex
  mov [FrameDelayArray+ebx*4],eax      //update FrameDelayArray
  popad                         //restore all registers
retn

PrevTickCount:
dd 0
FrameDelayArrayIndex:
dd 0
FrameDelayArray: //holds the time it took to render the last 8 frames
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>120</ID>
      <Description>"Test 5"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
alloc(SpeedAdjuster_Hook,300)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
registersymbol(SpeedAdjuster_AOB)

label(PrevTickCount)
label(EightThousand)
label(FrameDelayArrayIndex)
label(FrameDelayArray)


SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
       //store that delay in FrameDelayArray
  mov ebx,dword [FrameDelayArrayIndex] //load the index of the last FrameDelayArray we wrote
  inc ebx                              //increment it
  and ebx,7                            //but make sure it stays below 8
  mov dword [FrameDelayArrayIndex],ebx //update FrameDelayArrayIndex
  mov [FrameDelayArray+ebx*4],eax      //update FrameDelayArray
       //get the time it took to render the last 8 frames
  mov eax,dword [FrameDelayArray]
  add eax,dword [FrameDelayArray+4]
  add eax,dword [FrameDelayArray+8]
  add eax,dword [FrameDelayArray+c]
  add eax,dword [FrameDelayArray+10]
  add eax,dword [FrameDelayArray+14]
  add eax,dword [FrameDelayArray+18]
  add eax,dword [FrameDelayArray+1c]
       //calculate new game speed
  imul eax,eax,#60              //multiply time_elapsed_since_last_frame by 60 (desierd FPS)
  push eax
  fild dword [esp]              //convert time_elapsed...*60 into a float
  add esp,4                     //undo the previous push
  fdiv dword [EightThousand]    //divide it by 1000(mislisec per second)*8(number of frames used to calculate average frame delay)
  fstp st(0)                    //discard the result
  popad                         //restore all registers
retn

PrevTickCount:
dd 0
EightThousand:
dd (float)8000.0
FrameDelayArrayIndex:
dd 0
FrameDelayArray: //holds the time it took to render the last 8 frames
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>114</ID>
      <Description>"Dynamic gamespeed (8 frame avg)"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
//define(GRANULARITY,0.0001) //makes sure GameSpeed is always a multiple of GRANULARITY. it might help against attack wiffing
alloc(SpeedAdjuster_Hook,300)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
aobscanmodule(PointerBase_AOB,Injustice.exe,56 8B 31 33 D2 57)
registersymbol(SpeedAdjuster_AOB)

label(PrevTickCount)
label(EightThousand)
//label(Divisor)
label(FrameDelayArrayIndex)
label(FrameDelayArray)
label(PointerBase)

{
finds
  Injustice.exe+4A817B - 56                    - push esi
  Injustice.exe+4A817C - 8B 31                 - mov esi,[ecx]
  Injustice.exe+4A817E - 33 D2                 - xor edx,edx
  Injustice.exe+4A8180 - 57                    - push edi
  Injustice.exe+4A8181 - 8B 3D D03B9E03        - mov edi,[Injustice.exe+3073BD0]
  Injustice.exe+4A8187 - 89 5D FC              - mov [ebp-04],ebx
  Injustice.exe+4A818A - 85 DB                 - test ebx,ebx
and gets "Injustice.exe+3073BD0" from there
}
[PointerBase_AOB+8]:
PointerBase:


SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
       //store that delay in FrameDelayArray
  mov ebx,dword [FrameDelayArrayIndex] //load the index of the last FrameDelayArray we wrote
  inc ebx                              //increment it
  and ebx,7                            //but make sure it stays below 8
  mov dword [FrameDelayArrayIndex],ebx //update FrameDelayArrayIndex
  mov [FrameDelayArray+ebx*4],eax      //update FrameDelayArray
       //get the time it took to render the last 8 frames
  mov eax,dword [FrameDelayArray]
  add eax,dword [FrameDelayArray+4]
  add eax,dword [FrameDelayArray+8]
  add eax,dword [FrameDelayArray+c]
  add eax,dword [FrameDelayArray+10]
  add eax,dword [FrameDelayArray+14]
  add eax,dword [FrameDelayArray+18]
  add eax,dword [FrameDelayArray+1c]
       //calculate new game speed
  imul eax,eax,#60              //multiply time_elapsed_since_last_frame by 60 (desierd FPS)
  push eax
  fild dword [esp]              //convert time_elapsed...*60 into a float
  add esp,4                     //undo the previous push
  fdiv dword [EightThousand]      //divide it by 1000(mislisec per second)*8(number of frames used to calculate average frame delay)
       //now make sure the game speed is a multiple of GRANULARITY
 // fld dword [Divisor]
 // fld st(1)
 // fprem                         //now st0 is the modulus of gamespeed/GRANULARITY
 // fsub st(2),st(0)              //subtract the modulus from gamespeed
 // fstp st(0)                    //trash 2 temporary variables
 // fstp st(0)

  mov eax, dword [PointerBase] //walk down the pointer to the game's speed
  mov eax, dword [eax+48]
  mov eax, dword [eax+38]
  mov eax, dword [eax]
  fstp dword [eax+2dc]          //update gamespeed
  popad                         //restore all registers
retn

PrevTickCount:
dd 0
EightThousand:
dd (float)8000.0
//Divisor:
//dd (float)GRANULARITY
FrameDelayArrayIndex:
dd 0
FrameDelayArray: //holds the time it took to render the last 8 frames
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>122</ID>
      <Description>"Dynamic gamespeed (60 frame avg)"</Description>
      <LastState Activated="1"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
//define(GRANULARITY,0.0001) //makes sure GameSpeed is always a multiple of GRANULARITY. it might help against attack wiffing
define(AVERAGEDFRAMES,3C)  //3c=60 in hex
define(AVERAGEDFRAMESx1000,60000) //write here the result of 1000*AVERAGEDFRAMES in decimal
alloc(SpeedAdjuster_Hook,500)
aobscanmodule(SpeedAdjuster_AOB,Injustice.exe,8B 48 68 51 68 * * * * 68)
aobscanmodule(PointerBase_AOB,Injustice.exe,56 8B 31 33 D2 57)
registersymbol(SpeedAdjuster_AOB)

label(SpeedAdjuster_WriteFrameDelayArrayIndex)
label(SpeedAdjuster_ContinueSumming)
label(PrevTickCount)
label(AveragedFramesx1000)
//label(Divisor)
label(FrameDelayArrayIndex)
label(FrameDelayArray)
label(PointerBase)

{
finds
  Injustice.exe+4A817B - 56                    - push esi
  Injustice.exe+4A817C - 8B 31                 - mov esi,[ecx]
  Injustice.exe+4A817E - 33 D2                 - xor edx,edx
  Injustice.exe+4A8180 - 57                    - push edi
  Injustice.exe+4A8181 - 8B 3D D03B9E03        - mov edi,[Injustice.exe+3073BD0]
  Injustice.exe+4A8187 - 89 5D FC              - mov [ebp-04],ebx
  Injustice.exe+4A818A - 85 DB                 - test ebx,ebx
and gets "Injustice.exe+3073BD0" from there
}
[PointerBase_AOB+8]:
PointerBase:


SpeedAdjuster_AOB-5:
call SpeedAdjuster_Hook


SpeedAdjuster_Hook:
  pushad                         //save all registers
       //get time elapsed since last frame
  mov ebx, dword [PrevTickCount] //PrevTickCount=date when the previous frame was displayed
  call GetTickCount
  mov dword [PrevTickCount],eax //update PrevTickCount
  sub eax, ebx                  //get the time elapsed since last frame
       //store that delay in FrameDelayArray
  mov ebx,dword [FrameDelayArrayIndex] //load the index of the last FrameDelayArray we wrote
  inc ebx                              //increment it
  cmp ebx,AVERAGEDFRAMES               //but make sure it stays below AVERAGEDFRAMES
  jb SpeedAdjuster_WriteFrameDelayArrayIndex
    xor ebx,ebx
  SpeedAdjuster_WriteFrameDelayArrayIndex:
  mov dword [FrameDelayArrayIndex],ebx //update FrameDelayArrayIndex
  mov [FrameDelayArray+ebx*4],eax      //update FrameDelayArray
       //get the time it took to render the last 8 frames
  mov ebx,FrameDelayArray
  xor eax,eax
  SpeedAdjuster_ContinueSumming:
  add eax,dword [ebx]
  add ebx,4
  cmp ebx,FrameDelayArray+AVERAGEDFRAMES*4
  jb SpeedAdjuster_ContinueSumming
       //calculate new game speed
  imul eax,eax,#60              //multiply time_elapsed_since_last_frame by 60 (desired FPS)
  push eax
  fild dword [esp]              //convert time_elapsed...*60 into a float
  add esp,4                     //undo the previous push
  fdiv dword [AveragedFramesx1000]      //divide it by 1000(milisec per second)*8(number of frames used to calculate average frame delay)
       //now make sure the game speed is a multiple of GRANULARITY
 // fld dword [Divisor]
 // fld st(1)
 // fprem                         //now st0 is the modulus of gamespeed/GRANULARITY
 // fsub st(2),st(0)              //subtract the modulus from gamespeed
 // fstp st(0)                    //trash 2 temporary variables
 // fstp st(0)

  mov eax, dword [PointerBase] //walk down the pointer to the game's speed
  mov eax, dword [eax+48]
  mov eax, dword [eax+38]
  mov eax, dword [eax]
  fstp dword [eax+2dc]          //update gamespeed
  popad                         //restore all registers
retn

PrevTickCount:
dd 0
AveragedFramesx1000:
dd (float)AVERAGEDFRAMESx1000
//Divisor:
//dd (float)GRANULARITY
FrameDelayArrayIndex:
dd 0
FrameDelayArray: //holds the time it took to render the last 8 frames
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0

 
 
[DISABLE]
dealloc(SpeedAdjuster_Hook)
unregistersymbol(SpeedAdjuster_AOB)

SpeedAdjuster_AOB-5:
nop               //actually the real original code is MOV EAX,DWORD [injustice.exe+some]
nop               //but is already set to that value 3 lines before
nop
nop
nop
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>116</ID>
      <Description>"Locator"</Description>
      <LastState Activated="0"/>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
aobscanmodule(FrameCounter,Injustice.exe,8B 48 68 51 68 * * * * 68)
registersymbol(FrameCounter)

 
 
[DISABLE]
unregistersymbol(FrameCounter)


</AssemblerScript>
    </CheatEntry>
  </CheatEntries>
</CheatTable>

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Fri Mar 21, 2014 11:48 am    Post subject: Reply with quote

None of the tests crashed, and both Dynamic gamespeed worked flawlessly, I'll take some time to test the moves, but I played a bit, and it seemed normal, Amazing job!
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Fri Mar 21, 2014 12:38 pm    Post subject: Reply with quote

...And let me guess: you couldn't activate "Test 1". If it's indeed the case the problem is that our versions of the game do not increase the frame counter the same way: mine says "temporary=1, then add temporary to frame_count". Yours probably says "increase frame_count by 1" which is a lot less stupid. So when I try to overwrite "temporary=1", I actually overwrite something completely different, most likely one part of one instruction, and one part of the following, brewing a nice software nuke.

Anyway the 60 frame version takes more time (about 1 second) to adapt the game speed but seemed to prevent wiffing. Also you can edit this script to tune the number frames and find a better compromise.

I'm eager to know is this hack proves actually useful, and what granularity/frame count settings match your needs.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Gistix
How do I cheat?
Reputation: 0

Joined: 17 Mar 2014
Posts: 8

PostPosted: Fri Mar 21, 2014 1:46 pm    Post subject: Reply with quote

Oh, I actually were able to enable all the tests, and the 60 frame avg really looks smoother, If it is alright for you, I'll record a footage for YT Very Happy
Back to top
View user's profile Send private message
Gniarf
Grandmaster Cheater Supreme
Reputation: 43

Joined: 12 Mar 2012
Posts: 1285

PostPosted: Fri Mar 21, 2014 4:33 pm    Post subject: Reply with quote

Gistix wrote:
I actually were able to enable all the tests
Eh?? OK, fine, I'd better not try to understand what was happening there (hurts my pride though...).
Gistix wrote:
the 60 frame avg really looks smoother, If it is alright for you, I'll record a footage for YT
If you wanna make a video, why not.
Since you seem to like the 60 frame version, I added it to my IGAU table which you can find here http://forum.cheatengine.org/viewtopic.php?p=5507075 . It might be a good idea to give that link with the vid.

_________________
DO NOT PM me if you want help on making/fixing/using a hack.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites