ObjectReferencefunctionFindClosestReferenceOfTypeFromRef(FormarBaseObject, ObjectReferencearCenter, floatafRadius)Global
Description
Wiki Description
Finds the closest ObjectReference of the given type from the location of the target ObjectReference and within the given radius.
Documentation Comment
Finds the closest reference of a given base object within a given radius of a reference
Caveats
CK Wiki - Notes
- If the ObjectReference arCenter is of the same type as arBaseObject, this function will return arCenter. That is to say that this function does not exclude arCenter from it's search.
Parameters
Examples
; Find the closest diamond reference to the player, limiting the search to 5 units
ObjectReference closestDiamond = Game.FindClosestReferenceOfTypeFromRef(Diamond, Game.GetPlayer(), 5.0)scriptName OpenShackDoorScript extends ActiveMagicEffect
{Script for a Self Spell that opens the nearest Whiterun shack door}
import game
Door property WRShackDoor01 auto ; Switching to Door because Form properties are not auto-filled?
;======================================================================================;
; VARIABLES /
;=============/
objectReference CastFromHereRef
ObjectReference closestDoor
float RadiusToFindDoor = 1000.0
;======================================================================================;
; EVENTS /
;=============/
Event OnEffectStart(Actor Target, Actor Caster)
CastFromHereRef = Caster
closestDoor = Game.FindClosestReferenceOfTypeFromRef(WRShackDoor01, CastFromHereRef, RadiusToFindDoor )
if ( closestDoor == None)
Debug.Notification("There is no shack door near!")
else
if( closestDoor.isLocked() )
Debug.Notification("Opening door!")
closestDoor.Lock(false)
else
Debug.Notification("The door is not locked!")
endif
endif
EndEventAuto-Generated Example
Form myForm__arBaseObject
ObjectReference myObjectReference__arCenter
float myFloat__afRadius
ObjectReference returnedValue = Game.FindClosestReferenceOfTypeFromRef(myForm__arBaseObject, myObjectReference__arCenter, myFloat__afRadius)Related Pages
- Game
- Game.FindClosestReferenceOfAnyTypeInList(...)
- Game.FindClosestReferenceOfAnyTypeInListFromRef(...)
- Game.FindClosestReferenceOfType(...)
- Game.FindRandomReferenceOfAnyTypeInList(...)
- Game.FindRandomReferenceOfAnyTypeInListFromRef(...)
- Game.FindRandomReferenceOfType(...)
- Game.FindRandomReferenceOfTypeFromRef(...)
