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

HedgewarsScriptLoad("/Scripts/Locale.lua")

local gravity = 100
local wdGameTicks = 0
local wdTTL = 0

function onNewTurn()
    SetGravity(gravity)
    wdGameTicks = GameTime
end

function onGameTick20()
    if (TurnTimeLeft < 20) or (TurnTimeLeft > 0 and wdGameTicks + 15000 < GameTime) then
        SetGravity(100)
    elseif wdTTL ~= TurnTimeLeft then
        wdGameTicks = GameTime
        SetGravity(gravity)
    end

    wdTTL = TurnTimeLeft
end

function onGameInit()
    gravity = GetAwayTime
    GetAwayTime = 100
end

function onGameStart()
    ShowMission(loc("Gravity"),
                loc("Current value is ") .. gravity .. "%",
                loc("Set any gravity value you want by adjusting get away time"),
                0, 5000)
end