entity 'AI' not working

Not sure if it is AI but anyway. I am making an entity that moves from checkpoint to checkpoint. If a player is near it will go to then, else if a creep it will go to them, else if a tower ect… all the way to base.

If there is nothing near it it will move to the next checkpoint. If there is no next checkpoint then it will move to the enemy base.

Well this is what i have. The only problem is that it doesn’t move anywhere but to the player if the player is near. Any suggestions/criticizing on my coding will be accepted. This is the first time i have done anything like this…

Well just before the code. I have all the variables, all the entitys are working ect… it only follows the player… PLEASE HELP ME
BTW This is just the think code. I think this is all the code u need if you need to see anymore just post i will put more up.



function ENT:Think()
	if self.Entity.Active == 1 then
		if self.Entity.dogaEnemyTeam && self.Entity.Lane then
			if self.Entity.Timer < CurTime() then
				if self.Entity.dogaEnemyTeam == 1 then
					self.Entity:SetColor(0,0,255,255)
				else
					self.Entity:SetColor(0,255,0,255)
				end
				self.Entity.MoveToEnt = 0
				self.Entity.Timer = CurTime() + 1
				for k,v in pairs (ents.FindInSphere(self:GetPos(),200)) do
					local tower = "doga_Team"..self.Entity.dogaEnemyTeam.."Tower"
					if v:IsPlayer() && v:Alive() && v:Team() != self.Entity.dogaEnemyTeam  then
					
						if (v:GetPos() - self.Entity:GetPos()):Length() < 100 then
							v:TakeDamage(20,self.Entity)
						end
						
						self.Entity.MoveToEnt = 1
						self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))	
					elseif v:GetClass() == "doga_Creep" && v.dogaEnemyTeam != self.Entity.dogaEnemyTeam then
						
						if (v:GetPos() - self.Entity:GetPos()):Length() < 100 then
							v:TakeDamage(20,self.Entity)
						end
							
						self.Entity.MoveToEnt = 1
						self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
							
					elseif v:GetClass() == tower then
						
						if (v:GetPos() - self.Entity:GetPos()):Length() < 100 then
							v:TakeDamage(20,self.Entity)
						end
							
						self.Entity.MoveToEnt = 1
						self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
							
					elseif v:GetClass() == "doga_Spawner" && v.DogaTeam != self.Entity.dogaEnemyTeam then
						
						if (v:GetPos() - self.Entity:GetPos()):Length() < 100 then
							v:TakeDamage(20,self.Entity)
						end
						self.Entity.MoveToEnt = 1
						self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
							
					elseif v:GetClass() == "doga_CheckPoint"..self.Entity.Lane then
						if v.DogaTeam == self.Entity.dogaEnemyTeam && v.DogaCheckPoint == self.Entity.CurrentMovepoint  then
							for k2,v2 in pairs (ents.FindByClass( "doga_CheckPoint"..self.Entity.Lane )) do
								if v2.DogaCheckPoint == self.Entity.CurrentMovepoint + 1 then
									self.Entity.CurrentMovepoint = self.Entity.CurrentMovepoint + 1
									self.Entity.self.Entity.MoveToEnt = 0
									self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
								else
									self.Entity.MoveToBase = 1
								end
							end
						end
					end
					
				end
			
				if self.Entity.MoveToBase == 1 then	
					for _,base in pairs (ents.FindByClass("doga_Team"..self.Entity.dogaEnemyTeam.."Base")) do	
						self.Entity:SetPos(self.Entity:GetPos() +((base:GetPos() - self.Entity:GetPos()):GetNormal()*40))
						if (base:GetPos() - self.Entity:GetPos()):Length() < 100 then
							base:TakeDamage(20,self.Entity)
						end
					end
				end
				
				if self.Entity.MoveToEnt == 0 then
					for _,ent in pairs (ents.FindByClass("doga_CheckPoint"..self.Entity.Lane )) do	
						print ("works")
						if ent.DogaCheckPoint == self.Entity.CurrentMovepoint then
							self.Entity:SetPos(self.Entity:GetPos() +((ent:GetPos() - self.Entity:GetPos()):GetNormal()*40))
						end
					end
				end
			end
		else
			self:Remove()
		end
	end
end


