Skip to content

Commit

Permalink
v7.1(Beta) Update
Browse files Browse the repository at this point in the history
  • Loading branch information
T-MaxWiese-T committed Mar 13, 2021
1 parent 4a761d4 commit 33ef699
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 94 deletions.
5 changes: 4 additions & 1 deletion Source/Game/SwatAICommon/Classes/Actions/ComplianceAction.uc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var private bool bJustComplied;

const kPostComplianceGoalPriority = 91; // lower than being stunned or shot

var config float ThreatCooldown;

///////////////////////////////////////////////////////////////////////////////
//
// Init / Cleanup
Expand Down Expand Up @@ -197,7 +199,7 @@ latent final function Comply()
// make sure we are not a threat anymore
if (m_Pawn.IsA('SwatEnemy') && ISwatEnemy(m_Pawn).IsAThreat())
{
Enemy.UnbecomeAThreat();
Enemy.UnbecomeAThreat(true, ThreatCooldown);
}
}
}
Expand Down Expand Up @@ -244,4 +246,5 @@ state Running
defaultproperties
{
satisfiesGoal=class'ComplianceGoal'
ThreatCooldown=2.0
}
4 changes: 3 additions & 1 deletion Source/Game/SwatAICommon/Classes/Actions/FleeAction.uc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var config private float MaxAggressiveFleePercentageChance;

var private DistanceToOfficersSensor DistanceToOfficersSensor;
var private bool bUseDistanceToOfficersSensor;
var config private float ThreatCooldown;

///////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -363,7 +364,7 @@ latent function Flee()
local Pawn CurrentEnemy;
CurrentEnemy = ISwatEnemy(m_Pawn).GetEnemyCommanderAction().GetCurrentEnemy();

ISwatEnemy(m_Pawn).UnbecomeAThreat();
ISwatEnemy(m_Pawn).UnbecomeAThreat(true, ThreatCooldown);

// trigger the speech
ISwatEnemy(m_Pawn).GetEnemySpeechManagerAction().TriggerFleeSpeech();
Expand Down Expand Up @@ -443,4 +444,5 @@ Begin:
defaultproperties
{
satisfiesGoal = class'EngageOfficerGoal'
ThreatCooldown = 2.0
}
4 changes: 3 additions & 1 deletion Source/Game/SwatAICommon/Classes/Actions/StunnedAction.uc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import enum EUpperBodyAnimBehaviorClientId from UpperBodyAnimBehaviorClients;
// Variables

var config private float MinRequiredFleeDistanceFromOfficer; // the minimum distance between us and the closest officer to be able to flee
var config private float ThreatCooldown;

// behaviors we use
var private MoveToActorGoal CurrentMoveToActorGoal;
Expand Down Expand Up @@ -86,7 +87,7 @@ function initAction(AI_Resource r, AI_Goal goal)
}
if (m_Pawn.IsA('SwatEnemy') && ISwatEnemy(m_Pawn).IsAThreat())
{
ISwatEnemy(m_Pawn).UnbecomeAThreat();
ISwatEnemy(m_Pawn).UnbecomeAThreat(true, ThreatCooldown);
}
// if we're running on an hostage, let the hive know -J21C
if (m_Pawn.IsA('SwatHostage'))
Expand Down Expand Up @@ -714,4 +715,5 @@ defaultproperties
{
satisfiesGoal = class'StunnedGoal'
MinRequiredFleeDistanceFromOfficer = 200.0
ThreatCooldown = 2.0
}
2 changes: 1 addition & 1 deletion Source/Game/SwatAICommon/Classes/ISwatEnemy.uc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function EnemySpeechManagerAction GetEnemySpeechManagerAction();
function bool IsAThreat();
function bool IAmThreat();
function BecomeAThreat();
function UnbecomeAThreat();
function UnbecomeAThreat(optional bool UseCooldown, optional float CooldownDuration);

