share/hedgewars/Data/Scripts/Multiplayer/Tunnels.lua
author nemo
Tue, 02 Dec 2014 16:45:26 -0500
changeset 10607 532d43f3d6f9
parent 10423 b9d6463cf2ca
child 10611 58cad46782ff
permissions -rw-r--r--
forgot this one.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10607
532d43f3d6f9 forgot this one.
nemo
parents: 10423
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Draw.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()
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
     4
onGameInit()
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
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    10
    for i = 200,2000,600 do
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    11
        AddPoint(1,i,63)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    12
        AddPoint(4000,i)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    13
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    14
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
    15
    side = 0
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
    for i = 0,GetRandom(15)+25 do
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
        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
    18
            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
    19
        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
    20
            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
    21
        end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    22
        --side = GetRandom(4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    23
        dx = div(size,4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    24
        maxshift = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    25
        dy = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    26
        if side == 0 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    27
            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
    28
            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
    29
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    30
        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
    31
            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
    32
            y = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    33
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    34
        elseif side == 2 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    35
            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
    36
            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
    37
            dx = -dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    38
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    39
        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
    40
            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
    41
            y = 2048
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    42
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    43
            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
    44
        elseif side > 3 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    45
            x = GetRandom(2500)+500
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    46
            y = GetRandom(1250)+250
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    47
            dx = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    48
            dy = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    49
        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
    50
        length = GetRandom(500-size*25)+600
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    51
        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
    52
            length = length - 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    53
            AddPoint(x,y,size,true)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    54
            x = x + dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    55
            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
    56
            if GetRandom(8) == 0 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    57
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    58
                if (shift > 0) and (dx < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    59
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    60
                elseif (shift < 0) and (dx > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    61
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    62
                end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    63
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    64
                if (shift > 0) and (dy < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    65
                    dy = dy + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    66
                elseif (shift < 0) and (dy > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    67
                    dy = dy + shift
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
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    70
        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
    71
        if side < 6 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    72
            side = side + 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    73
        else 
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    74
            side = 0
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
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    77
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    78
    FlushPoints()
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    79
end