Advertisement
EngiN33R

Projectile System

Jun 9th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. --PLEASE DO NOT COMMENT ABOUT EFFICIENCY UNLESS THERE'S SOMETHING THAT'LL LAG PLAYERS TO THE POINT OF UNPLAYABILITY!
  2.  
  3. project=doublearray(32,4096,0)
  4. curproject=initArray2(32,1)
  5. projectpos=doublearray(32,4096,{0,0})
  6.  
  7.  
  8. function projectileShoot(id,proj,rot,w)
  9.     project[curproject[id]]=image(proj,player(id,"x"),player(id,"y"),3)
  10.     projectpos[id][curproject[id]][1]=player(id,"x")
  11.     projectpos[id][curproject[id]][2]=player(id,"y")
  12.     imagepos(project[curproject[id]],projectpos[id][curproject[id]][1],projectpos[id][curproject[id]][2],rot)
  13.     local prid=curproject[id]
  14.     projectileFly(id,proj,rot,w,prid)
  15.     curproject[id]=curproject[id]+1
  16. end
  17.  
  18. function projectileFly(id,proj,rot,w,prid)
  19.     local dx,dy=csconvert(rot,projectpos[id][prid][1],projectpos[id][prid][2],equipment[w].projspeed)
  20.     imagepos(project[prid],dx,dy,rot)
  21.     projectpos[id][prid][1],projectpos[id][prid][2]=dx,dy
  22.     msg("In flight")
  23.     for pid=1,32 do
  24.         if (player(pid,"exists") and pid~=id) then
  25.             if (math.floor(dx/32)~=player(pid,"tilex") and math.floor(dy/32)~=player(pid,"tiley") and tile(math.floor(dx/32),math.floor(dy/32),"frame")==0) then
  26.                 timer(1,"parse","lua projectileFly("..id..",".."\""..proj.."\","..rot..","..w..","..prid..")")
  27.                 msg("In flight timer")
  28.             else
  29.                 if (shield[pid]>=equipment[w].projsdmg) then
  30.                     shield[pid]=shield[pid]-equipment[w].projsdmg
  31.                 else
  32.                     parse("sethealth "..pid.." "..player(pid,"health")-equipment[w].projhdmg)
  33.                 end
  34.                 msg("Found target")
  35.             end
  36.             msg("LOLWUT")
  37.         end
  38.     end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement