Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Assets/Resources/defaults.ini.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ TerrainDistance=3
TerrainHeightmapPixelError=5
SmallerDungeons=False
CustomBooksImport=True
AssetCacheThreshold = 25
AssetCacheThreshold=25
DungeonsPoolSizeTarget=3

[Enhancements]
LypyL_GameConsole=True
Expand Down
88 changes: 73 additions & 15 deletions Assets/Scripts/Game/Questing/Place.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class Place : QuestResource
int p1; // Parameter 1
int p2; // Parameter 2
int p3; // Parameter 3
int[] alternateDungeonTypeIndices; // DFU extension for remote dungeons
bool listedSitesOnly; // DFU extension for remote dungeons

SiteDetails siteDetails; // Site found using inputs

Expand Down Expand Up @@ -143,8 +145,7 @@ public override void SetResource(string line)
base.SetResource(line);

// Match string for Place variants
string matchStr = @"(Place|place) (?<symbol>[a-zA-Z0-9_.-]+) (?<siteType>local|remote|permanent) (?<siteName>\w+)|" +
@"(Place|place) (?<symbol>[a-zA-Z0-9_.-]+) (?<siteType>randompermanent) (?<siteList>[a-zA-Z0-9_.,]+)";
string matchStr = @"(Place|place) (?<symbol>[a-zA-Z0-9_.-]+) (?<siteType>local|remote|permanent|randompermanent) (?<siteList>[a-zA-Z0-9_.,]+)(?<only> only)?";

// Try to match source line with pattern
bool randomSiteList = false;
Expand Down Expand Up @@ -182,22 +183,26 @@ public override void SetResource(string line)
throw new Exception(string.Format("Place found no site type match found for source: '{0}'. Must be local|remote|permanent.", line));
}

string only = match.Groups["only"].Value;
listedSitesOnly = (string.Compare(only, " only", true) == 0);

// Get place name for parameter lookup
name = match.Groups["siteName"].Value;
if (string.IsNullOrEmpty(name) && !randomSiteList)
{
throw new Exception(string.Format("Place site name empty for source: '{0}'", line));
}
string srcSiteList = match.Groups["siteList"].Value;
string[] siteNames = srcSiteList.Split(',');

// Pick one permanent place from random site list
if (randomSiteList)
{
string srcSiteList = match.Groups["siteList"].Value;
string[] siteNames = srcSiteList.Split(',');
if (siteNames == null || siteNames.Length == 0)
throw new Exception(string.Format("Place randompermanent must have at least one site name in source: '{0}'", line));
name = siteNames[UnityEngine.Random.Range(0, siteNames.Length)];
}
else // !randomSiteList
{
if (siteNames == null || siteNames.Length == 0)
throw new Exception(string.Format("Place site name empty for source: '{0}'", line));
name = siteNames[0];
}

// Try to read place variables from data table
Table placesTable = QuestMachine.Instance.PlacesTable;
Expand All @@ -213,6 +218,24 @@ public override void SetResource(string line)
throw new Exception(string.Format("Could not find place name in data table: '{0}'", name));
}

// Alternate places (used for remote dungeon types)
if (siteNames.Length > 1)
{
alternateDungeonTypeIndices = new int[siteNames.Length - 1];
for (int i = 1; i < siteNames.Length; i++)
{
if (placesTable.HasValue(siteNames[i]))
{
// Store value
alternateDungeonTypeIndices[i - 1] = CustomParseInt(placesTable.GetValue("p2", siteNames[i]));
}
else
{
throw new Exception(string.Format("Could not find place name in data table: '{0}'", siteNames[i]));
}
}
}

// Handle place by scope
if (scope == Scopes.Local)
{
Expand Down Expand Up @@ -770,10 +793,6 @@ void SetupRemoteSite(string line)
throw new Exception(string.Format("An unknown P1 value of {0} was encountered for Place {1}", p1, Symbol.Original));
}

// If searching for a dungeon and first numbered choice not found, then try again with any random dungeon type
if (!result && p1 == 1)
result = SelectRemoteDungeonSite(-1);

