ConversationChoice AIPickChoice()
    {
        ConversationChoice choice = currentChoices[Random.Range(0, currentChoices.Count)];

        AIText.text = choice.text;
        return(choice);
    }
        public bool AddChoiceToIdentifyQuestGivers(Conversation convo, GameObject speaker)
        {
            NewQuestHolders.Clear();
            ActiveQuestHolders.Clear();

            //determine which quest givers are in the area, using similar logic to DynamicQuestSignpostConversation.cs
            foreach (GameObject go in speaker.CurrentCell.ParentZone.GetObjectsWithProperty("GivesDynamicQuest"))
            {
                if (go != speaker && !go.HasEffect("Egcb_QuestGiverVision"))
                {
                    string questID = go.GetStringProperty("GivesDynamicQuest", null);
                    if (questID != null)
                    {
                        if (!XRLCore.Core.Game.HasQuest(questID))
                        {
                            NewQuestHolders.Add(go);
                        }
                        else if (!XRLCore.Core.Game.FinishedQuests.ContainsKey(questID))
                        {
                            ActiveQuestHolders.Add(go);
                        }
                    }
                }
            }
            if ((NewQuestHolders.Count + ActiveQuestHolders.Count) < 1) //No quest givers
            {
                return(false);
            }

            //add options to ask location of quest givers for whom the quest has already started
            if (ActiveQuestHolders.Count > 0 && convo.NodesByID.ContainsKey("Start"))
            {
                string           nameList = this.BuildQuestGiverNameList(ActiveQuestHolders);
                ConversationNode cNode    = convo.NodesByID["Start"];
                this.RemoveOldEgcbChoices(cNode);
                ConversationChoice cChoice = new ConversationChoice
                {
                    Text       = this.StatementLocationOf(nameList),
                    GotoID     = "End",
                    ParentNode = cNode,
                    Execute    = "XRL.World.Parts.Egcb_PlayerUIHelper:ApplyActiveQuestGiverEffect" //function to execute when this choice is selected.
                };
                cNode.Choices.Add(cChoice);
            }
            if (NewQuestHolders.Count > 0 && convo.NodesByID.ContainsKey("*DynamicQuestSignpostConversationIntro"))
            {
                string           nameList = this.BuildQuestGiverNameList(NewQuestHolders);
                ConversationNode cNode    = convo.NodesByID["*DynamicQuestSignpostConversationIntro"];
                this.RemoveOldEgcbChoices(cNode);
                ConversationChoice cChoice = new ConversationChoice
                {
                    Text       = this.QuestionLocationOf(nameList, NewQuestHolders.Count > 1),
                    GotoID     = "End",
                    ParentNode = cNode,
                    Execute    = "XRL.World.Parts.Egcb_PlayerUIHelper:ApplyNewQuestGiverEffect" //function to execute when this choice is selected.
                };
                cNode.Choices.Add(cChoice);
            }
            return(true);
        }
 void ProcessChoice(ConversationChoice choice)
 {
     if (choice.responces.Count > 0)
     {
         currentChoices = choice.responces;
     }
     else
     {
         currentChoices = GetRootChoicesAtRandom(defaultChoiceCount, lastChoice);
     }
     lastChoice = choice;
     for (int i = 0; i < playerChoiceText.Length; i++)
     {
         if (i < currentChoices.Count)
         {
             playerChoiceText[i].gameObject.SetActive(true);
             playerChoiceText[i].text = currentChoices[i].text;
         }
         else
         {
             playerChoiceText[i].gameObject.SetActive(false);
             playerChoiceText[i].text = "";
         }
     }
 }
        internal static ConversationChoice AsConversationChoice(this ConversationChoiceJsonData source, ConversationNode parent)
        {
            ConversationChoice conversationChoice = null;


            if (source.ID == ReservedIdentifiers.DefaultContinueConversationChoiceID)
            {
                conversationChoice = new ConversationChoice(parent,
                                                            source.ID,
                                                            ReservedIdentifiers.DefaultContinueConversationStringID,
                                                            null,
                                                            null,
                                                            null);
            }
            else
            {
                conversationChoice = new ConversationChoice(parent,
                                                            source.ID,
                                                            source.TextID,
                                                            source.CanShowID,
                                                            source.OnSelectedID,
                                                            source.NavigateTo);
            }
            return(conversationChoice);
        }
        internal static ConversationNode AsConversationNode(this ConversationNodeJsonData source, Conversation parent)
        {
            ConversationNode   conversationNode = null;
            ConversationChoice defaultOk        = null;
            bool useDefaultOk = true;

            conversationNode = new ConversationNode(parent, source.ID, source.CharacterID, source.TextID);

            if (source.Choices != null)
            {
                if (source.Choices.Length > 0)
                {
                    useDefaultOk = false;
                    foreach (ConversationChoiceJsonData conversationChoiceData in source.Choices)
                    {
                        ConversationChoice currentConversationChoice = conversationChoiceData.AsConversationChoice(conversationNode);
                        conversationNode.AddChoice(currentConversationChoice);
                    }
                }
            }

            if (useDefaultOk)
            {
                // Must be optimized. This is really ugly.
                defaultOk = new ConversationChoice(conversationNode,
                                                   ReservedIdentifiers.DefaultContinueConversationChoiceID,
                                                   ReservedIdentifiers.DefaultContinueConversationStringID,
                                                   null,
                                                   null,
                                                   null);
                conversationNode.AddChoice(defaultOk);
            }
            return(conversationNode);
        }
    void PlayerReponce(List <ConversationChoice> choices, int depth)
    {
        GUILayout.BeginVertical();

        GUILayout.Label("Player Reponce: " + depth, boldStyle);

        for (int j = 0; j < choices.Count; j++)
        {
            ConversationChoice choice = choices[j];

            GUILayout.BeginHorizontal("box");

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("-", GUILayout.Width(20)))
            {
                choices.RemoveAt(j);
            }

            EditorGUILayout.MinMaxSlider(ref choice.minKarma, ref choice.maxKarma, -100, 100, GUILayout.Width(100));
            choice.karmaReward = EditorGUILayout.FloatField(choice.karmaReward, GUILayout.Width(50));

            GUILayout.EndHorizontal();

            if (choice.text == "")
            {
                GUI.color = Color.red;
            }

            choice.text = GUILayout.TextArea(choice.text, GUILayout.MinWidth(100));

            GUILayout.EndVertical();

            GUI.color = Color.white;

            if (choice.responces.Count == 0)
            {
                if (GUILayout.Button("Add AI", GUILayout.Width(100)))
                {
                    choice.responces.Add(new ConversationChoice());
                }
            }
            else
            {
                ChoiceList(choice.responces, depth + 1);
            }

            GUILayout.EndHorizontal();
        }

        if (GUILayout.Button("Add Player", GUILayout.Width(100)))
        {
            choices.Add(new ConversationChoice());
        }

        GUILayout.EndVertical();
    }
