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

calculating spell range

spell range vectors hitbox hit box

  • Please log in to reply
13 replies to this topic

#1
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Is this how you calculate the if a spell is in range?
 

function IsInRange ( targetUnit, sourceUnit, range )
    local r = range
    if range == nil then
        r = math.huge
    end

    return targetUnit.pos:DistanceTo ( sourceUnit.pos ) < r
end

I'm not sure if pos is the point where the character's feet stand or if it's the center of gravity of it's collision box, whatever it is, some adjusments got to be made because a skill is in range not only if it can hit another unit's feet or their center of gravity, it is in range when it can hit any point of the target's hit box.

What I need to know is:

  1. is pos the location where the unit stands? or is it the barycenter of its hit box?
  2. how do I get a unit's hit box?
  3. how do I get a skill's "area of effect" (in case of, for example, brand's Q, it would be the missile's hit box, in case of brand's W it would be the radius of the circle, in case of brand's E it would be 0, because it is a punctual skill)

  • 0

#2
fubman

fubman

    Advanced Member

  • Contributor
  • 48 posts

take the snippet

Valid Target:

function IsValidTarget(unit, range, checkTeam, from)
    local range = range == nil and math.huge or range
    if unit == nil or not unit.valid or not unit.visible or unit.dead or not unit.isTargetable --[[or self:IsImmune(unit)]] or (checkTeam and unit.isAlly) then 
        return false 
    end 
    return unit.pos:DistanceTo(from and from or myHero) < range 
end
Example:

function KSQ(target)
    for K, Enemy in pairs(self:GetEnemyHeroes()) do
        if self:IsValidTarget(Enemy, Q.Range, false, myHero.pos) and Enemy.pos:DistanceTo(target.pos) < R.Range then
            self:CastQ(Enemy) return 
        end
    end
end


u need spell datas for this i did it with :

function Blitzcrank:LoadSpells()
    Q = {Range = 925, width = nil, Delay = 0.25, Radius = 0, Speed = 1750, Collision = true, aoe = false, type = "linear"}
    W = {Range = nil, width = nil, Delay = 0.25, Radius = 0, Speed = 0, Collision = false, aoe = false, type = "linear"}
    E = {Range = 240, width = nil, Delay = 0.25, Radius = 0, Speed = 200, Collision = false, aoe = false, type = "circular"}
    R = {Range = 600, width = 200, Delay = 0.25, Radius = 0, Speed = 0, Collision = false, aoe = true, type = "circular"}
end



But u can also do it like this:

local qSpellData = myHero:GetSpellData(_Q);
local wSpellData = myHero:GetSpellData(_W);
local eSpellData = myHero:GetSpellData(_E);
local rSpellData = myHero:GetSpellData(_R);


  • 0

#3
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Oh, so from is another unit in that code. But are hit boxes taken into consideration by Vector:DistanceTo? It seems unlikely.

 

What about this variation?

function IsInRange ( targetUnit, sourceUnit, range )
    local r = range
    if range == nil then
        r = math.huge
    end

    return targetUnit.pos:DistanceTo ( sourceUnit ) < r + targetUnit.boundingRadius
end

should I add sourceUnit.boundingRadius? should I remove targetUnit.boundingRadius because it is already accounted for?


  • 0

#4
evitaerCi

evitaerCi

    Advanced Member

  • Scripts Developer
  • 176 posts

Only some targeted spells should incluse boundingRadius, the rest of spells shouldn't use it.

 

Check http://leagueoflegen....com/wiki/Range in Targeted Exceptions.


  • 0

#5
Maxxxel

Maxxxel

    The One

  • Scripts Developer
  • 1,196 posts
  • LocationGuess the right City to win 10$

Only some targeted spells should incluse boundingRadius, the rest of spells shouldn't use it.

 

Check http://leagueoflegen....com/wiki/Range in Targeted Exceptions.

Correct.


  • 0

#6
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Only some targeted spells should incluse boundingRadius, the rest of spells shouldn't use it.

 

Check http://leagueoflegen....com/wiki/Range in Targeted Exceptions.

Very nice of you to show which spells are exceptions to the general rule, unfortunately, it doesn't answer my question:

What is the general rule?
And (new question): how do I factor in the bounding radius when needed?

It's almost funny to see how cryptic you people are. Are we hiding something? Is this a "members only" discussion? Because I had to pay 10 ****ing euros just to be in this chat. So it would be kind of nice, if someone who actually knew what they were talking about (like the red named guy, who by now is as rich as a small country) would take their time to, once a ****ing day, stop snorting cocaine out of high class eastern european prostitutes' pussies' and would, for 1 hour, take his time to answer questions of those who pay him for a service monthly.


  • 0

#7
Meeboo

Meeboo

    Advanced Member

  • Scripts Developer
  • 786 posts
  • LocationUnited States

