Example #1
0
        /// <summary>
        /// Either creates or add an entry to the journal that goes with the quest - there will only be one journal pr. quest
        /// </summary>
        /// <param name="name">The name of the journal category</param>
        /// <param name="priority">The priority of the journal entry</param>
        /// <param name="gender">The gender of the journal entry</param>
        /// <param name="lang">The language of the journal</param>
        /// <param name="category">The category that belong to the quest</param>
        /// <returns>The created journal</returns>
        public NWN2JournalCategory createJournal(string name, NWN2JournalPriority priority, BWLanguages.Gender gender, BWLanguages.BWLanguage lang, NWN2JournalCategory category)
        {
            int localQuestID = (questId == 0) ? 1 : questId;
            string tag = "Q_" + questNamePrep(name);
            foreach (NWN2JournalCategory jourCat in module.Journal.Categories)
                {
                if (jourCat.Tag == tag)
                    {
                    category = jourCat;
                    break;
                    }
                }

            if (category == null)
                {
                category = module.Journal.AddCategory();
                category.Name.SetString(name, lang, gender);

                category.Priority = priority;

                //I create the tag
                category.Tag = tag;
                }
            LinkedList<NWN2JournalEntry> journalEnties = new LinkedList<NWN2JournalEntry>();
            NWN2JournalEntry tempJournalEntry;

            if (localQuestID == 1)
                {
                /*
                for (int i = 0; i < category.Entries.Count; i++)
                    {
                    tempJournalEntry = category.Entries[i];
                    if ("pluginGenerated:" + localQuestID.ToString() == tempJournalEntry.Comment)
                        {
                        debug("equal comment");
                        journalEnties.AddLast(tempJournalEntry);
                        break;
                        }
                    }

                foreach (NWN2JournalEntry tempJournal in journalEnties)
                    {
                    debug("journal entry: " + tempJournal.Text[lang]);
                    category.Entries.Remove(tempJournal);
                    }
                 * */
                // If we are starting at a new quest, and there are risidual objects, we just clear them all
                category.Entries.Clear();
                }
            NWN2JournalEntry entry = category.AddEntry();
            entry.ID = (uint)localQuestID;
            entry.Endpoint = endPoint;
            entry.Comment = "pluginGenerated:" + entry.ID;
            entry.Text.SetString(journal, lang, gender);
            return category;
        }
Example #2
0
        /// <summary>
        /// Tries to create the quest
        /// </summary>
        private void Done_Click(object sender, EventArgs e)
            {
            LinkedList<StoryNode> ApprovedStoryNodes = new LinkedList<StoryNode>();
            /* I check to see if there are any illogical dependencies (that is
             * if a node requires something that is not there, or has been moved to a later position
             */
            int dependencyNumber = 0;

            pri = (NWN2JournalPriority)comboPri.SelectedIndex;
            lang = (BWLanguages.BWLanguage)comboLang.SelectedIndex;

            if (questName.Text == String.Empty)
                {
                report("You need to give the Quest a name");
                return;
                }

            foreach (StoryNode sNode in sNodeList.Items)
                {
                sNode.questId = (int)dependencyNumber;
                dependencyNumber += 5;
                ApprovedStoryNodes.AddLast(sNode);

                if (sNode.preReqNode != null)
                    {
                    if (!ApprovedStoryNodes.Contains(sNode.preReqNode))
                        {
                        report("There is a problematic dependency in " + sNode.Name + "\nPlease fix this and try again");
                        return;
                        }
                    }
                }

            string name = questName.Text;
            NWN2JournalCategory category = null;
            var actorMap = new Hashtable();
            var triggerMap = new Hashtable();
            Actor actor = null;
            Actor trigger = null;

            StoryNode.wipeConvHash();

            foreach (StoryNode sNode in ApprovedStoryNodes)
                {
                // This is done in order to ensure that the newest version of an actor is allways allocated
                actor = (Actor)actorMap[sNode.actor.Tag];
                if (actor != null)
                    sNode.actor = actor;

                if (sNode.trigger != null)
                    trigger = (Actor)triggerMap[sNode.trigger.Tag];

                if (trigger != null)
                    sNode.trigger = trigger;

                sNode.addConv(name, gender, lang);

                // I add the newest version of the actors
                actorMap[sNode.actor.Tag] = sNode.actor;

                if (sNode.trigger != null)
                    triggerMap[sNode.trigger.Tag] = sNode.trigger;

                if (sNode.journalCheck)
                    {
                    // I create the journal
                    category = sNode.createJournal(name, pri, gender, lang, category);
                    }
                }

            #region old code - might want to cut
            /*
            NWN2Campaign activeCampaign = NWN2CampaignManager.Instance.ActiveCampaign;
            foreach (Object actObj in actorMap.Values)
                {
                var act = (Actor)actObj;
                switch (act.type)
                    {
                    case EnumTypes.actorType.Creature:
                        toolsetCreatureUpdate(act, activeCampaign);
                        break;

                    case EnumTypes.actorType.Door:
                        toolsetDoorUpdate(act, activeCampaign);
                        break;

                    case EnumTypes.actorType.Placeable:
                        toolsetPlaceableUpdate(act, activeCampaign);
                        break;
                    }
                }

            foreach (Object trigObj in triggerMap.Values)
                {
                var trigAct = (Actor)trigObj;
                if (trigAct.boolInstance)
                    {
                    var instTrigger = (NWN2TriggerInstance)trigAct.instance;
                    foreach (NWN2GameArea area in module.Areas.Values)
                        {
                        area.Demand();
                        foreach (NWN2TriggerInstance trig in area.Triggers)
                            {
                            if (trig.Tag == trigAct.Tag)
                                {
                                debug(trigAct.Tag);
                                area.Triggers.Remove(trig);
                                area.Triggers.Add(trigAct.instance);
                                
                                trig.Variables = instTrigger.Variables;
                                trig.OnEnter = instTrigger.OnEnter;
                                
                                  }
                            }
                        }
                    }
                else
                    {
                    setCampaignModuleValues((NWN2TriggerBlueprint)trigAct.blueprint, module.Placeables);
                    setCampaignModuleValues((NWN2TriggerBlueprint)trigAct.blueprint, activeCampaign.Placeables);
                    }
                }
            }

        void toolsetCreatureUpdate(Actor act, NWN2Campaign activeCampaign)
            {
            if (act.boolInstance)
                {
                var instCreature = (NWN2CreatureInstance)act.instance;
                foreach (NWN2GameArea area in module.Areas.Values)
                    {
                    area.Demand();
                    foreach (NWN2CreatureInstance creature in area.Creatures)
                        if (creature.Tag == instCreature.Tag)
                            {
                            creature.Conversation = instCreature.Conversation;
                            creature.Inventory = instCreature.Inventory;
                            }
                    }
                }
            else
                {
                setCampaignModuleValues((NWN2CreatureBlueprint)act.blueprint, module.Creatures);
                setCampaignModuleValues((NWN2CreatureBlueprint)act.blueprint, activeCampaign.Creatures);
                }
            */
            }