# HG changeset patch # User Wuzzy # Date 1509050417 -7200 # Node ID cb29ec085767172a696beefe22802e1229e518a6 # Parent 255c2978b3664238a1cee63d45430afeadc0f56a Animate library: Add new parameter maxMoveTime to AnimMove diff -r 255c2978b366 -r cb29ec085767 ChangeLog.txt --- a/ChangeLog.txt Thu Oct 26 21:14:55 2017 +0200 +++ b/ChangeLog.txt Thu Oct 26 22:40:17 2017 +0200 @@ -380,6 +380,7 @@ + Locale library: loc_noop -- Mark string for translation but don't translate it + Animate library: AnimInit([startAnimating]) -- New parameter startAnimating: if true, will start game in cinematic mode with most controls disabled. Must play an animation after that + Animate library: AnimSetInputMask(extraInputMask) -- Set input mask in a manner comptible with the Animate library + + Animate library: AnimMove(gear, dir, posx, posy, [maxMoveTime]) -- new optional parameter maxMoveTime. If hog did not reach its destination within maxMoveTime milliseconds, animation stops and hog is just teleported there + Gear values: “Boom” -- used to modify explosion size and/or damage for most gears + 8 overridable custom sprites/sounds: sprCustom1-sprCustom8, sndCustom1-sndCustom8 * Fixed call: HideHog(gear) -- Fix crash when gear is invalid. Returns true on success or false otherwise diff -r 255c2978b366 -r cb29ec085767 share/hedgewars/Data/Scripts/Animate.lua --- 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