share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua
author unc0rr
Wed, 01 Jan 2014 14:16:01 +0400
changeset 9902 eb8e8b09b2f0
parent 9898 b87695f82d2e
child 9906 93c16a4b0c6a
permissions -rw-r--r--
Special script parameter variable in game scheme
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()
9898
b87695f82d2e Don't set gravity to normal immediately on turn end, let watchdog do its job if game gets frozen
unc0rr
parents: 9836
diff changeset
    13
    if 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()
9902
eb8e8b09b2f0 Special script parameter variable in game scheme
unc0rr
parents: 9898
diff changeset
    24
    gravity = ScriptParam
9836
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    25
end
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    26
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    27
function onGameStart()
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    28
    ShowMission(loc("Gravity"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    29
                loc("Current value is ") .. gravity .. "%",
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    30
                loc("Set any gravity value you want by adjusting get away time"),
00cbbb195f11 Rework of No Gravity script:
unc0rr
parents: 9819
diff changeset
    31
                0, 5000)
9902
eb8e8b09b2f0 Special script parameter variable in game scheme
unc0rr
parents: 9898
diff changeset
    32
end