From ed0a5f0f6691c61d192a759699c776e78ade0c1a Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 12 Jun 2017 18:56:33 +0300 Subject: [PATCH] - Enemies with the "attack when provoked" setting only start attacking humans and structures if the attacker is a non-AI character or has a HumanAIController. - Characters that launch a turret get assigned as the user of the projectile (-> shooting watchers with a railgun makes them attack). - Increased watchers' attack range. --- Barotrauma/Content/Characters/Watcher/watcher.xml | 2 +- Barotrauma/Source/Characters/AI/EnemyAIController.cs | 11 +++++++---- Barotrauma/Source/Items/Components/Projectile.cs | 2 ++ Barotrauma/Source/Items/Components/Turret.cs | 5 +++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Barotrauma/Content/Characters/Watcher/watcher.xml b/Barotrauma/Content/Characters/Watcher/watcher.xml index 0baeb14b1..314af040b 100644 --- a/Barotrauma/Content/Characters/Watcher/watcher.xml +++ b/Barotrauma/Content/Characters/Watcher/watcher.xml @@ -19,7 +19,7 @@ - + diff --git a/Barotrauma/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/Source/Characters/AI/EnemyAIController.cs index 7d9315b8b..db741c14e 100644 --- a/Barotrauma/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/Source/Characters/AI/EnemyAIController.cs @@ -360,13 +360,16 @@ namespace Barotrauma updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f); coolDownTimer *= 0.1f; - if (amount > 0.1f && attackWhenProvoked) + if (amount > 0.0f && attackWhenProvoked) { - attackHumans = 100.0f; - attackRooms = 100.0f; + if (!(attacker is AICharacter) || (((AICharacter)attacker).AIController is HumanAIController)) + { + attackHumans = 100.0f; + attackRooms = 100.0f; + } } - if (attacker==null || attacker.AiTarget==null) return; + if (attacker == null || attacker.AiTarget == null) return; AITargetMemory targetMemory = FindTargetMemory(attacker.AiTarget); targetMemory.Priority += amount; } diff --git a/Barotrauma/Source/Items/Components/Projectile.cs b/Barotrauma/Source/Items/Components/Projectile.cs index c525bb5a1..9408d1c80 100644 --- a/Barotrauma/Source/Items/Components/Projectile.cs +++ b/Barotrauma/Source/Items/Components/Projectile.cs @@ -60,6 +60,8 @@ namespace Barotrauma.Items.Components { if (character != null && !characterUsable) return false; + User = character; + Launch(new Vector2( (float)Math.Cos(item.body.Rotation), (float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass); diff --git a/Barotrauma/Source/Items/Components/Turret.cs b/Barotrauma/Source/Items/Components/Turret.cs index c97085f14..5297de04e 100644 --- a/Barotrauma/Source/Items/Components/Turret.cs +++ b/Barotrauma/Source/Items/Components/Turret.cs @@ -190,7 +190,7 @@ namespace Barotrauma.Items.Components } } - Launch(projectiles[0].Item); + Launch(projectiles[0].Item, character); if (character != null) { @@ -200,7 +200,7 @@ namespace Barotrauma.Items.Components return true; } - private void Launch(Item projectile) + private void Launch(Item projectile, Character user = null) { reload = reloadTime; @@ -217,6 +217,7 @@ namespace Barotrauma.Items.Components if (projectileComponent != null) { projectileComponent.Use((float)Timing.Step); + projectileComponent.User = user; } if (projectile.Container != null) projectile.Container.RemoveContained(projectile);