From 7f9767277d69c03b466bc0db46fddf7b7bd3e574 Mon Sep 17 00:00:00 2001 From: Mohamed Date: Thu, 16 Nov 2023 15:48:05 +0400 Subject: [PATCH] Scrake only damages a player if he is facing them + Scrake Rage Fix --- Classes/AdvSawZombieController.uc | 72 +++++++++++++++---------------- Classes/AdvZombieScrake.uc | 7 ++- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Classes/AdvSawZombieController.uc b/Classes/AdvSawZombieController.uc index 85af616..f5e90e3 100644 --- a/Classes/AdvSawZombieController.uc +++ b/Classes/AdvSawZombieController.uc @@ -4,6 +4,7 @@ class AdvSawZombieController extends KFMonsterController; var bool bDoneSpottedCheck; var bool bFacingTarget; +var float RelativeDir; state ZombieHunt { event SeePlayer(Pawn SeenPlayer) { @@ -27,42 +28,6 @@ function TimedFireWeaponAtEnemy() { else SetTimer(0.01, True); } -function bool FireWeaponAt(Actor A) { - local vector aFacing, aToB, TargetFacing, BToa; - local float RelativeDir, TargetRelativeDir; - - if (A == none) { - A = Enemy; - } - if (A == none || Focus != A) { - return false; - } - - - aFacing = Normal(Vector(Pawn.Rotation)); - TargetFacing = Normal(Vector(A.Rotation)); - - // Get the vector from A to B - aToB = A.Location - Pawn.Location; - BToa = Pawn.Location - A.Location; - - RelativeDir = aFacing dot aToB; - TargetRelativeDir = TargetFacing dot BToa; - - if (RelativeDir < -15) { - bFacingTarget = false; - } else { - bFacingTarget = true; - } - - - if (CanAttack(A)) { - Target = A; - Monster(Pawn).RangedAttack(Target); - } - return false; -} - state ZombieCharge { // Don't do this in this state function GetOutOfTheWayOfShot(vector ShotDirection, vector ShotOrigin){} @@ -92,5 +57,40 @@ Moving: SoakStop("STUCK IN CHARGING!"); } +function bool FireWeaponAt(Actor A) { + if (A == none) { + A = Enemy; + } + if (A == none || Focus != A) { + return false; + } + + Monster(Pawn).RangedAttack(Target); + return false; +} + +function tick(float DeltaTime) { + local vector aFacing, aToB, TargetFacing, BToa; + local float TargetRelativeDir; + + super.tick(DeltaTime); + + aFacing = Normal(Vector(Pawn.Rotation)); + TargetFacing = Normal(Vector(Enemy.Rotation)); + + // Get the vector from A to B + aToB = Enemy.Location - Pawn.Location; + BToa = Pawn.Location - Enemy.Location; + + RelativeDir = aFacing dot aToB; + TargetRelativeDir = TargetFacing dot BToa; + + if (RelativeDir < 30) { + bFacingTarget = false; + } else { + bFacingTarget = true; + } +} + defaultproperties { } diff --git a/Classes/AdvZombieScrake.uc b/Classes/AdvZombieScrake.uc index f6e6a3f..8a43422 100644 --- a/Classes/AdvZombieScrake.uc +++ b/Classes/AdvZombieScrake.uc @@ -132,14 +132,13 @@ simulated function UpdateExhaustEmitter() { simulated function Tick(float DeltaTime) { super.Tick(DeltaTime); - UpdateExhaustEmitter(); } function RangedAttack(Actor A) { if ( bShotAnim || Physics == PHYS_Swimming) return; - else if ( CanAttack(A) ) { + else if ( CanAttack(A) && AdvSawZombieController(Controller).bFacingTarget) { bShotAnim = true; SetAnimAction(MeleeAnims[Rand(2)]); CurrentDamType = ZombieDamType[0]; @@ -180,7 +179,7 @@ function bool MeleeDamageTarget(int hitdamage, vector pushdir) { Return True; } - if (!AdvSawZombieController(Controller).bFacingTarget) { + if (AdvSawZombieController(Controller).RelativeDir < 30) { return false; } /*ClearStayingDebugLines(); @@ -665,6 +664,6 @@ defaultproperties { // NOTE: Most Default Properties are set in the base class to eliminate hitching //------------------------------------------------------------------------------- - EventClasses(0)="KFChar.ZombieScrake_STANDARD" + EventClasses(0)="KFAdvZeds.AdvZombieScrake_S" ControllerClass=Class'KFAdvZeds.AdvSawZombieController' } \ No newline at end of file