Exemplo n.º 1
0
        public override void Update(Task caller)
        {
            // Set complete right away as we could be clearing our own task
            // If we set complete at end it just overwrites the rearm
            SetComplete();

            foreach (Symbol taskSymbol in taskSymbols)
            {
                Task task = ParentQuest.GetTask(taskSymbol);
                if (task != null)
                {
                    task.Clear();
                }
            }
        }
Exemplo n.º 2
0
        public override void Update(Task caller)
        {
            // Set complete right away as we could be disabling our own task
            SetComplete();

            foreach (Symbol taskSymbol in taskSymbols)
            {
                // Drop task
                Task task = ParentQuest.GetTask(taskSymbol);
                if (task != null)
                {
                    task.Drop();
                }
            }
        }
Exemplo n.º 3
0
        public void Update()
        {
            // "Always on" triggers can both start and stop a task
            // An example is S0000977 _S.03_ task which uses a single "when" trigger to start/stop spawns and play vengeance sound in Daggerfall city
            // But this becomes an issue if task has multiple "always on" triggers, as trigger A might start the task then trigger B will stop it again
            // One example of this behaviour is W0C00Y00 _pcgetsgold_ task where either "when" trigger can start reward task but subsequent triggers should not stop it again
            // This implementation considers the first "always on" trigger as the "primary" - able to both start & stop parent task
            // Subsequent "always on" triggers within the same task are "secondary" - only able to start a parent task but not stop it again
            bool ranPrimaryAlwaysOnTrigger = false;

            // Iterate conditions and actions for this task
            foreach (IQuestAction action in actions)
            {
                // Completed actions are never executed again
                // The action itself should decide if/when to be complete
                // At a higher level, turning off the task will also disable actions
                // The exception being triggers which always run even when task disabled
                if (action.IsComplete)
                {
                    continue;
                }

                // Always check trigger conditions
                // These can turn task on when any trigger evaluates true
                // They are no longer checked once task is triggered (unless set to always be on)
                // But can fire again if owning task is unset/rearmed later
                if (action.IsTriggerCondition && !IsTriggered || action.IsAlwaysOnTriggerCondition)
                {
                    // Handle primary/secondary "always on" triggers
                    if (action.IsAlwaysOnTriggerCondition && !ranPrimaryAlwaysOnTrigger)
                    {
                        // Primary "always on" trigger can start/stop parent task
                        // Flag is raised at first "always on" trigger so that subsequent triggers know the primary has run
                        IsTriggered = action.CheckTrigger(this);
                        ranPrimaryAlwaysOnTrigger = true;
                    }
                    else if (action.IsAlwaysOnTriggerCondition && ranPrimaryAlwaysOnTrigger)
                    {
                        // Secondary "always on" triggers can only start parent task, they cannot stop it again
                        if (action.CheckTrigger(this))
                        {
                            IsTriggered = true;
                        }
                    }
                    else
                    {
                        // All other triggers
                        IsTriggered = action.CheckTrigger(this);
                    }
                }

                // Tick other actions only when active
                if (IsTriggered && !action.IsTriggerCondition)
                {
                    // Initialise action if task was previously untriggered
                    if (!prevTriggered)
                    {
                        action.InitialiseOnSet();
                    }

                    // Update action and handle quest break
                    action.Update(this);
                    if (ParentQuest.QuestBreak)
                    {
                        return;
                    }
                }
            }

            // If this is a PersistUntil task we need to check target condition for unset state.
            // Experimentation seems to indicate these monitoring tasks get at least one tick.
            // For example, starting player outside of PH in classic using Z.CFG cheat will
            // cause main quest to start as normal before _exitstarter_ flag has a chance to
            // terminate "until _exitstarter_ performed" task.
            // Performing termination check AFTER executing task at least once to ensure behaviour matches classic.
            if (type == TaskType.PersistUntil)
            {
                Task targetTask = ParentQuest.GetTask(targetSymbol);
                if (targetTask.IsTriggered)
                {
                    // Target now set, terminate persistent task
                    Clear();
                }
                else
                {
                    // Rearm actions so they can repeat next run
                    // This behaviour obvserved in S0000011 in "until _S.12_ performed" to continuously clear Barenziah click
                    RearmActions();
                }
            }

            // Store trigger state this update
            prevTriggered = IsTriggered;
        }