Example #7
0
 public void disableConvo()
 {
     convParent.SetActive(false);
     currentConvo  = null;
     i             = 0;
     currentChoice = null;
     textToDisplay.Clear();
 }
Example #8
0
    public void addChoice(ConversationChoice c)
    {
        if (initialOptions == null)
        {
            initialOptions = new List <ConversationChoice> ();
        }

        initialOptions.Add(c);
    }
    public void addChoice(ConversationChoice c)
    {
        if (nextChoices == null)
        {
            nextChoices = new List <ConversationChoice> ();
        }

        nextChoices.Add(c);
    }
Example #10
0
    void setOptionsFromConvo(ConversationChoice c)
    {
        AddText("Player : " + c.playerText);
        AddText(currentConvo.personSpeakingTo + " : " + c.NPCResponse);
        c.done = true;
        //myText.rectTransform.anchoredPosition = new Vector2 (myText.rectTransform.anchoredPosition.x, Mathf.Lerp (((myText.rectTransform.rect.height / 1.9f) * -1)-50, i*10, 0.0f));

        if (c.myTrigger == null)
        {
        }
        else
        {
            c.myTrigger.OnOptionSelect();
        }

        currentChoice = c;
        index         = 0;

        filteredChoices = new List <ConversationChoice> ();
        foreach (ConversationChoice c2 in c.getChoices())
        {
            if (c2.done == false || c2.done == true && c2.repeatable == true)
            {
                filteredChoices.Add(c);
            }
        }

        lengthOfCurrentChoices = filteredChoices.Count;
        setOptions();
        upButton.gameObject.SetActive(shouldWeDisplayUpArrow());
        downButton.gameObject.SetActive(shouldWeDisplayDownArrow());
        //setButtonOptions (c.getChoices ());

        /*if (c.nextChoices.Count > 0) {
         *      button1.gameObject.SetActive (true);
         *      button1.gameObject.GetComponentInChildren<Text> ().text = c.nextChoices [0].playerText;
         * } else {
         *      button1.gameObject.SetActive (false);
         * }
         * if (c.nextChoices.Count > 1) {
         *      button2.gameObject.SetActive (true);
         *      button2.gameObject.GetComponentInChildren<Text> ().text = c.nextChoices [1].playerText;
         * } else {
         *      button2.gameObject.SetActive (false);
         * }
         * if (c.nextChoices.Count > 2) {
         *      button3.gameObject.SetActive (true);
         *      button3.gameObject.GetComponentInChildren<Text> ().text = c.nextChoices [2].playerText;
         * } else {
         *      button3.gameObject.SetActive (false);
         * }*/
    }
