Esempio n. 1
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5SignatureParameter?activatorParameter = codeScope.TryGetFunctionParameterByMeaning(TES5LocalVariableParameterMeaning.ACTIVATOR);

            if (activatorParameter == null)
            {
                throw new ConversionException("getActionRef in non-activator scope found. Cannot convert that one.", expected: true);
            }
            return(TES5ReferenceFactory.CreateReferenceToVariableOrProperty(activatorParameter));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            string functionName = function.FunctionCall.FunctionName;
            /* Emulating just the same disable player control as in Oblivion */
            TES5ObjectCallArguments newArgs = new TES5ObjectCallArguments()
            {
                new TES5Bool(true),
                new TES5Bool(true),
                new TES5Bool(false),
                new TES5Bool(false),
                new TES5Bool(false),
                new TES5Bool(true),
                new TES5Bool(true),
                new TES5Bool(true)
            };

            return(this.objectCallFactory.CreateObjectCall(TES5StaticReference.Game, functionName, multipleScriptsScope, newArgs));
        }
Esempio n. 3
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            string functionName = function.FunctionCall.FunctionName;
            TES4FunctionArguments functionArguments = function.Arguments;

            //@INCONSISTENCE @TODO: Entering an interior Cell and then exiting to an exterior will reset Fast Travel to the enabled state.
            return(this.objectCallFactory.CreateObjectCall(TES5StaticReference.Game, functionName, multipleScriptsScope, this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope)));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            const string            functionName    = "SetActorOwner";
            TES5ObjectCallArguments methodArguments = new TES5ObjectCallArguments()
            {
                new TES5None()
            };

            return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, methodArguments));
        }
 public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
 {
     return(this.objectCallFactory.CreateObjectCall(calledOn, "ClearLookAt", new TES5ObjectCallArguments()));
 }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            //WTM:  Note:  This always uses the player to send the tresspass alarm.  This might mean the player ultimately sends the trespass alarm for the player.
            //Oblivion doesn't seem to have a sender, only a trespasser.
            TES5ObjectCallArguments arguments = objectCallArgumentsFactory.CreateArgumentList(function.Arguments, codeScope, globalScope, multipleScriptsScope);

            return(objectCallFactory.CreateObjectCall(TES5ReferenceFactory.CreateReferenceToPlayer(globalScope), function.FunctionCall.FunctionName, arguments));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5ObjectCall getSleepState = this.objectCallFactory.CreateObjectCall(TES5ReferenceFactory.CreateReferenceToPlayer(globalScope), "getSleepState");

            return(TES5ExpressionFactory.CreateComparisonExpression(getSleepState, TES5ComparisonExpressionOperator.OPERATOR_GREATER, new TES5Integer(2)));
        }
        /*
         * Joins N QF subfragments into one QF fragment that can be properly binded into Skyrim VM
         * @throws ConversionException
         */
        public TES5Target JoinQFFragments(BuildTarget target, string resultingFragmentName, List <QuestStageScript> subfragmentsTrees)
        {
            StageMap stageMap = BuildStageMap(target, resultingFragmentName);

            /*
             * We need script fragment for objective handling for each stage, so when parsing the script fragments,
             * we"ll be marking them there, and intersecting this with stage.
             * This will give us an array of stages which don"t have script fragment, but will need it anyways
             * for objective handling.
             */
            TES5ScriptHeader resultingScriptHeader = new TES5ScriptHeader(resultingFragmentName, TES5BasicType.T_QUEST, "", true);
            TES5BlockList    resultingBlockList    = new TES5BlockList();
            TES5GlobalScope  resultingGlobalScope  = new TES5GlobalScope(resultingScriptHeader);

            /*
             * Add ReferenceAlias"es
             * At some point, we might port the conversion so it doesn"t use the directly injected property,
             * but instead has a map to aliases and we"ll map accordingly and have references point to aliases instead
             */
            string sourcePath  = target.GetSourceFromPath(resultingFragmentName);
            string scriptName  = Path.GetFileNameWithoutExtension(sourcePath);
            string aliasesFile = Path.Combine(Path.GetDirectoryName(sourcePath), scriptName + ".aliases");

            string[] aliasesLines = File.ReadAllLines(aliasesFile);
            Dictionary <string, bool> aliasesDeclared = new Dictionary <string, bool>();

            foreach (var alias in aliasesLines)
            {
                string trimmedAlias = alias.Trim();
                if (trimmedAlias == "")
                {
                    continue;
                }
                try
                {
                    aliasesDeclared.Add(trimmedAlias, true);
                }
                catch (ArgumentException) { continue; }
                resultingGlobalScope.AddProperty(new TES5Property(trimmedAlias, TES5BasicType.T_REFERENCEALIAS, trimmedAlias));
            }

            Dictionary <int, bool>    implementedStages       = new Dictionary <int, bool>();
            Dictionary <string, bool> propertiesNamesDeclared = new Dictionary <string, bool>();

            foreach (var subfragment in subfragmentsTrees)
            {
                TES5Target      subfragmentsTree       = subfragment.Script;
                TES5Script      subfragmentScript      = subfragmentsTree.Script;
                TES5GlobalScope subfragmentGlobalScope = subfragmentScript.GlobalScope;
                foreach (TES5Property subfragmentProperty in subfragmentGlobalScope.Properties)
                {
                    /*
                     * Move over the properties to the new global scope
                     */
                    string propertyName;
                    if (propertiesNamesDeclared.ContainsKey(subfragmentProperty.Name))
                    {
                        propertyName = GeneratePropertyName(subfragmentScript.ScriptHeader, subfragmentProperty);
                        subfragmentProperty.Rename(propertyName);
                    }
                    else
                    {
                        propertyName = subfragmentProperty.Name;
                    }

                    propertiesNamesDeclared.Add(propertyName, true);
                    resultingGlobalScope.AddProperty(subfragmentProperty);
                    //WTM:  Note:  See QF_FGD03Viranus_0102d154.  Since ViranusDontonREF is present in multiple of the original fragments,
                    //ViranusDontonREF gets renamed by the above.  So multiple ViranusDontonREF variables are output.
                    //Below I tried not renaming, assuming instead that variables with matching names and types within a set of fragments were intended to be the same variable.
                    //It had OK results, but I'm leaving it commented for now.

                    /*string propertyNameWithSuffix = subfragmentProperty.PropertyNameWithSuffix;
                     * TES5Property existingProperty = resultingGlobalScope.Properties.Where(p => p.PropertyNameWithSuffix == propertyNameWithSuffix).FirstOrDefault();
                     * if (existingProperty != null && TES5InheritanceGraphAnalyzer.isExtending(subfragmentProperty.PropertyType, existingProperty.PropertyType))
                     * {
                     *  existingProperty.PropertyType = subfragmentProperty.PropertyType;
                     * }
                     * else
                     * {
                     *  bool add = true;
                     *  if (existingProperty != null)
                     *  {
                     *      if (TES5InheritanceGraphAnalyzer.isExtending(existingProperty.PropertyType, subfragmentProperty.PropertyType))
                     *      {
                     *          add = false;
                     *      }
                     *      else
                     *      {
                     *          string generatedPropertyName = generatePropertyName(subfragmentScript.ScriptHeader, subfragmentProperty, i);
                     *          subfragmentProperty.Rename(generatedPropertyName);
                     *      }
                     *  }
                     *  if (add)
                     *  {
                     *      resultingGlobalScope.Add(subfragmentProperty);
                     *  }
                     * }*/
                }

                List <ITES5CodeBlock> subfragmentBlocks = subfragmentScript.BlockList.Blocks;
                if (subfragmentBlocks.Count != 1)
                {
                    throw new ConversionException("Wrong QF fragment, actual function count: " + subfragmentBlocks.Count + "..");
                }

                ITES5CodeBlock subfragmentBlock = subfragmentBlocks[0];
                if (subfragmentBlock.FunctionScope.BlockName != "Fragment_0")
                {
                    throw new ConversionException("Wrong QF fragment funcname, actual function name: " + subfragmentBlock.FunctionScope.BlockName + "..");
                }

                string newFragmentFunctionName = "Fragment_" + subfragment.Stage.ToString();
                if (subfragment.LogIndex != 0)
                {
                    newFragmentFunctionName += "_" + subfragment.LogIndex;
                }

                subfragmentBlock.FunctionScope.Rename(newFragmentFunctionName);
                var objectiveCodeChunks = this.objectiveHandlingFactory.GenerateObjectiveHandling(subfragmentBlock, resultingGlobalScope, stageMap.GetStageTargetsMap(subfragment.Stage));
                foreach (var newCodeChunk in objectiveCodeChunks)
                {
                    subfragmentBlock.AddChunk(newCodeChunk);
                }

                resultingBlockList.Add(subfragmentBlock);
                implementedStages[subfragment.Stage] = true;
            }

            /*
             * Diff to find stages which we still need to mark
             */
            int[] nonDoneStages = stageMap.StageIDs.Where(stageID => !implementedStages.ContainsKey(stageID)).ToArray();
            foreach (int nonDoneStage in nonDoneStages)
            {
                TES5FunctionCodeBlock fragment = this.objectiveHandlingFactory.CreateEnclosedFragment(resultingGlobalScope, nonDoneStage, stageMap.GetStageTargetsMap(nonDoneStage));
                resultingBlockList.Add(fragment);
            }

            this.mappedTargetsLogService.WriteScriptName(resultingFragmentName);
            foreach (var kvp in stageMap.MappedTargetsIndex)
            {
                var originalTargetIndex = kvp.Key;
                var mappedTargetIndexes = kvp.Value;
                this.mappedTargetsLogService.WriteLine(originalTargetIndex, mappedTargetIndexes);
            }

            TES5Script resultingTree = new TES5Script(resultingGlobalScope, resultingBlockList);
            string     outputPath    = target.GetTranspileToPath(resultingFragmentName);

            return(new TES5Target(resultingTree, outputPath));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope localScope = codeScope.LocalScope;
            //Using Legacy TES4 Connector Plugin
            ITES5Referencer newCalledOn = this.referenceFactory.CreateContainerReadReference(globalScope, multipleScriptsScope, localScope);

            return(this.objectPropertyFactory.CreateObjectProperty(newCalledOn, "isInJail", multipleScriptsScope));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            /*string firstArg = function.Arguments[0].StringValue;
             * string md5 = TES5TypeFactory.TES4Prefix + "SCENE_" + PHPFunction.MD5(calledOn.ReferencesTo.ReferenceEDID + firstArg).Substring(0, 16);
             * List<string> sceneData = new List<string>() { md5, firstArg };
             * if (function.Arguments.Count >= 2)
             * {
             *  sceneData.Add(function.Arguments[1].StringValue);
             * }
             * this.metadataLogService.WriteLine("ADD_FORCEGREET_SCENE", sceneData);
             * ITES5Referencer reference = this.referenceFactory.createReference(md5, globalScope, multipleScriptsScope, codeScope.LocalScope);
             * TES5ObjectCallArguments funcArgs = new TES5ObjectCallArguments();*/
            /*
             * Force start because in oblivion double using AddScriptPackage would actually overwrite the script package, so we mimic this
             * return this.objectCallFactory.createObjectCall(reference, "ForceStart", multipleScriptsScope, funcArgs);
             */
            //WTM:  Note:  Even though I got some parts of LegacyStartConversation to work, I realized that Oblivion calls StartConversation with DIAL.
            //DIAL is not a type in Papyrus.  The DIAL record would have to be converted to a Topic first somehow so StartConversation could be called.
            //I'm going to log calls to this function.

            /*TES4FunctionArguments oldArguments = function.Arguments;
             * TES5ObjectCallArguments newArguments = this.objectCallArgumentsFactory.CreateArgumentList(oldArguments, codeScope, globalScope, multipleScriptsScope);
             * return this.objectCallFactory.CreateObjectCall(calledOn, "LegacyStartConversation", newArguments);*/
            return(logUnknownFunctionFactory.CreateLogCall(function));
        }
