Talk:IsInInterior - ObjectReference

From the CreationKit Wiki
Jump to navigation Jump to search

IsInInteriorActual - ObjectReference[edit source]

This function is created by Chesko, the author of Frostfall. I will copy/paste his instructions for this function here.




Hey everyone. So, if you haven't noticed by now, the IsInInterior() function can "lie" to you. Not in the strictest sense; it always lets you know if an area is technically an interior or not. The problem is that the designers at Bethesda occasionally use Exterior worldspaces that look, function, and for all practical purposes are, an interior. So, another method is required if you want to know if your ObjectReference is in a "functional" interior or not.

First, create a new FormList, which we are calling WorldspacesInteriors. Add the following Worldspace objects to the FormList:


  • AlftandWorld
  • Blackreach
  • BlindCliffCaveWorld
  • BloatedMansGrottoWorld
  • BluePalaceWingWorld
  • BrinewaterGrottoWorld
  • DarkwaterWorld
  • DeepwoodRedoubtWorld
  • EastEmpireWarehouse
  • EldergleamSanctuaryWorld
  • FallowstoneCaveWorldStart
  • FrostmereCryptWorld
  • KatariahWorld
  • LabyrinthianWorld
  • LabyrinthianWorld03
  • LabyrinthianWorld04
  • MossMotherCavernWorld
  • RedEagleRedoubtWorld
  • ShadowgreenCavernWorld
  • SouthfringeWorld

Those are all of the worldspaces that I've identified from Skyrim.esm that look and act like interiors, even though their cells are classified as exterior. (If I missed one, let me know and I'll add it to the list!)

If you are using Dawnguard.esm as well with your mod, add the following as well:

  • DLC1AncestorsGladeWorld
  • DLC1DarkfallPassageWorld
  • DLC1ForebearsHoldout

(These could also be added to your FormList at runtime masterlessly, but that's beyond the scope of this tutorial)

Next, implement the following function in a script of your choice that needs this function:

FormList property WorldspacesInterior auto


bool function IsInInteriorActual(ObjectReference akObjectReference)
    if akObjectReference.IsInInterior()
	    return true
	else
        if WorldspacesInterior.HasForm(akObjectReference.GetWorldSpace())
			return true
		else
			return false
		endif
	endif
endFunction

Calling this function instead should reveal whether or not your ObjectReference is in an interior, even an exterior behaving like an interior.

IsInteriorAWorldSpace - ObjectReference[edit source]

Inspired by the above, I made an array version. Same steps apply, just different method.


WorldSpace[] property WorldSpaces auto
; Fill this property with the world spaces above.

Bool Function IsInteriorAWorldSpace(ObjectReference akObjectReference) 
Int i = 0
Int iIndex = WorldSpaces.Length

	if akObjectReference.IsInInterior()
	
		return true
	else
		While i < iIndex
			if akObjectReference.GetWorldSpace() == WorldSpaces[i]
			
				return true
			else
				i += 1
			endif
			
			
		EndWhile
	endif

	return false
EndFunction

Another way[edit source]

I think this can be trimmed down even further and not require while loops, arrays, and formlists. You're most definitely not in an interior cell if you're in any world space, but to keep you from having to check for DLC worldspaces, you can probably just check against whether or not you're in the Tamriel Worldspace. Don't call this on references that are in a cell that is not loaded:

Worldspace property Tamriel auto

Bool Function isWorldSpaceInterior(ObjectReference akRef)
	if akRef.GetParentCell().IsInterior() == false
		if akRef.GetWorldSpace() != Tamriel
			return true
		endif
		return false
	endif
	return false
EndFunction

--Rasikko (talk) 2021-10-16T09:27:15 (EDT)