share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua
author unc0rr
Tue, 24 Dec 2013 22:16:07 +0400
changeset 9836 00cbbb195f11
parent 9819 share/hedgewars/Data/Scripts/Multiplayer/No_Gravity.lua@5b10d119955c
child 9898 b87695f82d2e
permissions -rw-r--r--
Rework of No Gravity script: - Now called Gravity, gravity is derived from get away time percentage in game scheme - Watchdog which sets gravity to normal when TurnTimeLeft is frozen for more than 15 seconds
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     1
HedgewarsScriptLoad("/Scripts/Locale.lua")
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     2
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     3
local gravity = 100
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     4
local wdGameTicks = 0
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     5
local wdTTL = 0
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     6
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
     7
function onNewTurn()
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     8
    SetGravity(gravity)
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
     9
    wdGameTicks = GameTime
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    10
end
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    11
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    12
function onGameTick20()
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    13
    if (TurnTimeLeft < 20) or (TurnTimeLeft > 0 and wdGameTicks + 15000 < GameTime) then
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    14
        SetGravity(100)
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    15
    elseif wdTTL ~= TurnTimeLeft then
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    16
        wdGameTicks = GameTime
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    17
        SetGravity(gravity)
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    18
    end
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    19
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    20
    wdTTL = TurnTimeLeft
9816
e71188c140ee No gravity mode
unc0rr
parents:
diff changeset
    21
end
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    22
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    23
function onGameInit()
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    24
    gravity = GetAwayTime
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    25
    GetAwayTime = 100
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    26
end
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    27
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    28
function onGameStart()
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    29
    ShowMission(loc("Gravity"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    30
                loc("Current value is ") .. gravity .. "%",
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    31
                loc("Set any gravity value you want by adjusting get away time"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    32
                0, 5000)
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    33
end