Esempio n. 11
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope          localScope        = codeScope.LocalScope;
            string                  functionName      = function.FunctionCall.FunctionName;
            TES4FunctionArguments   functionArguments = function.Arguments;
            TES5ObjectCallArguments arguments         = new TES5ObjectCallArguments()
            {
                this.referenceFactory.CreateReadReference(functionArguments[0].StringValue, globalScope, multipleScriptsScope, localScope)
            };

            return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, arguments));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            /*string firstArg = function.Arguments[0].StringValue;
             * string md5 = TES5TypeFactory.TES4Prefix + "SCENE_" + PHPFunction.MD5(calledOn.ReferencesTo.ReferenceEDID + firstArg).Substring(0, 16);
             * List<string> sceneData = new List<string>() { md5, firstArg };
             * if (function.Arguments.Count >= 2)
             * {
             *  sceneData.Add(function.Arguments[1].StringValue);
             * }
             * this.metadataLogService.WriteLine("ADD_FORCEGREET_SCENE", sceneData);
             * ITES5Referencer reference = this.referenceFactory.createReference(md5, globalScope, multipleScriptsScope, codeScope.LocalScope);
             * TES5ObjectCallArguments funcArgs = new TES5ObjectCallArguments();*/
            /*
             * Force start because in oblivion double using AddScriptPackage would actually overwrite the script package, so we mimic this
             * return this.objectCallFactory.createObjectCall(reference, "ForceStart",multipleScriptsScope, funcArgs);
             */

            return(new TES5Filler());
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            const string            functionName      = "Disable";
            TES4FunctionArguments   functionArguments = function.Arguments;
            TES5ObjectCallArguments newArguments      = new TES5ObjectCallArguments();

            return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, newArguments));
        }
