Skip to content

Commit

Permalink
DiD S04 Todo: Add snow
Browse files Browse the repository at this point in the history
Lifted code from HttT to add snow coverage.
  • Loading branch information
GregoryLundberg committed Nov 30, 2017
1 parent 4e75618 commit 442284d
Showing 1 changed file with 47 additions and 1 deletion.
Expand Up @@ -133,7 +133,53 @@
[/gold_carryover]
[/objectives]

# TODO: manually add snow detritus
[lua]
code=<<
-- For prime-time use the filter terrain needs to come in and the convert
-- table needs to be VERY complete. Or, rename this to morph_terrain and
-- have the conversion table come in as an argument, too.

local locations = wesnoth.get_locations{terrain = 'Ce,Chr,Co,Gg,Gg^Efm,Gg^Vc,Gg^Vo,Gs^Fds,Gs^Fms,Gs^Fmw,Gs^Fp,Hh,Hh^Vhh,Hh^Vo,Ke,Khr,Ko,Mm,Mm^Xm'}

local coverage = 0.15
-- Constant 15% random coverage.
-- Valid range is (0.0 .. 1.0)
-- Do not raise too high or player may not be able to make it in the time allotted.

local snowNeeded = (#locations * coverage)

local convert = {
['Ce'] = 'Cea',
['Chr'] = 'Cha',
['Co'] = 'Coa',
['Gg'] = 'Aa',
['Gg^Efm'] = 'Aa',
['Gg^Vc'] = 'Aa^Vca',
['Gg^Vo'] = 'Aa^Voa',
['Gs^Fds'] = 'Aa^Fda',
['Gs^Fms'] = 'Aa^Fma',
['Gs^Fmw'] = 'Aa^Fma',
['Gs^Fp'] = 'Aa^Fpa',
['Hh'] = 'Ha',
['Hh^Vhh'] = 'Ha^Vha',
['Hh^Vo'] = 'Ha^Voa',
['Ke'] = 'Kea',
['Khr'] = 'Kha',
['Ko'] = 'Koa',
['Mm'] = 'Ms',
['Mm^Xm'] = 'Ms^Xm'
}

local loopCounter
for loopCounter = 1, snowNeeded do
local locationsIndex = wesnoth.random(#locations)
local coordinate = locations[locationsIndex]
local terrainCode = wesnoth.get_terrain(coordinate[1], coordinate[2])
wesnoth.set_terrain(coordinate[1], coordinate[2], (convert[terrainCode] or terrainCode))
table.remove(locations, locationsIndex)
end
>>
[/lua]

[recall]
id=Darken Volk
Expand Down

0 comments on commit 442284d

Please sign in to comment.