share/hedgewars/Data/Scripts/Multiplayer/Tunnels.lua
author alfadur
Tue, 16 Apr 2019 00:07:15 +0300
changeset 14828 b2beb784e4b5
parent 14571 8b66de6c9fb0
permissions -rw-r--r--
add support for multiple ping probes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13215
bc95df84395f Clear drawn maps in TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 11065
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Utils.lua")
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     2
10153
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     3
function onPreviewInit()
13215
bc95df84395f Clear drawn maps in TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 11065
diff changeset
     4
    onGameInit()
10153
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     5
end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     6
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     7
function onGameInit()
10423
b9d6463cf2ca fix mapgen of other scripts too
sheepluva
parents: 10153
diff changeset
     8
    MapGen = mgDrawn
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     9
    TemplateFilter = 0
14571
8b66de6c9fb0 Restore map scaling of Tunnels script
Wuzzy <Wuzzy2@mail.ru>
parents: 13215
diff changeset
    10
    local mapComplexity = MapFeatureSize
8b66de6c9fb0 Restore map scaling of Tunnels script
Wuzzy <Wuzzy2@mail.ru>
parents: 13215
diff changeset
    11
    -- reset feature size after use, to disable scaling
8b66de6c9fb0 Restore map scaling of Tunnels script
Wuzzy <Wuzzy2@mail.ru>
parents: 13215
diff changeset
    12
    MapFeatureSize = 12
13215
bc95df84395f Clear drawn maps in TechRacer
Wuzzy <Wuzzy2@mail.ru>
parents: 11065
diff changeset
    13
    fillMap(false)
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    14
    side = 0
14571
8b66de6c9fb0 Restore map scaling of Tunnels script
Wuzzy <Wuzzy2@mail.ru>
parents: 13215
diff changeset
    15
    for i = 0,1+mapComplexity*2 do
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    16
        if side > 3 then 
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    17
            size = GetRandom(4)+4
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    18
        else
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    19
            size = GetRandom(12)+4
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    20
        end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    21
        --side = GetRandom(4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    22
        dx = div(size,4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    23
        maxshift = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    24
        dy = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    25
        if side == 0 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    26
            x = 0
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    27
            y = GetRandom(2048-size*4)+size*2
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    28
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    29
        elseif side == 1 then
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    30
            x = GetRandom(4096-size*4)+size*2
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    31
            y = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    32
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    33
        elseif side == 2 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    34
            x = 4096
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    35
            y = GetRandom(2048-size*4)+size*2
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    36
            dx = -dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    37
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    38
        elseif side == 3 then
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    39
            x = GetRandom(4096-size*4)+size*2
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    40
            y = 2048
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    41
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    42
            dy = -dy
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    43
        elseif side > 3 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    44
            x = GetRandom(2500)+500
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    45
            y = GetRandom(1250)+250
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    46
            dx = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    47
            dy = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    48
        end
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    49
        length = GetRandom(500-size*25)+600
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    50
        while (length > 0) and (x > -300) and (y > -300) and (x < 4400) and (y < 2400) do
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    51
            length = length - 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    52
            AddPoint(x,y,size,true)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    53
            x = x + dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    54
            y = y + dy
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    55
            if GetRandom(8) == 0 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    56
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    57
                if (shift > 0) and (dx < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    58
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    59
                elseif (shift < 0) and (dx > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    60
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    61
                end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    62
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    63
                if (shift > 0) and (dy < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    64
                    dy = dy + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    65
                elseif (shift < 0) and (dy > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    66
                    dy = dy + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    67
                end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    68
            end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    69
        end
7791
b937274608ba Completely arbitrary tweaking of tunnel values (avoids a nil) - still needs smooth curves (probably a target dx/dy to aim for, and slow alterations) and taking less CPU. Also disable unused function in Highlander
nemo
parents: 7785
diff changeset
    70
        if side < 6 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    71
            side = side + 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    72
        else 
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    73
            side = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    74
        end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    75
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    76
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    77
    FlushPoints()
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    78
end