// Throw exception when remote place could not be selected, e.g. a dungeon of that type does not exist in this region
if (!result)
throw new Exception(string.Format("Search failed to locate matching remote site for Place {0} in region {1}. Resource source: '{2}'", Symbol.Original, GameManager.Instance.PlayerGPS.CurrentRegionName, line));
Expand Down Expand Up @@ -893,14 +912,53 @@ bool SelectRemoteDungeonSite(int dungeonTypeIndex)

// Get indices for all dungeons of this type
int[] foundIndices = CollectDungeonIndicesOfType(regionData, dungeonTypeIndex);

//Debug.LogFormat("Found a total of {0} possible dungeons of type {1} in {2}", foundIndices == null ? 0 : foundIndices.Length, dungeonTypeIndex, regionData.Name);

if (dungeonTypeIndex >= 0)
{
int equivalentIndex = 0;
if (foundIndices == null)
{
foundIndices = new int[] {};
}
// Add equivalence(s) if too few dungeons to select from
while (foundIndices.Length < DaggerfallUnity.Settings.DungeonsPoolSizeTarget)
{
Debug.LogFormat("Dungeon candidates list too short ({}) for proper randomization", foundIndices.Length);
if (alternateDungeonTypeIndices != null && alternateDungeonTypeIndices.Length > equivalentIndex)
{
int[] equivalentIndices = CollectDungeonIndicesOfType(regionData, alternateDungeonTypeIndices[equivalentIndex]);
if (equivalentIndices != null && equivalentIndices.Length > 0)
{
Debug.LogFormat("Adding {0} possible dungeons of type {1} by equivalence", equivalentIndices.Length, alternateDungeonTypeIndices[equivalentIndex]);
foundIndices = foundIndices.Concat(equivalentIndices).ToArray();
}
equivalentIndex++;
}
else
{
if (!listedSitesOnly)
{
// If everything failed, pick any dungeon (DFU classic behavior)
Debug.LogFormat("Falling back to picking any dungeon (classic DFU behavior)");
foundIndices = CollectDungeonIndicesOfType(regionData, -1);
}
else
{
Debug.LogFormat("No dungeon types fallback, continuing with available pool");
}
break;
}
}
}

if (foundIndices == null || foundIndices.Length == 0)
{
Debug.LogFormat("Could not find any random dungeons of type {0} in {1}", dungeonTypeIndex, regionData.Name);
return false;
}

//Debug.LogFormat("Found a total of {0} possible dungeons of type {1} in {2}", foundIndices.Length, dungeonTypeIndex, regionData.Name);

// Select a random dungeon location index from available list
int index = UnityEngine.Random.Range(0, foundIndices.Length);

Expand Down
3 changes: 3 additions & 0 deletions Assets/Scripts/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ string ReadDistributionSuffix()
public float TerrainHeightmapPixelError { get; set; }
public bool SmallerDungeons { get; set; }
public int AssetCacheThreshold { get; set; }
public int DungeonsPoolSizeTarget { get; set; }

// [Enhancements]
public bool LypyL_GameConsole { get; set; }
Expand Down Expand Up @@ -563,6 +564,7 @@ public void LoadSettings()
TerrainHeightmapPixelError = GetFloat(sectionExperimental, "TerrainHeightmapPixelError", 1, 10);
SmallerDungeons = GetBool(sectionExperimental, "SmallerDungeons");
AssetCacheThreshold = GetInt(sectionExperimental, "AssetCacheThreshold", 0, 120);
DungeonsPoolSizeTarget = GetInt(sectionExperimental, "DungeonsPoolSizeTarget", 0, 999);

LypyL_GameConsole = GetBool(sectionEnhancements, "LypyL_GameConsole");
LypyL_ModSystem = GetBool(sectionEnhancements, "LypyL_ModSystem");
Expand Down Expand Up @@ -758,6 +760,7 @@ public void SaveSettings()
SetFloat(sectionExperimental, "TerrainHeightmapPixelError", TerrainHeightmapPixelError);
SetBool(sectionExperimental, "SmallerDungeons", SmallerDungeons);
SetInt(sectionExperimental, "AssetCacheThreshold", AssetCacheThreshold);
SetInt(sectionExperimental, "DungeonsPoolSizeTarget", DungeonsPoolSizeTarget);

