Genaxx Posted August 18, 2016 Share Posted August 18, 2016 Hi I'm completely new to writing scripts and i'm struggling to solve this :pinch: The concept is, a grenade that teleports you to where it lands. So im guessing I need the explosion to place an xMarker as the reference point of where to teleport the player, then actually teleport them. So far i've got, Grenade > projectile > explosion > place object (Activator) Then the activator script; Scriptname WarpGrenadeSCR extends activemagiceffect ObjectReference property teleMarker auto ObjectReference property teleDest auto Event OnEffectStart *somehow place an xmarker?* Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(teleDest) EndEvent I tried just having the teleDest in the script but then I could only give it the property of an existing xMarker :confused: I could really use some help on this. Link to comment Share on other sites More sharing options...
kwong96 Posted August 18, 2016 Share Posted August 18, 2016 To create an xmarker (which is a static object) you need a form property. Then you can use PlaceAtMe on it. Scriptname WarpGrenadeSCR extends activemagiceffect Form property teleMarker auto ObjectReference property teleDest auto Event OnEffectStart (*function variables here*) teleDest = theObjYouWantToPlaceAt.PlaceAtMe(teleMarker, abDeleteWhenAble = True) ; Up to you if you want the marker to delete itself once the game has no loaded ref to it. EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(teleDest) EndEventIn the property section of the script you can then select xMarker or xMarkerHeading as a STATIC form type depending on what you need to use and it will create a new marker for you. To test it you can just select DiamondSignMegSurgery02NoCol to see something in-game to make sure it is spawning correctly. Link to comment Share on other sites More sharing options...
Genaxx Posted August 18, 2016 Author Share Posted August 18, 2016 Thanks for the help but I can't add DiamondSignMegSurgery02NoCol in the properties for teleDest, its not in the list :unsure: Scriptname WarpGrenadeSCR extends activemagiceffect Form property teleMarker auto ObjectReference property teleDest auto Event OnEffectStart (*function variables here*);These should be Actor target, Actor caster no? teleDest = DiamondSignMegSurgery02NoCol.PlaceAtMe(teleMarker, abDeleteWhenAble = True) EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(teleDest) EndEvent Also tried this but it did nothing :psyduck: Scriptname WarpGrenadeSCR extends activemagiceffect Form property teleMarker auto ObjectReference property WarpGrenadeMarker auto ObjectReference property teleDest auto Event OnEffectStart (Actor target, Actor caster) teleDest = WarpGrenadeMarker.PlaceAtMe(teleMarker, abDeleteWhenAble = True) EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(teleDest) EndEvent Link to comment Share on other sites More sharing options...
kwong96 Posted August 18, 2016 Share Posted August 18, 2016 (edited) I might have missed something there. So teleMarker is the variable to store what type of object you want to spawn. That has to be set in the property window. That is what will be set to the xMarker or for a visual representation to test it, the DiamondSignMegSurgery02NoCol, both of which are of Form Type Static. I'll see if I can add a picture in a min.The teleDest can just be a regular variable in the script, I missed that part, because you are setting it in the script. WarpGrenadeMarker or WarpGrenadeObject needs to be the object you are referencing so the game knows where to spawn the teleMarker. How you figure out how to obtain that info is up to you. You can try GetTargetActor(), but I think that will look for an actor the explosion "hits" and not the Object the magic effect is on or just use "target" from OnEffectStart. Sorry, it's been awhile since I've touched activemagiceffects so I don't recall off-hand how to find the object the magic effect is attached to. Scriptname WarpGrenadeSCR extends activemagiceffect Form property teleMarker auto ObjectReference property WarpGrenadeMarker auto ObjectReference teleDest Event OnEffectStart (Actor target, Actor caster) teleDest = WarpGrenadeMarker.PlaceAtMe(teleMarker, abDeleteWhenAble = True) EndEvent Event OnEffectFinish(Actor target, Actor caster) target.MoveTo(teleDest) EndEventhttp://i63.tinypic.com/35kj0g1.jpg Edited August 18, 2016 by kwong96 Link to comment Share on other sites More sharing options...
Genaxx Posted August 18, 2016 Author Share Posted August 18, 2016 Argh, feels like im over complicating things. Could I just make the player move to the base id of the marker or something? Link to comment Share on other sites More sharing options...
kwong96 Posted August 18, 2016 Share Posted August 18, 2016 (edited) You can take a look at TeleportInSpellEffect and SynthTeleportGrenade to see how bethesda dealt with grenades and spawning actors. Looks like they use the target of the OnEffectStart. Edit: Ok give me a few to upload some screenshots. Working teleport grenade incoming. .....................So, I duplicated a fragGrenade, fragGrenadeProjectile, fragGrenadeExplosion, and InstituteBeaconSpawn. Make sure you edit the names in the proper fields at least for the fragGrenade weapon so you can find your grenade in-game. Next, add a new script to your duplicate InstituteBeaconSpawn and I checked off "Is Marker" and "Ignored By Sandbox" since it is an activator and I wouldn't want it messing up some random NPC's ai, though, you might want to find another object to use. I just grabbed this one because it was quick. http://i63.tinypic.com/5bu2ra.jpg For the script: Scriptname Nog_teleportSpawner extends ObjectReference Const Actor Property PlayerRef Auto Const Mandatory Event OnLoad() PlayerRef.MoveTo(self) endEventand lastly, you need to set the object in the explosion effect under "Placed Object".http://i65.tinypic.com/35mp99j.jpg That should be it. Just add it to your inventory in-game and toss one. Edit: Oh and make sure you set damage to 0 or you might end up hurting yourself. I would also look into expanding on the script to make sure you don't let the player kill themself with this if you pop into a bad area or from falling... unless you want that to be able to happen, heh. But you prob will need to add some extra stuff if you don't want the player to get stuck somewhere. I can't say if you could potentially end up inside an object with this or not. It's just a hastily put together teleporter. Edited August 18, 2016 by kwong96 Link to comment Share on other sites More sharing options...
Genaxx Posted August 18, 2016 Author Share Posted August 18, 2016 Wow thanks Kwong! I'll get to work on it and let you know. As for the potential bugs and deaths, I did put a warning on the grenade :tongue: It works! :dance: thanks so much Kwong, all it needs now is some fine tuning :D http://i.imgur.com/KfFqS8E.png Link to comment Share on other sites More sharing options...
kwong96 Posted August 18, 2016 Share Posted August 18, 2016 heh, welcome. Hopefully that'll work for you and at least get you started on what you want to do. Link to comment Share on other sites More sharing options...
Recommended Posts