Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  1. ---------------------
  2. -- Furry Framework --
  3. ---------------------
  4. local Furry = _G.Furry
  5. ---------------------
  6. -- Roblox Services --
  7. ---------------------
  8. local RunService = Furry:GetService("RunService")
  9. -------------
  10. -- Remotes --
  11. -------------
  12. local ProjectileCreationRequest = Furry:CreateRemote("Remotes/Game/Projectiles/", "Request", "RemoteEvent")
  13. local ProjectileCreatedEvent = Furry:CreateRemote("Remotes/Game/Projectiles/", "Created", "RemoteEvent")
  14.  
  15. local Projectiles = {
  16.     Active = {},
  17.     Inactive = {},
  18. }
  19.  
  20. local function CreateProjectile(Owner, Type, Speed, Damage, Origin, Direction, IgnoreList)
  21.     local Projectile
  22.     if #Projectiles.Inactive < 1 then
  23.         local Identity = "Projectile_"..tostring(tick())
  24.         Projectile = {
  25.             [1] = Identity,
  26.             [2] = Owner,
  27.             [3] = Type,
  28.             [4] = Speed,
  29.             [5] = Damage,
  30.             [6] = Origin,
  31.             [7] = Direction,
  32.             [8] = IgnoreList,
  33.             [9] = tick(), -- Activated
  34.             Part = Furry:Create("Part", {
  35.                 Name = "Tracer",
  36.                 Anchored = true,
  37.                 CanCollide = false,
  38.                 BrickColor = BrickColor.new("Brick yellow"),
  39.                 Material = Enum.Material.Neon,
  40.                 Size = Vector3.new(0.3,0.3,4),
  41.                 Parent = game.Workspace.RayIgnore,
  42.             })
  43.         }
  44.     else
  45.         local Projectileindex = #Projectiles.Inactive
  46.         Projectile = {
  47.             [1] = Projectiles.Inactive[Projectileindex][1],
  48.             [2] = Owner,
  49.             [3] = Type,
  50.             [4] = Speed,
  51.             [5] = Damage,
  52.             [6] = Origin,
  53.             [7] = Direction,
  54.             [8] = IgnoreList,
  55.             [9] = tick(), -- Activated
  56.             Part = Projectiles.Inactive[Projectileindex].Part,
  57.         }
  58.         table.remove(Projectiles.Inactive, Projectileindex)
  59.     end
  60.     Projectile.Part.BrickColor = BrickColor.new("Brick yelllow")
  61.     Projectile.Part.CFrame = CFrame.new(Origin, Origin + Direction)
  62.     Projectiles.Active[#Projectiles.Active+1] = Projectile
  63.     ProjectileCreatedEvent:FireAllClients(Projectile)
  64. end
  65.  
  66. ProjectileCreationRequest.OnServerEvent:connect(function(Player, Origin, Direction)
  67.     local Owner = Player  -- Will not always be Player
  68.     local Type = nil -- Will be "Bullet" or "missile" or "Something else" in the future.
  69.     local Speed = 80
  70.     local Damage = 0
  71.     local IgnoreList = {game.Workspace.RayIgnore, Player.Character}
  72.     CreateProjectile(Owner, Type, Speed, Damage, Origin, Direction, IgnoreList)
  73. end)
  74.  
  75. local Loop = coroutine.wrap(function()
  76.     local Heartbeat = 0
  77.     while true do
  78.         Heartbeat = RunService.Heartbeat:wait()
  79.         for Index = #Projectiles.Active, 1, -1 do
  80.             local Projectile = Projectiles.Active[Index]
  81.             local ProjectileSpeed = Projectile[4]
  82.             local RayOrigin = Projectile[6]
  83.             local Direction = Projectile[7]
  84.             local TimeElasped = tick() - Projectile[9]
  85.             if TimeElasped < 5 then
  86.                 --local DistanceTraveled = ProjectileSpeed * TimeElasped
  87.                 --local RayOrigin = CFrame.new(Origin, Origin + Direction) * Vector3.new(0,0, -DistanceTraveled)           
  88.                 local RayLength = ProjectileSpeed * Heartbeat          
  89.                 local Velocity = Direction * RayLength         
  90.                 local IgnoreList = Projectile[8]
  91.                 local Hit, Position, Surface = Furry:RaycastWithIgnoreList(RayOrigin, Velocity, IgnoreList)
  92.                 if Hit then
  93.                     Projectile.Part.BrickColor = BrickColor.new("Shamrock")
  94.                     table.remove(Projectiles.Active, Index)
  95.                     Projectiles.Inactive[#Projectiles.Inactive+1] = Projectile
  96.                 end
  97.                 Projectile[6] = Position
  98.                 Projectile.Part.CFrame = CFrame.new(Position, Position + Direction)
  99.             else
  100.                 Projectile.Part.BrickColor = BrickColor.new("Bright red")
  101.                 table.remove(Projectiles.Active, Index)
  102.                 Projectiles.Inactive[#Projectiles.Inactive+1] = Projectile 
  103.             end
  104.         end
  105.     end
  106. end)
  107. Loop()
  108.  
  109. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement