/// <summary>
        /// Returns a modifier on travel time based on the quality of starting or arrival port.
        /// The reasoning here is that traveling between two major ports will be fast, because a lot of ships
        /// are sailing that route directly. Meanwhile, to sail from or to some forgotten fishing hamlet
        /// will necessarily include waiting for ships to leave and jumping ship once or twice because nobody
        /// is serving the route directly or regularly.
        /// </summary>
        /// <param name="startLocation"></param>
        /// <param name="endLocation"></param>
        /// <returns></returns>
        float GetLocationTraveltimeModifier(DFRegion.LocationTypes startLocation, DFRegion.LocationTypes endLocation)
        {
            var modifier = 1f;

            if (startLocation == DFRegion.LocationTypes.Tavern ||
                endLocation == DFRegion.LocationTypes.Tavern)
            {
                modifier += 0.1f;
            }

            if (startLocation == DFRegion.LocationTypes.TownVillage ||
                endLocation == DFRegion.LocationTypes.TownVillage ||
                startLocation == DFRegion.LocationTypes.ReligionTemple ||
                endLocation == DFRegion.LocationTypes.ReligionTemple)
            {
                modifier += 0.2f;
            }

            if (startLocation == DFRegion.LocationTypes.TownHamlet ||
                endLocation == DFRegion.LocationTypes.TownHamlet ||
                startLocation == DFRegion.LocationTypes.HomeWealthy ||
                endLocation == DFRegion.LocationTypes.HomeWealthy)
            {
                modifier += 0.3f;
            }

            return(modifier);
        }
Example #2
0
        void AssignHomeTown()
        {
            // If this is a Questor or individual NPC then use current location name
            // Person is being instantiated where player currently is
            if (isQuestor || (IsIndividualNPC && isIndividualAtHome))
            {
                if (GameManager.Instance.PlayerGPS.HasCurrentLocation)
                {
                    homeTownName = GameManager.Instance.PlayerGPS.CurrentLocation.Name;
                    return;
                }
            }

            // Find a random location name from town types
            // This might take a few attempts but will very quickly find a random town name
            int      index;
            bool     found       = false;
            int      regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
            DFRegion regionData  = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetRegion(regionIndex);

            while (!found)
            {
                index = UnityEngine.Random.Range(0, regionData.MapTable.Length);
                DFRegion.LocationTypes locationType = regionData.MapTable[index].LocationType;
                if (locationType == DFRegion.LocationTypes.TownCity ||
                    locationType == DFRegion.LocationTypes.TownHamlet ||
                    locationType == DFRegion.LocationTypes.TownVillage)
                {
                    homeTownName = regionData.MapNames[index];
                    found        = true;
                }
            }
        }
Example #3
0
        private void UpdateWorldInfo(int x, int y)
        {
            // Requires MAPS.BSA connection
            if (dfUnity.ContentReader.MapFileReader == null)
            {
                return;
            }

            // Get climate and politic data
            currentClimateIndex = dfUnity.ContentReader.MapFileReader.GetClimateIndex(x, y);
            currentPoliticIndex = dfUnity.ContentReader.MapFileReader.GetPoliticIndex(x, y);
            climateSettings     = MapsFile.GetWorldClimateSettings(currentClimateIndex);
            if (currentPoliticIndex > 128)
            {
                regionName = dfUnity.ContentReader.MapFileReader.GetRegionName(currentPoliticIndex - 128);
            }
            else if (currentPoliticIndex == 64)
            {
                regionName = "Ocean";
            }
            else
            {
                regionName = "Unknown";
            }

            // Get region data
            currentRegion = dfUnity.ContentReader.MapFileReader.GetRegion(CurrentRegionIndex);

            // Get location data
            ContentReader.MapSummary mapSummary;
            if (dfUnity.ContentReader.HasLocation(x, y, out mapSummary))
            {
                currentLocation    = dfUnity.ContentReader.MapFileReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex);
                hasCurrentLocation = true;
                CalculateWorldLocationRect();
            }
            else
            {
                currentLocation    = new DFLocation();
                hasCurrentLocation = false;
                ClearWorldLocationRect();
            }

            // Get location type
            if (hasCurrentLocation)
            {
                if (currentRegion.MapTable == null)
                {
                    DaggerfallUnity.LogMessage(string.Format("PlayerGPS: Location {0} in region{1} has a null MapTable.", currentLocation.Name, currentLocation.RegionName));
                }
                else
                {
                    currentLocationType = currentRegion.MapTable[mapSummary.MapIndex].LocationType;
                }
            }
        }
 private void PlayerGPS_OnEnterLocationRect(DFLocation location)
 {
     previousLocationType = currentLocationType;
     if (location.Loaded)
     {
         currentLocationType = location.MapTableData.LocationType;
     }
     else
     {
         currentLocationType = DFRegion.LocationTypes.None;
     }
 }
Example #5
0
        void AssignHomeTown()
        {
            const string blank = "BLANK";

            // If this is a Questor or individual NPC then use current location name
            // Person is being instantiated where player currently is
            if (isQuestor || (IsIndividualNPC && isIndividualAtHome))
            {
                if (GameManager.Instance.PlayerGPS.HasCurrentLocation)
                {
                    homeTownName     = GameManager.Instance.PlayerGPS.CurrentLocation.Name;
                    homeRegionName   = GameManager.Instance.PlayerGPS.CurrentLocation.RegionName;
                    homeBuildingName = blank;
                    return;
                }
            }

            // Handle specific home Place assigned at create time
            if (homePlaceSymbol != null)
            {
                Place home = ParentQuest.GetPlace(homePlaceSymbol);
                if (home != null)
                {
                    homeTownName     = home.SiteDetails.locationName;
                    homeRegionName   = home.SiteDetails.regionName;
                    homeBuildingName = home.SiteDetails.buildingName;
                }
            }
            else
            {
                // Find a random location name from town types for flavour text
                // This might take a few attempts but will very quickly find a random town name
                int      index;
                bool     found       = false;
                int      regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex;
                DFRegion regionData  = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetRegion(regionIndex);
                while (!found)
                {
                    index = UnityEngine.Random.Range(0, regionData.MapTable.Length);
                    DFRegion.LocationTypes locationType = regionData.MapTable[index].LocationType;
                    if (locationType == DFRegion.LocationTypes.TownCity ||
                        locationType == DFRegion.LocationTypes.TownHamlet ||
                        locationType == DFRegion.LocationTypes.TownVillage)
                    {
                        homeTownName     = regionData.MapNames[index];
                        homeRegionName   = regionData.Name;
                        homeBuildingName = blank;
                        found            = true;
                    }
                }
            }
        }
Example #6
0
        public override void RestoreSaveData(object dataIn)
        {
            if (dataIn == null)
            {
                return;
            }

            SaveData_v1 data = (SaveData_v1)dataIn;

            onEnter              = data.onEnter;
            sourceExteriorType   = data.sourceExteriorType;
            indexExteriorType    = data.indexExteriorType;
            currentLocationType  = data.currentLocationType;
            previousLocationType = data.previousLocationType;
        }
Example #7
0
        /// <summary>
        /// Checks if location is one of the dungeon types.
        /// </summary>
        bool IsDungeonType(DFRegion.LocationTypes locationType)
        {
            // Consider 3 major dungeon types and 2 graveyard types as dungeons
            // Will exclude locations with dungeons, such as Daggerfall, Wayrest, Sentinel
            if (locationType == DFRegion.LocationTypes.DungeonKeep ||
                locationType == DFRegion.LocationTypes.DungeonLabyrinth ||
                locationType == DFRegion.LocationTypes.DungeonRuin ||
                locationType == DFRegion.LocationTypes.GraveyardCommon ||
                locationType == DFRegion.LocationTypes.GraveyardForgotten)
            {
                return(true);
            }

            return(false);
        }
Example #8
0
 public static bool checkIfLocationTypeAlwaysKnown(DFRegion.LocationTypes locationType)
 {
     if (locationType == DFRegion.LocationTypes.GraveyardCommon ||
         locationType == DFRegion.LocationTypes.HomeFarms ||
         locationType == DFRegion.LocationTypes.HomePoor ||
         locationType == DFRegion.LocationTypes.HomeWealthy ||
         locationType == DFRegion.LocationTypes.ReligionCult ||
         locationType == DFRegion.LocationTypes.ReligionTemple ||
         locationType == DFRegion.LocationTypes.Tavern ||
         locationType == DFRegion.LocationTypes.TownCity ||
         locationType == DFRegion.LocationTypes.TownHamlet ||
         locationType == DFRegion.LocationTypes.TownVillage)
     {
         return(true);
     }
     return(false);
 }
