Rework of No Gravity script:
authorunc0rr
Tue, 24 Dec 2013 22:16:07 +0400
changeset 9836 00cbbb195f11
parent 9834 4486c29d176c
child 9837 fa94ee96f006
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
hedgewars/uScript.pas
share/hedgewars/Data/Scripts/Multiplayer/Gravity.cfg
share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua
share/hedgewars/Data/Scripts/Multiplayer/No_Gravity.cfg
share/hedgewars/Data/Scripts/Multiplayer/No_Gravity.lua
--- a/hedgewars/uScript.pas	Tue Dec 24 12:52:08 2013 -0500
+++ b/hedgewars/uScript.pas	Tue Dec 24 22:16:07 2013 +0400
@@ -2040,6 +2040,7 @@
 ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns);
 ScriptSetInteger('WaterRise', cWaterRise);
 ScriptSetInteger('HealthDecrease', cHealthDecrease);
+ScriptSetInteger('GetAwayTime', cGetAwayTime);
 ScriptSetString('Map', cMapName);
 
 ScriptSetString('Theme', '');
@@ -2068,6 +2069,7 @@
 cSuddenDTurns    := ScriptGetInteger('SuddenDeathTurns');
 cWaterRise       := ScriptGetInteger('WaterRise');
 cHealthDecrease  := ScriptGetInteger('HealthDecrease');
+cGetAwayTime     := ScriptGetInteger('GetAwayTime');
 
 if cMapName <> ScriptGetString('Map') then
     ParseCommand('map ' + ScriptGetString('Map'), true, true);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.cfg	Tue Dec 24 22:16:07 2013 +0400
@@ -0,0 +1,2 @@
+Default
+Default
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Gravity.lua	Tue Dec 24 22:16:07 2013 +0400
@@ -0,0 +1,33 @@
+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
\ No newline at end of file
--- a/share/hedgewars/Data/Scripts/Multiplayer/No_Gravity.cfg	Tue Dec 24 12:52:08 2013 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Default
-Default
--- a/share/hedgewars/Data/Scripts/Multiplayer/No_Gravity.lua	Tue Dec 24 12:52:08 2013 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-function onNewTurn()
-    SetGravity(0)
-end
-
-function onGameTick20()
-    if TurnTimeLeft < 20 then
-        SetGravity(100)
-    end
-end