Jump to content
dennis

Lua ai problem

Recommended Posts

Heya guys,

 

I have a problem with the genericai script from imchaseinyou

It keeps on shooting through walls... How can I fix this?

 

Thanks in common,

Dennis

Share this post


Link to post

it's referring to a distancetopoint, and I am getting attacked! the problem is that I only can stop the attack when I'm out of attack range

Share this post


Link to post

it's referring to a distancetopoint, and I am getting attacked! the problem is that I only can stop the attack when I'm out of attack range

 

i know a way to remedy this is to use a pick to see if it hits the player, if it hits say a prop or scene or what ever then the damage should be 0.

 

(or if it is a breakable prop apply the damage to the object it picked, that has a keyvalue breakable or something)

Share this post


Link to post

what pick should I use then?

 

the target is determined here:

 

function Script:IsTargetInAttackRange()
local pos = self.entity:GetPosition()
local targetpos = self.target.entity:GetPosition()
if math.abs(targetpos.y-pos.y)<self.attackRange then
 if pos:xz():DistanceToPoint(targetpos:xz())<self.attackRange then
  return true
 end
end
return false
end

 

and the attack is started here:

 

elseif self.mode=="attack" then
 if self.attackbegan~=nil then
  if t-self.attackbegan>300 then
   self.attackbegan=nil
   self.target:Hurt(self.damage)
  end
 end
 local pos = self.entity:GetPosition()
 local targetpos = self.target.entity:GetPosition()
 local dx=targetpos.x-pos.x
 local dz=targetpos.z-pos.z
 self.entity:AlignToVector(-dx,0,-dz)
end

 

I tried to put the attack before "if self.attackbegin~=nil then"

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...