///////////////////////////////////////////////////////////////////////////////
//
Expand Down
2 changes: 1 addition & 1 deletion Source/Game/SwatGame/Classes/AI/SwatAICharacter.uc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ protected function bool ShouldReactToNonLethals()

///////////////////////////////////////

function UnbecomeAThreat();
function UnbecomeAThreat(optional bool UseCooldown, optional float CooldownDuration);

///////////////////////////////////////////////////////////////////////////////

Expand Down
100 changes: 60 additions & 40 deletions Source/Game/SwatGame/Classes/AI/SwatEnemy.uc
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,25 @@ var config float LowSkillAdditionalBaseAimError;
var config float MediumSkillAdditionalBaseAimError;
var config float HighSkillAdditionalBaseAimError;

/*
var config float LowSkillMinTimeToFireFullAuto;
var config float LowSkillMaxTimeToFireFullAuto;
var config float MediumSkillMinTimeToFireFullAuto;
var config float MediumSkillMaxTimeToFireFullAuto;
var config float HighSkillMinTimeToFireFullAuto;
var config float HighSkillMaxTimeToFireFullAuto;

const LowSkillMinTimeBeforeShooting = 0.8;
const LowSkillMaxTimeBeforeShooting = 1.3;
const MediumSkillMinTimeBeforeShooting = 0.7;
const MediumSkillMaxTimeBeforeShooting = 1.0;
const HighSkillMinTimeBeforeShooting = 0.4;
const HighSkillMaxTimeBeforeShooting = 0.8;

var config float MinDistanceToAffectMoraleOfOtherEnemiesUponDeath;

*/
var float unused1;
var float unused2;
var float unused3;
var float unused4;
var float unused5;
var float unused6;

//var config float MinDistanceToAffectMoraleOfOtherEnemiesUponDeath;
var protected Timer ThreatTimer;

/*
var config array<name> ThrowWeaponDownAnimationsHG;
var config array<name> ThrowWeaponDownAnimationsMG;
var config array<name> ThrowWeaponDownAnimationsSMG;
Expand All @@ -53,12 +56,15 @@ var config array<name> ThrowWeaponDownAnimationsSG;
var config float LowSkillFullBodyHitChance;
var config float MediumSkillFullBodyHitChance;
var config float HighSkillFullBodyHitChance;
*/
var array<name> unused8;
var array<name> unused9;
var array<name> unused10;
var array<name> unused11;

//can't run game with these vars compiled in; throws a
//'native class size does not match scripted class size' error -K.F.
//var config float LowSkillComplyInstantDropChance;
//var config float MediumSkillComplyInstantDropChance;
//var config float HighSkillComplyInstantDropChance;
var float unused12;
var float unused13;
var float unused14;

var bool bEnteredFleeSafeguard;

Expand Down Expand Up @@ -372,15 +378,15 @@ function bool ShouldPlayFullBodyHitAnimation()
switch(Skill)
{
case EnemySkill_High:
Chance = HighSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.HighSkillFullBodyHitChance;
break;

case EnemySkill_Medium:
Chance = MediumSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.MediumSkillFullBodyHitChance;
break;

case EnemySkill_Low:
Chance = LowSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.LowSkillFullBodyHitChance;
break;
}

