Jump to content

problem trying to randomize strings


Guest

Recommended Posts

Trying to create a conversation, getting subtitles on keypress etc is all working great only thing that isn't working is when I try to randomize something from a list....:

private int dialogWithSuspectIndex = 0;
private int SuspectResponseIndex = 0;
private List<string> dialogWithSuspect = new List<string>()
    {
        "~r~Suspect~w~: line1",
        "~b~You~w~: line2.",
        "~r~Suspect~w~: line3",
        "~b~You~w~: line4"
    };
        private List<string> suspectResponse = new List<string>()
    {
        "~r~Suspect~w~: line5",
        "~r~Suspect~w~: line6",
        "~r~Suspect~w~: line7"
    };
...
...
...
public override void Process
{
  SuspectResponseIndex = General.Random.Next(0, 3);
  dialogWithSuspect.Add(suspectResponse[SuspectResponseIndex]);
  
  if (IsTask3Done == true && player.Position.DistanceTo(Suspect) <= 4)
            {
                if (Game.IsKeyDown(Settings.TalkKey))
                {
                    if (dialogWithSuspectIndex < dialogWithSuspect.Count)
                    {
                        Game.DisplaySubtitle(dialogWithSuspect[dialogWithSuspectIndex]);
                        dialogWithSuspectIndex = dialogWithSuspectIndex + 1;
                    }
                }
            }  
}  

what isn't working is the SuspectResponseIndex part, what I am guessing is that it is randomizing the common.random.next part infinetly because when I get to the suspectResponse part it keeps playing either line5, line6 or line7....just asking for a away to only play one randomized string.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...