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

  • 4 weeks later...

If anyone would like to investigate or demonstrate this 'bug' I seem to have found in placeatme (and potentially discover a way to avoid it), I've written a simple mod that can demonstrate it:

https://www.dafutils.com/mods/PlaceAtMeTEST.zip

Just a small .esp, a .pex and the .psc as below...

Scriptname PlaceAtMeTestScript extends ObjectReference  

static property myStatic auto
static property XMarker auto

event onActivate(ObjectReference actronaut)
	ObjectReference ourMarker=self.placeAtMe(XMarker)
	int count=50
	while(count)
		count-=1
		ourMarker.moveTo(self, 0, 0, 64+(count*10), true)
		ourMarker.placeAtMe(myStatic)
	endwhile
endevent

To test, install the files in your data folder, add it to your load order via the creations menu in game, and when playing go to the console and type...

coc TESTPlaceAtMe

You should appear in a small lit room with 16 levers in front of you. Maybe do a quicksave so you can test it multiple times.

Pulling each of them will create a pile of 50 static nordic pots floating in the air above each lever. When you've done all 16 go back to the console and type...

tcl

to turn off clipping. Then back out of the room through the wall. At the point at which you leave the roombound, which surrounds the room, you should see the room, lighting and the pots disappear. If you see any remaining pots, they haven't been correctly applied to the roombound, and will only appear when outside. Currently I'm seeing around 1 in 300 seem to fall in this category. Oddly I've actually started seeing some which can be seen both inside and outside the roombound, which I didn't think was possible. I *think* the faster you pull the levers makes it more likely to happen but that doesn't always seem to be the case.

If you make a save whilst seeing this problem and load it, the problem appears to be corrected.

Do please let me know if you don't find any problems - could be somehow this is just my problem, and my gamefiles (or maybe graphics driver) are corrupted! Testing on a GTX 1660 super.

Cheers - dafyd99

Link to comment
Share on other sites

  • Recently Browsing   0 members

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