Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Listing objective states

Hey there,

I'm just getting started with the Objectives feature, and I have a question.

The Objectives UI seems set up now to be a bit like a quest log in a game like Skyrim, where there is a list of quests and you can click them for more information. What I'm hoping to build is more like an objectives overlay from a game like The Witcher 3 or Deus Ex, where active objectives are shown on the screen at all times with a list of their sub states visible, and this list can expand or shrink dynamically when objectives are revealed or completed/failed. It seems the InventoryBox menu element is currently only setup to reveal one state at a time on click - is there a way to show them all in labels, like this?

Quest 1

  • Objective 1
  • Objective 2 completed
  • Objective 3

Quest 2

  • Objective 1 completed
  • Objective 2 failed

Comments

  • The level of customisation to get e.g. strikethroughs through completed objectives etc would be too granular for them to be offered in a simple Label element's properties, but all the data can be accessed through AC's API for you to use in i.e. a custom Unity UI canvas.

    You can get all the current Objectives with:

    KickStarter.runtimeObjectives.GetObjectives ();
    

    See the Scripting Guide entry for more options and details, though I appreciate this is something of a rabbit hole.

    On categorising multiple "Objectives" into "Quests" - this could feasibly be done at the same time, whereby a Quest is just another Objective, that's hard coded to be dependent on other Objectives, referenced by their ID values. The RuntimeObjectives class also has functions to get / set Objective states.

    However, I shall look into this further to see if I can provide something more specific - even if it's in the form of an example script. Please leave with me for the moment.

  • OK, try this:

    https://adventure-creator.fandom.com/wiki/Quest_Objectives_and_sub-Objectives

    This allows you to classify "Quests" and their sub-Objectives by naming convention: an Objective named "MyQuest" will be the main Quest, while Objectives named "MyQuest/SubObjectiveA" and "MyQuest/SubObjectiveB" will automatically be its sub-objectives.

    Quest objectives will then be automatically completed/failed based on the state of its sub-objectives.

    The script will also output all active Quests into a formatted string, similar to the one in your example above. This string is used to update a String Variable, which can then be used how you choose.

    It's really intended more as a basis for further tweaking, though - and this is really the core of the matter when it comes to Objectives: how exactly you want them to depend on one another will vary from game to game, or even within a game. One scenario may need all sub-objectives to be completed, while another may only need a selection of them. By relying on custom logic like this, you can define the rules for this without having to rely on a limited set of options in an AC Manager.

    One thing I did notice about this though is that inserting forward-slashes into the name does mess up display in the various Objectives Actions - but this can be amended by opening InventoryManager.cs and replacing the instance of:

    labelList[i] = KickStarter.inventoryManager.objectives[i].ID.ToString () + ": " + KickStarter.inventoryManager.objectives[i].Title;
    

    (Around line 1194) with:

    labelList[i] = KickStarter.inventoryManager.objectives[i].Title;
    

    That will make them display hierarchically in Action selector popups. I'll make the same change in the next update.

  • edited April 5

    Wow @ChrisIceBox, this is amazing. It's exactly what I needed; Thanks so much!

    I'll battle-test this thing in my current project, the first test looks very promising.

  • No problem!

    I've also updated the wiki script to simplify the process. Quest IDs no longer have to be manually assigned - Quests are now assumed to be any Objective that has no forward slash in it's name.

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.
Do NOT follow this link or you will be banned from the site!