SetBool(sectionEnhancements, "LypyL_GameConsole", LypyL_GameConsole);
SetBool(sectionEnhancements, "LypyL_ModSystem", LypyL_ModSystem);
Expand Down
4 changes: 2 additions & 2 deletions Assets/StreamingAssets/Quests/$CUREVAM.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ Person _vamp1_ face 40 factiontype Vampire_Clan remote
Person _vamp2_ face 4 factiontype Vampire_Clan male remote
Person _hunter_ face 1 factiontype Knightly_Guard remote anyInfo 1011 rumors 1012

Place _fatherdung_ remote dungeon8
Place _wrongdung_ remote dungeon5
Place _fatherdung_ remote dungeon8 only
Place _wrongdung_ remote dungeon5,dungeon6 only

Clock _S.10_ 1.00:00 2.22:00
Clock _S.13_ 7.00:00 27.23:40
Expand Down
4 changes: 2 additions & 2 deletions Assets/StreamingAssets/Quests/$CUREWER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ Person _alchemist_ group Chemist remote
Person _father_ face 5 group Noble male remote anyInfo 1013 rumors 1014
Person _local_ group Resident1 remote

Place _mapdung_ remote dungeon4
Place _mapdung_ remote dungeon4,dungeon7 only
Place glenmorilCoven permanent GlenmorilCoven
Place _childhouse_ remote house2
Place _hintdung_ remote dungeon11
Place _hintdung_ remote dungeon11,dungeon2 only

Clock _S.05_ 7.00:00 27.23:40
Clock _huntstart_ 60.00:00 0
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/00B00Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Item _reward_ gold

Person _questgiver_ group Questor

Place _mondung_ remote dungeon9
Place _mondung_ remote dungeon9 only

Clock _1stparton_ 00:00 0 flag 17 range 0 2

Expand Down
4 changes: 2 additions & 2 deletions Assets/StreamingAssets/Quests/20C00Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ Person _questgiver_ face 112 named Molag_Bal anyInfo 1011
Person _contact_ face 233 faction The_Cabal remote anyInfo 1012
Person _dummy_ face 1 group Spellcaster remote

Place _mondung_ remote dungeon9
Place _mondung_ remote dungeon9 only
Place _tavern_ remote tavern
Place _hideout_ remote dungeon11
Place _hideout_ remote dungeon11,dungeon2 only

Clock _1stparton_ 00:00 0 flag 1 range 0 5
Clock _S.08_ 00:01 00:04
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/70C00Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Item _artifact_ artifact Sanguine_Rose anyInfo 1014
Person _questgiver_ face 112 named Sanguine anyInfo 1011
Person _contact_ face 232 faction The_Cabal remote anyInfo 1012

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7 only

Clock _1stparton_ 00:00 0 flag 1 range 2 5

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/A0C0XY04.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Person _dummymage_ face 1 faction The_Mages_Guild remote
Person _dummyorc_ face 1 named Gortwog
Person _dummydarkb_ face 49 faction The_Dark_Brotherhood remote

Place _dungeon_ remote dungeon7
Place _dungeon_ remote dungeon7,dungeon4
Place _meetingplace_ local apothecary

Clock _extratime_ 00:30 0 flag 1 range 0 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/A0C41Y18.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Person _sage_ group Cleric remote anyInfo 1050 rumors 1050
Person _giver_ group Questor
Person _dummy_ group Innkeeper remote

Place _dungeon_ remote dungeon0
Place _dungeon_ remote dungeon0 only

Clock _S.10_ 1001.00:00 0 flag 1 range 0 1

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B20Y07.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ QBN:
Person _qgiver_ group Questor
Person _local_ face 1 group Resident2 local