Exemplo n.º 4
0
        public void Update()
        {
            // Iterate conditions and actions for this task
            foreach (IQuestAction action in actions)
            {
                // Completed actions are never executed again
                // The action itself should decide if/when to be complete
                // At a higher level, turning off the task will also disable actions
                // The exception being triggers which always run even when task disabled
                if (action.IsComplete)
                {
                    continue;
                }

                // Always check trigger conditions
                // These can turn task on when any trigger evaluates true
                // They are no longer checked once task is triggered (unless set to always be on)
                // But can fire again if owning task is unset/rearmed later
                if (action.IsTriggerCondition && !IsTriggered || action.IsAlwaysOnTriggerCondition)
                {
                    if (action.CheckTrigger(this))
                    {
                        IsTriggered = true;
                    }
                    else
                    {
                        IsTriggered = false;
                    }
                }

                // Tick other actions only when active
                if (IsTriggered && !action.IsTriggerCondition)
                {
                    // Initialise action if task was previously untriggered
                    if (!prevTriggered)
                    {
                        action.InitialiseOnSet();
                    }

                    // Update action and handle quest break
                    action.Update(this);
                    if (ParentQuest.QuestBreak)
                    {
                        return;
                    }
                }
            }

            // If this is a PersistUntil task we need to check target condition for unset state.
            // Experimentation seems to indicate these monitoring tasks get at least one tick.
            // For example, starting player outside of PH in classic using Z.CFG cheat will
            // cause main quest to start as normal before _exitstarter_ flag has a chance to
            // terminate "until _exitstarter_ performed" task.
            // Performing termination check AFTER executing task at least once to ensure behaviour matches classic.
            if (type == TaskType.PersistUntil)
            {
                Task targetTask = ParentQuest.GetTask(targetSymbol);
                if (targetTask.IsTriggered)
                {
                    // Target now set, terminate persistent task
                    Clear();
                }
                else
                {
                    // Rearm actions so they can repeat next run
                    // This behaviour obvserved in S0000011 in "until _S.12_ performed" to continuously clear Barenziah click
                    RearmActions();
                }
            }

            // Store trigger state this update
            prevTriggered = IsTriggered;
        }
Exemplo n.º 5
0
        public void Update()
        {
            // Iterate conditions and actions for this task
            foreach (IQuestAction action in actions)
            {
                // Completed actions are never executed again
                // The action itself should decide if/when to be complete
                // At a higher level, turning off the task will also disable actions
                // The exception being triggers which always run even when task disabled
                if (action.IsComplete)
                {
                    continue;
                }

                // Always check trigger conditions
                // These can turn task on when any trigger evaluates true
                // They are no longer checked once task is triggered
                // But can fire again if task is unset/rearmed later
                if (action.IsTriggerCondition && !triggered)
                {
                    if (action.CheckTrigger(this))
                    {
                        triggered = true;
                    }
                    else
                    {
                        triggered = false;
                    }
                }

                // Tick other actions only when active
                if (triggered && !action.IsTriggerCondition)
                {
                    // Initialise action if task was previously untriggered
                    if (!prevTriggered)
                    {
                        action.InitialiseOnSet();
                    }

                    // Update action and handle quest break
                    action.Update(this);
                    if (ParentQuest.QuestBreak)
                    {
                        return;
                    }
                }
            }

            // If this is a PersistUntil task we need to check target condition for unset state.
            // Experimentation seems to indicate these monitoring tasks get at least one tick.
            // For example, starting player outside of PH in classic using Z.CFG cheat will
            // cause main quest to start as normal before _exitstarter_ flag has a chance to
            // terminate "until _exitstarter_ performed" task.
            // Performing termination check AFTER executing task at least once to ensure behaviour matches classic.
            if (type == TaskType.PersistUntil)
            {
                // Unset this task when target symbol is also unset
                Task targetTask = ParentQuest.GetTask(targetSymbol);
                if (targetTask != null)
                {
                    if (!targetTask.IsSet)
                    {
                        Unset();
                    }
                    // Should these tasks be able to rearm?
                    // Would need strong evidence before allowing this
                }
            }

            // Store trigger state this update
            prevTriggered = triggered;
        }