Forum rules - please read before posting.

Set Objective States

Hello everyone,

I am currently trying to use Objectives as a quest journal. I am wondering if there is a reason why AC uses the state ID for Objective: Set state, but uses the state label for Automatic state-switching.
Some of my objective states have the same label and only differ in their description, which means that I cannot select the correct state in the dropdown menu for All sub-obs complete.

AC: 1.85.3
Unity: 2022.3.62f3

Comments

  • State ID is always used by AC to reference objective and states. The dropdown you're referring, however, does populate its fields with the state labels.

    It's possible to amend this to also include the ID. If you open up AC's ObjectiveState script, look for the following around line 274:

    labelList.Add (popupSelectData.label);
    

    Replace it with:

    labelList.Add (popupSelectData.ID + ": " +popupSelectData.label);
    

    Does that fix it?

  • In a quick test, this now works for my concept. I'll check it again in more detail over the next few days, but for now it looks like my problem has been solved.

    Thank you :)

  • I came across another question on the topic of objectives. I would like to display the objectives and subobjectives in a menu.
    Objective Menu:
    The objective should be selected on the left (1.), and then the details (2.) and a list of according subobjectives (3.) should appear on the right. If a subobjective is then selected, the details should be updated to subobjective details (4.).

    Objective element:

    Subobjective element:

    However, I cannot create an ActionList for Inventory box Type: Sub Objectives, as is possible for Inventory box Type: Objectives. How can I reach my desired behavior otherwise?

  • I'll need to provide this functionality as part of the next update. Thanks for the alert.

  • I need to come back to the topic of Objectives. I’ve copied a second Objective menu to create a separate section for more specific quests. In that menu, I’d like to have a button that executes an ActionList depending on the currently selected Objective. I was thinking of something like Objective: Check Selected, followed by a series of ActionList: Run commands.
    But it’s not quite that simple. Is there another option?

    Unity:2022.3.62f3
    AC:1.86.0

  • That might be best done with a custom script, as you can have it run a different ActionList based on which Objective was clicked.

    Try this: paste it into a C# file named ClickObjective, add it to the scene, and fill in its Inspector array with pairs of Objective IDs and the ActionList to run.

    using UnityEngine;
    using AC;
    
    public class ClickObjective : MonoBehaviour
    {
    
        public string elementName = "MyObjectives";
        public ObjectiveActionList[] objectiveActionLists;
    
        void OnEnable() => EventManager.OnMenuElementClick += OnMenuElementClick;
        void OnDisable() => EventManager.OnMenuElementClick -= OnMenuElementClick;
    
        private void OnMenuElementClick(Menu _menu, MenuElement _element, int _slot, int buttonPressed)
        {
            if (_element == null || _element.title != elementName) return;
    
            var inventoryBox = _element as MenuInventoryBox;
            var objective = inventoryBox.GetObjective(_slot);
    
            foreach (var objectiveActionList in objectiveActionLists)
            {
                if (objectiveActionList.objectiveID == objective.ObjectiveID)
                {
                    objectiveActionList.actionListAsset.Interact();
                    return;
                }
            }
        }
    
    
        [System.Serializable]   
        public class ObjectiveActionList
        {
            public int objectiveID;
            public ActionListAsset actionListAsset;
        }
    
    }
    
  • edited June 27

    That was a great help, thank you. I’ve expanded on it a bit further. To give some background, the menu is meant to be an order book. The Objectives represent the clients, and when you select one, details (SelectedTitle, SelectedDescription, etc.) are displayed. Once the player has read the details, there’s an extra button that executes the action list for that specific client (Objective). To do this, the script now remembers the action list, and the button simply calls ‘Object: Send message -> RunCurrentObjective’.

    using UnityEngine;
    using AC;
    public class ClickObjective : MonoBehaviour
    {
    
        public string elementName = "MyObjectives";
        public ObjectiveActionList[] objectiveActionLists;
        private ActionListAsset currentActionList;
    
        void OnEnable() => EventManager.OnMenuElementClick += OnMenuElementClick;
        void OnDisable() => EventManager.OnMenuElementClick -= OnMenuElementClick;
    
        private void OnMenuElementClick(Menu _menu, MenuElement _element, int _slot, int buttonPressed)
        {
            if (_element == null || _element.title != elementName) return;
    
            var inventoryBox = _element as MenuInventoryBox;
            var objective = inventoryBox.GetObjective(_slot);
    
            foreach (var objectiveActionList in objectiveActionLists)
            {
                if (objectiveActionList.objectiveID == objective.ObjectiveID)
                {
                    currentActionList = objectiveActionList.actionListAsset;
                    return;
                }
            }
        }
    
        public void RunCurrentObjective()
        {
            if (currentActionList != null)
            {
                currentActionList.Interact();
            }
        }
    
        [System.Serializable]
        public class ObjectiveActionList
        {
            public int objectiveID;
            public ActionListAsset actionListAsset;
        }
    
    }
    
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.