Difference between revisions of "FindRandomReferenceOfAnyTypeInListFromRef - Game"

Removed confusing return function from syntax, as other functions on this wiki do not follow that format.
imported>Tox2ik
imported>Chesko
(Removed confusing return function from syntax, as other functions on this wiki do not follow that format.)
 
(6 intermediate revisions by 2 users not shown)
Line 7: Line 7:
== Syntax ==
== Syntax ==
<source lang="papyrus">
<source lang="papyrus">
ObjectReference Function FindRandomReferenceOfAnyTypeInListFromRef(FormList arBaseObjectsA, ObjectReference arCenter, \
ObjectReference Function FindRandomReferenceOfAnyTypeInListFromRef(FormList arBaseObjects, ObjectReference arCenter, float afRadius) global
  float afRadius) global
</source>
</source>


== Parameters ==
== Parameters ==
*arBaseObjectsA: The list of valid base objects to look for
*arBaseObjectsA: The list of valid base objects to look for
*arCenter: The [[ObjectReference Script|reference]] to use as a center of the search
*arCenter: The [[ObjectReference Script|reference]] to use as a center of the search.
*afRadius: Maximum distance from center to look for a [[ObjectReference Script|reference]]
*afRadius: Maximum distance from center to look for a [[ObjectReference Script|reference]]. 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.


== Return Value ==
== Return Value ==
Line 22: Line 21:
<source lang="papyrus">
<source lang="papyrus">
import debug
import debug
FormList property AllEnchantedArmors auto ; roughly 1500 entries
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
float distance = 2560.0          ; slightly longer than the carpet in The Great Porch of Dragonsreach
int len = lookForItems.getSize()
int len = lookForItems.getSize()
Line 48: Line 47:
trace("no items found. list: " +lookForItems+ ", list entries: " + len)
trace("no items found. list: " +lookForItems+ ", list entries: " + len)
endif
endif
</source>


 
This example will look any enchanted armor that the lookForItems FormList has been filled with (in the CK).
</source>
While the search distance and the length of the form list look ominously big, this example should find an
item within a second if the player is within the specified distance of a qualifying item.  The reason for
iterating so many times is not really well founded, but it follows the example in critterBird.psc.


== See Also ==
== See Also ==
Line 61: Line 63:
*[[FindRandomReferenceOfType - Game]]
*[[FindRandomReferenceOfType - Game]]
*[[FindRandomReferenceOfTypeFromRef - Game]]
*[[FindRandomReferenceOfTypeFromRef - Game]]
*[[Unit]]
Anonymous user