share/hedgewars/Data/Scripts/Animate.lua
author sheepluva
Sat, 03 Dec 2016 09:09:16 +0100
changeset 12103 966a9739812f
parent 12093 1da37e2ba6fd
child 12599 d8adae379d3c
permissions -rw-r--r--
copyToXYFromRect: fix pixels overflowing pixel lines in dest
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     1
local animPos, lastx, lasty, jumpTypes, jumpTimes, moveDirs, jumpStarted
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
     2
local backJumped, jTimer, awTime, globalWait, stageEvents, seNum, curEvent
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
     3
local needtoDecrease
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     4
local AnimList, AnimListNum
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     5
local FunctionList, FunctionListNum
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     6
local skipFuncList
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     7
local skipping
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     8
--------------------------------Animation---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     9
--------------------------(In-game cinematics)----------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    10
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    11
function AddSkipFunction(anim, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    12
  skipFuncList[anim] = {sfunc = func, sargs = args}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    13
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    14
7263
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
    15
function RemoveSkipFunction(anim)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    16
  skipFuncList[anim] = nil
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    17
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    18
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    19
function SetAnimSkip(bool)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    20
  skipping = bool
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    21
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    22
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    23
function AnimInProgress()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    24
  return AnimListNum ~= 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    25
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    26
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    27
function SkipAnimation(anim)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    28
  if skipFuncList[anim] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    29
    return
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    30
  else 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    31
    skipFuncList[anim].sfunc(unpack(skipFuncList[anim].sargs))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    32
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    33
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    34
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    35
function AddFunction(element)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    36
  table.insert(FunctionList, element)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    37
  FunctionListNum = FunctionListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    38
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    39
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    40
function RemoveFunction()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    41
  table.remove(FunctionList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    42
  FunctionListNum = FunctionListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    43
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    44
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    45
function ExecuteAfterAnimations()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    46
  if FunctionListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    47
    return
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    48
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    49
  FunctionList[1].func(unpack(FunctionList[1].args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    50
  RemoveFunction()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    51
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    52
12093
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    53
local function startCinemaLock()
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    54
     SetCinematicMode(true)
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    55
     SetInputMask(bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon))
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    56
end
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    57
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    58
local function stopCinemaLock()
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    59
     SetInputMask(0xFFFFFFFF)
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    60
     SetCinematicMode(false)
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    61
end
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    62
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    63
function AnimInit(startAnimating)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    64
  lastx = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    65
  lasty = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    66
  jumpTypes = {long = gmLJump, high = gmHJump, back = gmHJump}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    67
  jumpTimes = {long = 500, high = 500, back = 300, backback = 500} 
7245
53f73f4ae203 Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box
belphegorr <szabibibi@gmail.com>
parents: 7213
diff changeset
    68
  moveDirs = {Right = gmRight, Left = gmLeft}
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    69
  jumpStarted = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    70
  backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    71
  jTimer = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    72
  awTime = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    73
  globalWait = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    74
  stageEvents = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    75
  seNum = 0
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
    76
  curEvent = 0
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
    77
  needToDecrease = 0
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    78
  AnimList = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    79
  AnimListNum = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    80
  FunctionList = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    81
  FunctionListNum = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    82
  skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    83
  skipFuncList = {}
12093
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    84
  animPos = 1
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    85
  if startAnimating then
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    86
     startCinemaLock()
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
    87
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    88
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    89
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    90
function AnimSwitchHog(gear)
7255
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
    91
  --SetGearMessage(gear, 0)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
    92
  --SetState(gear, 0)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    93
  SwitchHog(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    94
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    95
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    96
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    97
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    98
function AnimGiveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    99
  SetState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   100
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   101
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   102
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   103
function AnimRemoveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   104
  SetState(gear, band(GetState(gear), bnot(state)))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   105
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   106
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   107
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   108
function AnimGearWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   109
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   110
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   111
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   112
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   113
function AnimUnWait()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   114
  if globalWait > 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   115
    globalWait = globalWait - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   116
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   117
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   118
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   119
function AnimWait(gear, time)   -- gear is for compatibility with Animate
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   120
  globalWait = globalWait + time
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   121
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   122
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   123
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   124
function AnimWaitLeft()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   125
  return globalWait
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   126
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   127
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   128
function AnimSay(gear, text, manner, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   129
  HogSay(gear, text, manner, 2)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   130
  if time ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   131
    AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   132
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   133
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   134
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   135
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   136
function AnimSound(gear, sound, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   137
  PlaySound(sound, gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   138
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   139
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   140
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   141
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   142
function AnimTurn(gear, dir)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   143
  if dir == "Right" then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   144
    HogTurnLeft(gear, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   145
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   146
    HogTurnLeft(gear, true)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   147
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   148
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   149
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   150
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   151
function AnimFollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   152
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   153
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   154
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   155
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   156
function AnimMove(gear, dir, posx, posy)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   157
  dirr = moveDirs[dir]
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   158
  SetGearMessage(gear, dirr)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   159
  if GetX(gear) == posx or GetY(gear) == posy then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   160
    SetGearMessage(gear, 0)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   161
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   162
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   163
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   164
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   165
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   166
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   167
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   168
function AnimJump(gear, jumpType)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   169
  if jumpStarted == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   170
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   171
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   172
    backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   173
    jumpStarted = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   174
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   175
    AnimGearWait(gear, jumpTimes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   176
  elseif jumpType == "back" and backJumped == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   177
    backJumped = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   178
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   179
    AnimGearWait(gear, jumpTimes["backback"])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   180
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   181
    curx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   182
    cury = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   183
    if curx == lastx and cury == lasty then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   184
      jumpStarted = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   185
      backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   186
      AnimGearWait(gear, 100)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   187
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   188
    else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   189
      lastx = curx
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   190
      lasty = cury
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   191
      AnimGearWait(gear, 100)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   192
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   193
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   194
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   195
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   196
7448
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   197
function AnimSetGearPosition(gear, destX, destY, fall)
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   198
  SetGearPosition(gear, destX, destY)
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   199
  if fall ~= false then
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   200
    SetGearVelocity(gear, 0, 10)
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   201
  end
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   202
  return true
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   203
end
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   204
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   205
function AnimDisappear(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   206
	AddVisualGear(GetX(gear)-5, GetY(gear)-5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   207
	AddVisualGear(GetX(gear)+5, GetY(gear)+5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   208
	AddVisualGear(GetX(gear)-5, GetY(gear)+5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   209
	AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false)
7245
53f73f4ae203 Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box
belphegorr <szabibibi@gmail.com>
parents: 7213
diff changeset
   210
  PlaySound(sndExplosion)
7448
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   211
	AnimSetGearPosition(gear, destX, destY)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   212
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   213
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   214
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   215
function AnimOutOfNowhere(gear, destX, destY)
7448
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   216
  AnimSetGearPosition(gear, destX, destY)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   217
  AddVisualGear(destX, destY, vgtBigExplosion, 0, false)
7245
53f73f4ae203 Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box
belphegorr <szabibibi@gmail.com>
parents: 7213
diff changeset
   218
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   219
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   220
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   221
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   222
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   223
function AnimTeleportGear(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   224
	AddVisualGear(GetX(gear)-5, GetY(gear)-5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   225
	AddVisualGear(GetX(gear)+5, GetY(gear)+5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   226
	AddVisualGear(GetX(gear)-5, GetY(gear)+5, vgtSmoke, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   227
	AddVisualGear(GetX(gear)+5, GetY(gear)-5, vgtSmoke, 0, false)
7448
d0521a3a4358 Solved "floating repositionings" in every mission
belphegorr <szabibibi@gmail.com>
parents: 7438
diff changeset
   228
	AnimSetGearPosition(gear, destX, destY)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   229
	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
7245
53f73f4ae203 Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box
belphegorr <szabibibi@gmail.com>
parents: 7213
diff changeset
   230
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   231
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   232
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   233
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   234
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   235
7255
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   236
function AnimVisualGear(gear, x, y, vgType, state, critical, follow)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   237
  local vgear = AddVisualGear(x, y, vgType, state, critical)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   238
  if follow == true then 
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   239
    FollowGear(vgear)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   240
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   241
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   242
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   243
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   244
function AnimCaption(gear, text, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   245
  AddCaption(text)
7213
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   246
  if time == nil then
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   247
    return true
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   248
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   249
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   250
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   251
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   252
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   253
function AnimCustomFunction(gear, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   254
  if args == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   255
    args = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   256
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   257
  retval = func(unpack(args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   258
  if retval == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   259
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   260
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   261
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   262
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   263
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   264
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   265
function AnimInsertStepNext(step)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   266
  table.insert(AnimList[1], animPos + 1, step)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   267
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   268
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   269
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   270
function AnimShowMission(gear, caption, subcaption, text, icon, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   271
  ShowMission(caption, subcaption, text, icon, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   272
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   273
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   274
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   275
function RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   276
  table.remove(AnimList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   277
  AnimListNum = AnimListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   278
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   279
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   280
function AddAnim(animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   281
  table.insert(AnimList, animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   282
  AnimListNum = AnimListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   283
  if AnimListNum == 1 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   284
    skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   285
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   286
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   287
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   288
function ShowAnimation()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   289
  if AnimListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   290
    skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   291
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   292
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   293
    TurnTimeLeft = -1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   294
    if Animate(AnimList[1]) == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   295
      RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   296
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   297
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   298
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   299
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   300
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   301
function Animate(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   302
  if skipping == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   303
    animPos = 1
12093
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
   304
    stopCinemaLock()
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   305
    SkipAnimation(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   306
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   307
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   308
    
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   309
  if globalWait ~= 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   310
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   311
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   312
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   313
  if steps[animPos] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   314
      animPos = 1
12093
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
   315
      stopCinemaLock()
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   316
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   317
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   318
  
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   319
  if steps[animPos].args[1] ~= CurrentHedgehog and steps[animPos].func ~= AnimWait 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   320
    and (steps[animPos].swh == nil or steps[animPos].swh == true) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   321
      AnimSwitchHog(steps[animPos].args[1])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   322
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   323
12093
1da37e2ba6fd Fix A Space Adventure Missions allowing player to walk before 1st animation and screw things up
Wuzzy <almikes@aol.com>
parents: 12089
diff changeset
   324
  startCinemaLock()
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   325
  retVal = steps[animPos].func(unpack(steps[animPos].args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   326
  if (retVal ~= false) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   327
    animPos = animPos + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   328
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   329
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   330
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   331
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   332
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   333
------------------------------Event Handling------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   334
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   335
function AddEvent(condFunc, condArgs, doFunc, doArgs, evType)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   336
  seNum = seNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   337
  stageEvents[seNum] = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   338
  stageEvents[seNum].cFunc = condFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   339
  stageEvents[seNum].cArgs = condArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   340
  stageEvents[seNum].dFunc = doFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   341
  stageEvents[seNum].dArgs = doArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   342
  stageEvents[seNum].evType = evType
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   343
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   344
7263
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   345
function AddNewEvent(condFunc, condArgs, doFunc, doArgs, evType)
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   346
  local i
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   347
  for i = 1, seNum do
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   348
    if stageEvents[i].cFunc == condFunc and stageEvents[i].cArgs == condArgs and
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   349
       stageEvents[i].dFunc == doFunc and stageEvents[i].dArgs == doArgs and 
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   350
       stageEvents[seNum].evType == evType then
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   351
       return
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   352
    end
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   353
  end
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   354
  AddEvent(condFunc, condArgs, doFunc, doArgs, evType)
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   355
end
644eabbc9218 Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
belphegorr <szabibibi@gmail.com>
parents: 7255
diff changeset
   356
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   357
function RemoveEvent(evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   358
  if stageEvents[evNum] ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   359
    seNum = seNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   360
    table.remove(stageEvents, evNum)
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   361
    if evNum < curEvent then
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   362
      return true
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   363
    end
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   364
  end
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   365
  if evNum < curEvent then
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   366
    needToDecrease = needToDecrease + 1
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   367
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   368
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   369
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   370
function RemoveEventFunc(cFunc, cArgs)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   371
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   372
  while i <= seNum do
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   373
    if stageEvents[i].cFunc == cFunc and (cArgs == nil or cArgs == stageEvents[i].cArgs) then
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   374
      RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   375
      i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   376
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   377
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   378
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   379
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   380
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   381
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   382
function CheckEvents()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   383
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   384
  while i <= seNum do
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   385
    curEvent = i
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   386
    if stageEvents[i].cFunc(unpack(stageEvents[i].cArgs)) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   387
      stageEvents[i].dFunc(unpack(stageEvents[i].dArgs))
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   388
      if needToDecrease > 0 then
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   389
        i = i - needToDecrease
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   390
        needToDecrease = 0
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   391
      end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   392
      if stageEvents[i].evType ~= 1 then 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   393
        RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   394
        i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   395
      end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   396
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   397
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   398
  end
7438
195f9cbd6df6 Modified Animate.lua: Modified event removal function to check if removed event is before current one, added optional parameter to RemoveEventFunc for optional checking of parameter list identicity.
belphegorr <szabibibi@gmail.com>
parents: 7263
diff changeset
   399
  curEvent = 0
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   400
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   401
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   402
-------------------------------------Misc---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   403
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   404
function StoppedGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   405
  dx,dy = GetGearVelocity(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   406
  return math.abs(dx) <= 1 and math.abs(dy) <= 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   407
end