Forum rules - please read before posting.

Updating a "Connect the Dots" logic puzzle where some dots have multiple possible states? (and more)

edited October 2019 in Technical Q&A

Hey gang, long-time Adventure Creator, first-time poster. Love the software.

Over the last few days I've been prototyping a 2D detective game. I have all the mechanics down except one - the "Logic Board".

It's quite similar to the deduction mechanic seen during the first minute of this video:

Essentially, raw clues during the investigation are combined into deduction "nodes". Some of those nodes have two states: Clicking on them brings up both options (e.g. innocent flirting or jilted lover) with a small image and a short blurb of text. Clicking on one of the options switches the node and thus re-wires the connections, leading to multiple potential endings for the case.

I've managed to make something similar, but I'm starting to see issues with future scaling in the way I've designed it.

Here's how it works in mine:

Every physical clue is an item of one category that, when combined with the appropriate other clue, removes the clues and adds a node (an item of another category) into the main logic board. Clicking on these switches them (if possible) between their two states, and right-clicking brings up an AC document describing the node (but only that one). Whenever a node is added or switched into, it checks the presence of other nodes that it can possibly pair with in order to make one of the larger connections.

These larger connections in turn connect with other larger connections after checking for their presence in the inventory, ultimately forming a conclusion - an item of a third category that, when clicked, asks for confirmation, offers a moral choice, and then plays the appropriate ending cutscene.

This works fine for one or two endings. However, because the larger nodes depend on each other to form conclusions, changing one minor node's state disrupts the chain of logic. That's fine, that's what I want - but I'm worried that this will become too convoluted, or introduce unforeseen problems down the track.

For example, let's say that one minor node (A's Innocence / A's Guilt) determines whether to consider Character A a suspect or innocent, but mistaken based on his statements that are incongruent with the evidence. Along with, say, A's footprints at the scene, A's animosity towards the victim. A's Guilt combines with "B's Innocence" to form the conclusion "A The Killer" or with "B's guilt" to form the conclusion "Two Killers". B's innocence or guilt also hinge on multiple nodes and choices.

So, switching the node from "A's Guilt" back to "A's Innocence" means you have to:
remove A's Guilt, add A's Innocence
check for A the Killer (conclusion)
check for Two Killers (conclusion)
and remove them
Check for B's Guilt, and add B the Killer (conclusion) if so
If not and B's innocence is present, add "Burglar Did It" (A's original story) as a conclusion

Switching it from A's Innocence to A's Guilt means checking for A's footprints, A's animosity towards the victim, adding A the Killer if B's Innocence is present or Two Killers if B's Guilt is present.

Again, this is fine, but I worry that if I want to make a case with, say, 5 or more character and endings, that the logic could eventually break down or become overly cumbersome over time. Because the player can find evidence non-linearly (or miss it entirely) and because switching the state of nodes removes and adds the inventory items, I have to essentially check and re-draw almost the entire tree (depending on how integral the node is to the case) for the case each time, which might become insane when there are 30 clues.

Sorry for the long explanation. Basically, it does work, but it might scale poorly. I guess I'm asking if my solution is decent (in which case I don't mind sticking with it as long as it will work), or if I'm missing some very obvious way to do this much more simply - An actionlist to just recalculate and draw the grid on demand that I can just run after every node update or something

My other questions are:

  1. How can I bring up both options at once and click to choose there, instead of just clicking on the node to switch them? I can't figure out how to 1. display multiple documents or 2. change the node appropriately without clicking on the inventory. Maybe global variables? I'm very new to programming.

  2. How would I go about dynamically connecting the dots, or some similar effect?

  3. Can I arbitrarily edit the text and graphics of UI elements with actionlists?

  4. I can never get UI labels to work with variable tokens. I set their text as [var:1] in both the AC menu and the Unity canvas, but no dice.

Thanks in advance for your help. Please don't feel the need to answer all of those questions. The logic board is the one I'm most interested in, and I know some of these are kind of abstract and unclear.

