using GTA;
using GTA.Math;
using GTA.Native;
using System;
using System.Windows.Forms;
public class HomelanderLaser : Script
{
public HomelanderLaser()
{
Tick += OnTick;
}
private void OnTick(object sender, EventArgs e)
{
if (!Game.IsKeyPressed(Keys.B))
return;
Ped ped = Game.Player.Character;
// Кость головы
Vector3 head = ped.GetBoneCoord(Bone.SKEL_Head);
// Смещение к глазам
Vector3 right = ped.RightVector * 0.035f;
Vector3 up = ped.UpVector * 0.03f;
Vector3 leftEye = head - right + up;
Vector3 rightEye = head + right + up;
Vector3 dir = GameplayCamera.Direction;
Vector3 endLeft = leftEye + dir * 500f;
Vector3 endRight = rightEye + dir * 500f;
// Красные лучи
DrawLaser(leftEye, endLeft);
DrawLaser(rightEye, endRight);
// Проверяем попадания
ExplodeHit(leftEye, endLeft);
ExplodeHit(rightEye, endRight);
}
private void DrawLaser(Vector3 from, Vector3 to)
{
Function.Call(Hash.DRAW_LINE,
from.X, from.Y, from.Z,
to.X, to.Y, to.Z,
255, 0, 0, 255);
}
private void ExplodeHit(Vector3 from, Vector3 to)
{
RaycastResult hit = World.Raycast(from, to, IntersectOptions.Everything);
if (hit.DitHitEntity && hit.HitEntity is Vehicle vehicle)
{
World.AddExplosion(
vehicle.Position,
ExplosionType.Rocket,
8.0f,
1.0f);
vehicle.EngineHealth = -4000;
}
}
}