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 find aobscan for DOF Life Is Strange
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Mon Jan 18, 2016 3:51 pm    Post subject: Reply with quote

Hey. I used the injection template. Now I have 7 possible scripts! All seem to work. Is one better than another? Or, can I use any one of them? One of them looks odd as it has part of the exe. Should I toss it?

code:
mov [_camera],edi
test eax,eax
je LifeIsStrange.GetStackOwnerClass+310A68
cmp dword ptr [edi+00000274],00
jmp return
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Mon Jan 18, 2016 4:00 pm    Post subject: Reply with quote

Pick any of them. Assuming the AoB signature is unique, it doesn't really matter as long as no dynamically calculated addresses are in the signature.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Thu Jan 21, 2016 4:07 am    Post subject: Reply with quote

I'm just about there. Got injection working. Seems to be working pretty steadily. I'm pretty happy with it Smile Can't wait to actually sit down and actually play with it rather than test.

drive.google(.)com/file/d/0Bz1PTpaR0llTcmg5MUlrSnFXN0U/view?usp=sharing
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Sat Jan 30, 2016 2:35 pm    Post subject: Reply with quote

I searched but didn't find an answer. Can I set my hotkeys to only work when the game has focus? I would prefer nothing to happen while I'm alt tabbed. Since I'm using this to set up a screenshot in game, I have all kinds of hotkeys bound. But sometimes I need to leave the game and come back to find out the camera has moved. I have a lot of keys to bind. I'm trying to avoid commonly used keys but it's getting unavoidable.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Sun Jan 31, 2016 12:49 am    Post subject: Reply with quote

You might be able to check to see if the values returned by getForegroundProcess() and getOpenedProcessID() are equal in your onHotkey function of the hotkey.

You can combine up to 5 keys in a single hotkey... it shouldn't be that hard to pick something you won't hit. Just pick a really hard combination to hit at once like Ctrl + Shift + \ + OtherKey.
main.lua wrote:
GenericHotkey Class : (Inheritance: Object)
createHotkey(function, keys, ...) : returns an initialized GenericHotkey class object. Maximum of 5 keys
createHotkey(function, {keys, ...}) : ^

Look in defines.lua to see a list of all the key codes (search "VK_").

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Tue Feb 09, 2016 5:16 pm    Post subject: Reply with quote

Parkour, your save-cam-locations script didn't work. When I try to save a position, all my addresses go to 00000000. I know very little programming and even less of LUA so, when you first posted it, it was WAY over my head. Smile I blew right by it. But now, I'm trying to learn LUA for a free-fly cam script. I thought I would use your script as a starting point to learn.

I'm confused why you have "for i=0,9,1 do..." when there are 8 entries in the hash. Then, there is "for j=1,8,1 do..." Does that part not need to start at 0 and go to 7? Also you have "createHotkey(get, _G["VK_" .. i], VK_SHIFT)". Aren't the number keys VK_KEY_[num 0-9]? Not VK_[num]?

I'm really stumped about the free-fly cam where to start. I took a look at www(.)cheatengine(.)org/forum/viewtopic.php?p=5645347 but didn't get anywhere. I'd really like to get this working because while playing with the cam it only moves along the world axes and I keep getting confused where I am. I want it to move forward where it's pointed.

There are no cos or sin values. I'd have to calculate them. All I have is yaw 0 to 65536 = one turn and pitch -16384 to 16384. And of course x,y,z. In that script I think you posted about an LUA script? But I didn't see a link. Do you know of any other examples?

P.S. Can you use a free Steam code for this game? I have one. I appreciate all the help you've given.


EDIT: Actually.......it worked perfectly. Sorry Very Happy. I modified the script to use VK_NEXT and VK_DELETE since shift and control are already used in-game. It seemed like an innocent change, but that caused all kinds of problems. And I realize "Delete" was a hotkey bound to the POST PROCESSING script but I erased that hotkey. Anyway, I changed the in-game keys to something else and kept it as you had this time and it worked! Also, I understand now that "for i=0,9,1 do" pertain to the number keys and "for j=1,8,1 do," the hash indexes. And now having actually read the Cheat Engine VK documentation see that you were correct about the VK number keys. Another website said it was VK_KEY_[num].
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Wed Feb 10, 2016 12:21 pm    Post subject: Reply with quote

The outer for i=0,9,1 do... loop is to assign all the 0-9 keys. I started it at 0 and ended it at 9 just because that seemed like the most straightforward thing to do.

Inside that for loop, I create functions that are called when you press a hotkey. There's a "set" function and a "get" function. The "set" hotkey is only defined for all numbers except 0. This is because I wanted 0 to always be the last camera position you jumped from just so that you could jump back if you needed to, hence you shouldn't have to set that manually.

Inside those functions, there is another for j=1,8,1 do... loop. In the set function, this gets the current values of all the addresses and stores them. In the get function, it first checks to see if it's already stored the values in that specific slot. If it hasn't, then it'll just return since there's nothing to load. If it has, then it will store the current values of the addresses into slot 0 as long as you're not loading from slot 0. After that, it loads the bytes from your backup back into memory.

Note that you could also use readFloat(...) and writeFloat(...) to store the backup, but I figured it might have been possible for the numbers to not perfectly match up after saving and restoring the backup. Reading and writing the bytes directly would prevent any loss of information between saving/loading the values. If there was a loss in using read/writeFloat, it probably would've been negligible anyways, but whatever.

The reason why the outer for loop starts at 0 is because I thought that just made the most sense. The inner for loops start at 1 because that's how arrays are suppose to work in Lua. When you have a table like this:
Code:
camCheat.addy = {base+0x8; base+0xC; base+0x10; base+0x24; base+0x28; base+0x2C; base+0x1C; base-0x2b8}
camCheat.addy[1] == base+0x8, camCheat.addy[2] == base+0xC, etc...
Looking back at this, it might have been better to iterate over the camCheat.addy table via ipairs (namely for j,v in ipairs(camCheat.addy) do...).


