Jump to content

Location akNewLoc and cells with no name


Recommended Posts

Hi all,

I made a script that changes my follower outfit for specific locations and it works.

The way I did it was to create a few string[] property array with the location names I want to be assigned for a specific outfit.

The problem I have now I want my follower to put the azmut suit when in a Glowing sea cell, but a lot of the glowing sea cells don't have names assigned to them, only EditorID's. Since the Location akNewLoc works only with location names (If I'm not mistaking) how can I detect a change location to a Glowing sea cell?

I hope I'm clear enough, if not let me know.

Link to comment
Share on other sites

1 hour ago, F4llfield said:

Since the Location akNewLoc works only with location names (If I'm not mistaking) how can I detect a change location to a Glowing sea cell?

Actor Cell change event is not exposed to vanilla Papyrus, only OnLocationChange.

You can either use this (vanilla) implementation or a custom script extender if multiple dependency isn't an issue (now that BGS releases updates which break them it is probably better to rely on vanilla if possible).

There are other vanilla methods but similarly the one I linked, they also store the previous targetRef.GetParentCell() then compare it to the new (current) one.

  • Like 1
Link to comment
Share on other sites

Yes but be aware that will conflict/trash (depending on load order) with ANYTHING else that touches that area to add persistent references or workshops and such.

You could do it unobtrusively with XY coordinate range test, the Glowing Sea is all -X and -Y South-West e.g.

Float fPosX = thisActor.GetPositionX()
Float fPosY = thisActor.GetPositionY()

If(ftargetPosX <= GlowingSeaNorthBoundary) && (ftargetPosY <= GlowingSeaEastBoundary)

; doglowingseastuff

Endif

 

  • Like 1
Link to comment
Share on other sites

10 hours ago, F4llfield said:

Is it possible to create a new location, for example called Glowing sea which will have all the cells of the glowing sea not assigned to a location ?

 

Here's a quick and simple way to determine whether the player has changed their parent cell.

I can think of better approaches of course but as I said it's quick and simple. 🙂 

Int[] Property CellIDs Auto				; holds the FormIDs of the Cells in the Glowing Sea
Int Property previousPlayerCellID Auto		; holds the FormID of the Cell the player was in previously


Event OnQuestInit()
	Int CellIDCount = BuildCellIDArray()
	Debug.MessageBox("Built CellID array, its size = " + CellIDCount)
	StartTimer(10, 555)		; start timer, 10 real time seconds
EndEvent

Int Function BuildCellIDArray()
	CellIDs = new Cell[0]	; initialize the array
	CellIDs.Add(0x123)		; some Cell in the Glowing Sea
	CellIDs.Add(0x234)		; another Cell in the Glowing Sea
	CellIDs.Add(0x345)		; and another Cell in the Glowing Sea
	Return CellIDs.Length
EndFunction

Event OnTimer(int aiTimerID)
	If aiTimerID == 555
		Int currentPlayerCellID = Game.GetPlayer().GetParentCell().GetFormID()
		If CellIDs.Find(currentPlayerCellID) >= 0			; Player is in one of Cells at the Glowing Sea
			If currentPlayerCellID == previousPlayerCell		; player is in the same cell as they were in 10 seconds ago

			Else			; player is in another cell

			EndIf
		Else			; player is not at the Glowing Sea

		EndIf
		previousPlayerCell = currentPlayerCellID	; store the most recent cell
		StartTimer(10, 555)
	EndIf
EndEvent

 

Link to comment
Share on other sites

Good point:

A simple 30 second timer would allow a max distance travelled of 15k gameunits (500 unit/second sprint) but is a constant overhead.

Dropping an invisible activator with an attached script which OnUnload move to player & check XYZ would be more elegant for the same 15K game unit movement delta if the player has not monkeyed with uGridsToLoad.

Most of my constant movement based solutions drop an xmarker and register for OnDistanceGreaterThan 4k to 5k game units then move to player & check XYZ.

 

 

Link to comment
Share on other sites

My suggestion:

Event/Function ToInitilaize()
	RegisterForDistanceGreaterThanEvent(Center, NPC, X)
	RegisterForDistanceLessThanEvent(Center, NPC, X)
endEvent/Function

Event OnDistanceLessThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	RegisterForDistanceGreaterThanEvent(Center, NPC, X)
	;Equip hazmat
endEvent

Event OnDistanceGreaterThan(ObjectReference akObj1, ObjectReference akObj2, float afDistance)
	RegisterForDistanceLessThanEvent(Center, NPC, X)
	;Unequip hazmat
endEvent

PS: RegisterForDistanceX registers to receive a single OnDistanceX event, so that you need to register again each time a distance event is received.

9k18nu.jpg

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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