• I need help with this some npc code
    0 replies, posted
3 things when i downloaded this addon it was not very descriptive on what this code did but what im seeing is its shooting this entity but i get a unknown entity and it floods my console 1. [CODE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize() math.randomseed(CurTime()) self.exploded = false self.Entity:SetModel( "models/dav0r/hoverball.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetMaterial("models/props_combine/portalball001_sheet") self.Entity:SetColor(0,191,255,235) self.Entity:Ignite( 120, 40 ) self.dietime = CurTime() + 3 local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:Wake() phys:EnableGravity(false) end self:SetGravity(0.25) end function ENT:OnTakeDamage( dmginfo ) self.Entity:TakePhysicsDamage( dmginfo ) end function ENT:PhysicsCollide() if ( self.exploded == false) then util.BlastDamage(self.Entity, self.Entity, self.Entity:GetPos(), 25, 10) local effectdata = EffectData() effectdata:SetOrigin(self.Entity:GetPos()) util.Effect( "ImpactGunship", effectdata ) self.exploded = true end end function ENT:Think() if ( self.dietime < CurTime() ) then util.BlastDamage(self.Entity, self.Entity, self.Entity:GetPos(), 25, 10) local effectdata = EffectData() effectdata:SetOrigin(self.Entity:GetPos()) util.Effect( "ImpactGunship", effectdata ) self.exploded = true end if self.exploded == true then self:Remove() end self:NextThink( CurTime() ) return true end [/CODE] 2. he spawns but he will not move regardless of what i do heres his code [CODE]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') ENT.Model = "models/combine_guard.mdl" ENT.health = 99999999 ENT.Alerted = false ENT.Territorial = false ENT.Bleeds = false ENT.Leaps = true ENT.Chasing = false ENT.Flinches = true ENT.FriendlyToPlayer = false ENT.Damage = 100 ENT.AcidBlood = false ENT.BleedsRed = false ENT.LeapDamage = 15 ENT.LeapSpeed = 1000 ENT.LeapDistance = 1400 ENT.MinLeapDistance = 200 ENT.MeleeAttacking = false; ENT.Leaping = false ENT.alert1 = Sound("npc/synth/advisor/advisor_blast1.wav") ENT.alert2 = Sound("npc/synth/advisor/advisor_blast6.wav") ENT.alert3 = Sound("npc/synth/advisor/advisor_blast1.wav") ENT.alert3 = Sound("npc/synth/advisor/advisor_blast6.wav") ENT.idle1 = Sound("npc/scanner/scanner_scan2.wav") ENT.idle2 = Sound("npc/scanner/scanner_scan4.wav") ENT.idle3 = Sound("npc/scanner/scanner_scan2.wav") ENT.idle4 = Sound("npc/scanner/scanner_scan4.wav") ENT.attack1 = Sound("") ENT.attack2 = Sound("") ENT.attack3 = Sound("") ENT.attack4 = Sound("") ENT.attack5 = Sound("") ENT.attack6 = Sound("") ENT.attackmiss1 = Sound("npc/synth/ministrider/body_medium_impact_hard3.wav") ENT.attackmiss2 = Sound("npc/synth/ministrider/body_medium_impact_hard1.wav") ENT.attackmiss3 = Sound("npc/synth/ministrider/body_medium_impact_hard5.wav") ENT.attackmiss4 = Sound("npc/synth/ministrider/body_medium_impact_hard6.wav") ENT.attackleap = Sound("") ENT.hurt1 = Sound("") ENT.hurt2 = Sound("") ENT.hurt3 = Sound("") ENT.die1 = Sound("npc/synth/advisor/advisor_scream.wav") ENT.die2 = Sound("npc/synth/advisor/advisor_scream.wav") ENT.dead = false local schedJump = ai_schedule.New( "Jump" ) schedJump:EngTask( "TASK_PLAY_SEQUENCE", ACT_WALK ) function ENT:Initialize() self:SetModel( self.Model ) self:SetHullType( HULL_MEDIUM_TALL ) self:SetHullSizeNormal() self:SetSolid( SOLID_BBOX ) self:SetMoveType( MOVETYPE_STEP ) self:CapabilitiesAdd( CAP_MOVE_GROUND , CAP_SQUAD ) self:SetMaxYawSpeed( 5000 ) self:SetHealth(self.health) end function ENT:Think() --------------- local function setmeleefalse() if self:Health() < 0 then return end self.MeleeAttacking = false self.Leaping = false self:SetSchedule(SCHED_CHASE_ENEMY) end --------------- local function fireplasma() if self:Health() < 0 then return end local shoot_vector = (self:GetEnemy():GetPos() - self:LocalToWorld(Vector(0,-25,20))) shoot_vector:Normalize() local rocket = ents.Create("ent_zvg_zap") rocket:SetPos(self:GetPos() + self:GetRight() * 25 + self:GetUp() * 80 + shoot_vector * 40) rocket:SetAngles(shoot_vector:Angle()) rocket:Activate() rocket:Spawn() local phy = rocket:GetPhysicsObject() if phy:IsValid() then phy:ApplyForceCenter((shoot_vector * 4500)) end end --------------- local function Attack_Melee() if self:Health() < 0 then return end local entstoattack = ents.FindInSphere(self:GetPos() + self:GetForward()*75,47) local hit = false if entstoattack != nil then for _,v in pairs(entstoattack) do if ( (v:IsNPC() || ( v:IsPlayer() && v:Alive())) && (v != self) && (v:GetClass() != self:GetClass()) || (v:GetClass() == "prop_physics")) then v:TakeDamage( self.Damage, self ) if v:IsPlayer() then v:ViewPunch(Angle(math.random(-1,1)*self.Damage,math.random(-1,1)*self.Damage,math.random(-1,1)*self.Damage)) end if v:GetClass() == "prop_physics" then local phys = v:GetPhysicsObject() if phys != nil && phys != NULL then phys:ApplyForceOffset(self:GetForward()*1000,Vector(math.random(-1,1),math.random(-1,1),math.random(-1,1))) end end hit = true end end 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(94,106)) elseif randomsound == 2 then self:EmitSound( self.attackmiss2,500,math.random(94,106)) elseif randomsound == 3 then self:EmitSound( self.attackmiss3,500,math.random(94,106)) elseif randomsound == 4 then self:EmitSound( self.attackmiss4,500,math.random(94,106)) end else local randomsound = math.random(1,6) 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(94,106)) elseif randomsound == 2 then self:EmitSound( self.attack2,500,math.random(94,106)) elseif randomsound == 3 then self:EmitSound( self.attack3,500,math.random(94,106)) elseif randomsound == 4 then self:EmitSound( self.attack4,500,math.random(94,106)) elseif randomsound == 5 then self:EmitSound( self.attack5,500,math.random(94,106)) elseif randomsound == 6 then self:EmitSound( self.attack6,500,math.random(94,106)) end self:EmitSound( "",500,math.random(94,106)) ///////////////////////FIXME end timer.Create( "melee_done_timer" .. self.Entity:EntIndex( ), 0.6, 1, setmeleefalse ) end //--------------- //--------------- if GetConVarNumber("ai_disabled") == 0 then if self:GetEnemy() != nil then self:UpdateEnemyMemory(self:GetEnemy(),self:GetEnemy():GetPos()) end //make the sound local randomsound = math.random(1,120) if randomsound == 1 then self:StopSound(self.idle1) self:StopSound(self.idle2) self:StopSound(self.idle3) self:StopSound(self.idle4) //self:EmitSound( self.idle1,500,math.random(94,106)) elseif randomsound == 2 then self:StopSound(self.idle1) self:StopSound(self.idle2) self:StopSound(self.idle3) self:StopSound(self.idle4) self:EmitSound( self.idle2,500,math.random(94,106)) elseif randomsound == 3 then self:StopSound(self.idle1) self:StopSound(self.idle2) self:StopSound(self.idle3) self:StopSound(self.idle4) self:EmitSound( self.idle3,500,math.random(94,106)) elseif randomsound == 4 then self:StopSound(self.idle1) self:StopSound(self.id
Sorry, you need to Log In to post a reply to this thread.