If you're at a loss to know where to even start a program, it's helpful to first clearly identify what you want to do (which you've done). Then, start mapping out a basic control structure using pseudo-code, like so:
Code:
if (keyW is pressed) then
  move forward
end
if (keyS is pressed) then
  move backward
end
if (keyA is pressed) then
  move left
end
if (keyD is pressed) then
  move right
end
loop

After you have a basic pseudo-code control structure down, you can start to further define stuff, like "move forward". Namely, how are you going to move forward? You'll need to know the camera's coordinates, get it's current values, change them by adding/subtracting something to/from them, then store the new values back into the addresses.

This leads you to another question: what do I add/subtract to/from the values? Well, Gniarf tells you what you need to do here. You'll need to know the basics of trig to understand what Gniarf says in that post.

After you get everything down in pseudo-code, you can start translating that into real code (either Lua or ASM in this case). When you get more experienced, you can completely skip over writing everything down in pseudo-code.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Thu Feb 11, 2016 3:49 am    Post subject: Reply with quote

Here's a really ugly script I made in my attempt. Of course, it doesn't work. I can't figure out how to get the 4-byte decimals into float radians. I tried readInteger as well as readBytes. Didn't bother with the z-axis yet. I'm stumped. I searched and search for a similar problem. And I've come to understand this is a very common way for UE games to store pitch and yaw like this. So, why can't I find anything? :/.

Code:
[ENABLE]

{$lua}
setGlobalDelayBetweenHotkeyActivation(10)

if syntaxcheck then return end
local symbolCheckT = createTimer()
symbolCheckT.Interval = 50
symbolCheckT.OnTimer = function(sender)
  local base = readInteger("_camera")
  if base == 0 or base == nil then return end

  camXAD  = base+0x6F4; camX  = readFloat(camXAD)
  camYAD  = base+0x6F8; camY  = readFloat(camYAD)
  camZAD  = base+0x6FC; camZ  = readFloat(camZAD)
  tarXAD  = base+0x710; tarX  = readFloat(tarXAD)
  tarYAD  = base+0x714; tarY  = readFloat(tarYAD)
  tarZAD  = base+0x718; tarZ  = readFloat(tarZAD)
  pitchAD = base+0x700; pitch = readBytes(pitchAD,4,true) -- -16384 to 16384
  yawAD   = base+0x704; yaw   = readBytes(yawAD,2,true) -- 0 to 65536 (2 bytes)
  rollAD  = base+0x71C; roll  = readFloat(rollAD) -- 0 to 2*pi radians
  FOVAD   = base+0x70C; FOV   = readFloat(FOVAD)
  flySpeed = 10

  -- yaw is read-only. derived from cam and cam target, so cam and tar move together
  -- aiming will be done by moving tar

  function goForward ()
    yaw = readBytes(yawAD,2,true)
    yawRads = 2*math.pi*(yaw/65536)
    yAmt = flySpeed*math.sin(yawRads)
    xAmt = flySpeed*math.cos(yawRads)
    camY = camY + yAmt
    tarY = tarY + yAmt
    camX = camX + xAmt
    tarX = tarX + xAmt
    writeFloat(camYAD, camY)
    writeFloat(tarYAD, tarY)
    writeFloat(camXAD, camX)
    writeFloat(tarXAD, tarX)
  end

  function goBackward ()
    yaw = readBytes(yawAD,2,true)
    yawRads = 2*math.pi*(yaw/65536)
    yAmt = flySpeed*math.sin(yawRads)
    xAmt = flySpeed*math.cos(yawRads)
    camY = camY - yAmt
    tarY = tarY - yAmt
    camX = camX - xAmt
    tarX = tarX - xAmt
    writeFloat(camYAD, camY)
    writeFloat(tarYAD, tarY)
    writeFloat(camXAD, camX)
    writeFloat(tarXAD, tarX)
  end

  function strafeRight ()
    yaw = readBytes(yawAD,2,true)
    yawRads = 2*math.pi*(yaw/65536)
    yAmt = flySpeed*math.sin(yawRads)
    xAmt = flySpeed*math.cos(yawRads)
    camY = camY + yAmt
    tarY = tarY + yAmt
    camX = camX - xAmt
    tarX = tarX - xAmt
    writeFloat(camYAD, camY)
    writeFloat(tarYAD, tarY)
    writeFloat(camXAD, camX)
    writeFloat(tarXAD, tarX)
  end

  function strafeLeft ()
    yaw = readBytes(yawAD,2,true)
    yawRads = 2*math.pi*(yaw/65536)
    yAmt = flySpeed*math.sin(yawRads)
    xAmt = flySpeed*math.cos(yawRads)
    camY = camY - yAmt
    tarY = tarY - yAmt
    camX = camX + xAmt
    tarX = tarX + xAmt
    writeFloat(camYAD, camY)
    writeFloat(tarYAD, tarY)
    writeFloat(camXAD, camX)
    writeFloat(tarXAD, tarX)
  end

  createHotkey(goForward, VK_NUMPAD8)
  createHotkey(goBackward, VK_NUMPAD5)
  createHotkey(strafeLeft, VK_NUMPAD4)
  createHotkey(strafeRight, VK_NUMPAD6)

  sender.destroy()
end
{$asm}

[DISABLE]

Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Thu Feb 11, 2016 12:29 pm    Post subject: Reply with quote

You won't even need to worry about this in this case, but I'll explain how to read a word anyways.
There is readInteger(...), but since that'll read 4 bytes, it's not the best solution. You can manually convert 2 bytes into a word by adding the first byte to the second byte multiplied by 256:
Code:
local b1,b2 = readBytes(address,2,false)
local my2byteInt = b1+b2*256
This might not be the best way of doing it, but it's the easiest I can think of without any readWord(...) function or something.
There are a few quirks with this, however: the value is unsigned and it will be treated like it's greater than 2 bytes long by Lua. If you take proper precautions for both, neither of these should be a problem. Implement the limits for both when modifying those values using modular mathematics.
Also, when you go back to write to the addresses, you'll need to convert your word back into 2 bytes and write those directly.

setGlobalDelayBetweenHotkeyActivation(...) is a useful function to save a bit of code, but you had better be sure that no other Lua scripts are calling that function. If anything else does, it could mess up the timing of the hotkeys in your script. I'd set the DelayBetweenActivate property of all the hotkeys to 10 ms instead.

You're not declaring your variables and functions as local. That's just bad practice, but your script will still run. I didn't declare the camCheat table as a local in my script because I needed to clean up the hotkeys I made (explained later).

In your functions, it would be best if you read the current values of camX and camY into local variables before modifying them. This is so that if the game makes changes to those addresses while your script is active, your script will take those changes into account.

When doing your calculations, you don't even need to get the yaw or pitch. You can use you camera's position and the target's position to get the yaw and pitch. You will probably need to mess around with the signs of everything, but you'll find it. Namely:
Code:
local yaw = math.atan((tarY-camY)/(tarX-camX))
local pitch = math.atan((tarZ-camZ)/math.sqrt((tarX-camX)*(tarX-camX)+(tarY-camY)*(tarY-camY)))
If you understand trig, then you'd see that you can simplify this if you're just going to be taking the sin or cos of these angles:
Code:
function goForward ()
  local camX = readFloat(camXAD)
  local camY = readFloat(camYAD)
  local hypXY = math.sqrt((tarX-camX)*(tarX-camX)+(tarY-camY)*(tarY-camY))
  local dx = flySpeed * (tarX-camX)/hypXY
  local dy = flySpeed * (tarY-camY)/hypXY
  writeFloat(camXAD, camX+dx)
  writeFloat(camYAD, camY+dy)
end
For goBackward, strafeRight, and strafeLeft, all you should need to modify is whether you're adding or subtracting dx and/or dy. If you ever make a goUp and/or goDown function, the math will be slightly more complicated unless you just want to go straight up or straight down.

Finally, you should clean up everything in the [DISABLE] section. This would entail storing your hotkeys globally so that you can destroy them.
Code:
[ENABLE]
...
freeFlyCamHotkeys = {
  createHotkey(goForward, VK_NUMPAD8),
  createHotkey(goBackward, VK_NUMPAD5),
  createHotkey(strafeLeft, VK_NUMPAD4),
  createHotkey(strafeRight, VK_NUMPAD6)
}
...
[DISABLE]
if freeFlyCamHotkeys ~= nil then
  for _,v in ipairs(freeFlyCamHotkeys) do
    v.destroy()
  end
  freeFlyCamHotkeys = nil
end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Mon Feb 15, 2016 6:21 pm    Post subject: Reply with quote

Got it working! In fact...more than that. I got Z figured out as well and have implemented a free-fly cam and orbital cam. I figured out a dolly zoom too which I'm pretty proud of. Code is pretty messy but will clean it up and post. It's so awesome, thanks!

P.S. Should have realized that about yaw. :p
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Mon Feb 22, 2016 6:59 pm    Post subject: Reply with quote

Here's what I came up with and it works. Did I do anything too funky? I'm not quite sure I understand what syntaxcheck and symbolCheckT do but I left it in.

Code:

//"LifeIsStrange.exe"+2BBFB4
[ENABLE]

aobscanmodule(cameraAOB,LifeIsStrange.exe,8B 03 57 8B CB FF 90 94 04 00 00 5F)
alloc(newmem,$1000)

label(code)
label(return)

globalalloc(_camera,4)

newmem:

code:
  mov [_camera],ebx
  mov eax,[ebx]
  push edi
  mov ecx,ebx
  jmp return

cameraAOB:
  jmp code
return:
registersymbol(cameraAOB)

{$lua}
if syntaxcheck then return end
local symbolCheckT = createTimer()
symbolCheckT.Interval = 50
symbolCheckT.OnTimer = function(sender)

  local base = readInteger("_camera")
  if base == 0 or base == nil then return end

  -- ADDRESSES  (end ..AD)
  local camXAD  = base+0x6F4
  local camYAD  = base+0x6F8
  local camZAD  = base+0x6FC
  local tarXAD  = base+0x710
  local tarYAD  = base+0x714
  local tarZAD  = base+0x718
  local rollAD  = base+0x71C
  local FOVAD   = base+0x70C
  local freecamID   = readInteger(readInteger(base+0x2A4)) -- [[base+2A4]+0]
  local currentIDAD = base+0x288 -- copy above here to switch cams. 0 for default

  -- VARIABLES
  local freecamEnabled = false
  local flySpeed  = 3
  local aimSpeed  = math.pi/720
  local rollSpeed = math.pi/540
  local FOVSpeed  = 0.25
  local pitchMax  = 0.99*math.pi/2
  local moveDir   = ""
  local panDir    = ""
  local dollyDir  = ""
  local orbitDir  = ""

  -- SAVE/LOAD CAMERA SETTINGS
  if camCheat == nil then camCheat = {} end
  camCheat.addy = {camXAD; camYAD; camZAD; tarXAD; tarYAD; tarZAD; rollAD; FOVAD}
  for i=0,9,1 do
    camCheat[i] = {value = {}}
    local set = function(sender)
      if getOpenedProcessID()~=getForegroundProcess() then return end
      for j=1,8,1 do camCheat[i].value[j] = readBytes(camCheat.addy[j],4,true) end
    end
    if i == 0 then set(nil) else
      camCheat[i].setHotkey = createHotkey(set, _G["VK_" .. i], VK_MENU)
      camCheat[i].setHotkey.DelayBetweenActivate = 1000
    end
    local get = function(sender)
      if getOpenedProcessID()~=getForegroundProcess() then return end
      if #camCheat[i].value ~= 8 then return end
      for j=1,8,1 do
        if i ~= 0 then camCheat[0].value[j] = readBytes(camCheat.addy[j],4,true) end
        writeBytes(camCheat.addy[j], camCheat[i].value[j])
      end
    end
    camCheat[i].getHotkey = createHotkey(get, _G["VK_" .. i])
    camCheat[i].getHotkey.DelayBetweenActivate = 1000
  end

  -- WATCH FOR SPEED MODIFIER KEYS
  local didReset = true
  local didSlow = false
  local didFast = false
  local flySpeedOrig  = flySpeed
  local aimSpeedOrig  = aimSpeed
  local rollSpeedOrig = rollSpeed
  local FOVSpeedOrig  = FOVSpeed
  function checkKeys(timer)
    if getOpenedProcessID()~=getForegroundProcess() then return end
    if isKeyPressed(VK_F) then
      if not didFast then
        flySpeed  = flySpeedOrig*10
        aimSpeed  = aimSpeedOrig*10
        rollSpeed = rollSpeedOrig*10
        FOVSpeed  = FOVSpeedOrig*10
        didReset  = false
        didFast   = true
      end
    elseif isKeyPressed(VK_C) then
      if not didSlow then
        flySpeed  = flySpeedOrig/10
        aimSpeed  = aimSpeedOrig/10
        rollSpeed = rollSpeedOrig/10
        FOVSpeed  = FOVSpeedOrig/10
        didReset  = false
        didSlow   = true
      end
    elseif not didReset then
      flySpeed  = flySpeedOrig
      aimSpeed  = aimSpeedOrig
      rollSpeed = rollSpeedOrig
      FOVSpeed  = FOVSpeedOrig
      didFast   = false
      didSlow   = false
      didReset  = true
    end
  end
  t = createTimer(nil)
  timer_setInterval(t, 100)
  timer_onTimer(t, checkKeys)
  timer_setEnabled(t, true)

  -- FUNCTIONS...

  function moveF () move("forward") end
  function moveB () move("backward") end
  function moveL () move("left") end
  function moveR () move("right") end
  function orbitL () orbit("left") end
  function orbitR () orbit("right") end
  function orbitU () orbit("up") end
  function orbitD () orbit("down") end
  function aimL () aim("left") end
  function aimR () aim("right") end
  function aimU () aim("up") end
  function aimD () aim("down") end

  function move (moveDir)
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local dX; local dY; local dZ
    if moveDir == "forward" then
      dX = 1; dY = 1; dZ = 1
    elseif moveDir == "backward" then
      dX = -1; dY = -1; dZ = -1
    else
      if moveDir == "right" then
        dX = -1; dY = 1; dZ = -1
      elseif moveDir == "left" then
        dX = 1; dY = -1; dZ = 1
      else return
      end
      local roll  = readFloat(rollAD)
      local cosRoll  = math.cos(roll)
      dX = dX*flySpeed*cosRoll*Ydiff/hypZ
      dY = dY*flySpeed*cosRoll*Xdiff/hypZ
      dZ = dZ*flySpeed*math.sin(roll)
      writeFloat(tarXAD, tarX+dX)
      writeFloat(tarYAD, tarY+dY)
      writeFloat(tarZAD, tarZ+dZ)
      writeFloat(camXAD, camX+dX)
      writeFloat(camYAD, camY+dY)
      writeFloat(camZAD, camZ+dZ)
      return
    end
    dX = dX*flySpeed*Xdiff/hypZ
    dY = dY*flySpeed*Ydiff/hypZ
    dZ = dZ*flySpeed*Zdiff/hypZ
    writeFloat(tarXAD, tarX+dX)
    writeFloat(tarYAD, tarY+dY)
    writeFloat(tarZAD, tarZ+dZ)
    writeFloat(camXAD, camX+dX)
    writeFloat(camYAD, camY+dY)
    writeFloat(camZAD, camZ+dZ)
  end

  function moveU ()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local camZ  = readFloat(camZAD)
    local tarZ  = readFloat(tarZAD)
    writeFloat(camZAD, camZ+flySpeed)
    writeFloat(tarZAD, tarZ+flySpeed)
  end

  function moveD ()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local camZ  = readFloat(camZAD)
    local tarZ  = readFloat(tarZAD)
    writeFloat(camZAD, camZ-flySpeed)
    writeFloat(tarZAD, tarZ-flySpeed)
  end

  function aim (aimDir)
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local pitch
    if aimDir == "up" then
      pitch = math.asin(Zdiff/hypZ)+aimSpeed
    elseif aimDir == "down" then
      pitch = math.asin(Zdiff/hypZ)-aimSpeed
    else
      local yaw
      if aimDir == "left" then
        yaw = math.atan(Ydiff/Xdiff)-aimSpeed
      elseif aimDir == "right" then
        yaw = math.atan(Ydiff/Xdiff)+aimSpeed
      else return
      end
      if Xdiff<0 then yaw = yaw + math.pi end
      local dX = hypXY*math.cos(yaw)
      local dY = hypXY*math.sin(yaw)
      writeFloat(tarXAD, camX+dX)
      writeFloat(tarYAD, camY+dY)
      return
    end
    if pitch > -1*pitchMax and pitch <= pitchMax then
      local R  = hypZ*math.cos(pitch)/hypXY
      local dX = Xdiff*R
      local dY = Ydiff*R
      local dZ = hypZ*math.sin(pitch)
      writeFloat(tarXAD, camX+dX)
      writeFloat(tarYAD, camY+dY)
      writeFloat(tarZAD, camZ+dZ)
    end
  end

  function orbit(orbitDir)
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local yaw
    if orbitDir == "left" then
      yaw = math.atan(Ydiff/Xdiff)-aimSpeed
    elseif orbitDir == "right" then
      yaw = math.atan(Ydiff/Xdiff)+aimSpeed
    else
      local camZ  = readFloat(camZAD)
      local tarZ  = readFloat(tarZAD)
      local Zdiff = tarZ-camZ
      local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
      local pitch
      if orbitDir == "down" then
        pitch = math.asin(Zdiff/hypZ)+aimSpeed
      elseif orbitDir == "up" then
        pitch = math.asin(Zdiff/hypZ)-aimSpeed
      else return
      end
      if pitch>-1*pitchMax and pitch <= pitchMax then
        local R  = hypZ*math.cos(pitch)/hypXY
        local dX = Xdiff*R
        local dY = Ydiff*R
        local dZ = hypZ*math.sin(pitch)
        writeFloat(camXAD, tarX-dX)
        writeFloat(camYAD, tarY-dY)
        writeFloat(camZAD, tarZ-dZ)
      end
      return
    end
    if Xdiff<0 then yaw = yaw + math.pi end
    local dX    = hypXY*math.cos(yaw)
    local dY    = hypXY*math.sin(yaw)
    writeFloat(camXAD, tarX-dX)
    writeFloat(camYAD, tarY-dY)
  end

  function FOVup ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local FOV = readFloat(FOVAD)
    writeFloat(FOVAD, FOV+FOVSpeed)
  end

  function FOVdn ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local FOV = readFloat(FOVAD)
    writeFloat(FOVAD, FOV-FOVSpeed)
  end

  function FOVrs ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    writeFloat(FOVAD, "68")
  end

  function rollup ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local roll = readFloat(rollAD)
    writeFloat(rollAD, roll+rollSpeed)
  end

  function rolldn ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local roll = readFloat(rollAD)
    writeFloat(rollAD, roll-rollSpeed)
  end

  function rollReset ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    writeFloat(rollAD, 0)
  end

  function toggleFreecam ()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    if not freecamEnabled then
      writeInteger(currentIDAD, freecamID)
      freecamEnabled = true
    else
      for j=1,8,1 do
        camCheat[0].value[j] = readBytes(camCheat.addy[j],4,true)
      end
      writeInteger(currentIDAD, 0)
      freecamEnabled = false
    end
  end

  function dollyCloser ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    if hypZ>flySpeed then
      local dX    = flySpeed*Xdiff/hypZ
      local dY    = flySpeed*Ydiff/hypZ
      local dZ    = flySpeed*Zdiff/hypZ
      writeFloat(camXAD, camX+dX)
      writeFloat(camYAD, camY+dY)
      writeFloat(camZAD, camZ+dZ)
    end
  end

  function dollyFarther ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local dX    = flySpeed*Xdiff/hypZ
    local dY    = flySpeed*Ydiff/hypZ
    local dZ    = flySpeed*Zdiff/hypZ
    writeFloat(camXAD, camX-dX)
    writeFloat(camYAD, camY-dY)
    writeFloat(camZAD, camZ-dZ)
  end

  function dollyZoomOut ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local FOV   = readFloat(FOVAD)
    local FOVrads = math.pi*FOV/180
    local dollySpeed = flySpeed*(1-FOV/170)^2
    local objWidth = hypZ*2*math.tan(FOVrads/2)
    FOVrads = 2*math.atan(objWidth/(2*(hypZ-dollySpeed)))
    FOV = 180*FOVrads/math.pi
    if FOV <= 170 then
      local dX = dollySpeed*Xdiff/hypZ
      local dY = dollySpeed*Ydiff/hypZ
      local dZ = dollySpeed*Zdiff/hypZ
      writeFloat(FOVAD, FOV)
      writeFloat(camXAD, camX+dX)
      writeFloat(camYAD, camY+dY)
      writeFloat(camZAD, camZ+dZ)
    end
  end

  function dollyZoomIn ()
    if not freecamEnabled or getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local FOV   = readFloat(FOVAD)
    local FOVin = FOV
    local dollySpeed = flySpeed*(1-FOV/170)^2
    local FOVrads = math.pi*FOV/180
    local objWidth = hypZ*2*math.tan(FOVrads/2)
    FOVrads = 2*math.atan(objWidth/(2*(hypZ+dollySpeed)))
    FOV = 180*FOVrads/math.pi
    if FOV >= 3.1 then
      local dX    = dollySpeed*Xdiff/hypZ
      local dY    = dollySpeed*Ydiff/hypZ
      local dZ    = dollySpeed*Zdiff/hypZ
      writeFloat(FOVAD, FOV)
      writeFloat(camXAD, camX-dX)
      writeFloat(camYAD, camY-dY)
      writeFloat(camZAD, camZ-dZ)
    end
  end

  -- CREATE HOTKEYS
  hk1 = createHotkey(moveF, VK_NUMPAD8)
  hk2 = createHotkey(moveB, VK_NUMPAD5)
  hk3 = createHotkey(moveR, VK_NUMPAD6)
  hk4 = createHotkey(moveL, VK_NUMPAD4)
  hk5 = createHotkey(moveU, VK_NUMPAD9)
  hk6 = createHotkey(moveD, VK_NUMPAD7)
  hk7 = createHotkey(aimR, VK_ADD, VK_NUMPAD6)
  hk8 = createHotkey(aimL, VK_ADD, VK_NUMPAD4)
  hk9 = createHotkey(FOVup, VK_ADD, VK_NUMPAD7)
  hk10 = createHotkey(FOVdn, VK_ADD, VK_NUMPAD9)
  hk11 = createHotkey(aimU, VK_ADD, VK_NUMPAD8)
  hk12 = createHotkey(aimD, VK_ADD, VK_NUMPAD5)
  hk13 = createHotkey(dollyFarther, VK_RETURN, VK_NUMPAD1)
  hk14 = createHotkey(dollyCloser, VK_RETURN, VK_NUMPAD3)
  hk15 = createHotkey(dollyReset, VK_RETURN, VK_NUMPAD2)
  hk16 = createHotkey(rolldn, VK_ADD, VK_NUMPAD1)
  hk17 = createHotkey(rollup, VK_ADD, VK_NUMPAD3)
  hk18 = createHotkey(rollReset, VK_ADD, VK_NUMPAD2)
  hk19 = createHotkey(orbitD, VK_RETURN, VK_NUMPAD8)
  hk20 = createHotkey(orbitU, VK_RETURN, VK_NUMPAD5)
  hk21 = createHotkey(orbitR, VK_RETURN, VK_NUMPAD4)
  hk22 = createHotkey(orbitL, VK_RETURN, VK_NUMPAD6)
  hk23 = createHotkey(dollyZoomIn, VK_RETURN, VK_NUMPAD9)
  hk24 = createHotkey(dollyZoomOut, VK_RETURN, VK_NUMPAD7)
  hk25 = createHotkey(toggleFreecam, VK_NEXT)
  camHotkeys = {}
  for i=1,24,1 do
    _G["hk"..i].DelayBetweenActivate = 10
    table.insert(camHotkeys,_G["hk"..i])
  end
  hk25.DelayBetweenActivate = 1000
  table.insert(camHotkeys,hk25)

  sender.destroy()
end

{$asm}
[DISABLE]

cameraAOB:
  db 8B 03 57 8B CB

unregistersymbol(cameraAOB)
dealloc(newmem)

{$lua}
if camHotkeys ~= nil then
  for _,v in ipairs(camHotkeys) do v.destroy() end
  camHotkeys = nil
end
if camCheat ~= nil then
  for i=0,9,1 do
    if i ~= 0 then camCheat[i].setHotkey.destroy() end
    camCheat[i].getHotkey.destroy()
  end
  camCheat = nil
end
[/code]
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Feb 23, 2016 2:38 am    Post subject: Reply with quote

I'm a bit tired right now, so please forgive me if I say something wrong, explain something ineptly, or generally miss something.

syntaxcheck is a boolean variable set by CE to tell your script if it's just running the code to make sure there aren't any major errors in it or something. I was pretty certain there weren't any major errors in mine and I didn't want to be bothered by it when writing the script, so I added that line of code to make the Lua script not run if it's only doing a syntaxcheck. It's not that important in this case, but it's been a pain for me in other scripts.

symbolCheckT is a timer I made to check when the symbol is valid. When it is, run the code, then destroy the timer (the "sender.destroy()" line of code at the end).

idk31 wrote:
Code:
if getOpenedProcessID()~=getForegroundProcess() then return end
if #camCheat[i].value ~= 8 then return end
Since the two if statements do the same thing and they're right next to each other, you can combine them into one using the "or" logical operator. You can guess what it does as its name implies, but it has a few other quirks with it in Lua that are documented here.

idk31 wrote:
Code:
function checkKeys(timer)
  ...
end
-- other functions here
Your functions aren't local. Again, this is just bad practice, but your script will still work just fine. To make them local:
Code:
local function checkKeys(timer) ... end
-- or:
local checkKeys = function(timer) ... end
-- be careful with self-referencing on that second way of declaring it. If you want to (e.g. recursion):
local checkKeys; checkKeys = function(timer) ... end

idk31 wrote:
Code:
t = createTimer(nil)
timer_setInterval(t, 100)
timer_onTimer(t, checkKeys)
timer_setEnabled(t, true)
I'm pretty sure the "className_functionName" functions are deprecated and shouldn't be used. Just use "t.setInterval(100)" instead.
You don't need to set the enabled property to true. It's already true by default. Once you set the onTimer property, it's good to go.
You can simplify it a bit by doing something like:
Code:
t.onTimer = function()
  -- body of checkKeys function here
end

idk31 wrote:
Code:
-- CREATE HOTKEYS
hk1 = createHotkey(moveF, VK_NUMPAD8)
...
You don't set those global variables to nil in the disable section. It would be better if you did it something like this:
Code:
camHotkeys = {
  createHotkey(moveF, VK_NUMPAD8),
  createHotkey(moveB, VK_NUMPAD5),
-- other hotkeys...
  createHotkey(toggleFreecam, VK_NEXT)
}
for i,v in ipairs(camHotkeys) do
  v.DelayBetweenActivate = i == 25 and 1000 or 10  -- aforementioned quirkiness with logical operators
end

idk31 wrote:
Code:
if hypZ>flySpeed then
  local dX    = flySpeed*Xdiff/hypZ
  local dY    = flySpeed*Ydiff/hypZ
  local dZ    = flySpeed*Zdiff/hypZ
  writeFloat(camXAD, camX+dX)
  writeFloat(camYAD, camY+dY)
  writeFloat(camZAD, camZ+dZ)
end
Your formatting is generally good (much better than some people on these forums), but it could use improvements in a few awkward places such as the spaces above.


Beyond all of that, there's a few optimizations you can make. There are some big ones that I can't go into that much detail over without taking apart the entire script, but an example of a smaller one is how the "move(moveDir)" function works. There's also some very minor things here and there; for example,
Code:
-- your code:
if pitch > -1*pitchMax and pitch <= pitchMax then
-- why not just put "pitch > -pitchMax" instead?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Tue Feb 23, 2016 12:02 pm    Post subject: Reply with quote

Good tips. So, [Enable] doesn't activate the lua code? It kinda exists all on its own? I added a "base (address) == nil" check even though it checks for base == 0. Otherwise, the lua debugger still had a fit when I activated it and there was no symbol found. As to the pitch thing yeah I do need it that way: if pitch<=pitchMax and pitch>-pitchMax...I need a floor and a ceiling to that value. The game doesn't handle a 90 degree pitch up very well.

Edit: v.DelayBetweenActivate = i == 25 and 1000 or 10, didn't work forme.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4300

PostPosted: Tue Feb 23, 2016 1:02 pm    Post subject: Reply with quote

Everything below [ENABLE] and above [DISABLE] is run when you check the checkbox next to the script in the cheat table, including any Lua scripts inside it. The reason that timer exists is because the game needs to execute that section of ASM in order for the "_camera" symbol to be populated. It's already been globally allocated, so its value is 0 by default. That's why I'm reading it and comparing it with 0. If it is 0, then that section of ASM hasn't been run, and trying to dereference that is going to raise a segfault, crashing the game. Once that section of ASM is run, however, its value will be some valid address (not 0), so you can then safely run your Lua code without any fear of that symbol causing a segfault.

Also, it's never going to be nil unless that symbol doesn't exist. Since it has been globally allocated, it's never going to be nil, and that check is pointless. I'm not sure why it would be giving you an error, unless you had a typo somewhere. I thought that maybe CE was starting the timer before it globally allocated that variable, but 50ms is a huge amount of time for a computer and should be more than enough for CE to allocate the memory and register it as a symbol.

I just had a thought- if the script is deactivated before the symbol could be populated, it would run indefinitely. There are a few ways you could solve this. The most "correct" one IMO would be to check if the script is deactivated using the AddressList and MemoryRecord classes, and if it is, destroy the timer. You could also just set it as a global variable and destroy it in the disable section if you want, but I like using as few global things as possible.

idk31 wrote:
v.DelayBetweenActivate = i == 25 and 1000 or 10, didn't work forme.
What do you mean? Open up the Lua engine window (Ctrl + Alt + Shift + L from main CE window), paste this in, and execute it:
Code:
local i = 25
print(i == 25 and 1000 or 10)   -- 1000
print(i == 15 and 1000 or 10)   -- 10
print((i == 25) and 1000 or 10) -- 1000
print((i == 15) and 1000 or 10) -- 10
If that doesn't work, try downloading the latest CE 6.5. It works fine for me, so maybe yours is out of date or something.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
idk31
Cheater
Reputation: 1

Joined: 11 Jan 2016
Posts: 42

PostPosted: Wed Feb 24, 2016 5:41 pm    Post subject: Reply with quote

Well, you were right (again) Smile. That code, v.DelayBetweenActivate = i == 25 and 1000 or 10, does work. I probably just broke my script elsewhere.

Here's the full table for anyone interested.
https://drive.google(.)com/file/d/0Bz1PTpaR0llTSVU0YzhWSU1IN1E/view?usp=sharing

Updated script:

Code:

[ENABLE]
.... (aobscan)

{$lua}
if syntaxcheck then return end
symbolCheckT = createTimer()
symbolCheckT.Interval = 50
symbolCheckT.OnTimer = function(sender)

  local base = readInteger("_camera")
  if base == 0 or base == nil then return end

  -- ADDRESSES  (end ..AD)
  local camXAD  = base+0x6F4
  local camYAD  = base+0x6F8
  local camZAD  = base+0x6FC
  local tarXAD  = base+0x710
  local tarYAD  = base+0x714
  local tarZAD  = base+0x718
  local rollAD  = base+0x71C
  local FOVAD   = base+0x70C
  local freecamID   = readInteger(readInteger(base+0x2A4))
  local currentIDAD = base+0x288

  -- VARIABLES
  local flySpeed  = 3
  local aimSpeed  = math.pi/720
  local rollSpeed = math.pi/540
  local FOVSpeed  = 0.25
  local fastMult  = 10 -- how many times faster on hotkey press
  local slowDiv   = 10 -- how many times slower on hotkey press
  local pitchMax  = 0.99*math.pi/2

  -- SAVE/LOAD CAMERA SETTINGS
  if camCheat == nil then camCheat = {} end
  camCheat.addy = {camXAD; camYAD; camZAD; tarXAD; tarYAD; tarZAD; rollAD; FOVAD}
  for i=0,9,1 do
    camCheat[i] = {value = {}}
    local set = function(sender)
      if getOpenedProcessID()~=getForegroundProcess() then return end
      for j=1,8,1 do camCheat[i].value[j] = readBytes(camCheat.addy[j],4,true) end
    end
    if i == 0 then set(nil) else
      camCheat[i].setHotkey = createHotkey(set, _G["VK_" .. i], VK_MENU)
      camCheat[i].setHotkey.DelayBetweenActivate = 1000
    end
    local get = function(sender)
      if getOpenedProcessID()~=getForegroundProcess() then return end
      if #camCheat[i].value ~= 8 then return end
      for j=1,8,1 do
        if i ~= 0 then camCheat[0].value[j] = readBytes(camCheat.addy[j],4,true) end
        writeBytes(camCheat.addy[j], camCheat[i].value[j])
      end
    end
    camCheat[i].getHotkey = createHotkey(get, _G["VK_" .. i])
    camCheat[i].getHotkey.DelayBetweenActivate = 1000
  end

  -- WATCH FOR SPEED MODIFIER KEYS
  local didReset = true
  local didSlow = false
  local didFast = false
  local flySpeedOrig  = flySpeed
  local aimSpeedOrig  = aimSpeed
  local rollSpeedOrig = rollSpeed
  local FOVSpeedOrig  = FOVSpeed
  local checkKeys = createTimer()
  checkKeys.setInterval(100)
  checkKeys.onTimer = function()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    if isKeyPressed(VK_F) then
      if not didFast then
        flySpeed  = flySpeedOrig*fastMult
        aimSpeed  = aimSpeedOrig*fastMult
        rollSpeed = rollSpeedOrig*fastMult
        FOVSpeed  = FOVSpeedOrig*fastMult
        didReset  = false
        didFast   = true
      end
    elseif isKeyPressed(VK_C) then
      if not didSlow then
        flySpeed  = flySpeedOrig/slowDiv
        aimSpeed  = aimSpeedOrig/slowDiv
        rollSpeed = rollSpeedOrig/slowDiv
        FOVSpeed  = FOVSpeedOrig/slowDiv
        didReset  = false
        didSlow   = true
      end
    elseif not didReset then
      flySpeed  = flySpeedOrig
      aimSpeed  = aimSpeedOrig
      rollSpeed = rollSpeedOrig
      FOVSpeed  = FOVSpeedOrig
      didFast   = false
      didSlow   = false
      didReset  = true
    end
  end

  -- CAMERA FUNCTIONS...

  local function toggleFreecam()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    if freecamID == readInteger(currentIDAD) then -- save camera settings
      for j=1,8,1 do camCheat[0].value[j] = readBytes(camCheat.addy[j],4,true) end
      writeInteger(currentIDAD, 0)
    else
      writeInteger(currentIDAD, freecamID)
    end
  end

  local function move(moveDir)
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local camZ  = readFloat(camZAD)
    local tarZ  = readFloat(tarZAD)
    if moveDir == "up" then
      writeFloat(camZAD, camZ+flySpeed)
      writeFloat(tarZAD, tarZ+flySpeed)
      return
    elseif moveDir == "down" then
      writeFloat(camZAD, camZ-flySpeed)
      writeFloat(tarZAD, tarZ-flySpeed)
      return
    end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    local dX; local dY; local dZ
    if moveDir == "right" then
      local roll  = readFloat(rollAD)
      local cosRoll  = math.cos(roll)
      dX = flySpeed*cosRoll*Ydiff/hypZ
      dY = flySpeed*cosRoll*Xdiff/hypZ
      dZ = flySpeed*math.sin(roll)
      writeFloat(tarXAD, tarX-dX)
      writeFloat(tarYAD, tarY+dY)
      writeFloat(tarZAD, tarZ-dZ)
      writeFloat(camXAD, camX-dX)
      writeFloat(camYAD, camY+dY)
      writeFloat(camZAD, camZ-dZ)
      return
    elseif moveDir == "left" then
      local roll  = readFloat(rollAD)
      local cosRoll  = math.cos(roll)
      dX = flySpeed*cosRoll*Ydiff/hypZ
      dY = flySpeed*cosRoll*Xdiff/hypZ
      dZ = flySpeed*math.sin(roll)
      writeFloat(tarXAD, tarX+dX)
      writeFloat(tarYAD, tarY-dY)
      writeFloat(tarZAD, tarZ+dZ)
      writeFloat(camXAD, camX+dX)
      writeFloat(camYAD, camY-dY)
      writeFloat(camZAD, camZ+dZ)
      return
    end
    dX = flySpeed*Xdiff/hypZ
    dY = flySpeed*Ydiff/hypZ
    dZ = flySpeed*Zdiff/hypZ
    if moveDir == "forward" then
      writeFloat(tarXAD, tarX+dX)
      writeFloat(tarYAD, tarY+dY)
      writeFloat(tarZAD, tarZ+dZ)
      writeFloat(camXAD, camX+dX)
      writeFloat(camYAD, camY+dY)
      writeFloat(camZAD, camZ+dZ)
    elseif moveDir == "backward" then
      writeFloat(tarXAD, tarX-dX)
      writeFloat(tarYAD, tarY-dY)
      writeFloat(tarZAD, tarZ-dZ)
      writeFloat(camXAD, camX-dX)
      writeFloat(camYAD, camY-dY)
      writeFloat(camZAD, camZ-dZ)
    else return
    end
  end

  local function orbit(orbitDir)
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local yaw
    if orbitDir == "left" or orbitDir == "panRight" then
      yaw = math.atan(Ydiff/Xdiff)+aimSpeed
    elseif orbitDir == "right" or orbitDir == "panLeft" then
      yaw = math.atan(Ydiff/Xdiff)-aimSpeed
    else
      local camZ  = readFloat(camZAD)
      local tarZ  = readFloat(tarZAD)
      local Zdiff = tarZ-camZ
      local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
      local pitch
      if orbitDir == "down" or orbitDir == "panUp" then
        pitch = math.asin(Zdiff/hypZ)+aimSpeed
      elseif orbitDir == "up" or orbitDir == "panDown" then
        pitch = math.asin(Zdiff/hypZ)-aimSpeed
      else return
      end
      if pitch>-pitchMax and pitch <= pitchMax then
        local R  = hypZ*math.cos(pitch)/hypXY
        local dX = Xdiff*R
        local dY = Ydiff*R
        local dZ = hypZ*math.sin(pitch)
        if orbitDir == "panUp" or orbitDir == "panDown" then
          writeFloat(tarXAD, camX+dX)
          writeFloat(tarYAD, camY+dY)
          writeFloat(tarZAD, camZ+dZ)
          return
        else
          writeFloat(camXAD, tarX-dX)
          writeFloat(camYAD, tarY-dY)
          writeFloat(camZAD, tarZ-dZ)
          return
        end
      end
      return
    end
    if Xdiff<0 then yaw = yaw + math.pi end
    local dX = hypXY*math.cos(yaw)
    local dY = hypXY*math.sin(yaw)
    if orbitDir == "panLeft" or orbitDir == "panRight" then
      writeFloat(tarXAD, camX+dX)
      writeFloat(tarYAD, camY+dY)
    elseif orbitDir == "left" or orbitDir == "right" then
      writeFloat(camXAD, tarX-dX)
      writeFloat(camYAD, tarY-dY)
    else return
    end
  end

  local function dolly(dollyDir)
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local camX  = readFloat(camXAD)
    local camY  = readFloat(camYAD)
    local camZ  = readFloat(camZAD)
    local tarX  = readFloat(tarXAD)
    local tarY  = readFloat(tarYAD)
    local tarZ  = readFloat(tarZAD)
    local Xdiff = tarX-camX
    local Ydiff = tarY-camY
    local Zdiff = tarZ-camZ
    local hypXY = math.sqrt(Xdiff*Xdiff+Ydiff*Ydiff)
    local hypZ  = math.sqrt(Zdiff*Zdiff+hypXY*hypXY)
    if dollyDir == "zoomReset" then
      local FOV = readFloat(FOVAD) -- stored in degrees
      local FOVr = math.pi*FOV/180 -- convert to radians
      local objWidth = hypZ*2*math.tan(FOVr/2)
      local FOV2  = 68 -- default FOV
      local FOVr2 = math.pi*FOV2/180
      local hypZ2 = objWidth/(2*math.tan(FOVr2/2))-hypZ
      local dX = hypZ2*Xdiff/hypZ
      local dY = hypZ2*Ydiff/hypZ
      local dZ = hypZ2*Zdiff/hypZ
      writeFloat(FOVAD, FOV2)
      writeFloat(camXAD, camX-dX)
      writeFloat(camYAD, camY-dY)
      writeFloat(camZAD, camZ-dZ)
      return
    elseif dollyDir == "closer" then
      if hypZ>=26 then -- don't get too close to the origin
        local dX = flySpeed*Xdiff/hypZ
        local dY = flySpeed*Ydiff/hypZ
        local dZ = flySpeed*Zdiff/hypZ
        writeFloat(camXAD, camX+dX)
        writeFloat(camYAD, camY+dY)
        writeFloat(camZAD, camZ+dZ)
      end
      return
    elseif dollyDir == "farther" then
      local dX = flySpeed*Xdiff/hypZ
      local dY = flySpeed*Ydiff/hypZ
      local dZ = flySpeed*Zdiff/hypZ
      writeFloat(camXAD, camX-dX)
      writeFloat(camYAD, camY-dY)
      writeFloat(camZAD, camZ-dZ)
      return
    end
    local FOV  = readFloat(FOVAD) -- stored in degrees
    local FOVr = math.pi*FOV/180 -- convert to radians
    local dollySpeed = flySpeed*(1-FOV/180)^2
    local objWidth = hypZ*2*math.tan(FOVr/2)
    if dollyDir == "zoomIn" then
      FOVr = 2*math.atan(objWidth/(2*(hypZ+dollySpeed)))
      FOV  = 180*FOVr/math.pi -- convert back to degrees
      if FOV >=1.2 then
        local dX = dollySpeed*Xdiff/hypZ
        local dY = dollySpeed*Ydiff/hypZ
        local dZ = dollySpeed*Zdiff/hypZ
        writeFloat(FOVAD, FOV)
        writeFloat(camXAD, camX-dX)
        writeFloat(camYAD, camY-dY)
        writeFloat(camZAD, camZ-dZ)
      end
    elseif dollyDir == "zoomOut" then
      FOVr = 2*math.atan(objWidth/(2*(hypZ-dollySpeed)))
      FOV  = 180*FOVr/math.pi -- convert back to degrees
      if FOV <= 169 then
        local dX = dollySpeed*Xdiff/hypZ
        local dY = dollySpeed*Ydiff/hypZ
        local dZ = dollySpeed*Zdiff/hypZ
        writeFloat(FOVAD, FOV)
        writeFloat(camXAD, camX+dX)
        writeFloat(camYAD, camY+dY)
        writeFloat(camZAD, camZ+dZ)
      end
    else return
    end
  end

  local function zoomIn()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local FOV = readFloat(FOVAD)
    writeFloat(FOVAD, FOV+FOVSpeed)
  end

  local function zoomOut()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local FOV = readFloat(FOVAD)
    writeFloat(FOVAD, FOV-FOVSpeed)
  end

  local function rollLeft()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local roll = readFloat(rollAD)
    writeFloat(rollAD, roll+rollSpeed)
  end

  local function rollRight()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    local roll = readFloat(rollAD)
    writeFloat(rollAD, roll-rollSpeed)
  end

  local function rollReset()
    if getOpenedProcessID()~=getForegroundProcess() then return end
    writeFloat(rollAD, 0)
  end

  local function moveForward() move("forward") end
  local function moveBackward() move("backward") end
  local function moveLeft() move("left") end
  local function moveRight() move("right") end
  local function moveUp() move("up") end
  local function moveDown() move("down") end
  local function panUp() orbit("panUp") end
  local function panDown() orbit("panDown") end
  local function panLeft() orbit("panLeft") end
  local function panRight() orbit("panRight") end
  local function orbitUp() orbit("up") end
  local function orbitDown() orbit("down") end
  local function orbitLeft() orbit("left") end
  local function orbitRight() orbit("right") end
  local function dollyCloser() dolly("closer") end
  local function dollyFarther() dolly("farther") end
  local function dollyZoomIn() dolly("zoomIn") end
  local function dollyZoomOut() dolly("zoomOut") end
  local function dollyZoomReset() dolly("zoomReset") end

  -- CREATE HOTKEYS
  camHotkeys = {
    createHotkey(toggleFreecam, VK_NEXT), -- leave at pos 1
    createHotkey(moveForward, VK_NUMPAD8),
    createHotkey(moveBackward, VK_NUMPAD5),
    createHotkey(moveLeft, VK_NUMPAD4),
    createHotkey(moveRight, VK_NUMPAD6),
    createHotkey(moveUp, VK_NUMPAD9),
    createHotkey(moveDown, VK_NUMPAD7),
    createHotkey(panUp, VK_ADD, VK_NUMPAD8),
    createHotkey(panDown, VK_ADD, VK_NUMPAD5),
    createHotkey(panLeft, VK_ADD, VK_NUMPAD4),
    createHotkey(panRight, VK_ADD, VK_NUMPAD6),
    createHotkey(rollLeft, VK_ADD, VK_NUMPAD3),
    createHotkey(rollRight, VK_ADD, VK_NUMPAD1),
    createHotkey(rollReset, VK_ADD, VK_NUMPAD2),
    createHotkey(zoomIn, VK_ADD, VK_NUMPAD7),
    createHotkey(zoomOut, VK_ADD, VK_NUMPAD9),
    createHotkey(orbitUp, VK_RETURN, VK_NUMPAD5),
    createHotkey(orbitDown, VK_RETURN, VK_NUMPAD8),
    createHotkey(orbitLeft, VK_RETURN, VK_NUMPAD6),
    createHotkey(orbitRight, VK_RETURN, VK_NUMPAD4),
    createHotkey(dollyCloser, VK_RETURN, VK_NUMPAD9),
    createHotkey(dollyFarther, VK_RETURN, VK_NUMPAD7),
    createHotkey(dollyZoomIn, VK_RETURN, VK_NUMPAD3),
    createHotkey(dollyZoomOut, VK_RETURN, VK_NUMPAD1),
    createHotkey(dollyZoomReset, VK_RETURN, VK_NUMPAD2)
  }
  for i,v in ipairs(camHotkeys) do
    v.DelayBetweenActivate = i == 1 and 1000 or 10
  end

  sender.destroy()
end

{$asm}
[DISABLE]

cameraAOB:
  db 8B 03 57 8B CB

unregistersymbol(cameraAOB)
dealloc(newmem)

{$lua}
if camCheat ~= nil then
  for i=0,9,1 do
    if i ~= 0 then camCheat[i].setHotkey.destroy() end
    camCheat[i].getHotkey.destroy()
  end
  camCheat = nil
end
if camHotkeys ~= nil then
  for i,v in ipairs(camHotkeys) do v.destroy() end
  camHotkeys = nil
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 All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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