Jump to content

placeAtMe - seems unreliable?


Recommended Posts

PlaceAtMe works just fine. Here... save you some heartache. Tweak how you like, and I offer no warranty

	ObjectReference NazeemSpawn = Gate().PlaceAtMe(Game.GetForm(0x13BBF)); Or use the Nao call to skip immersive visual placement
	When3D(NazeemSpawn)
	WhateverYouWanted3DLoadedFirstToDo()
	Etc()


;=================================================================
ObjectReference Function Gate(Float Dist = 300.0,Float Elev = 0.0,Float Bias = 0.0) Global
	 ObjectReference PCO = Game.GetForm(0x14) as ObjectReference
	 ObjectReference Here = PCO.PlaceAtMe(Game.GetForm(0x7CD55),1,False,True); 0xC9ED4 or 0x7CD55
	 Here.MoveTo(PCO,Dist * Math.Sin(PCO.GetAngleZ()),Dist * Math.Cos(PCO.GetAngleZ()),Elev)
	 Here.SetAngle(0.0,0.0,Here.GetAngleZ() + Here.GetHeadingAngle(PCO) + Bias); Change Bias to 180.0 to make it face away from you instead
	 Here.Enable()
	 Utility.Wait(1.0); Skip if you want... I like a second here
	 Return Here
EndFunction
;=================================================================
ObjectReference Function Nao(Form What,Float Dist = 300.0,Float Elev = 0.0,Float Bias = 0.0,Bool Insistent = False,Bool Hid = False) Global
	 ObjectReference PCO = Game.GetForm(0x14) as ObjectReference
	 Bool QuietPlacement = Hid || What.GetType() != 43
	 ObjectReference Here = PCO.PlaceAtMe(What,1,Insistent,QuietPlacement)
	 Here.MoveTo(PCO,Dist * Math.Sin(PCO.GetAngleZ()),Dist * Math.Cos(PCO.GetAngleZ()),Elev)
	 Here.SetAngle(0.0,0.0,Here.GetAngleZ() + Here.GetHeadingAngle(PCO) + Bias); Change Bias to 180.0 to make ref face away from you instead
	 QuietPlacement && !Hid && Here.Enable()
	 Return Here
EndFunction
;=================================================================
Bool Function When3D(ObjectReference Arriving,Float Delay = 0.1,Float Timeout = 10.0) Global
	 While Arriving as Bool && !Arriving.Is3DLoaded() && Timeout as Bool
		 Utility.Wait(0.1)
		 Timeout -= 0.1
	 EndWhile
	 Return Utility.Wait(Delay) as String && Arriving as Bool && Arriving.Is3DLoaded()
EndFunction
;=================================================================

 

Use properties instead of GetForm calls if you want. Just showing how to do it 

If placing something in another cell than what player is in, you can, just yeah assume it isn't rendered until you visit. Can always place at player then move them after. Play around with solutions

Link to comment
Share on other sites

Thanks Sphered! Wow - I don't think I've ever quite seen code like that before!

Yes, I'm not doubting placeAtMe works well in most situations. But for whatever reason I'm finding that using it within a room marker has very rare issues (area of 1 in 20 to 1 in 100) with it binding the newly created reference to the correct room marker, hence making the reference invisible from within that room marker. If I remove the surrounding room marker, it works 100% of the time. It could be that there's something unusual with the nifs I'm using or perhaps the creation kit is making room markers semi-broken some how, but both of those seem quite unlikely. I've experimented around with whether the placeAtMe is placing a persistent reference or not, whether it's placing it disabled or enabled, whether I use a setScale on it, and an enableNoWait - all show the same results when the reference is placed in a room marker, so I don't believe they have any bearing on the issue. The reason why I'm not posting code etc is partly because the script is over 300 lines long (containing many functions) but also because I very much doubt there's a problem with it - as what I'm seeing is actually impossible to purposely make happen with scripting, so must lie in a problem with the engine.

Cheers - dafydd99

Link to comment
Share on other sites

  • Recently Browsing   0 members

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