share/hedgewars/Data/Scripts/Animate.lua
author belphegorr <szabibibi@gmail.com>
Fri, 29 Jun 2012 14:39:05 +0300
changeset 7213 fce7de71742f
parent 7205 cdc38e49a276
child 7245 53f73f4ae203
permissions -rw-r--r--
Fixed some bugs with Mission 2 and Animate.lua.
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} 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
    58
  moveDirs = {right = gmRight, left = gmLeft}
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)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   185
	SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   186
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   187
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   188
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   189
function AnimOutOfNowhere(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   190
  SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   191
  AddVisualGear(destX, destY, vgtBigExplosion, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   192
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   193
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   194
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   195
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   196
function AnimTeleportGear(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   197
	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
   198
	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
   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
	SetGearPosition(gear, destX, destY)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   202
	AddVisualGear(GetX(gear), GetY(gear), vgtBigExplosion, 0, false)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   203
  FollowGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   204
  AnimGearWait(gear, 50)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   205
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   206
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   207
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   208
function AnimSetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   209
  SetGearPosition(gear, x, y)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   210
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   211
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   212
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   213
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
   214
  AddVisualGear(x, y, vgType, state, critical)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   215
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   216
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   217
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   218
function AnimCaption(gear, text, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   219
  AddCaption(text)
7213
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   220
  if time == nil then
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   221
    return true
fce7de71742f Fixed some bugs with Mission 2 and Animate.lua.
belphegorr <szabibibi@gmail.com>
parents: 7205
diff changeset
   222
  end
7205
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   223
  AnimWait(gear, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   224
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   225
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   226
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   227
function AnimCustomFunction(gear, func, args)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   228
  if args == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   229
    args = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   230
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   231
  retval = func(unpack(args))
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   232
  if retval == false then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   233
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   234
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   235
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   236
  end
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   239
function AnimInsertStepNext(step)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   240
  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
   241
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   242
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   243
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   244
function 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
   245
  ShowMission(caption, subcaption, text, icon, time)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   246
  return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   247
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   248
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   249
function RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   250
  table.remove(AnimList, 1)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   251
  AnimListNum = AnimListNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   252
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   253
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   254
function AddAnim(animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   255
  table.insert(AnimList, animation)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   256
  AnimListNum = AnimListNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   257
  if AnimListNum == 1 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   258
    skipping = false
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
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   261
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   262
function ShowAnimation()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   263
  if AnimListNum == 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   264
    skipping = false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   265
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   266
  else
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   267
    TurnTimeLeft = -1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   268
    if Animate(AnimList[1]) == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   269
      RemoveAnim()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   270
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   271
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   272
  return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   273
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   274
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   275
function Animate(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   276
  if skipping == true then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   277
    animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   278
    SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   279
    SkipAnimation(steps)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   280
    return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   281
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   282
    
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   283
  if globalWait ~= 0 then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   284
    return false
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   285
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   286
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   287
  if steps[animPos] == nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   288
      animPos = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   289
      SetInputMask(0xFFFFFFFF)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   290
      return true
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   291
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   292
  
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   293
  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
   294
    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
   295
      AnimSwitchHog(steps[animPos].args[1])
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   296
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   297
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   298
  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
   299
  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
   300
  if (retVal ~= false) then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   301
    animPos = animPos + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   302
  end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   303
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   304
  return false
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
------------------------------Event Handling------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   308
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   309
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
   310
  seNum = seNum + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   311
  stageEvents[seNum] = {}
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   312
  stageEvents[seNum].cFunc = condFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   313
  stageEvents[seNum].cArgs = condArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   314
  stageEvents[seNum].dFunc = doFunc
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   315
  stageEvents[seNum].dArgs = doArgs
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   316
  stageEvents[seNum].evType = evType
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   317
end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   318
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   319
function RemoveEvent(evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   320
  if stageEvents[evNum] ~= nil then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   321
    seNum = seNum - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   322
    table.remove(stageEvents, evNum)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   323
  end
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 RemoveEventFunc(cFunc)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   327
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   328
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   329
    if stageEvents[i].cFunc == cFunc then
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   330
      RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   331
      i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   332
    end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   333
    i = i + 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   334
  end
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   337
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   338
function CheckEvents()
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   339
  local i = 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   340
  while i <= seNum do
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   341
    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
   342
      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
   343
      if stageEvents[i].evType ~= 1 then 
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   344
        RemoveEvent(i)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   345
        i = i - 1
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   346
      end
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   347
    end
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
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   352
-------------------------------------Misc---------------------------------
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   353
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   354
function StoppedGear(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   355
  dx,dy = GetGearVelocity(gear)
cdc38e49a276 Added the helper script I forgot to add last time
belphegorr <szabibibi@gmail.com>
parents:
diff changeset
   356
  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
   357
end