ObjectReferencefunctionFindRandomReferenceOfAnyTypeInListFromRef(FormListarBaseObjects, ObjectReferencearCenter, floatafRadius)Global
Description
Wiki Description
Finds a random ObjectReference of any of the types in the list from the given ObjectReference location and within the given radius.
Documentation Comment
Finds a random reference of a given base object within a given radius of a reference
Caveats
Parameters
floatafRadius
CK Wiki Description
Maximum distance from center to look for a ObjectReference. The unit of this parameter is comparatively much shorter than the radius of a cloak spell or the feet parameter given to "target actor" and "target location" spells. Try starting with a value of 400.
Examples
import debug
FormList property lookForItems auto ; roughly 1500 entries (all enchanted armors)
float distance = 2560.0 ; slightly longer than the carpet in The Great Porch of Dragonsreach
int len = lookForItems.getSize()
bool looking = true
ObjectReference item
ObjectReference p = game.getPlayer() as ObjectReference
while i < len && looking
item = Game.FindRandomReferenceOfAnyTypeInListFromRef(lookForItems, p, distance)
if item
looking = false
endif
if i % 60 == 0
trace(" iteration: " + i + " / " + len)
endif
i += 1
endWhile
if item
item.moveto(p)
trace("got item: " + item)
else
trace("no items found. list: " +lookForItems+ ", list entries: " + len)
endifAuto-Generated Example
FormList myFormList__arBaseObjects
ObjectReference myObjectReference__arCenter
float myFloat__afRadius
ObjectReference returnedValue = Game.FindRandomReferenceOfAnyTypeInListFromRef(myFormList__arBaseObjects, myObjectReference__arCenter, myFloat__afRadius)Related Pages
- Game
- Game.FindClosestReferenceOfAnyTypeInList(...)
- Game.FindClosestReferenceOfAnyTypeInListFromRef(...)
- Game.FindClosestReferenceOfType(...)
- Game.FindClosestReferenceOfTypeFromRef(...)
- Game.FindRandomReferenceOfAnyTypeInList(...)
- Game.FindRandomReferenceOfType(...)
- Game.FindRandomReferenceOfTypeFromRef(...)
- Unit
