Jump to content

Welcome to Gaming On Steroids Forums
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account
Photo

Function RunningAway(target) - NODDY PRED


  • Please log in to reply
3 replies to this topic

#1
lucky5

lucky5

    Newbie

  • Members
  • 5 posts

i'm realy good in math but i'm just starting in the world of coding , i created a basic function in lua for check if a target running away from your champion , i used GetPred from Noddy Pred.

 

Tell me if i made a mistake , i want to learn , ty.

 

code :

function runningAway(target)
   local d1 = GetDistance(target)
   local x, y, z = GetPred(target,2,0)
   local d2 = GetDistance({x=x, y=y, z=z})
   local d3 = GetDistance({x=x, y=y, z=z},target)
   local angle = math.acos((d2*d2-d3*d3-d1*d1)/(-2*d3*d1))
   return angle%(2*math.pi)>math.pi/2 and angle%(2*math.pi)<math.pi*3/2
end

  • 0

#2
sikaka

sikaka

    Advanced Member

  • Trial Developer
  • 594 posts

If you want to check if a target is running towards you or away you can use their current distance vs the distance of path[0]. 

 

If you want the direction they are facing for things like trynd/cass you can use .dir (semi reliable, breaks sometimes with patches) or can use a angle calc similar to what you posted to get the relative angle (in degrees) of their position->path vs your position->theirs. 

 

Something I've started doing is checking the angle and if it is near directly towards or away from us and it's a line skillshot, increase accuracy because they are running along the same path as the skill needs to be cast in.


  • 1

#3
lucky5

lucky5

    Newbie

  • Members
  • 5 posts

If you want to check if a target is running towards you or away you can use their current distance vs the distance of path[0]. 

 

If you want the direction they are facing for things like trynd/cass you can use .dir (semi reliable, breaks sometimes with patches) or can use a angle calc similar to what you posted to get the relative angle (in degrees) of their position->path vs your position->theirs. 

 

Something I've started doing is checking the angle and if it is near directly towards or away from us and it's a line skillshot, increase accuracy because they are running along the same path as the skill needs to be cast in.

ty for the answer 


  • 0

#4
InsidiousQuack

InsidiousQuack

    Advanced Member

  • Contributor
  • 138 posts
  • LocationLondon

My personal favourite method for telling if a target is running away uses a little bit of vector math to get the job done, and works out very nicely.

The angle between two vectors is calculable from the scalar product and magnitudes. Let A and B represent two 3 dimensional vectors in random directions, the shortest angle between A and B will be AB)/ |A|x|B|

You can get the movement vector of a champion from their path instance, and the point at index 1 will be their current goal. Thus let A be their movement vector.

 

Let B be the vector between your champion's position and the enemy champions position. 

Then simply check if the angle between the two vectors is less than 45 degrees, and if it is, they are running away.


  • 0




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users