share/hedgewars/Data/Scripts/Animate.lua
author belphegorr <szabibibi@gmail.com>
Sun, 08 Jul 2012 19:15:38 +0300
changeset 7245 53f73f4ae203
parent 7213 fce7de71742f
child 7255 93cf6b3b89be
permissions -rw-r--r--
Modified frontend so that updating campaogn progress no longer changes current index of the mission combo box Updated Animate.lua (forgot to copy it last time) Mission 1: Fixed a bug where events would cause animations to stutter Moved a crate Made the princess and the elder pay attention to Leaks A Lot Changed the name of the chief to Righteous Beard Mission 2: - Mission 3: Removed leftover debug lines Solved a bug where Dense Cloud could not select weapons during final scene Made the hogs fave each other during the final animation Mission 4: Solved a bug where Dense Cloud would appear even if he's dead
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     2
local backJumped, jTimer, awTime, globalWait, stageEvents, seNum
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     3
local AnimList, AnimListNum
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     4
local FunctionList, FunctionListNum
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     5
local skipFuncList
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     6
local skipping
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     7
--------------------------------Animation---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     8
--------------------------(In-game cinematics)----------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
     9
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    10
function AddSkipFunction(anim, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    11
  skipFuncList[anim] = {sfunc = func, sargs = args}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    12
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    13
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    14
function RemoveSkipFunctin(anim)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    15
  skipFuncList[anim] = nil
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    16
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    17
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    18
function SetAnimSkip(bool)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    19
  skipping = bool
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    20
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    21
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    22
function AnimInProgress()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    23
  return AnimListNum ~= 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    24
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    25
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    26
function SkipAnimation(anim)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    27
  if skipFuncList[anim] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    28
    return
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    29
  else 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    30
    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
    31
  end
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    34
function AddFunction(element)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    35
  table.insert(FunctionList, element)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    36
  FunctionListNum = FunctionListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    37
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    38
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    39
function RemoveFunction()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    40
  table.remove(FunctionList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    41
  FunctionListNum = FunctionListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    42
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    43
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    44
function ExecuteAfterAnimations()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    45
  if FunctionListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    46
    return
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    47
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    48
  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
    49
  RemoveFunction()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    50
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    51
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    52
function AnimInit()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    53
  animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    54
  lastx = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    55
  lasty = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    56
  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
    57
  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
    58
  moveDirs = {Right = gmRight, Left = gmLeft}
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    59
  jumpStarted = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    60
  backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    61
  jTimer = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    62
  awTime = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    63
  globalWait = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    64
  stageEvents = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    65
  seNum = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    66
  AnimList = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    67
  AnimListNum = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    68
  FunctionList = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    69
  FunctionListNum = 0
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    70
  skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    71
  skipFuncList = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    72
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    73
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    74
function AnimSwitchHog(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    75
  SwitchHog(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    76
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    77
  SetGearMessage(gear, 0)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    78
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    79
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    80
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    81
function AnimGiveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    82
  SetState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    83
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    84
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    85
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    86
function AnimRemoveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    87
  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
    88
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    89
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    90
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    91
function AnimGearWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    92
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    93
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    94
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    95
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    96
function AnimUnWait()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    97
  if globalWait > 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    98
    globalWait = globalWait - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    99
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   100
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   101
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   102
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
   103
  globalWait = globalWait + time
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   104
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   105
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   106
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   107
function AnimWaitLeft()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   108
  return globalWait
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   109
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   110
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   111
function AnimSay(gear, text, manner, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   112
  HogSay(gear, text, manner, 2)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   113
  if time ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   114
    AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   115
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   116
  return true
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 AnimSound(gear, sound, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   120
  PlaySound(sound, gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   121
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   122
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   123
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   124
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   125
function AnimTurn(gear, dir)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   126
  if dir == "Right" then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   127
    HogTurnLeft(gear, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   128
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   129
    HogTurnLeft(gear, true)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   130
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   131
  return true
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   134
function AnimFollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   135
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   136
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   137
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   138
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   139
function AnimMove(gear, dir, posx, posy)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   140
  dirr = moveDirs[dir]
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   141
  SetGearMessage(gear, dirr)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   142
  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
   143
    SetGearMessage(gear, 0)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   144
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   145
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   146
    return 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 false
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 AnimJump(gear, jumpType)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   152
  if jumpStarted == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   153
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   154
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   155
    backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   156
    jumpStarted = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   157
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   158
    AnimGearWait(gear, jumpTimes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   159
  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
   160
    backJumped = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   161
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   162
    AnimGearWait(gear, jumpTimes["backback"])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   163
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   164
    curx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   165
    cury = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   166
    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
   167
      jumpStarted = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   168
      backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   169
      AnimGearWait(gear, 100)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   170
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   171
    else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   172
      lastx = curx
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   173
      lasty = cury
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   174
      AnimGearWait(gear, 100)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   175
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   176
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   177
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   178
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   179
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   180
function AnimDisappear(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   181
	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
   182
	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
   183
	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
   184
	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
   185
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   186
	SetGearPosition(gear, destX, destY)
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
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   189
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   190
function AnimOutOfNowhere(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   191
  SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   192
  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
   193
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   194
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   195
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   196
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   197
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   198
function AnimTeleportGear(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   199
	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
   200
	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
   201
	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
   202
	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
   203
	SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   204
	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
   205
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   206
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   207
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   208
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   209
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   210
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   211
function AnimSetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   212
  SetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   213
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   214
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   215
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   216
function AnimVisualGear(gear, x, y, vgType, state, critical)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   217
  AddVisualGear(x, y, vgType, state, critical)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   218
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   219
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   220
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   221
function AnimCaption(gear, text, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   222
  AddCaption(text)
7213
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   223
  if time == nil then
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   224
    return true
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   225
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   226
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   227
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   228
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   229
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   230
function AnimCustomFunction(gear, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   231
  if args == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   232
    args = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   233
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   234
  retval = func(unpack(args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   235
  if retval == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   236
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   237
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   238
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   239
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   240
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   241
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   242
function AnimInsertStepNext(step)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   243
  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
   244
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   245
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   246
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   247
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
   248
  ShowMission(caption, subcaption, text, icon, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   249
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   250
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   251
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   252
function RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   253
  table.remove(AnimList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   254
  AnimListNum = AnimListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   255
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   256
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   257
function AddAnim(animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   258
  table.insert(AnimList, animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   259
  AnimListNum = AnimListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   260
  if AnimListNum == 1 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   261
    skipping = false
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 ShowAnimation()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   266
  if AnimListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   267
    skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   268
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   269
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   270
    TurnTimeLeft = -1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   271
    if Animate(AnimList[1]) == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   272
      RemoveAnim()
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
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   275
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   276
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   277
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   278
function Animate(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   279
  if skipping == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   280
    animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   281
    SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   282
    SkipAnimation(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   283
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   284
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   285
    
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   286
  if globalWait ~= 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   287
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   288
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   289
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   290
  if steps[animPos] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   291
      animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   292
      SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   293
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   294
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   295
  
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   296
  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
   297
    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
   298
      AnimSwitchHog(steps[animPos].args[1])
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
  SetInputMask(band(0xFFFFFFFF, bnot(gmAnimate+gmAttack+gmDown+gmHJump+gmLeft+gmLJump+gmRight+gmSlot+gmSwitch+gmTimer+gmUp+gmWeapon)))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   302
  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
   303
  if (retVal ~= false) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   304
    animPos = animPos + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   305
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   306
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   307
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   308
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   309
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   310
------------------------------Event Handling------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   311
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   312
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
   313
  seNum = seNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   314
  stageEvents[seNum] = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   315
  stageEvents[seNum].cFunc = condFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   316
  stageEvents[seNum].cArgs = condArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   317
  stageEvents[seNum].dFunc = doFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   318
  stageEvents[seNum].dArgs = doArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   319
  stageEvents[seNum].evType = evType
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   320
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   321
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   322
function RemoveEvent(evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   323
  if stageEvents[evNum] ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   324
    seNum = seNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   325
    table.remove(stageEvents, evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   326
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   327
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   328
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   329
function RemoveEventFunc(cFunc)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   330
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   331
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   332
    if stageEvents[i].cFunc == cFunc then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   333
      RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   334
      i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   335
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   336
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   337
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   338
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   339
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   340
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   341
function CheckEvents()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   342
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   343
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   344
    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
   345
      stageEvents[i].dFunc(unpack(stageEvents[i].dArgs))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   346
      if stageEvents[i].evType ~= 1 then 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   347
        RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   348
        i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   349
      end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   350
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   351
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   352
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   353
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   354
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   355
-------------------------------------Misc---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   356
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   357
function StoppedGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   358
  dx,dy = GetGearVelocity(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   359
  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
   360
end