Forum rules - please read before posting.

[feat/doc req] Objectives and persistent Objectives

Hi there!

I gladly found the new "Objectives" feature, and I was hoping to use it to track my game/player progresses.

I searched for every occurrence of "Objective" in the Manual and in the Scripting Guide and I'm assuming that's not what I'm looking for, or the feature I was hoping it to be.

Yet, I was explicitly looking in the docs about clear evidence about the feature not being a way to store progress, but I'm just assuming. So I created a topic trying to understand.

I could surely peek into the source code, but that's really a last resort.

All points in the direction that Objectives are a visual extension with no persistence.

So, when you save or load a game, you have to manually retrieve all the states of all the objectives using variables.

I'm assuming, and if I remember correctly, all Objectives are reset on application launch, so every save/load event needs appropriate handling via code.

At least, this is what I am assuming also having a look at other threads

Now, I know it's a touchy subject when something is done like it is "by design", yet, wouldn't it be possible to (optionally!) link objectives to variables - since I assume that 90% of the time it's what an AC user is going to manually do?

I'm thinking of something similar to the options/var linking. So an objective could be linked to no variables (eg: some minigame in a scene), a local variable (some Objective with a scene-wide scope), or a global variable (main quests and subquests).

Being able to "nest" Objectives would be great. So, an objective could either be an Objective just like now (SimpleObjective), OR also have a list of Sub-Objectives with an operator (and/or) that make the Objective Complete when the logical operator on it, applied to the list, is true (ObjectiveComplex, having a list of Objectives that could either be ObjectiveSimple or ObjectiveComples/Multiple).

I know it's quite a stretch to ask for the feature as it is right now (if I understood it correctly), yet it could evolve in a full Quest system, making it easier to track player progress in a compact way (also, saving a lot of space in the savegame/serialization) that is also somehow easier to check, since you could query Objectives and not variables (even if they're bound together).

Objective Load/Save events would help to sync the scene state with the actual appearance of the world, without having to rely too much on remembering variable names.

Extra: another type of Objective could be ObjectiveAmount, which tracks another linked variable, in objectives where completion is determined by the variable reaching a certain amount.

I know, it's a lot, and could definitely be manually extended in this way.
Yet, I believe it's more or less what every AC user is trying to do when using Objectives, so this is my brainstorming about it.

I understand at the moment it could be quite some work that doesn't fit into the design of the feature, yet I believe some of the above feature could really help a lot of user out there that wish to use Objective in a more immediate, battletestes, and native to AC way.

Comments

  • edited March 2020

    The state of Objectives are recorded in save games - and restored when loading a save file. I'm not sure what you mean here about needing to hook into load events.

    Objectives are not logic-based, though - they aren't automatically synced to variables or updated automatically based on other logic. What consitutes an Objective as being complete won't be the same for each type - one might require just a simple Bool change, another must need a series of Integers to be correct.

    In the case of being synced to a Bool, you could consider doing away with the Bool variable and simply check/set the Objective's state instead.

    You can hook into the OnVariableChange event to update an Objective through script, though.

    Not being tied to variables directly also allows for Objectives to be synced to other Objectives - allowing for the nesting you describe. When a given Objective's state is updated, you can use this state to update another - either with the provided Actions or through use of the OnObjectiveUpdate event.

  • edited March 2020

    Thanks for the clarification!
    I know it could be just me, but couldn't understand if Objectives got saved/restored in a savegame. I searched in the online docs but I may have missed that part.

    So, they are somehow persistent and you can serialize/save/load their state in the saves. Yet, you're suggesting to use them as a bool, even if they've got Active, Completed and Inactive states? Did I get it right?

    What's the calling order of the events when saving/loading a game, regarding Objectives?

    I'm looking forward to use Objectives as logical elements to save/restore the states of my scenes/scene elements.

    That would allow me to rely less on Remember scripts, and force all the narration narration progress to be bound to Objectives.

    I'm just a bit worried about the calling order.
    Of course I should be hooking into loading/saving events, or variable, to restore/save the state of the game.

    Do you have any tips on how to do that?
    A Persistent singleton "ProgressManager" created on the boot scene, to handle all saving/restoring of Objectives when a scene/scene gets loaded?

    Considering I'm going to extend Objective with a GlobalObjective class (that has a globalvarname field to restore its state on scene load), which events do you suggest leveraging on?

    EDIT:
    I've been peeking at the source code.
    Just doublechecking: is the currently selected Objective saved/restored in the savegames? If it isn't, could it be an (optional) feature in the future? (I know I could always use variables, but still...)

  • edited March 2020

    (out of comment edit-time)

    How could I force/hack all objectives to have different number of "Default" states.
    Currently there are 2 (Active and Complete). I'd like to avoid having to add "Inactive" and "Failed" each time I create another in the editor.
    Where should I be adding such code?
    I was thinking about having:
    -1 == Inactive
    2 = Failed

    not sure if using these values is going to affect the code (saving? Bool check?) in some other way.

    If I could refactor the int values, I'd use:
    0 = inactive
    1 = started
    2 = completed/success
    3 = failed
    4 = impossible to complete
    5 = refused to accept it

    Thanks!
    (also, thanks for all of the changes and updates you did these months, they didn't get unnoticed, I greatly appreciated seeing them there :) )

  • edited March 2020

    you're suggesting to use them as a bool, even if they've got Active, Completed and Inactive states?

    I'm not suggesting they're a direct replacement for any bool, but if you're using a bool to determine if something's been achieved or not, then you could feasibly check if an Objective has been completed instead. This may or may not be appropriate for a given variable - it depends on the situation.

    What's the calling order of the events when saving/loading a game, regarding Objectives?

    Data is loaded in at the same time as all other global data - though specifically it's just after the music is restored. It's all handled before the OnFinishLoading event, however.

    Of course I should be hooking into loading/saving events, or variable, to restore/save the state of the game.

    As this is handled automatically, I'm not clear on why you're talking about this. If you're not relying on AC to handled data-loading automatically, you'll have to elaborate on the actual situation here.

    is the currently selected Objective saved/restored in the savegames?

    It is not, but I will consider this as a possibility.

    How could I force/hack all objectives to have different number of "Default" states.

    Default states are added in the Objective class constructor, but there is no "Inactive" state. An inactive Objective is like an inventory item that isn't currently held - it's just not included in any save data.

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.