Esempio n. 14
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments   functionArguments = function.Arguments;
            TES5ObjectCallArguments methodArguments   = new TES5ObjectCallArguments()
            {
                new TES5Bool(false)//override different behaviour
            };
            ITES4StringValue lockAsOwner     = functionArguments.GetOrNull(1);
            bool             lockAsOwnerBool = lockAsOwner != null && (bool)lockAsOwner.Data;

            methodArguments.Add(new TES5Bool(lockAsOwnerBool));
            return(this.objectCallFactory.CreateObjectCall(calledOn, "Lock", multipleScriptsScope, methodArguments));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope localScope = codeScope.LocalScope;
            //@INCONSISTENCE - Will only check for scripted effects
            //In oblivion, this is checking for a spell which targeted a given actor
            //In Skyrim you can check for effects only.
            TES5ObjectCallArguments newArgs = new TES5ObjectCallArguments()
            {
                this.referenceFactory.CreateReference("EffectSEFF", globalScope, multipleScriptsScope, localScope)
            };

            return(this.objectCallFactory.CreateObjectCall(calledOn, "HasMagicEffect", multipleScriptsScope, newArgs));
        }
Esempio n. 16
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments tes4Arguments = function.Arguments;
            int    statInt = ((TES4Integer)tes4Arguments[0]).IntValue;
            string statName;

            if (statInt == 14)
            {
                statName = "Horses Owned";
            }
            else if (statInt == 15)
            {
                statName = "Houses Owned";
            }
            else if (statInt == 16)
            {
                statName = "Stores Invested In";
            }
            else if (statInt == 27)
            {
                statName = "Nirnroots Found";
            }
            else
            {
                //Oblivion contains many calls to statInt = 19 (Artifacts Found)
                return(logUnknownFunctionFactory.CreateLogCall(function));
            }
            TES5ObjectCallArguments arguments = new TES5ObjectCallArguments();

            arguments.Add(new TES5String(statName));
            if (tes4Arguments.Count > 1)
            {
                int modAmount = ((TES4Integer)tes4Arguments[1]).IntValue;
                arguments.Add(new TES5Integer(modAmount));
            }
            return(objectCallFactory.CreateObjectCall(TES5StaticReferenceFactory.Game, "IncrementStat", arguments));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope          localScope         = codeScope.LocalScope;
            string                  functionName       = function.FunctionCall.FunctionName;
            TES4FunctionArguments   functionArguments  = function.Arguments;
            ITES4StringValue        value              = functionArguments[0];
            ITES5Referencer         toBeMethodArgument = calledOn;
            ITES5Referencer         newCalledOn        = this.referenceFactory.CreateReadReference(value.StringValue, globalScope, multipleScriptsScope, localScope);
            TES5ObjectCallArguments methodArguments    = new TES5ObjectCallArguments()
            {
                toBeMethodArgument
            };
            ITES4StringValue?target = functionArguments.GetOrNull(1);

            if (target != null)
            {
                methodArguments.Add(this.referenceFactory.CreateReadReference(target.StringValue, globalScope, multipleScriptsScope, localScope));
            }

            return(this.objectCallFactory.CreateObjectCall(newCalledOn, functionName, methodArguments));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments functionArguments = function.Arguments;
            TES5LocalScope        localScope = codeScope.LocalScope;
            int x = 0, y = 0, z = 0;
            int secondArgumentData = (int)functionArguments[1].Data;

            switch (functionArguments[0].StringValue.ToLower())
            {
            case "x":
            {
                x = secondArgumentData;
                break;
            }

            case "y":
            {
                y = secondArgumentData;
                break;
            }

            case "z":
            {
                z = secondArgumentData;
                break;
            }
            }

            TES5ObjectCallArguments rotateArguments = new TES5ObjectCallArguments()
            {
                calledOn,
                new TES5Integer(x),
                new TES5Integer(y),
                new TES5Integer(z)
            };
            TES5ObjectCall newFunction = this.objectCallFactory.CreateObjectCall(this.referenceFactory.CreateTimerReadReference(globalScope, multipleScriptsScope, localScope), "Rotate", rotateArguments);

            return(newFunction);
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope        localScope        = codeScope.LocalScope;
            TES4FunctionArguments functionArguments = function.Arguments;
            //WARNING: This is not an exact implementation
            //According to cs.elderscrolls.com, its about being in the faction AND having an attack on them ( violent crime )
            //It"s similar but groups all nonviolent wrongdoings
            ITES5Referencer         factionReference = this.referenceFactory.CreateReadReference(functionArguments[0].StringValue, globalScope, multipleScriptsScope, localScope);
            TES5ObjectCallArguments arguments        = new TES5ObjectCallArguments()
            {
                factionReference
            };
            TES5ObjectCall            isInFaction         = this.objectCallFactory.CreateObjectCall(TES5ReferenceFactory.CreateReferenceToPlayer(globalScope), "IsInFaction", arguments);
            TES5TrueBooleanExpression leftExpression      = TES5ExpressionFactory.CreateTrueBooleanExpression(isInFaction);
            TES5ObjectCall            crimeGoldNonViolent = this.objectCallFactory.CreateObjectCall(factionReference, "GetCrimeGoldNonViolent");
            TES5ComparisonExpression  rightExpression     = TES5ExpressionFactory.CreateComparisonExpression(crimeGoldNonViolent, TES5ComparisonExpressionOperator.OPERATOR_GREATER, new TES5Integer(0));
            TES5LogicalExpression     logicalExpression   = TES5ExpressionFactory.CreateLogicalExpression(leftExpression, TES5LogicalExpressionOperator.OPERATOR_AND, rightExpression);

            return(logicalExpression);
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            //WTM:  Change:  Apparently moving the player wakes up the player.  I want to see if this works.
            var playerRef = TES5ReferenceFactory.CreateReferenceToPlayer(globalScope);

            return(objectCallFactory.CreateObjectCall(playerRef, "MoveTo", new TES5ObjectCallArguments()
            {
                playerRef
            }));
        }
