Advertisement
NegotiationDry

CodeForWave

Mar 9th, 2024
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. wavetimer = 0
  2. --H rook
  3. hRook = CreateProjectile("R", 60, 40)
  4. hRook.SetVar('hxspeed', 0)
  5. hRook.SetVar('hyspeed', 0)
  6. --A Rook
  7. aRook = CreateProjectile("R", -60, 40)
  8. aRook.SetVar('axspeed', 0)
  9. aRook.SetVar('ayspeed', 0)
  10.  
  11.  
  12.  
  13. function Update()
  14.    --Rooks follow the player in their own x and y coordinates
  15.     if wavetimer < 60 then
  16.         local HxDif = Player.x - hRook.x
  17.         local HyDif = Player.y - hRook.y
  18.         local hxspeed = hRook.GetVar('hxspeed') / 2 + HxDif / 50
  19.         local hyspeed = hRook.GetVar('hyspeed') / 2 + HyDif / 50
  20.         hRook.Move(hxspeed, 0)
  21.         hRook.SetVar('hxspeed', hxspeed)
  22.         hRook.SetVar('hyspeed', hyspeed)
  23.  
  24.         local AxDif = Player.x - aRook.x
  25.         local AyDif = Player.y - aRook.y
  26.         local axspeed = aRook.GetVar('axspeed') / 2 + AxDif / 50
  27.         local ayspeed = aRook.GetVar('ayspeed') / 2 + AyDif / 50
  28.         aRook.Move(0, ayspeed)
  29.         aRook.SetVar('axspeed', axspeed)
  30.         aRook.SetVar('ayspeed', ayspeed)
  31.     --Rooks move forward to actually attack the player
  32.     elseif wavetimer < 180 then
  33.         hRook.Move(0, -1)
  34.         aRook.Move(1, 0)
  35.         if hRook.y < -40 then
  36.             hRook.MoveTo(hRook.x, -40)
  37.         end
  38.     --Rooks stop
  39.     elseif wavetimer < 240 then
  40.         local HxDif = Player.x - hRook.x
  41.         local HyDif = Player.y - hRook.y
  42.         local hxspeed = hRook.GetVar('hxspeed') / 2 + HxDif / 50
  43.         local hyspeed = hRook.GetVar('hyspeed') / 2 + HyDif / 50
  44.         hRook.Move(hxspeed, 0)
  45.         hRook.SetVar('hxspeed', hxspeed)
  46.         hRook.SetVar('hyspeed', hyspeed)
  47.  
  48.         local AxDif = Player.x - aRook.x
  49.         local AyDif = Player.y - aRook.y
  50.         local axspeed = aRook.GetVar('axspeed') / 2 + AxDif / 50
  51.         local ayspeed = aRook.GetVar('ayspeed') / 2 + AyDif / 50
  52.         aRook.Move(0, ayspeed)
  53.         aRook.SetVar('axspeed', axspeed)
  54.         aRook.SetVar('ayspeed', ayspeed)
  55.     elseif wavetimer < 360 then
  56.         hRook.Move(0, 1)
  57.         aRook.Move(-1, 0)
  58.         if hRook.y > 40 then --This code shouldn't work, the coordinates given are completely wrong. And yet work it does. Strange, I won't touch it tho
  59.             hRook.MoveTo(hRook.x, 40)
  60.         end
  61.         if aRook.x < -60 then
  62.             aRook.MoveTo(aRook.X,40)
  63.         end
  64.     --I'm ngl this doesn't really serve a purpose? It just let's the moves above actually play
  65.     else
  66.         if hRook.x ~= 60 then
  67.             hRook.Move(1,0)
  68.         elseif hRook.y ~= 40 then
  69.             hRook.Move(0,1)
  70.  
  71.         elseif aRook.y ~= 40 then
  72.             aRook.Move(0,1)
  73.         elseif aRook.y ~= -60 then
  74.             aRook.Move(-1,0)
  75.         end
  76.  
  77.     end
  78.  
  79.     wavetimer = wavetimer + 1
  80. end
Tags: Undertale
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement