Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2024
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. bullets = {}
  2.  
  3.  
  4. gforcemult = 1
  5. timer = 0
  6. Arena.resize(360, 360)
  7.  
  8. function Update()
  9.     timer = timer + 1
  10.     if timer > 16 then
  11.         attractor = CreateProjectile('nova/attractor',0,0)
  12.     end
  13.     if timer%4==0 and timer > 16 and timer < 60 * 2 then
  14.         bullet = 0
  15.         dir = math.rad((timer %90))*4
  16.         bullet = CreateProjectile('nova/pellet', math.sin(dir)*Arena.width*2/4, math.cos(dir)*Arena.width*2/4)
  17.         table.insert(bullets, bullet)
  18.  
  19.     end
  20.     if timer > 60*3 and gforcemult > -1 and timer < 60*4 then
  21.         gforcemult = gforcemult -0.1
  22.     end
  23.     if timer > 60*4  and gforcemult < 4 then
  24.         gforcemult = gforcemult + 0.4
  25.     end
  26.     if timer > 16 then
  27.         for i=1,#bullets do -- update all bullets based on velocity
  28.             local bullet = bullets[i]
  29.             if bullet.isactive then
  30.                 local velx = bullet.GetVar('velx')
  31.                 local vely = bullet.GetVar('vely')
  32.                 local newposx = bullet.x + velx
  33.                 local newposy = bullet.y + vely
  34.  
  35.                 bullet.MoveTo(newposx, newposy)
  36.  
  37.                 xdist = attractor.x - bullet.x
  38.                 ydist = attractor.y - bullet.y
  39.  
  40.                 angle = math.atan2(xdist, ydist)
  41.                 length = math.sqrt(xdist*xdist + ydist*ydist)
  42.                 power = 1/length*length
  43.  
  44.                 velx = velx + power*gforcemult*xdist/length
  45.                 vely = vely + power*gforcemult*ydist/length
  46.  
  47.                 if(timer < 60*3) then
  48.                     velx = velx * (0.97 - math.max(0, 60-length)/60)
  49.                     vely = vely * (0.97 - math.max(0, 60-length)/60)
  50.                 else
  51.                     velx = velx * (0.97 - (0.001 * length))
  52.                     vely = vely * (0.97 - (0.001 * length))
  53.                 end
  54.  
  55.                 bullet.SetVar('velx',velx)
  56.                 bullet.SetVar('vely',vely)
  57.  
  58.             end
  59.         end
  60.     end
  61. end
  62.  
  63. function OnHit(bullet)
  64.     bullet.Remove()
  65.     Player.Hurt(2,0.2)
  66.     Audio.PlaySound('hit')
  67. end
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement