share/hedgewars/Data/Scripts/Multiplayer/Tunnels.lua
author sheepluva
Sat, 30 Apr 2016 21:06:46 +0200
changeset 11787 8873546a893c
parent 11065 dce587dfed4f
child 13220 bc95df84395f
permissions -rw-r--r--
update changelog
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     1
10153
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     2
function onPreviewInit()
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     3
onGameInit()
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     4
end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     6
function onGameInit()
10423
b9d6463cf2ca fix mapgen of other scripts too
sheepluva
parents: 10153
diff changeset
     7
    MapGen = mgDrawn
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     8
    TemplateFilter = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     9
    for i = 200,2000,600 do
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    10
        AddPoint(1,i,63)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    11
        AddPoint(4000,i)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    12
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    13
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
11065
dce587dfed4f make tunnels script use MapFeatureSize
wuzzy
parents: 10611
diff changeset
    15
    for i = 0,1+MapFeatureSize*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