Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.VarixDog
- local animationActive = false
- local animationEnded = false
- local animationStarted = false
- local animationTimer = 0
- local projectileID = 0
- local projectiles = {}
- local explosionSoundIDs = {4474833664, 142070127, 262562442, 5801257793}
- local mousePos = Vector3.new(0,0,0)
- local localRemote = Instance.new("RemoteEvent",player.Character)
- localRemote.Name = "mouse getter 9000"
- NLS([[
- local player = game:GetService("Players").VarixDog
- local remote = player.Character["mouse getter 9000"]
- function swait()
- game:GetService("RunService").Heartbeat:Wait()
- end
- while true do
- swait()
- remote:FireServer(player:GetMouse().Hit.Position)
- end
- ]],player.Character)
- localRemote.OnServerEvent:Connect(function(player, mousepos)
- mousePos = mousepos
- end)
- function createTorsoPartWithJoint(size, colour, material, motorOffset, motorAngle, name, shape, cfAngle)
- local backPart = Instance.new("Part", player.Character.Torso)
- backPart.CanCollide = false
- backPart.Name = name
- backPart.Size = size
- backPart.Material = material
- backPart.Color = colour
- if shape == nil then
- shape = Enum.PartType.Cylinder
- end
- backPart.Shape = shape
- --================ • Welding to torso • ===================--
- local weld = Instance.new("Motor6D", player.Character.Torso)
- weld.Part0 = player.Character.Torso
- weld.Name = name
- weld.Part1 = backPart
- weld.CurrentAngle = motorAngle
- if cfAngle then
- weld.C0 = CFrame.new(motorOffset.x, motorOffset.y, motorOffset.z) * cfAngle
- else
- weld.C0 = CFrame.new(motorOffset.x, motorOffset.y, motorOffset.z)
- end
- return backPart
- end
- function createBack()
- local decoCF = CFrame.new(0,2.7/2, 1.25)
- local decoAngle1 = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(90))
- local decoAngle2 = CFrame.fromEulerAnglesXYZ(0, math.rad(45), math.rad(90))
- local decoAngle3 = CFrame.fromEulerAnglesXYZ(0, math.rad(90), math.rad(90))
- local decoAngle4 = CFrame.fromEulerAnglesXYZ(0, math.rad(135), math.rad(90))
- --====================== • MAIN PART BEHIND TORSO • ========================--
- local part1 = createTorsoPartWithJoint(Vector3.new(3,2.5,2.5), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, Vector3.new(0,0,1.25), 1.5708, "MainBack")
- --========================= • PARTS THAT SURROUND MAIN PART • ==================================--
- local part2 = createTorsoPartWithJoint(Vector3.new(0.3,2.7,2.7),Color3.fromRGB(163, 162, 165) , Enum.Material.DiamondPlate, Vector3.new(0,1.25,1.25), 1.5708, "MainRim1")
- local part3 = createTorsoPartWithJoint(Vector3.new(0.3,2.7,2.7),Color3.fromRGB(163, 162, 165) , Enum.Material.DiamondPlate, Vector3.new(0,-1.25,1.25), 1.5708, "MainRim2")
- --======================== • TOP PART OF BARREL • ==============================--
- local part4 = createTorsoPartWithJoint(Vector3.new(1.4,2.3,2.3), Color3.fromRGB(99, 95, 98), Enum.Material.DiamondPlate, Vector3.new(0,2.7/2,1.25), 1.5708, "BeforeBarrel")
- local part5 = createTorsoPartWithJoint(Vector3.new(0.01,2.1,2.1), Color3.fromRGB(0 ,0 ,0), Enum.Material.SmoothPlastic, Vector3.new(0,2.7/2+1.4/2,1.25), 1.5708, "Hole")
- --============================== • TOP BARREL SURROUNDING PARTS • ===============================--
- local part6 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco1", Enum.PartType.Block, decoAngle1)
- local part7 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco2", Enum.PartType.Block, decoAngle2)
- local part8 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco3", Enum.PartType.Block, decoAngle3)
- local part9 = createTorsoPartWithJoint(Vector3.new(2.35, 1.395, 0.2), Color3.fromRGB(160, 95, 53), Enum.Material.Wood, decoCF, 1.5708, "Deco4", Enum.PartType.Block, decoAngle4)
- --======== • CANNON SECTION • =====================--
- local cannonP = Instance.new("Part", player.Character.Torso)
- cannonP.CanCollide = false
- cannonP.Name = "CannonPart"
- cannonP.Size = Vector3.new(2.128, 3.684, 2.128)
- cannonP.Color = Color3.fromRGB(99, 95, 98)
- local cannonMesh = Instance.new("SpecialMesh", cannonP)
- cannonMesh.MeshId = "rbxassetid://1418967188"
- cannonMesh.Scale = Vector3.new(0.9,0.35,0.9)
- local cannonM = Instance.new("Motor6D", player.Character.Torso)
- cannonM.Part0 = player.Character.Torso
- cannonM.Name = "Cannon"
- cannonM.Part1 = cannonP
- cannonM.CurrentAngle = 0
- cannonM.C0 = CFrame.new(0,2.7/2+1.5, 1.25)
- end
- function swait()
- game:GetService("RunService").Heartbeat:Wait()
- end
- function cannonRecoil(strength)
- local cannon = player.Character.Torso.Cannon
- if cannon ~= nil then
- cannon.C0 = cannon.C0:lerp(CFrame.new(0 ,2.7/2-1, 1.25), strength)
- end
- end
- function cannonReturn(strength)
- local cannon = player.Character.Torso.Cannon
- if cannon ~= nil then
- cannon.C0 = cannon.C0:lerp(CFrame.new(0,2.7/2+1.5, 1.25), strength)
- end
- end
- wait(1)
- createBack()
- function animateCannon()
- if animationTimer > 0 then
- cannonRecoil(0.2)
- elseif animationTimer < 0 then
- cannonReturn(0.01)
- end
- end
- function lerp(a, b, c)
- return a + (b - a) * c
- end
- function radialDamage(position, radius, damage)
- for i,obj in pairs(workspace:GetChildren()) do
- if obj:IsA("Model") then
- local model = obj
- local hitHum = model:FindFirstChildWhichIsA("Humanoid")
- local modelMain = model.PrimaryPart
- if hitHum then
- local mag = (modelMain.Position - position).Magnitude
- if mag < radius then
- hitHum:TakeDamage(damage)
- end
- end
- end
- end
- end
- function radialBreakJoints(position, radius)
- local part = Instance.new("Part",workspace); part.Size = Vector3.new(1,1,1); part.Anchored = true; part.CanCollide = false; part.Position = Vector3.new(radius,0,0) + position
- local part2 = Instance.new("Part",workspace); part2.Size = Vector3.new(1,1,1); part2.Anchored = true; part2.CanCollide = false; part2.Position = Vector3.new(-radius,0,0) + position
- local part3 = Instance.new("Part",workspace); part3.Size = Vector3.new(1,1,1); part3.Anchored = true; part3.CanCollide = false; part3.Position = Vector3.new(0,0,radius) + position
- local part4 = Instance.new("Part",workspace); part4.Size = Vector3.new(1,1,1); part4.Anchored = true; part4.CanCollide = false; part4.Position = Vector3.new(0,0,-radius) + position
- --============== • DETECT HUMANOIDS IN MODELS • ===================--
- for i,obj in pairs(workspace:GetChildren()) do
- if obj:IsA("Model") and obj.PrimaryPart then
- local model = obj
- local modelMain = model.PrimaryPart
- local mag = (modelMain.Position - position).Magnitude
- if mag < radius then
- local modelParts = model:GetChildren()
- for i,objM in pairs(modelParts) do
- if objM:IsA("BasePart") then
- objM:BreakJoints()
- end
- end
- end
- --============ • CHECK THEY ARENT HIDDEN IN ANOTHER MODEL • ============--
- elseif obj:IsA("Model") and not obj.PrimaryPart then
- local model = obj
- local checkForNextModel = model:FindFirstChildWhichIsA("Model")
- if checkForNextModel then
- local model2Main = nil
- if checkForNextModel.PrimaryPart == nil then
- if checkForNextModel:FindFirstChild("Torso") ~= nil then
- model2Main = checkForNextModel:FindFirstChild("Torso")
- end
- elseif checkForNextModel.PrimaryPart ~= nil then
- model2Main = checkForNextModel.PrimaryPart
- end
- local mag = (model2Main.Position - position).Magnitude
- if mag < radius then
- local mode2Parts = checkForNextModel:GetChildren()
- for i,objM in pairs(mode2Parts) do
- if objM:IsA("BasePart") then
- objM:BreakJoints()
- end
- end
- end
- end
- end
- end
- end
- function cannonFireMissileSwarm()
- animationTimer = 0.5
- for i = 1,10 do
- local missile = Instance.new("Part", workspace)
- end
- end
- --Get nuke Velocity Direction
- --Get Nuke Direction To Target
- --Get Angle between (Nuke Velocity Direction * Nuke Target Position)
- --Rotate Nukes velocity at a certain amount to get to that angle
- function cannonFireNuke(mouseMode, worldCollides, targetPart)
- local nukeTurnRate = 3
- projectileID += 1
- local projectileIndex = projectileID
- local projectileOrigin = player.Character.Torso.CannonPart.Position + Vector3.new(0, 3.684/2, 0)
- local bezierMidpoint = projectileOrigin + Vector3.new(0,30,0)
- local projectileEnd = mousePos
- local nukeDistance = (projectileOrigin - projectileEnd).Magnitude
- local nukeCollided = false
- local nukeAtTargetHeight = false
- local nukeTargetHeight = 50
- animationTimer = 0.6
- local nuke = Instance.new("Part",workspace)
- nuke.Name = "nukeMainPart"
- nuke.CanCollide = true
- nuke.Anchored = true
- nuke.Position = projectileOrigin
- nuke.Size = Vector3.new(1.667, 1.667, 5.1)
- nuke.Orientation = Vector3.new(90, -90, 0)
- local mesh = Instance.new("SpecialMesh",nuke)
- mesh.Scale = Vector3.new(0.15, 0.15, 0.1)
- mesh.MeshId = "rbxassetid://4402080069"
- mesh.TextureId = "rbxassetid://4402080160"
- local sound = Instance.new("Sound",nuke)
- sound.SoundId = "rbxassetid://7615746490"
- sound.Volume = 1
- sound:Play()
- --=============================== • NUKE THRUSTER PARTICLE EMITTERS • =======================================--
- local afterAir = Instance.new("ParticleEmitter", nuke)
- local Thruster = Instance.new("ParticleEmitter", nuke)
- local nukeAfterThrustSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(68,68,68)), ColorSequenceKeypoint.new(1, Color3.fromRGB(0,0,0))}
- local nukeThrusterSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(213,128,10)), ColorSequenceKeypoint.new(0.5, Color3.fromRGB(159,53,0)), ColorSequenceKeypoint.new(0.6, Color3.fromRGB(61,57,57)), ColorSequenceKeypoint.new(1, Color3.fromRGB(85,85,85))}
- local nukeAfterThrustSizeSeq = {NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(0.04, 0), NumberSequenceKeypoint.new(1, 10)}
- local nukeThrusterSizeSeq = {NumberSequenceKeypoint.new(0,0), NumberSequenceKeypoint.new(0.05,0), NumberSequenceKeypoint.new(0.2, 2.5), NumberSequenceKeypoint.new(0.7, 0), NumberSequenceKeypoint.new(1,0)}
- local nukeAfterThrustTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(0.75, 0.3), NumberSequenceKeypoint.new(1, 1)}
- local nukeThrusterTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(0.9, 0.35), NumberSequenceKeypoint.new(1,1)}
- afterAir.Color = ColorSequence.new(nukeAfterThrustSeq)
- Thruster.Color = ColorSequence.new(nukeThrusterSeq)
- afterAir.LightEmission = 1
- Thruster.LightEmission = 1
- afterAir.LightInfluence = 1
- Thruster.LightInfluence = 1
- afterAir.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
- Thruster.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
- afterAir.Texture = "http://www.roblox.com/asset/?id=528256032"
- Thruster.Texture = "http://www.roblox.com/asset/?id=528256032"
- afterAir.Transparency = NumberSequence.new(nukeAfterThrustTransparencySeq)
- Thruster.Transparency = NumberSequence.new(nukeThrusterTransparencySeq)
- afterAir.ZOffset = -1
- Thruster.ZOffset = 0
- afterAir.Name = "AirParticles"
- Thruster.Name = "Thruster"
- afterAir.EmissionDirection = "Back"
- Thruster.EmissionDirection = "Back"
- afterAir.Enabled = true
- Thruster.Enabled = true
- afterAir.Lifetime = NumberRange.new(1,1)
- Thruster.Lifetime = NumberRange.new(1,1)
- afterAir.Rate = 10
- Thruster.Rate = 10
- afterAir.Speed = NumberRange.new(60,60)
- Thruster.Speed = NumberRange.new(60,60)
- local nukeInfo = {
- part = nuke,
- ID = projectileID,
- originPosition = projectileOrigin,
- worldCollisions = worldCollides,
- targetPart = nil,
- followsMouse = true,
- recoilSecconds = 0.6,
- targetHeight = 50,
- turnSpeed = nukeTurnRate,
- atTargetHeight = false,
- canExplode = false,
- collision = false
- }
- table.insert(projectiles,1,nukeInfo)
- end
- function projectileUpdate()
- for index,dict in ipairs(projectiles) do
- --spawn(function()
- --print(index)
- local nuke = dict["part"]
- local projectileOrigin = dict["originPosition"]
- local nukeTargetHeight = dict["targetHeight"]
- local nukeAtTargetHeight = dict["atTargetHeight"]
- local nukeTurnRate = dict["turnSpeed"]
- local nukeCollided = dict["collision"]
- local currentNukeIndex = dict["ID"]
- --=================================== • Reach Target Height • ================================--
- if nuke.Position.Y < (projectileOrigin.Y+nukeTargetHeight) and nukeAtTargetHeight == false then
- nuke.Position = nuke.Position + nuke.CFrame.LookVector * 2
- elseif nuke.Position.Y > (projectileOrigin.Y+nukeTargetHeight) then
- dict["atTargetHeight"] = true
- end
- --====== • Optimisation • ======--
- if dict["collision"] == false then
- --==================================== • Calculations • =======================================--
- local touchedParts = nuke:GetTouchingParts()
- local touchedPartValid = false
- for index, part in ipairs(touchedParts) do
- if not tostring(part.Name) == "nukeMainPart" or part.Parent ~= player.Character then
- --print("Collided With Non-Missile / Character Part")
- --dict["collision"] = true
- end
- end
- --print(touchedParts)
- if dict["collision"] == true then
- spawn(function()
- dict["collision"] = true
- nuke.Transparency = 1
- nuke.CanCollide = false
- for i,obj in pairs(nuke:GetChildren()) do
- if obj:IsA("ParticleEmitter") then
- obj.Enabled = false
- end
- end
- local collisionPosition = Vector3.new(nuke.Position.X, nuke.Position.Y-1, nuke.Position.Z)
- local particlePart = Instance.new("Part",workspace)
- particlePart.Anchored = true
- particlePart.CanCollide = false
- particlePart.Size =- Vector3.new(0.1, 0.1, 0.1)
- particlePart.Transparency = 1
- particlePart.Position = collisionPosition
- game:GetService("Debris"):AddItem(particlePart, 3)
- local ExplosionSphere = Instance.new("ParticleEmitter", particlePart)
- local ExplosionRing = Instance.new("ParticleEmitter", particlePart)
- local nukeAfterThrustSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(106,106,106)), ColorSequenceKeypoint.new(1, Color3.fromRGB(106,106,106))}
- local nukeThrusterSeq = {ColorSequenceKeypoint.new(0, Color3.fromRGB(135,135,135)), ColorSequenceKeypoint.new(1, Color3.fromRGB(135,135,135))}
- local nukeAfterThrustSizeSeq = {NumberSequenceKeypoint.new(0, 5), NumberSequenceKeypoint.new(1, 10)}
- local nukeThrusterSizeSeq = {NumberSequenceKeypoint.new(0,5), NumberSequenceKeypoint.new(1, 10)}
- local nukeAfterThrustTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(1, 1)}
- local nukeThrusterTransparencySeq = {NumberSequenceKeypoint.new(0,0.25), NumberSequenceKeypoint.new(1,1)}
- ExplosionSphere.Color = ColorSequence.new(nukeAfterThrustSeq)
- ExplosionRing.Color = ColorSequence.new(nukeThrusterSeq)
- ExplosionSphere.LightEmission = 0
- ExplosionRing.LightEmission = 0
- ExplosionSphere.LightInfluence = 1
- ExplosionRing.LightInfluence = 1
- ExplosionSphere.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
- ExplosionRing.Size = NumberSequence.new(nukeAfterThrustSizeSeq)
- ExplosionSphere.Texture = "http://www.roblox.com/asset/?id=528256032"
- ExplosionRing.Texture = "http://www.roblox.com/asset/?id=528256032"
- ExplosionSphere.Transparency = NumberSequence.new(nukeAfterThrustTransparencySeq)
- ExplosionRing.Transparency = NumberSequence.new(nukeThrusterTransparencySeq)
- ExplosionSphere.ZOffset = 0
- ExplosionRing.ZOffset = -1
- ExplosionSphere.Name = "ExplosionA"
- ExplosionRing.Name = "ExplosionB"
- ExplosionSphere.EmissionDirection="Top"
- ExplosionRing.EmissionDirection= "Front"
- ExplosionSphere.Acceleration = Vector3.new(0,-30,0)
- ExplosionRing.Acceleration = Vector3.new(0,-5,0)
- ExplosionSphere.Enabled = false
- ExplosionRing.Enabled = false
- ExplosionSphere.Lifetime = NumberRange.new(1,3)
- ExplosionRing.Lifetime = NumberRange.new(1,3)
- ExplosionSphere.Rate = 200
- ExplosionRing.Rate = 200
- ExplosionSphere.Drag = 10
- ExplosionRing.Drag = 10
- ExplosionSphere.Speed = NumberRange.new(180,220)
- ExplosionRing.Speed = NumberRange.new(300,300)
- ExplosionSphere.SpreadAngle = Vector2.new(180,180)
- ExplosionRing.SpreadAngle = Vector2.new(1,180)
- radialBreakJoints(collisionPosition, 20)
- ExplosionSphere:Emit(300)
- ExplosionRing:Emit(300)
- wait(1.1)
- nuke:Destroy()
- for index,dict in pairs(projectiles) do
- if currentNukeIndex == dict["ID"] then
- table.remove(projectiles,index)
- end
- end
- end)
- end
- local targPos = Vector3.new(0,50,0)
- if dict["followsMouse"] == true then
- targPos = mousePos
- elseif dict["followMouse"] == false then
- targPos = dict["targetPart"].Position
- end
- local nukeVelocityDir = nuke.CFrame.LookVector
- local nukeTargetDir = CFrame.new(nuke.Position, targPos).LookVector
- local nukeDegreesToTarget = math.deg( math.acos(nukeVelocityDir.unit:Dot(nukeTargetDir.unit)) )
- local nukeAxisToTarget = nukeVelocityDir:Cross(nukeTargetDir)
- local nukeTurnAmount = math.clamp(nukeDegreesToTarget, -nukeTurnRate, nukeTurnRate)
- --============================== • Linear Rotation Part • ========================================--
- if nukeDegreesToTarget > 0 and nukeAtTargetHeight == true then
- local rotCF = (CFrame.fromAxisAngle(nukeAxisToTarget ,math.rad(nukeTurnAmount)) * nuke.CFrame)
- local x, y, z = rotCF:ToEulerAnglesYXZ()
- --print((tostring(x) .. " " .. tostring(y) .. " " .. tostring(z)))
- nuke.CFrame = CFrame.new(nuke.Position) * CFrame.fromEulerAnglesYXZ(x,y,z)
- end
- --============ • Move Part • =========--
- nuke.Position = nuke.Position + nuke.CFrame.LookVector * 2
- elseif dict["collision"] == true then
- end
- --end)
- end
- end
- --Planned: Missile, Sentry, Bowling ball, weird other stuff
- spawn(function()
- game:GetService("RunService").Heartbeat:Connect(function(step)
- animationTimer = animationTimer - step
- animateCannon()
- projectileUpdate()
- end)
- end)
- wait(2)
- cannonFireNuke()
- wait(2.5)
- cannonFireNuke()
- wait(2.5)
- cannonFireNuke()
- while wait(2) do
- spawn(function()
- end)
- end
- local sound = Instance.new("Sound",workspace.VarixDog.Torso)
- sound.SoundId = "rbxassetid://5232019423"
- sound.Volume = 0.5
- sound.MaxDistance = 300
- sound.Looped = true
- sound:Play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement