sailro / EscapeFromTarkov-Trainer

Escape from Tarkov (EFT) Trainer - Internal
MIT License
612 stars 138 forks source link

Aimbot issue and other Emu support #71

Closed Billybishop closed 3 years ago

Billybishop commented 3 years ago

EDIT: This issue has mutated into an enhancement rather than a series of questions. After playing with one of the branches and the master branch I have found the Aimbot to work properly as well as I added several features to the Aimbot which I hope to merge with Sebastian's latest version. Also, the hook can potentially work with JET emu but have yet to try. In my opinion SPT-AKI is the more promising emulation project so far.

ARCHIVED: Hey, thanks for sharing this base. It's been a pleasure to play around with it and make changes to the code.

I hadn't seen this mentioned, and probably for good reason, but my question is about whether it's possible to adapt one of the current branches to work with game client v0.12.9.10988? That is the newest version which JET emu is compatible with, and I was looking to give that emulator a try because I heard good things about a particular mod over there that greatly improves the AI behavior - which I noticed is not quite up to par on SPT.

Aside from that question which isn't terribly important, I was hoping to make some improvements on my own to the Aimbot feature, like Aim smoothing, FOV limit, and non-sticky targeting.

So far though, from just testing the Aimbot's original code it doesn't seem to work properly. The Aimbot does not rotate to the enemy but instead immediately aims downwards or to the side. I wasn't sure if you were aware of the issue or if there is a fix for it but I thought it was worth mentioning. Maybe you can guide me on what needs changed? I will also try fixing it.

Billybishop commented 3 years ago

image

Here is the error I see in console, I think I tracked it down to this line: image

Though I'm not sure, I will continue investigating and try to resolve it.

Billybishop commented 3 years ago

Update:

I was able to get a working Aimbot by scrapping what's here and C+P'ing the Mono-Mocket aimbot - which has a basic FOV limit implemented already. Though, it doesn't have basic projectile prediction included yet like your Aimbot implementation. I'll try to get to that later, for now I am trying to smooth the Aimbot's rotation so it acts more as an assist tool instead of a snapping-aim tool.

I've noticed a few things worth noting while debugging the Aimbots and playing with Unity Explorer. I'll try to compile some notes and post them somewhere soon.

EDIT:

After checking out the latest build version (instead of the older one I was using to play on SPT-AKI 1.5.1), the original Aimbot code is working as expected on SPT-AKI 2.0 and Tarkov 0.12.11.14290! I will continue with modifying this Aimbot for smoothing and try to carry over the FOV.

Billybishop commented 3 years ago

Hi @sailro !

Great news, I was able to implement an elegant solution for smoothing the Aim angle - it will follow the target perfectly at any speed while still smoothing out the aim using a percent based calculation for the angle difference! This means the smoothing will slow down as it reaches the target, and will speed up if the target speeds up / the distance from the center of screen and the target is farther:

[Note: The percent for 'smooth' value should be between 1 and 0, I found 0.1 to 0.085 to be a good range of value for smoothing the Aimbot]

        AimAtPosition(localPlayer, nearestTarget, SmoothPercent);  //usage

    private static void AimAtPosition(Player player, Vector3 target_position, float smooth)
    {
        Vector3 current_firing_angle = (player.Fireport.position - player.Fireport.up * 1f);
        Vector3 diff_pos = (target_position - current_firing_angle).normalized;
        Quaternion target_quat = Quaternion.LookRotation(diff_pos);
        Vector3 target_euler = target_quat.eulerAngles;

        //This is necessary due to crossing Y plane with target
        if (target_euler.x > 180f)
            target_euler.x -= 360f;

        Vector2 current_rotation = player.MovementContext.Rotation;
        Vector2 smooth_angle = GetSmoothAngle(current_rotation, new Vector2(target_euler.y, target_euler.x), smooth);
        player.MovementContext.Rotation = (smooth_angle);
    }

    public static Vector2 GetSmoothAngle(Vector2 from_angle, Vector2 to_angle, float percent)
    {
        Vector2 delta = (from_angle - to_angle);
        NormalizeAngle(ref delta);
        Vector2 smoothed_delta = Vector2.Scale(delta, new Vector2(percent, percent));
        to_angle = (from_angle - smoothed_delta);
        return to_angle;
    }

    public static void NormalizeAngle(ref Vector2 angle)
    {
        float new_x = angle.x;
        float new_y = angle.y;

        if (angle.x <= -180f)
            new_x = (angle.x + 360f);
        if (angle.x > 180f)
            new_x = (angle.x - 360f);
        if (angle.y > 90f)
            new_y = (angle.y - 180f);
        if (angle.y <= -90f)
            new_y = (angle.y + 180f);

        angle = new Vector2(new_x, new_y);
    }

I'm not sure how you wish to proceed with deploying this as a new feature to the hook, but it would surely be a great addition! I was careful to account for the angle normals and scale the vectors appropriately, it turns out that clamping the angles is not necessary. After extensive testing it now works properly when aiming at targets from any angle difference.

I will now begin implementing the fov calculation and then I will try my hand at implementing a basic hit marker mod.

sailro commented 3 years ago

Thank you @Billybishop , I just ported the feature in the master branch.

I exposed the smoothness as a parameter in the trainer.ini file:

EFT.Trainer.Features.Aimbot.Key="Slash"
EFT.Trainer.Features.Aimbot.MaximumDistance=200.0
EFT.Trainer.Features.Aimbot.Smoothness=0.085