TaxiVader Posted December 19, 2020 Share Posted December 19, 2020 Hi Folks. I am making a mod at the moment that is sort of a large town. It contains lots of shops, pubs and other interesting places. Part of the population of the town is the idle elite, and I want them to behave that way. I now understand the package system of setting NPC movements, but what I'd really like is for my idle rich people to wander around town popping into shops, pubs, whatever, throughout the day in the times when I don't have them specifically being elsewhere. Giving the appearance of that sort of thing with packages is possible but extremely clunky, each NPC would have a package list as long as my arm, especially if they are to be doing different sequences on different days of the week. Can anyone suggest a method for doing this, perhaps using some form of script(s)? Like, can I have a list of locations that the NPC will visit randomly during specified times of the day for either set or random periods of time per visit? If I was doing this in Microsoft Excel I'd use random numbers, vlookups and indexes, is such a thing possible here? I have little experience with scripting to date but am not afraid to give anything a go. Any ideas? Thanks, TV Link to comment Share on other sites More sharing options...
dylbill Posted December 19, 2020 Share Posted December 19, 2020 Hey yes this is possible. I did something similar to this with my latest mod Triple Triad Card Game in Skyrim. The NPC travels to a random inn, anywhere in Skyrim every 5 to 14 days. What I did was put the travel package on a reference alias in a quest. The reference alias point to the NPC, specific reference. Make another reference alias in the same quest. This one put as Find Matching Reference. Here you can put conditions for the reference to find. Maybe you can put a bunch of object reference markers in a formlist and use the IsInList condition. The alias fills with a random object reference based on the conditions when the quest starts. So, when you want your NPC to go somewhere, start the quest with the script. Then use the package end fragment or the package change fragment to stop the quest. I checked the Must Complete flag in the package so it will always stop the quest. Also in your package set the Travel Location to your reference alias. Hope that helps! Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 19, 2020 Share Posted December 19, 2020 A RefAlias script could be like this depends on what are you looking for. You can add properties like location or package when needed for comparing or use method from dybill with two refaliases.Behesda tut for package creation: https://www.creationkit.com/index.php?title=Bethesda_Tutorial_Packages tvNPCBehaviorAliasScript Scriptname tvNPCBehaviorAliasScript extend ReferenceAlias ; https://forums.nexusmods.com/index.php?/topic/9412423-random-movement-of-npcs;-is-it-possible-with-scripting/ GlobalVariable PROPERTY GameHour auto ; use auto-fill by CK ; -- EVENTs -- EVENT OnInit() Debug.Trace(" OnInit() - has been called for " + self) gotoState("Action") ; ### STATE ### ENDEVENT ; Event received when this reference is reset EVENT OnReset() Debug.Trace(" OnReset() - has been reached for " + self) ENDEVENT ;================================= state Done ;========= endState ;================================= state Action ; all events here for actor only ;=========== EVENT OnDeath(Actor akKiller) ; Event that is triggered when this actor finishes dying (only if this alias points at an actor) gotoState("Done") ; ### STATE ### Debug.Trace(" OnDeath() - R.I.P. for " + self) self.Clear() ; remove binding from actor to RefAlias ENDEVENT EVENT OnLocationChange(Location akOldLoc, Location akNewLoc) gotoState(Done) ; ### STATE ### myF_Action(akNewLoc) gotoState("Action") ; ### STATE ### ENDEVENT EVENT OnPackageStart(Package akNewPackage) ; Event received when this actor starts a new package ENDEVENT EVENT OnPackageChange(Package akOldPackage) ENDEVENT EVENT OnPackageEnd(Package akOldPackage) ENDEVENT ;======= endState ; -- FUNCTIONs -- ;------------------------------------- FUNCTION myF_Action(Location akNewLoc) ;------------------------------------- IF ( akNewLoc ) ELSE RETURN ; - STOP - location is None, NPC is anywhere in the wilderness ENDIF ;--------------------- ; code here ENDFUNCTION ;-------------------------- Int FUNCTION GetHourOfDay() ;-------------------------- int i = GameHour.GetValue() as Int RETURN i ENDFUNCTION ;-------------------------- Int FUNCTION GetDayOfWeek() ;-------------------------- ; https://www.creationkit.com/index.php?title=Complete_Example_Scripts#A_helper_script_with_functions_to_get_the_current_moonphase.2C_sync_between_the_two_moons_and_day_of_the_week ; returns the current ingame day of the week as int. ; 0 - Sundas ; 1 - Morndas ; 2 - Tirdas ; 3 - Middas ; 4 - Turdas ; 5 - Fredas ; 6 - Loredas int i = Utility.GetCurrentGameTime() as Int ; i = GameDaysPassed RETURN (i % 7) ENDFUNCTION Link to comment Share on other sites More sharing options...
TaxiVader Posted December 19, 2020 Author Share Posted December 19, 2020 Thanks folks, I'll get to work. Much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts