import com.vng.pubgmobile.*;
import java.io.*;

public class WeaponTrackingSystem {
    static class WeaponConfig {
        String id;
        int trackingRange;
        int lockTime;
        int sensitivity;
        int acceleration;
        int damageMultiplier;
        int effectiveDistance;
        boolean burstTracking;
    }

    static WeaponConfig[] weapons = new WeaponConfig[10];

    static {
        // 1. M416 (突击步枪)
        weapons[0] = new WeaponConfig();
        weapons[0].id = "M416";
        weapons[0].trackingRange = 300;
        weapons[0].lockTime = 400;
        weapons[0].sensitivity = 85;
        weapons[0].acceleration = 20;
        weapons[0].damageMultiplier = 12;
        weapons[0].effectiveDistance = 400;
        weapons[0].burstTracking = true;

        // 2. AKM (突击步枪)
        weapons[1] = new WeaponConfig();
        weapons[1].id = "AKM";
        weapons[1].trackingRange = 280;
        weapons[1].lockTime = 350;
        weapons[1].sensitivity = 90;
        weapons[1].acceleration = 22;
        weapons[1].damageMultiplier = 15;
        weapons[1].effectiveDistance = 350;
        weapons[1].burstTracking = true;

        // 3. AWM (狙击枪)
        weapons[2] = new WeaponConfig();
        weapons[2].id = "AWM";
        weapons[2].trackingRange = 1000;
        weapons[2].lockTime = 800;
        weapons[2].sensitivity = 70;
        weapons[2].acceleration = 15;
        weapons[2].damageMultiplier = 50;
        weapons[2].effectiveDistance = 1000;
        weapons[2].burstTracking = false;

        // 4. Kar98k (狙击枪)
        weapons[3] = new WeaponConfig();
        weapons[3].id = "Kar98k";
        weapons[3].trackingRange = 700;
        weapons[3].lockTime = 750;
        weapons[3].sensitivity = 75;
        weapons[3].acceleration = 18;
        weapons[3].damageMultiplier = 40;
        weapons[3].effectiveDistance = 700;
        weapons[3].burstTracking = false;

        // 5. UZI (冲锋枪)
        weapons[4] = new WeaponConfig();
        weapons[4].id = "UZI";
        weapons[4].trackingRange = 120;
        weapons[4].lockTime = 150;
        weapons[4].sensitivity = 95;
        weapons[4].acceleration = 30;
        weapons[4].damageMultiplier = 8;
        weapons[4].effectiveDistance = 150;
        weapons[4].burstTracking = true;

        // 6. MP5 (冲锋枪)
        weapons[5] = new WeaponConfig();
        weapons[5].id = "MP5";
        weapons[5].trackingRange = 180;
        weapons[5].lockTime = 200;
        weapons[5].sensitivity = 90;
        weapons[5].acceleration = 28;
        weapons[5].damageMultiplier = 10;
        weapons[5].effectiveDistance = 200;
        weapons[5].burstTracking = true;

        // 7. S686 (霰弹枪)
        weapons[6] = new WeaponConfig();
        weapons[6].id = "S686";
        weapons[6].trackingRange = 50;
        weapons[6].lockTime = 100;
        weapons[6].sensitivity = 80;
        weapons[6].acceleration = 35;
        weapons[6].damageMultiplier = 25;
        weapons[6].effectiveDistance = 50;
        weapons[6].burstTracking = true;

        // 8. S12K (霰弹枪)
        weapons[7] = new WeaponConfig();
        weapons[7].id = "S12K";
        weapons[7].trackingRange = 60;
        weapons[7].lockTime = 120;
        weapons[7].sensitivity = 82;
        weapons[7].acceleration = 32;
        weapons[7].damageMultiplier = 20;
        weapons[7].effectiveDistance = 60;
        weapons[7].burstTracking = true;

        // 9. M249 (轻机枪)
        weapons[8] = new WeaponConfig();
        weapons[8].id = "M249";
        weapons[8].trackingRange = 500;
        weapons[8].lockTime = 450;
        weapons[8].sensitivity = 75;
        weapons[8].acceleration = 18;
        weapons[8].damageMultiplier = 11;
        weapons[8].effectiveDistance = 600;
        weapons[8].burstTracking = true;

        // 10. Groza (突击步枪)
        weapons[9] = new WeaponConfig();
        weapons[9].id = "Groza";
        weapons[9].trackingRange = 320;
        weapons[9].lockTime = 380;
        weapons[9].sensitivity = 88;
        weapons[9].acceleration = 21;
        weapons[9].damageMultiplier = 14;
        weapons[9].effectiveDistance = 380;
        weapons[9].burstTracking = true;
    }

    public static void activateTracking(String weaponId) {
        for (WeaponConfig cfg : weapons) {
            if (cfg.id.equals(weaponId)) {
                Log.i("WeaponTracking", "Activating " + cfg.id);
                Log.i("WeaponTracking", "Range:" + cfg.trackingRange + " LockTime:" + cfg.lockTime);
                Log.i("WeaponTracking", "Sensitivity:" + cfg.sensitivity + " Acceleration:" + cfg.acceleration);
                Log.i("WeaponTracking", "DamageMul:" + cfg.damageMultiplier + " Dist:" + cfg.effectiveDistance);
                Log.i("WeaponTracking", "BurstTrack:" + cfg.burstTracking);
                Injector.inject("com.vng.pubgmobile.tracking." + cfg.id);
                return;
            }
        }
    }

    public static void main(String[] args) {
        for (WeaponConfig cfg : weapons) {
            activateTracking(cfg.id);
        }
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {}
        }
    }
}

class FilePatcher {
    public static void patchFile(String path) throws IOException {
        File file = new File(path);
        FileInputStream fis = new FileInputStream(file);
        byte[] data = new byte[(int) file.length()];
        fis.read(data);
        fis.close();
        for (int i = 0; i < data.length; i++) {
            int val = data[i] & 0xFF;
            if (val >= 128) {
                val *= 2;
                if (val > 255) val = 255;
                data[i] = (byte) val;
            }
        }
        FileOutputStream fos = new FileOutputStream(file);
        fos.write(data);
        fos.close();
    }

    public static void main(String[] args) throws IOException {
        patchFile("weapon_tracking.pak");
        while (true) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {}
        }
    }
}
