share/hedgewars/Data/Scripts/Multiplayer/Tunnels.lua
author nemo
Sat, 29 Mar 2014 13:57:46 -0400
changeset 10219 bbeb1e9aaa65
parent 10153 28e53573fdd2
child 10423 b9d6463cf2ca
permissions -rw-r--r--
param for original highlander mode - right now just allows getting another copy of a weapon you already had, but had used that turn.
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
 PointsBuffer = ''  -- A string to accumulate points in
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     2
 function AddPoint(x, y, width, erase)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     3
     PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     4
     if width then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     5
         width = bor(width,0x80)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     6
         if erase then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     7
             width = bor(width,0x40)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     8
         end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
     9
         PointsBuffer = PointsBuffer .. string.char(width)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    10
     else
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    11
         PointsBuffer = PointsBuffer .. string.char(0)
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
     if #PointsBuffer > 245 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    14
         ParseCommand('draw '..PointsBuffer)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    15
         PointsBuffer = ''
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    16
     end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    17
 end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    18
 function FlushPoints()
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    19
     if #PointsBuffer > 0 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    20
         ParseCommand('draw '..PointsBuffer)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    21
         PointsBuffer = ''
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    22
     end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    23
 end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    24
10153
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
    25
function onPreviewInit()
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
    26
onGameInit()
28e53573fdd2 add preview init to tunnels too
nemo
parents: 7791
diff changeset
    27
end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    28
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    29
function onGameInit()
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    30
    MapGen = 2
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    31
    TemplateFilter = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    32
    for i = 200,2000,600 do
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    33
        AddPoint(1,i,63)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    34
        AddPoint(4000,i)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    35
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    36
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
    37
    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
    38
    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
    39
        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
    40
            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
    41
        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
    42
            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
    43
        end
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    44
        --side = GetRandom(4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    45
        dx = div(size,4)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    46
        maxshift = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    47
        dy = dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    48
        if side == 0 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    49
            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
    50
            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
    51
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    52
        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
    53
            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
    54
            y = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    55
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    56
        elseif side == 2 then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    57
            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
    58
            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
    59
            dx = -dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    60
            dy = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    61
        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
    62
            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
    63
            y = 2048
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    64
            dx = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    65
            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
    66
        elseif side > 3 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    67
            x = GetRandom(2500)+500
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    68
            y = GetRandom(1250)+250
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    69
            dx = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    70
            dy = GetRandom(maxshift*2)-maxshift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    71
        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
    72
        length = GetRandom(500-size*25)+600
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    73
        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
    74
            length = length - 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    75
            AddPoint(x,y,size,true)
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    76
            x = x + dx
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    77
            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
    78
            if GetRandom(8) == 0 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    79
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    80
                if (shift > 0) and (dx < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    81
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    82
                elseif (shift < 0) and (dx > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    83
                    dx = dx + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    84
                end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    85
                shift = GetRandom(10)-5
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    86
                if (shift > 0) and (dy < maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    87
                    dy = dy + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    88
                elseif (shift < 0) and (dy > -maxshift) then
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    89
                    dy = dy + shift
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    90
                end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    91
            end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    92
        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
    93
        if side < 6 then
7785
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    94
            side = side + 1
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    95
        else 
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    96
            side = 0
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    97
        end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    98
    end
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
    99
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
   100
    FlushPoints()
9b5dceaea976 Someone should look this over to make sure it should stay in
nemo
parents:
diff changeset
   101
end