Agnot2006 Posted November 14, 2011 Share Posted November 14, 2011 Can anyone give me a way of saving the name of the current AI package being run in a script by an NPC that it is attached to so after I have completed my package I can put back the package that was running before? Ref MyPackageRef Begin Gamemode If GetCurrentAIPackage > 1 ; Follow Set PackageRef to aaGuardPlayer ; something to save the name of the Package RemoveScriptPackage ; remove the package AddScriptPackage "myPackage" Endif ;Later If mystuff is finished RemoveScriptPackage AddScriptPackage "The one that was saved" endif End Any Help would be appreciated Link to comment Share on other sites More sharing options...
vforvic Posted November 14, 2011 Share Posted November 14, 2011 What situation are you using this package in and on who? This can make a difference on what can be done. For example, depending on the exact situation, you really don't have to use RemoveScriptPackage when you use AddScriptPackage since the Package called by AddScriptPackage should start running over whatever Package is already running anyway. You just need to make sure you either use a Variable or some type of Condition to keep it running. Remember that the Package added by AddScriptPackage is not truely added to the NPC like a GECK added Package. Once that Package added by AddScriptPackage finishes running then it goes away completely and would have to be called again to be used. Normal Package Evaluation or running EVP would have the NPC start running its normal Package Routines again. Also, RemoveScriptPackage, if I am not mistaken, cannot remove a Package added by the GECK, but is only for removing Packages added via AddScriptPackage that you have set to run until removed. Link to comment Share on other sites More sharing options...
Agnot2006 Posted November 15, 2011 Author Share Posted November 15, 2011 My Problem is I have created a companion that can be asked to lead instead of follow for a change (she will follow as well if asked) There are 14 different markers she can lead you to across the wasteland depending on the Package thats added via a Quest topics. She also has extensive Sandbox routines that can be activated by topics for overnight stops and things.This all works fine. I just wanted to be able to tell her to carry on to the marker and as the actual package name was saved before the sandbox routing was started could be added again as if she remembered where she was going. I just hoped there was a way to save what the package name was instead of setting a variable to a number and doing a list of Ifs to put the package back? Link to comment Share on other sites More sharing options...
vforvic Posted November 16, 2011 Share Posted November 16, 2011 I have used Reference Variables in the past to do something similar. If you set a Reference Variable to a Package Name then when you call the Reference Variable it will call the Package Name.So if I set PackageRef to TheNameOfMyTravelPackage in the On Begin Script in my Sandbox Package. For example when my NPC stopped for the night to Sandbox during a Travel to a point.Now that Package Name is saved to that Reference Variable and I can use it whenever.Then the next morning I say lets get going and that sets another variable in the Dialog Script which kicks off the AddScriptPackage part of my NPC Script.and then when the NPC's Script saysAddScriptPackage PackageRefit will really be saying AddScriptPackage TheNameOfMyTravelPackage and the day befores travel package will start running again.Of course in your case you would probably need 14 Sandbox Packages to match up to the 14 Travel Markers which would probably be as much work as the If's.Still it is something to keep in mind. Link to comment Share on other sites More sharing options...
Agnot2006 Posted November 16, 2011 Author Share Posted November 16, 2011 Thank You for your replyIs there a way to use Set PackageRef to GetCurrentAIPackage something like it. I know that GetCurrentAIPackage would result in a number but is there something that would contain the name of the package the companion is using at the time? That would save a lot of time and space in my script. I suppose I could set the PackageRef when I start each particular escort running with AddScriptPackage in the quest topic result script box, but that would still mean 14 of them.It would be so nice if I could just test for the package name in the main script and store that. Link to comment Share on other sites More sharing options...
vforvic Posted November 16, 2011 Share Posted November 16, 2011 You set up a Global for controlling when the Stop for the Night Sandbox runs. I called mine MOREscortSBGlobal. You have this code in your NPC Script. ref PackageMOR ;this is your PackageRef Variable short runonce ;this tells the script to only run the package when this variable is set so you don't get a loop. Begin GameMode if runonce == 1 ;set in the Quest Dialog Script when it is time to continue the Escort Package. AddScriptPackage PackageMOR ;PackageMOR has been set in the Escort Packages On Begin Script evp set runonce to 0 endif End In each Escort Package in the On Begin Script you have Set MORNovaREF.PackageMOR to MORJessicaEscort1 ;MORJessicaEscort1 being whatever that Packages name is. This sets the Reference Variable to the Package Name for use in the NPC Script when needed later. When you are ready for the NPC to start you say "Lets go to point 1" and put the following in that Quest Dialog "Result Script [End]" MORNovaRef.Addscriptpackage MORJessicaEscort1 ;the referenced NPC will now start that particular Escort Package. When you are ready to stop the NPC for the night you say "Lets Camp for the Night" and put the following in that Quest Dialog "Result Script [End]" MORNovaRef.Removescriptpackage PackageMOR ;you are taking away the Escort Package saved in the Reference so it stops running. set MOREscortSBGlobal to 1 ;setting this Global to 1 allows the Stop for the Night Sandbox Package to run since you set this as a condition in the Package. In the morning when you are ready for the NPC to continue you say "Time to go" and put the following in that Quest Dialog "Result Script [End]" set MOREscortSBGlobal to 0 ;this stops the Stop for the Night Sandbox Package. set MORNovaRef.runonce to 1 ;in the NPC Script this now starts the part of the script that says "AddScriptPackage PackageMOR" which starts the saved Escort Package again. This is the basis for it and you could probably still use the Quest Script in some way as well as the Quest Stage Scripts. Keeping in mind of course that some Scripts don't like References.Of course this is all simple and generic. Depending on how you have things set up as far as how things already start and stop and how your Quest and Dialogs work things may or may not work. This is more of a this can be done thing. Link to comment Share on other sites More sharing options...
Agnot2006 Posted November 17, 2011 Author Share Posted November 17, 2011 I want to thank you very Much for your assistance, it’s been most helpful. Link to comment Share on other sites More sharing options...
Recommended Posts