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 


Change different AoB's with Lua/AA

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

Joined: 24 Aug 2009
Posts: 6

PostPosted: Sun Jun 10, 2018 9:17 am    Post subject: Change different AoB's with Lua/AA Reply with quote

Hi, I want to change some different AoB's and tried to do this with Lua and AA, but I failed and I need some help hehe
E.g. I want to change all of this (50+ results)
Code:
4f 96 02 00 08 00 1c 96 07 00 08 06 07 ?? 00 00 00 4f 96 02 00 08 00 1c 96 ?? 00 08 07

to
Code:
4f 96 02 00 08 00 1c 96 07 00 08 06 07 64 00 00 00 4f 96 02 00 08 00 1c 96 ?? 00 08 07

If I do with AA, it only change the first result (I read here on the forum, that CE stop scan after first result)
And with Lua I get this error (Screen attached: AI-TG_AoB_Lua_01)
Maybe someone can help me or have a better idea to solve this.



AI-TG_AoB_Lua_01.jpg
 Description:
AI-TG_AoB_Lua_01
 Filesize:  451.85 KB
 Viewed:  335 Time(s)

AI-TG_AoB_Lua_01.jpg


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 32

Joined: 09 Aug 2013
Posts: 768

PostPosted: Sun Jun 10, 2018 12:52 pm    Post subject: Reply with quote

0x?? is not a valid hex number. writeBytes does not support wild cards. Split it up into multiple writes so you simply don't overwrite bytes that you don't want to change. Though I wouldn't be surprised if you could find some function on the forums that took an aobstring and called writeBytes for you which did support them, eg. https://forum.cheatengine.org/viewtopic.php?t=571272 or https://forum.cheatengine.org/viewtopic.php?t=571294
_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
MrShady187
How do I cheat?
Reputation: 0

Joined: 24 Aug 2009
Posts: 6

PostPosted: Sun Jun 10, 2018 6:50 pm    Post subject: Reply with quote

Thank you for the answer, I tried both functions from your links and both didn't work for me Very Happy
But after testing a bit, the function from your first link works for me partially.
It finds the AoB's and replaces them but if I want replace with e.g. FF ?? 01 02
it dont replace the ??, it jumps over them and replace it instead with FF 01 02 02.
Do you have an idea how I could solve this?
Do you know, would it work with the function at your 2nd link?

Could you give me an example with the 2nd function for this code:

Code:
4f 96 02 00 08 00 1c 96 07 00 08 06 07 ?? 00 00 00 4f 96 02 00 08 00 1c 96 ?? 00 08 07
to
4f 96 02 00 08 00 1c 96 07 00 08 06 07 64 00 00 00 4f 96 02 00 08 00 1c 96 ?? 00 08 07

4f 96 02 00 08 00 1c 96 0b 00 08 06 06 ?? ?? ?? ?? ?? ?? ?? ?? 4f 96 02 00 08 00 1c 96 ?? 00 08 07
to
4f 96 02 00 08 00 1c 96 0b 00 08 06 06 00 00 59 40 ?? ?? ?? ?? 4f 96 02 00 08 00 1c 96 ?? 00 08 07
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 32

Joined: 09 Aug 2013
Posts: 768

PostPosted: Mon Jun 11, 2018 8:54 am    Post subject: Reply with quote

I haven't used either, though the second does have some code that looked like it might support that, specifically the: local x, y = string.find(z, "%?+");

Since that doesn't seem to have worked for you perhaps this will: https://github.com/FreeER/CE-Examples/blob/5f34a197673e68e7f071f00a0683641f820aaa1e/AOB%20To%20Bytes%20-%20playing.lua

Code:
function AOBToBytes(aob)
  -- convert non-hex character to * if it is not a space
  local s = aob:gsub('%X', function(c) return c~=' ' and '*' or c end)
  -- replace single *s by two and remove all spaces for easy parsing
  s = s:gsub(' %* ', '**'):gsub(' ','')

  local b = {}
  for c in s:gmatch('..') do
    -- write bytes accepts numbers > 255 as wild cards
    -- with spaces removed anything that's not a hex number
    -- should be *s which should be treated as wild cards
    b[#b+1] = tonumber(c, 16) or 256
  end
  return b
end


It's designed to turn an AOB string into a table of bytes that you can pass to writeBytes (though I haven't tested it much) eg.
Code:
local RareMobs1AOB = '4F 96 02 00 08 00 1C 96 07 00 08 06 07 ?? 00 00 00 4F 96 02 00 08 00 1C 96 P? 00 08 07'
local RareMobs1 = AOBScan(RareMobs1AOB, '+W*X-C')
if RareMobs1 then
  for x=0, RareMobs1.getCount() do
    writeBytes(RareMobs1[x], AOBToBytes(RareMobs1AOB))
  end
  RareMobs1.Destroy()
  RareMobs1=nil