[lua]function ENT:Think()
if self.Entity.Active == 1 && self.Entity.dogaEnemyTeam
&& self.Entity.Lane && self.Entity.Timer < CurTime() then
if self.Entity.dogaEnemyTeam == 1 then
self.Entity:SetColor(0,0,255,255)
else
self.Entity:SetColor(0,255,0,255)
end
self.Entity.MoveToEnt = 0
self.Entity.Timer = CurTime() + 1
for k,v in pairs (ents.FindInSphere(self:GetPos(),200)) do
local tower = “doga_Team” … self.Entity.dogaEnemyTeam … “Tower”
if v:IsPlayer() && v:Alive() && v:Team() != self.Entity.dogaEnemyTeam then

			if (v:GetPos() - self.Entity:GetPos()):Length() &lt; 100 then
				v:TakeDamage(20,self.Entity)
			end
			
			self.Entity.MoveToEnt = 1
			self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))	
		elseif v:GetClass() == "doga_Creep" && v.dogaEnemyTeam != self.Entity.dogaEnemyTeam then
			
			if (v:GetPos() - self.Entity:GetPos()):Length() &lt; 100 then
				v:TakeDamage(20,self.Entity)
			end
				
			self.Entity.MoveToEnt = 1
			self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
				
		elseif v:GetClass() == tower then
			
			if (v:GetPos() - self.Entity:GetPos()):Length() &lt; 100 then
				v:TakeDamage(20,self.Entity)
			end
				
			self.Entity.MoveToEnt = 1
			self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
				
		elseif v:GetClass() == "doga_Spawner" && v.DogaTeam != self.Entity.dogaEnemyTeam then
			
			if (v:GetPos() - self.Entity:GetPos()):Length() &lt; 100 then
				v:TakeDamage(20,self.Entity)
			end
			self.Entity.MoveToEnt = 1
			self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
				
		elseif v:GetClass() == "doga_CheckPoint"..self.Entity.Lane 
		&& v.DogaTeam == self.Entity.dogaEnemyTeam 
		&& v.DogaCheckPoint == self.Entity.CurrentMovepoint  then
			for k2,v2 in pairs (ents.FindByClass( "doga_CheckPoint"..self.Entity.Lane )) do
				if v2.DogaCheckPoint == self.Entity.CurrentMovepoint + 1 then
					self.Entity.CurrentMovepoint = self.Entity.CurrentMovepoint + 1
					self.Entity.self.Entity.MoveToEnt = 0
					self.Entity:SetPos(self.Entity:GetPos() +((v:GetPos() - self.Entity:GetPos()):GetNormal()*40))
				else
					self.Entity.MoveToBase = 1
				end
			end
		end
		
	end

	if self.Entity.MoveToBase == 1 then	
		for _,base in pairs (ents.FindByClass("doga_Team"..self.Entity.dogaEnemyTeam.."Base")) do	
			self.Entity:SetPos(self.Entity:GetPos() +((base:GetPos() - self.Entity:GetPos()):GetNormal()*40))
			if (base:GetPos() - self.Entity:GetPos()):Length() &lt; 100 then
				base:TakeDamage(20,self.Entity)
			end
		end
	end
	
	if self.Entity.MoveToEnt == 0 then
		for _,ent in pairs (ents.FindByClass("doga_CheckPoint"..self.Entity.Lane )) do	
			print ("works")
			if ent.DogaCheckPoint == self.Entity.CurrentMovepoint then
				self.Entity:SetPos(self.Entity:GetPos() +((ent:GetPos() - self.Entity:GetPos()):GetNormal()*40))
			end
		end
	end
else
	self:Remove()
end

end[/lua]

Just made a quick fix up. I didn’t really change the content, but rather organized it better so there wasn’t as much indentation. You can try and see if this fixed your problem or not(Doubt it, but it looks a little better).

Hi, I am Andres Kramack from http://www.cathybarryadultstore.com/.

It’s a ‘pleasure’ serving the public if you know what I mean and this message is

Here at Cathy Barry Adult Store, we offer a wide variety of dildos that come in all sizes from goblin-sized dicks to black-man draconic dicks. I know at Facepunch everyone loves good old dicks which is why I personally offer anyone with an association with Facepunch Forums a 50% discount code “DIL4FACEPUNCH”. Don’t forget, this offer lasts until the next Garry’s Mod update which we so much love.

Here are pictures of our products just for you!

Sponsored Images:

http://static.fjcdn.com/pictures/Gym+leaders+hate+him_ab471d_5017861.jpg

https://static.fjcdn.com/comments/That+one+with+the+lamp+got+me+_e68beb19422eea14289caa5f4d6dffb7.jpg

Got any questions? Visit my Steam Profile!