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