Example #11
0
        public override bool FireEvent(Event E)
        {
            if (E.ID == "ShowConversationChoices")
            {
                if (XRLCore.Core.Game.Player.Body.GetPart <acegiak_CustomsPainting>() != null)
                {
                    if (this.GetPaintingRecipe() != null && !this.GetPaintingRecipe().revealed)
                    {
                        if (E.GetParameter <ConversationNode>("CurrentNode") != null && E.GetParameter <ConversationNode>("CurrentNode") is WaterRitualNode)
                        {
                            WaterRitualNode           wrnode  = E.GetParameter <ConversationNode>("CurrentNode") as WaterRitualNode;
                            List <ConversationChoice> Choices = E.GetParameter <List <ConversationChoice> >("Choices") as List <ConversationChoice>;

                            if (Choices.Where(b => b.ID == "LearnPaintingStyle").Count() <= 0)
                            {
                                bool canlearn = XRLCore.Core.Game.PlayerReputation.get(ParentObject.pBrain.GetPrimaryFaction()) > 50;

                                ConversationChoice conversationChoice = new ConversationChoice();
                                conversationChoice.Text       = (canlearn?"&G":"&K") + "Teach me to paint &W" + this.GetPaintingRecipe().FormName + (canlearn?"&g":"&K") + " [" + (canlearn?"&C":"&r") + "-50" + (canlearn?"&g":"&K") + " reputation]";
                                conversationChoice.GotoID     = "End";
                                conversationChoice.ParentNode = wrnode;
                                conversationChoice.ID         = "LearnPaintingStyle";
                                conversationChoice.onAction   = delegate()
                                {
                                    if (!canlearn)
                                    {
                                        Popup.Show("You do not have enough reputation.");
                                        return(false);
                                    }
                                    this.GetPaintingRecipe().revealed = true;
                                    Popup.Show("You learned to paint: " + this.GetPaintingRecipe().FormName);
                                    JournalAPI.AddAccomplishment("You learned to paint " + this.GetPaintingRecipe().FormName);
                                    JournalAPI.AddObservation(this.GetPaintingRecipe().FormName + ":\n" + this.GetPaintingRecipe().FormDescription, this.GetPaintingRecipe().FormName, "Painting Forms", null, null, true);
                                    XRLCore.Core.Game.PlayerReputation.modify(Factions.get(ParentObject.pBrain.GetPrimaryFaction()).Name, -50, false);

                                    return(true);
                                };
                                Choices.Add(conversationChoice);
                                Choices.Sort(new ConversationChoice.Sorter());
                                // wrnode.Choices.Add(conversationChoice);
                                // wrnode.SortEndChoicesToEnd();
                                E.SetParameter("CurrentNode", wrnode);
                            }
                        }
                    }
                }
            }
            return(base.FireEvent(E));
        }
