IronDusk33 Posted April 2, 2017 Share Posted April 2, 2017 I'm working on a mod that adds new generic NPCs to towns and cities. The way I go about this is I have several Markers in cities, that detect when the player has entered or exited the area. When the player leaves the area, a new person is placed using PlaceAtMe. When the player enters the area, and a sufficient amount of time has passed, the person is marked for deletion. Here's the source code: GlobalVariable Property MinLiving Auto GlobalVariable Property MaxLiving Auto GlobalVariable Property RespawnWait Auto GlobalVariable Property GameDaysPassed Auto ObjectReference Property PlaceMarker Auto LeveledActor Property ToPlace Auto string Property MarkerName Auto float LastUpdate = -100.0 Actor Person = None Event OnCellDetach() Debug.Trace("People: " + MarkerName + " Detached from Cell") if((!Person || Person.IsDead() || Person.IsDeleted()) && (GameDaysPassed.GetValue() - LastUpdate) > RespawnWait.GetValue()) Debug.Trace("People: " + MarkerName + " Placing New Person") Person = PlaceMarker.PlaceAtMe(ToPlace) as Actor LastUpdate = GameDaysPassed.GetValue() Debug.Trace("People: " + MarkerName + " New Person Placed: " + Person.GetFormID()) endIf endEvent Event OnCellAttach() Debug.Trace("People: " + MarkerName + " Attached to Cell") float RandLiving = Utility.RandomFloat(MinLiving.GetValue(), MaxLiving.GetValue()) if(Person && (GameDaysPassed.GetValue() - LastUpdate) > RandLiving) Debug.Trace("People: " + MarkerName + " Deleting Person: " + Person.GetFormID()) Person.DeleteWhenAble() Debug.Trace("People: " + MarkerName + " Person Deleted") Person = None endIf endEvent My question is, how safe is this? Would this constant deletion potentially cause save-game bloat? Or if one of the radiant npcs was used in an alias, then deleted, would that cause issues? Link to comment Share on other sites More sharing options...
Gamer921 Posted May 19, 2017 Share Posted May 19, 2017 (edited) Off the top of my head and at first glance it appears you forgot to use actorbase property while using placeatme. I was under the influence thats the only way placeatme works. Also id try disabling the npcs then deletion. I think that helps prevent the bloat save. Edited May 19, 2017 by Gamer921 Link to comment Share on other sites More sharing options...
TheDungeonDweller Posted May 19, 2017 Share Posted May 19, 2017 (edited) That's the only way it works when you want to create actors at run time, yes.Also, nah, constant deletion will not cause save-game bloat. In fact it is seriously encouraged that all created refs are cleaned up when they aren't needed. Edited May 19, 2017 by TheDungeonDweller Link to comment Share on other sites More sharing options...
Gamer921 Posted May 24, 2017 Share Posted May 24, 2017 So self.delete over self.disable? Link to comment Share on other sites More sharing options...
TheDungeonDweller Posted May 24, 2017 Share Posted May 24, 2017 From what I've seen from Beth's scripts, they like to disable the object first and then delete. self.disable()self.delete()I haven't done it any other way than this. Obviously you don't disable an object that isn't visible to begin with. Link to comment Share on other sites More sharing options...
Gamer921 Posted May 24, 2017 Share Posted May 24, 2017 True, i may rework my standalone follower now that this is confirmed. Kinda sux i cant upload my mod on the nexus. Mainly due to lack of permissions from the original authors of some of the meshes i use. Link to comment Share on other sites More sharing options...
JonathanOstrus Posted May 28, 2017 Share Posted May 28, 2017 From what I've seen from Beth's scripts, they like to disable the object first and then delete. self.disable()self.delete() I haven't done it any other way than this. Obviously you don't disable an object that isn't visible to begin with.Disable hides it from immediate view but the reference remains in case you EVER enable it again: http://www.creationkit.com/index.php?title=Disable_-_ObjectReferenceDisables this reference, fading it out if necessary. This function is latent and will wait for the fade out and/or disable to happen.Delete is really more like delete when conditions are met: http://www.creationkit.com/index.php?title=Delete_-_ObjectReferenceFlags this object reference as wanting to be deleted. A reference that is flagged for delete will be deleted as soon as:It is no longer in a script propertyIt is no longer registered for updatesIt is no longer being watched for Anim EventsIt is no longer held in a quest AliasBoth are used so that the object disappears immediately and is then marked to be removed when the conditions are met. Link to comment Share on other sites More sharing options...
Recommended Posts