From 33ef69966dce9b96dfa349aba4c3ce62a2e52015 Mon Sep 17 00:00:00 2001 From: T-MaxWiese-T Date: Sat, 13 Mar 2021 21:20:54 +0100 Subject: [PATCH] v7.1(Beta) Update --- .../Classes/Actions/ComplianceAction.uc | 5 +- .../Classes/Actions/FleeAction.uc | 4 +- .../Classes/Actions/StunnedAction.uc | 4 +- .../Game/SwatAICommon/Classes/ISwatEnemy.uc | 2 +- .../SwatGame/Classes/AI/SwatAICharacter.uc | 2 +- Source/Game/SwatGame/Classes/AI/SwatEnemy.uc | 100 +++++++++++------- .../SwatGame/Classes/AI/SwatEnemyConfig.uc | 41 +++++++ System/AI.ini | 55 ++++++++-- System/SwatPawn.ini | 39 +------ 9 files changed, 158 insertions(+), 94 deletions(-) create mode 100644 Source/Game/SwatGame/Classes/AI/SwatEnemyConfig.uc diff --git a/Source/Game/SwatAICommon/Classes/Actions/ComplianceAction.uc b/Source/Game/SwatAICommon/Classes/Actions/ComplianceAction.uc index d27201e..b381e93 100644 --- a/Source/Game/SwatAICommon/Classes/Actions/ComplianceAction.uc +++ b/Source/Game/SwatAICommon/Classes/Actions/ComplianceAction.uc @@ -38,6 +38,8 @@ var private bool bJustComplied; const kPostComplianceGoalPriority = 91; // lower than being stunned or shot +var config float ThreatCooldown; + /////////////////////////////////////////////////////////////////////////////// // // Init / Cleanup @@ -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); } } } @@ -244,4 +246,5 @@ state Running defaultproperties { satisfiesGoal=class'ComplianceGoal' + ThreatCooldown=2.0 } diff --git a/Source/Game/SwatAICommon/Classes/Actions/FleeAction.uc b/Source/Game/SwatAICommon/Classes/Actions/FleeAction.uc index 499a2b3..26722f7 100644 --- a/Source/Game/SwatAICommon/Classes/Actions/FleeAction.uc +++ b/Source/Game/SwatAICommon/Classes/Actions/FleeAction.uc @@ -30,6 +30,7 @@ var config private float MaxAggressiveFleePercentageChance; var private DistanceToOfficersSensor DistanceToOfficersSensor; var private bool bUseDistanceToOfficersSensor; +var config private float ThreatCooldown; /////////////////////////////////////////////////////////////////////////////// // @@ -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(); @@ -443,4 +444,5 @@ Begin: defaultproperties { satisfiesGoal = class'EngageOfficerGoal' + ThreatCooldown = 2.0 } diff --git a/Source/Game/SwatAICommon/Classes/Actions/StunnedAction.uc b/Source/Game/SwatAICommon/Classes/Actions/StunnedAction.uc index 981adf5..68f0a1d 100644 --- a/Source/Game/SwatAICommon/Classes/Actions/StunnedAction.uc +++ b/Source/Game/SwatAICommon/Classes/Actions/StunnedAction.uc @@ -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; @@ -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')) @@ -714,4 +715,5 @@ defaultproperties { satisfiesGoal = class'StunnedGoal' MinRequiredFleeDistanceFromOfficer = 200.0 + ThreatCooldown = 2.0 } diff --git a/Source/Game/SwatAICommon/Classes/ISwatEnemy.uc b/Source/Game/SwatAICommon/Classes/ISwatEnemy.uc index 31e9071..491eea7 100644 --- a/Source/Game/SwatAICommon/Classes/ISwatEnemy.uc +++ b/Source/Game/SwatAICommon/Classes/ISwatEnemy.uc @@ -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); /////////////////////////////////////////////////////////////////////////////// // diff --git a/Source/Game/SwatGame/Classes/AI/SwatAICharacter.uc b/Source/Game/SwatGame/Classes/AI/SwatAICharacter.uc index 169bdaa..158be0a 100644 --- a/Source/Game/SwatGame/Classes/AI/SwatAICharacter.uc +++ b/Source/Game/SwatGame/Classes/AI/SwatAICharacter.uc @@ -251,7 +251,7 @@ protected function bool ShouldReactToNonLethals() /////////////////////////////////////// -function UnbecomeAThreat(); +function UnbecomeAThreat(optional bool UseCooldown, optional float CooldownDuration); /////////////////////////////////////////////////////////////////////////////// diff --git a/Source/Game/SwatGame/Classes/AI/SwatEnemy.uc b/Source/Game/SwatGame/Classes/AI/SwatEnemy.uc index 49afa01..43b0e12 100644 --- a/Source/Game/SwatGame/Classes/AI/SwatEnemy.uc +++ b/Source/Game/SwatGame/Classes/AI/SwatEnemy.uc @@ -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 ThrowWeaponDownAnimationsHG; var config array ThrowWeaponDownAnimationsMG; var config array ThrowWeaponDownAnimationsSMG; @@ -53,12 +56,15 @@ var config array ThrowWeaponDownAnimationsSG; var config float LowSkillFullBodyHitChance; var config float MediumSkillFullBodyHitChance; var config float HighSkillFullBodyHitChance; +*/ +var array unused8; +var array unused9; +var array unused10; +var array 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; @@ -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; } @@ -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')) @@ -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)]; } } @@ -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); } @@ -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) @@ -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; @@ -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); } } @@ -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); } } diff --git a/Source/Game/SwatGame/Classes/AI/SwatEnemyConfig.uc b/Source/Game/SwatGame/Classes/AI/SwatEnemyConfig.uc new file mode 100644 index 0000000..436f12d --- /dev/null +++ b/Source/Game/SwatGame/Classes/AI/SwatEnemyConfig.uc @@ -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 ThrowWeaponDownAnimationsHG; +var config array ThrowWeaponDownAnimationsMG; +var config array ThrowWeaponDownAnimationsSMG; +var config array 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 +} \ No newline at end of file diff --git a/System/AI.ini b/System/AI.ini index c9e1f92..9faae1f 100644 --- a/System/AI.ini +++ b/System/AI.ini @@ -855,14 +855,47 @@ WildGunnerSweepSpeed=0.20f ;; ;; Some new SEF stuff ;; - -[SwatGame.SwatEnemyBase] - -; These are a new set of timers, to add reaction time to the AI. -; These are cumulative with the amount of time necessary to aim -LowSkillMinTimeBeforeShooting = 5 -LowSkillMaxTimeBeforeShooting = 10 -MediumSkillMinTimeBeforeShooting = 5 -MediumSkillMaxTimeBeforeShooting = 10 -HighSkillMinTimeBeforeShooting = 5 -HighSkillMaxTimeBeforeShooting = 10 +[SwatGame.SwatEnemyConfig] +; Base Aim Error by Skill Level +LowSkillAdditionalBaseAimError=10.0 +MediumSkillAdditionalBaseAimError=8.0 +HighSkillAdditionalBaseAimError=3.0 + +; minimum 2d distance between us and another enemy to affect their morale +; also does a line of sight check +MinDistanceToAffectMoraleOfOtherEnemiesUponDeath=500.0 + +; Range of time per skill level that an Enemy will fire full auto for +LowSkillMinTimeToFireFullAuto=1.0 +LowSkillMaxTimeToFireFullAuto=2.0 +MediumSkillMinTimeToFireFullAuto=0.6 +MediumSkillMaxTimeToFireFullAuto=1.0 +HighSkillMinTimeToFireFullAuto=0.2 +HighSkillMaxTimeToFireFullAuto=1.3 + +; animations used for throwing weapons down when they're empty +ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG1 +ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG2 +ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG3 + +ThrowWeaponDownAnimationsSMG=OutOfAmmoDropSMG1 +ThrowWeaponDownAnimationsSMG=OutOfAmmoDropSMG2 + +ThrowWeaponDownAnimationsMG=OutOfAmmoDropMG1 +ThrowWeaponDownAnimationsMG=OutOfAmmoDropMG2 + +ThrowWeaponDownAnimationsSG=OutOfAmmoDropSG1 +ThrowWeaponDownAnimationsSG=OutOfAmmoDropSG2 + +; chance that we will play a full body hit animation +HighSkillFullBodyHitChance=0.2 +MediumSkillFullBodyHitChance=0.7 +LowSkillFullBodyHitChance=0.8 + +; SEF-introduced delay before firing a weapon +LowSkillMinTimeBeforeShooting = 1.0 +LowSkillMaxTimeBeforeShooting = 1.7 +MediumSkillMinTimeBeforeShooting = 0.9 +MediumSkillMaxTimeBeforeShooting = 1.3 +HighSkillMinTimeBeforeShooting = 0.6 +HighSkillMaxTimeBeforeShooting = 1.0 \ No newline at end of file diff --git a/System/SwatPawn.ini b/System/SwatPawn.ini index 558fbd1..7c86b3e 100644 --- a/System/SwatPawn.ini +++ b/System/SwatPawn.ini @@ -116,6 +116,7 @@ StingViewEffectAmplitude=(Roll=9000,Pitch=9000,Yaw=9000) ;in input units per second StingInputEffectMagnitude=9 + ;*********************** ;Leaning tuning ;*********************** @@ -409,44 +410,6 @@ LowSkillAdditionalBaseAimError=10.0 MediumSkillAdditionalBaseAimError=8.0 HighSkillAdditionalBaseAimError=3.0 -; minimum 2d distance between us and another enemy to affect their morale -; also does a line of sight check -MinDistanceToAffectMoraleOfOtherEnemiesUponDeath=500.0 - -; Range of time per skill level that an Enemy will fire full auto for -LowSkillMinTimeToFireFullAuto=1.0 -LowSkillMaxTimeToFireFullAuto=2.0 -MediumSkillMinTimeToFireFullAuto=0.6 -MediumSkillMaxTimeToFireFullAuto=1.0 -HighSkillMinTimeToFireFullAuto=0.2 -HighSkillMaxTimeToFireFullAuto=1.3 - -; animations used for throwing weapons down when they're empty -ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG1 -ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG2 -ThrowWeaponDownAnimationsHG=OutOfAmmoDropHG3 - -ThrowWeaponDownAnimationsSMG=OutOfAmmoDropSMG1 -ThrowWeaponDownAnimationsSMG=OutOfAmmoDropSMG2 - -ThrowWeaponDownAnimationsMG=OutOfAmmoDropMG1 -ThrowWeaponDownAnimationsMG=OutOfAmmoDropMG2 - -ThrowWeaponDownAnimationsSG=OutOfAmmoDropSG1 -ThrowWeaponDownAnimationsSG=OutOfAmmoDropSG2 - -; chance that we will play a full body hit animation -HighSkillFullBodyHitChance=0.2 -MediumSkillFullBodyHitChance=0.7 -LowSkillFullBodyHitChance=0.8 - -; chance that we will drop weapons instantly when complying -; Unused at the moment; can't seem to compile SwatEnemy with new config vars -; For now, reusing the FullBodyHitChance vars as a substitute. -K.F. -;HighSkillComplyInstantDropChance=0.7 -;MediumSkillComplyInstantDropChance=0.8 -;LowSkillComplyInstantDropChance=0.9 - [SwatGame.SwatWildGunner] ; Range of time per skill level that an Enemy will fire full auto for LowSkillMinTimeToFireFullAuto=3.0