share/hedgewars/Data/Maps/FlightJoust/map.lua
author Wuzzy <Wuzzy2@mail.ru>
Fri, 07 Jun 2019 15:09:42 +0200
changeset 15135 13e7d4eccb67
parent 14406 6c21bd8547dd
permissions -rw-r--r--
CTF/Control: Fix incomplete hedgehog loop bounds
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 
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 3734
diff changeset
    32
    MinesNum = 0 
3734
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    33
    Explosives = 0 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    34
    SuddenDeathTurns = 99999 -- "disable" sudden death
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    35
    Theme = Compost
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    36
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    37
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    38
function onGameStart()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    39
    local offset = 50
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    40
    local team1hh = filter(function(h) return GetHogClan(h) == 0 end, hogs)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    41
    local team2hh = filter(function(h) return GetHogClan(h) == 1 end, hogs)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    42
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    43
    for i,h in ipairs(team1hh) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    44
        SetGearPosition(h, 250+(i-1)*offset, 1000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    45
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    46
    for i,h in ipairs(team2hh) do
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    47
        SetGearPosition(h, 3500-(i-1)*offset, 1000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    48
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    49
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    50
    SpawnHealthCrate(1800, 1150)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    51
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    52
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    53
function onAmmoStoreInit()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    54
    SetAmmo(amRCPlane, 9, 0, 0, 0)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    55
    SetAmmo(amSkip, 9, 0, 0, 0)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    56
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    57
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    58
function onGearAdd(gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    59
    if GetGearType(gear) == gtRCPlane then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    60
        SetTimer(gear,60000)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    61
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    62
    if GetGearType(gear) == gtHedgehog then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    63
        table.insert(hogs, gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    64
    end 
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    65
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    66
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    67
function onGameTick()
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    68
    if (TurnTimeLeft == 9999 and spawncrate == 1) then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    69
        SpawnHealthCrate(1800, 1150)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    70
        spawncrate = 0
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    71
    end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    72
end
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    73
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    74
function onGearDelete(gear)
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    75
    if GetGearType(gear) == gtCase then
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    76
        spawncrate = 1
304a83637eb4 * SpawnCustomCrateAt procedure + lua bindings
burp
parents: 3732
diff changeset
    77
    end
4162
923db448ad16 update and fix some lua stuff
Henek
parents: 3734
diff changeset
    78
end