Skip to content

Commit

Permalink
Scrake only damages a player if he is facing them + Scrake Rage Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
theengineertcr committed Nov 16, 2023
1 parent ba049b3 commit 7f97672
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
72 changes: 36 additions & 36 deletions Classes/AdvSawZombieController.uc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class AdvSawZombieController extends KFMonsterController;

var bool bDoneSpottedCheck;
var bool bFacingTarget;
var float RelativeDir;

state ZombieHunt {
event SeePlayer(Pawn SeenPlayer) {
Expand All @@ -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){}
Expand Down Expand Up @@ -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 {
}
7 changes: 3 additions & 4 deletions Classes/AdvZombieScrake.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'
}

0 comments on commit 7f97672

Please sign in to comment.