Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile( "cl_init.lua" )
- AddCSLuaFile( "shared.lua" )
- include( 'shared.lua' )
- ENT.Sound = "50cal.wav"//"weapons/shotgun/shotgun_dbl_fire7.wav"
- ENT.Model = "models/Sillirion/weapons/turretA/turret_base.mdl"
- ENT.HealthVal = 2000
- function ENT:SpawnFunction( ply, tr)
- local SpawnPos = tr.HitPos + tr.HitNormal * 100
- local ent = ents.Create( "Testing" )
- ent:SetPos( SpawnPos )
- ent:Spawn()
- ent:Activate()
- return ent
- end
- function ENT:Initialize()
- self.Entity:SetModel( self.Model )
- self.Entity:SetVar('DoAttack',CurTime())
- self.Entity:PhysicsInit( SOLID_VPHYSICS )
- self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
- self.Entity:SetSolid( SOLID_VPHYSICS )
- self.PhysObj = self.Entity:GetPhysicsObject()
- if ( self.PhysObj:IsValid() ) then
- self.PhysObj:Wake()
- self.PhysObj:EnableGravity(true)
- end
- self.TurretBase = ents.Create("prop_physics")
- self.TurretBase:SetModel( "models/Sillirion/weapons/turretA/turret_main.mdl")
- self.TurretBase:SetPos(self:GetPos())
- self.TurretBase:SetAngles(self.Entity:GetAngles()+Angle( 0, 180, 0))
- self.TurretBase:SetParent(self)
- self.TurretBase:Spawn()
- self.Ammotank = ents.Create("prop_physics")
- self.Ammotank:SetModel( "models/Sillirion/weapons/turretA/turret_ammotank.mdl")
- self.Ammotank:SetPos(self:GetPos())
- self.Ammotank:SetAngles(self.TurretBase:GetAngles())
- salf.Ammotank:SetParent(self.TurretBase)
- self.Ammotank:Spawn()
- self.Turret = ents.Create("prop_physics")
- self.Turret:SetModel( "models/Sillirion/weapons/turretA/turret_gun.mdl" )
- self.Turret:SetPos(self:GetPos() + self:GetUp() * 50 + self:GetForward() * 10 )
- self.Turret:SetAngles(self.Entity:GetAngles())
- self.Turret:SetParent(self.TurretBase)
- self.Turret:Spawn()
- constraint.NoCollide( self.TurretBase, self.Ammotank, 0, 0 )
- constraint.NoCollide( self.Turret,self.TurretBase , 0, 0 )
- self.TurretBase = constraint.Axis(self.TurretBase, self, 0, 0, Vector(0,1,0) , self:GetPos(), 0, 0, 1, 0 )
- self.Turret = constraint.Axis( self.Turret, self, 0, 0, Vector(0,0,1) ,self.TurretBase:GetPos(), 0, 0, 1, 0 )
- self.TurretPhys = self.Turret:GetPhysicsObject()
- if ( self.TurretPhys:IsValid() ) then
- self.TurretPhys:Wake()
- self.TurretPhys:EnableGravity( false )
- self.TurretPhys:EnableCollisions( true )
- end
- self.BasePhys = self.TurretBase:GetPhysicsObject()
- if ( self.BasePhys:IsValid() ) then
- self.BasePhys:Wake()
- self.BasePhys:EnableGravity( false )
- self.BasePhys:EnableCollisions( true )
- end
- self.Owner = self.Entity:GetOwner()
- self:SetNetworkedInt( "health" , self.HealthVal )
- self.Entity:SetPhysicsAttacker(self.Owner)
- end
- local function apr(a,b,c)
- local z = math.AngleDifference( b, a )
- return math.Approach( a, a + z, c )
- end
- function ENT:OnTakeDamage(dmginfo)
- self:TakePhysicsDamage( dmginfo )
- self.HealthVal = self.HealthVal - dmginfo:GetDamage()
- self:SetNetworkedInt( "health" , self.HealthVal )
- if ( self.HealthVal < 10 ) then
- self:ExplosionImproved()
- self:Remove()
- end
- end
- function ENT:FireTurret()
- end
- function ENT:PhysicsUpdate()
- return true
- end
- function ENT:LerpAim(Target)
- if ( Target == nil ) then
- return
- end
- if (!Target:IsValid()) then
- return
- end
- local a = self.Turret:GetPos()
- local b = Target:GetPos()
- local c = Vector( a.x - b.x, a.y - b.y, a.z - b.z )
- local e = math.sqrt( ( c.x ^ 2 ) + ( c.y ^ 2 ) + (c.z ^ 2 ) )
- local target = Vector( -( c.x / e ), -( c.y / e ), -( c.z / e ) )
- self.Turret:SetAngles( LerpAngle( 0.05, target:Angle(), self.Turret:GetAngles() ) )
- self.TurretBase:SetAngles( LerpAngle( 0.05, target:Angle(), self.TurretBase:GetAngles() ) )
- end
- local function Rain(ent,Target)
- local r = ents.Create("sent_rocketbarrage")
- r:SetPos(ent:GetPos()+ent:GetForward()*64 +ent:GetRight()*math.random(-64,64))
- r:SetAngles(ent:GetAngles())
- r:Spawn()
- r:SetPhysicsAttacker(ent)
- r:GunAim(target)
- r.Target = target
- end
- function ENT:Think()
- local selfpos = self.Entity:GetPos()
- local forward = self.Entity:GetForward()
- local entities = ents.FindInSphere(selfpos,6000)
- for k,v in pairs(entities) do
- // loooooooooooooooong....
- 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
- // looooooong
- if (v:GetVelocity():Length() > 1) then
- if ( v:GetPos().z > self.Entity:GetPos().z +128 ) then
- // still not done with it wtf?
- self.Target = v
- // Aimbot!!
- self.Entity:LerpAim(v)
- local tr = {}
- tr.start=self:GetPos()+self:GetForward()*32
- tr.endpos=self:GetPos()+self:GetForward()*25800
- tr.filter=self
- local Trace = util.TraceLine(tr)
- if ( Trace.Hit && Trace.Entity == v ) then
- self.Turret:TurretFire()
- end
- local TSR = self.Entity:GetVar('DoRocket',0)
- if (TSR + 25) > CurTime() then return end
- self.Entity:SetVar('DoRocket',CurTime())
- timer.Simple(0.2,function() Rain(self.Entity,self.Target) end)
- timer.Simple(0.6,function() Rain(self.Entity,self.Target) end)
- timer.Simple(1,function() Rain(self.Entity,self.Target) end)
- timer.Simple(1.4,function() Rain(self.Entity,self.Target) end)
- end
- end
- end
- end
- local TSlaunch = self.Entity:GetVar('TLaunch', 0)
- if (TSlaunch + 4) > CurTime() then return end
- self.Entity:SetVar( 'TLaunch', CurTime() )
- end
- function ENT:OnRemove()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement