Загрузка данных


using GTA;
using GTA.Math; // Исправляет ошибку с Vector3 из лога
using GTA.Native;
using System;
using System.Windows.Forms;

public class HomelanderMod : Script
{
    private bool isLaserActive = false;

    public HomelanderMod()
    {
        KeyDown += OnKeyDown;
        Tick += OnTick;
    }

    private void OnKeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyCode == Keys.U)
        {
            isLaserActive = !isLaserActive;

            if (isLaserActive)
            {
                UI.Notify("~r~Лазерный взгляд Хоумлендера включен!~s~");
            }
            else
            {
                UI.Notify("~g~Лазерный взгляд выключен.~s~");
            }
        }
    }

    private void OnTick(object sender, EventArgs e)
    {
        if (!isLaserActive) return;

        Ped playerPed = Game.Player.Character;

        if (playerPed.Exists() && playerPed.IsAlive)
        {
            // Бессмертие игрока, чтобы не подорвать самого себя
            playerPed.IsInvincible = true;

            // Получаем направление камеры
            Vector3 camCoord = GameplayCamera.Position;
            Vector3 camRot = GameplayCamera.Rotation;
            
            float num = camRot.Z * 0.0174532924f;
            float num2 = camRot.X * 0.0174532924f;
            float num3 = Math.Abs((float)Math.Cos((double)num2));
            
            // Точка прицеливания впереди (на расстоянии 40 метров)
            Vector3 targetPos = new Vector3();
            targetPos.X = camCoord.X - (float)Math.Sin((double)num) * num3 * 40f;
            targetPos.Y = camCoord.Y + (float)Math.Cos((double)num) * num3 * 40f;
            targetPos.Z = camCoord.Z + (float)Math.Sin((double)num2) * 40f;

            // Позиция глаз персонажа
            Vector3 eyePos = playerPed.Position + playerPed.UpVector * 0.6f;
            Vector3 leftEye = eyePos - playerPed.RightVector * 0.1f;
            Vector3 rightEye = eyePos + playerPed.RightVector * 0.1f;

            // Рисуем два красных лазерных луча (RGB: 255, 0, 0)
            Function.Call(Hash.DRAW_LINE, leftEye.X, leftEye.Y, leftEye.Z, targetPos.X, targetPos.Y, targetPos.Z, 255, 0, 0, 255);
            Function.Call(Hash.DRAW_LINE, rightEye.X, rightEye.Y, rightEye.Z, targetPos.X, targetPos.Y, targetPos.Z, 255, 0, 0, 255);

            // Создаем взрывы лазерного типа прямо в точке, куда вы смотрите
            // Тип взрыва 23 (BULLET) поджигает и ломает объекты, но работает без вылетов на старой версии
            World.AddExplosion(targetPos, ExplosionType.Bullet, 5.0f, 0.5f);

            // Принудительный поджог точки попадания луча
            Function.Call(Hash.START_SCRIPT_FIRE, targetPos.X, targetPos.Y, targetPos.Z, 1, true);
        }
    }
}