Jump to content

Recommended Posts

Posted

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)

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Posted

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"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...