// Check if NPC is a Questor
        bool QuestorCheck(StaticNPC npc)
        {
            // Check if player clicked on supported guild questor
            DaggerfallGuildPopupWindow.TempGuilds guild;
            if (npc.Data.factionID == PersistentFactionData.fightersGuildQuestorFactionID)
            {
                guild = DaggerfallGuildPopupWindow.TempGuilds.Fighter;
            }
            else if (npc.Data.factionID == PersistentFactionData.magesGuildQuestorFactionID)
            {
                guild = DaggerfallGuildPopupWindow.TempGuilds.Mage;
            }
            else
            {
                guild = DaggerfallGuildPopupWindow.TempGuilds.None;
            }

            // Open guild service window
            if (guild != DaggerfallGuildPopupWindow.TempGuilds.None)
            {
                DaggerfallGuildPopupWindow guildWindow = new DaggerfallGuildPopupWindow(DaggerfallUI.Instance.UserInterfaceManager);
                guildWindow.CurrentGuild   = guild;
                guildWindow.CurrentService = DaggerfallGuildPopupWindow.TempGuildServices.Questor;
                guildWindow.QuestorNPC     = npc;
                DaggerfallUI.Instance.UserInterfaceManager.PushWindow(guildWindow);
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public void SetTargetNPC(StaticNPC targetNPC, int reactionToPlayer)
        {
            if (targetNPC == lastTargetStaticNPC)
            {
                return;
            }

            this.targetStaticNPC = targetNPC;

            DaggerfallTalkWindow.FacePortraitArchive facePortraitArchive;
            int recordIndex;

            getPortraitIndexFromStaticNPCBillboard(out facePortraitArchive, out recordIndex);
            DaggerfallUI.Instance.TalkWindow.SetNPCPortrait(facePortraitArchive, recordIndex);

            lastTargetStaticNPC = targetNPC;

            nameNPC = targetNPC.DisplayName;
            DaggerfallUI.Instance.TalkWindow.UpdateNameNPC();

            this.reactionToPlayer = reactionToPlayer;

            // reset npc knowledge, for now it resets every time the npc has changed (player talked to new npc)
            // TODO: match classic daggerfall - in classic npc remember their knowledge about topics for their time of existence
            resetNPCKnowledgeInTopicListRecursively(listTopicLocation);
            resetNPCKnowledgeInTopicListRecursively(listTopicPerson);
            resetNPCKnowledgeInTopicListRecursively(listTopicThing);
            resetNPCKnowledgeInTopicListRecursively(listTopicTellMeAbout);
        }
        // Player has clicked on a special NPC
        void SpecialNPCClick(StaticNPC npc)
        {
            // Handle special NPC in home location click
            SpecialNPCClickHandler specialNPCClickHandler = npc.gameObject.GetComponent <SpecialNPCClickHandler>();

            if (specialNPCClickHandler)
            {
                specialNPCClickHandler.DoClick();
            }
        }
 // Check if raycast hit a StaticNPC
 private bool NPCCheck(RaycastHit hitInfo, out StaticNPC staticNPC)
 {
     staticNPC = hitInfo.transform.GetComponent <StaticNPC>();
     if (staticNPC != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        // Check if NPC is a Questor
        void QuestorCheck(StaticNPC npc)
        {
            const int fighterGuildFactionID = 851;

            // Detect Fighter's Guild Questors
            if (npc.Data.factionID == fighterGuildFactionID)
            {
                // Temp guild quest pump UI
                DaggerfallGuildPopupWindow questorWindow = new DaggerfallGuildPopupWindow(DaggerfallUI.Instance.UserInterfaceManager);
                questorWindow.CurrentGuild = DaggerfallGuildPopupWindow.TempGuilds.Fighter;
                questorWindow.CurrentRole  = DaggerfallGuildPopupWindow.TempGuildRoles.Questor;
                questorWindow.QuestorNPC   = npc;
                DaggerfallUI.Instance.UserInterfaceManager.PushWindow(questorWindow);
            }
        }
        // Output NPC info to HUD
        private void PresentNPCInfo(StaticNPC npc)
        {
            DaggerfallUI.AddHUDText(HardStrings.youSee.Replace("%s", npc.DisplayName));

            // Add debug info
            if (DaggerfallUI.Instance.DaggerfallHUD.ShowQuestDebugger)
            {
                // Get faction info of this NPC
                FactionFile.FactionData factionData;
                if (GameManager.Instance.PlayerEntity.FactionData.GetFactionData(npc.Data.factionID, out factionData))
                {
                    string debugInfo = string.Format("Debugger: Your reputation with this NPC is {0}.", factionData.rep);
                    DaggerfallUI.AddHUDText(debugInfo);
                }
            }
        }
        // Player has clicked on a static NPC
        void StaticNPCClick(StaticNPC npc)
        {
            // Store the NPC just clicked in quest engine
            QuestMachine.Instance.LastNPCClicked = npc;

            // Check if this NPC is a quest giver and show temp guild quest popup
            QuestorCheck(npc);

            // Handle special NPC in home location click
            SpecialNPCClickHandler specialNPCClickHandler = npc.gameObject.GetComponent <SpecialNPCClickHandler>();

            if (specialNPCClickHandler)
            {
                specialNPCClickHandler.DoClick();
            }
        }
Esempio n. 8
0
        // Player has clicked or static talk target or clicked the talk button inside a popup-window
        public void TalkToStaticNPC(StaticNPC targetNPC)
        {
            const int youGetNoResponseTextId = 7205;

            // Get NPC faction
            FactionFile.FactionData NPCfaction;
            int oneBasedPlayerRegion = GameManager.Instance.PlayerGPS.CurrentOneBasedRegionIndex;

            FactionFile.FactionData[] factions = GameManager.Instance.PlayerEntity.FactionData.FindFactions(
                (int)FactionFile.FactionTypes.Province, -1, -1, oneBasedPlayerRegion);

            // Should always find a region
            if (factions == null || factions.Length == 0)
            {
                throw new Exception("TalkToStaticNPC() did not find a match for NPC faction.");
            }

            // Warn if more than 1 region is found
            if (factions.Length > 1)
            {
                Debug.LogWarningFormat("TalkToStaticNPC() found more than 1 matching NPC faction for region {0}.", oneBasedPlayerRegion);
            }

            NPCfaction = factions[0];

            // Get reaction to player
            int          reactionToPlayer = 0;
            PlayerEntity player           = GameManager.Instance.PlayerEntity;

            reactionToPlayer  = NPCfaction.rep;
            reactionToPlayer += player.BiographyReactionMod;

            if (NPCfaction.sgroup < player.SGroupReputations.Length) // one of the five general social groups
            {
                reactionToPlayer += player.SGroupReputations[NPCfaction.sgroup];
            }

            if (reactionToPlayer >= -20)
            {
                DaggerfallUI.UIManager.PushWindow(DaggerfallUI.Instance.TalkWindow);
                GameManager.Instance.TalkManager.SetTargetNPC(targetNPC, reactionToPlayer);
            }
            else
            {
                DaggerfallUI.MessageBox(youGetNoResponseTextId);
            }
        }
        // Player has clicked on a static NPC
        void StaticNPCClick(StaticNPC npc)
        {
            // Do nothing if no NPC passed or fade in progress
            // Quest machine does not tick while fading (to prevent things happening while screen is black)
            // But this can result in player clicking a quest NPC before quest state ticks after load and breaking quest
            if (!npc || DaggerfallUI.Instance.FadeInProgress)
            {
                return;
            }

            // Store the NPC just clicked in quest engine
            QuestMachine.Instance.LastNPCClicked = npc;

            // Check if this NPC is a quest giver and show temp guild quest popup
            // This will be changed later when temp guild system replaced with real thing
            if (QuestorCheck(npc))
            {
                return;
            }

            // Handle quest NPC click and exit if linked to a Person resource
            QuestResourceBehaviour questResourceBehaviour = npc.gameObject.GetComponent <QuestResourceBehaviour>();

            if (questResourceBehaviour)
            {
                if (TriggerQuestResourceBehaviourClick(questResourceBehaviour))
                {
                    return;
                }
            }

            // Do nothing further if a quest is actively listening on this individual NPC
            // This NPC not reserved as a Person resource but has a WhenNpcIsAvailable action listening on it
            // This effectively shuts down several named NPCs during main quest, but not trivial to otherwise determine appropriate access
            // TODO: Try to find a good solution for releasing listeners when the owning action is disabled
            if (QuestMachine.Instance.HasFactionListener(npc.Data.factionID))
            {
                return;
            }

            // Get faction data.
            FactionFile.FactionData factionData;
            if (playerEnterExit.IsPlayerInsideBuilding &&
                GameManager.Instance.PlayerEntity.FactionData.GetFactionData(npc.Data.factionID, out factionData))
            {
                UserInterfaceManager uiManager = DaggerfallUI.Instance.UserInterfaceManager;
                Debug.LogFormat("faction id: {0}, social group: {1}, guild: {2}",
                                npc.Data.factionID, (FactionFile.SocialGroups)factionData.sgroup, (FactionFile.GuildGroups)factionData.ggroup);

                // Check if the NPC offers a guild service.
                if (Enum.IsDefined(typeof(GuildServices), npc.Data.factionID))
                {
                    FactionFile.GuildGroups guild   = (FactionFile.GuildGroups)factionData.ggroup;
                    GuildServices           service = (GuildServices)npc.Data.factionID;
                    Debug.Log("NPC offers guild service: " + service.ToString());
                    uiManager.PushWindow(new DaggerfallGuildServicePopupWindow(uiManager, npc, guild, service));
                }
                // Check if this NPC is a merchant.
                else if ((FactionFile.SocialGroups)factionData.sgroup == FactionFile.SocialGroups.Merchants)
                {
                    // Shop?
                    if (RMBLayout.IsShop(playerEnterExit.BuildingDiscoveryData.buildingType))
                    {
                        if (RMBLayout.IsRepairShop(playerEnterExit.BuildingDiscoveryData.buildingType))
                        {
                            uiManager.PushWindow(new DaggerfallMerchantRepairPopupWindow(uiManager, npc));
                        }
                        else
                        {
                            uiManager.PushWindow(new DaggerfallMerchantServicePopupWindow(uiManager, npc, DaggerfallMerchantServicePopupWindow.Services.Sell));
                        }
                    }
                    // Bank?
                    else if (playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Bank)
                    {
                        uiManager.PushWindow(new DaggerfallMerchantServicePopupWindow(uiManager, npc, DaggerfallMerchantServicePopupWindow.Services.Banking));
                    }
                    // Tavern?
                    else if (playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Tavern)
                    {
                        // for now only talk to all npc in taverns - TODO: add tavern option in here
                        GameManager.Instance.TalkManager.TalkToStaticNPC(npc);
                    }
                }
                // TODO - more checks for npc social types?
                else // if no special handling had to be done for npc with social group of type merchant: talk to the static npc
                {
                    GameManager.Instance.TalkManager.TalkToStaticNPC(npc);
                }
            }
            else // if no special handling had to be done (all remaining npcs of the remaining social groups not handled explicitely above): default is talk to the static npc
            {
                // with one exception: guards
                if (npc.Data.billboardArchiveIndex == 183 && npc.Data.billboardRecordIndex == 3) // detect if clicked guard (comment Nystul: didn't find a better mechanism than billboard texture check)
                {
                    return;                                                                      // if guard was clicked don't open talk window
                }
                // otherwise open talk window
                GameManager.Instance.TalkManager.TalkToStaticNPC(npc);
            }
        }
Esempio n. 10
0
 // Output NPC info to HUD
 private void PresentNPCInfo(StaticNPC npc)
 {
     DaggerfallUI.AddHUDText(HardStrings.youSee.Replace("%s", npc.DisplayName));
 }