コード例 #1
0
        public List <ITES5CodeChunk> GenerateObjectiveHandling(ITES5CodeBlock codeBlock, TES5GlobalScope globalScope, List <int> stageMap)
        {
            TES5LocalVariable     castedToQuest   = new TES5LocalVariable("__temp", TES5BasicType.T_QUEST);
            TES5Reference         referenceToTemp = TES5ReferenceFactory.CreateReferenceToVariable(castedToQuest);
            List <ITES5CodeChunk> result          = new List <ITES5CodeChunk>()
            {
                TES5VariableAssignationFactory.CreateAssignation(referenceToTemp, TES5ReferenceFactory.CreateReferenceToSelf(globalScope))
            };
            TES5LocalScope localScope = codeBlock.CodeScope.LocalScope;

            localScope.AddVariable(castedToQuest);
            int i = 0;

            foreach (var stageTargetState in stageMap)
            {
                TES5Integer targetIndex = new TES5Integer(i);
                if (stageTargetState != 0)
                {
                    //Should be visible
                    TES5ObjectCallArguments displayedArguments = new TES5ObjectCallArguments()
                    {
                        targetIndex
                    };
                    TES5ObjectCall           isObjectiveDisplayed = new TES5ObjectCall(referenceToTemp, "IsObjectiveDisplayed", displayedArguments);
                    TES5ComparisonExpression expression           = TES5ExpressionFactory.CreateComparisonExpression(isObjectiveDisplayed, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Integer(0));
                    TES5ObjectCallArguments  arguments            = new TES5ObjectCallArguments()
                    {
                        targetIndex, new TES5Integer(1)
                    };
                    TES5ObjectCall showTheObjective = new TES5ObjectCall(referenceToTemp, "SetObjectiveDisplayed", arguments);
                    TES5Branch     branch           = TES5BranchFactory.CreateSimpleBranch(expression, localScope);
                    branch.MainBranch.CodeScope.AddChunk(showTheObjective);
                    result.Add(branch);
                }
                else
                {
                    TES5ObjectCallArguments displayedArguments = new TES5ObjectCallArguments()
                    {
                        targetIndex
                    };
                    TES5ObjectCall           isObjectiveDisplayed = new TES5ObjectCall(referenceToTemp, "IsObjectiveDisplayed", displayedArguments);
                    TES5ComparisonExpression expression           = TES5ExpressionFactory.CreateComparisonExpression(isObjectiveDisplayed, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Integer(1));
                    TES5ObjectCallArguments  arguments            = new TES5ObjectCallArguments()
                    {
                        targetIndex, new TES5Integer(1)
                    };
                    TES5ObjectCall completeTheObjective = new TES5ObjectCall(referenceToTemp, "SetObjectiveCompleted", arguments);
                    TES5Branch     branch = TES5BranchFactory.CreateSimpleBranch(expression, localScope);
                    branch.MainBranch.CodeScope.AddChunk(completeTheObjective);
                    result.Add(branch);
                }

                ++i;
            }

            return(result);
        }
コード例 #2
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments functionArguments = function.Arguments;
            TES5ObjectCall        startSneaking     = this.objectCallFactory.CreateObjectCall(calledOn, "StartSneaking", multipleScriptsScope);

            if (((TES4Integer)functionArguments[0]).IntValue == 0)
            {
                //WTM:  Change:  Since StartSneaking toggles sneaking, we check if the TES4 code wants the user to stop sneaking.
                //If so, if the user is sneaking, call StartSneaking, which actually stops sneaking if already sneaking.
                TES5ObjectCall           isSneaking          = this.objectCallFactory.CreateObjectCall(calledOn, "IsSneaking", multipleScriptsScope);
                TES5ComparisonExpression playerIsNotSneaking = TES5ExpressionFactory.CreateComparisonExpression(isSneaking, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Bool(true));
                TES5Branch branch = TES5BranchFactory.CreateSimpleBranch(playerIsNotSneaking, codeScope.LocalScope);
                branch.MainBranch.CodeScope.AddChunk(startSneaking);
                return(branch);
            }
            return(startSneaking);
        }
コード例 #3
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            //WTM:  Added:  This is to prevent these Papyrus messages:

            /*
             * Actor is dead, cannot start combat.
             * Actor has no AI process, cannot start combat. [I might need to use Actor.IsAIEnabled or even Actor.EnableAI(True).]
             */
            TES5ObjectCall           isDeadCall        = this.objectCallFactory.CreateObjectCall(calledOn, "IsDead");
            TES5ComparisonExpression isNotDead         = TES5ExpressionFactory.CreateComparisonExpression(isDeadCall, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Bool(false));
            TES4FunctionArguments    functionArguments = function.Arguments;
            TES5ObjectCallArguments  newArguments      = this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope);
            TES5ObjectCall           startCombatCall   = this.objectCallFactory.CreateObjectCall(calledOn, "StartCombat", newArguments);
            TES5Branch ifNotDeadStartCombat            = TES5BranchFactory.CreateSimpleBranch(isNotDead, codeScope.LocalScope);

            ifNotDeadStartCombat.MainBranch.CodeScope.AddChunk(startCombatCall);
            return(ifNotDeadStartCombat);
        }
コード例 #4
0
        public List <ITES5CodeChunk> GenerateObjectiveHandling(ITES5CodeBlock codeBlock, TES5GlobalScope globalScope, List <int> stageMap)
        {
            List <ITES5CodeChunk> result = new List <ITES5CodeChunk>();

            //WTM:  Change:
            if (!stageMap.Any())
            {
                return(result);
            }
            TES5LocalVariable       castedToQuest        = new TES5LocalVariable("__temp", TES5BasicType.T_QUEST);//WTM:  Note:  Why is this variable even necessary?
            TES5Reference           referenceToTemp      = TES5ReferenceFactory.CreateReferenceToVariableOrProperty(castedToQuest);
            TES5SelfReference       questSelfReference   = TES5ReferenceFactory.CreateReferenceToSelf(globalScope);
            TES5VariableAssignation tempQuestAssignation = TES5VariableAssignationFactory.CreateAssignation(referenceToTemp, questSelfReference);

            result.Add(tempQuestAssignation);
            TES5LocalScope localScope = codeBlock.CodeScope.LocalScope;

            localScope.AddVariable(castedToQuest);
            int i = 0;

            foreach (var stageTargetState in stageMap)
            {
                TES5Integer             targetIndex        = new TES5Integer(i);
                TES5ObjectCallArguments displayedArguments = new TES5ObjectCallArguments()
                {
                    targetIndex
                };
                TES5ObjectCall           isObjectiveDisplayed         = objectCallFactory.CreateObjectCall(referenceToTemp, "IsObjectiveDisplayed", displayedArguments, inference: false);
                int                      isObjectiveDisplayedArgument = stageTargetState != 0 ? 0 : 1;
                TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(isObjectiveDisplayed, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Integer(isObjectiveDisplayedArgument));
                TES5ObjectCallArguments  arguments  = new TES5ObjectCallArguments()
                {
                    targetIndex, new TES5Integer(1)
                };
                string         setObjectiveFunction   = stageTargetState != 0 ? "SetObjectiveDisplayed" : "SetObjectiveCompleted";
                TES5ObjectCall setObjectiveObjectCall = objectCallFactory.CreateObjectCall(referenceToTemp, setObjectiveFunction, arguments, inference: false);
                TES5Branch     branch = TES5BranchFactory.CreateSimpleBranch(expression, localScope);
                branch.MainBranch.CodeScope.AddChunk(setObjectiveObjectCall);
                result.Add(branch);
                ++i;
            }

            return(result);
        }