Example #12
0
        public void HandleBeginConversation(Conversation conversation, GameObject speaker)
        {
            if (conversation.NodesByID != null &&
                conversation.NodesByID.Count > 0 &&
                speaker != null &&
                speaker.GetPart <acegiak_Romancable>() != null)
            {
                conversation.NodesByID.ToList().Where(pair => pair.Key.StartsWith("acegiak_romance_")).ToList().ForEach(pair => conversation.NodesByID.Remove(pair.Key));


                string StartID = conversation.NodesByID.Keys.ToArray()[0];
                if (conversation.NodesByID.ContainsKey("Start"))
                {
                    StartID = "Start";
                }
                speaker.GetPart <acegiak_Romancable>().havePreference();

                acegiak_RomanceChatNode aboutme = new acegiak_RomanceChatNode();
                aboutme.ID   = "acegiak_romance_aboutme";
                aboutme.Text = "Very well.";
                aboutme.ParentConversation = conversation;


                ConversationChoice returntostart = new ConversationChoice();
                returntostart.Text       = "Ok.";
                returntostart.GotoID     = "End";
                returntostart.ParentNode = aboutme;

                aboutme.Choices.Add(returntostart);

                ConversationChoice romanticEnquiry = new ConversationChoice();
                romanticEnquiry.ParentNode = conversation.NodesByID[StartID];
                romanticEnquiry.ID         = "acegiak_romance_askaboutme";
                romanticEnquiry.Text       = "Let's chat.";
                romanticEnquiry.GotoID     = "acegiak_romance_aboutme";
                romanticEnquiry.Ordinal    = 800;


                conversation.AddNode(aboutme);
                foreach (ConversationNode node in conversation.StartNodes)
                {
                    node.Choices.RemoveAll(choice => choice.ID.StartsWith("acegiak_romance_"));
                    node.Choices.Add(romanticEnquiry);
                }
            }
        }
    public static List <ConversationChoice> GetRootChoicesAtRandom(int count, ConversationChoice exclude)
    {
        int minCount = Mathf.Min(count, GetData().choices.Count);

        List <ConversationChoice> choices = new List <ConversationChoice>(GetData().choices);
        List <ConversationChoice> chosen  = new List <ConversationChoice>();

        while (chosen.Count < minCount)
        {
            ConversationChoice c = choices[Random.Range(0, choices.Count)];
            if (c != exclude)
            {
                chosen.Add(c);
                choices.Remove(c);
            }
        }
        return(chosen);
    }
 public void RemoveOldEgcbChoices(ConversationNode cNode)
 {
     if (cNode == null || cNode.Choices == null)
     {
         return;
     }
     for (int i = cNode.Choices.Count - 1; i >= 0; i--)
     {
         ConversationChoice cChoice = cNode.Choices[i];
         if (cChoice != null && cChoice.Execute != null && cChoice.Execute.Contains(":"))
         {
             string executeType = cChoice.Execute.Split(':')[0];
             if (executeType == "XRL.World.Parts.Egcb_PlayerUIHelper")
             {
                 cNode.Choices.RemoveAt(i);
             }
         }
     }
 }
