share/hedgewars/Data/Scripts/Multiplayer/DiagonalMaze.lua
author Wuzzy <Wuzzy2@mail.ru>
Mon, 13 May 2019 21:26:13 +0200
changeset 14950 f112847eb93e
parent 14479 99117df5a3d3
permissions -rw-r--r--
Space Invasion: Remove incorrect gstWinner
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14479
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Params.lua")
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
     2
local overrideFeatureSize = true
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
     3
local mazeScale = 0
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     4
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     5
function onPreviewInit()
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     6
onGameInit()
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     7
end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
     8
14479
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
     9
function onParameters()
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    10
    parseParams()
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    11
    if params["scalemap"] ~= nil then 
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    12
        overrideFeatureSize = false 
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    13
    end
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    14
    if params["mazescale"] ~= nil then
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    15
        mazeScale = tonumber(params["mazescale"])
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    16
    end
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    17
end
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    18
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    19
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    20
function onGameInit()
14479
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    21
    local step
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    22
    local width 
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    23
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    24
    MapGen = mgDrawn
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    25
    TemplateFilter = 0
14479
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    26
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    27
    if mazeScale > 0 then
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    28
        step = 80 + 10 * mazeScale
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    29
        width = 1 + div(math.max(0, mazeScale-12), 6)
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    30
    else
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    31
        step = 80 + 10 * MapFeatureSize
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    32
        width = 1 + div(math.max(0, MapFeatureSize-12), 6)
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    33
    end
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    34
    -- reset feature size after use, to disable scaling
99117df5a3d3 fix DiagonalMaze after the drawing scaling change, add some params since ginormous maze is kinda entertaining
nemo
parents: 11064
diff changeset
    35
    if overrideFeatureSize then MapFeatureSize = 12 end
11064
884f40b6f640 some more tweaks
sheepluva
parents: 11063
diff changeset
    36
    -- center maze
884f40b6f640 some more tweaks
sheepluva
parents: 11063
diff changeset
    37
    local xoff = div((4000 % step), 2)
11063
c57f815cbb14 make diagonal maze use map feature size
sheepluva
parents: 10611
diff changeset
    38
    for y = 48,2048,step do
11064
884f40b6f640 some more tweaks
sheepluva
parents: 11063
diff changeset
    39
       for x = 48+xoff,4048-step,step do
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    40
            if GetRandom(2) == 0 then
11064
884f40b6f640 some more tweaks
sheepluva
parents: 11063
diff changeset
    41
                AddPoint(x,y,width)
11063
c57f815cbb14 make diagonal maze use map feature size
sheepluva
parents: 10611
diff changeset
    42
                AddPoint(x+step,y+step)
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    43
            else
11064
884f40b6f640 some more tweaks
sheepluva
parents: 11063
diff changeset
    44
                AddPoint(x,y+step,width)
11063
c57f815cbb14 make diagonal maze use map feature size
sheepluva
parents: 10611
diff changeset
    45
                AddPoint(x+step,y)
10604
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    46
            end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    47
        end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    48
    end
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    49
    FlushPoints()
f2f9928ea2e7 Sheepluva thought this was worth adding.
nemo
parents:
diff changeset
    50
end