public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { string functionName = function.FunctionCall.FunctionName; TES4FunctionArguments functionArguments = function.Arguments; 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) { /* * @INCONSISTENCE - Will always return 0 */ return(new TES5Integer(0)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; string dataString = functionArguments[0].StringValue; ITES5Referencer targetReference = this.referenceFactory.CreateReadReference(dataString, globalScope, multipleScriptsScope, localScope); ITES5Type dataType = this.analyzer.GetFormTypeByEDID(dataString); TES5ObjectCall owner; ITES5Referencer baseReference; if (dataType == TES5BasicType.T_FACTION) { owner = this.objectCallFactory.CreateObjectCall(calledOn, "GetFactionOwner", multipleScriptsScope); baseReference = targetReference; } else { owner = this.objectCallFactory.CreateObjectCall(calledOn, "GetActorOwner", multipleScriptsScope); baseReference = this.objectCallFactory.CreateGetActorBase(targetReference, multipleScriptsScope); } TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(owner, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, baseReference); return(expression); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; string arg0String = functionArguments[0].StringValue; ITES5Referencer targetReference = this.referenceFactory.CreateReadReference(arg0String, globalScope, multipleScriptsScope, localScope); var arg0Type = targetReference.TES5Type; string functionName; ITES5Referencer baseReference; if (TES5InheritanceGraphAnalyzer.IsTypeOrExtendsType(arg0Type, TES5BasicType.T_ACTORBASE)) { functionName = "GetActorOwner"; baseReference = targetReference; } else if (TES5InheritanceGraphAnalyzer.IsTypeOrExtendsType(arg0Type, TES5BasicType.T_ACTOR)) { functionName = "GetActorOwner"; baseReference = this.objectCallFactory.CreateGetActorBase(targetReference); } else if (TES5InheritanceGraphAnalyzer.IsTypeOrExtendsType(arg0Type, TES5BasicType.T_FACTION)) { functionName = "GetFactionOwner"; baseReference = targetReference; } else { throw new ConversionException(function.FunctionCall.FunctionName + " should be called with either an ActorBase or a Faction."); } TES5ObjectCall owner = this.objectCallFactory.CreateObjectCall(calledOn, functionName); TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(owner, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, baseReference); return(expression); }
/*public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) * { * TES5LocalScope localScope = codeScope.LocalScope; * ITES5Referencer timerReference = this.referenceFactory.CreateTimerReadReference(globalScope, multipleScriptsScope, localScope); * ITES5Referencer localTimeReference = this.referenceFactory.CreateGSPLocalTimerReadReference(globalScope, multipleScriptsScope, localScope); * TES5ObjectCallArguments methodArguments = new TES5ObjectCallArguments() { calledOn }; * return this.objectCallFactory.CreateObjectCall(timerReference, "getSecondsPassed", multipleScriptsScope, methodArguments); * }*/ public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { const string newFunctionName = "GetSecondsPassed"; TES5BasicType returnType = TES5BasicType.T_FLOAT; /*globalScope.AddFunctionIfNotExists(newFunctionName, () => * { * const string getCurrentRealTime = "GetCurrentRealTime"; * TES5FunctionScope newFunctionScope = new TES5FunctionScope(newFunctionName); * TES5LocalScope newLocalScope = TES5LocalScopeFactory.CreateRootScope(newFunctionScope); * TES5CodeScope newCodeScope = TES5CodeScopeFactory.CreateCodeScope(newLocalScope); * TES5GlobalVariable calledYet = new TES5GlobalVariable("GSPCalledYet"); * TES5GlobalVariable lastSeconds = new TES5GlobalVariable("GSPLastSeconds"); * TES5SubBranch ifNotCalledYet = TES5BranchFactory.CreateSubBranch(new TES5ComparisonExpression(calledYet, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Bool(false)), newLocalScope); * ifNotCalledYet.CodeScope.AddChunk(TES5VariableAssignationFactory.CreateAssignation(calledYet, new TES5Bool(true))); * ifNotCalledYet.CodeScope.AddChunk(TES5VariableAssignationFactory.CreateAssignation(lastSeconds, this.objectCallFactory.CreateObjectCall(TES5StaticReference.Utility, getCurrentRealTime, multipleScriptsScope))); * ifNotCalledYet.CodeScope.AddChunk(new TES5Return(new TES5Float(0))); * TES5CodeScope ifCalledYetCodeScope = TES5CodeScopeFactory.CreateCodeScopeRoot(newFunctionScope); * ifCalledYetCodeScope.AddChunk(new TES5Return(new TES5ArithmeticExpression(this.objectCallFactory.CreateObjectCall(TES5StaticReference.Utility, getCurrentRealTime, multipleScriptsScope), TES5ArithmeticExpressionOperator.OPERATOR_SUBSTRACT, lastSeconds))); * TES5ElseSubBranch ifCalledYet = new TES5ElseSubBranch(ifCalledYetCodeScope); * TES5Branch branch = new TES5Branch(ifNotCalledYet, elseBranch: ifCalledYet); * TES5FunctionCodeBlock getSecondsPassedLocalFunction = new TES5FunctionCodeBlock(newFunctionScope, newCodeScope, returnType, true); * getSecondsPassedLocalFunction.AddChunk(branch); * return getSecondsPassedLocalFunction; * });*/ return(this.objectCallFactory.CreateObjectCall(calledOn, newFunctionName, multipleScriptsScope)); }
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 newArgs = new TES5ObjectCallArguments(); string dataString = functionArguments[0].StringValue; newArgs.Add(this.referenceFactory.CreateReference("Effect" + dataString, globalScope, multipleScriptsScope, localScope)); /*switch (dataString) * { * * case "INVI": * { * newArgs.add(this.referenceFactory.createReference("InvisibillityFFSelf", globalScope, multipleScriptsScope, localScope)); * break; * } * * case "REFA": * { * newArgs.add(this.referenceFactory.createReference("PerkRestoreStaminaFFSelf", globalScope, multipleScriptsScope, localScope)); * break; * } * * default: * { * newArgs.add(this.referenceFactory.createReference("Effect" + dataString, globalScope, multipleScriptsScope, localScope)); * break; * } * }*/ return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, newArgs)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { const string functionName = "Disable"; TES5ObjectCallArguments newArguments = new TES5ObjectCallArguments(); return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, newArguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4FunctionArguments functionArguments = function.Arguments; //Simple implementation without looking. TES5ObjectCallArguments arguments = new TES5ObjectCallArguments(); //if (calledOn.TES5Type != TES5BasicType.T_OBJECTREFERENCE) //{ // TES5Castable calledOnCastable = calledOn as TES5Reference; // if (calledOn != null && TES5InheritanceGraphAnalyzer.IsExtending(TES5BasicType.T_ACTOR, calledOn.TES5Type)) // { // calledOnCastable.ManualCastTo = TES5BasicType.T_OBJECTREFERENCE; // } //} //arguments.Add(calledOn); arguments.Add(this.valueFactory.CreateValue(functionArguments[0], codeScope, globalScope, multipleScriptsScope)); ITES5Value argument1 = this.valueFactory.CreateValue(functionArguments[1], codeScope, globalScope, multipleScriptsScope); //WTM: Change: Why is the below necessary? /*if (argument1.TES5Type != TES5BasicType.T_TOPIC) * { * TES5Reference? argument1Reference = argument1 as TES5Reference; * if (argument1Reference != null && TES5InheritanceGraphAnalyzer.IsExtending(TES5BasicType.T_TOPIC, argument1.TES5Type)) * { * argument1Reference.ManualCastTo = TES5BasicType.T_TOPIC; * } * }*/ arguments.Add(argument1); arguments.Add(new TES5Bool(true)); //TES5LocalScope localScope = codeScope.LocalScope; //ITES5Referencer timerReference = this.referenceFactory.CreateTimerReadReference(globalScope, multipleScriptsScope, localScope); return(this.objectCallFactory.CreateObjectCall(calledOn, "LegacySayTo", arguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; //Using Legacy TES4 Connector Plugin return(this.objectPropertyFactory.CreateObjectProperty(multipleScriptsScope, this.referenceFactory.CreateContainerReadReference(globalScope, multipleScriptsScope, localScope), "isInJail")); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4FunctionArguments oldArguments = function.Arguments; TES5ObjectCallArguments newArguments = this.objectCallArgumentsFactory.CreateArgumentList(oldArguments, codeScope, globalScope, multipleScriptsScope); return(this.objectCallFactory.CreateObjectCall(calledOn, this.newFunctionName, newArguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; //todo Refactor - add floating point vars . if (functionArguments.Count == 1) { TES5StaticReference calledOnRef = TES5StaticReferenceFactory.Debug; return(this.objectCallFactory.CreateObjectCall(calledOnRef, "MessageBox", this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope))); } else { string[] stringArguments = functionArguments.Select(v => v.StringValue).ToArray(); string edid = messageBoxData.GetEDID(stringArguments); IEnumerable <string> messageArguments = (new string[] { edid }).Concat(functionArguments.Select(a => a.StringValue)); this.metadataLogService.WriteLine("ADD_MESSAGE", messageArguments); Nullable <int> tes5FormIDNullable = messageBoxData.GetTES5FormID(edid); TES5Property messageBoxProperty = TES5PropertyFactory.ConstructWithTES5FormID(edid, TES5BasicType.T_MESSAGE, edid, tes5FormIDNullable); globalScope.AddProperty(messageBoxProperty); ITES5Referencer messageBoxReference = TES5ReferenceFactory.CreateReferenceToVariableOrProperty(messageBoxProperty); TES5ObjectCall messageBoxShow = this.objectCallFactory.CreateObjectCall(messageBoxReference, "Show"); ITES5Referencer messageBoxResult = this.referenceFactory.CreateReadReference(TES5ReferenceFactory.MESSAGEBOX_VARIABLE_CONST, globalScope, multipleScriptsScope, localScope); return(TES5VariableAssignationFactory.CreateAssignation(messageBoxResult, messageBoxShow)); } }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { ITES5ValueCodeChunk isPlayable = getIsPlayableRaceFactory.ConvertFunction(calledOn, function, codeScope, globalScope, multipleScriptsScope); TES5ComparisonExpression comparison = new TES5ComparisonExpression(isPlayable, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Bool(false)); return(comparison); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { //WTM: Note: Just like DisablePlayerControlsFactory, I want to emulate this: //https://cs.elderscrolls.com/index.php?title=DisablePlayerControls //Player cannot move, wait, activate anything, or access his journal interface. string[] functionNames = new string[] { "IsMovementControlsEnabled", "IsMenuControlsEnabled" /*closest to "IsWaitControlsEnabled" I could find*/, "IsActivateControlsEnabled", "IsJournalControlsEnabled" }; TES5ObjectCall[] objectCalls = functionNames.Select(f => objectCallFactory.CreateObjectCall(TES5StaticReferenceFactory.Game, f)).ToArray(); ITES5ValueCodeChunk?accumulatedStatement = null; foreach (TES5ObjectCall objectCall in objectCalls) { if (accumulatedStatement == null) { accumulatedStatement = objectCall; } else { accumulatedStatement = TES5ExpressionFactory.CreateLogicalExpression(accumulatedStatement, TES5LogicalExpressionOperator.OPERATOR_AND, objectCall); } } if (accumulatedStatement == null) { throw new NullableException(nameof(accumulatedStatement)); } TES5ComparisonExpression negatedExpression = TES5ExpressionFactory.CreateComparisonExpression(accumulatedStatement, TES5ComparisonExpressionOperator.OPERATOR_NOT_EQUAL, new TES5Bool(true)); return(negatedExpression); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { //GetInCell checks if a cell name starts with the argument string: https://cs.elderscrolls.com/index.php?title=GetInCell //The below will probably not always work. TES4FunctionArguments functionArguments = function.Arguments; ITES4StringValue apiToken = functionArguments[0]; string cellName = apiToken.StringValue; TES5ObjectCall getParentCell = this.objectCallFactory.CreateObjectCall(calledOn, "GetParentCell", multipleScriptsScope); TES5ObjectCall getParentCellName = this.objectCallFactory.CreateObjectCall(getParentCell, "GetName", multipleScriptsScope); int length = cellName.Length; TES5ObjectCallArguments substringArguments = new TES5ObjectCallArguments() { getParentCellName, new TES5Integer(0), new TES5Integer(length) }; TES5ObjectCall substring = this.objectCallFactory.CreateObjectCall(TES5StaticReference.StringUtil, "Substring", multipleScriptsScope, substringArguments); TES4LoadedRecord cellRecord = ESMAnalyzer._instance().FindInTES4Collection(cellName, false); string cellNameWithSpaces = cellRecord.GetSubrecordTrim("FULL"); if (cellNameWithSpaces == null) { cellNameWithSpaces = cellName; } TES5String cellNameTES5String = new TES5String(cellNameWithSpaces); return(TES5ExpressionFactory.CreateComparisonExpression(substring, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, cellNameTES5String)); }
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)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { //WTM: Note: I'd prefer a single method call obviously, but this is the best solution I can imagine. //https://www.creationkit.com/index.php?title=GetIsPlayableRace /* * TES5ObjectCall calledOnRaceName = objectCallFactory.CreateObjectCall(objectCallFactory.CreateObjectCall(calledOn, "GetRace"), "GetName"); * string[] playableRaces = new string[] { "Altmer", "Argonian", "Bosmer", "Breton", "Dunmer", "Imperial", "Khajiit", "Nord", "Orc", "Redguard" }; * ITES5Expression? accumulatedStatement = null; * foreach (string race in playableRaces) * { * TES5ComparisonExpression newExpression = TES5ExpressionFactory.CreateComparisonExpression(calledOnRaceName, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5String(race)); * if (accumulatedStatement == null) * { * accumulatedStatement = newExpression; * } * else * { * accumulatedStatement = TES5ExpressionFactory.CreateLogicalExpression(accumulatedStatement, TES5LogicalExpressionOperator.OPERATOR_OR, newExpression); * } * } * if (accumulatedStatement == null) { throw new NullableException(nameof(accumulatedStatement)); } * return accumulatedStatement; */ //Actor.GetRace().IsPlayable() might work: //https://www.creationkit.com/index.php?title=Race_Script return(objectCallFactory.CreateObjectCall(objectCallFactory.CreateObjectCall(calledOn, "GetRace"), "IsPlayable")); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5StaticReference newCalledOn = TES5StaticReferenceFactory.Game; TES5ObjectCallArguments arguments = objectCallArgumentsFactory.CreateArgumentList(function.Arguments, codeScope, globalScope, multipleScriptsScope); return(this.objectCallFactory.CreateObjectCall(newCalledOn, "PlayBink", arguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4FunctionArguments functionArguments = function.Arguments; TES5ObjectCall functionThis = this.objectCallFactory.CreateObjectCall(this.objectCallFactory.CreateGetActorBase(calledOn, multipleScriptsScope), "GetSex", multipleScriptsScope); int operand; switch ((functionArguments[0].StringValue).ToLower()) { case "male": { operand = 0; break; } case "female": { operand = 1; break; } default: { throw new ConversionException("GetIsSex used with unknown gender."); } } TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(functionThis, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, new TES5Integer(operand)); return(expression); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4FunctionArguments functionArguments = function.Arguments; int arg0 = (int)functionArguments.Pop(0).Data; string functionName; switch (arg0) { case 0: { functionName = "SheatheWeapon"; break; } case 1: { functionName = "DrawWeapon"; break; } default: { throw new ConversionException("Unknown setAlert value, must be 0 or 1"); } } TES5ObjectCallArguments newArguments = this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope); return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, newArguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5PlayerReference player = TES5ReferenceFactory.CreateReferenceToPlayer(globalScope); TES5ObjectCallArguments arguments = objectCallArgumentsFactory.CreateArgumentList(function.Arguments, codeScope, globalScope, multipleScriptsScope); return(objectCallFactory.CreateObjectCall(player, "SetDisplayName", arguments)); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { //@INCONSISTENCE - evaluated in random compile time, cannot assure all inference has happened already. TES5Bool boolean = new TES5Bool(TES5InheritanceGraphAnalyzer.IsTypeOrExtendsType(calledOn.TES5Type, TES5BasicType.T_ACTOR)); return(boolean); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES4FunctionArguments functionArguments = function.Arguments; TES5ObjectCallArguments args; string functionName; if (functionArguments.Any()) { args = this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope); ITES5Type arg0Type = analyzer.GetFormTypeByEDID(functionArguments[0].StringValue); if (arg0Type == TES5BasicType.T_ACTOR) { functionName = "SetActorOwner"; } else if (arg0Type == TES5BasicType.T_FACTION) { functionName = "SetFactionOwner"; } else { throw new ConversionException("Unknown setOwnership() param"); } } else { functionName = "SetActorOwner"; args = new TES5ObjectCallArguments() { this.objectCallFactory.CreateGetActorBaseOfPlayer(multipleScriptsScope) }; } return(this.objectCallFactory.CreateObjectCall(calledOn, functionName, multipleScriptsScope, args)); }
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 = 1000; break; } default: { throw new ConversionException("SetPCFactionMurder/SetPCFactionAttack 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, "SetCrimeGoldViolent", constantArgument); return(newFunction); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; ITES5Referencer newCalledOn = this.referenceFactory.CreateCyrodiilCrimeFactionReadReference(globalScope, multipleScriptsScope, localScope); return(this.objectCallFactory.CreateObjectCall(newCalledOn, "SendPlayerToJail", new TES5ObjectCallArguments())); }
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(TES5StaticReferenceFactory.Game, functionName, this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope))); }
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", multipleScriptsScope, this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope))); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; ITES5Referencer newCalledOn = this.referenceFactory.CreateReadReference(functionArguments.Pop(0).StringValue, globalScope, multipleScriptsScope, localScope); return(this.objectCallFactory.CreateObjectCall(newCalledOn, this.newFunctionName, multipleScriptsScope, this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope))); }
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) { TES5LocalScope localScope = codeScope.LocalScope; TES4FunctionArguments functionArguments = function.Arguments; ITES5Referencer argument = this.referenceFactory.CreateReadReference(functionArguments[0].StringValue, globalScope, multipleScriptsScope, localScope); TES5ComparisonExpression expression = TES5ExpressionFactory.CreateComparisonExpression(calledOn, TES5ComparisonExpressionOperator.OPERATOR_EQUAL, argument); return(expression); }
public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope) { TES5ObjectCallArguments arguments = new TES5ObjectCallArguments() { new TES5String("Variable01") }; return(this.objectCallFactory.CreateObjectCall(calledOn, "GetActorValue", multipleScriptsScope, arguments)); }