Example #15
0
        public void DisplayConversationNode(ConversationNode node)
        {
            ConversationNode currNode = DialogController.GetInstance().currNode;

            if (!initialized)
            {
                return;
            }

            HideChoices();

            // Load the correct image
            portraitImg.sprite = DialogController.GetInstance().GetPortraitSprite(currNode.spriteName);

            // Display the dialog text
            dialogText.text = currNode.displayBody;

            // If it's the last node then we can assume there's no choice to be made and
            // all that's necessary is a continue
            if (currNode.tags.Contains(Conversation.TAG_END))
            {
                // If it's the end of the conversation or there are no choices continue;
                choices[0].gameObject.SetActive(true);
                choicesText[0].text = UIConstants.CONV_CONTINUE;
                return;
            }

            // Iterate through the choices and set up the choice buttons
            for (int i = 0; i < currNode.choices.Count; i++)
            {
                ConversationChoice choice = currNode.choices[i];

                Button choiceBtn = choices[i];

                // Re-enable it to make it visible.
                choiceBtn.gameObject.SetActive(true);

                Text choiceTxt = choicesText[i];
                choiceTxt.text = i + ") " + choice.text;
            }
        }
        public static bool AddChoiceToRestockers(Conversation convo = null, GameObject speaker = null)
        {
            int _debugSegmentCounter = 0;

            try
            {
                if (speaker == null)
                {
                    if (Egcb_PlayerUIHelper.ConversationPartner == null)
                    {
                        return(false);
                    }
                    speaker = Egcb_PlayerUIHelper.ConversationPartner;
                    convo   = speaker.GetPart <ConversationScript>().customConversation;
                    if (convo == null)
                    {
                        return(false);
                    }
                }
                _debugSegmentCounter = 1;

                //you must view a trader's goods before the new conversation options become available.
                if (!Egcb_PlayerUIHelper.ZoneTradersTradedWith.Contains(speaker))
                {
                    return(false);
                }
                _debugSegmentCounter = 2;

                //clean up old versions of the conversation if they exist
                if (convo.NodesByID.ContainsKey("*Egcb_RestockDiscussionNode"))
                {
                    _debugSegmentCounter = 3;
                    convo.NodesByID.Remove("*Egcb_RestockDiscussionNode");
                    if (convo.NodesByID.ContainsKey("Start"))
                    {
                        _debugSegmentCounter = 4;
                        for (int i = 0; i < convo.NodesByID["Start"].Choices.Count; i++)
                        {
                            if (convo.NodesByID["Start"].Choices[i].ID == "*Egcb_RestockerDiscussionStartChoice")
                            {
                                convo.NodesByID["Start"].Choices.RemoveAt(i);
                                break;
                            }
                        }
                    }
                }
                _debugSegmentCounter = 5;

                long ticksRemaining;
                bool bChanceBasedRestock = false;
                if (speaker.HasPart("Restocker"))
                {
                    _debugSegmentCounter = 6;
                    Restocker r = speaker.GetPart <Restocker>();
                    ticksRemaining       = r.NextRestockTick - ZoneManager.Ticker;
                    _debugSegmentCounter = 7;
                }
                else if (speaker.HasPart("GenericInventoryRestocker"))
                {
                    _debugSegmentCounter = 8;
                    GenericInventoryRestocker r = speaker.GetPart <GenericInventoryRestocker>();
                    ticksRemaining       = r.RestockFrequency - (ZoneManager.Ticker - r.LastRestockTick);
                    bChanceBasedRestock  = true;
                    _debugSegmentCounter = 9;
                }
                else
                {
                    return(false);
                }
                _debugSegmentCounter = 10;

                //build some dialog based on the time until restock and related parameters. TraderDialogGenData ensures the dialog options
                //stay the same for a single trader during the entire time that trader is waiting for restock
                TraderDialogGenData dialogGen = TraderDialogGenData.GetData(speaker, ticksRemaining);
                _debugSegmentCounter = 11;
                double daysTillRestock = (double)ticksRemaining / 1200.0;
                string restockDialog;
                if (daysTillRestock >= 9)
                {
                    _debugSegmentCounter = 12;
                    if (speaker.Blueprint == "Sparafucile")
                    {
                        restockDialog = "\n&w*Sparafucile pokes at a few of =pronouns.possessive= wares and then gazes up at you, squinting, as if to question the basis of your inquiry.*&y\n ";
                    }
                    else
                    {
                        restockDialog = (dialogGen.Random2 == 1)
                            ? "Business is booming, friend.\n\nI'm pretty satisfied with what I've got for sale right now; maybe you should look for another "
                                        + "vendor if you need something I'm not offering. I'll think about acquiring more goods eventually, but it won't be anytime soon."
                            : "Don't see anything that catches your eye?\n\nWell, you're in the minority. My latest shipment has been selling well and "
                                        + "it'll be a while before I think about rotating my stock.";
                    }
                }
                else
                {
                    _debugSegmentCounter = 13;
                    if (speaker.Blueprint == "Sparafucile")
                    {
                        _debugSegmentCounter = 14;
                        if (daysTillRestock < 0.5)
                        {
                            _debugSegmentCounter = 15;
                            restockDialog        = "\n&w*Sparafucile nods eagerly, as if to convey that =pronouns.subjective= is expecting something very soon.*&y\n ";
                        }
                        else
                        {
                            restockDialog = "\n&w*Smiling, Sparafucile gives a slight nod.*&y\n\n"
                                            + "&w*=pronouns.Subjective= purses =pronouns.possessive= lips thoughtfully for a moment, then raises " + Math.Max(1, (int)daysTillRestock) + " thin fingers.*&y\n ";
                        }
                    }
                    else
                    {
                        _debugSegmentCounter = 16;
                        string daysTillRestockPhrase = (daysTillRestock < 0.5) ? "in a matter of hours"
                                    : (daysTillRestock < 1) ? "by this time tomorrow"
                                    : (daysTillRestock < 1.8) ? "within a day or two"
                                    : (daysTillRestock < 2.5) ? "in about two days' time"
                                    : (daysTillRestock < 3.5) ? "in about three days' time"
                                    : (daysTillRestock < 5.5) ? "in four or five days"
                                    : "in about a week, give or take";
                        string pronounObj  = (dialogGen.Random3 == 1 ? "him" : (dialogGen.Random3 == 2 ? "her" : "them"));
                        string pronounSubj = (dialogGen.Random3 == 1 ? "he" : (dialogGen.Random3 == 2 ? "she" : "they"));
                        restockDialog =
                            (dialogGen.Random4 == 1) ? "There are rumors of a well-stocked dromad caravan moving through the area.\n\nMy sources tell me the caravan "
                            + "should be passing through " + daysTillRestockPhrase + ". I'll likely able to pick up some new trinkets at that time."
                            + (bChanceBasedRestock ? "\n\nOf course, they are only rumors, and dromads tend to wander. I can't make any guarantees." : string.Empty)
                            : (dialogGen.Random4 == 2) ? "My friend, a water baron is coming to visit this area soon. I sent " + pronounObj + " a list of my requests and should "
                            + "have some new stock available after " + pronounSubj + " arrive" + (pronounSubj == "they" ? "" : "s") + ".\n\n"
                            + "By the movements of the Beetle Moon, I predict " + pronounSubj + " should be here " + daysTillRestockPhrase + "."
                            + (bChanceBasedRestock ? "\n\nIn honesty, though, " + pronounSubj + (pronounSubj == "they" ? " are" : " is") + " not the most "
                               + "reliable friend. I can't make any guarantees." : string.Empty)
                            : (dialogGen.Random4 == 3) ? "It just so happens my apprentice has come upon a new source of inventory, and is negotiating with the merchant in a "
                            + "nearby village.\n\nThose talks should wrap up soon and I expect to have some new stock " + daysTillRestockPhrase + "."
                            + (bChanceBasedRestock ? "\n\nOf course, negotiations run like water through the salt. I can't make any guarantees." : string.Empty)
                            : "I'm glad you asked, friend. Arconauts have been coming in droves from a nearby ruin that was recently unearthed. "
                            + "They've been selling me trinkets faster than I can sort them, to be honest. After I manage to get things organized "
                            + "I'll have more inventory to offer.\n\nCheck back with me " + daysTillRestockPhrase + ", and I'll show you what I've got."
                            + (bChanceBasedRestock ? "\n\nThat is... assuming any of the junk is actually resellable. I can't make any guarantees." : string.Empty);
                    }
                    _debugSegmentCounter = 17;
                }

                //DEBUG ONLY
                _debugSegmentCounter = 18;

                //add options to ask location of quest givers for whom the quest has already started
                if (convo.NodesByID.ContainsKey("Start"))
                {
                    _debugSegmentCounter = 19;
                    //create node with info about trading
                    string           restockNodeID = "*Egcb_RestockDiscussionNode";
                    ConversationNode restockNode   = ConversationsAPI.newNode(restockDialog, restockNodeID);
                    _debugSegmentCounter = 20;
                    restockNode.AddChoice("I have more to ask.", "Start", null);
                    restockNode.AddChoice("Live and drink.", "End", null);
                    convo.AddNode(restockNode);
                    _debugSegmentCounter = 21;
                    ConversationNode startNode = convo.NodesByID["Start"];
                    int rand = Stat.Random(1, 3);
                    _debugSegmentCounter = 22;
                    ConversationChoice askRestockChoice = new ConversationChoice
                    {
                        ID   = "*Egcb_RestockerDiscussionStartChoice",
                        Text = (rand == 1) ? "Any new wares on the way?"
                            : (rand == 2) ? "Do you have anything else to sell?"
                            : "Can you let me know if you get any new stock?",
                        GotoID     = restockNodeID,
                        ParentNode = startNode,
                        Ordinal    = 991 //set to make this appear immediately after the trade option
                    };
                    _debugSegmentCounter = 23;
                    startNode.Choices.Add(askRestockChoice);
                    _debugSegmentCounter = 24;
                    startNode.SortEndChoicesToEnd();
                    _debugSegmentCounter = 25;
                }
                _debugSegmentCounter = 26;
                return(true);
            }
            catch (Exception ex)
            {
                Debug.Log("QudUX Mod: Error encountered in AddChoiceToRestockers (debugSegment: " + _debugSegmentCounter + ", Exception: " + ex.ToString() + ")");
                return(false);
            }
        }
