share/hedgewars/Data/Scripts/Animate.lua
author belphegorr <szabibibi@gmail.com>
Mon, 16 Jul 2012 20:56:55 +0300
changeset 7255 93cf6b3b89be
parent 7245 53f73f4ae203
child 7263 644eabbc9218
permissions -rw-r--r--
Fixed a visual gear in Mission 5 Animate.lua: added an optional boolean parameter to AnimVisualGear - follow
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)
7255
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
    75
  --SetGearMessage(gear, 0)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
    76
  --SetState(gear, 0)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    77
  SwitchHog(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    78
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    79
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    80
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    81
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    82
function AnimGiveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    83
  SetState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    84
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    85
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    86
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    87
function AnimRemoveState(gear, state)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    88
  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
    89
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    90
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    91
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    92
function AnimGearWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    93
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    94
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    95
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    96
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    97
function AnimUnWait()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    98
  if globalWait > 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    99
    globalWait = globalWait - 1
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
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 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
   104
  globalWait = globalWait + time
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 AnimWaitLeft()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   109
  return globalWait
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   110
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   111
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   112
function AnimSay(gear, text, manner, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   113
  HogSay(gear, text, manner, 2)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   114
  if time ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   115
    AnimWait(gear, time)
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
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   118
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   119
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   120
function AnimSound(gear, sound, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   121
  PlaySound(sound, gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   122
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   123
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   124
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   125
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   126
function AnimTurn(gear, dir)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   127
  if dir == "Right" then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   128
    HogTurnLeft(gear, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   129
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   130
    HogTurnLeft(gear, true)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   131
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   132
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   133
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   134
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   135
function AnimFollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   136
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   137
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   138
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   139
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   140
function AnimMove(gear, dir, posx, posy)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   141
  dirr = moveDirs[dir]
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   142
  SetGearMessage(gear, dirr)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   143
  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
   144
    SetGearMessage(gear, 0)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   145
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   146
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   147
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   148
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   149
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   150
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   151
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   152
function AnimJump(gear, jumpType)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   153
  if jumpStarted == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   154
    lastx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   155
    lasty = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   156
    backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   157
    jumpStarted = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   158
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   159
    AnimGearWait(gear, jumpTimes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   160
  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
   161
    backJumped = true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   162
    SetGearMessage(gear, jumpTypes[jumpType])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   163
    AnimGearWait(gear, jumpTimes["backback"])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   164
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   165
    curx = GetX(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   166
    cury = GetY(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   167
    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
   168
      jumpStarted = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   169
      backJumped = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   170
      AnimGearWait(gear, 100)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   171
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   172
    else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   173
      lastx = curx
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   174
      lasty = cury
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   175
      AnimGearWait(gear, 100)
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
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   178
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   179
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   180
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   181
function AnimDisappear(gear, destX, destY)
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)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   185
	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
   186
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   187
	SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   188
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   189
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   190
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   191
function AnimOutOfNowhere(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   192
  SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   193
  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
   194
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   195
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   196
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   197
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   198
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   199
function AnimTeleportGear(gear, destX, destY)
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
	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
   204
	SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   205
	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
   206
  PlaySound(sndExplosion)
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   207
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   208
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   209
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   210
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   211
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   212
function AnimSetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   213
  SetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   214
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   215
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   216
7255
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   217
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
   218
  local vgear = AddVisualGear(x, y, vgType, state, critical)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   219
  if follow == true then 
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   220
    FollowGear(vgear)
93cf6b3b89be Fixed a visual gear in Mission 5
belphegorr <szabibibi@gmail.com>
parents: 7245
diff changeset
   221
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   222
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   223
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   224
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   225
function AnimCaption(gear, text, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   226
  AddCaption(text)
7213
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   227
  if time == nil then
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   228
    return true
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   229
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   230
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   231
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   232
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   233
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   234
function AnimCustomFunction(gear, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   235
  if args == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   236
    args = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   237
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   238
  retval = func(unpack(args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   239
  if retval == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   240
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   241
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   242
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   243
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   244
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   245
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   246
function AnimInsertStepNext(step)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   247
  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
   248
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   249
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   250
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   251
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
   252
  ShowMission(caption, subcaption, text, icon, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   253
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   254
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   255
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   256
function RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   257
  table.remove(AnimList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   258
  AnimListNum = AnimListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   259
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   260
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   261
function AddAnim(animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   262
  table.insert(AnimList, animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   263
  AnimListNum = AnimListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   264
  if AnimListNum == 1 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   265
    skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   266
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   267
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   268
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   269
function ShowAnimation()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   270
  if AnimListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   271
    skipping = false
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
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   274
    TurnTimeLeft = -1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   275
    if Animate(AnimList[1]) == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   276
      RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   277
    end
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
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   280
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   281
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   282
function Animate(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   283
  if skipping == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   284
    animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   285
    SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   286
    SkipAnimation(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   287
    return true
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 globalWait ~= 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   291
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   292
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   293
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   294
  if steps[animPos] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   295
      animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   296
      SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   297
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   298
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   299
  
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   300
  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
   301
    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
   302
      AnimSwitchHog(steps[animPos].args[1])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   303
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   304
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   305
  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
   306
  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
   307
  if (retVal ~= false) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   308
    animPos = animPos + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   309
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   310
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   311
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   312
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   313
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   314
------------------------------Event Handling------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   315
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   316
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
   317
  seNum = seNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   318
  stageEvents[seNum] = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   319
  stageEvents[seNum].cFunc = condFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   320
  stageEvents[seNum].cArgs = condArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   321
  stageEvents[seNum].dFunc = doFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   322
  stageEvents[seNum].dArgs = doArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   323
  stageEvents[seNum].evType = evType
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   324
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   325
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   326
function RemoveEvent(evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   327
  if stageEvents[evNum] ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   328
    seNum = seNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   329
    table.remove(stageEvents, evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   330
  end
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
function RemoveEventFunc(cFunc)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   334
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   335
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   336
    if stageEvents[i].cFunc == cFunc then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   337
      RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   338
      i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   339
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   340
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   341
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   342
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   343
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   344
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   345
function CheckEvents()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   346
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   347
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   348
    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
   349
      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
   350
      if stageEvents[i].evType ~= 1 then 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   351
        RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   352
        i = i - 1
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
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   355
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   356
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   357
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   358
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   359
-------------------------------------Misc---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   360
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   361
function StoppedGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   362
  dx,dy = GetGearVelocity(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   363
  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
   364
end