예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        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 = "";

            // add dialog for resources
            if (place != null)
            {
                namePlace = place.SiteDetails.locationName;
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, namePlace, TalkManager.QuestInfoResourceType.Location, false);
            }
            if (person != null)
            {
                namePerson = person.DisplayName;
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, namePerson, TalkManager.QuestInfoResourceType.Person, false);
            }
            if (item != null)
            {
                nameItem = item.DaggerfallUnityItem.ItemName;
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, nameItem, TalkManager.QuestInfoResourceType.Thing, false);
            }

            SetComplete();
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
        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(item.DaggerfallUnityItem);

            // 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);
            }

            SetComplete();
        }
예제 #8
0
        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();
        }
예제 #9
0
        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 Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                throw new Exception(string.Format("Could not find Item resource symbol {0}", itemSymbol));
            }

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

            if (place == null)
            {
                throw new Exception(string.Format("Could not find Place resource symbol {0}", placeSymbol));
            }

            // Assign Item to Place
            place.AssignQuestResource(item.Symbol);

            SetComplete();
        }
예제 #10
0
        public override void Update(Task caller)
        {
            base.Update(caller);

            // Handle giving player nothing
            // This also shows QuestComplete message but does not give player loot
            if (isNothing)
            {
                OfferToPlayerWithQuestComplete(null);
                SetComplete();
                return;
            }

            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                Debug.LogErrorFormat("Could not find Item resource symbol {0}", itemSymbol);
                return;
            }

            // Give quest item to player based on command format
            if (textId != 0)
            {
                DirectToPlayerWithNotify(item);
            }
            else
            {
                OfferToPlayerWithQuestComplete(item);
            }

            SetComplete();
        }
예제 #11
0
        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);

            // add dialog for resources
            if (place != null)
            {
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, place.Symbol.Name, TalkManager.QuestInfoResourceType.Location, false);
            }
            if (person != null)
            {
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, person.Symbol.Name, TalkManager.QuestInfoResourceType.Person, false);
            }
            if (item != null)
            {
                GameManager.Instance.TalkManager.AddDialogForQuestInfoResource(ParentQuest.UID, item.Symbol.Name, TalkManager.QuestInfoResourceType.Thing, false);
            }

            SetComplete();
        }
예제 #12
0
        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);
        }
예제 #13
0
        public override void Update(Task caller)
        {
            base.Update(caller);

            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find Item resource symbol {0}", itemSymbol));
            }

            // Attempt to get target resource
            QuestResource target = ParentQuest.GetResource(targetSymbol);

            if (target == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find target resource symbol {0}", targetSymbol));
            }

            // Target must exist in the world
            if (!target.QuestResourceBehaviour)
            {
                return;
            }

            // Must have an Entity to receive item
            DaggerfallEntityBehaviour entityBehaviour = target.QuestResourceBehaviour.GetComponent <DaggerfallEntityBehaviour>();

            if (!entityBehaviour)
            {
                SetComplete();
                throw new Exception(string.Format("GiveItem target {0} is not an Entity with DaggerfallEntityBehaviour", targetSymbol));
            }

            // Assign item for player to find
            //  * Some quests assign item to Foe at create time, others on injured event
            //  * It's possible for target enemy to be one-shot or to be killed by other means (such as "killall")
            //  * This assignment will direct quest loot item either to live enemy or corpse loot container
            if (entityBehaviour.CorpseLootContainer)
            {
                // If enemy is already dead then place item in corpse loot container
                entityBehaviour.CorpseLootContainer.Items.AddItem(item.DaggerfallUnityItem);
            }
            else
            {
                // Otherwise add quest Item to Entity item collection
                // It will be transferred to corpse marker loot container when dropped
                entityBehaviour.Entity.Items.AddItem(item.DaggerfallUnityItem);
            }

            SetComplete();
        }
예제 #14
0
        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();
        }
예제 #15
0
        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();
        }
예제 #16
0
        public override void Update(Task caller)
        {
            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(targetItem);

            if (item == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find Item resource symbol {0}", targetItem));
            }

            // Start target task based on player carrying item
            if (GameManager.Instance.PlayerEntity.Items.Contains(item))
            {
                ParentQuest.StartTask(targetTask);
            }
        }
예제 #17
0
        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;
            }

            // Give quest item to player
            GameManager.Instance.PlayerEntity.Items.AddItem(item.DaggerfallUnityItem, Items.ItemCollection.AddPosition.Front);

            SetComplete();
        }
예제 #18
0
        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);
        }
