Advertisement
offbrandbiscuit

Untitled

May 30th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.99 KB | None | 0 0
  1. timer = 0
  2. timer2 = 0
  3. Encounter.SetVar("wavetimer",math.huge)
  4. Arena.Resize(200,200)
  5. Encounter.Call("Animate",Encounter['Anim_To_Side'])
  6. Player.MoveTo(0,0,false)
  7. difficulty = Encounter["difficulty"]
  8.  
  9. fadintime = 60
  10. fadinstate = 0
  11. willshoot = false
  12. source_x = Arena.width/2 + 10
  13. source_y = 0
  14.  
  15. side = 1
  16.  
  17. spawntimer = 20 - difficulty * 4
  18. spawntimer2 = 200 - difficulty * 20
  19. speed = 1.5 + difficulty * 0.2
  20. speed2 = 1
  21.  
  22. bullets = {}
  23.  
  24. phase = 0
  25.  
  26. function Update()
  27. timer = timer + Time.mult
  28. while timer >= 1 do
  29. timer = timer - 1
  30. timer2 = timer2 + 1
  31. if phase == 0 then
  32. FadeHands()
  33. if willshoot == true then
  34. ShootBullets()
  35. end
  36. if timer2 >= 6*60 and phase == 0 then -- SET TO 12!!!
  37. phase = 1
  38. hand_targety = hand_dir * (Arena.height/2 - 5)
  39. ResizeCustomSpeed(2,{50,200})
  40. hand_to = "start"
  41. Encounter.Call("Animate",Encounter['Anim_To_Firewall_Mid'])
  42. end
  43. end
  44. if phase == 0 then
  45. l_hand.MoveTo(-(Arena.currentwidth/2 + 25),-20)
  46. r_hand.MoveTo((Arena.currentwidth/2 + 25),-20)
  47. end
  48. if phase == 1 then
  49. HandAttack()
  50. ShootBullets2()
  51. end
  52. if phase == 1.5 then
  53. HandAttack()
  54. end
  55. if phase == 2 then
  56. ShootBullets()
  57. if timer2 >= 6*60 and phase == 2 then
  58. Encounter.Call("Animate",Encounter['Anim_To_Side_Inv'])
  59. EndWave()
  60. end
  61. end
  62. MoveBullets()
  63. CustomResize()
  64. Encounter['Flame_mid_y'] = 300 + Arena.currentheight - 130
  65. end
  66. end
  67.  
  68. l_hand = CreateProjectile("lhand",-(Arena.width/2 + 25),-20)
  69. r_hand = CreateProjectile("rhand",(Arena.width/2 + 25),-20)
  70. l_hand.sprite.alpha = 0
  71. r_hand.sprite.alpha = 0
  72.  
  73. hand_flames = {}
  74.  
  75. for i = 1,6 do
  76. local bullet = CreateProjectile("fball",-35 + i * 10,Arena.height/2 - 5)
  77. bullet.SetVar('type',"handflame")
  78. bullet.sprite.alpha = 0
  79. table.insert(hand_flames,bullet)
  80. end
  81.  
  82. function FadeHands()
  83. if fadinstate < fadintime then
  84. fadinstate = fadinstate + 1
  85. l_hand.sprite.alpha = fadinstate/fadintime
  86. r_hand.sprite.alpha = fadinstate/fadintime
  87. elseif willshoot ~= true then
  88. willshoot = true
  89. end
  90. end
  91.  
  92. function MoveHands(y)
  93. l_hand.MoveTo(-(Arena.currentwidth/2 + 25),y - 20)
  94. r_hand.MoveTo((Arena.currentwidth/2 + 25),y - 20)
  95. for i = 1,#hand_flames do
  96. local flame = hand_flames[i]
  97. flame.MoveTo(flame.x,y)
  98. end
  99. end
  100.  
  101. hand_dir = (math.random(1,2)-1.5)*2
  102. hand_speed = 0
  103. hand_targety = 0
  104. hand_y = 0
  105. flames_on = false
  106. newsize = {40,200}
  107. hand_to = "none" -- possible: "start" = no flames yet; "end" = flames on; "none" = no acceleration
  108.  
  109. hand_attack = 0
  110.  
  111. acc_start = 0.3
  112. acc_end = 0.05
  113. function SetMaxSpeed()
  114. max_speed_start = 4 + hand_attack/2
  115. max_speed_end = 1.5 + hand_attack/10
  116. end
  117.  
  118. SetMaxSpeed()
  119.  
  120. function HandAttack()
  121. hand_y = l_hand.y + 20
  122. hand_dist = hand_targety - hand_y
  123. hand_go = hand_dist/math.abs(hand_dist)
  124. if math.abs(hand_dist) - math.abs(hand_speed) < 0 then
  125. MoveHands(hand_targety)
  126. if hand_to == "start" and phase == 1 then
  127. Audio.PlaySound("bfball")
  128. hand_to = "end"
  129. for i = 1,#hand_flames do
  130. local flame = hand_flames[i]
  131. flame.sprite.alpha = 1
  132. end
  133. hand_targety = - hand_dir * (Arena.height/2 - 35 + difficulty * 5)
  134. elseif hand_to == "end" then
  135. ResizeCustomSpeed(0.2,{50,Arena.height-6})
  136. hand_to = "start"
  137. hand_dir = (math.random(1,2)-1.5)*2
  138. hand_targety = hand_dir * (Arena.height/2 + 5)
  139. hand_attack = hand_attack + 1
  140. SetMaxSpeed()
  141. if hand_attack > 3 * difficulty + 6 then
  142. phase = 1.5
  143. Encounter.Call("Animate",Encounter['Anim_From_Firewall_Mid'])
  144. hand_targety = 0
  145. hand_to = "none"
  146. ResizeCustomSpeed(5,{200,200})
  147. end
  148. for i = 1,#hand_flames do
  149. local flame = hand_flames[i]
  150. flame.sprite.alpha = 0
  151. end
  152. end
  153. if hand_to == "none" and phase == 1.5 and resize == false then
  154. phase = 2
  155. timer2 = 0
  156. end
  157. if phase ~= 1.5 then
  158. hand_speed = 0
  159. end
  160. else
  161. MoveHands(hand_y + hand_go * hand_speed)
  162. if hand_to == "start" then
  163. if hand_speed + acc_start < max_speed_start then
  164. hand_speed = hand_speed + acc_start
  165. else
  166. hand_speed = max_speed_start
  167. end
  168. elseif hand_to == "end" or hand_to == "none" then
  169. if hand_speed + acc_end < max_speed_end then
  170. hand_speed = hand_speed + acc_end
  171. else
  172. hand_speed = max_speed_end
  173. end
  174. end
  175. end
  176. end
  177.  
  178. function MoveBullets()
  179. for i = 1,#bullets do
  180. local bullet = bullets[i]
  181. if bullet.isactive then
  182. local velx = bullet.GetVar('velx')
  183. local vely = bullet.GetVar('vely')
  184. local posx = bullet.GetVar('posx')
  185. local posy = bullet.GetVar('posy')
  186. if (math.abs(posx + velx) > Arena.width/2 or
  187. math.abs(posy + vely) > Arena.height/2) and
  188. math.abs(bullet.x) < Arena.width/2 and
  189. math.abs(bullet.y) < Arena.height/2 then
  190. bullet.Remove()
  191. else
  192. local posx = posx + velx
  193. local posy = posy + vely
  194. bullet.MoveTo(posx,posy)
  195. bullet.SetVar('posx',posx)
  196. bullet.SetVar('posy',posy)
  197. end
  198. end
  199. end
  200. end
  201.  
  202. function ShootBullets()
  203. if timer2%spawntimer == 0 then
  204. side = -side
  205. Audio.PlaySound("fball")
  206. for i = -1,1 do
  207. local bullet = CreateProjectile("fball",side * source_x,source_y)
  208. local dir = Direction({Player.x,Player.y + i*20},{bullet.x,bullet.y})
  209. bullet.SetVar('velx',speed * dir[1])
  210. bullet.SetVar('vely',speed * dir[2])
  211. bullet.SetVar('posx',bullet.x)
  212. bullet.SetVar('posy',bullet.y)
  213. table.insert(bullets,bullet)
  214. end
  215. end
  216. end
  217.  
  218. function ShootBullets2()
  219. if timer2%spawntimer2 == 0 then
  220. Audio.PlaySound("fball")
  221. side = (math.random(1,2)-1.5)*2
  222. local bullet = CreateProjectile("fball",math.random(40)-20,side * (Arena.height/2 + 50))
  223. bullet.SetVar('velx',0)
  224. bullet.SetVar('vely',speed2 * -side)
  225. bullet.SetVar('posx',bullet.x)
  226. bullet.SetVar('posy',bullet.y)
  227. table.insert(bullets,bullet)
  228. end
  229. end
  230.  
  231. function Direction(postarget,posshooter)
  232. local dx = postarget[1] - posshooter[1]
  233. local dy = postarget[2] - posshooter[2]
  234. local d = math.sqrt(dx^2+dy^2)
  235. local alpha = math.acos(dx/d)
  236. if dy > 0 then
  237. alpha = alpha
  238. else
  239. alpha = - alpha
  240. end
  241. local x = math.cos(alpha)
  242. local y = math.sin(alpha)
  243. local dir = {x,y}
  244. return dir
  245. end
  246.  
  247. function OnHit(bullet)
  248. if bullet.GetVar('type') == "handflame" and hand_to ~= "end" then
  249. else
  250. Player.Hurt(5)
  251. end
  252. end
  253.  
  254. resize_speed = 0
  255. resize_target = {}
  256. resize = false
  257.  
  258. function ResizeCustomSpeed(speed,target)
  259. resize_speed = speed
  260. resize_target = target
  261. resize = true
  262. end
  263.  
  264. function CustomResize()
  265. if resize == true then
  266. local dw = resize_target[1] - Arena.width
  267. local w = dw/math.abs(dw)
  268. local dh = resize_target[2] - Arena.height
  269. local h = dh/math.abs(dh)
  270. local neow = 0
  271. local neoh = 0
  272. if math.abs(dw) - resize_speed > 0 then
  273. neow = Arena.width + w * resize_speed
  274. else
  275. neow = resize_target[1]
  276. end
  277. if math.abs(dh) - resize_speed > 0 then
  278. neoh = Arena.height + h * resize_speed
  279. else
  280. neoh = resize_target[2]
  281. end
  282. Arena.ResizeImmediate(neow,neoh)
  283. if neow == resize_target[1] and neoh == resize_target[2] then
  284. resize = false
  285. end
  286. end
  287. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement