ToBreakTheQuietQuestScript

From RPG Creation Kit
Jump to navigation Jump to search
using UnityEngine;
using RPGCreationKit;
using RPGCreationKit.Quests;
using RPGCreationKit.AI;
using RPGCreationKit.CellsSystem;

namespace RPGCreationKit.Quests
{
    public class ToBreakTheQuietQuestScript : QuestScript
    {
        RckAI bandit1;
        RckAI bandit2;

        // This will start running the CustomUpdate as soon as the quest starts.
        public void Start()
        {
            quest.questScriptExecutionDelay = 1f;
            RunQuestScript();
        }

        // CustomUpdate runs once every (quest.questScriptExecutionDelay) seconds
        public override void CustomUpdate()
        {
            base.CustomUpdate();

            // If the Current Quest Stage is 20
            if (quest.currentQuestStage == 20)
            {
                // If the bandit data has not been assigned
                if(bandit1 == null || bandit2 == null)
                {
                    // Those two lines tries to get the NPCs, if they're loaded
                    CellInformation.TryToGetAI("UQBandit001", out bandit1);
                    CellInformation.TryToGetAI("UQBandit002", out bandit2);
                }
                else
                {
                    if (bandit1.isAlive == false && bandit2.isAlive == false)
                    {
                        // This block runs if the bandit data has been assigned and both bandits are dead
                        RCKFunctions.CompleteQuestStage(quest.questID, 20);
                        RCKFunctions.SetQuestStage(quest.questID, 30);
                    }
                }
            }
        }
    }
}