Minuos Posted December 2, 2021 Share Posted December 2, 2021 Hi all, My mod has actors that are more like workshop objects than settlers, but they have the WorkshopNPCScript. I've made a function which converts them into settlers, which seems to work except for the fact that they can't be assigned to objects or caravans unless they are sent to another workshop and back, or the player leaves and returns. I'm thinking the best solution to this would be to remove them from whatever workshop they currently belong to before OpenWorkshopSettlementMenu() pops, so the player can reassign them to the workshop without having to move them to a different one first. Anyone know how I might do this? Link to comment Share on other sites More sharing options...
SKKmods Posted December 2, 2021 Share Posted December 2, 2021 If you check WorkshopNPCScript for Event OnLoad you will se why they can not be assigned until they unload and then load. The dirty hack is to disable then enable the actor. The elegant solution is, rather than setting values directly and then wating for WorkshopNPCScript to trigger OnLoad, call the script functions like this: If ((ThisActor as WorkshopNPCScript).bCountsForPopulation == True) (ThisActor as WorkshopNPCScript).SetCommandable(TRUE) (ThisActor as WorkshopNPCScript).SetAllowCaravan(TRUE) (ThisActor as WorkshopNPCScript).SetAllowMove(TRUE) EndIf Following that a common issue is that the workshop resource statuses are not up to date due to constant issues with ResetWorkshop (search on my SKK articles which iexplain WHY). If thats the case fire this: If (pWorkshopParent as WorkshopParentScript).IsEditLocked() == FALSE) (pWorkshopParent as WorkshopParentScript).ResetWorkshop(ThisWorkshop as WorkshopScript) EndIf Link to comment Share on other sites More sharing options...
Pelgar Posted December 2, 2021 Share Posted December 2, 2021 I'm not sure how you would do that with OpenWorkshopSettlementMenu(). I have a script that I've been using for a while now that places new npc's in settlement via the workshop. The settlers are added to the workshop and commendable on placement. I attach the script, along with WorkshopNPCScript, to the actor I want to place. Scriptname PelgWorkshopNPCScript extends Actor Conditional WorkshopParentScript Property WorkshopParent Auto Const Bool property bAddedToWkShop = false auto Event OnWorkshopObjectPlaced(objectreference akReference) If (!bAddedToWkShop) ;Debug.MessageBox("OnWorkshopObjectPlaced Event ran on Pelg Settler.") self.EvaluatePackage(true) self.AddKeyword(WorkshopParent.WorkshopAllowCommand) self.AddKeyword(WorkshopParent.WorkshopAllowMove) self.SetNoBleedoutRecovery(false) actor PelgSettler = Self as actor workshopnpcscript WkShpScript = PelgSettler as workshopnpcscript WkShpScript.bCommandable = true WkShpScript.bAllowCaravan = true WkShpScript.bAllowMove = true WkShpScript.bIsWorker = true WkShpScript.bCountsForPopulation = true WkShpScript.bWork24Hours = false WkShpScript.assignedMultiResource = WorkshopParent.WorkshopRatings[WorkshopParent.WorkshopRatingFood].resourceValue workshopscript workshopRef = self.getLinkedRef(WorkshopParent.WorkshopItemKeyword) as workshopscript WorkshopParent.AddActorToWorkshopPUBLIC(PelgSettler as workshopnpcscript, workshopRef, false) bAddedToWkShop = true EndIf EndEvent Hope this helps Link to comment Share on other sites More sharing options...
Minuos Posted December 2, 2021 Author Share Posted December 2, 2021 (edited) Thanks guys. I played around with this stuff for a while, but this was the key: actor PelgSettler = Self as actor workshopnpcscript WkShpScript = PelgSettler as workshopnpcscript workshopscript workshopRef = self.getLinkedRef(WorkshopParent.WorkshopItemKeyword) as workshopscript WorkshopParent.AddActorToWorkshopPUBLIC(PelgSettler as workshopnpcscript, workshopRef, false) Including a slight variation of these lines in my conversion script allows me to assign the actors without having to move them at all. Big thanks. All I need to do now is find a way to check if an actor is a provisioner or vendor and my mod's groundwork is pretty much done. Edited December 2, 2021 by Minuos Link to comment Share on other sites More sharing options...
Recommended Posts