From 490e373c7a540085e2142fd43b1c5f8f77350bcc Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 25 Jan 2018 13:58:08 +0200 Subject: [PATCH] Artifacts and monsters are allowed to spawn close to the sub if they spawn inside ruins. Fixes "could not find a suitable position" errors in levels where there's only one ruin next to the spawnpos of the sub. --- .../BarotraumaShared/Source/Events/Missions/SalvageMission.cs | 4 +++- Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs index 0d430ad10..5ae148b83 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/SalvageMission.cs @@ -46,7 +46,9 @@ namespace Barotrauma public override void Start(Level level) { - Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, Level.Loaded.Size.X * 0.3f, 30.0f); + //ruin items are allowed to spawn close to the sub + float minDistance = spawnPositionType == Level.PositionType.Ruin ? 0.0f : Level.Loaded.Size.X * 0.3f; + Vector2 position = Level.Loaded.GetRandomItemPos(spawnPositionType, 100.0f, minDistance, 30.0f); item = new Item(itemPrefab, position, null); item.MoveWithLevel = true; diff --git a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs index 9b6d2c34e..2fd6a7078 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs @@ -85,7 +85,8 @@ namespace Barotrauma if (disallowed) return null; Vector2 spawnPos; - if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, 20000.0f, out spawnPos)) + float minDist = spawnPosType == Level.PositionType.Ruin ? 0.0f : 20000.0f; + if (!Level.Loaded.TryGetInterestingPosition(true, spawnPosType, minDist, out spawnPos)) { //no suitable position found, disable the event repeat = false;