Comments

  • Welcome to the community, @BarryBingo.

    Impressive that you've achieved something similar to the video using Inventory items and Documents! While I do try to make such features flexible to be used in non-standard ways, I'd personally choose to make such a system with scripting, so that it's designed to work as intended from the start.

    To incorporate more AC elements and rely less on scripting, I'd recommend switching over to variables to keep track of node states. The PopUp variable type can be used to store these states: for example, a "Character A" PopUp variable could have the possible values "A is innocent", and "A is guilty". The Variable: Check, Variable: Set and Variable: PopUp switch Actions could then be used to read/manipulate this variable accordingly.

    Working out the dependencies of the different nodes, then, would (I'm guessing, from how I understand you) just then be a case of reading/writing a series of variables. While this could be done in an ActionList, it may be easier to do so through scripting. See the Manual's "Variable scripting" chapter, as well as the front page of the Scripting Guide, for examples on this - but variable values can typically be read and written through single line script commands. If you have many variables dependent on one another, I'd imagine this'd be the easier way to handle them.

    Having inventory items as the visual thing to click on in a Menu is a smart idea - I expect you're adding these items to the Player's inventory upon getting clues? What you could do is instead connect items to variables, so that - when the puzzle begins - all such items are cleared from the player's inventory, and then ones are added according to the variable states. You could, then, have an additional "Hidden" PopUp state (the default value) in the "Character A" example above - which tells the game to not add this as an item. This, too, could be done through script - see the "Inventory scripting" chapter for details, but you could typically do this with something like:

    // Add item '2' if Global Variable '1' is not 'Hidden'
    if (GlobalVariables.GetPopupValue (1) != "Hidden")
    {
        KickStarter.runtimeInventory.Add (2);
    }
    

    I can advise more on how to go about such scripts, but it really depends on how you want to approach this.

    How can I bring up both options at once and click to choose there, instead of just clicking on the node to switch them?

    Best to use Label menu elements for each aspect, rather than Journal elements set to display the active document, of which there can only be one. Using variable tokens to store each choice text, Document text can be extracted through script, so it'd be feasible to update variables (and hence the UI) with an appropriate script.

    If these "choices" were shown in a new Menu (named e.g. "ShowChoices"), then you could hook into the OnMenuTurnOn custom event to read the last-clicked inventory item and update the variables accordingly:

    private void OnEnable ()
    {
        EventManager.OnMenuTurnOn += OnMenuTurnOn;
    }
    
    private void OnDisable ()
    {
        EventManager.OnMenuTurnOn -= OnMenuTurnOn;
    }
    
    private void OnMenuTurnOn (Menu menu, bool isInstant)
    {
        if (menu.title == "ShowChoices")
        {
            if (KickStarter.runtimeInventory.lastClickedItem.id == 1)
            {
                // Clicked on item ID 1, so update Variable IDs 2 and 3 with Document IDs 3 and 4:
                GlobalVariables.SetStringValue (2, KickStarter.inventoryManager.GetDocument (3).pages[0].text);
                GlobalVariables.SetStringValue (3, KickStarter.inventoryManager.GetDocument (4).pages[0].text);
            }
        }
    }
    

    It'd be best however, in a "proper" script, to create a new class that lets you match up variables to documents and inventory items in the Inspector, but again - best to know how you want to approach this all first.

    Can I arbitrarily edit the text and graphics of UI elements with actionlists?

    Custom Actions can do whatever you like, but menu text can be updated by use of tokens. UI graphics can also be changed through animation, and then using the Object: Animate Action to update an Animator's playback.

    I can never get UI labels to work with variable tokens. I set their text as [var:1] in both the AC menu and the Unity canvas, but no dice.

    Don't update the Unity canvas - the text there will be updated by what you set in the Label text field in the Menu Manager. Share screenshots if you wish, as it should work, but a tutorial on this topic can be found here.

  • Chris,

    Thank you so much for the prompt and detailed response. This is exactly what I was looking for. I would make this reply longer, but I'm going to start looking into this immediately. Thank you, you absolute legend!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.