Unambiguously defining auto attack and spell range


[FONT=arial]I’ve been analyzing sniff data in order to once and for all unambiguously define the minimum range of auto attacks and spells and what “combat reach” and “bounding radius” are . Here is my attempt at doing so. Feel free to criticize and question my understanding of each of theses cases but please provide proof (if possible sniffed data) and arguments so this can be refined as much as possible (and be put into the wiki[/FONT] once it’s ready). I can provide the data I found if asked.[FONT=arial] [/FONT]

[FONT=arial]max distance between 2 units:[/FONT]

[ul][li][FONT=arial]for auto attack melee: unitA->combatReach + unitB->combatReach + 1.0 (cf note 2)[/FONT][/li]
[FONT=arial]example: If unit A (let’s say a huge boss like Sapphiron) has a combat reach of 22 and unit B (let’s say a player) has a [/FONT] [FONT=arial]combat reach [/FONT] [FONT=arial]of 1.5, in order to AA each other, they need to stand at maximum 24.5 yards from each other.[/FONT]

[ul][li][FONT=arial]for auto attack ranged: unitA->combatReach + unitB->combatReach + range of the weapon (30.0 for wand. 35 for bow, gun, etc…)[/FONT][/li]
[li][FONT=arial]for targeted spell: unitA->combatReach + unitB->combatReach + range of the spell[/FONT][/li]

[ul][li][FONT=arial]for GTAoE spell: not sure yet ??? may or may not involve the bounding radius[/FONT][/li]
[li][FONT=arial]for PBAoE spell: not sure yet ??? may or may not [/FONT] [FONT=arial]involve [/FONT] [FONT=arial] the bounding radius[/FONT][/li]
[FONT=arial]Notes for auto attacks:[/FONT]

[ol][li][FONT=arial]When a NPC moves toward a unit in order to AA it, its AI makes [/FONT] [FONT=arial]it [/FONT][FONT=arial]move at distance “unitA->combatReach + unitB->combatReach”. I have solid proof of this.[/FONT][/li]
[li]I’m still unsure about this. I found this relation by playing with the client. The wow client doesn’t allow any player to auto attack beyond this distance. This could mean that this relation is only true for players but not for NPCs. I’m still looking for sniff data to confirm or infirm this.[/li]
[li][FONT=arial]The relation is symmetrical. In other words, if unit A is in range to auto-attack unit B, unit B is also in range to auto-attack unit A. No exception![/FONT][/li]
[li][FONT=arial]The bounding radius is completely irrelevant to auto attacks range. Only the position of both unit and their combat reach are part of the condition[/FONT][/li]
[li][FONT=arial]the distance to consider is in 3D. NOT 2D. In other words, the combat reach can be seen as a spherical radius.[/FONT][/li]

[FONT=arial]Thread linked to:[/FONT]


[FONT=arial]tot78 aka chaodhib[/FONT]

Copy paste of the conversation with Shauren on that topic:

Decompiled client code that handle range validations:


So Shauren’s reply prompt me to acquire more data from the client. What I did was modify my combat reach and the combat reach of my target and then find at which maximum distance I could auto attack it (using .distance). (I didn’t finish every cells. I got bored at some point. The rest is easy to guess based on the other values). It was done on the 3.3.5a client.

I have put the data in attachment. The colored cells (in the header) are the values of “combat reach” used for the test. and the result cells are the auto attack range distance found for that combination of combat reach. Green cells are the cells in the diagonal (to more easily notice that this matrix is symmetrical. in other words, the melee range for unitA against unit B is equal to the melee range for unitB against unit A)


Finally, the conclusion: The algorithm that matches with the data is:

if(a < 2)
a = 2;
if(b < 2)
b = 2;
meleeRangeMax= a + b + 1.0;

FYI: In order to reacquire this data, use a NPC without AI and this command “.debug setvalue 66 NEW_COMBAT_REACH_VALUE_HERE 0” or https://github.com/TrinityCore/TrinityCore/pull/16940#issuecomment-208754787

I got more data from the client.

This time I tested a melee spell (47486 Mortal Strike (Rank 8), warrior spell).

I didn’t acquire a lot of points but basically what I found is this algorithm that compute the maximum range of melee spells:

[FONT=arial]maxRange =unitA->combatReach + unitB->combatReach + 1.33333333;[/FONT]
[FONT=arial]if(maxRange <5.0)[/FONT]
[FONT=arial]maxRange = 5.0;[/FONT]

This is consistent with Shauren’s decompiled code, more specifically the lines 43 to 62. In conclusion, my opinion is that the code that computes the maximum range of melee auto attacks is not in that method.

Now the same work should be done for range spells and ranged AA.

PS: The line 42 “v13 = spellRange->Flags;” represents the 6th column in SpellRange.dbc. This column only takes 3 values: 0 (default), 1 (melee) and 2 (ranged).

Any updates @tot78