Esempio n. 21
0
 public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
 {
     //@INCONSISTENCE - Will always return false
     return(new TES5Bool(false));
 }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope localScope = codeScope.LocalScope;

            return(this.referenceFactory.CreateReadReference("Fame", globalScope, multipleScriptsScope, localScope));
        }
Esempio n. 23
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments functionArguments = function.Arguments;
            TES5LocalScope        localScope        = codeScope.LocalScope;
            ITES5Referencer       newCalledOn       = this.referenceFactory.CreateCyrodiilCrimeFactionReadReference(globalScope, multipleScriptsScope, localScope);

            return(this.objectCallFactory.CreateObjectCall(newCalledOn, "SetCrimeGold", this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope)));
        }
Esempio n. 24
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            const string seWorldLocationEditorID   = TES5TypeFactory.TES4Prefix + SEWorldLocationPropertyName;
            int          seWorldLocationTES5FormID = locationFinder.GetLocationFormIDByLocationEditorID(seWorldLocationEditorID);
            TES5Property?seWorldLocationProperty   = globalScope.TryGetPropertyByName(SEWorldLocationPropertyName);

            if (seWorldLocationProperty == null)
            {
                seWorldLocationProperty = TES5PropertyFactory.ConstructWithTES5FormID(SEWorldLocationPropertyName, TES5BasicType.T_LOCATION, SEWorldLocationPropertyName, seWorldLocationTES5FormID);
                globalScope.AddProperty(seWorldLocationProperty);
            }
            ITES5Referencer         seWorldLocationReference = TES5ReferenceFactory.CreateReferenceToVariableOrProperty(seWorldLocationProperty);
            TES5ObjectCallArguments arguments = new TES5ObjectCallArguments()
            {
                seWorldLocationReference
            };
            TES5ObjectCall isInLocation = this.objectCallFactory.CreateObjectCall(TES5ReferenceFactory.CreateReferenceToPlayer(globalScope), "IsInLocation", arguments);

            return(isInLocation);
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES4FunctionArguments functionArguments = function.Arguments;
            string setting = functionArguments[0].StringValue;

            switch (setting.ToLower())
            {
            case "icrimegoldattackmin":
            case "icrimegoldattack":
            {
                return(new TES5Integer(25));
            }

            case "icrimegoldjailbreak":
            {
                return(new TES5Integer(50));
            }

            default:
            {
                throw new ConversionException("GetGameSetting() - unknown setting.");
            }
            }
        }
