Talk:IsInInterior - ObjectReference

Revision as of 10:06, 27 November 2016 by imported>Lisselli (On making this function faster.)

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

This function is much slower than its counterpart IsInterior - Cell. It is basically a convenience function. Both of the above functions takes about 65ms to finish, it calls GetParentCell and InInterior in addition to IsInterior. You should store the myObject.GetParentCell() to a variable first and then pass it the function. You can reduce them to 31 frames by doing this instead(Using the second function as an example):

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

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

	return false
EndFunction

This will return false when in an exterior, or if GetParentCell returns none due to the issue with IsInterior. --Lisselli (talk)

Return to "IsInInterior - ObjectReference" page.