selectBestPlaces: Difference between revisions
Jump to navigation
Jump to search
m (Add notedate for Rube's note.) |
(Add note with tow expressions and three simple expressions for selectBestPlaces.) |
||
Line 40: | Line 40: | ||
Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as usefull as retrieving multiple (and already sorted) positions.<br> | Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as usefull as retrieving multiple (and already sorted) positions.<br> | ||
Also do not underestimate the keywords ''night, rain'' or ''windy'', for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost. (this, btw., is how animals "choose" where and when to spawn) | Also do not underestimate the keywords ''night, rain'' or ''windy'', for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost. (this, btw., is how animals "choose" where and when to spawn) | ||
<dd class="notedate">Posted on Apr 3, 2014 - 16:10 | |||
<dt class="note">'''[[User:ffur2007slx2_5|ffur2007slx2_5]]'''<dd class="note"> | |||
In ArmA3 ver 1.14 Two new expressions are available: '''waterDepth'''(0-1) and '''camDepth'''(0-1), along with three simple operators: interpolate, randomGen and factor that can be used together with expressions. E.g. | |||
<code> | |||
p = selectBestPlaces [ | |||
position player, | |||
500, | |||
"(2 * (waterDepth interpolate [1,16,0,1]) * ((0.1+houses factor [0.1,0.8]) * (randomGen 1 + houses)))", | |||
1, | |||
1]; | |||
</code> | |||
'''A'''lgorithm randomGen: | |||
<code> | |||
randomGen A(number): randomly generate a float number from 0 - A | |||
</code> | |||
'''A'''lgorithm factor: | |||
<code> | |||
A(number) factor [p,q] = | |||
p< A <q: [(A -p)/(q-p)] | |||
</code> | |||
'''A'''lgorithm interpolate: | |||
<code> | |||
A(number) interpolate [p,q,r,s] = | |||
A <=p:r | |||
A >=q:s | |||
p< A <q: [(A -p)/(q-p)]*(s-r) +r | |||
</code> | |||
<!-- Note Section END --> | <!-- Note Section END --> | ||
</dl> | </dl> |
Revision as of 09:12, 3 April 2014
Description
- Description:
- Find the places with the maximum value of _expression in the given area. Places can be on water.
- Groups:
- Uncategorised
Syntax
- Syntax:
- selectBestPlaces [_position, _radius, _expression, _precision, _sourcesCount]
- Parameters:
- [_position, _radius, _expression, _precision, _sourcesCount]: Array -
- Return Value:
- Array - Format is [[position: Position2D, expressionResult: Number], ...]
Examples
- Example 1:
myPlaces = selectBestPlaces [position player, 50, "meadow + 2*hills", 1, 5]
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
- Posted on Jul 17, 2010 - 18:39
- Rübe
- see http://forums.bistudio.com/showthread.php?t=93897 for some more information (though neither official, nor complete). The most important information is the list of useable keywords for the expression which is: forest, trees, meadow, hills, houses, sea, night, rain, windy and deadBody. The keyword will be replaced by the actual value at the given sample position and thus the expression gets evaluated. For example the following expression (which returns high values in forest) "forest + trees - meadow - houses - (10 * sea)" might be transformed to 0 + 0.1 - 0.7 - 0 - (10 * 0) which is - with it's result of -0.6 - not in the forest, though there are some tree(s) around. You get the idea.
Also note that you may aswell check such an expression value at a single position by passing a low radius and a sourceCount of 1, which is often just as usefull as retrieving multiple (and already sorted) positions.
Also do not underestimate the keywords night, rain or windy, for if you couple them with the other keywords, you can easily get a highly dynamic system at a very low cost. (this, btw., is how animals "choose" where and when to spawn) - Posted on Apr 3, 2014 - 16:10
- ffur2007slx2_5
-
In ArmA3 ver 1.14 Two new expressions are available: waterDepth(0-1) and camDepth(0-1), along with three simple operators: interpolate, randomGen and factor that can be used together with expressions. E.g.
p = selectBestPlaces [ position player, 500, "(2 * (waterDepth interpolate [1,16,0,1]) * ((0.1+houses factor [0.1,0.8]) * (randomGen 1 + houses)))", 1, 1];
Algorithm randomGen:randomGen A(number): randomly generate a float number from 0 - A
Algorithm factor:A(number) factor [p,q] = p< A <q: [(A -p)/(q-p)]
Algorithm interpolate:A(number) interpolate [p,q,r,s] = A <=p:r A >=q:s p< A <q: [(A -p)/(q-p)]*(s-r) +r