Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.thor.plugins.game
- import org.thor.DEBUG
- import org.thor.define.*
- import org.thor.define.Client.clientDLL
- import org.thor.define.Client.enemies
- import org.thor.define.Engine.clientState
- import org.thor.define.offsets.m_dwForceAttack
- import org.neptune.spear.keyPressed
- import java.lang.Math.*
- import org.thor.util.random
- object BoneTriggerScopedOnly : InGame("Bone Trigger Scoped Only", duration = 1) {
- private const val KEY = 5
- val TARGET_BONE = Bones.HEAD
- private const val FOV = 9
- private val aim = Vector(0F, 0F, 0F)
- private var hold = false
- private const val MIN_SCOPE_DURATION = 85
- private const val MAX_SCOPE_DURATION = 160
- private const val BOLT_ACTION_ONLY = true
- private var scopeDuration = 0
- override fun cycle() {
- if(!keyPressed(KEY)) return
- val scoped = +Me.inScope
- if (!scoped) {
- scopeDuration = 0
- return
- }
- scopeDuration += duration
- if (scopeDuration < random(MIN_SCOPE_DURATION, MAX_SCOPE_DURATION)) return
- try {
- val weapon = (+Me().weapon).type!!
- if (Weapons.SSG08 !=weapon || (BOLT_ACTION_ONLY && !weapon.boltAction)) return
- } catch (t: Throwable) {
- if (DEBUG) t.printStackTrace()
- }
- val myPosition = +Me().position
- val angle = clientState(1024).angle()
- var closestDelta = Int.MAX_VALUE
- for ((i, e) in enemies) {
- if (+e.dead || +e.dormant || !+e.spotted) continue
- val ePos = e.bonePosition(TARGET_BONE.id)
- val distance = distance(myPosition, ePos)
- calculateAngle(Me(), myPosition, ePos, aim.reset())
- normalizeAngle(aim)
- val pitchDiff = abs(angle.x - aim.x)
- val yawDiff = abs(angle.y - aim.y)
- val diff = sin(toRadians(pitchDiff.toDouble())) + sin(toRadians(yawDiff.toDouble()))
- val delta = abs(diff * distance)
- if (delta <= FOV && delta < closestDelta) closestDelta = delta.toInt()
- }
- if (closestDelta <= FOV && !hold) {
- clientDLL[m_dwForceAttack] = 5.toByte()
- hold = true
- } else if (hold) {
- clientDLL[m_dwForceAttack] = 4.toByte()
- hold = false
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement