Exemple #1
0
        public static QuestTask Load(GomObjectData obj, QuestStep step)
        {
            QuestTask task = new QuestTask();

            task.Step = step;
            task.Id   = (int)obj.ValueOrDefault <long>("qstTaskId", 0);

            task.CountMax     = (int)obj.ValueOrDefault <long>("qstTaskCountMax", 0);
            task.ShowTracking = obj.ValueOrDefault <bool>("qstTaskShowTracking", false);
            task.ShowCount    = obj.ValueOrDefault <bool>("qstTaskShowTrackingCount", false);
            task.Hook         = QuestHookExtensions.ToQuestHook((string)obj.ValueOrDefault <string>("qstHook", null));
            long stringId = 0;

            long.TryParse(obj.ValueOrDefault <string>("qstTaskStringid", null), out stringId);

            var txtLookup = step.Branch.Quest.TextLookup;

            if (txtLookup.ContainsKey(stringId))
            {
                task.String = StringTable.TryGetString(step.Branch.Quest.Fqn, (GomObjectData)txtLookup[stringId]);
            }

            task.TaskQuests = new List <Quest>();
            task.TaskNpcs   = new List <Npc>();
            var qstTaskObjects = (Dictionary <object, object>)obj.ValueOrDefault <Dictionary <object, object> >("qstTaskObjects", null);

            if (qstTaskObjects != null)
            {
                foreach (var taskObj in qstTaskObjects)
                {
                    string fqn = (string)taskObj.Key;
                    if (fqn.StartsWith("qst."))
                    {
                        var qst = QuestLoader.Load(fqn);
                        task.TaskQuests.Add(qst);
                    }
                    else if (fqn.StartsWith("npc."))
                    {
                        var npc = NpcLoader.Load(fqn);
                        task.TaskNpcs.Add(npc);
                    }
                    else if (fqn.StartsWith("plc."))
                    {
                    }
                }
            }

            return(task);
        }
        static DialogNode LoadDialogNode(Conversation cnv, GomObjectData data)
        {
            DialogNode result = new DialogNode();

            result.NodeId    = (int)data.Get <long>("cnvNodeNumber");
            result.MinLevel  = (int)data.ValueOrDefault <long>("cnvLevelConditionMin", -1);
            result.MaxLevel  = (int)data.ValueOrDefault <long>("cnvLevelConditionMax", -1);
            result.IsEmpty   = data.ValueOrDefault <bool>("cnvIsEmpty", false);
            result.IsAmbient = data.ValueOrDefault <bool>("cnvIsAmbient", false);
            result.JoinDisabledForHolocom   = data.ValueOrDefault <bool>("cnvIsJoinDisabledForHolocom", false);
            result.ChoiceDisabledForHolocom = data.ValueOrDefault <bool>("cnvIsVoteWinDisabledForHolocom", false);
            result.AbortsConversation       = data.ValueOrDefault <bool>("cnvAbortConversation", false);
            result.IsPlayerNode             = data.ValueOrDefault <bool>("cnvIsPcNode", false);

            result.ActionHook = QuestHookExtensions.ToQuestHook(data.ValueOrDefault <string>("cnvActionHook", null));

            // Load Alignment Results
            long alignmentAmount = data.ValueOrDefault <long>("cnvRewardForceAmount", 0);

            if (alignmentAmount != 0)
            {
                string forceType = data.Get <ScriptEnum>("cnvRewardForceType").ToString();
                result.AlignmentGain = ConversationAlignmentExtensions.ToConversationAlignment(alignmentAmount, forceType);
            }

            // Load Companion Affection Results
            var affectionGains = data.ValueOrDefault <Dictionary <object, object> >("cnvRewardAffectionRewards", null);

            result.AffectionRewards = new Dictionary <Npc, ConversationAffection>();
            if (affectionGains != null)
            {
                foreach (var companionGain in affectionGains)
                {
                    long companionShortNameId           = (long)companionGain.Key;
                    ConversationAffection affectionGain = ConversationAffectionExtensions.ToConversationAffection((long)companionGain.Value);
                    Npc companion = CompanionBySimpleNameId(companionShortNameId);
                    result.AffectionRewards[companion] = affectionGain;
                }
            }

            // Get Text
            var           textMap = data.Get <Dictionary <object, object> >("locTextRetrieverMap");
            GomObjectData txtData = (GomObjectData)textMap[(long)result.NodeId];

            result.Text = StringTable.TryGetString(cnv.Fqn, txtData);

            result.ChildIds = new List <int>();
            foreach (long childId in data.Get <List <object> >("cnvChildNodes"))
            {
                result.ChildIds.Add((int)childId);
            }

            // Load Quests
            var actionQuest = data.ValueOrDefault <ulong>("cnvActionQuest", 0);

            if (actionQuest > 0)
            {
                result.ActionQuest = QuestLoader.Load(actionQuest);
            }

            var questReward = data.ValueOrDefault <ulong>("cnvRewardQuest", 0);

            if (questReward > 0)
            {
                result.QuestReward = QuestLoader.Load(questReward);
            }

            var questGrants = data.Get <Dictionary <object, object> >("cnvNodeQuestGrants");

            result.QuestsGranted = new List <Quest>();
            foreach (var grant in questGrants)
            {
                if ((bool)grant.Value)
                {
                    Quest q = QuestLoader.Load((ulong)grant.Key);
                    result.QuestsGranted.Add(q);
                }
            }

            var questEnds = data.Get <Dictionary <object, object> >("cnvNodeQuestEnds");

            result.QuestsEnded = new List <Quest>();
            foreach (var ends in questEnds)
            {
                if ((bool)ends.Value)
                {
                    Quest q = QuestLoader.Load((ulong)ends.Key);
                    result.QuestsEnded.Add(q);
                }
            }

            var questProgress = data.Get <Dictionary <object, object> >("cnvNodeQuestProgress");

            result.QuestsProgressed = new List <Quest>();
            foreach (var prog in questProgress)
            {
                if ((bool)prog.Value)
                {
                    Quest q = QuestLoader.Load((ulong)prog.Key);
                    result.QuestsProgressed.Add(q);
                }
            }

            return(result);
        }