Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.74 KB | None | 0 0
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile( "shared.lua" )
  3. include( 'shared.lua' )
  4.  
  5. ENT.Sound = "50cal.wav"//"weapons/shotgun/shotgun_dbl_fire7.wav"
  6. ENT.Model = "models/Sillirion/weapons/turretA/turret_base.mdl"
  7.  
  8. ENT.HealthVal = 2000
  9.  
  10.  
  11. function ENT:SpawnFunction( ply, tr)
  12.  
  13.     local SpawnPos = tr.HitPos + tr.HitNormal * 100
  14.     local ent = ents.Create( "Testing" )
  15.     ent:SetPos( SpawnPos )
  16.     ent:Spawn()
  17.     ent:Activate()
  18.    
  19.     return ent
  20.    
  21. end
  22.  
  23. function ENT:Initialize()
  24.  
  25.     self.Entity:SetModel( self.Model )
  26.     self.Entity:SetVar('DoAttack',CurTime())
  27.     self.Entity:PhysicsInit( SOLID_VPHYSICS )
  28.     self.Entity:SetMoveType( MOVETYPE_VPHYSICS )   
  29.     self.Entity:SetSolid( SOLID_VPHYSICS )
  30.     self.PhysObj = self.Entity:GetPhysicsObject()
  31.    
  32.     if ( self.PhysObj:IsValid() ) then
  33.    
  34.         self.PhysObj:Wake()
  35.         self.PhysObj:EnableGravity(true)
  36.     end
  37.    
  38.           self.TurretBase  = ents.Create("prop_physics")                          
  39.           self.TurretBase:SetModel( "models/Sillirion/weapons/turretA/turret_main.mdl")
  40.           self.TurretBase:SetPos(self:GetPos())
  41.           self.TurretBase:SetAngles(self.Entity:GetAngles()+Angle( 0, 180, 0))
  42.            self.TurretBase:SetParent(self)
  43.            self.TurretBase:Spawn()
  44.            
  45.            self.Ammotank  = ents.Create("prop_physics")                          
  46.            self.Ammotank:SetModel( "models/Sillirion/weapons/turretA/turret_ammotank.mdl")
  47.            self.Ammotank:SetPos(self:GetPos())
  48.            self.Ammotank:SetAngles(self.TurretBase:GetAngles())
  49.            salf.Ammotank:SetParent(self.TurretBase)
  50.           self.Ammotank:Spawn()
  51.                
  52.         self.Turret = ents.Create("prop_physics")
  53.         self.Turret:SetModel( "models/Sillirion/weapons/turretA/turret_gun.mdl" )
  54.         self.Turret:SetPos(self:GetPos() + self:GetUp() * 50 + self:GetForward() * 10 )
  55.         self.Turret:SetAngles(self.Entity:GetAngles())
  56.         self.Turret:SetParent(self.TurretBase)
  57.         self.Turret:Spawn()
  58.        
  59.         constraint.NoCollide( self.TurretBase, self.Ammotank, 0, 0 )
  60.         constraint.NoCollide( self.Turret,self.TurretBase , 0, 0 )
  61.  
  62.         self.TurretBase = constraint.Axis(self.TurretBase, self, 0, 0, Vector(0,1,0) , self:GetPos(), 0, 0, 1, 0 )
  63.         self.Turret = constraint.Axis( self.Turret, self, 0, 0, Vector(0,0,1) ,self.TurretBase:GetPos(), 0, 0, 1, 0 )
  64.    
  65.     self.TurretPhys =  self.Turret:GetPhysicsObject()
  66.    
  67.     if ( self.TurretPhys:IsValid() ) then
  68.    
  69.         self.TurretPhys:Wake()
  70.         self.TurretPhys:EnableGravity( false )
  71.         self.TurretPhys:EnableCollisions( true )
  72.     end
  73.    
  74.     self.BasePhys = self.TurretBase:GetPhysicsObject()
  75.    
  76.     if ( self.BasePhys:IsValid() ) then
  77.    
  78.         self.BasePhys:Wake()
  79.         self.BasePhys:EnableGravity( false )
  80.         self.BasePhys:EnableCollisions( true )
  81.     end
  82.    
  83.     self.Owner = self.Entity:GetOwner()
  84.     self:SetNetworkedInt( "health" , self.HealthVal )
  85.     self.Entity:SetPhysicsAttacker(self.Owner)
  86.  
  87. end
  88.  
  89. local function apr(a,b,c)
  90.     local z = math.AngleDifference( b, a )
  91.     return math.Approach( a, a + z, c )
  92. end
  93.  
  94.  
  95. function ENT:OnTakeDamage(dmginfo)
  96.        
  97.     self:TakePhysicsDamage( dmginfo )
  98.    
  99.     self.HealthVal = self.HealthVal - dmginfo:GetDamage()
  100.    
  101.     self:SetNetworkedInt( "health" , self.HealthVal )
  102.    
  103.     if ( self.HealthVal < 10 ) then
  104.        
  105.        
  106.         self:ExplosionImproved()
  107.         self:Remove()
  108.        
  109.     end
  110.    
  111. end
  112.  
  113.  
  114. function ENT:FireTurret()
  115.  
  116.    
  117.    
  118. end
  119.  
  120.  
  121. function ENT:PhysicsUpdate()
  122.  
  123. return true
  124.    
  125. end
  126.  
  127. function ENT:LerpAim(Target)
  128.  
  129.     if ( Target == nil ) then
  130.  
  131.         return
  132.  
  133.     end
  134.    
  135.     if (!Target:IsValid()) then
  136.            
  137.         return
  138.        
  139.     end
  140.    
  141.     local a = self.Turret:GetPos()
  142.     local b = Target:GetPos()
  143.     local c = Vector( a.x - b.x, a.y - b.y, a.z - b.z )
  144.     local e = math.sqrt( ( c.x ^ 2 ) + ( c.y ^ 2 ) + (c.z ^ 2 ) )
  145.     local target = Vector( -( c.x / e ), -( c.y / e ), -( c.z / e ) )
  146.    
  147.     self.Turret:SetAngles( LerpAngle( 0.05, target:Angle(), self.Turret:GetAngles() ) )
  148.     self.TurretBase:SetAngles( LerpAngle( 0.05, target:Angle(), self.TurretBase:GetAngles() ) )
  149. end
  150.  
  151.  
  152. local function Rain(ent,Target)
  153.                     local r = ents.Create("sent_rocketbarrage")
  154.                     r:SetPos(ent:GetPos()+ent:GetForward()*64 +ent:GetRight()*math.random(-64,64))
  155.                     r:SetAngles(ent:GetAngles())
  156.                     r:Spawn()
  157.                     r:SetPhysicsAttacker(ent)
  158.                     r:GunAim(target)
  159.                     r.Target = target
  160.                    
  161. end
  162.  
  163.  
  164. function ENT:Think()
  165.     local selfpos = self.Entity:GetPos()
  166.     local forward = self.Entity:GetForward()
  167.     local entities = ents.FindInSphere(selfpos,6000)
  168.    
  169.     for k,v in pairs(entities) do
  170.     // loooooooooooooooong....
  171. if (v:IsNPC() || v:IsPlayer() || string.find(v:GetClass(),"missile") || string.find(v:GetClass(),"nuke") || string.find(v:GetClass(),"thruster") || string.find(v:GetClass(),"npc_")) then
  172.             // looooooong
  173.             if (v:GetVelocity():Length() > 1) then
  174.                 if ( v:GetPos().z > self.Entity:GetPos().z +128 )  then
  175.                 // still not done with it wtf?
  176.                     self.Target = v
  177.                    
  178.                     // Aimbot!!
  179.                     self.Entity:LerpAim(v)
  180.                    
  181.                     local tr = {}
  182.                     tr.start=self:GetPos()+self:GetForward()*32
  183.                     tr.endpos=self:GetPos()+self:GetForward()*25800
  184.                     tr.filter=self
  185.                     local Trace = util.TraceLine(tr)
  186.                        
  187.                     if ( Trace.Hit && Trace.Entity == v ) then
  188.                
  189.                     self.Turret:TurretFire()
  190.                 end
  191.                     local TSR = self.Entity:GetVar('DoRocket',0)
  192.                     if (TSR + 25) > CurTime() then return end
  193.                     self.Entity:SetVar('DoRocket',CurTime())
  194.                     timer.Simple(0.2,function() Rain(self.Entity,self.Target) end)
  195.                     timer.Simple(0.6,function() Rain(self.Entity,self.Target) end)
  196.                     timer.Simple(1,function() Rain(self.Entity,self.Target) end)
  197.                     timer.Simple(1.4,function() Rain(self.Entity,self.Target) end)
  198.             end
  199.         end
  200.     end
  201. end
  202.         local TSlaunch = self.Entity:GetVar('TLaunch', 0)
  203.         if (TSlaunch + 4) > CurTime() then return end
  204.         self.Entity:SetVar( 'TLaunch', CurTime() )
  205.        
  206. end
  207.  
  208.  
  209. function ENT:OnRemove()
  210.  
  211. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement