Skip to content

Commit

Permalink
feat: version 3.1.0; massively cleaned up codebase, image conversion …
Browse files Browse the repository at this point in the history
…removed! (performance upgrade)
  • Loading branch information
Jire committed Mar 26, 2021
1 parent 8eab744 commit 80682ea
Show file tree
Hide file tree
Showing 17 changed files with 350 additions and 227 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ The first step is to compile the source code into a usable cheat program.
* Double click on the "_build_" (_build.bat_) script and wait for it to complete

Once those steps are complete, the usable cheat program can be found within the _build_
directory, and will in a directory called **Overwatcheat 3.0.0**.
directory, and will in a directory called **Overwatcheat 3.1.0**.

From within the **Overwatcheat 3.0.0** directory, you can start the cheat by running the _"Start Overwatcheat 3.0.0"_
From within the **Overwatcheat 3.1.0** directory, you can start the cheat by running the _"Start Overwatcheat 3.1.0"_
script.

**Requirements:**

* Use fullscreen windowed mode if not using OBS projector
* It is vital to configure sensitivity to be the same as your in-game sens
* Increasing sensitivity to beyond your sens will give you slower aim
* Increasing sensitivity to beyond your sens will give you slower aim
* Increasing FPS will increase accuracy

---
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.nio.file.Files
*/

group 'com.overwatcheat'
version '3.0.0'
version '3.1.0'

