Jump to content

Script: Placeatme and auto-linking


Zorkaz

Recommended Posts

I don't need this currently but

 

Is it possible for an activator to use "placetame" and automatically "linkrefing" the placed object to the activator.

 

E.g creating a light source, but if the light source exists, another one won't spawn. And will get deleted if the object gets picked up / scrapped

 

This might come in handy for dynamically placed objects.

Link to comment
Share on other sites

Yes do it all the time. This is an example of a workshop construtable campfire which places idle markers around it (as scripting is easier than working with NIFs for me);


;*****************************************************************************************************************

Event OnLoad()

Debug.Trace("SKK_MWCampFireScript.OnLoad " + Self + " Workshop " + Self.GetLinkedRef(pWorkshopItemKeyword))

If (Self.GetLinkedRef(pWorkshopItemKeyword) != None) && (Self.CountRefsLinkedToMe(pSKK_MWIdleLink) == 0)
	ObjectReference ThisMarker
	ThisMarker = Self.PlaceAtNode("SKK_ATTACHIDLE00", pNPCInvGroundSit, aiCount = 1, abForcePersist = true, abInitiallyDisabled = false, abDeleteWhenAble = false, abAttach = true)
	ThisMarker.SetLinkedRef(Self, pSKK_MWIdleLink) 
	ThisMarker = Self.PlaceAtNode("SKK_ATTACHIDLE01", pNPCInvGroundSit, aiCount = 1, abForcePersist = true, abInitiallyDisabled = false, abDeleteWhenAble = false, abAttach = true)
	ThisMarker.SetLinkedRef(Self, pSKK_MWIdleLink) 
	ThisMarker = Self.PlaceAtNode("SKK_ATTACHIDLE02", pNPCInvGroundSit, aiCount = 1, abForcePersist = true, abInitiallyDisabled = false, abDeleteWhenAble = false, abAttach = true)
	ThisMarker.SetLinkedRef(Self, pSKK_MWIdleLink) 
	ThisMarker = Self.PlaceAtNode("SKK_ATTACHIDLE03", pNPCInvGroundSit, aiCount = 1, abForcePersist = true, abInitiallyDisabled = false, abDeleteWhenAble = false, abAttach = true)
	ThisMarker.SetLinkedRef(Self, pSKK_MWIdleLink) 
EndIf
		
EndEvent

; dont forget to cleanup linkref markers OnWorkshopObjectDestroyed to avoid persistant orphan objects

;*****************************************************************************************************************

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...