end


Though in the case of

4f 96 02 00 08 00 1c 96 0b 00 08 06 06 ?? ?? ?? ?? ?? ?? ?? ?? 4f 96 02 00 08 00 1c 96 ?? 00 08 07
to
4f 96 02 00 08 00 1c 96 0b 00 08 06 06 00 00 59 40 ?? ?? ?? ?? 4f 96 02 00 08 00 1c 96 ?? 00 08 07

you're not changing anything after the first ?? in the second, so just don't include any of that:
4f 96 02 00 08 00 1c 96 0b 00 08 06 06 00 00 59 40

no, ??s, no problem.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
MrShady187
How do I cheat?
Reputation: 0

Joined: 24 Aug 2009
Posts: 6

PostPosted: Mon Jun 11, 2018 3:29 pm    Post subject: Reply with quote

Well it was a bad example Very Happy There are also AoB's like change to: 01 ?? 02 ??.
I tried it with a other solution, I searched the AoB's manually and now I replace all of them with the bytes, what the most of them have Very Happy So I don't know what it changes but it works at this game Very Happy I know it's not a good solution hehe
But I don't understand your code, I see you scan for the AoB but where you replace it? Is this the line to replace? Didn't you replace it there with the same code as scanned?
Code:
writeBytes(RareMobs1[x], AOBToBytes(RareMobs1AOB))


Sorry I have no clue from AA or Lua Very Happy

But I have a new problem Very Happy
Maybe you can help me with that, too.
I want search for an AoB, replace it and freeze it.
I found this:
(I can't post URL's but it's here at this forum with the title "How to Freeze AOB in AA?")
(Screen attached -> AI-TG_AoB_Lua_02)
First I execute the Lua script, then I check the AA script to change the Value and then I check the AA script to freeze it, where it search for the new changed AoB..
Sometimes I got error, sometimes not, I also tried to run both AA scripts in one, but there I only got a error, most time for the line with {$lua}..
This is my try in one AA script:
Code:
[ENABLE]
//9999 CoR and CoUR
Aobscan(_InfCoR, F6 1B BC D0 11 04 00 00 18 03 9A D0 11 04 00 00 ?? ?? ?? 00 00 00 00 00 2C 5F D9 D1 11 04 00 00 ?? ?? ??)
_InfCoR +10:
db 78 38 01

_InfCoR +20:
db 78 38 01

{$lua}
local r = AOBScan'F6 1B BC D0 11 04 00 00 18 03 9A D0 11 04 00 00 78 38 01 00 00 00 00 00 2C 5F D9 D1 11 04 00 00 78 38 01' -- your AOB
local result = r[0]
r.destroy();
return freeze(result,4); -- freeze 4 bytes
{$asm}
[DISABLE]
luacall(unfreeze())


The script is checkable. but don't freeze anything, the value is still changing if I use it at the game..



AI-TG_AoB_Lua_02.jpg
 Description:
AI-TG_AoB_Lua_02
 Filesize:  351.09 KB
 Viewed:  237 Time(s)

AI-TG_AoB_Lua_02.jpg


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater
Reputation: 32

Joined: 09 Aug 2013
Posts: 768

PostPosted: Tue Jun 12, 2018 8:54 am    Post subject: Reply with quote

freeze is only going to freeze the first 4 bytes, F6 1B BC D0, which you didn't change in the previous script...

btw, read/write Bytes can use tables and lua has true/false booleans that you could use instead of 0 and 1.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
MrShady187
How do I cheat?
Reputation: 0

Joined: 24 Aug 2009
Posts: 6

PostPosted: Tue Jun 12, 2018 7:52 pm    Post subject: Reply with quote

Oh damn, youre right Very Happy I tried with 6 bytes, but didn't realize I need much more haha
Thank you very much
And like I said, I rly have no clue from lua Very Happy I'm even bad at copying hehe
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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