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 


Auto increment of offset

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Twistedfate
Expert Cheater
Reputation: 1

Joined: 11 Mar 2016
Posts: 231

PostPosted: Wed Apr 26, 2017 4:06 am    Post subject: Auto increment of offset Reply with quote

if first monster name address in my game is

Code:
r=readInteger("[game.exe]+220")

the 2nd is
0x220+1c68 =1E88

Code:
r2=readInteger("[game.exe]+1E88")
+1c68 . ... . . .

r3=....

Is that possible to make auto increment to get all monsters addresses ?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Wed Apr 26, 2017 5:29 am    Post subject: This post has 1 review(s) Reply with quote

Sure, though you do need some way to tell how many monsters there are so that you know when to stop.

1 way is to assume you know (or can find) a length:

Code:
-- get numeric address
local enemyBase = getAddress("[game.exe]+220")
-- loop over each enemy
for i=0,length-1 do
  r=readInteger(enemyBase+0x1c68*i)
  -- do something with r, eg. table.insert(enemyList, r) or writeInteger(enemyBase+0x1c68*i, r-100)
end


you could also assume that there's a 0 value after the last enemy (like how C strings are 0 terminated) eg,

Code:
local i=0
while true do
  local strAddress = "[game.exe]+" .. string.format('%X', 0x220 +0x1C68*i)
  r=readInteger(strAddress)
  i=i+1
  if r == 0 then break end -- stop the loop if done
  -- do something with r
end
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