Jire / Abendigo

A free as in both freedom and free beer game modding platform using Kotlin on the JVM.
GNU General Public License v3.0
57 stars 56 forks source link

BoneTriggerBot Problem , Can't Spray with Automatic Weapons #16

Closed punkjj closed 8 years ago

punkjj commented 8 years ago

I cant Spray while using Automatic weapons :cry: Im using it for !weapon.pistol and !weapon.automatic

punkjj commented 8 years ago

Reply ?

Jire commented 8 years ago

@punkjj Post your full plugin code with the insert code feature.

punkjj commented 8 years ago

`package org.abendigo.plugin.csgo

import org.abendigo.DEBUG import org.abendigo.csgo. import org.abendigo.csgo.Client.clientDLL import org.abendigo.csgo.Client.enemies import org.abendigo.csgo.Engine.clientState import org.abendigo.csgo.offsets.m_dwForceAttack import java.lang.Math.

object BoneTriggerPlugin : InGamePlugin("Bone Trigger", duration = 1) {

val TARGET_BONE = Bones.HEAD
private const val FOV = 10

private val aim = Vector(0F, 0F, 0F)
private var hold = false

override fun cycle() {
    val myPosition = +Me().position
    val angle = clientState(1024).angle()
    try {
        val weapon = (+Me().weapon).type!!
        if (!weapon.pistol && !weapon.sniper1) return
    } catch (t: Throwable) {
        if (DEBUG) t.printStackTrace()
    }

    var closestDelta = Int.MAX_VALUE
    for ((i, e) in enemies) {
        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
    }
}

`}``

punkjj commented 8 years ago

Here sniper1 = SSG 08 or scout

punkjj commented 8 years ago

Can you edit and put a toggle function ? and Right now I removed !weapon.automatic

punkjj commented 8 years ago

@Jire ^^

Jire commented 8 years ago

If you only want to have it work for non-automatics, you should be returning if the weapon is an automatic, not if it's not an automatic.

But using inclusivity (whitelisting) is easier than writing all the exclusives:

if (!weapon.pistol && !weapon.shotgun && !weapon.sniper) return