Advertisement
princeofheaven

Untitled

Jul 20th, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.05 KB | None | 0 0
  1.  
  2.  
  3. PRESENTED BY: SCRIPTLEAK
  4.  
  5. //DESC.
  6.  
  7. This is the entire script for Crazyman's Perilous Skys Missile Control.
  8.  
  9. It basically is a heatseaking missile that uses a very simple time/distance/speed manipulation to predict
  10. where an enemies plane will be
  11.  
  12. //SCRIPT [FULL]
  13.  
  14. wait()
  15. local fly = true
  16. while (not script:findFirstChild("Missile")) do wait() end
  17. local missile = script.Missile.Value
  18. game:GetService("Debris"):AddItem(missile,15)
  19. game:GetService("Debris"):AddItem(script,15)
  20. local pos = missile.Position
  21. local dist = 0
  22. local track
  23.  
  24. while (not script:findFirstChild("Speed")) do wait() end
  25. local spd = (script.Speed.Value)
  26. local max = 500
  27. local inc = 10
  28.  
  29. local start = time()
  30. local expire = 8
  31. local expired = false
  32. local contacted = false
  33. local isKill = false
  34.  
  35. local pointCostForMiss = 2
  36.  
  37. function waitFor(object,array)
  38. for _,name in pairs(array) do
  39. while (not object:findFirstChild(name)) do wait() end
  40. end
  41. end
  42.  
  43. function showPtAdd(player,add,txt)
  44. local pt = Instance.new("IntValue")
  45. local msg = Instance.new("StringValue",pt)
  46. pt.Name,msg.Name = "PtChange","Msg"
  47. pt.Value,msg.Value = add,txt
  48. pt.Parent = player
  49. end
  50.  
  51. function contact(isPlane,obj,pln,plr,targ)
  52. track.Value = false
  53. contacted,fly = true,false
  54. targ.MLocked.Value = (targ.MLocked.Value-1)
  55. if (isPlane) then
  56. local plr2 = pln.Player.Value
  57. plr.Locked.Value = nil
  58. if ((isPlane) and (pln.Team.Value ~= plr.TeamColor) and (pln.Health.Value > 0) and (not expired)) then
  59. isKill = true
  60. pln.Health.Shot.PlayerName.Value = plr.Name
  61. pln.Health.Shot.Value = true
  62. pln.Health.Value = 0
  63. plr.leaderstats.Kills.Value = (plr.leaderstats.Kills.Value+1)
  64. plr.Stats.Kills.Missiles.Value = (plr.Stats.Kills.Missiles.Value+1)
  65. local ptAdd = ((plr.Bonus.Value and 100 or 50)+math.ceil(dist/100))
  66. showPtAdd(plr,ptAdd,"Missile Kill")
  67. plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value+ptAdd)
  68. plr.PlayerGui.Gui.Main.Hit.Visible = true
  69. if (plr2) then
  70. plr.PlayerGui.Gui.Main.Killed.Insert.Value = plr2.Name
  71. plr2.Stats.Deaths.Missiles.Value = (plr2.Stats.Deaths.Missiles.Value+1)
  72. end
  73. else
  74. plr.PlayerGui.Gui.Main.Missed.Visible = true
  75. end
  76. elseif (plr) then
  77. plr.PlayerGui.Gui.Main.Missed.Visible = true
  78. end
  79. missile.Smoke.Smoke.Enabled = false
  80. missile.Transparency = 1
  81. missile.Anchored = true
  82. delay(5,function() missile:remove() end)
  83. end
  84.  
  85. function dodged(targ)
  86. local plr = targ.Player.Value
  87. if ((not plr) or (not plr.Parent) or (targ.Health.Value <= 0)) then return end
  88. local ptAdd = 5
  89. showPtAdd(plr,ptAdd,"Missile Dodged")
  90. plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value+ptAdd)
  91. plr.Stats.MissilesFired.Dodged.Value = (plr.Stats.MissilesFired.Dodged.Value+1)
  92. end
  93.  
  94. function calcNewPos(targ)
  95. local main = targ.Functions.Main
  96. local dist = (main.Position-missile.Position).magnitude
  97. local t = (dist/(spd == 0 and 1 or spd))
  98. local d = (targ.CurrentSpeed.Value*t)
  99. local newPos = (main.Position+(main.CFrame.lookVector*d))
  100. local newDist = (newPos-missile.Position).magnitude
  101. local mult = (dist < 100 and (1-(dist/100)) or 0)
  102. newDist = (newDist-(math.abs(newDist-dist)*mult))
  103. t = (newDist/(spd == 0 and 1 or spd))
  104. local nextPos = CFrame.new(missile.Position,(main.Position+(main.CFrame.lookVector*targ.CurrentSpeed.Value*t)))
  105. return nextPos
  106. end
  107.  
  108. function fire()
  109. waitFor(script,{"Missile","Player","Target","Origin","LS","Track"})
  110. track = script.Track
  111. track.Parent = missile
  112. track.Value = true
  113. local plr,targ,origin,ls = script.Player.Value,script.Target.Value,script.Origin.Value,script.LS.Value
  114. plr.Stats.MissilesFired.Value = (plr.Stats.MissilesFired.Value+1)
  115. plr.Locked.Value = targ
  116. targ.MLocked.Value = (targ.MLocked.Value+1)
  117. local function isPlane(obj)
  118. for _,v in pairs(game.Workspace:GetChildren()) do
  119. if ((v:IsAncestorOf(obj)) and (v:findFirstChild("Player")) and (v.Player.Value) and (v ~= origin)) then
  120. return v
  121. end
  122. end
  123. end
  124. local function hasTarget()
  125. if ((targ) and (targ.Parent) and (targ.Player.Value) and (not targ.Safe.Value) and (missile.Position.y > 0)) then return true else plr.PlayerGui.Gui.Main.Missed.Visible = true track.Value = false end
  126. end
  127. local function onTime()
  128. local t = (time()-start)
  129. if ((t >= expire) and (not contacted)) then
  130. track.Value = false
  131. expired = true
  132. plr.Locked.Value = nil
  133. targ.MLocked.Value = (targ.MLocked.Value-1)
  134. if (fly) then
  135. plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
  136. showPtAdd(plr,-pointCostForMiss,"Missile Missed")
  137. end
  138. contact(false)
  139. else return true
  140. end
  141. end
  142. missile.Touched:connect(function(obj)
  143. if ((contacted) or (obj.Name == "Smoke") or (obj:IsDescendantOf(origin))) then return end
  144. local pln = isPlane(obj)
  145. if ((not pln) and (fly)) then
  146. plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
  147. showPtAdd(plr,-pointCostForMiss,"Missile Missed")
  148. end
  149. contact(pln,obj,pln,plr,targ) -- Arg #1 acting as boolean
  150. end)
  151.  
  152.  
  153. local newCF = calcNewPos(targ)
  154. local differ = (missile.CFrame.lookVector-newCF.lookVector).magnitude
  155. newCF = (differ > ls and CFrame.new(missile.Position,targ.Functions.Main.Position) or newCF)
  156. missile.Gyro.cframe = newCF
  157.  
  158.  
  159. delay(0,function()
  160. while ((missile.Parent) and (not contacted)) do
  161. dist = (dist+(pos-missile.Position).magnitude)
  162. pos = missile.Position
  163. spd = (spd+inc)
  164. spd = (spd > max and max or spd)
  165. local curC = missile.Gyro.cframe
  166. local newC = calcNewPos(targ)
  167. local diff = (curC.lookVector-newC.lookVector).magnitude
  168. newC = (diff > ls and CFrame.new(missile.Position,targ.Functions.Main.Position) or newC)
  169. diff = (curC.lookVector-newC.lookVector).magnitude
  170. local breakLock = false
  171. if ((diff > ls) and (fly)) then
  172. breakLock = true
  173. fly = false
  174. targ.MLocked.Value = (targ.MLocked.Value-1)
  175. plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
  176. delay(1,function()
  177. if (not isKill) then
  178. showPtAdd(plr,-pointCostForMiss,"Missile Missed")
  179. plr.PlayerGui.Gui.Main.Missed.Visible = true
  180. dodged(targ)
  181. end
  182. end)
  183. end
  184. missile.Gyro.cframe = (fly and hasTarget() and onTime() and newC or curC)
  185. missile.Move.velocity = (missile.CFrame.lookVector*spd)
  186. if (not breakLock) then onTime() end
  187. wait()
  188. end
  189. end)
  190. end
  191.  
  192. fire()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement