Writing a Cassiopeia script, and am including an option to 'only ult enemies facing you.'
Since the API doesn't seem to have such a function, here's an implementation:
function MyScript:IsFacing(target) -- make sure directions are facing opposite: local dotProduct = myHero.dir.x*target.dir.x + myHero.dir.z*target.dir.z if (dotProduct < 0) then -- also make sure you dont have your backs to each other: if (myHero.dir.x > 0 and myHero.dir.z > 0) then return ((target.pos.x - myHero.pos.x > 0) and (target.pos.z - myHero.pos.z > 0)) elseif (myHero.dir.x < 0 and myHero.dir.z < 0) then return ((target.pos.x - myHero.pos.x < 0) and (target.pos.z - myHero.pos.z < 0)) elseif (myHero.dir.x > 0 and myHero.dir.z < 0) then return ((target.pos.x - myHero.pos.x > 0) and (target.pos.z - myHero.pos.z < 0)) elseif (myHero.dir.x < 0 and myHero.dir.z > 0) then return ((target.pos.x - myHero.pos.x < 0) and (target.pos.z - myHero.pos.z > 0)) end end return false end
Sign In
Create Account

Back to top
Report








