jcdenton2012 Posted August 10, 2017 Share Posted August 10, 2017 Hi, I'm working on the basic design work for a project, but I need help with a scripting idea that I had because I couldn't script my way out of a paperbag. Without giving to much away, its about aliens, and I need the script to do the following. Spawn and/or activate an NPC.Make the NPC walk from one X marker to the other X markerRemove and/or deactivate the NPC. I kind of would like help sourcing this because I couldn't script jack to save my life. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted August 10, 2017 Share Posted August 10, 2017 (edited) I'm bored and this is easy enough. You'll probably want to have an actor base just for this npc. It's not necessary but as you'll see below it might be useful. Make an xMarker for the spawn and target walk location. Name them so you can find them in the cell view easily enough should you need to. Make a package with Travel as the template. Name it something like "AlienTravelToMarker". What you name it really doesn't matter, it's just so you can find it later. In the package data window below click on the first line "Place to travel", on the right click the box above view that probably says "Near linked reference". Select "Near Reference". Click select reference. It will switch to the Render window. Select the marker for where you want the actor to walk to. Go back to the reference selection window if it didn't automatically switch back. Hit OK. Goto the Flags tab. Uncheck everything. If you want the actor to ignore being attacked then check "Ignore Combat" and "No Combat Alert". You should also make the actor base Invulnerable otherwise you could still kill the actor even though it will ignore the fact it's being attacked. Hit OK. We have to save the new package first so we can add scripts. Now select the package and open it up to edit it again. Goto the Begin/End/Change tab. In the middle "End" section add a papyrus fragment with ; this disables the actor that is running the package akActor.Disable() ; this deletes it once it is no longer referenced and is unloaded. akActor.DeleteWhenAble()Hit Compile. If you don't get an error then hit OK to save it. From here there's a few possibilities. I'm going to assume this all all going to be from a quest and the quest itself has been created already and edited at least once so it's base is created. So in the quest make an alias to hold this actor. For this example lets call the alias "AlienWalker". Add the package you created to the alias. Set the alias type to Specific Reference but leave it blank. Now whenever an actor is in that alias that package will fire (provided that actor isn't in any other quest aliases with higher priority). We'll handle spawning and filling the alias in a quest fragment. You're done with the alias so hit OK to finish up there. Now go to the Quest Stages tab and edit or make a new stage for spawning the actor. You need to make a log entry if you don't have one already. It can be empty, or not, you just need one so you can add a fragment script. In the fragment section click the little down arrow on the properties button. Select to create the Alias_AlienWalker property. It will take a second then give a message saying it made it. Now click the properties button to open the settings window. Click the down arrow on the Add Property button and select Create using form. You'll need to give it the editor ID name of your Alien actor. You can edit the name of the property as well. Lets do that and call it "AlienActor". So the Form Editor ID box has the editor id name of your actor and the property name has "AlienActor". This is important because that's what we're going to use in the spawning. The property type should come up ActorBase. If it's all good hit OK. You should see it populate in the properties window and auto fill the value. Now click Add Property to manually add one. Select type of ObjectReference and name SpawnMarker hit OK. Select the newly created property and on the right side click Edit Value. Then Pick Reference in Render Window. It will switch to the Render Window automatically. Double click on the marker you want to spawn the actor at. Then go back to the properties window and hit OK. In the fragment box put Actor newAlien = SpawnMarker.PlaceAtMe(AlienActor) Alias_AlienWalker.ForceRefTo(newAlien)Hit Compile and you should get no error. If you're good then hit OK. Now when that stage is set your actor should spawn at the spawn marker and walk to the target marker then disappear. Since the Alias will remain pointing to the reference until either the quest is stopped, or another actor is spawned and placed in it we should clear it at some point. You can use another stage fragment and add the line Alias_AlienWalker.Clear()This will clear it up so the DeleteWhenAble() can function and remove it. It also removes the persistency from the reference. That should do it. If you need to find the filenames of the script files (for manual packing or what not) you can open the package or quest, goto the fragments and on the Advanced tab of the fragment window it shows the Script Name. It will usually be something like "Fragments:Packages:PF_*" or similar depending what kind of script it is. If you didn't want to use a quest fragment to spawn it (or use a quest at all) you can use a trigger box. The script code gets slightly more complicated because you have to make an Activator, add the script with an OnTriggerEnter function to do your stuff. Then add the package to the actor base instead of an alias (if you want to go full no quest). Edited August 10, 2017 by BigAndFlabby Link to comment Share on other sites More sharing options...
jcdenton2012 Posted August 10, 2017 Author Share Posted August 10, 2017 It's... well... I'll tell you in private because I want to preserve the surprise. However, this is extremely helpful. I'll have time after work tomorrow to take a crack at it and see if I can get it to work properly. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted August 10, 2017 Share Posted August 10, 2017 (edited) Actually the more I think about it a trigger box might be better. Here's how that would work. Make an activator (I clone the DefaultEmptyTrigger) put a script on it. Add the properties for the ActorBase AlienActor and the ObjectReference SpawnMarker. Then edit the script source and add Event OnTriggerEnter(ObjectReference akActionRef) ; Since the package cleans itself up and we have no persistent reference of this spawned actor this is all we need. SpawnMarker.PlaceAtMe(AlienActor) EndEvent Here's a video showing it in action Edited August 10, 2017 by BigAndFlabby Link to comment Share on other sites More sharing options...
Recommended Posts