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); } // Get related Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return(false); } // Check item clicked flag if (item.HasPlayerClicked) { //item.RearmPlayerClick(); if (id != 0) { ParentQuest.ShowMessagePopup(id); } return(true); } return(false); }
public override void Update(Task caller) { // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return; } // Check if player is wearing item if (!GameManager.Instance.PlayerEntity.ItemEquipTable.IsEquipped(item.DaggerfallUnityItem)) { return; } // Say message if (textID != 0) { ParentQuest.ShowMessagePopup(textID); } // Trigger target task ParentQuest.StartTask(taskSymbol); SetComplete(); }
public override void Update(Task caller) { // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return; } // Let the item know it's being watched item.ActionWatching = true; // Player must be wearing item or item clicked with "use" in inventory if (GameManager.Instance.PlayerEntity.ItemEquipTable.IsEquipped(item.DaggerfallUnityItem) || item.UseClicked) { // Say message if (textID != 0) { ParentQuest.ShowMessagePopup(textID); } // Trigger target task ParentQuest.StartTask(taskSymbol); // Clear watching flag item.ActionWatching = false; 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 if player at this place result = place.IsPlayerHere(); // Handle positive check if (result) { // "saying" popup // TODO: Should this run every time or only once? if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } // Start target task ParentQuest.StartTask(taskSymbol); } else { // Clear target task ParentQuest.ClearTask(taskSymbol); } }
public override void Update(Task caller) { base.Update(caller); // Add related Person or Foe resource if (personSymbol != null && !string.IsNullOrEmpty(personSymbol.Name)) { Person person = ParentQuest.GetPerson(personSymbol); if (person != null) { DaggerfallUI.Instance.DaggerfallHUD.EscortingFaces.AddFace(person); } } else if (foeSymbol != null && !string.IsNullOrEmpty(foeSymbol.Name)) { Foe foe = ParentQuest.GetFoe(foeSymbol); if (foe != null) { DaggerfallUI.Instance.DaggerfallHUD.EscortingFaces.AddFace(foe); } } // Popup saying message if (sayingID != 0) { ParentQuest.ShowMessagePopup(sayingID); } SetComplete(); }
void OfferToPlayerWithQuestComplete(Item item) { // Quest successful ParentQuest.QuestSuccess = true; // Show quest complete message DaggerfallMessageBox messageBox = ParentQuest.ShowMessagePopup((int)QuestMachine.QuestMessages.QuestComplete); // If no item for reward then we are done if (item == null) { return; } // Release item so we can offer back to player // Sometimes a quest item is both carried by player then offered back to them // Example is Sx010 where "curse" is removed and player can keep item GameManager.Instance.PlayerEntity.ReleaseQuestItemForReoffer(ParentQuest.UID, item, true); // Create a dropped loot container window for player to loot their reward rewardLoot = GameObjectHelper.CreateDroppedLootContainer(GameManager.Instance.PlayerObject, DaggerfallUnity.NextUID); rewardLoot.ContainerImage = InventoryContainerImages.Merchant; rewardLoot.Items.AddItem(item.DaggerfallUnityItem); // Schedule loot window to open when player dismisses message messageBox.OnClose += QuestCompleteMessage_OnClose; }
public override void Update(Task caller) { // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return; } // Let the item know it's being watched item.ActionWatching = true; // Player must "use" item from inventory if (item.UseClicked) { // Say message if (textID != 0) { ParentQuest.ShowMessagePopup(textID); } // Trigger target task ParentQuest.StartTask(taskSymbol); // Clear watching flag item.ActionWatching = false; SetComplete(); } }
public override void Update(Task caller) { base.Update(caller); // Do nothing if isNothing if (isNothing) { SetComplete(); return; } // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { throw new Exception(string.Format("Could not find Item resource symbol {0}", itemSymbol)); } // Add quest item to player GameManager.Instance.PlayerEntity.Items.AddItem(item.DaggerfallUnityItem, Items.ItemCollection.AddPosition.Front); // Show the popup message if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } 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 if player at this place result = place.IsPlayerHere(); // 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) { base.Update(caller); // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { Debug.LogErrorFormat("Could not find Item resource symbol {0}", itemSymbol); return; } // Release item - this will clear equip state and remove item from player's inventory // Now item is not associated with any collections and will just be garbage collected GameManager.Instance.PlayerEntity.ReleaseQuestItemForReoffer(ParentQuest.UID, item); // "saying" popup if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } 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 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); } // Get related Person resource Person person = ParentQuest.GetPerson(npcSymbol); if (person == null) { return(false); } // Check player clicked flag if (person.HasPlayerClicked) { // When a gold amount and task is specified, the player must have that amount of gold or another task is called if (goldAmount > 0 && taskSymbol != null && !string.IsNullOrEmpty(taskSymbol.Name)) { // Does player have enough gold? if (GameManager.Instance.PlayerEntity.GoldPieces >= goldAmount) { // Then deduct gold and fire trigger GameManager.Instance.PlayerEntity.GoldPieces -= goldAmount; } else { // Otherwise trigger secondary task and exit without firing trigger ParentQuest.StartTask(taskSymbol); return(false); } } if (id != 0) { ParentQuest.ShowMessagePopup(id); } // Rearm person click after current task ParentQuest.ScheduleClickRearm(person); return(true); } return(false); }
public override void Update(Task caller) { // "saying" popup if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } // Flag quest over so quest machine can remove it //Debug.LogFormat("Ending quest {0}", ParentQuest.UID); ParentQuest.QuestBreak = true; ParentQuest.EndQuest(); SetComplete(); }
public override void Update(Task caller) { base.Update(caller); // Quest successful ParentQuest.QuestSuccess = true; // Show quest complete message DaggerfallMessageBox messageBox = ParentQuest.ShowMessagePopup((int)QuestMachine.QuestMessages.QuestComplete); // Schedule loot window to open when player dismisses message messageBox.OnClose += QuestCompleteMessage_OnClose; 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); } }
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); } // Get related Person resource Person person = ParentQuest.GetPerson(npcSymbol); if (person == null) { return(false); } // Get related Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return(false); } // Check player clicked flag if (person.HasPlayerClicked) { // Check if player has item if (GameManager.Instance.PlayerEntity.Items.Contains(item)) { // Rearm person click after current task ParentQuest.ScheduleClickRearm(person); // Show message popup, remove item, return true on trigger ParentQuest.ShowMessagePopup(id); GameManager.Instance.PlayerEntity.ReleaseQuestItemForReoffer(item.DaggerfallUnityItem); return(true); } } return(false); }
public override bool CheckTrigger(Task caller) { // Get related Foe resource Foe foe = ParentQuest.GetFoe(foeSymbol); if (foe == null) return false; // Check total kills recorded on this Foe if (foe.KillCount >= killsRequired) { // Popup saying message if (sayingID != 0) ParentQuest.ShowMessagePopup(sayingID); return true; } return false; }
void OfferToPlayerWithQuestComplete(Item item) { // Show quest complete message DaggerfallMessageBox messageBox = ParentQuest.ShowMessagePopup((int)QuestMachine.QuestMessages.QuestComplete); // If no item for reward then we are done if (item == null) { return; } // Create a dropped loot container window for player to loot their reward rewardLoot = GameObjectHelper.CreateDroppedLootContainer(GameManager.Instance.PlayerObject, DaggerfallUnity.NextUID); rewardLoot.ContainerImage = InventoryContainerImages.Merchant; rewardLoot.Items.AddItem(item.DaggerfallUnityItem); // Schedule loot window to open when player dismisses message messageBox.OnClose += QuestCompleteMessage_OnClose; }
public override void Update(Task caller) { base.Update(caller); // Attempt to get Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { Debug.LogErrorFormat("Could not find Item resource symbol {0}", itemSymbol); return; } // Release item so we can give back to player // Sometimes a quest item is both carried by player then handed back to them // Example is Sx012 where courier hands back two items of jewellery GameManager.Instance.PlayerEntity.ReleaseQuestItemForReoffer(ParentQuest.UID, item); // Give quest item to player if (item.DaggerfallUnityItem.IsOfTemplate(ItemGroups.Currency, (int)Currency.Gold_pieces)) { // Give player gold equal to stack size and notify int amount = item.DaggerfallUnityItem.stackCount; GameManager.Instance.PlayerEntity.GoldPieces += amount; DaggerfallUI.AddHUDText(HardStrings.youReceiveGoldPieces.Replace("%s", amount.ToString())); } else { // Give player actual item GameManager.Instance.PlayerEntity.Items.AddItem(item.DaggerfallUnityItem, ItemCollection.AddPosition.Front); } // "saying" popup if (textId != 0) { ParentQuest.ShowMessagePopup(textId); } 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); } // Get related Person resource Person person = ParentQuest.GetPerson(npcSymbol); if (person == null) { return(false); } // Get related Item resource Item item = ParentQuest.GetItem(itemSymbol); if (item == null) { return(false); } // Check player clicked flag if (person.HasPlayerClicked) { //person.RearmPlayerClick(); if (GameManager.Instance.PlayerEntity.Items.Contains(item)) { ParentQuest.ShowMessagePopup(id); return(true); } } return(false); }
public override void Update(Task caller) { base.Update(caller); // Get related Person resource Person person = ParentQuest.GetPerson(personSymbol); if (person == null) { return; } // Add face to HUD DaggerfallUI.Instance.DaggerfallHUD.EscortingFaces.AddFace(person); // Popup saying message if (sayingID != 0) { ParentQuest.ShowMessagePopup(sayingID); } SetComplete(); }
public override bool CheckTrigger(Task caller) { // Get related Foe resource Foe foe = ParentQuest.GetFoe(foeSymbol); if (foe == null) { return(false); } // Check injured flag if (foe.InjuredTrigger) { // Optionally show message if (textID != 0) { ParentQuest.ShowMessagePopup(textID); } return(true); } return(false); }
// Uses raycasts to find next spawn position just outside of player's field of view void PlaceFoeFreely(GameObject[] gameObjects, Transform parent, float minDistance = 5f, float maxDistance = 20f) { const float overlapSphereRadius = 0.65f; const float separationDistance = 1.25f; const float maxFloorDistance = 4f; // Must have received a valid array if (gameObjects == null || gameObjects.Length == 0) { return; } // Set parent - otherwise caller must set a parent if (parent) { gameObjects[pendingFoesSpawned].transform.parent = parent; } // Select a left or right direction outside of camera FOV Quaternion rotation; float directionAngle = GameManager.Instance.MainCamera.fieldOfView; directionAngle += UnityEngine.Random.Range(0f, 4f); if (UnityEngine.Random.Range(0f, 1f) > 0.5f) { rotation = Quaternion.Euler(0, -directionAngle, 0); } else { rotation = Quaternion.Euler(0, directionAngle, 0); } // Get direction vector and create a new ray Vector3 angle = (rotation * Vector3.forward).normalized; Vector3 spawnDirection = GameManager.Instance.PlayerObject.transform.TransformDirection(angle).normalized; Ray ray = new Ray(GameManager.Instance.PlayerObject.transform.position, spawnDirection); // Check for a hit Vector3 currentPoint; RaycastHit initialHit; if (Physics.Raycast(ray, out initialHit, maxDistance)) { // Separate out from hit point float extraDistance = UnityEngine.Random.Range(0f, 2f); currentPoint = initialHit.point + initialHit.normal.normalized * (separationDistance + extraDistance); // Must be greater than minDistance if (initialHit.distance < minDistance) { return; } } else { // Player might be in an open area (e.g. outdoors) pick a random point along spawn direction currentPoint = GameManager.Instance.PlayerObject.transform.position + spawnDirection * UnityEngine.Random.Range(minDistance, maxDistance); } // Must be able to find a surface below RaycastHit floorHit; ray = new Ray(currentPoint, Vector3.down); if (!Physics.Raycast(ray, out floorHit, maxFloorDistance)) { return; } // Ensure this is open space Vector3 testPoint = floorHit.point + Vector3.up * separationDistance; Collider[] colliders = Physics.OverlapSphere(testPoint, overlapSphereRadius); if (colliders.Length > 0) { return; } // This looks like a good spawn position pendingFoeGameObjects[pendingFoesSpawned].transform.position = testPoint; FinalizeFoe(pendingFoeGameObjects[pendingFoesSpawned]); gameObjects[pendingFoesSpawned].transform.LookAt(GameManager.Instance.PlayerObject.transform.position); // Send msg message on first spawn only if (msgMessageID != -1) { ParentQuest.ShowMessagePopup(msgMessageID); msgMessageID = -1; } // Increment count pendingFoesSpawned++; }
void DirectToPlayerWithNotify(Item item) { // Give player item and show notify message GameManager.Instance.PlayerEntity.Items.AddItem(item.DaggerfallUnityItem, Items.ItemCollection.AddPosition.Front); ParentQuest.ShowMessagePopup(textId); }
public override void Update(Task caller) { ParentQuest.ShowMessagePopup(id); SetComplete(); }