예제 #19
0
        public override void Update(Task caller)
        {
            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(target);

            if (item == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find Item resource symbol {0}", target));
            }

            // Convert to permanent
            if (item.DaggerfallUnityItem != null)
            {
                item.DaggerfallUnityItem.MakePermanent();
            }

            SetComplete();
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
        public override void Update(Task caller)
        {
            const int minHour  = 7;
            const int maxHour  = 18;
            const int minDelay = 40;
            const int maxDelay = 500;

            base.Update(caller);

            // "give pc anItem notify 1234" and "give pc anItem silently" require player
            // to be within a town, outdoors, and during set hours for action to fire
            if ((textId != 0 || silently) && !offerImmediately)
            {
                // Fail if conditions not met, but take note we are waiting
                DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;
                if (!GameManager.Instance.PlayerGPS.IsPlayerInTown(true, true) || now.Hour < minHour || now.Hour > maxHour)
                {
                    waitingForTown = true;
                    ticksUntilFire = 0;
                    return;
                }

                // If we were waiting then add a small random delay so messages don't all arrive at once
                if (waitingForTown)
                {
                    ticksUntilFire = UnityEngine.Random.Range(minDelay, maxDelay + 1);
                    waitingForTown = false;
                    RaiseOnOfferPendingEvent(this);
                }
            }

            // Reduce random delay until nothing is left
            // This is in questmachine ticks which is currently 10 ticks per second while game is running
            // Does not tick while game paused or resting - player must be actively in town walking around
            if (ticksUntilFire > 0)
            {
                ticksUntilFire--;
                return;
            }

            // Handle giving player nothing
            // This also shows QuestComplete message but does not give player loot
            if (isNothing)
            {
                OfferToPlayerWithQuestComplete(null);
                SetComplete();
                return;
            }

            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                Debug.LogErrorFormat("Could not find Item resource symbol {0}", itemSymbol);
                return;
            }

            // Give quest item to player based on command format
            if (textId != 0)
            {
                DirectToPlayerWithNotify(item);
            }
            else
            {
                if (silently)
                {
                    DirectToPlayerWithoutNotify(item);
                }
                else
                {
                    OfferToPlayerWithQuestComplete(item);
                }
            }

            offerImmediately = false;
            SetComplete();
        }
예제 #23
0
        public override void Update(Task caller)
        {
            base.Update(caller);

            // Attempt to get Item resource
            Item item = ParentQuest.GetItem(itemSymbol);

            if (item == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find Item resource symbol {0}", itemSymbol));
            }

            // Attempt to get target resource
            QuestResource target = ParentQuest.GetResource(targetSymbol);

            if (target == null)
            {
                SetComplete();
                throw new Exception(string.Format("Could not find target resource symbol {0}", targetSymbol));
            }

            // Add item to Foe resource or generic entity
            // In practice GiveItem will always be to a Foe resource - NPCs are handled by "get item"
            // Keeping generic GiveItem behaviour as entity catch-all and reference
            if (target is Foe)
            {
                // Add to Foe item queue
                (target as Foe).QueueItem(item.DaggerfallUnityItem);

                // Dequeue items on entity immediately if target already exists in the world
                // Will also handle placing items to dead enemy loot container
                if (target.QuestResourceBehaviour)
                {
                    DaggerfallEntityBehaviour entityBehaviour = target.QuestResourceBehaviour.GetComponent <DaggerfallEntityBehaviour>();
                    if (entityBehaviour)
                    {
                        target.QuestResourceBehaviour.AddItemQueue(target as Foe, entityBehaviour);
                    }
                }
            }
            else
            {
                // Target must exist in the world
                if (!target.QuestResourceBehaviour)
                {
                    return;
                }

                // Must have an Entity to receive item
                DaggerfallEntityBehaviour entityBehaviour = target.QuestResourceBehaviour.GetComponent <DaggerfallEntityBehaviour>();
                if (!entityBehaviour)
                {
                    SetComplete();
                    throw new Exception(string.Format("GiveItem target {0} is not an Entity with DaggerfallEntityBehaviour", targetSymbol));
                }

                // Assign item for player to find
                //  * Some quests assign item to Foe at create time, others on injured event
                //  * It's possible for target enemy to be one-shot or to be killed by other means (such as "killall")
                //  * This assignment will direct quest loot item either to live enemy or corpse loot container
                if (entityBehaviour.CorpseLootContainer)
                {
                    // If enemy is already dead then place item in corpse loot container
                    entityBehaviour.CorpseLootContainer.Items.AddItem(item.DaggerfallUnityItem);
                }
                else
                {
                    // Otherwise add quest Item to Entity item collection
                    // It will be transferred to corpse marker loot container when dropped
                    entityBehaviour.Entity.Items.AddItem(item.DaggerfallUnityItem);
                }
            }

            // Remove item from player inventory if they are holding it
            if (GameManager.Instance.PlayerEntity.Items.Contains(item.DaggerfallUnityItem))
            {
                GameManager.Instance.PlayerEntity.Items.RemoveItem(item.DaggerfallUnityItem);
            }

            SetComplete();
        }