Talk:IsInInterior - ObjectReference

From the CreationKit Wiki
Revision as of 08:53, 2 January 2016 by imported>Terra Nova2 (→‎IsInInteriorActual - ObjectReference: added an array version.)
Jump to navigation Jump to search

IsInInteriorActual - ObjectReference

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
  • EldergleamSancturaryWorld
  • 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

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