Example #17
0
        public acegiak_RomanceChatNode BuildNode(acegiak_RomanceChatNode node)
        {
            havePreference();
            this.lockout = false;
            node.Choices.Clear();
            //IPart.AddPlayerMessage("They are:"+ParentObject.pBrain.GetOpinion(XRLCore.Core.Game.Player.Body)+": "+ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body).ToString()+" patience:"+patience.ToString());

            if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1 && patience > 0)
            {
                ParentObject.pBrain.SetFeeling(XRLCore.Core.Game.Player.Body, 1);
            }

            if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1 || patience <= 0)
            {
                List <string> Stories = new List <string>(new string[] {
                    "Sorry, I have other things to do.",
                    "Anyway, I'm very busy.",
                    "Maybe we could talk some more another time?"
                });
                node.Text = node.Text + "\n\n" + Stories[Stat.Rnd2.Next(0, Stories.Count - 1)];

                ConversationChoice returntostart = new ConversationChoice();
                returntostart.Ordinal    = 800;
                returntostart.Text       = "Ok.";
                returntostart.GotoID     = node.ParentConversation.StartNodes[0].ID;
                returntostart.ParentNode = node;
                node.Choices.Add(returntostart);
            }
            else if (boons.Where(b => b.BoonReady(XRLCore.Core.Game.Player.Body)).Count() > 0)
            {
                acegiak_RomanceBoon boon = boons.Where(b => b.BoonReady(XRLCore.Core.Game.Player.Body)).OrderBy(o => Stat.Rnd2.NextDouble()).FirstOrDefault();
                try
                {
                    node = boon.BuildNode(node);
                    node.InsertMyReaction(ParentObject, XRLCore.Core.Game.Player.Body);
                    node.ExpandText(GetSelfEntity());
                }
                catch (Exception e)
                {
                    node.Text = e.ToString() + "\n\n" + node.Text;
                }
            }
            else
            {
                int c             = 0;
                int whichquestion = 0;
                do
                {
                    whichquestion = Stat.Rnd2.Next(0, preferences.Count);
                    c++;
                }while(whichquestion == lastQuestion && c < 5);
                lastQuestion = whichquestion;
                try
                {
                    node = preferences[whichquestion].BuildNode(node);
                    node.InsertMyReaction(ParentObject, XRLCore.Core.Game.Player.Body);
                    node.ExpandText(GetSelfEntity());
                }
                catch (Exception e)
                {
                    node.Text = e.ToString() + "\n\n" + node.Text;
                }

                if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) > 5)
                {
                    acegiak_RomanceChatChoice giftoption = new acegiak_RomanceChatChoice();
                    giftoption.Ordinal    = 900;
                    giftoption.Text       = "[Offer A Gift]";
                    giftoption.action     = "*Gift";
                    giftoption.ParentNode = node;
                    giftoption.GotoID     = "End";
                    node.Choices.Add(giftoption);
                }
                if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) >= 25)
                {
                    acegiak_RomanceChatChoice kissoption = new acegiak_RomanceChatChoice();
                    kissoption.Ordinal    = 910;
                    kissoption.Text       = "[Propose a Date]";
                    kissoption.action     = "*Date";
                    kissoption.ParentNode = node;
                    kissoption.GotoID     = "End";
                    node.Choices.Add(kissoption);
                }
                if (ParentObject.GetPart <acegiak_Kissable>() != null && ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) >= 55)
                {
                    acegiak_RomanceChatChoice kissoption = new acegiak_RomanceChatChoice();
                    kissoption.Ordinal    = 910;
                    kissoption.Text       = "[Attempt to Kiss]";
                    kissoption.action     = "*Kiss";
                    kissoption.ParentNode = node;
                    kissoption.GotoID     = "End";
                    node.Choices.Add(kissoption);
                }
            }
            if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1)
            {
                ParentObject.pBrain.SetFeeling(XRLCore.Core.Game.Player.Body, 1);
            }



            patience--;


            ConversationChoice liveanddrink = new ConversationChoice();

            liveanddrink.Ordinal    = 99999;
            liveanddrink.Text       = "Live and drink.";
            liveanddrink.GotoID     = "End";
            liveanddrink.ParentNode = node;
            node.Choices.Add(liveanddrink);


            return(node);
        }
