/// <summary> /// Gets home Place resource assigned to this NPC (if any). /// </summary> /// <returns>Home Place resource or null.</returns> public Place GetHomePlace() { if (homePlaceSymbol != null) { return(ParentQuest.GetPlace(homePlaceSymbol)); } return(null); }
public override void Update(Task caller) { base.Update(caller); // Create SiteLink if not already present if (!QuestMachine.HasSiteLink(ParentQuest, placeSymbol)) { QuestMachine.CreateSiteLink(ParentQuest, placeSymbol); } // Attempt to get Person resource Person person = ParentQuest.GetPerson(npcSymbol); if (person == null) { SetComplete(); throw new Exception(string.Format("Could not find Person resource symbol {0}", npcSymbol)); } // Do nothing if Person is destroyed if (person.IsDestroyed) { SetComplete(); return; } // Attempt to get Place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { SetComplete(); throw new Exception(string.Format("Could not find Place resource symbol {0}", placeSymbol)); } // Is target an individual NPC that is supposed to be at home // Daggerfall never seems to use "create npc at" or "place npc" for "athome" NPCs // Treating this as an error and logging as such, but don't throw an exception // Just log, terminate action, and get out of dodge if (person.IsIndividualNPC && person.IsIndividualAtHome) { Debug.LogErrorFormat("Quest tried to place Person {0} [_{1}_] at Place _{2}_ but they are supposed to be atHome", person.DisplayName, person.Symbol.Name, place.Symbol.Name); SetComplete(); return; } // Assign Person to Place place.AssignQuestResource(person.Symbol, marker); person.SetAssignedPlaceSymbol(placeSymbol); // Person is also unhidden when placed person.IsHidden = false; TalkManager.Instance.ForceTopicListsUpdate(); SetComplete(); }
public override bool CheckTrigger(Task caller) { // Always return true once owning Task is triggered // Another action will need to rearm/unset this task if another click is required // This seems to fit how classic works based on current observation if (caller.IsTriggered) { return(true); } // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return(false); } // Attempt to get Place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return(false); } // Watch item item.ActionWatching = true; // Allow drop only when player at correct location if (place.IsPlayerHere()) { item.AllowDrop = true; } else { item.AllowDrop = false; return(false); } // Handle player dropped if (item.PlayerDropped) { // Show text if (textId != 0 && !textShown) { ParentQuest.ShowMessagePopup(textId); textShown = true; } SetComplete(); return(true); } return(false); }
public override void Update(Task caller) { // Get related Location resource Place place = ParentQuest.GetPlace(placeSymbol); // Get related Person resource Person person = ParentQuest.GetPerson(npcSymbol); // Get related Item resource Item item = ParentQuest.GetItem(itemSymbol); string namePlace = "", namePerson = "", nameItem = ""; // first create dialog link for just the separated resources (which will hide them) if (place != null) { /* * namePlace = place.SiteDetails.buildingName; // use building name as default * if (namePlace == null) // no building? * namePlace = place.SiteDetails.locationName; // use dungeon name */ GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, place.Symbol.Name, TalkManager.QuestInfoResourceType.Location); } if (person != null) { namePerson = person.DisplayName; GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, person.Symbol.Name, TalkManager.QuestInfoResourceType.Person); } if (item != null) { nameItem = item.DaggerfallUnityItem.ItemName; GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, item.Symbol.Name, TalkManager.QuestInfoResourceType.Thing); } // then create dialog links between the resources if ((place != null) && (person != null)) { // register both links (location -> person as well as person -> location) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location, namePerson, TalkManager.QuestInfoResourceType.Person); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person, namePlace, TalkManager.QuestInfoResourceType.Location); } if ((place != null) && (item != null)) { // register both links (location -> item as well as item -> location) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location, nameItem, TalkManager.QuestInfoResourceType.Thing); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing, namePlace, TalkManager.QuestInfoResourceType.Location); } if ((person != null) && (item != null)) { // register both links (person -> item as well as item -> person) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person, nameItem, TalkManager.QuestInfoResourceType.Thing); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing, namePerson, TalkManager.QuestInfoResourceType.Person); } SetComplete(); }
public override void Update(Task caller) { // Get related Location resource Place place = ParentQuest.GetPlace(placeSymbol); // Get related Person resource Person person = ParentQuest.GetPerson(npcSymbol); // Get related Item resource Item item = ParentQuest.GetItem(itemSymbol); string namePlace = "", namePerson = "", nameItem = ""; // first create dialog link for just the separated resources (which will hide them) if (place != null) { namePlace = place.SiteDetails.locationName; if (namePlace == null) { namePlace = place.Name; // workaround to prevent exception, TODO: correct name resolving for local houses/residences } GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location); } if (person != null) { namePerson = person.DisplayName; GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person); } if (item != null) { nameItem = item.DaggerfallUnityItem.ItemName; GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing); } // then create dialog links between the resources if ((place != null) && (person != null)) { // register both links (location -> person as well as person -> location) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location, namePerson, TalkManager.QuestInfoResourceType.Person); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person, namePlace, TalkManager.QuestInfoResourceType.Location); } if ((place != null) && (item != null)) { // register both links (location -> item as well as item -> location) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location, nameItem, TalkManager.QuestInfoResourceType.Thing); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing, namePlace, TalkManager.QuestInfoResourceType.Location); } if ((person != null) && (item != null)) { // register both links (person -> item as well as item -> person) GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person, nameItem, TalkManager.QuestInfoResourceType.Thing); GameManager.Instance.TalkManager.DialogLinkForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing, namePerson, TalkManager.QuestInfoResourceType.Person); } SetComplete(); }
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; } } } }
public override void Update(Task caller) { // Get place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return; } // Discover location GameManager.Instance.PlayerGPS.DiscoverLocation(place.SiteDetails.regionName, place.SiteDetails.locationName); SetComplete(); }
/// <summary> /// Continuously checks where player is and sets target true/false based on site properties. /// </summary> public override void Update(Task caller) { bool result = false; // Get place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return; } // Check building site if (place.SiteDetails.siteType == SiteTypes.Building) { result = CheckInsideBuilding(place); } else if (place.SiteDetails.siteType == SiteTypes.Town) { result = CheckInsideTown(place); } else if (place.SiteDetails.siteType == SiteTypes.Dungeon) { result = CheckInsideDungeon(place); } // Handle positive check if (result) { // "saying" popup // TODO: Should this run every time or only once? if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } // Enable target task ParentQuest.SetTask(taskSymbol); } else { // Disable target task ParentQuest.UnsetTask(taskSymbol); } }
/// <summary> /// Continuously checks where player is and sets target true/false based on site properties. /// </summary> public override void Update(Task caller) { bool result; if (placeSymbol != null) { // Get place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return; } // Check if player at this place result = place.IsPlayerHere(); } else { result = Place.IsPlayerAtBuildingType(p2, p3); } // Handle positive check if (result) { // "saying" popup // Only display this once or player can get a popup loop if (textId != 0 && !textShown) { ParentQuest.ShowMessagePopup(textId); textShown = true; } // Start target task ParentQuest.StartTask(taskSymbol); } else { // Clear target task ParentQuest.ClearTask(taskSymbol); } }
public override void Update(Task caller) { // Get place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return; } // Discover location GameManager.Instance.PlayerGPS.DiscoverLocation(place.SiteDetails.regionName, place.SiteDetails.locationName); if (readMap) { GameManager.Instance.PlayerEntity.Notebook.AddNote( TextManager.Instance.GetText("DaggerfallUI", "readMap").Replace("%map", place.SiteDetails.locationName)); } SetComplete(); }
public override bool CheckTrigger(Task caller) { // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return(false); } // Attempt to get Place resource Place place = ParentQuest.GetPlace(placeSymbol); if (place == null) { return(false); } // Watch item item.ActionWatching = true; // Allow drop only when player at correct location if (place.IsPlayerHere()) { item.DaggerfallUnityItem.AllowQuestItemRemoval = true; } else { item.DaggerfallUnityItem.AllowQuestItemRemoval = false; return(false); } // Handle player dropped if (item.PlayerDropped) { return(true); } return(false); }
/// <summary> /// Checks if player in same world cell as Place this Person was assigned to. /// Does not care about specific building/dungeon or interior/exterior, just matching location mapID. /// Does not care if player actually inside bounds, just if inside same world cell. /// </summary> /// <returns>True if player in same world cell as location.</returns> public bool IsPlayerInSameLocationWorldCell() { // Get Place resource Place place = ParentQuest.GetPlace(lastAssignedPlaceSymbol); if (place == null) { return(false); } // Compare mapID of player location and Place DFLocation location = GameManager.Instance.PlayerGPS.CurrentLocation; if (location.Loaded) { if (location.MapTableData.MapId == place.SiteDetails.mapId) { return(true); } } return(false); }
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; } // Hot-place NPC at this location when player enters if (home.IsPlayerHere()) { PlaceAtHome(); } } }
/// <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); }
/// <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); }
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; }