Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PRESENTED BY: SCRIPTLEAK
- //DESC.
- This is the entire script for Crazyman's Perilous Skys Missile Control.
- It basically is a heatseaking missile that uses a very simple time/distance/speed manipulation to predict
- where an enemies plane will be
- //SCRIPT [FULL]
- wait()
- local fly = true
- while (not script:findFirstChild("Missile")) do wait() end
- local missile = script.Missile.Value
- game:GetService("Debris"):AddItem(missile,15)
- game:GetService("Debris"):AddItem(script,15)
- local pos = missile.Position
- local dist = 0
- local track
- while (not script:findFirstChild("Speed")) do wait() end
- local spd = (script.Speed.Value)
- local max = 500
- local inc = 10
- local start = time()
- local expire = 8
- local expired = false
- local contacted = false
- local isKill = false
- local pointCostForMiss = 2
- function waitFor(object,array)
- for _,name in pairs(array) do
- while (not object:findFirstChild(name)) do wait() end
- end
- end
- function showPtAdd(player,add,txt)
- local pt = Instance.new("IntValue")
- local msg = Instance.new("StringValue",pt)
- pt.Name,msg.Name = "PtChange","Msg"
- pt.Value,msg.Value = add,txt
- pt.Parent = player
- end
- function contact(isPlane,obj,pln,plr,targ)
- track.Value = false
- contacted,fly = true,false
- targ.MLocked.Value = (targ.MLocked.Value-1)
- if (isPlane) then
- local plr2 = pln.Player.Value
- plr.Locked.Value = nil
- if ((isPlane) and (pln.Team.Value ~= plr.TeamColor) and (pln.Health.Value > 0) and (not expired)) then
- isKill = true
- pln.Health.Shot.PlayerName.Value = plr.Name
- pln.Health.Shot.Value = true
- pln.Health.Value = 0
- plr.leaderstats.Kills.Value = (plr.leaderstats.Kills.Value+1)
- plr.Stats.Kills.Missiles.Value = (plr.Stats.Kills.Missiles.Value+1)
- local ptAdd = ((plr.Bonus.Value and 100 or 50)+math.ceil(dist/100))
- showPtAdd(plr,ptAdd,"Missile Kill")
- plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value+ptAdd)
- plr.PlayerGui.Gui.Main.Hit.Visible = true
- if (plr2) then
- plr.PlayerGui.Gui.Main.Killed.Insert.Value = plr2.Name
- plr2.Stats.Deaths.Missiles.Value = (plr2.Stats.Deaths.Missiles.Value+1)
- end
- else
- plr.PlayerGui.Gui.Main.Missed.Visible = true
- end
- elseif (plr) then
- plr.PlayerGui.Gui.Main.Missed.Visible = true
- end
- missile.Smoke.Smoke.Enabled = false
- missile.Transparency = 1
- missile.Anchored = true
- delay(5,function() missile:remove() end)
- end
- function dodged(targ)
- local plr = targ.Player.Value
- if ((not plr) or (not plr.Parent) or (targ.Health.Value <= 0)) then return end
- local ptAdd = 5
- showPtAdd(plr,ptAdd,"Missile Dodged")
- plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value+ptAdd)
- plr.Stats.MissilesFired.Dodged.Value = (plr.Stats.MissilesFired.Dodged.Value+1)
- end
- function calcNewPos(targ)
- local main = targ.Functions.Main
- local dist = (main.Position-missile.Position).magnitude
- local t = (dist/(spd == 0 and 1 or spd))
- local d = (targ.CurrentSpeed.Value*t)
- local newPos = (main.Position+(main.CFrame.lookVector*d))
- local newDist = (newPos-missile.Position).magnitude
- local mult = (dist < 100 and (1-(dist/100)) or 0)
- newDist = (newDist-(math.abs(newDist-dist)*mult))
- t = (newDist/(spd == 0 and 1 or spd))
- local nextPos = CFrame.new(missile.Position,(main.Position+(main.CFrame.lookVector*targ.CurrentSpeed.Value*t)))
- return nextPos
- end
- function fire()
- waitFor(script,{"Missile","Player","Target","Origin","LS","Track"})
- track = script.Track
- track.Parent = missile
- track.Value = true
- local plr,targ,origin,ls = script.Player.Value,script.Target.Value,script.Origin.Value,script.LS.Value
- plr.Stats.MissilesFired.Value = (plr.Stats.MissilesFired.Value+1)
- plr.Locked.Value = targ
- targ.MLocked.Value = (targ.MLocked.Value+1)
- local function isPlane(obj)
- for _,v in pairs(game.Workspace:GetChildren()) do
- if ((v:IsAncestorOf(obj)) and (v:findFirstChild("Player")) and (v.Player.Value) and (v ~= origin)) then
- return v
- end
- end
- end
- local function hasTarget()
- 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
- end
- local function onTime()
- local t = (time()-start)
- if ((t >= expire) and (not contacted)) then
- track.Value = false
- expired = true
- plr.Locked.Value = nil
- targ.MLocked.Value = (targ.MLocked.Value-1)
- if (fly) then
- plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
- showPtAdd(plr,-pointCostForMiss,"Missile Missed")
- end
- contact(false)
- else return true
- end
- end
- missile.Touched:connect(function(obj)
- if ((contacted) or (obj.Name == "Smoke") or (obj:IsDescendantOf(origin))) then return end
- local pln = isPlane(obj)
- if ((not pln) and (fly)) then
- plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
- showPtAdd(plr,-pointCostForMiss,"Missile Missed")
- end
- contact(pln,obj,pln,plr,targ) -- Arg #1 acting as boolean
- end)
- local newCF = calcNewPos(targ)
- local differ = (missile.CFrame.lookVector-newCF.lookVector).magnitude
- newCF = (differ > ls and CFrame.new(missile.Position,targ.Functions.Main.Position) or newCF)
- missile.Gyro.cframe = newCF
- delay(0,function()
- while ((missile.Parent) and (not contacted)) do
- dist = (dist+(pos-missile.Position).magnitude)
- pos = missile.Position
- spd = (spd+inc)
- spd = (spd > max and max or spd)
- local curC = missile.Gyro.cframe
- local newC = calcNewPos(targ)
- local diff = (curC.lookVector-newC.lookVector).magnitude
- newC = (diff > ls and CFrame.new(missile.Position,targ.Functions.Main.Position) or newC)
- diff = (curC.lookVector-newC.lookVector).magnitude
- local breakLock = false
- if ((diff > ls) and (fly)) then
- breakLock = true
- fly = false
- targ.MLocked.Value = (targ.MLocked.Value-1)
- plr.leaderstats.Points.Value = (plr.leaderstats.Points.Value-pointCostForMiss)
- delay(1,function()
- if (not isKill) then
- showPtAdd(plr,-pointCostForMiss,"Missile Missed")
- plr.PlayerGui.Gui.Main.Missed.Visible = true
- dodged(targ)
- end
- end)
- end
- missile.Gyro.cframe = (fly and hasTarget() and onTime() and newC or curC)
- missile.Move.velocity = (missile.CFrame.lookVector*spd)
- if (not breakLock) then onTime() end
- wait()
- end
- end)
- end
- fire()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement