Added a new SCATTER_EMBELLISHMENTS...

...macro which can be used, unsurprisingly, to randomly scatter embellishments.
This commit is contained in:
Lari Nieminen 2010-09-09 19:07:11 +00:00
parent 110c6dd581
commit 70a58cdf9c

View file

@ -69,3 +69,46 @@
{CLEAR_VARIABLE random_subscript}
{CLEAR_VARIABLE random_placement_locations}
#enddef
#define SCATTER_EMBELLISHMENTS TERRAIN EMBELLISHMENT PERCENTAGE
# Adds the given embellishment to the given percentage of the given terrain
# on the map.
#
# For example, this will add flowers to 5% of all grassland:
#! {SCATTER_EMBELLISHMENTS G* ^Efm 5}
[store_locations]
terrain={TERRAIN}
variable=terrain_variation_locations
[/store_locations]
{VARIABLE terrain_variations_to_place {PERCENTAGE}}
# TODO: change back to 100.0 once it no longer causes a crash
{VARIABLE_OP terrain_variations_to_place divide 100.001}
{VARIABLE_OP terrain_variations_to_place multiply $terrain_variation_locations.length}
{VARIABLE_OP terrain_variations_to_place round ceil}
[while]
[variable]
name=terrain_variations_to_place
greater_than=0
[/variable]
[do]
{VARIABLE_OP terrain_variation_i rand "0..$($terrain_variation_locations.length - 1)"}
[terrain]
x,y=$terrain_variation_locations[$terrain_variation_i].x,$terrain_variation_locations[$terrain_variation_i].y
terrain={EMBELLISHMENT}
layer=overlay
[/terrain]
{VARIABLE_OP terrain_variations_to_place sub 1}
{CLEAR_VARIABLE terrain_variation_locations[$terrain_variation_i]}
[/do]
[/while]
{CLEAR_VARIABLE terrain_variation_locations,terrain_variations_to_place,terrain_variation_i}
#enddef