Esempio n. 26
0
        public void RunTask(StreamWriter errorLog, ProgressWriter progressWriter)
        {
            foreach (var buildChunk in this.buildPlan)
            {
                Dictionary <string, TES5GlobalScope> scriptsScopes = new Dictionary <string, TES5GlobalScope>();
                TES5GlobalVariables globalVariables = this.esmAnalyzer.GlobalVariables;

                /*
                 * First, build the scripts global scopes
                 */
                foreach (var kvp in buildChunk)
                {
                    var         buildTargetName = kvp.Key;
                    var         buildScripts    = kvp.Value;
                    BuildTarget buildTarget     = this.GetBuildTarget(buildTargetName);
                    foreach (var buildScript in buildScripts)
                    {
                        string scriptName = Path.GetFileNameWithoutExtension(buildScript);
                        string sourcePath = buildTarget.GetSourceFromPath(scriptName);
                        scriptsScopes.Add(scriptName, buildTarget.BuildScope(sourcePath, globalVariables));
                    }
                }

                //Add the static global scopes which are added by complimenting scripts..
                List <TES5GlobalScope> staticGlobalScopes = TES5StaticGlobalScopesFactory.CreateGlobalScopes();
                //WTM:  Change:  In the PHP, scriptsScopes is used as a dictionary above but as a list below.  I have added the "GlobalScope"+n key to ameliorate this.
                int globalScopeIndex = 0;
                foreach (var staticGlobalScope in staticGlobalScopes)
                {
                    scriptsScopes.Add("GlobalScope" + globalScopeIndex.ToString(), staticGlobalScope);
                    globalScopeIndex++;
                }

                TES5MultipleScriptsScope multipleScriptsScope = new TES5MultipleScriptsScope(scriptsScopes.Values, globalVariables);
                //Dictionary<string, TES5Target> convertedScripts = new Dictionary<string, TES5Target>();
                foreach (var kvp in buildChunk)
                {
                    var buildTargetName = kvp.Key;
                    var buildScripts    = kvp.Value;
                    foreach (var buildScript in buildScripts)
                    {
                        BuildTarget     buildTarget = this.GetBuildTarget(buildTargetName);
                        string          scriptName  = Path.GetFileNameWithoutExtension(buildScript);
                        TES5GlobalScope globalScope = scriptsScopes[scriptName];
                        string          sourcePath  = buildTarget.GetSourceFromPath(scriptName);
                        string          outputPath  = buildTarget.GetTranspileToPath(scriptName);
                        TES5Target      convertedScript;
                        try
                        {
                            convertedScript = buildTarget.Transpile(sourcePath, outputPath, globalScope, multipleScriptsScope);
                        }
                        catch (EOFOnlyException) { continue; }//Ignore files that are only whitespace or comments.
#if !DEBUG || LOG_EXCEPTIONS
                        catch (ConversionException ex) when(ex.Expected)
                        {
                            errorLog.Write(scriptName + " (" + sourcePath + ")" + Environment.NewLine + ex.GetType().FullName + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine);
                            continue;
                        }
#endif
                        this.buildTracker.RegisterBuiltScript(buildTarget, convertedScript);
                        //convertedScripts.Add(buildScript, convertedScript);
                        progressWriter.IncrementAndWrite();
                    }
                }

                /*foreach (var kvp2 in convertedScripts)
                 * {
                 *  var originalScriptName = kvp2.Key;
                 *  Console.WriteLine("Script Complete:  " + originalScriptName);
                 * }*/
            }
        }
 public TES5Script(TES5GlobalScope globalScope, TES5BlockList blockList = null)
 {
     this.ScriptHeader = globalScope.ScriptHeader;
     this.GlobalScope  = globalScope;
     this.BlockList    = blockList;
 }
