Sekoshiba Posted March 25, 2018 Share Posted March 25, 2018 (edited) Hi all, I'm brand new to modding and struggling to create a mod. Essentially what I'm looking to do is give the player an item that slows down time by a significant amount, allows them to wander around, then teleports them back to their original location when the duration is reached. So far I've managed to: - Modify the file for Jet so that it lasts longer, and has it's own custom item ("Yoyo").- Program the item so that on use it invisibly adds another of the item to the player's inventory, so they never run out. I'm struggling with the "Teleport to start" part of the mod. From what I've read I'll either need to: - "GetPos" on effect activate, then Setpos on effect expiration. This would be ideal if it's an option.- Have the player drop an object at the effect activation, then "MoveTo" the player to the object when the effect expires. I've tinkered with both of these, but the syntax is quite unfamiliar and I've been unable to get my mod to compile past this point. I'd really appreciate any help. Thank you! Edit: Here is my code so far. I apologise if there are any obvious issues. As I say, super new to modding! Scriptname YoyoReturnScript extends activemagiceffect Actor property PlayerRef Auto GlobalVariable property Playerposition Auto Event OnEffectStart (Actor target, Actor caster) PlayerPosition = PlayerRef.GetPos EndEvent Event OnEffectFinish(Actor target, Actor caster) PlayerRef.SetPos = PlayerPosition EndEvent The compiler gives me these errors: Papyrus Compiler Version 2.8.0.4 for Fallout 4 Copyright (C) ZeniMax Media. All rights reserved. Starting 1 compile threads for 1 files... Compiling "YoyoReturnScript"... C:\Users\EuanW\AppData\Local\Temp\PapyrusTemp\YoyoReturnScript.psc(8,27): GetPos is not a property on script actor or one of its parents C:\Users\EuanW\AppData\Local\Temp\PapyrusTemp\YoyoReturnScript.psc(12,10): SetPos is not a property on script actor or one of its parents C:\Users\EuanW\AppData\Local\Temp\PapyrusTemp\YoyoReturnScript.psc(12,9): type mismatch while assigning to a none (cast missing or types unrelated) No output generated for YoyoReturnScript, compilation failed. Batch compile of 1 files finished. 0 succeeded, 1 failed. Failed on YoyoReturnScript Edited March 25, 2018 by Sekoshiba Link to comment Share on other sites More sharing options...
JonathanOstrus Posted March 26, 2018 Share Posted March 26, 2018 Some issues here:Unless I'm misremembering things, script variables and properties are no longer available when OnEffectFinish is called. So you need some other way of retrieving data if you need more than the arguments of target or caster.For the compiler errors this is due to:The use of PlayerPosition global you're trying to assign the property to be an invalid thing. You need to access the value of a global with one of the member functions on it or the .Value property. https://www.creationkit.com/fallout4/index.php?title=GlobalVariable_ScriptGetPos is not a property of an Actor or ObjectReference. Nor is it a valid member function.There are 3 different functions for getting positional data of an ObjectReference which is GetPositionX(), GetPositionY(), GetPositionZ(). So you would need 3 variables to store the location. Alternatively you could place a marker to get an ObjectReference and then use that reference instead of 3 floats of x/y/z data.Same issue with the SetPos.Assuming I am correctly remembering not being able to use the variables during finish. I can't think of a viable way to use the effect script to do what you want without some ugly hacks involving GetFormFromFile(). Link to comment Share on other sites More sharing options...
Sekoshiba Posted March 26, 2018 Author Share Posted March 26, 2018 Some issues here:Unless I'm misremembering things, script variables and properties are no longer available when OnEffectFinish is called. So you need some other way of retrieving data if you need more than the arguments of target or caster.For the compiler errors this is due to:The use of PlayerPosition global you're trying to assign the property to be an invalid thing. You need to access the value of a global with one of the member functions on it or the .Value property. https://www.creationkit.com/fallout4/index.php?title=GlobalVariable_ScriptGetPos is not a property of an Actor or ObjectReference. Nor is it a valid member function.There are 3 different functions for getting positional data of an ObjectReference which is GetPositionX(), GetPositionY(), GetPositionZ(). So you would need 3 variables to store the location. Alternatively you could place a marker to get an ObjectReference and then use that reference instead of 3 floats of x/y/z data.Same issue with the SetPos.Assuming I am correctly remembering not being able to use the variables during finish. I can't think of a viable way to use the effect script to do what you want without some ugly hacks involving GetFormFromFile(). Thanks for the reply! I've tinkered with the code a bit more, and managed to find some code for a 'teleport grenade' that cleared up some of my misunderstanding. This is what I've changed the code to: Scriptname YoyoReturnScript extends activemagiceffect Form property TeleportMarker auto ObjectReference property PhysicalReturnMarker auto ObjectReference TeleportDestination Event OnEffectStart (Actor target, Actor caster) TeleportDestination = PhysicalReturnMarker.PlaceAtMe(TeleportMarker, abDeleteWhenAble = True) EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(TeleportDestination) EndEvent Looking back at my code, the player isn't referenced. But apparently 'PlayerRef.MoveTo' is an illegal operation for actors, so I'm not sure how to fix that. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted March 26, 2018 Share Posted March 26, 2018 actors can moveto just fine. the issue is that the destination as written will be invalid. you could verify by putting a debug trace in to spit out the reference id during the finish. when you check the log I bet you'll find it to be a none value. Link to comment Share on other sites More sharing options...
Sekoshiba Posted March 26, 2018 Author Share Posted March 26, 2018 actors can moveto just fine. the issue is that the destination as written will be invalid. you could verify by putting a debug trace in to spit out the reference id during the finish. when you check the log I bet you'll find it to be a none value. I fiddled with the properties and got the script working. The Debug Message returns 'TeleportDestination' as '[ObjectReference', but the teleport now works. The code: Scriptname YoyoReturnScript extends activemagiceffect Form property TeleportMarker auto ObjectReference property PhysicalReturnMarker auto ObjectReference TeleportDestination Actor Property PlayerRef Auto Const Mandatory Event OnEffectStart (Actor target, Actor caster) TeleportDestination = PhysicalReturnMarker.PlaceAtMe(TeleportMarker, abDeleteWhenAble = True) EndEvent Event OnEffectFinish(Actor target, Actor caster) PlayerRef.MoveTo(TeleportDestination) EndEvent The only issue I have with this is that 'MoveTo' forces a loading screen for the player. The only solution on the forums I've seen so far is to manually offset the player's position with "TranslateRefTo", but I can't find adequate documentation on it. Off the top of my head, if there was a way I could make the player noclip and very quickly offset their current position, that'd work. I have no idea if that's an option though, and I can't find any documentation on a noclip function. Link to comment Share on other sites More sharing options...
deadbeeftffn Posted March 26, 2018 Share Posted March 26, 2018 Maybe you can use PathToReference(). There was a thread just a few days ago. Link to comment Share on other sites More sharing options...
Sekoshiba Posted March 26, 2018 Author Share Posted March 26, 2018 (edited) Maybe you can use PathToReference(). There was a thread just a few days ago. That'd be ideal, but unfortunately I can't seem to get it working. I changed: Event OnEffectFinish(Actor target, Actor caster) PlayerRef.MoveTo(TeleportDestination) EndEvent To: Event OnEffectFinish(Actor target, Actor caster) PlayerRef.PathToReference(TeleportDestination, 1) EndEvent and it no longer works. Update: actors can moveto just fine. the issue is that the destination as written will be invalid. you could verify by putting a debug trace in to spit out the reference id during the finish. when you check the log I bet you'll find it to be a none value. You're correct. Your idea to use Debug messages highlighted that the ObjectReference held by the variable is an error. With "MoveTo" the teleport worked, but "PathToReference" will not work because the ObjectReference is not properly defined. I'm confused how to rewrite this though... Event OnEffectStart (Actor target, Actor caster) TeleportDestination = PhysicalReturnMarker.PlaceAtMe(TeleportMarker, abDeleteWhenAble = True) EndEvent In the properties menu for the script, I have: PhysicalReturnMarker - ObjectReference - PlayerRef(00000014) PlayerRef - Actor const - PlayerRef(00000014) TeleportMarker - Form - XMarker(0000003B) Edited March 26, 2018 by Sekoshiba Link to comment Share on other sites More sharing options...
Sekoshiba Posted March 26, 2018 Author Share Posted March 26, 2018 (edited) Maybe you can use PathToReference(). There was a thread just a few days ago. After looking at further documentation, it looks like PathToReference() has a top speed parameter of running-speed. That's too slow for what I'm trying to do, sorry. I'm going to stick with "MoveTo()" for the time being, I reckon I can fiddle with 'fMinPlayerMoveToDistForLoadScreen' in the Fallout.ini file so that loading screens don't bother me for the moment.actors can moveto just fine. the issue is that the destination as written will be invalid. you could verify by putting a debug trace in to spit out the reference id during the finish. when you check the log I bet you'll find it to be a none value. I'm grateful for the help up to this point. I'm still unsure what the issue with the following is though... Scriptname YoyoReturnScript extends activemagiceffect Form property TeleportMarker auto ObjectReference property PhysicalReturnMarker auto ObjectReference TeleportDestination Actor Property PlayerRef Auto Const Mandatory Event OnEffectStart (Actor target, Actor caster) TeleportDestination = PhysicalReturnMarker.PlaceAtMe(TeleportMarker, abDeleteWhenAble = True) ;In particular the above. I can't figure out why it's returning an ObjectReference error. EndEvent Event OnEffectFinish(Actor target, Actor caster) PlayerRef.MoveTo(TeleportDestination) EndEvent Perhaps I should be using "PlayerRef.GetPositionX/Y/Z" instead, seeing as I'm having trouble understanding the code I'm using? Do you happen to know if there's a way to force Noclip on the player, then set them to glide to a specific point? I've looked at the Geck docs but haven't been able to find anything. Edited March 26, 2018 by Sekoshiba Link to comment Share on other sites More sharing options...
JonathanOstrus Posted March 26, 2018 Share Posted March 26, 2018 Ok so that that I've had some rest I can see I was wrong about the property being invalid when the event fires. Maybe I'm misremembering something from Skyrim. I don't know. In any case, I'm a bit confused about the way you're writing this script. And how the properties are being assigned. I'm going to rewrite it so the property for my example below can be auto filled. The only property it now has is the xMarker it places. Scriptname YoyoReturnScript extends activemagiceffect Static property xMarker auto ObjectReference TeleportDestination Event OnEffectStart (Actor target, Actor caster) TeleportDestination = target.PlaceAtMe(xMarker, abDeleteWhenAble = True) ;Debug.Trace(self + " target: " + target + " xMarker: " + xMarker + " destination: " + TeleportDestination) EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(TeleportDestination) ;Debug.Trace(self + " target: " + target + " destination: " + TeleportDestination) EndEvent I tested this script with a dummy plugin I made and it worked across worldspaces, short, and far distances. Though regardless of distance it triggered a load screen. I'm not sure there's any way to avoid that honestly. I did try with grabbing X/Y/Z and using SetPosition() and that caused an infinite load screen for me for a short distance. So that seems to be out. In fact it hung my game so I had to force close the process via TaskManager. Link to comment Share on other sites More sharing options...
dagobaking Posted March 27, 2018 Share Posted March 27, 2018 Maybe you can use PathToReference(). There was a thread just a few days ago. That'd be ideal, but unfortunately I can't seem to get it working. I changed: Event OnEffectFinish(Actor target, Actor caster) PlayerRef.MoveTo(TeleportDestination) EndEvent To: Event OnEffectFinish(Actor target, Actor caster) PlayerRef.PathToReference(TeleportDestination, 1) EndEvent and it no longer works. To get PathToReference to work on the player, you need to allow AI to control the player first. This line: Game.SetPlayerAIDriven()https://www.creationkit.com/fallout4/index.php?title=SetPlayerAIDriven_-_Game Do you happen to know if there's a way to force Noclip on the player, then set them to glide to a specific point? If I'm understanding what you are trying to do correctly, it might work to run this first: debug.enableCollisions(false)Move the actor and then turn collisions back on. debug.enableCollisions(true) Link to comment Share on other sites More sharing options...
Recommended Posts