share/hedgewars/Data/Maps/FlightJoust/map.lua
author Palewolf
Sat, 06 Nov 2010 14:05:17 +0100
changeset 4145 84008f2ca18d
parent 3734 304a83637eb4
child 4162 923db448ad16
permissions -rw-r--r--
Fix watermelon fragments stray pixels. Clean Nature/Landtex.svg a little
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     1
local hogs = {}
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     2
local spawncrate = 0
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     3
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     4
function mapM_(func, tbl)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     5
    for i,v in pairs(tbl) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     6
        func(v)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     7
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     8
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
     9
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    10
function map(func, tbl)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    11
    local newtbl = {}
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    12
    for i,v in pairs(tbl) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    13
        newtbl[i] = func(v)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    14
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    15
    return newtbl
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    16
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    17
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    18
function filter(func, tbl)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    19
    local newtbl = {}
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    20
    for i,v in pairs(tbl) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    21
        if func(v) then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    22
            table.insert(newtbl, v)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    23
        end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    24
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    25
    return newtbl
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    26
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    27
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    28
function onGameInit()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    29
    GameFlags = gfSolidLand + gfDivideTeams
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    30
    TurnTime = 10000
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    31
    CaseFreq = 0 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    32
    LandAdds = 0 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    33
    Explosives = 0 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    34
    Delay = 500 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    35
    SuddenDeathTurns = 99999 -- "disable" sudden death
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    36
    Theme = Compost
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    37
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    38
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    39
function onGameStart()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    40
    local offset = 50
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    41
    local team1hh = filter(function(h) return GetHogClan(h) == 0 end, hogs)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    42
    local team2hh = filter(function(h) return GetHogClan(h) == 1 end, hogs)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    43
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    44
    for i,h in ipairs(team1hh) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    45
        SetGearPosition(h, 250+(i-1)*offset, 1000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    46
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    47
    for i,h in ipairs(team2hh) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    48
        SetGearPosition(h, 3500-(i-1)*offset, 1000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    49
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    50
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    51
    SpawnHealthCrate(1800, 1150)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    52
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    53
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    54
function onAmmoStoreInit()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    55
    SetAmmo(amRCPlane, 9, 0, 0, 0)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    56
    SetAmmo(amSkip, 9, 0, 0, 0)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    57
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    58
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    59
function onGearAdd(gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    60
    if GetGearType(gear) == gtRCPlane then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    61
        SetTimer(gear,60000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    62
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    63
    if GetGearType(gear) == gtHedgehog then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    64
        table.insert(hogs, gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    65
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    66
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    67
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    68
function onGameTick()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    69
    if (TurnTimeLeft == 9999 and spawncrate == 1) then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    70
        SpawnHealthCrate(1800, 1150)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    71
        spawncrate = 0
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    72
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    73
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    74
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    75
function onGearDelete(gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    76
    if GetGearType(gear) == gtCase then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    77
        spawncrate = 1
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    78
    end
3732
ec1c81d8c05a More script updates for FJ
tiyuri@gmail.com
parents: 3731
diff changeset
    79
end