share/hedgewars/Data/Scripts/Animate.lua
changeset 12783 cb29ec085767
parent 12599 d8adae379d3c
child 13037 91f23558c936
--- a/share/hedgewars/Data/Scripts/Animate.lua	Thu Oct 26 21:14:55 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Thu Oct 26 22:40:17 2017 +0200
@@ -1,4 +1,5 @@
 local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
+local moveTime = 0
 local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent
 local needtoDecrease
 local AnimList, AnimListNum
@@ -166,13 +167,22 @@
   return true
 end
 
-function AnimMove(gear, dir, posx, posy)
+function AnimMove(gear, dir, posx, posy, maxMoveTime)
   dirr = moveDirs[dir]
   SetGearMessage(gear, dirr)
-  if GetX(gear) == posx or GetY(gear) == posy then
+  moveTime = moveTime + 1
+  if (maxMoveTime and moveTime > maxMoveTime) then
+    SetGearMessage(gear, 0)
+    SetGearPosition(gear, posx, posy)
+    lastx = GetX(gear)
+    lasty = GetY(gear)
+    moveTime = 0
+    return true
+  elseif GetX(gear) == posx or GetY(gear) == posy then
     SetGearMessage(gear, 0)
     lastx = GetX(gear)
     lasty = GetY(gear)
+    moveTime = 0
     return true
   end
   return false