Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
authorWuzzy <almikes@aol.com>
Wed, 19 Apr 2017 20:21:15 +0200
changeset 12287 faf1b93422ba
parent 12286 b4dde7035fe2
child 12288 a5a7d0c6d3f3
Use new EndTurn in a couple of scripts, esp. to fix timeout taunts in Racer
share/hedgewars/Data/Maps/TrophyRace/map.lua
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
share/hedgewars/Data/Scripts/Multiplayer/WxW.lua
--- a/share/hedgewars/Data/Maps/TrophyRace/map.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Maps/TrophyRace/map.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -177,7 +177,7 @@
             end
             
             ShowMission(loc("TrophyRace"), loc("Race"), loc("You've reached the goal!| |Time: ") .. (ttime / 1000) .. " s" .. hscore, 0, 0)
-            TurnTimeLeft = 0
+            EndTurn(true)
         end
     end
 end
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -3671,7 +3671,7 @@
 	if GetHogLevel(CurrentHedgehog) == 0 then
 		TurnTimeLeft = -1	-- is that turntime in your pocket? :D
 	else
-		TurnTimeLeft = 1 -- skip the computer's turn
+		ParseCommand("skip") -- skip the computer's turn
 	end
 
 end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -487,11 +487,16 @@
 
 end
 
-function DisableTumbler()
-        currCount = 0
-        fastIndex = 0
-        TurnTimeLeft = 0
-        racerActive = false -- newadd
+function DisableTumbler(endTurn)
+        if endTurn == nil then endTurn = true end
+        if racerActive then
+                currCount = 0
+                fastIndex = 0
+                if endTurn then
+                        EndTurn(true)
+                end
+                racerActive = false -- newadd
+        end
 end
 
 function HandleGhost()
@@ -715,7 +720,7 @@
                                 PlaceWayPoint(x, y)
                                 if wpCount == wpLimit then
                                         AddCaption(loc("Race complexity limit reached"))
-                                        DisableTumbler()
+                                        EndTurn(true)
                                 end
                         end
                 else
@@ -797,7 +802,7 @@
         AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
 
         if gear == CurrentHedgehog then
-                DisableTumbler()
+                DisableTumbler(false)
         end
 
 end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -899,7 +899,7 @@
 		end
 
 		gameOver = true
-		TurnTimeLeft = 0	--1
+		EndTurn(true)
 		TimeLeft = 0
 		SendStat(siGraphTitle, "Score graph")
 		EndGame()
--- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -559,11 +559,16 @@
 
 end
 
-function DisableTumbler()
-        currCount = 0
-        fastIndex = 0
-        TurnTimeLeft = 0
-        racerActive = false -- newadd
+function DisableTumbler(endTurn)
+        if endTurn == nil then endTurn = true end
+        if racerActive then
+                currCount = 0
+                fastIndex = 0
+                racerActive = false -- newadd
+                if endTurn then
+                         EndTurn(true)
+                end
+        end
 end
 
 function HandleGhost()
@@ -1151,11 +1156,11 @@
 
                         end
 
-                end
+                        -- If hedgehog is not controlled anymore, stop racing mode
+                        if band(GetState(CurrentHedgehog), gstHHDriven) == 0 then
+                                DisableTumbler(false)
+                        end
 
-                -- if the player has expended his tunbling time, stop him tumbling
-                if TurnTimeLeft <= 20 then
-                        DisableTumbler()
                 end
 
         end
@@ -1222,7 +1227,7 @@
         AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
 
         if gear == CurrentHedgehog then
-                DisableTumbler()
+               DisableTumbler(false)
         end
 
 end
--- a/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Wed Apr 19 17:50:31 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Wed Apr 19 20:21:15 2017 +0200
@@ -1328,8 +1328,8 @@
 		-- Was the team violating the attackRule the last time?
 		if getTeamValue(teamName, "skipPenalty") then
 			-- Then take away this turn
-			AddCaption(string.format(loc("%s must skip this turn for rule violation ."), teamName), msgColorWarn, capgrpMessage)
-			TurnTimeLeft = 0
+			AddCaption(string.format(loc("%s must skip this turn for rule violation."), teamName), msgColorWarn, capgrpMessage)
+			EndTurn(true)
 			setTeamValue(teamName, "skipPenalty", false)
 		end