Place _dungeon_ remote dungeon1
Place _dungeon_ remote dungeon1 only

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B50Y11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Person _qgiver_ group Questor
Person _nobleman_ face 182 factiontype Province remote
Person _local_ face 77 group Resident2 male local

Place _dungeon_ remote dungeon11
Place _dungeon_ remote dungeon11 only

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B70Y14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Item _gold_ gold

Person _qgiver_ group Questor

Place _dungeon_ remote dungeon7
Place _dungeon_ remote dungeon7,dungeon4

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B70Y16.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ QBN:
Person _qgiver_ group Questor
Person _local_ face 93 group Resident2 male local

Place _dungeon_ remote dungeon14
Place _dungeon_ remote dungeon14 only

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B80Y17.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ QBN:
Person _qgiver_ group Questor
Person _local_ face 1 group Resident2 local

Place _dungeon_ remote dungeon0
Place _dungeon_ remote dungeon0,dungeon11

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0B81Y02.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Person _wizard_ face 1 group Spellcaster remote
Place _dungeon_ remote dungeon
Place _dungeon2_ remote dungeon
Place _mageguild_ remote magery
Place _dungeon3_ remote dungeon0
Place _dungeon3_ remote dungeon0,dungeon11 only

Clock _2dung_ 00:00 0 flag 17 range 0 2
Clock _S.30_ 180.13:20 0 flag 1 range 0 1
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/B0C00Y10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ QBN:
Person _qgiver_ group Questor
Person _local_ face 1 group Resident2 local

Place _dungeon_ remote dungeon1
Place _dungeon_ remote dungeon1 only

Clock _2dung_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/C0B00Y01.txt
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ Person _prophet_ face 1 group Local_4.0 anyInfo 1038
Person _replace_ face 3 factiontype Temple female anyInfo 1023
Person _lover_ face 104 group Group_7.0 remote anyInfo 1017

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7 only
Place _tavern_ remote tavern
Place _prophouse_ remote tavern

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/C0B00Y03.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ QBN:
Person _qgiver_ group Questor
Person _cleric_ face 105 factiontype Temple

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7

Clock _queston_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/C0B00Y14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Item _I.00_ item class 10 subclass 4
Person _questgiver_ group Questor
Person _priest_ group Cleric remote

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7 only

Clock _qtime_ 00:00 0 flag 17 range 1 5

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/E0B00Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Item _reward_ gold

Person _questgiver_ group Questor

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7

Clock _1stparton_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/H0B00Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Item _reward_ gold

Person _questgiver_ group Questor

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7 only

Clock _1stparton_ 00:00 0 flag 17 range 0 2

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/K0C00Y02.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Item _I.07_ gold
Person _qgiver_ group Questor

Place _depository_ remote bank
Place _mondung_ remote dungeon2
Place _mondung_ remote dungeon2,dungeon15 only
Place _palace_ remote palace
Place _mansion_ remote house1

Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/K0C00Y05.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ Person _qgiver_ group Questor
Person _knight_ face 216 faction The_Fighters_Guild remote
Person _child_ faction Children female

Place _mondung_ remote dungeon1
Place _mondung_ remote dungeon1 only
Place _childlocale_ local house2

Clock _queston_ 00:00 0 flag 17 range 0 5
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/K0C01Y00.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Person _victim_ face 1 group Group_7.0
Person _tg_ faction The_Thieves_Guild local

Place _mondung_ remote dungeon
Place _mondung2_ remote dungeon2
Place _mondung2_ remote dungeon2,dungeon15 only

Clock _queston1_ 00:00 0 flag 17 range 0 2
Clock _S.05_ 08:20 3.11:20
Expand Down
2 changes: 1 addition & 1 deletion Assets/StreamingAssets/Quests/K0C01Y10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Item _bothdorjii_ letter used 1011

Person _qgiver_ group Questor

Place _mondung_ remote dungeon4
Place _mondung_ remote dungeon4,dungeon7 only

Clock _queston_ 00:00 0 flag 17 range 0 2

Expand Down
Loading