v1.2.4.b1
This commit is contained in:
parent
dcf4020981
commit
12d04191f3
8 changed files with 48 additions and 7 deletions
|
|
@ -782,6 +782,7 @@ namespace src.player
|
|||
if (pawn.AbsOrigin == null || pawn.AbsRotation == null) return;
|
||||
|
||||
if (pawn.IsDefusing) return;
|
||||
if (IsAimingAtPlantedBomb(player, pawn)) return;
|
||||
|
||||
Vector eyePos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
Vector endPos = eyePos + SkillUtils.GetForwardVector(pawn.EyeAngles) * 80;
|
||||
|
|
@ -815,6 +816,35 @@ namespace src.player
|
|||
}
|
||||
}
|
||||
|
||||
private const float BombBlockRange = 100f;
|
||||
private const float BombBlockCos = 0.7071f;
|
||||
|
||||
private static bool IsAimingAtPlantedBomb(CCSPlayerController player, CCSPlayerPawn pawn)
|
||||
{
|
||||
if (player.Team != CsTeam.CounterTerrorist) return false;
|
||||
if (pawn.AbsOrigin == null) return false;
|
||||
|
||||
foreach (var bomb in Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4"))
|
||||
{
|
||||
if (bomb == null || !bomb.IsValid || bomb.AbsOrigin == null) continue;
|
||||
if (!bomb.BombTicking || bomb.BombDefused) continue;
|
||||
|
||||
float dx = bomb.AbsOrigin.X - pawn.AbsOrigin.X;
|
||||
float dy = bomb.AbsOrigin.Y - pawn.AbsOrigin.Y;
|
||||
float dz = bomb.AbsOrigin.Z - (pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
|
||||
|
||||
float distance = MathF.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||
if (distance > BombBlockRange || distance <= 0.01f) continue;
|
||||
|
||||
var forward = SkillUtils.GetForwardVector(pawn.EyeAngles);
|
||||
float dot = (forward.X * dx + forward.Y * dy + forward.Z * dz) / distance;
|
||||
|
||||
if (dot >= BombBlockCos) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static HookResult BulletImpact(EventBulletImpact @event, GameEventInfo info)
|
||||
{
|
||||
lock (setLock)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue