public override void Tick(Quest caller)
        {
            base.Tick(caller);

            // Auto-assign NPC to home Place if available and player enters
            // This only happens for very specific NPC types
            // Equivalent to calling "place anNPC at aPlace" from script
            // Will not be called again as assignment is permanent for duration of quest
            if (homePlaceSymbol != null && !assignedToHome)
            {
                Place home = ParentQuest.GetPlace(homePlaceSymbol);
                if (home == null)
                {
                    return;
                }

                if (home.IsPlayerHere())
                {
                    // Create SiteLink if not already present
                    if (!QuestMachine.HasSiteLink(ParentQuest, homePlaceSymbol))
                    {
                        QuestMachine.CreateSiteLink(ParentQuest, homePlaceSymbol);
                    }

                    // Hot-place NPC at this location
                    home.AssignQuestResource(Symbol);
                    assignedToHome = true;
                }
            }
        }
        /// <summary>
        /// Places NPC to home. This can happen automatically when player enters building or when
        /// quest script uses "create npc" action to automatically assign Person to home.
        /// </summary>
        public bool PlaceAtHome()
        {
            // Does not attempt to place a questor as they should be statically place or moved manually
            Place homePlace = ParentQuest.GetPlace(homePlaceSymbol);

            if (homePlace == null || isQuestor)
            {
                return(false);
            }

            // Create SiteLink if not already present
            if (!QuestMachine.HasSiteLink(ParentQuest, homePlaceSymbol))
            {
                QuestMachine.CreateSiteLink(ParentQuest, homePlaceSymbol);
            }

            // Assign to home place
            homePlace.AssignQuestResource(Symbol);
            SetAssignedPlaceSymbol(homePlace.Symbol);
            assignedToHome = true;

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Places NPC to home. This can happen automatically when player enters building or when
        /// quest script uses "create npc" action to automatically assign Person to home.
        /// </summary>
        public bool PlaceAtHome()
        {
            // Does not attempt to place a questor as they should be statically placed or moved manually
            // Individual NPCs are also excluded as they are either automatically at home or moved elsewhere by quest
            Place homePlace = ParentQuest.GetPlace(homePlaceSymbol);

            if (homePlace == null || isQuestor || isIndividualNPC)
            {
                return(false);
            }

            // Create SiteLink if not already present
            if (!QuestMachine.HasSiteLink(ParentQuest, homePlaceSymbol))
            {
                QuestMachine.CreateSiteLink(ParentQuest, homePlaceSymbol);
            }

            // Assign to home place
            homePlace.AssignQuestResource(Symbol);
            SetAssignedPlaceSymbol(homePlace.Symbol);
            assignedToHome = true;

            return(true);
        }
Exemple #4
0
        public override void Update(Task caller)
        {
            base.Update(caller);

            // Do nothing while player respawning
            if (GameManager.Instance.PlayerEnterExit.IsRespawning)
            {
                return;
            }

            // Handle resume on next tick of action after respawn process complete
            if (resumePending)
            {
                GameObject player = GameManager.Instance.PlayerObject;
                player.transform.position = resumePosition;
                resumePending             = false;
                SetComplete();
                return;
            }

            // Create SiteLink if not already present
            if (!QuestMachine.HasSiteLink(ParentQuest, targetPlace))
            {
                QuestMachine.CreateSiteLink(ParentQuest, targetPlace);
            }

            // Attempt to get Place resource
            Place place = ParentQuest.GetPlace(targetPlace);

            if (place == null)
            {
                return;
            }

            // Get selected spawn QuestMarker for this Place
            bool        usingMarker = false;
            QuestMarker marker      = new QuestMarker();

            if (targetMarker >= 0 && targetMarker < place.SiteDetails.questSpawnMarkers.Length)
            {
                marker      = place.SiteDetails.questSpawnMarkers[targetMarker];
                usingMarker = true;
            }

            // Attempt to get location data - using GetLocation(regionName, locationName) as it can support all locations
            DFLocation location;

            if (!DaggerfallUnity.Instance.ContentReader.GetLocation(place.SiteDetails.regionName, place.SiteDetails.locationName, out location))
            {
                return;
            }

            // Spawn inside dungeon at this world position
            DFPosition mapPixel = MapsFile.LongitudeLatitudeToMapPixel((int)location.MapTableData.Longitude, location.MapTableData.Latitude);
            DFPosition worldPos = MapsFile.MapPixelToWorldCoord(mapPixel.X, mapPixel.Y);

            GameManager.Instance.PlayerEnterExit.RespawnPlayer(
                worldPos.X,
                worldPos.Y,
                true,
                true);

            // Determine start position
            if (usingMarker)
            {
                // Use specified quest marker
                Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide);
                resumePosition = dungeonBlockPosition + marker.flatPosition;
            }
            else
            {
                // Use first quest marker
                marker = place.SiteDetails.questSpawnMarkers[0];
                Vector3 dungeonBlockPosition = new Vector3(marker.dungeonX * RDBLayout.RDBSide, 0, marker.dungeonZ * RDBLayout.RDBSide);
                resumePosition = dungeonBlockPosition + marker.flatPosition;
            }

            resumePending = true;
        }