buildscript {
ext.kotlin_version = '1.4.32'
Expand Down
Binary file removed interception.lib
Binary file not shown.
13 changes: 10 additions & 3 deletions overwatcheat.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The virtual key code key which activates the aim bot when held
aim_key=5
aim_key=1

# Your in-game sensitivity.
sensitivity=10.0
sensitivity=15.0

# The number of frames per second to capture the game at.
# The higher this is, the faster the aim speed, relative to the sensitivity.
Expand Down Expand Up @@ -33,4 +33,11 @@ window_title_search=Overwatch

# The native mouse device ID, usually this should be 11.
# The range is 11..20 for mouse IDs, and 1..10 for keyboard IDs.
device_id=11
device_id=11

# The offset in pixels to calculate the delta from.
# This number is specified for 1440p and automatically will scale with your screen resolution.
#
# You can try playing around with this to change where to aim, like moving the y down to do bodyshots.
aim_offset_x=34
aim_offset_y=56
53 changes: 0 additions & 53 deletions src/main/kotlin/com/overwatcheat/Colors.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.overwatcheat.util
package com.overwatcheat

import com.overwatcheat.nativelib.User32

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.overwatcheat.nativelib.interception
package com.overwatcheat

import com.overwatcheat.Overwatcheat
import com.overwatcheat.nativelib.Kernel32
import com.overwatcheat.nativelib.interception.Interception
import com.overwatcheat.nativelib.interception.InterceptionFilter
import com.overwatcheat.nativelib.interception.InterceptionMouseFlag
import com.overwatcheat.nativelib.interception.InterceptionStroke
import com.sun.jna.Callback

object Mouse : Thread() {
Expand Down Expand Up @@ -56,10 +59,10 @@ object Mouse : Thread() {
0, 0, 0, 0, true
)

fun move(x: Int, y: Int) {
fun move(x: Int, y: Int, deviceID: Int) {
stroke.x = x
stroke.y = y
Interception.interception_send(context, Overwatcheat.SETTINGS.deviceId, stroke, 1)
Interception.interception_send(context, deviceID, stroke, 1)
}

init {
Expand Down
139 changes: 50 additions & 89 deletions src/main/kotlin/com/overwatcheat/Overwatcheat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,100 +20,61 @@

package com.overwatcheat

import com.overwatcheat.nativelib.HWNDFinder
import com.overwatcheat.nativelib.interception.Mouse
import com.overwatcheat.util.Keyboard.keyPressed
import com.overwatcheat.util.Screen
import org.bytedeco.javacv.FFmpegFrameGrabber
import org.bytedeco.javacv.FrameConverter
import org.bytedeco.javacv.Java2DFrameConverter
import java.awt.image.BufferedImage
import java.awt.image.DataBufferByte
import kotlin.math.abs
import com.overwatcheat.aimbot.AimColorMatcher
import com.overwatcheat.aimbot.AimFrameHandler
import com.overwatcheat.framegrab.FrameGrabber
import com.overwatcheat.framegrab.FrameGrabberThread
import com.overwatcheat.framegrab.FrameHandler
import kotlin.math.ceil

object Overwatcheat {

lateinit var SETTINGS: Settings
lateinit var FRAME_GRABBER: FFmpegFrameGrabber
lateinit var FRAME_CONVERTER: FrameConverter<BufferedImage>

var CAPTURE_WIDTH = 0
private set
var CAPTURE_HEIGHT = 0
private set

var CAPTURE_OFFSET_X = 0
private set
var CAPTURE_OFFSET_Y = 0
private set

var CAPTURE_CENTER_X = 0
private set
var CAPTURE_CENTER_Y = 0
private set

@JvmStatic
fun main(args: Array<String>) {
Thread.currentThread().priority = Thread.MAX_PRIORITY

SETTINGS = Settings.read() // load settings

CAPTURE_WIDTH = (Screen.WIDTH / SETTINGS.boxWidthDivisor).toInt()
CAPTURE_HEIGHT = (Screen.HEIGHT / SETTINGS.boxHeightDivisor).toInt()

val MAX_SNAP_X = CAPTURE_WIDTH / SETTINGS.maxSnapDivisor
val MAX_SNAP_Y = CAPTURE_HEIGHT / SETTINGS.maxSnapDivisor

CAPTURE_OFFSET_X = (Screen.WIDTH - CAPTURE_WIDTH) / 2
CAPTURE_OFFSET_Y = (Screen.HEIGHT - CAPTURE_HEIGHT) / 2

CAPTURE_CENTER_X = CAPTURE_WIDTH / 2
CAPTURE_CENTER_Y = CAPTURE_HEIGHT / 2

FRAME_GRABBER = FFmpegFrameGrabber("title=${HWNDFinder.projectorWindowTitle}").apply {
format = "gdigrab"
frameRate = SETTINGS.fps
imageWidth = CAPTURE_WIDTH
imageHeight = CAPTURE_HEIGHT

setOption("offset_x", CAPTURE_OFFSET_X.toString())
setOption("offset_y", CAPTURE_OFFSET_Y.toString())

start()
}

FRAME_CONVERTER = Java2DFrameConverter()
Colors.init()

frames@ while (true) {
val frame = FRAME_GRABBER.grabImage()

if (!keyPressed(SETTINGS.aimKey)) continue

val img = FRAME_CONVERTER.convert(frame)
val imgWidth = img.width
val imgHeight = img.height
val pixels = (img.raster.dataBuffer as DataBufferByte).data

y@ for (y in 0..imgHeight - 1) {
val pixelY = imgWidth * y * 3
for (x in 0..imgWidth - 1) {
val pixel = pixelY + (x * 3)
val rgb = (pixels[pixel].toInt() and 0xFF) or // blue
((pixels[pixel + 1].toInt() and 0xFF) shl 8) or // green
((pixels[pixel + 2].toInt() and 0xFF) shl 16) // red
if (!Colors.colorMatches(rgb)) continue

val dX = x - CAPTURE_CENTER_X + X_OFFSET
if (abs(dX) >= MAX_SNAP_X) continue
val dY = y - CAPTURE_CENTER_Y + Y_OFFSET
if (abs(dY) >= MAX_SNAP_Y) continue

Mouse.move((dX / SETTINGS.sensitivity).toInt(), (dY / SETTINGS.sensitivity).toInt())
continue@frames
}
}
}
val settings = Settings.read() // load settings

val captureWidth = (Screen.WIDTH / settings.boxWidthDivisor).toInt()
val captureHeight = (Screen.HEIGHT / settings.boxHeightDivisor).toInt()

val maxSnapX = captureWidth / settings.maxSnapDivisor
val maxSnapY = captureHeight / settings.maxSnapDivisor

val captureOffsetX = (Screen.WIDTH - captureWidth) / 2
val captureOffsetY = (Screen.HEIGHT - captureHeight) / 2

val captureCenterX = captureWidth / 2
val captureCenterY = captureHeight / 2

val aimColorMatcher = AimColorMatcher(
settings.targetColorTolerance,
*settings.targetColors
)
aimColorMatcher.initializeMatchSet()

val aimOffsetX = ceil(settings.aimOffsetX * (Screen.WIDTH / 2560.0)).toInt()
val aimOffsetY = ceil(settings.aimOffsetY * (Screen.HEIGHT / 1440.0)).toInt()

val frameHandler: FrameHandler = AimFrameHandler(
settings.aimKey,
aimColorMatcher,
settings.sensitivity,
captureCenterX, captureCenterY,
aimOffsetX, aimOffsetY,
maxSnapX, maxSnapY,
settings.deviceId
)

val frameGrabber = FrameGrabber(
settings.windowTitleSearch,
settings.fps,
captureWidth,
captureHeight,
captureOffsetX,
captureOffsetY
)

val frameGrabberThread = FrameGrabberThread(frameGrabber, frameHandler)
frameGrabberThread.start()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.overwatcheat.util
package com.overwatcheat

import java.awt.Dimension
import java.awt.Toolkit
Expand Down
15 changes: 11 additions & 4 deletions src/main/kotlin/com/overwatcheat/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Settings(
val targetColors: IntArray, val targetColorTolerance: Int,
val windowTitleSearch: String,
val deviceId: Int,
val aimOffsetX: Int, val aimOffsetY: Int
) {

companion object {
Expand All @@ -36,8 +37,8 @@ class Settings(
fun read(filePath: String = DEFAULT_FILE) = read(File(filePath))

fun read(file: File): Settings {
var aimKey = 5
var sensitivity = 10.0F
var aimKey = 1
var sensitivity = 15.0F
var fps = 60.0

var boxWidthDivisor = 10.0F
Expand All @@ -46,12 +47,15 @@ class Settings(
var maxSnapDivisor = 2.0F

var targetColors = intArrayOf(0xdd32db, 0xdb33d8, 0xe23be9, 0xd619dd, 0xd200d6)
var targetColorTolerance = 12
var targetColorTolerance = 16

var windowTitleSearch = "Overwatch"

var deviceId = 11

var aimOffsetX = 34
var aimOffsetY = 56

file.readLines().forEach {
if (it.contains("=")) {
val split = it.split("=")
Expand All @@ -67,6 +71,8 @@ class Settings(
"target_color_tolerance" -> targetColorTolerance = split[1].toInt()
"window_title_search" -> windowTitleSearch = split[1]
"device_id" -> deviceId = split[1].toInt()
"aim_offset_x" -> aimOffsetX = split[1].toInt()
"aim_offset_y" -> aimOffsetY = split[1].toInt()
}
}
}
Expand All @@ -81,7 +87,8 @@ class Settings(
targetColors,
targetColorTolerance,
windowTitleSearch,
deviceId
deviceId,
aimOffsetX, aimOffsetY
)
}
}
Expand Down

0 comments on commit 80682ea

Please sign in to comment.