Example #9
0
        private void UpdateWorldInfo(int x, int y)
        {
            // Get climate and politic data
            currentClimateIndex = dfUnity.ContentReader.MapFileReader.GetClimateIndex(x, y);
            currentPoliticIndex = dfUnity.ContentReader.MapFileReader.GetPoliticIndex(x, y);
            climateSettings     = MapsFile.GetWorldClimateSettings(currentClimateIndex);
            if (currentPoliticIndex > 128)
            {
                regionName = dfUnity.ContentReader.MapFileReader.GetRegionName(currentPoliticIndex - 128);
            }
            else if (currentPoliticIndex == 64)
            {
                regionName = "Ocean";
            }
            else
            {
                regionName = "Unknown";
            }

            // Get region data
            currentRegion = dfUnity.ContentReader.MapFileReader.GetRegion(CurrentRegionIndex);

            // Get location data
            ContentReader.MapSummary mapSummary;
            if (dfUnity.ContentReader.HasLocation(x, y, out mapSummary))
            {
                currentLocation    = dfUnity.ContentReader.MapFileReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex);
                hasCurrentLocation = true;
                CalculateWorldLocationRect();
            }
            else
            {
                currentLocation    = new DFLocation();
                hasCurrentLocation = false;
                ClearWorldLocationRect();
            }

            // Get location type
            if (hasCurrentLocation)
            {
                currentLocationType = currentRegion.MapTable[mapSummary.MapIndex].Type;
            }
        }
        void EnumerateLocationsByType(SearchPatterns pattern)
        {
            locationNames.Clear();

            if (regionData.LocationCount == 0)
            {
                ReloadCurrentRegion();
            }

            for (int i = 0; i < regionData.LocationCount; i++)
            {
                bool addName = false;
                DFRegion.LocationTypes type = regionData.MapTable[i].LocationType;
                switch (pattern)
                {
                case SearchPatterns.All:
                    addName = true;
                    break;

                case SearchPatterns.Cities:
                    if (type == DFRegion.LocationTypes.TownCity ||
                        type == DFRegion.LocationTypes.TownHamlet ||
                        type == DFRegion.LocationTypes.TownVillage)
                    {
                        addName = true;
                    }
                    break;

                case SearchPatterns.Dungeons:
                    if (type == DFRegion.LocationTypes.DungeonKeep ||
                        type == DFRegion.LocationTypes.DungeonLabyrinth ||
                        type == DFRegion.LocationTypes.DungeonRuin)
                    {
                        addName = true;
                    }
                    break;

                case SearchPatterns.Graveyards:
                    if (type == DFRegion.LocationTypes.GraveyardCommon ||
                        type == DFRegion.LocationTypes.GraveyardForgotten)
                    {
                        addName = true;
                    }
                    break;

                case SearchPatterns.Homes:
                    if (type == DFRegion.LocationTypes.HomeFarms ||
                        type == DFRegion.LocationTypes.HomePoor ||
                        type == DFRegion.LocationTypes.HomeWealthy ||
                        type == DFRegion.LocationTypes.HomeYourShips)
                    {
                        addName = true;
                    }
                    break;

                case SearchPatterns.Taverns:
                    if (type == DFRegion.LocationTypes.Tavern)
                    {
                        addName = true;
                    }
                    break;

                case SearchPatterns.Temples:
                    if (type == DFRegion.LocationTypes.ReligionCoven ||
                        type == DFRegion.LocationTypes.ReligionCult ||
                        type == DFRegion.LocationTypes.ReligionTemple)
                    {
                        addName = true;
                    }
                    break;
                }
                if (addName)
                {
                    locationNames.Add(regionData.MapNames[i]);
                }
            }

            locationNames.Sort();
        }
Example #11
0
 bool IsLocationLarge(DFRegion.LocationTypes locationType)
 {
     return(locationType == DFRegion.LocationTypes.TownCity || locationType == DFRegion.LocationTypes.TownHamlet || onlyLargeDots);
 }
 private void PlayerGPS_OnExitLocationRect()
 {
     previousLocationType = currentLocationType;
     currentLocationType  = DFRegion.LocationTypes.None;
 }
Example #13
0
        private void UpdateWorldInfo(int x, int y)
        {
            // Requires MAPS.BSA connection
            if (dfUnity.ContentReader.MapFileReader == null)
                return;

            // Get climate and politic data
            currentClimateIndex = dfUnity.ContentReader.MapFileReader.GetClimateIndex(x, y);
            currentPoliticIndex = dfUnity.ContentReader.MapFileReader.GetPoliticIndex(x, y);
            climateSettings = MapsFile.GetWorldClimateSettings(currentClimateIndex);
            if (currentPoliticIndex > 128)
                regionName = dfUnity.ContentReader.MapFileReader.GetRegionName(currentPoliticIndex - 128);
            else if (currentPoliticIndex == 64)
                regionName = "Ocean";
            else
                regionName = "Unknown";

            // Get region data
            currentRegion = dfUnity.ContentReader.MapFileReader.GetRegion(CurrentRegionIndex);

            // Get location data
            ContentReader.MapSummary mapSummary;
            if (dfUnity.ContentReader.HasLocation(x, y, out mapSummary))
            {
                currentLocation = dfUnity.ContentReader.MapFileReader.GetLocation(mapSummary.RegionIndex, mapSummary.MapIndex);
                hasCurrentLocation = true;
                CalculateWorldLocationRect();
            }
            else
            {
                currentLocation = new DFLocation();
                hasCurrentLocation = false;
                ClearWorldLocationRect();
            }

            // Get location type
            if (hasCurrentLocation)
            {
                if (currentRegion.MapTable == null)
                {
                    DaggerfallUnity.LogMessage(string.Format("PlayerGPS: Location {0} in region{1} has a null MapTable.", currentLocation.Name, currentLocation.RegionName));
                }
                else
                {
                    currentLocationType = currentRegion.MapTable[mapSummary.MapIndex].LocationType;
                }
            }
        }