Very nice of you to show which spells are exceptions to the general rule, unfortunately, it doesn't answer my question:

What is the general rule?
And (new question): how do I factor in the bounding radius when needed?

It's almost funny to see how cryptic you people are. Are we hiding something? Is this a "members only" discussion? Because I had to pay 10 ****ing euros just to be in this chat. So it would be kind of nice, if someone who actually knew what they were talking about (like the red named guy, who by now is as rich as a small country) would take their time to, once a ****ing day, stop snorting cocaine out of high class eastern european prostitutes' pussies' and would, for 1 hour, take his time to answer questions of those who pay him for a service monthly.

Read it carefully, you will find out your answer. Furthermore, If you need help for specific spell, just ask here


  • 0

#8
evitaerCi

evitaerCi

    Advanced Member

  • Scripts Developer
  • 176 posts

Very nice of you to show which spells are exceptions to the general rule, unfortunately, it doesn't answer my question:

What is the general rule?
And (new question): how do I factor in the bounding radius when needed?

It's almost funny to see how cryptic you people are. Are we hiding something? Is this a "members only" discussion? Because I had to pay 10 ****ing euros just to be in this chat. So it would be kind of nice, if someone who actually knew what they were talking about (like the red named guy, who by now is as rich as a small country) would take their time to, once a ****ing day, stop snorting cocaine out of high class eastern european prostitutes' pussies' and would, for 1 hour, take his time to answer questions of those who pay him for a service monthly.

Hi Sir, No one should need help for this if it's public in their Wiki Site.
The formula for edge-to-edge range is:

Range + source.boundingRadius + target.boundingRadius
  • 0

#9
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Hi Sir, No one should need help for this if it's public in their Wiki Site.
The formula for edge-to-edge range is:

Range + source.boundingRadius + target.boundingRadius

Which is interesting, Sir or Madam, because this is not the answers I got from your peers above. If you'd mind to take a look at those...


  • 0

#10
evitaerCi

evitaerCi

    Advanced Member

  • Scripts Developer
  • 176 posts

Which is interesting, Sir or Madam, because this is not the answers I got from our peers above. If you'd mind to take a look at those...

just fappa
  • 0

#11
Feretorix

Feretorix

    Administrator

  • Administrators
  • 3,177 posts

If the spell is targeted (like Veigar's ultimate) you might just use the raw range, it's from the center point of your hero, to the center point of the enemy hero, no bounding radius is taken into account.

 

If you're talking about auto-attacks, just as evitaerCi said, its source.boundingRadius + range + target.boundingRadius, the same applies for skillshots.

 

 

There still could be exceptions for that (Smite takes bounding radius since S6 and is targeted spell). Your best bet would be try and trial in the new Sandbox mode for league.


  • 0

#12
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

If the spell is targeted (like Veigar's ultimate) you might just use the raw range, it's from the center point of your hero, to the center point of the enemy hero, no bounding radius is taken into account.

 

If you're talking about auto-attacks, just as evitaerCi said, its source.boundingRadius + range + target.boundingRadius, the same applies for skillshots.

 

 

There still could be exceptions for that (Smite takes bounding radius since S6 and is targeted spell). Your best bet would be try and trial in the new Sandbox mode for league.

I don't know what the new Sandbox mode is.


  • 0

#13
LeighaLish

LeighaLish

    Advanced Member

  • Ex-Staff
  • PipPipPip
  • 1,156 posts

I don't know what the new Sandbox mode is.

Meant the new practice tool. It's so helpful for testing scripts


  • 1

#14
MonkeyKid

MonkeyKid

    Advanced Member

  • Members
  • 112 posts
  • LocationBrazil

Meant the new practice tool. It's so helpful for testing scripts

I see. I think the actual ranges for each spell and items should be static values calculated for us developers. There should be a C inbuilt method, customized for each skill that would go something like this unit:IsTargetInAreaOfEffect ( target, [spell/item slot] ). This method would take into consideration bounding radiuses, spell shapes, spell levels, basically everything, except random factors.

So if I would cast Veigar's Event Horizon, the method should predict with precise accuracy if the spell will hit (as long as the target remains still), But the method shouldn't have to predict if Brand's ult will definetely hit the unit given, considering there a great number of units around. Basically, if possible, the method should return a float value from 0 (won't hit, given the exact state of all units at this tick) to 1 (will definetly hit, as long as things remain the same from start of casting to the end of it). And an estimate in between in case of skills that have a random factor, like Brand's R, Pyroclasm, or old Ryze's E, Spellflux, that I don't really understand these days.

I think this would be a good thing for devs to join efforts on to implement, and I'm willing to help however I can.


  • 0





Also tagged with one or more of these keywords: spell range, vectors, hitbox, hit box

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users