Alien Swarm Drone? (Final Test)


//AddCSLuaFile( "shared.lua" )
//AddCSLuaFile( "cl_init.lua" )
include( 'shared.lua' )

ENT.Model = "models/aliens/drone/drone.mdl"
ENT.Class = CLASS_ASW_ALIEN
ENT.Ignitable = true
ENT.Alerted = false
ENT.Territorial = true
ENT.alert1 = Sound("alert01.wav") ENT.alert2 = Sound("alert02.wav") ENT.alert3 = Sound("alert03.wav") ENT.idle1 = Sound("roar01.wav") ENT.idle2 = Sound("roar02.wav") ENT.idle3 = Sound("roar01.wav") ENT.idle4 = Sound("roar02.wav") ENT.attack1 = Sound("attack01.wav") ENT.attack2 = Sound("attack02.wav")ENT.attack3 = Sound("attack03.wav") ENT.attack4 = Sound("attack04.wav") ENT.attack5 = Sound("attack01.wav") ENT.attack6 = Sound("attack02.wav")ENT.attackmiss1 = Sound("pain01.wav") ENT.attackmiss2 = Sound("pain02.wav")
ENT.attackmiss3 = Sound("pain03.wav") ENT.attackmiss4 = Sound("pain04.wav") ENT.hurt1 = Sound("roar01.wav") ENT.hurt2 = Sound("roar02.wav") ENT.hurt3 = Sound("roar01.wav")ENT.die1 = Sound("death01.wav") ENT.die2 = Sound("death02.wav") ENT.die3 = Sound("death03.wav")
ENT.Damage = 38
ENT.AcidBlood = true
ENT.BloodColour = BLOOD_COLOUR_GREEN
end

	self:SetModel( self.Model )

	self:SetHullType( HULL_WIDE_SHORT );
	self:SetHullSizeNormal();

	self:SetSolid( SOLID_BBOX )
	self:SetMoveType( MOVETYPE_STEP )

	self:CapabilitiesAdd( CAP_MOVE_GROUND | CAP_OPEN_DOORS | CAP_FRIENDLY_DMG_IMMUNE | CAP_SQUAD )
	self:SetMaxYawSpeed( 5000 )
end
	self:SetUpEnemies( {"npc_fastzombie_torso", "npc_fastzombie",  "npc_poisonzombie", "npc_zombie", "npc_zombie_torso", "npc_zombine", "npc_headcrab", "npc_headcrab_black", "npc_headcrab_poison", "npc_headcrab_fast", "npc_antlion", "monster_gargantua", "monster_zombie", "monster_bigmomma", "npc_barnacle", "npc_antlionguard"} )
	self.enemyTable_fear = { "npc_combinedropship", "npc_combinegunship", "npc_helicopter", "npc_strider", "npc_sniper" }
	self.enemyTable_LI = { "npc_asw_shieldbug", "npc_asw_boomer", "npc_asw_parasite", "npc_asw_harvester", "npc_asw_grub", "npc_asw_queen"}
	
	self.enemyTable_enemies_e = {}
end
		local randomsound = math.random(1,4)
		if hit == false then
			self:StopSound(self.idle1)
			self:StopSound(self.idle2)
			self:StopSound(self.idle3)
			self:StopSound(self.idle4)
			
			if randomsound == 1 then
	      		self:EmitSound( self.attackmiss1,500,math.random(80,100))
			elseif randomsound == 2 then
	      		self:EmitSound( self.attackmiss2,500,math.random(80,100))
			elseif randomsound == 3 then
	      		self:EmitSound( self.attackmiss3,500,math.random(80,100))
			elseif randomsound == 4 then
	      		self:EmitSound( self.attackmiss4,500,math.random(80,100))
			end
		else
			local randomsound = math.random(1,6)
			//make the sound
			self:StopSound(self.idle1)
			self:StopSound(self.idle2)
			self:StopSound(self.idle3)
			self:StopSound(self.idle4)

			if randomsound == 1 then
	      		self:EmitSound( self.attack1,500,math.random(80,100))
			elseif randomsound == 2 then
	      		self:EmitSound( self.attack2,500,math.random(80,100))
			elseif randomsound == 3 then
	      		self:EmitSound( self.attack3,500,math.random(80,100))
			elseif randomsound == 4 then
	      		self:EmitSound( self.attack4,500,math.random(80,100))
			elseif randomsound == 5 then
	      		self:EmitSound( self.attack5,500,math.random(80,100))
			elseif randomsound == 6 then
	      		self:EmitSound( self.attack6,500,math.random(80,100))
			end
		end
		timer.Create( "melee_done_timer" .. self.Entity:EntIndex( ), 0.5, 1, setmeleefalse )
	end
			self:SetNPCState( NPC_STATE_DEAD )
			self:EmitSound( "npc/.wav", 100, 100 )
			self:SetLocalVelocity( self:GetPos():Normalize() + Vector(0,0,190) )//*5 )
			local function snark_explode()
				self:EmitSound( "npc/squeek/sqk_blast1.wav", 100, 100 )
				local effectdata = EffectData()
				effectdata:SetStart( self:GetPos() ) 
				effectdata:SetOrigin( self:GetPos() )
				effectdata:SetScale( 1 )
				util.Effect( "antlion_spit", effectdata )
				local dmg_ents = ents.FindInSphere( self:GetPos(), 62 )
				for k, v in pairs( dmg_ents ) do
					if( ( ( ( v:IsPlayer() and v:Alive() ) or v:IsNPC() ) and ( self:Disposition( v ) == 1 or self:Disposition( v ) == 2 ) ) or v:GetClass() == "prop_physics" ) then
end

function ENT:StopHurtSounds()
end

function ENT:Killed()

	//create ragdoll
	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib3_forelegl.mdl" )
	ragdoll:SetPos( self:GetPos() )
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib4_forelegr.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,0,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib3_forelegl.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(-100,0,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib5_rearlegl.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib6_rearlegr.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib2_abdomenrear.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_physics" )
	ragdoll:SetModel( "models/aliens/drone/dronegib2_abdomenrear.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/ragdoll_leg_r.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/ragdoll_uparm.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/ragdoll_tail.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/ragdoll_uparm.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/gib_torso.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)

	local ragdoll = ents.Create( "prop_ragdoll" )
	ragdoll:SetModel( "models/aliens/drone/dronek.mdl" )
	ragdoll:SetPos( self:LocalToWorld(Vector(100,5,0)))
	ragdoll:SetAngles( self:GetAngles() )
	ragdoll:Spawn()
	ragdoll:SetSkin( self:GetSkin() )
	ragdoll:SetColor( self:GetColor() )
	ragdoll:SetMaterial( self:GetMaterial() )
	undo.AddEntity(ragdoll)
	undo.AddEntity(ragdoll)
	cleanup.ReplaceEntity(self,ragdoll)
	//ignight ragdoll if on fire.
	if self:IsOnFire() then ragdoll:Ignite( math.Rand( 8, 10 ), 0 ) end

	//position bones the same way.
        for i=1,128 do
		local bone = ragdoll:GetPhysicsObjectNum( i )
		if ValidEntity( bone ) then
			local bonepos, boneang = self:GetBonePosition( ragdoll:TranslatePhysBoneToBone( i ) )
		end
	end

What Have I POSSIBLY Done Wrong NOW? It Wont Even Spawn!