Expand Down Expand Up @@ -577,7 +583,7 @@ simulated function NotifyNearbyEnemiesOfDeath(Pawn Killer)
{
if ((Iter != self) && Iter.IsA('SwatEnemy') && SwatEnemy(Iter).IsConscious())
{
if ((VSize2D(Iter.Location - Location) < MinDistanceToAffectMoraleOfOtherEnemiesUponDeath) &&
if ((VSize2D(Iter.Location - Location) < class'SwatEnemyConfig'.default.MinDistanceToAffectMoraleOfOtherEnemiesUponDeath) &&
LineOfSightTo(Iter))
{
if(Killer.IsA('SwatOfficer') || Killer.IsA('SwatPlayer') || Killer.IsA('NetPlayer'))
Expand Down Expand Up @@ -1007,21 +1013,21 @@ simulated private function name GetThrowWeaponDownAnimation()
{
if (GetActiveItem().IsA('Handgun'))
{
return ThrowWeaponDownAnimationsHG[Rand(ThrowWeaponDownAnimationsHG.Length)];
return class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsHG[Rand(class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsHG.Length)];
}
else if (GetActiveItem().IsA('MachineGun'))
{
return ThrowWeaponDownAnimationsMG[Rand(ThrowWeaponDownAnimationsMG.Length)];
return class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsMG[Rand(class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsMG.Length)];
}
else if (GetActiveItem().IsA('SubMachineGun'))
{
return ThrowWeaponDownAnimationsSMG[Rand(ThrowWeaponDownAnimationsSMG.Length)];
return class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsSMG[Rand(class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsSMG.Length)];
}
else
{
assert(GetActiveItem().IsA('Shotgun'));

return ThrowWeaponDownAnimationsSG[Rand(ThrowWeaponDownAnimationsSG.Length)];
return class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsSG[Rand(class'SwatEnemyConfig'.default.ThrowWeaponDownAnimationsSG.Length)];
}
}

Expand Down Expand Up @@ -1061,13 +1067,13 @@ function bool ShouldDropWeaponInstantly()
//FullyBodyHitChance vars as a temporary hack
case EnemySkill_High:
//Chance = HighSkillComplyInstantDropChance;
Chance = HighSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.HighSkillFullBodyHitChance;
case EnemySkill_Medium:
//Chance = MediumSkillComplyInstantDropChance;
Chance = MediumSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.MediumSkillFullBodyHitChance;
case EnemySkill_Low:
//Chance = LowSkillComplyInstantDropChance;
Chance = LowSkillFullBodyHitChance;
Chance = class'SwatEnemyConfig'.default.LowSkillFullBodyHitChance;
}
return (FRand() < Chance);
}
Expand All @@ -1078,6 +1084,7 @@ function bool ShouldDropWeaponInstantly()

function BecomeAThreat()
{
ThreatTimer.StopTimer(); // don't unbecome a threat if we just became a threat
if (! bThreat)
{
// if (logTyrion)
Expand All @@ -1090,20 +1097,33 @@ function BecomeAThreat()
}
}

function UnbecomeAThreat() //Not imaginative name, I know -J21C
function UnbecomeAThreat(optional bool bAfterTime, optional float Delay) //Not imaginative name, I know -J21C
{
if (bThreat)
{
// if (logTyrion)
log(Name $ " is not a Threat anymore!");

bThreat = false;

// notify the hive that we've become a threat (so Officers deal with us appropriately)
SwatAIRepository(Level.AIRepo).GetHive().NotifyEnemyBecameThreat(self);
if(bAfterTime)
{
if(ThreatTimer == None)
{
ThreatTimer = new class'Timer';
ThreatTimer.TimerDelegate = FinishedThreatTimer;
}
ThreatTimer.StartTimer(Delay, false);
}
else
{
FinishedThreatTimer();
}
}
}

simulated function FinishedThreatTimer()
{
log(Name $ " is not a Threat anymore!");
bThreat = false;
SwatAIRepository(Level.AIRepo).GetHive().NotifyEnemyUnbecameThreat(self);
}

function bool IAmThreat()
{
return bThreat;
Expand Down Expand Up @@ -1159,11 +1179,11 @@ function float GetTimeToWaitBeforeFiring()
switch(Skill)
{
case EnemySkill_High:
return RandRange(HighSkillMinTimeBeforeShooting, HighSkillMaxTimeBeforeShooting);
return RandRange(class'SwatEnemyConfig'.default.HighSkillMinTimeBeforeShooting, class'SwatEnemyConfig'.default.HighSkillMaxTimeBeforeShooting);
case EnemySkill_Medium:
return RandRange(MediumSkillMinTimeBeforeShooting, MediumSkillMaxTimeBeforeShooting);
return RandRange(class'SwatEnemyConfig'.default.MediumSkillMinTimeBeforeShooting, class'SwatEnemyConfig'.default.MediumSkillMaxTimeBeforeShooting);
case EnemySkill_Low:
return RandRange(LowSkillMinTimeBeforeShooting, LowSkillMaxTimeBeforeShooting);
return RandRange(class'SwatEnemyConfig'.default.LowSkillMinTimeBeforeShooting, class'SwatEnemyConfig'.default.LowSkillMaxTimeBeforeShooting);
}
}

Expand All @@ -1173,13 +1193,13 @@ protected function float GetLengthOfTimeToFireFullAuto()
switch(Skill)
{
case EnemySkill_High:
return RandRange(HighSkillMinTimeToFireFullAuto, HighSkillMaxTimeToFireFullAuto);
return RandRange(class'SwatEnemyConfig'.default.HighSkillMinTimeToFireFullAuto, class'SwatEnemyConfig'.default.HighSkillMaxTimeToFireFullAuto);

case EnemySkill_Medium:
return RandRange(MediumSkillMinTimeToFireFullAuto, MediumSkillMaxTimeToFireFullAuto);
return RandRange(class'SwatEnemyConfig'.default.MediumSkillMinTimeToFireFullAuto, class'SwatEnemyConfig'.default.MediumSkillMaxTimeToFireFullAuto);

case EnemySkill_Low:
return RandRange(LowSkillMinTimeToFireFullAuto, LowSkillMaxTimeToFireFullAuto);
return RandRange(class'SwatEnemyConfig'.default.LowSkillMinTimeToFireFullAuto, class'SwatEnemyConfig'.default.LowSkillMaxTimeToFireFullAuto);
}
}

Expand Down
41 changes: 41 additions & 0 deletions Source/Game/SwatGame/Classes/AI/SwatEnemyConfig.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class SwatEnemyConfig extends Core.Object
config(AI);

var config float LowSkillAdditionalBaseAimError;
var config float MediumSkillAdditionalBaseAimError;
var config float HighSkillAdditionalBaseAimError;

var config float LowSkillMinTimeToFireFullAuto;
var config float LowSkillMaxTimeToFireFullAuto;
var config float MediumSkillMinTimeToFireFullAuto;
var config float MediumSkillMaxTimeToFireFullAuto;
var config float HighSkillMinTimeToFireFullAuto;
var config float HighSkillMaxTimeToFireFullAuto;

var config float MinDistanceToAffectMoraleOfOtherEnemiesUponDeath;

var config array<name> ThrowWeaponDownAnimationsHG;
var config array<name> ThrowWeaponDownAnimationsMG;
var config array<name> ThrowWeaponDownAnimationsSMG;
var config array<name> ThrowWeaponDownAnimationsSG;

var config float LowSkillFullBodyHitChance;
var config float MediumSkillFullBodyHitChance;
var config float HighSkillFullBodyHitChance;

var config float LowSkillMinTimeBeforeShooting;
var config float LowSkillMaxTimeBeforeShooting;
var config float MediumSkillMinTimeBeforeShooting;
var config float MediumSkillMaxTimeBeforeShooting;
var config float HighSkillMinTimeBeforeShooting;
var config float HighSkillMaxTimeBeforeShooting;

defaultproperties
{
LowSkillMinTimeBeforeShooting = 1.0
LowSkillMaxTimeBeforeShooting = 1.7
MediumSkillMinTimeBeforeShooting = 0.9
MediumSkillMaxTimeBeforeShooting = 1.3
HighSkillMinTimeBeforeShooting = 0.6
HighSkillMaxTimeBeforeShooting = 1.0
}
Loading

0 comments on commit 33ef699

Please sign in to comment.