Esempio n. 28
0
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope        localScope        = codeScope.LocalScope;
            TES4FunctionArguments functionArguments = function.Arguments;
            int arg;

            switch (((TES4Integer)functionArguments[1]).IntValue)
            {
            case 0:
            {
                arg = 0;
                break;
            }

            case 1:
            {
                arg = 100;
                break;
            }

            default:
            {
                throw new ConversionException("SetPCFactionSteal argument unknown");
            }
            }

            TES5ObjectCallArguments constantArgument = new TES5ObjectCallArguments()
            {
                new TES5Integer(arg)
            };
            ITES5Referencer faction     = this.referenceFactory.CreateReadReference(functionArguments[0].StringValue, globalScope, multipleScriptsScope, localScope);
            TES5ObjectCall  newFunction = this.objectCallFactory.CreateObjectCall(faction, "SetCrimeGold", constantArgument);

            return(newFunction);
        }
Esempio n. 29
0
 public abstract ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope);
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope           localScope           = codeScope.LocalScope;
            TES4FunctionArguments    functionArguments    = function.Arguments;
            ITES5Referencer          fameReference        = this.referenceFactory.CreateReadReference("Infamy", globalScope, multipleScriptsScope, localScope);
            TES5ObjectCallArguments  fameArguments        = new TES5ObjectCallArguments();
            TES5ArithmeticExpression arithmeticExpression = TES5ExpressionFactory.CreateArithmeticExpression(fameReference, TES5ArithmeticExpressionOperator.OPERATOR_ADD, new TES5Integer(((TES4Integer)functionArguments[0]).IntValue));

            fameArguments.Add(arithmeticExpression);
            TES5ObjectCall newFunction = this.objectCallFactory.CreateObjectCall(this.referenceFactory.CreateReference("Infamy", globalScope, multipleScriptsScope, localScope), "SetValue", fameArguments);

            return(newFunction);
        }