Example #18
0
        public override bool FireEvent(Event E)
        {
            if (E.ID == "AIBored")
            {
                if (ParentObject.GetPart <Inventory>() != null)
                {
                    if (XRLCore.Core.Game.TimeTicks - lastPlayed > 100)
                    {
                        lastPlayed = XRLCore.Core.Game.TimeTicks;

                        foreach (GameObject GO in ParentObject.GetPart <Inventory>().GetObjects())
                        {
                            if (GO.GetPart <acegiak_Musical>() != null)
                            {
                                GO.FireEvent(XRL.World.Event.New("InvCommandPlayTune", "Owner", ParentObject, "Object", GO));
                            }
                        }
                    }
                }
            }



            if (E.ID == "ShowConversationChoices" && !ParentObject.IsPlayer())
            {
                if (XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>() != null && XRLCore.Core.Game.Player.Body.HasSkill("acegiak_Customs_Music"))
                {
                    //IPart.AddPlayerMessage("My tags are:" + String.Join(", ", FactionTags(ParentObject.pBrain.GetPrimaryFaction()).ToArray()));

                    if (this.Songs.Count > 0 && !this.learnedFrom)
                    {
                        if (E.GetParameter <ConversationNode>("CurrentNode") != null && E.GetParameter <ConversationNode>("CurrentNode") is WaterRitualNode)
                        {
                            WaterRitualNode           wrnode  = E.GetParameter <ConversationNode>("CurrentNode") as WaterRitualNode;
                            List <ConversationChoice> Choices = E.GetParameter <List <ConversationChoice> >("Choices") as List <ConversationChoice>;

                            if (Choices.Where(b => b.ID == "LearnSong").Count() <= 0)
                            {
                                bool canlearn = XRLCore.Core.Game.PlayerReputation.get(ParentObject.pBrain.GetPrimaryFaction()) >= 50;

                                ConversationChoice conversationChoice = new ConversationChoice();
                                conversationChoice.Text       = (canlearn?"&G":"&K") + "Teach me to play &W" + this.Songs[0].Name + (canlearn?"&g":"&K") + " [" + (canlearn?"&C":"&r") + "-50" + (canlearn?"&g":"&K") + " reputation]";
                                conversationChoice.GotoID     = "End";
                                conversationChoice.ParentNode = wrnode;
                                conversationChoice.ID         = "LearnSong";
                                conversationChoice.onAction   = delegate()
                                {
                                    if (!canlearn)
                                    {
                                        Popup.Show("You do not have enough reputation.");
                                        return(false);
                                    }
                                    XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>().Songs.Add(this.Songs[0]);
                                    this.learnedFrom = true;
                                    Popup.Show("You learned to play " + this.Songs[0].Name);

                                    JournalAPI.AddAccomplishment("You learned to play " + this.Songs[0].Name);
                                    JournalAPI.AddObservation(Faction.getFormattedName(ParentObject.pBrain.GetPrimaryFaction()) + " play a song called \"" + this.Songs[0].Name + "\"", this.Songs[0].Name, "Songs", null, null, true);
                                    XRLCore.Core.Game.PlayerReputation.modify(Factions.get(ParentObject.pBrain.GetPrimaryFaction()).Name, -50, false);

                                    return(true);
                                };
                                Choices.Add(conversationChoice);
                                Choices.Sort(new ConversationChoice.Sorter());
                                // wrnode.Choices.Add(conversationChoice);
                                // wrnode.SortEndChoicesToEnd();
                                E.SetParameter("CurrentNode", wrnode);
                            }
                        }
                    }
                }
            }
            return(base.FireEvent(E));
        }