AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') local DESTROYABLE=true -- set to false to prevent damage local HEALTH=500 -- change to set spawn health of shuttles local ALWAYS_ON=false -- change to TRUE if you do not want to have to hold a key to go local maxents = CreateConVar( "harvester_maxents", "5" ) -- max ents to store in the "buffer" local allowconstraint = CreateConVar( "harvester_allowconstrainedprops", "0" ) -- if set to 1, props/entities which have been constrained will not be allowed to be sucked in local allowplayers = CreateConVar( "harvester_allowplayers", "1" ) -- if set to 1 players may be sucked in local DISALLOWED={ -- these entities cannot be sucked up prop_door_rotating=true, stargate_atlantis=true, stargate_sg1=true, dhd_atlantis=true, dhd_sg1=true, prop_ragdoll=true } local soundx2=Sound("ambient/atmosphere/city_beacon_loop1.wav") local soundx=Sound("DartEngine.wav") function ENT:SpawnFunction( ply, tr) local SpawnPos = tr.HitPos + tr.HitNormal * 100 local ent = ents.Create( "shuttle_dart" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() self.LastSpit=0 if (!self.Sound2) then self.Sound2 = CreateSound( self.Entity, soundx2 ) end self.Ents={} self.Entity:SetNetworkedInt("health",HEALTH) if (!self.Sound) then self.Sound = CreateSound( self.Entity, soundx ) end self.Entity:SetUseType( SIMPLE_USE ) self.Firee=nil self.Inflight=false self.Pilot=nil self.Entity:SetModel("models/wraith_dart.mdl") self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() phys:SetMass(10000) end self.Entity:StartMotionController() self.LThink=0 end function ENT:DoKill() local effectdata = EffectData() effectdata:SetOrigin( self.Entity:GetPos() ) util.Effect( "Explosion", effectdata, true, true ) self.Sound:Stop() self.Pilot:UnSpectate() self.Pilot:DrawViewModel(true) self.Pilot:DrawWorldModel(true) self.Pilot:Spawn() self.Pilot:SetNetworkedBool("isDriveShuttle",false) self.Pilot:SetPos(self.Entity:GetPos()+Vector(0,0,100)) self.Entity:Remove() end function ENT:OnTakeDamage(dmg) if self.Inflight and DESTROYABLE and not self.Done then local health=self.Entity:GetNetworkedInt("health") self.Entity:SetNetworkedInt("health",health-dmg:GetDamage()) local health=self.Entity:GetNetworkedInt("health") if health<1 then self.Entity:DoKill() self.Done=true end end end function ENT:AcceptInput(name,activator,caller) if name=="on" then self.Entity:SetNetworkedBool("on",true) self.Sound2:Play() self.Sound2:SetSoundLevel(110) self.Sound2:ChangeVolume(400,0.1) self.Sound2:ChangePitch(250,1) end if name=="off" then self.Entity:SetNetworkedBool("on",false) self.Sound2:Stop() end if name=="spit" then self.Entity:Spit() end end function ENT:Spit(override) local trace = {} trace.start = self.Entity:GetPos() trace.endpos = self.Entity:GetPos()+(self.Entity:GetUp()*-1)*1000 trace.filter = self.Entity local e=util.TraceLine( trace ) local pos=e.HitPos for i,v in pairs(self.Ents) do if v==NULL or not v:IsValid() then self.Ents[i]=nil return end local ed = EffectData() ed:SetStart(self.Entity:GetPos()) ed:SetOrigin(pos) util.Effect( "wraithbeam", ed ) self.Entity:EmitSound("npc/scanner/scanner_electric2.wav",150,200) v:SetMoveType(self.Ents[i].MoveType) v:SetSolid(self.Ents[i].Solid) v:SetColor(self.Ents[i].r,self.Ents[i].g,self.Ents[i].b,self.Ents[i].a) v:SetParent(nil) v:SetPos(e.HitPos) v:SetAngles(Angle(0,0,0)) if self.Ents[i].MoveType==MOVETYPE_VPHYSICS then local phys=v:GetPhysicsObject() phys:EnableMotion(true) phys:Wake() end if v:IsPlayer() then v:UnSpectate() v:DrawViewModel(true) v:DrawWorldModel(true) v:Spawn() v:SetColor(255,255,255,255) for _,n in pairs(self.Ents[i].Weapons) do v:Give(n) end end local vFlushPoint = e.HitPos - ( e.HitNormal * 512 ) vFlushPoint = v:NearestPoint( vFlushPoint ) vFlushPoint = v:GetPos() - vFlushPoint vFlushPoint = e.HitPos + vFlushPoint v:SetPos(vFlushPoint) self.Ents[i]=nil if not override then return end end end local function findent(tabl,ent) for k,v in pairs(tabl) do if v==ent then return true end end if DISALLOWED[ent:GetClass()] then return true end if string.find(ent:GetClass(),"func_") then return true end return false end function ENT:OnRemove() if (self.Sound) then self.Sound:Stop() end if (self.Sound2) then self.Sound2:Stop() end self.Entity:Spit(true) end function ENT:Think() if self.Entity:GetNetworkedBool("on") and #self.Ents110 and not findent(self.Ents,ent) then if ent:IsPlayer() and not allowplayers:GetBool() or ent:IsConstrained() and not allowconstraint:GetBool() then else if ent:GetPhysicsObject():IsValid() or ent:IsPlayer() and #self.Ents0 or num<0 then local pr={} pr.secondstoarrive = 1 pr.pos = self.Entity:GetPos()+self.Entity:GetForward()*num pr.maxangular = 5000 pr.maxangulardamp = 10000 pr.maxspeed = 1000000 pr.maxspeeddamp = 10000 pr.dampfactor = 0.8 pr.teleportdistance = 5000 pr.angle = self.Pilot:GetAimVector():Angle() if self.Pilot:KeyDown(IN_SPEED) then pr.angle=self.Entity:GetAngles() self.Entity:Fire("on","",0) else self.Entity:Fire("off","",0) end if self.Pilot:KeyDown(IN_RELOAD) then if self.LastSpit