From b1a860ff849475321135beede276d3b7e35e9ce0 Mon Sep 17 00:00:00 2001 From: Karliky Date: Thu, 30 Apr 2020 11:08:14 +0200 Subject: [PATCH 1/8] with angle wip --- src/core/domain/disableViewMatrixUpdate.js | 5 +- src/core/domain/enableViewMatrixUpdate.js | 5 +- src/core/domain/getCameraData.js | 13 +++- src/core/domain/setCameraView.js | 20 ++++- src/core/logic/patterns.js | 16 +++- src/core/manager.js | 4 +- src/index.ejs | 4 + src/renderer/components/keyboard.vue | 76 +++++++++++++++++-- .../components/sections/cinematicBuilder.vue | 2 + 9 files changed, 123 insertions(+), 22 deletions(-) diff --git a/src/core/domain/disableViewMatrixUpdate.js b/src/core/domain/disableViewMatrixUpdate.js index 67d0707..34d7131 100644 --- a/src/core/domain/disableViewMatrixUpdate.js +++ b/src/core/domain/disableViewMatrixUpdate.js @@ -1,10 +1,7 @@ function disableViewMatrixUpdate(Game, Memory, Offsets) { return (ViewMatrixInstructionsPointer) => { - Memory.writeData(ViewMatrixInstructionsPointer, - Offsets[Game.client].cameraViewMatrix.version[Game.build].fix, - Offsets[Game.client].cameraViewMatrix.version[Game.build].fix.byteLength, - ); + }; } diff --git a/src/core/domain/enableViewMatrixUpdate.js b/src/core/domain/enableViewMatrixUpdate.js index 4e0713e..cb212f4 100644 --- a/src/core/domain/enableViewMatrixUpdate.js +++ b/src/core/domain/enableViewMatrixUpdate.js @@ -1,10 +1,7 @@ function enableViewMatrixUpdate(Game, Memory, Offsets) { return (ViewMatrixInstructionsPointer) => { - Memory.writeData(ViewMatrixInstructionsPointer, - Offsets[Game.client].cameraViewMatrix.version[Game.build].pattern, - Offsets[Game.client].cameraViewMatrix.version[Game.build].pattern.byteLength, - ); + }; } diff --git a/src/core/domain/getCameraData.js b/src/core/domain/getCameraData.js index c4223c2..a87b2e7 100644 --- a/src/core/domain/getCameraData.js +++ b/src/core/domain/getCameraData.js @@ -8,10 +8,15 @@ const clonedeep = require('lodash.clonedeep'); const cameraBufferSize = 0x48; const cameraBuffer = new Buffer(cameraBufferSize); -function GetCameraData(Memory) { +const cameraRotBufferSize = 0xC; +const cameraRotBuffer = new Buffer(cameraRotBufferSize); + +function GetCameraData(Offsets, Game, Memory) { return (Pointer) => { const camera = getCameraStruct(); + const rotationPtr = Offsets[Game.client].CameraRot; Memory.readData(Pointer, cameraBuffer, cameraBufferSize); + Memory.readData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBufferSize); camera.position.x = cameraBuffer.readFloatLE(0x8); camera.position.y = cameraBuffer.readFloatLE(0xC); @@ -44,6 +49,12 @@ function GetCameraData(Memory) { camera.roll.y = camera.viewMatrix[2][1]; camera.roll.z = camera.viewMatrix[2][2]; + camera.CameraRot = { + x: cameraRotBuffer.readFloatLE(0), + y: cameraRotBuffer.readFloatLE(4), + z: cameraRotBuffer.readFloatLE(8), + }; + camera.Fov = cameraBuffer.readFloatLE(0x38); camera.NearClip = cameraBuffer.readFloatLE(0x3C); camera.FarClip = cameraBuffer.readFloatLE(0x40); diff --git a/src/core/domain/setCameraView.js b/src/core/domain/setCameraView.js index f805d48..b2534dd 100644 --- a/src/core/domain/setCameraView.js +++ b/src/core/domain/setCameraView.js @@ -1,6 +1,7 @@ -function SetCameraView(Game, Memory, SetPosition) { +function SetCameraView(Game, Memory, Offsets, SetPosition) { const viewMatrixBuffer = new Buffer(0x24); + const cameraRotBuffer = new Buffer(0xC); return (CameraStruct, view) => { const { x, y, z } = view; const matrix = [ @@ -8,6 +9,18 @@ function SetCameraView(Game, Memory, SetPosition) { [view.viewMatrix10, view.viewMatrix11, view.viewMatrix12], [view.viewMatrix20, view.viewMatrix21, view.viewMatrix22], ]; + + + const rotation = view.rotation; + const angle = rotation * 180 / Math.PI; + const clamped = angle + Math.ceil(-angle / 360) * 360; + const finalRotation = clamped * Math.PI / 180; + + //console.log(`{ rotation: ${view.rotation} }`, finalRotation); + + cameraRotBuffer.writeFloatLE(view.CameraRotx, 0); + cameraRotBuffer.writeFloatLE(view.rotation, 4); + cameraRotBuffer.writeFloatLE(view.CameraRotz, 8); setViewMatrix(CameraStruct, x, y, z, matrix); }; function setViewMatrix(CameraStruct, x, y, z, viewMatrix) { @@ -23,7 +36,10 @@ function SetCameraView(Game, Memory, SetPosition) { viewMatrixBuffer.writeFloatLE(viewMatrix[2][0], 0x18); viewMatrixBuffer.writeFloatLE(viewMatrix[2][1], 0x1C); viewMatrixBuffer.writeFloatLE(viewMatrix[2][2], 0x20); - Memory.writeData(Pointer + 0x14, viewMatrixBuffer, viewMatrixBuffer.byteLength); + // Memory.writeData(Pointer + 0x14, viewMatrixBuffer, viewMatrixBuffer.byteLength); + + const rotationPtr = Offsets[Game.client].CameraRot; + Memory.writeData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBuffer.byteLength); if (Game.client === 'vanilla' || Game.client === 'alpha') { SetPosition(Pointer, x, y, z); } else { diff --git a/src/core/logic/patterns.js b/src/core/logic/patterns.js index af13501..a4a3f33 100644 --- a/src/core/logic/patterns.js +++ b/src/core/logic/patterns.js @@ -82,12 +82,19 @@ export const alpha = { } } }, + CameraRot: 0xD8, cameraViewMatrix: { version: { - ['0.5.3']: { - pattern: new Buffer([0x8D, 0x8D, 0x70, 0xFF, 0xFF, 0xFF, 0xE8, 0x34, 0x5E, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0xF3, 0xA5]), - fix: new Buffer([0x8D, 0x8D, 0x70, 0xFF, 0xFF, 0xFF, 0xE8, 0x34, 0x5E, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0x90, 0x90]) - }, + ['0.5.3']: [ + { + pattern: new Buffer([0xD8, 0x86, 0xE4, 0x00, 0x00, 0x00, 0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD8, 0x86, 0xE4, 0x00, 0x00, 0x00, 0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + pattern: new Buffer([0x89, 0x9E, 0x64, 0x01, 0x00, 0x00, 0x89, 0x8E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0x89, 0x9E, 0x64, 0x01, 0x00, 0x00, 0x89, 0x8E, 0xD0, 0x00, 0x00, 0x00]) + } + ], ['0.8.0']: { pattern: new Buffer([0xE8, 0x94, 0x80, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0xF3, 0xA5]), fix: new Buffer([0xE8, 0x94, 0x80, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0x90, 0x90]) @@ -129,6 +136,7 @@ export const wlk = { CameraValuesPointer: 0x00ACE4A8, Collision: 0x48, Speed: 0x44, + CameraRot: 0x118, cameraViewMatrix: { version: { ['3.3.5a']: { diff --git a/src/core/manager.js b/src/core/manager.js index 0bf20c6..8f3bd47 100644 --- a/src/core/manager.js +++ b/src/core/manager.js @@ -25,7 +25,7 @@ module.exports = (process, Module, Memory, window, Offsets) => { const EnableViewMatrixUpdate = createEnableViewMatrixUpdate(Game, Memory, Offsets); const DisableViewMatrixUpdate = createDisableViewMatrixUpdate(Game, Memory, Offsets); const GetCametaPtr = createGetCametaPtr(Game, Memory, Module, Offsets); - const GetCameraData = createGetCameraData(Memory); + const GetCameraData = createGetCameraData(Offsets, Game, Memory); const SetPosition = createSetPosition(Game, Memory); const EnableSpectate = createEnableSpectate(Game, Memory, Offsets, Module, GetCameraData, SetPosition); const DisableSpectate = createDisableSpectate(Game, Memory, Offsets, Module); @@ -39,7 +39,7 @@ module.exports = (process, Module, Memory, window, Offsets) => { SetPosition, SetSpeed, ); - const SetCameraView = createSetCameraView(Game, Memory, SetPosition); + const SetCameraView = createSetCameraView(Game, Memory, Offsets, SetPosition); const camera = createCamera( GetCametaPtr, diff --git a/src/index.ejs b/src/index.ejs index 46b6e4e..e5ec3eb 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -14,6 +14,10 @@ + + + + diff --git a/src/renderer/components/keyboard.vue b/src/renderer/components/keyboard.vue index 5cf8ee1..090ba72 100644 --- a/src/renderer/components/keyboard.vue +++ b/src/renderer/components/keyboard.vue @@ -36,9 +36,13 @@ viewMatrix20: firstStep.viewMatrix[2][0], viewMatrix21: firstStep.viewMatrix[2][1], viewMatrix22: firstStep.viewMatrix[2][2], + CameraRotx: firstStep.CameraRot.x, + CameraRoty: firstStep.CameraRot.y, + CameraRotz: firstStep.CameraRot.z, + rotation: firstStep.CameraRot.y, }; - - Camera.SetCameraView(cinematicValues); + + // Camera.SetCameraView(cinematicValues); const keyframes = cinematicSteps.map((step) => { return { @@ -54,13 +58,69 @@ viewMatrix20: step.viewMatrix[2][0], viewMatrix21: step.viewMatrix[2][1], viewMatrix22: step.viewMatrix[2][2], + CameraRotx: step.CameraRot.x, + CameraRoty: step.CameraRot.y, + CameraRotz: step.CameraRot.z, + rotation: step.CameraRot.y, }; }); const cinematicSpeed = Number(speed || 10); + console.log('# cinematicValues', cinematicValues); + + // gsap.registerPlugin(MotionPathPlugin); + // tween = gsap.to(cinematicValues, { + // duration: cinematicSpeed, + // ease: "none", + // onComplete: () => { + // if (shouldLoop) return playCinematic(cinematicSteps, speed, commit, shouldLoop, Camera); + // commit('setMode', 'SPECTATE'); + // tween = null; + // }, + // onUpdate: () => { + // console.log('# cinematicValues', cinematicValues.rotation); + // Camera.SetCameraView(cinematicValues); + // }, + // motionPath: { + // path: relativize(cinematicValues, keyframes, "rotation", true), + // relative: true + // } + // }); + // tween.play(); + + // converts the points into RELATIVE values, optionally making rotational values go in the shortest direction. + function relativize(start, points, rotationProperty, useRadians) { + let cur = start; + let cap = useRadians ? Math.PI * 2 : 360; + let result = []; + let p; + let i; + let point; + let rel; + let dif; + for (i = 0; i < points.length; i++) { + point = points[i]; + rel = {}; + for (p in point) { + rel[p] = point[p]; + if (p === rotationProperty) { + dif = rel[p] % cap; + if (dif !== dif % (cap / 2)) { + rel[p] = dif < 0 ? dif + cap : dif - cap; + } + } + } + result.push(rel); + cur = point; + } + return result; + } + + const path = relativize(cinematicValues, keyframes, "rotation", true); + console.log('# path', path); tween = TweenLite.to(cinematicValues, cinematicSpeed, { bezier: { - values: keyframes, + values: path, curviness: 0, type: 'soft', timeResolution: 0, @@ -75,7 +135,13 @@ commit('setMode', 'SPECTATE'); tween = null; }, - onUpdate: () => Camera.SetCameraView(cinematicValues) + onUpdate: () => { + const currentTime = tween.time(); + const totalTime = tween.totalProgress(); + console.log('# currentTime, totalTime', currentTime, totalTime); + //console.log('# cinematicValues', cinematicValues.rotation); + Camera.SetCameraView(cinematicValues); + } }); }; @@ -112,7 +178,7 @@ } } if (pressingKey(robot.KEY_F6)) store.dispatch('cleanWaypoints'); - }, 90); + }, 20); }, computed: { mode() { return this.$store.state.camera.mode; } diff --git a/src/renderer/components/sections/cinematicBuilder.vue b/src/renderer/components/sections/cinematicBuilder.vue index 0a37dfe..e0df11e 100644 --- a/src/renderer/components/sections/cinematicBuilder.vue +++ b/src/renderer/components/sections/cinematicBuilder.vue @@ -69,6 +69,7 @@ Pos x Pos y Pos z + Angle @@ -76,6 +77,7 @@ {{ cinematic.position.x }} {{ cinematic.position.y }} {{ cinematic.position.z }} + {{ cinematic.CameraRot.y }} From 77714a202aca8c1bda4d6d4d4ce4743a0883bd65 Mon Sep 17 00:00:00 2001 From: Karliky Date: Sat, 2 May 2020 12:57:13 +0200 Subject: [PATCH 2/8] add support for new versions based on angle movement --- package-lock.json | 7 +- package.json | 1 + src/core/domain/disableSpectate.js | 3 +- src/core/domain/disableViewMatrixUpdate.js | 8 +- src/core/domain/enableKeyboardControls.js | 18 +- src/core/domain/enableSpectate.js | 3 +- src/core/domain/enableViewMatrixUpdate.js | 8 +- src/core/domain/getCameraData.js | 45 +-- src/core/domain/getCameraPtr.js | 46 ++-- src/core/domain/setCameraView.js | 41 +-- src/core/initialize.js | 4 +- src/core/logic/camera.js | 5 +- src/core/logic/patterns.js | 260 ++++++++++++++---- src/core/manager.js | 4 +- src/index.ejs | 4 - src/renderer/components/keyboard.vue | 96 +------ .../components/sections/cinematicBuilder.vue | 17 +- src/renderer/store/modules/camera.js | 3 + 18 files changed, 307 insertions(+), 266 deletions(-) diff --git a/package-lock.json b/package-lock.json index f50201c..d150dfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bugcraft-studio", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3124,6 +3124,11 @@ "array-find-index": "1.0.2" } }, + "curve-interpolator": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/curve-interpolator/-/curve-interpolator-2.0.6.tgz", + "integrity": "sha512-YYq1bVGbqhdM3u9Kz9y3zTWb/tR5NztKVSh2lFll2xg6rjC9Sh1FVt66Aul1ZJcw4vtWdeKO12xD9a70vLWh1A==" + }, "cyclist": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", diff --git a/package.json b/package.json index bc138be..a0e90f3 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "dependencies": { "axios": "^0.16.1", "bulma": "0.8.2", + "curve-interpolator": "^2.0.6", "gsap": "^3.0.2", "lodash.clonedeep": "^4.5.0", "robot-js": "git@github.com:Robot/robot-js.git#dev", diff --git a/src/core/domain/disableSpectate.js b/src/core/domain/disableSpectate.js index 7f6f607..bcbdd0c 100644 --- a/src/core/domain/disableSpectate.js +++ b/src/core/domain/disableSpectate.js @@ -7,7 +7,8 @@ function disableSpectate(Game, Memory, Offsets, Module) { SpectatePointer, } = CameraStruct; if (Game.client === 'vanilla' || Game.client === 'alpha') { - Memory.writeData(InstructionPointer, Offsets[Game.client].camera.pattern, Offsets[Game.client].camera.pattern.byteLength); + const fixPositionPattern = Offsets[Game.client].camera.position[Game.build].pattern; + Memory.writeData(InstructionPointer, fixPositionPattern, fixPositionPattern.byteLength); } else if (Game.client === 'ctl') { Memory.writeData(Module + Offsets[Game.client].SpectatePointer, Offsets[Game.client].DisableSpectate, Offsets[Game.client].DisableSpectate.byteLength); Memory.writeData(Pointer + Offsets[Game.client].EnableCorrectKeyboardControls, Offsets[Game.client].DisableSpectateOnCam, Offsets[Game.client].DisableSpectateOnCam.byteLength); diff --git a/src/core/domain/disableViewMatrixUpdate.js b/src/core/domain/disableViewMatrixUpdate.js index 34d7131..22ba696 100644 --- a/src/core/domain/disableViewMatrixUpdate.js +++ b/src/core/domain/disableViewMatrixUpdate.js @@ -1,7 +1,11 @@ function disableViewMatrixUpdate(Game, Memory, Offsets) { - return (ViewMatrixInstructionsPointer) => { - + return () => { + if (Game.client !== 'alpha') return; + const patterns = Offsets[Game.client].cameraViewMatrix.version[Game.build]; + patterns.forEach((instruction) => { + Memory.writeData(instruction.offset, instruction.fix, instruction.fix.byteLength); + }); }; } diff --git a/src/core/domain/enableKeyboardControls.js b/src/core/domain/enableKeyboardControls.js index c555434..3d5309f 100644 --- a/src/core/domain/enableKeyboardControls.js +++ b/src/core/domain/enableKeyboardControls.js @@ -2,7 +2,7 @@ const Robot = require('robot-js'); const Keyboard = Robot.Keyboard; const Mouse = Robot.Mouse; -function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, GetCameraData, SetPosition, SetSpeed) { +function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, GetCameraData, SetPosition, SetSpeed, Offsets, Memory) { return (CameraStruct, speed) => { const { Pointer, @@ -16,6 +16,10 @@ function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, Ge return 1; } + const enableCameraFacingBuffer = new Buffer([0xD6, 0x00, 0x00, 0x00, 0x61, 0x0E, 0xC2, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); + const enableCameraFacingPtr = Offsets[Game.client].enableCameraFacing; + Memory.writeData(Pointer + enableCameraFacingPtr, enableCameraFacingBuffer, enableCameraFacingBuffer.byteLength); + EnableSpectate(CameraStruct, Pointer); EnableViewMatrixUpdate(ViewMatrixInstructionsPointer); return setInterval(() => { @@ -26,15 +30,15 @@ function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, Ge const camera = GetCameraData(Pointer); const state = Mouse.getState(); if (Keyboard.getState(Robot.KEY_W) || (state[Robot.BUTTON_LEFT] && state[Robot.BUTTON_RIGHT])) { - const x = camera.position.x + camera.yaw.x * speed; - const y = camera.position.y + camera.yaw.y * speed; - const z = camera.position.z + camera.yaw.z * speed; + const x = camera.position.x + camera.forward.x * speed; + const y = camera.position.y + camera.forward.y * speed; + const z = camera.position.z + camera.forward.z * speed; return SetPosition(Pointer, x, y, z); } if (Keyboard.getState(Robot.KEY_S)) { - const x = camera.position.x - camera.yaw.x * speed; - const y = camera.position.y - camera.yaw.y * speed; - const z = camera.position.z - camera.yaw.z * speed; + const x = camera.position.x - camera.forward.x * speed; + const y = camera.position.y - camera.forward.y * speed; + const z = camera.position.z - camera.forward.z * speed; return SetPosition(Pointer, x, y, z); } if (Keyboard.getState(Robot.KEY_SPACE)) { diff --git a/src/core/domain/enableSpectate.js b/src/core/domain/enableSpectate.js index 3e790ea..fc85383 100644 --- a/src/core/domain/enableSpectate.js +++ b/src/core/domain/enableSpectate.js @@ -8,7 +8,8 @@ function enableSpectateMode(Game, Memory, Offsets, Module, GetCameraData, SetPos CameraValuesPointer, } = CameraStruct; if (Game.client === 'vanilla' || Game.client === 'alpha') { - Memory.writeData(InstructionPointer, Offsets[Game.client].camera.fix, Offsets[Game.client].camera.fix.byteLength); + const fixPositionPattern = Offsets[Game.client].camera.position[Game.build].fix; + Memory.writeData(InstructionPointer, fixPositionPattern, fixPositionPattern.byteLength); } else if (Game.client === 'ctl') { const { position } = GetCameraData(Pointer); SetPosition(CameraValuesPointer, position.x, position.y, position.z); diff --git a/src/core/domain/enableViewMatrixUpdate.js b/src/core/domain/enableViewMatrixUpdate.js index cb212f4..835f240 100644 --- a/src/core/domain/enableViewMatrixUpdate.js +++ b/src/core/domain/enableViewMatrixUpdate.js @@ -1,7 +1,11 @@ function enableViewMatrixUpdate(Game, Memory, Offsets) { - return (ViewMatrixInstructionsPointer) => { - + return () => { + if (Game.client !== 'alpha') return; + const patterns = Offsets[Game.client].cameraViewMatrix.version[Game.build]; + patterns.forEach((instruction) => { + Memory.writeData(instruction.offset, instruction.pattern, instruction.pattern.byteLength); + }); }; } diff --git a/src/core/domain/getCameraData.js b/src/core/domain/getCameraData.js index a87b2e7..c3f843a 100644 --- a/src/core/domain/getCameraData.js +++ b/src/core/domain/getCameraData.js @@ -26,34 +26,16 @@ function GetCameraData(Offsets, Game, Memory) { camera.viewMatrix[0][1] = cameraBuffer.readFloatLE(0x18); camera.viewMatrix[0][2] = cameraBuffer.readFloatLE(0x1C); - camera.viewMatrix[1][0] = cameraBuffer.readFloatLE(0x20); - camera.viewMatrix[1][1] = cameraBuffer.readFloatLE(0x24); - camera.viewMatrix[1][2] = cameraBuffer.readFloatLE(0x28); - - camera.viewMatrix[2][0] = cameraBuffer.readFloatLE(0x2C); - camera.viewMatrix[2][1] = cameraBuffer.readFloatLE(0x30); - camera.viewMatrix[2][2] = cameraBuffer.readFloatLE(0x34); - /** * First row of the View Matrix is the forward vector */ - camera.yaw.x = camera.viewMatrix[0][0]; - camera.yaw.y = camera.viewMatrix[0][1]; - camera.yaw.z = camera.viewMatrix[0][2]; - - camera.pitch.x = camera.viewMatrix[1][0]; - camera.pitch.y = camera.viewMatrix[1][1]; - camera.pitch.z = camera.viewMatrix[1][2]; + camera.forward.x = camera.viewMatrix[0][0]; + camera.forward.y = camera.viewMatrix[0][1]; + camera.forward.z = camera.viewMatrix[0][2]; - camera.roll.x = camera.viewMatrix[2][0]; - camera.roll.y = camera.viewMatrix[2][1]; - camera.roll.z = camera.viewMatrix[2][2]; - - camera.CameraRot = { - x: cameraRotBuffer.readFloatLE(0), - y: cameraRotBuffer.readFloatLE(4), - z: cameraRotBuffer.readFloatLE(8), - }; + camera.yaw = cameraRotBuffer.readFloatLE(0); + camera.pitch = cameraRotBuffer.readFloatLE(4); + camera.roll = cameraRotBuffer.readFloatLE(8); camera.Fov = cameraBuffer.readFloatLE(0x38); camera.NearClip = cameraBuffer.readFloatLE(0x3C); @@ -75,21 +57,14 @@ function getCameraStruct() { y: 0, z: 0, }, - yaw: { - x: 0, - y: 0, - z: 0, - }, - pitch: { - x: 0, - y: 0, - z: 0, - }, - roll: { + forward: { x: 0, y: 0, z: 0, }, + yaw: 0, + pitch: 0, + roll: 0, Fov: 0, NearClip: 0, FarClip: 0, diff --git a/src/core/domain/getCameraPtr.js b/src/core/domain/getCameraPtr.js index fa89e6d..7779bda 100644 --- a/src/core/domain/getCameraPtr.js +++ b/src/core/domain/getCameraPtr.js @@ -1,15 +1,10 @@ function GetCameraPtr(Game, memory, Module, offsets) { return () => { - const viewMatrixFixPtr = offsets[Game.client].cameraViewMatrix.version[Game.build].pattern; - const ViewMatrixInstructionsPointer = memory.find(viewMatrixFixPtr.toString('hex'), 0, -1, 1, '-x')[0]; - - if (Game.client === 'vanilla' || Game.client === 'alpha') { - const InstructionPointer = memory.find(offsets[Game.client].camera.pattern.toString('hex'), 0, -1, 1, '-x')[0]; - + if (Game.client === 'alpha' || Game.client === 'vanilla') { + const InstructionPointer = memory.find(offsets[Game.client].camera.position[Game.build].pattern.toString('hex'), 0, -1, 1, '-x')[0]; const instructionBase = offsets[Game.client].camera.base; const ptrFix = offsets[Game.client].camera.base.version[Game.build].ptrFix; - let Pointer = memory.resolvePtrBySetOfInstruction(instructionBase, ptrFix); - + let Pointer = memory.resolvePtrBySetOfInstruction(instructionBase, Game.build, ptrFix); /** * Move this somewhere */ @@ -21,51 +16,48 @@ function GetCameraPtr(Game, memory, Module, offsets) { throw new Error('Can\'t find camera'); } - console.log('# Camera PTR found at', `0x${Pointer.toString(16)}`); + console.log('# Camera PTR found at', `0x${(Pointer || 0).toString(16)}`); return { Pointer, InstructionPointer, - ViewMatrixInstructionsPointer, - SpectatePointer: null, CameraValuesPointer: null, }; } else if (offsets[Game.client].base) { - const viewMatrixFixPtr = offsets[Game.client].cameraViewMatrix.version[Game.build].pattern; - const ViewMatrixInstructionsPointer = memory.find(viewMatrixFixPtr.toString('hex'), 0, -1, 1, '-x')[0]; const SpectatePointerFinder = offsets[Game.client].base.version[Game.build].SpectatePointer; const SpectatePointer = Array.isArray(SpectatePointerFinder) ? memory.readMultiLevelPtr(SpectatePointerFinder) : SpectatePointerFinder; const Pointer = memory.readMultiLevelPtr(offsets[Game.client].base.version[Game.build].CameraPointer); const CameraValuesPointer = Module + offsets[Game.client].base.version[Game.build].CameraValuesPointer; - + console.log('# Camera SpectatePointer found at', `0x${SpectatePointer.toString(16)} - Camera spectate values at: 0x${CameraValuesPointer.toString(16)} - - Camera values at: 0x${Pointer.toString(16)} - - ViewMatrixInstructionsPointer: 0x${ViewMatrixInstructionsPointer.toString(16)}`); + - Camera values at: 0x${Pointer.toString(16)}`); return { Pointer, InstructionPointer: null, - ViewMatrixInstructionsPointer, - + SpectatePointer, CameraValuesPointer, }; } else { const SpectatePointerFinder = offsets[Game.client].SpectatePointer; const SpectatePointer = Array.isArray(SpectatePointerFinder) ? memory.readMultiLevelPtr(SpectatePointerFinder) : SpectatePointerFinder; - const Pointer = memory.readMultiLevelPtr(offsets[Game.client].CameraPointer, true); - const CameraValuesPointer = offsets[Game.client].CameraValuesPointer; - - console.log('# Camera SpectatePointer found at', `0x${SpectatePointer.toString(16)} - - Camera spectate values at: 0x${CameraValuesPointer.toString(16)} - - Camera values at: 0x${Pointer.toString(16)} - - ViewMatrixInstructionsPointer: 0x${ViewMatrixInstructionsPointer.toString(16)}`); + const Pointer = memory.readMultiLevelPtr(offsets[Game.client].CameraPointer); + let CameraValuesPointer; + if (offsets[Game.client].CameraValuesPointer.module) { + CameraValuesPointer = Module + offsets[Game.client].CameraValuesPointer.offset; + } else { + CameraValuesPointer = offsets[Game.client].CameraValuesPointer; + } + + console.log('# Camera SpectatePointer found at', `0x${(SpectatePointer || 0).toString(16)} + - Camera spectate values at: 0x${(CameraValuesPointer || 0).toString(16)} + - Camera values at: 0x${(Pointer || 0).toString(16)}`); return { Pointer, InstructionPointer: null, - ViewMatrixInstructionsPointer, - + SpectatePointer, CameraValuesPointer, }; diff --git a/src/core/domain/setCameraView.js b/src/core/domain/setCameraView.js index b2534dd..2d8d6aa 100644 --- a/src/core/domain/setCameraView.js +++ b/src/core/domain/setCameraView.js @@ -1,48 +1,21 @@ function SetCameraView(Game, Memory, Offsets, SetPosition) { - const viewMatrixBuffer = new Buffer(0x24); const cameraRotBuffer = new Buffer(0xC); return (CameraStruct, view) => { const { x, y, z } = view; - const matrix = [ - [view.viewMatrix00, view.viewMatrix01, view.viewMatrix02], - [view.viewMatrix10, view.viewMatrix11, view.viewMatrix12], - [view.viewMatrix20, view.viewMatrix21, view.viewMatrix22], - ]; - - - const rotation = view.rotation; - const angle = rotation * 180 / Math.PI; - const clamped = angle + Math.ceil(-angle / 360) * 360; - const finalRotation = clamped * Math.PI / 180; - - //console.log(`{ rotation: ${view.rotation} }`, finalRotation); - - cameraRotBuffer.writeFloatLE(view.CameraRotx, 0); - cameraRotBuffer.writeFloatLE(view.rotation, 4); - cameraRotBuffer.writeFloatLE(view.CameraRotz, 8); - setViewMatrix(CameraStruct, x, y, z, matrix); + cameraRotBuffer.writeFloatLE(view.yaw, 0); + cameraRotBuffer.writeFloatLE(view.pitch, 4); + cameraRotBuffer.writeFloatLE(view.roll, 8); + setViewMatrix(CameraStruct, x, y, z); }; - function setViewMatrix(CameraStruct, x, y, z, viewMatrix) { + function setViewMatrix(CameraStruct, x, y, z) { const { Pointer, CameraValuesPointer } = CameraStruct; - viewMatrixBuffer.writeFloatLE(viewMatrix[0][0], 0x0); - viewMatrixBuffer.writeFloatLE(viewMatrix[0][1], 0x4); - viewMatrixBuffer.writeFloatLE(viewMatrix[0][2], 0x8); - - viewMatrixBuffer.writeFloatLE(viewMatrix[1][0], 0xC); - viewMatrixBuffer.writeFloatLE(viewMatrix[1][1], 0x10); - viewMatrixBuffer.writeFloatLE(viewMatrix[1][2], 0x14); - - viewMatrixBuffer.writeFloatLE(viewMatrix[2][0], 0x18); - viewMatrixBuffer.writeFloatLE(viewMatrix[2][1], 0x1C); - viewMatrixBuffer.writeFloatLE(viewMatrix[2][2], 0x20); - // Memory.writeData(Pointer + 0x14, viewMatrixBuffer, viewMatrixBuffer.byteLength); - const rotationPtr = Offsets[Game.client].CameraRot; - Memory.writeData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBuffer.byteLength); if (Game.client === 'vanilla' || Game.client === 'alpha') { + Memory.writeData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBuffer.byteLength); SetPosition(Pointer, x, y, z); } else { + Memory.writeData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBuffer.byteLength); SetPosition(CameraValuesPointer, x, y, z); } } diff --git a/src/core/initialize.js b/src/core/initialize.js index a78fd6e..b90df85 100644 --- a/src/core/initialize.js +++ b/src/core/initialize.js @@ -33,13 +33,13 @@ function initialize(cb) { const findPattern = pattern => memory.find(pattern, 0, -1, 1, '-x'); - function resolvePtrBySetOfInstruction(patternBase, ptrFix) { + function resolvePtrBySetOfInstruction(patternBase, build, ptrFix) { ptrFix = ptrFix || 0; const hexPattern = patternBase.pattern.toString('hex'); let patternPtr = findPattern(hexPattern); if (patternPtr.length === 0) return; patternPtr = patternPtr.shift(); - patternPtr += patternBase.patternFix; + patternPtr += patternBase.patternFix[build]; memory.readData(patternPtr, ptrContainer, ptrContainer.byteLength); const ptr = reverseArrayOfBytesAsNumber(ptrContainer); if (Array.isArray(ptrFix)) { diff --git a/src/core/logic/camera.js b/src/core/logic/camera.js index 84cf6cf..c02a548 100644 --- a/src/core/logic/camera.js +++ b/src/core/logic/camera.js @@ -15,7 +15,7 @@ module.exports = ( SetCameraView, SetCollision ) => { - return () => { + return (Offsets, Game, Memory) => { const { /** * For custom spectate controls @@ -48,6 +48,9 @@ module.exports = ( }; const disableSpectatorMode = () => { + const enableCameraFacingBuffer = new Buffer([0xD7, 0x42, 0x00, 0x00, 0x61, 0x0E, 0xC2, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00]); + const enableCameraFacingPtr = Offsets[Game.client].enableCameraFacing; + Memory.writeData(Pointer + enableCameraFacingPtr, enableCameraFacingBuffer, enableCameraFacingBuffer.byteLength); clearInterval(spectatorInterval); }; diff --git a/src/core/logic/patterns.js b/src/core/logic/patterns.js index a4a3f33..a8338eb 100644 --- a/src/core/logic/patterns.js +++ b/src/core/logic/patterns.js @@ -11,67 +11,55 @@ export const getVersion = (Memory) => { console.log('# WoW Build Found', buildFound); if (buildFound === '3368') return { client: 'alpha', build: '0.5.3' }; if (buildFound === '3734') return { client: 'alpha', build: '0.8.0' }; + if (buildFound === '4125') return { client: 'vanilla', build: '1.1.2' }; if (buildFound === '4735') return { client: 'vanilla', build: '1.8.0' }; if (buildFound === '5875') return { client: 'vanilla', build: '1.12.0' }; if (buildFound === '8606') return { client: 'tbc', build: '2.4.3' }; if (buildFound === '12340') return { client: 'wlk', build: '3.3.5a' }; if (buildFound === '15595') return { client: 'ctl', build: '4.3.4' }; + if (buildFound === '18414') return { client: 'mop', build: '5.4.8' }; if (buildFound === '20779') return { client: 'draenor', build: '6.2.3' }; if (buildFound === '24742') return { client: 'legion', build: '7.2.5' }; if (buildFound === '26972') return { client: 'legion', build: '7.3.5' }; }; -export const vanilla = { +export const alpha = { camera: { - pattern: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x89, 0x11, 0x8B, 0x50, 0x04, 0x89, 0x51, 0x04, 0x8B, 0x40, 0x08, 0x89, 0x41, 0x08]), - fix: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x90, 0x90, 0x8B, 0x50, 0x04, 0x90, 0x90, 0x90, 0x8B, 0x40, 0x08, 0x90, 0x90, 0x90]), - base: { - pattern: new Buffer([0x8B ,0x11 ,0x8D ,0x45 ,0xF4 ,0x50 ,0xFF ,0x52 - ,0x04 ,0x8B ,0x4D ,0xF4 ,0x8B ,0x55 ,0xF8 ,0x8B ,0x45 ,0xFC ,0x89 - ,0x0E ,0x89 ,0x56 ,0x04 ,0x89 ,0x46 ,0x08 ,0x5E ,0x8B ,0xE5 ,0x5D]), - patternFix: -0xD, - version: { - ['1.8.0']: { - ptrFix: [0x6570, 0] - }, - ['1.12.0']: { - ptrFix: [0x65B8, 0] - } - } - } - }, - cameraViewMatrix: { - version: { - ['1.8.0']: { - pattern: new Buffer([0xE8, 0x5F, 0xF1, 0xE6, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x60, 0xFF, 0xFF, 0xFF, 0xF3, 0xA5]), - fix: new Buffer([0xE8, 0x5F, 0xF1, 0xE6, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x60, 0xFF, 0xFF, 0xFF, 0x90, 0x90]) + position: { + ['0.5.3']: { + pattern: new Buffer([0x89, 0x02, 0xD9, 0x5D, 0xF8, 0x8B, + 0x4D, 0xF8, 0xDD, 0xD8, 0x89, 0x4A, 0x04, 0xDD, 0xD8, + 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, + 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, + 0xD8, 0x65, 0x08, 0x89, 0x42, 0x08]), + fix: new Buffer([0x90, 0x90, 0xD9, 0x5D, 0xF8, 0x8B, + 0x4D, 0xF8, 0xDD, 0xD8, 0x90, 0x90, 0x90, 0xDD, 0xD8, + 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, + 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, + 0xD8, 0x65, 0x08, 0x90, 0x90, 0x90]), }, - ['1.12.0']: { - pattern: new Buffer([0xE8, 0x0F, 0x97, 0xE3, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x60, 0xFF, 0xFF, 0xFF, 0xF3, 0xA5]), - fix: new Buffer([0xE8, 0x0F, 0x97, 0xE3, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x60, 0xFF, 0xFF, 0xFF, 0x90, 0x90]) + ['0.8.0']: { + pattern: new Buffer([0x89, 0x02, 0xD9, 0x5D, 0xF8, 0x8B, + 0x4D, 0xF8, 0xDD, 0xD8, 0x89, 0x4A, 0x04, 0xDD, 0xD8, + 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, + 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, + 0xD8, 0x65, 0x08, 0x89, 0x42, 0x08]), + fix: new Buffer([0x90, 0x90, 0xD9, 0x5D, 0xF8, 0x8B, + 0x4D, 0xF8, 0xDD, 0xD8, 0x90, 0x90, 0x90, 0xDD, 0xD8, + 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, + 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, + 0xD8, 0x65, 0x08, 0x90, 0x90, 0x90]), } - } - } -}; - -export const alpha = { - camera: { - pattern: new Buffer([0x89, 0x02, 0xD9, 0x5D, 0xF8, 0x8B, - 0x4D, 0xF8, 0xDD, 0xD8, 0x89, 0x4A, 0x04, 0xDD, 0xD8, - 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, - 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, - 0xD8, 0x65, 0x08, 0x89, 0x42, 0x08]), - fix: new Buffer([0x90, 0x90, 0xD9, 0x5D, 0xF8, 0x8B, - 0x4D, 0xF8, 0xDD, 0xD8, 0x90, 0x90, 0x90, 0xDD, 0xD8, - 0xD9, 0x45, 0xF0, 0xD8, 0x65, 0xE4, 0xD9, 0x5D, 0xFC, - 0xD9, 0x86, 0xD4, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xFC, - 0xD8, 0x65, 0x08, 0x90, 0x90, 0x90]), + }, base: { pattern: new Buffer([0xC6, 0x83, 0x88, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x7D, 0x0C, 0x8B, 0xC3, 0xC1, 0xE8, 0x10, 0x66, 0x89, 0x45, 0xFC, 0x66, 0xC7, 0x45, 0xFE, 0x6D, 0x6F, 0x8B, 0x4D, 0xFC, 0x89, 0x4B, 0x0C]), - patternFix: 0x22, + patternFix: { + ['0.5.3']: 0x22, + ['0.8.0']: 0x22, + }, version: { ['0.5.3']: { ptrFix: 0x3D4 @@ -82,37 +70,165 @@ export const alpha = { } } }, - CameraRot: 0xD8, + CameraRot: 0xDC, cameraViewMatrix: { version: { ['0.5.3']: [ + /** + * Yaw + */ { - pattern: new Buffer([0xD8, 0x86, 0xE4, 0x00, 0x00, 0x00, 0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), - fix: new Buffer([0xD8, 0x86, 0xE4, 0x00, 0x00, 0x00, 0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + offset: 0x0053D5BB, + pattern: new Buffer([0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) }, { - pattern: new Buffer([0x89, 0x9E, 0x64, 0x01, 0x00, 0x00, 0x89, 0x8E, 0xDC, 0x00, 0x00, 0x00]), - fix: new Buffer([0x89, 0x9E, 0x64, 0x01, 0x00, 0x00, 0x89, 0x8E, 0xD0, 0x00, 0x00, 0x00]) - } + offset: 0x0053E141, + pattern: new Buffer([0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0053C613, + pattern: new Buffer([0xD9, 0x99, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0053C643, + pattern: new Buffer([0xD9, 0x99, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + /** + * Pitch + */ + { + offset: 0x0053C5E2, + pattern: new Buffer([0xD9, 0x99, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0053D500, + pattern: new Buffer([0xD9, 0x9E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0053E11A, + pattern: new Buffer([0xD9, 0x9E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0053D51D, + pattern: new Buffer([0x89, 0x8E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0x89, 0x8E, 0xD0, 0x00, 0x00, 0x00]) + }, ], - ['0.8.0']: { - pattern: new Buffer([0xE8, 0x94, 0x80, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0xF3, 0xA5]), - fix: new Buffer([0xE8, 0x94, 0x80, 0xFA, 0xFF, 0xB9, 0x09, 0x00, 0x00, 0x00, 0x8D, 0xB5, 0x70, 0xFF, 0xFF, 0xFF, 0x90, 0x90]) - } + ['0.8.0']: [ + /** + * Yaw + */ + { + offset: 0x0054B152, + pattern: new Buffer([0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054BD01, + pattern: new Buffer([0xD9, 0x9E, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054A1E3, + pattern: new Buffer([0xD9, 0x99, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054A213, + pattern: new Buffer([0xD9, 0x99, 0xD8, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + /** + * Pitch + */ + { + offset: 0x0054A1B2, + pattern: new Buffer([0xD9, 0x99, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x99, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054B0B4, + pattern: new Buffer([0x89, 0x8E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0x89, 0x8E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054BCDA, + pattern: new Buffer([0xD9, 0x9E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + { + offset: 0x0054B097, + pattern: new Buffer([0xD9, 0x9E, 0xDC, 0x00, 0x00, 0x00]), + fix: new Buffer([0xD9, 0x9E, 0xD0, 0x00, 0x00, 0x00]) + }, + ] } }, environment: { version: { ['0.5.3']: { timeOfDay: 0xCB23B4 + }, + ['0.8.0']: { + timeOfDay: 0 } } }, }; +export const vanilla = { + CameraRot: 0xF0, + enableCameraFacing: 0x90, + camera: { + position: { + ['1.1.2']: { + pattern: new Buffer([0x8B, 0x08, 0x8D, 0x56, 0x08, 0x89, 0x0A, 0x8B, 0x48, 0x04, 0x89, 0x4A, 0x04, 0x8B, 0x40, 0x08, 0x89, 0x42, 0x08]), + fix: new Buffer([0x8B, 0x08, 0x8D, 0x56, 0x08, 0x90, 0x90, 0x8B, 0x48, 0x04, 0x90, 0x90, 0x90, 0x8B, 0x40, 0x08, 0x90, 0x90, 0x90]), + }, + ['1.8.0']: { + pattern: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x89, 0x11, 0x8B, 0x50, 0x04, 0x89, 0x51, 0x04, 0x8B, 0x40, 0x08, 0x89, 0x41, 0x08]), + fix: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x90, 0x90, 0x8B, 0x50, 0x04, 0x90, 0x90, 0x90, 0x8B, 0x40, 0x08, 0x90, 0x90, 0x90]), + }, + ['1.12.0']: { + pattern: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x89, 0x11, 0x8B, 0x50, 0x04, 0x89, 0x51, 0x04, 0x8B, 0x40, 0x08, 0x89, 0x41, 0x08]), + fix: new Buffer([0x8B, 0x10, 0x8D, 0x4E, 0x08, 0x90, 0x90, 0x8B, 0x50, 0x04, 0x90, 0x90, 0x90, 0x8B, 0x40, 0x08, 0x90, 0x90, 0x90]), + }, + }, + base: { + pattern: new Buffer([0x8B ,0x11 ,0x8D ,0x45 ,0xF4 ,0x50 ,0xFF ,0x52 + ,0x04 ,0x8B ,0x4D ,0xF4 ,0x8B ,0x55 ,0xF8 ,0x8B ,0x45 ,0xFC ,0x89 + ,0x0E ,0x89 ,0x56 ,0x04 ,0x89 ,0x46 ,0x08 ,0x5E ,0x8B ,0xE5 ,0x5D]), + patternFix: { + ['1.1.2']: -0xA, + ['1.8.0']: -0xD, + ['1.12.0']: -0xD, + }, + version: { + ['1.1.2']: { + ptrFix: [0x6558, 0] + }, + ['1.8.0']: { + ptrFix: [0x6570, 0] + }, + ['1.12.0']: { + ptrFix: [0x65B8, 0] + } + } + } + } +}; + export const tbc = { + CameraRot: 0x104, SpectatePointer: [0x00871B94, 0xCC, 0x49C], - CameraPointer: [0x00C6ECCC, 0x732c, 0], + CameraPointer: [0x86ECCC, 0x732c, 0], EnableSpectate: new Buffer([0x00, 0x00, 0x7F, 0x43]), DisableSpectate: new Buffer([0, 0, 0, 0]), CameraValuesPointer: 0x00CEF468, @@ -130,13 +246,13 @@ export const tbc = { export const wlk = { SpectatePointer: [0x006DB754, 0x38, 0x98, 0x240], - CameraPointer: [0xB7436C, 0x7e20, 0], + CameraPointer: [0x77436C, 0x7e20, 0], EnableSpectate: new Buffer([0x00, 0x00, 0x7F, 0x43]), DisableSpectate: new Buffer([0, 0, 0, 0]), CameraValuesPointer: 0x00ACE4A8, Collision: 0x48, Speed: 0x44, - CameraRot: 0x118, + CameraRot: 0x11C, cameraViewMatrix: { version: { ['3.3.5a']: { @@ -149,13 +265,14 @@ export const wlk = { export const ctl = { SpectatePointer: 0x163BEC, - CameraPointer: [0x013F7A10, 0x80D0, 0], + CameraRot: 0x104, + CameraPointer: [0xAD7A10, 0x80D0, 0], EnableCorrectKeyboardControls: 0x94, // I would like to know one day why 4.3.4 is so "special" EnableSpectate: new Buffer([0xBA, 0x00, 0x00, 0x48, 0x00, 0xC1, 0xEA, 0x13, 0xF6, 0xC2, 0x01, 0x74, 0x18, 0xC1, 0xE9, 0x16, 0xF6, 0xC1, 0x01, 0x75, 0x0A, 0x85, 0xC0, 0x74, 0x0C, 0x83, 0x78, 0x08, 0x00, 0x75, 0x06, 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3, 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC]), DisableSpectate: new Buffer([0x8B, 0x49, 0x08, 0x8B, 0xD1, 0xC1, 0xEA, 0x13, 0xF6, 0xC2, 0x01, 0x74, 0x18, 0xC1, 0xE9, 0x16, 0xF6, 0xC1, 0x01, 0x75, 0x0A, 0x85, 0xC0, 0x74, 0x0C, 0x83, 0x78, 0x08, 0x04, 0x75, 0x06, 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3, 0x33, 0xC0, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC]), EnableSpectateOnCam: new Buffer([2, 0x00, 0x00, 0x0]), DisableSpectateOnCam: new Buffer([0, 0, 0, 0]), - CameraValuesPointer: 0x012319A0, + CameraValuesPointer: { offset: 0x9119A0, module: true }, Collision: 0x48, Speed: 0x44, cameraViewMatrix: { @@ -168,9 +285,29 @@ export const ctl = { }, }; +export const mop = { + SpectatePointer: [0xCFEFAC, 0x1504, 0x8], + CameraRot: 0x10C, + CameraPointer: [0xD6496C, 0x8208, 0], + EnableSpectate: new Buffer([0x00, 0x00, 0x48, 0x00]), + DisableSpectate: new Buffer([0, 0, 0, 0]), + CameraValuesPointer: 0x00F67EB8, + Collision: 0x48, + Speed: 0x44, + cameraViewMatrix: { + version: { + ['5.4.8']: { + pattern: new Buffer([0x83, 0xC4, 0x18, 0x8B, 0xC8, 0xE8, 0xB2, 0x9D, 0xFF, 0xFF, 0x6A, 0x09, 0x59, 0x8B, 0xF0, 0xF3, 0xA5]), + fix: new Buffer([0x83, 0xC4, 0x18, 0x8B, 0xC8, 0xE8, 0xB2, 0x9D, 0xFF, 0xFF, 0x6A, 0x09, 0x59, 0x8B, 0xF0, 0x90, 0x90]) + } + } + } +}; + export const draenor = { SpectatePointer: [0x00E379B0, 0xD4, 0x50, 0x350], - CameraPointer: [0x012AF270, 0x7610, 0], + CameraRot: 0x128, + CameraPointer: [0xEAF270, 0x7610, 0], EnableSpectate: new Buffer([0x00, 0x00, 0x48, 0x00]), DisableSpectate: new Buffer([0, 0, 0, 0]), CameraValuesPointer: 0x01325968, @@ -191,6 +328,7 @@ export const legion = { DisableSpectate: new Buffer([0, 0, 0, 0]), Collision: 0x90, Speed: 0x84, + CameraRot: 0x124, base: { version: { ['7.2.5']: { @@ -200,8 +338,8 @@ export const legion = { }, ['7.3.5']: { SpectatePointer: [0x01226DA0, 0x4, 0x28, 0x8, 0x384], - CameraPointer: [0x01BFF9A4, 0x0324C, 0], - CameraValuesPointer: 0x01FF57C8, + CameraPointer: [0x11DF9A4, 0x0324C, 0], + CameraValuesPointer: 0x11F57C8, } } }, diff --git a/src/core/manager.js b/src/core/manager.js index 8f3bd47..8d1d4d5 100644 --- a/src/core/manager.js +++ b/src/core/manager.js @@ -38,6 +38,8 @@ module.exports = (process, Module, Memory, window, Offsets) => { GetCameraData, SetPosition, SetSpeed, + Offsets, + Memory, ); const SetCameraView = createSetCameraView(Game, Memory, Offsets, SetPosition); @@ -51,7 +53,7 @@ module.exports = (process, Module, Memory, window, Offsets) => { SetPosition, SetCameraView, SetCollision, - )(); + )(Offsets, Game, Memory); const setTimeOfday = createSetTimeOfday(Game, Memory, Offsets, Module); const environmentStruct = createGetEnvPtr(Game, Memory, Module, Offsets)(); diff --git a/src/index.ejs b/src/index.ejs index e5ec3eb..46b6e4e 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -14,10 +14,6 @@ - - - - diff --git a/src/renderer/components/keyboard.vue b/src/renderer/components/keyboard.vue index 090ba72..9bed4c3 100644 --- a/src/renderer/components/keyboard.vue +++ b/src/renderer/components/keyboard.vue @@ -4,6 +4,7 @@ diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index ae854bd..465b49f 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -4,7 +4,7 @@ import modules from './modules'; import VTooltip from 'v-tooltip'; Vue.use(Vuex); -Vue.use(VTooltip); +Vue.use(VTooltip, { autoHide: false }); export default new Vuex.Store({ modules, diff --git a/src/renderer/store/modules/camera.js b/src/renderer/store/modules/camera.js index 72ab6c7..e94bd49 100644 --- a/src/renderer/store/modules/camera.js +++ b/src/renderer/store/modules/camera.js @@ -1,7 +1,7 @@ export default { state: { - speed: 10, + speed: 1, mode: 'DISABLED', // ['DISABLED', 'SPECTATE', 'PLAYING'] cinematicSteps: [], cinematicSpeed: 10, @@ -26,7 +26,8 @@ export default { setSpeed(state, speed) { const core = this.getters.core.camera; state.speed = speed; - core.setSpeed(Number(speed)); + const isSpectateEnabled = state.mode !== 'DISABLED'; + core.setSpeed(Number(speed), isSpectateEnabled); }, setRoll(state, { index, value }) { state.cinematicSteps[index].roll = parseFloat(value); diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 26647c8..b5333ee 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -3,8 +3,15 @@ export default { state: { alwaysOnTop: false, windowTransparency: 100, + build: 0, + client: 0, }, mutations: { + setGameInfo(state, { build, client }) { + console.log('# setGameInfo', build, client); + state.build = build; + state.client = client; + }, setAlwaysOnTop(state, value) { state.alwaysOnTop = value; }, From bc6ebf8b7cd88cd0283eb2013f8aa87858e37747 Mon Sep 17 00:00:00 2001 From: Karliky Date: Sun, 3 May 2020 10:24:41 +0200 Subject: [PATCH 4/8] set a correct offset for 2.4.3 --- src/core/index.js | 25 +++++++++++++++++++++++++ src/core/logic/patterns.js | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/core/index.js b/src/core/index.js index 645d588..0de1c65 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -93,3 +93,28 @@ window.launch = launchCore; // WoW.exe+26FFB8 - D8 1D 74FD7F00 - fcomp dword ptr [WoW.exe+3FFD74] { [00000000] } // WoW.exe+26FFBE - DFE0 - fnstsw ax // WoW.exe+26FFC0 - F6 C4 44 - test ah,44 { 68 } + + +// Tumba +// 0.00 0.00 11.00 0.00 408.81 -2010.49 320.00 0.91 408.05 -2011.01 340.00 409.57 -2009.97 321.03 408.10 -2010.50 340.00 408.10 -2010.50 320.00 1.00 0.00 0.00 0.00 + +// D6 0E 30 41 C0 D8 91 2A 8A 67 CC 43 A7 4F FB C4 00 00 A0 43 86 94 69 3F D0 05 CC 43 57 60 FB C4 00 00 AA 43 43 C9 CC 43 F7 3E FB C4 A3 83 A0 43 C0 0C CC 43 10 50 FB C4 00 00 AA 43 C0 0C CC 43 10 50 FB C4 00 00 A0 43 00 00 80 3F 80 00 00 00 00 00 00 00 00 00 00 00 + +// this one works: +// 86 94 69 3F D0 05 CC 43 57 60 FB C4 00 00 AA 43 43 C9 CC 43 +// 408.81 + +// good pattern +// 8A 67 CC 43 A7 4F FB C4 83 54 A0 43 86 94 69 3F D0 05 CC 43 57 60 FB C4 63 25 A0 43 43 C9 CC 43 F7 3E FB C4 A3 83 A0 43 C0 0C CC 43 10 50 FB C4 38 41 A0 43 C0 0C CC 43 10 50 FB C4 38 41 A0 43 00 00 80 3F 80 00 00 00 +// 408,81 -2010,49 320,66 0,91 408,05 -2011,01 320,29 409,57 -2009,97 321,03 408,10 -2010,50 320,51 408,10 -2010,50 320,51 1,00 0,00 + +// x y z 8A 67 CC 43 A7 4F FB C4 83 54 A0 43 + +// 320.6602478 +// 320.2920837 +// 321.0284119 +// 320.5095215 +// 320.5095215 +// 320.5095215 + +// Start of block terrain? 00 F0 E2 23 00 60 E1 05 diff --git a/src/core/logic/patterns.js b/src/core/logic/patterns.js index a8338eb..4d30fc9 100644 --- a/src/core/logic/patterns.js +++ b/src/core/logic/patterns.js @@ -227,7 +227,7 @@ export const vanilla = { export const tbc = { CameraRot: 0x104, - SpectatePointer: [0x00871B94, 0xCC, 0x49C], + SpectatePointer: [0x00A29D28, 0x128, 0x7FC, 0x7F8, 0x720, 0x6FC], CameraPointer: [0x86ECCC, 0x732c, 0], EnableSpectate: new Buffer([0x00, 0x00, 0x7F, 0x43]), DisableSpectate: new Buffer([0, 0, 0, 0]), From 0c895b62575c68d20529a7af16a43ab9c90819aa Mon Sep 17 00:00:00 2001 From: Karliky Date: Sun, 3 May 2020 13:20:12 +0200 Subject: [PATCH 5/8] darker UI and camera pos setter --- src/core/logic/camera.js | 2 +- src/index.ejs | 2 +- src/main/index.js | 2 +- src/renderer/App.vue | 93 +++++++ src/renderer/components/navbar.vue | 207 ++++++++------- .../components/sections/cinematicBuilder.vue | 16 +- .../components/sections/settingsMenu.vue | 4 +- src/renderer/components/sections/spectate.vue | 240 +++++++++++------- .../components/sections/spectateMenu.vue | 8 +- src/renderer/store/modules/camera.js | 13 + 10 files changed, 382 insertions(+), 205 deletions(-) diff --git a/src/core/logic/camera.js b/src/core/logic/camera.js index 3f5879c..53e33ed 100644 --- a/src/core/logic/camera.js +++ b/src/core/logic/camera.js @@ -70,7 +70,7 @@ module.exports = ( speed = Number(newSpeed); if (isSpectateEnabled) enableSpectator(); }, - setPosition: (data) => SetPosition(Pointer, data.x, data.y, data.z), + setPosition: (data) => SetPosition(CameraStruct, data.x, data.y, data.z), getViewMatrix: () => GetCameraData(Pointer).viewMatrix, getView: () => GetCameraData(Pointer), SetCameraView: (cinematicValues) => SetCameraView(CameraStruct, cinematicValues), diff --git a/src/index.ejs b/src/index.ejs index 46b6e4e..43a91aa 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -1,5 +1,5 @@ - + BugCraft Studio diff --git a/src/main/index.js b/src/main/index.js index 1d70483..13561e9 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -20,7 +20,7 @@ function createWindow() { mainWindow = new BrowserWindow({ width: 1400, minWidth: 330, - height: 350, + height: 370, frame: false, title: 'BugCraft Studio', bottom: 0, diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 7b121e0..8958c18 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -30,6 +30,99 @@ overflow: auto; } + /** + * Body + */ + html, body { + background: #1a1e21; + color: #e8e8ea; + } + + /** + * Label + */ + .label { + color: #e8e8ea; + } + + /** + * Input + */ + .input { + border-radius: #4a473f; + background: #1a1e21; + color: #e8e8ea; + } + + /** + * NavBar + */ + + .navbar { + background: #1a1e21; + border-bottom: 1px solid #29292b; + } + + .navbar-item { + color: #e8e8ea; + } + .navbar-item:hover { + color: #e8e8ea; + } + + .navbar-item:hover { + border-bottom: 1px solid #cc272d; + } + .navbar-item.router-link-exact-active { + border-bottom: 1px solid #cc272d; + } + + /** + * Tabs + */ + .tabs a { + color: #e8e8ea; + } + .tabs a:hover { + color: #e8e8ea; + } + .tabs.is-boxed a { + background-color: #1a1e21; + border: none; + border-radius: inherit; + border-bottom: 2px solid #1a1e21; + } + .tabs.is-boxed a:hover { + background-color: #1a1e21; + border: none; + border-radius: inherit; + border-bottom: 2px solid #cd262d; + } + .tabs.is-boxed a.router-link-exact-active { + border: none; + border-radius: inherit; + border-bottom: 2px solid #cd262d; + } + .tabs ul { + border: none; + } + /** + * Box + */ + .box { + background-color: #20201e; + color: #e8e8ea; + border-left: 6px solid #464648; + } + + .title { + color: #e8e8ea; + } + + .subtitle { + color: #e8e8ea; + } + /** * Tooltip */ diff --git a/src/renderer/components/navbar.vue b/src/renderer/components/navbar.vue index 621db3d..7c89c60 100644 --- a/src/renderer/components/navbar.vue +++ b/src/renderer/components/navbar.vue @@ -1,129 +1,140 @@ diff --git a/src/renderer/components/sections/cinematicBuilder.vue b/src/renderer/components/sections/cinematicBuilder.vue index e198882..2b9876d 100644 --- a/src/renderer/components/sections/cinematicBuilder.vue +++ b/src/renderer/components/sections/cinematicBuilder.vue @@ -1,15 +1,11 @@ diff --git a/src/renderer/components/sections/settingsMenu.vue b/src/renderer/components/sections/settingsMenu.vue index bfc0f14..b372391 100644 --- a/src/renderer/components/sections/settingsMenu.vue +++ b/src/renderer/components/sections/settingsMenu.vue @@ -1,13 +1,13 @@ + + \ No newline at end of file diff --git a/src/renderer/components/sections/spectateMenu.vue b/src/renderer/components/sections/spectateMenu.vue index 569f543..bd4c17f 100644 --- a/src/renderer/components/sections/spectateMenu.vue +++ b/src/renderer/components/sections/spectateMenu.vue @@ -1,15 +1,15 @@