share/hedgewars/Data/Scripts/Multiplayer/DiagonalMaze.lua
changeset 14479 99117df5a3d3
parent 11064 884f40b6f640
equal deleted inserted replaced
14478:98ef2913ec73 14479:99117df5a3d3
       
     1 HedgewarsScriptLoad("/Scripts/Params.lua")
       
     2 local overrideFeatureSize = true
       
     3 local mazeScale = 0
     1 
     4 
     2 function onPreviewInit()
     5 function onPreviewInit()
     3 onGameInit()
     6 onGameInit()
     4 end
     7 end
     5 
     8 
       
     9 function onParameters()
       
    10     parseParams()
       
    11     if params["scalemap"] ~= nil then 
       
    12         overrideFeatureSize = false 
       
    13     end
       
    14     if params["mazescale"] ~= nil then
       
    15         mazeScale = tonumber(params["mazescale"])
       
    16     end
       
    17 end
       
    18 
       
    19 
     6 function onGameInit()
    20 function onGameInit()
       
    21     local step
       
    22     local width 
       
    23 
     7     MapGen = mgDrawn
    24     MapGen = mgDrawn
     8     TemplateFilter = 0
    25     TemplateFilter = 0
     9     local step = 80 + 10 * MapFeatureSize
    26 
    10     local width = 1 + div(math.max(0, MapFeatureSize-12), 6)
    27     if mazeScale > 0 then
       
    28         step = 80 + 10 * mazeScale
       
    29         width = 1 + div(math.max(0, mazeScale-12), 6)
       
    30     else
       
    31         step = 80 + 10 * MapFeatureSize
       
    32         width = 1 + div(math.max(0, MapFeatureSize-12), 6)
       
    33     end
       
    34     -- reset feature size after use, to disable scaling
       
    35     if overrideFeatureSize then MapFeatureSize = 12 end
    11     -- center maze
    36     -- center maze
    12     local xoff = div((4000 % step), 2)
    37     local xoff = div((4000 % step), 2)
    13     for y = 48,2048,step do
    38     for y = 48,2048,step do
    14        for x = 48+xoff,4048-step,step do
    39        for x = 48+xoff,4048-step,step do
    15             if GetRandom(2) == 0 then
    40             if GetRandom(2) == 0 then