IsInSameCurrentLocAsRef

From the CreationKit Wiki
Jump to navigation Jump to search

Description[edit | edit source]

IsInSameCurrentLocAsRef returns 1 if the two refs' current locations are the same location, or their current locations have a parent location matching the (optional) keyword.

The keyword is used to essentially define which "level" of location to test. For example, if two actors' current locations are each a different interior (their houses), and each of the their houses are attached to locations that have the same parent location (a town), then passing a keyword associated with that parent location (example: LocTypeTown), it will return true.

Not passing the keyword tests against the immediate location of the cell each reference is currently in (in other words, doesn't care if they share any of same parent locations).

Usually you will be supplying a keyword that helps define the "range" of the location you are looking at, above the particular immediate location the reference is placed. For example, are these two references in the same dungeon, or town, or Hold, rather than are these two reference in the same house, or room.

When used to fill a Reference Alias[edit | edit source]

When you use IsInSameCurrentLocAsRef to fill a Reference Alias, be aware that a reference's current actual location as well as its persistence location, if it has one, will be considered.

For example, if an Actor is currently in Markarth but has a persistence location of WhiterunLocation, then IsInSameCurrentLocAsRef PlayerRef LocTypeHabitation will match the Actor when the player is in either Markarth or Whiterun.

When used to fill a Location Alias[edit | edit source]

When you use IsInSameCurrentLocAsRef to fill a Location Alias, the game will first find the parent location of OtherRef that has the specified keyword. It will then select a Location at random within that parent Location, regardless of whether OtherRef is currently in the selected Location. To emphasize, OtherRef might not be in the selected Location or one of its children at all.

For example, if you fill an alias using IsInSameCurrentLocAsRef PlayerRef LocTypeHold while the player is standing in Candlehearth Hall in Eastmarch, this will select a location within Eastmarch hold, but it will not necessarily select the hold itself. It may even select a Location that has no other parent Location in common with the player other than Eastmarch hold. It could select a Location in Darkwater Crossing or in Kynesgrove, even though the player is standing in Windhelm. Using this example, if you want to force selection of the player's current hold, you must also use LocationHasKeyword as one of the conditions on the Location Alias.

Syntax[edit | edit source]

[ObjectREF.]IsInSameCurrentLocAsRef OtherRef LocationKeyword

Examples[edit | edit source]

player.IsInSameCurrentLocAsRef AlvorRef     ; returns true if both the player and AlvorRef are currently each in a cell in the same location
player.IsInSameCurrentLocAsRef AlvorRef LocTypeCity     ; returns true if both the player and AlvorRef are each currently in a cell in locations that have the keyword LocTypeCioty, or if any of the parents of their locations have that keyword.

See Also[edit | edit source]

Papyrus Version[edit | edit source]

GetCurrentLocation - ObjectReference
HasCommonParent - Location