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 


Need help / Triggerbot - Click MButton1 when a byte changes

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

Joined: 16 Jul 2015
Posts: 1

PostPosted: Thu Jul 16, 2015 3:28 am    Post subject: Need help / Triggerbot - Click MButton1 when a byte changes Reply with quote

Hello,

EDIT: My first problem was to get LUA read 3 bytes at a given adress. I solved this now (see code below).

My new problem now is that the keyDown/Up and doKeyPress commands don't work. Guess the game doesn't accept virtual keys. How to solve this?



Code for the read-3-bytes-if-then-keypress:

Code:

j = 4
processName = 'prog.exe'
openProcess(processName)
sleep(2000)
while j <= 10 do
   if getForegroundProcess() == getProcessIDFromProcessName(processName) then
    sleep(1000)
   ------------Read 3 bytes
    zoom = readBytes("[[[[prog.exe+01c4af28]+118]+0]+118]+8f8")
    zoom2 = readBytes("[[[[prog.exe+01c4af28]+118]+0]+118]+8f9")
    zoom3 = readBytes("[[[[prog.exe+01c4af28]+118]+0]+118]+8fa")
            -----------Crosshair green
            if zoom == 0 and zoom2 == 255 and zoom3 == 0 then
               keyDown(1)
               sleep(50)
               keyUp(1)
               sleep(300)
            end
            ------------Crosshair white
            if zoom == 255 and zoom2 == 255 and zoom3 == 255 then
               beep()
               sleep(50)
            end
            --------Press F2 to exit CE
             if isKeyPressed(113) == true then
                   showMessage("Exiting:D")
                   closeCE()
             end
      end
end
Back to top
View user's profile Send private message
ZacTheSin
I post too much
Reputation: 6

Joined: 09 May 2006
Posts: 2657

PostPosted: Thu Jul 16, 2015 11:02 pm    Post subject: Reply with quote

Ooh, somewhere I can help!

I had this exact same issue when creating a bot for another game.

I used a lua library called winapi by Steve Donovan (https://github.com/stevedonovan/winapi).

Here's it compiled with the current version of CheatEngine's libraries *CE6.4*.
Available via Hostr: https://hostr.co/KoMrvLM0H2ZW

Usage: https://raw.githubusercontent.com/Acen/FushBot/Script_Rewrite/FushBot.CT

Actual keypress usage from older version
Window select:
Code:
function windowSelect(fushBotSessionInt)
  if(fushBotSessionInt == 0) then
    windowSharedInteger = allocateSharedMemory("windowInteger", 4096)
    sleep(100)
    appWindow = winapi.find_window_match('Application Window Name')
    if (windowSharedInteger &lt; 1) or (readInteger(windowSharedInteger) &lt; 1) then
      writeInteger(windowSharedInteger, 1)
      local appWindowName = 'FushBot' .. readInteger(windowSharedInteger)
      appWindow:set_text(appWindowName)
      appWindow = winapi.find_window_match(appWindowName)
      print('fushBotSession:\t', readInteger(windowSharedInteger))
      return(readInteger(windowSharedInteger))
    elseif (windowSharedInteger &gt; 0) then
      writeInteger(windowSharedInteger, (readInteger(windowSharedInteger)+1))
      local appWindowName = 'FushBot' .. readInteger(windowSharedInteger)
      appWindow:set_text(appWindowName)
      appWindow = winapi.find_window_match(appWindowName)
      return(readInteger(windowSharedInteger))
    else
      print("Failed to find app client to connect new Fushbot session. Please try again.")
    end --]]
  elseif(fushBotSessionInt &gt; 0) then
    print('Existing Fushbot session found -- connecting ' .. fushBotSessionInt)
    appWindow = winapi.find_window_match('FushBot' .. fushBotSessionInt)
    return fushBotSessionInt
  else
    print('No session found. Please try again.')
  end
end


Code:
function castLine()
  varFishingStatus = 1
  if (readInteger(varLuresAvailable) > 0) then
     if (readInteger(varLineCast) == 0) then
       appWindow:send_message(7, 0, 0)
       sleep(100)
       appWindow:send_message(256, 70, 2162689)
       sleep(10)
       appWindow:send_message(257, 70, 2162689)
       print('Casting Line')
       sleep(3000)
     else
       print("Line already cast?")
     end
  else
    print("No lures available, or in assigned inventory slot (bottom left).")
  end
end

function catchFush()
  if (readInteger(varLineCast) > 0) then
    print("Reeling Line")
    sleep(500)
    appWindow:send_message(7,0,0)
    sleep(100)
    appWindow:send_message(256, 70, 2162689)
    sleep(1)
    appWindow:send_message(257, 70, 2162689)
    sleep(3000)
    varFishingStatus = 0
    fushCaught = fushCaught + 1
    if (fushCaught ~= 0) and (fushCaught % 5 == 0) then
      print("Fish Caught:\t", fushCaught)
    end
  else
    print("Line not cast? What in the world..?")
  end
end



Message me if you want finer detail. I'm not sure about what the rules are regarding specific detail when the code may have to do with an online game.
If you can't message - Skype: TheAcen

_________________
If someone helps you, why not Rep them?
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