jrouten 1 Posted May 19, 2017 Share Posted May 19, 2017 I'm building a protection warrior fight class, and am having some issues with some of the spells and effective range to target. Heroic Throw: range must be greater than 8 but less than 30 Here is the scenario I set up: I positioned my character in game at the precise minimum range where I can cast Heroic Throw. I know this because if I move forward even a tiny distance, the Heroic Throw icon greys out. I then do a memory info dump, and get these values for my Target: InteractDistance = 9.3 CombatReach = 6.6 GetDistance = 16.10403 GetDistance2D = 16.0859 GetDistanceZ = 0.7640839 None of these distances is giving me what I'm looking for. From the perspective of being able to cast a spell, I should be at or very slightly above 8 meters. Even if I subtract CombatReach, that still leaves a distance of 9.9, which is still not accurate. Same for InteractDistance, which if subtracted leaves a distance of 6.9. How do I get a real range value that tells me "spell casting range" or whatever? Link to comment Share on other sites More sharing options...
jrouten 1 Posted May 19, 2017 Author Share Posted May 19, 2017 Actually, I believe I might have figured this out... If I add together my player's CombatReach and the Target's CombatReach, that seems to make up the difference. So to get the minimum distance I must be from the target: Spell.MinRange + Me.CombatReach + Target.CombatReach Of course, if MinRange is 0, we don't need to consider CombatReach, and can ignore it. And likewise, the maximum distance to target would be: Spell.MaxRange + Me.CombatReach + Target.CombatReach This can make a significant difference on very large mobs, when trying to calculate whether a spell can be cast. For you C# folks, here's a good function to check if a spell is in range to cast: public static bool isSpellInRange(Spell spell) { float minRange = spell.MinRange == 0 ? 0 : spell.MinRange + ObjectManager.Me.CombatReach + ObjectManager.Target.CombatReach; float maxRange = spell.MaxRange + ObjectManager.Me.CombatReach + ObjectManager.Target.CombatReach; return (minRange <= ObjectManager.Target.GetDistance) && (ObjectManager.Target.GetDistance <= maxRange); } Link to comment Share on other sites More sharing options...
Droidz 2734 Posted May 20, 2017 Share Posted May 20, 2017 Hello, Yes WRobot don't check min range in "Is good distance...", you can also use lua http://wow.gamepedia.com/API_IsSpellInRange Link to comment Share on other sites More sharing options...
jrouten 1 Posted May 20, 2017 Author Share Posted May 20, 2017 IsSpellInRange is only available via LUA? Link to comment Share on other sites More sharing options...
jrouten 1 Posted May 20, 2017 Author Share Posted May 20, 2017 So I tested this using LUA, and it seems that only spells that actually list a range on their tooltip will work with IsInSpellRange(). Here's the code I tested: var lua = new[] { "inRange = 0", "local unit = \"target\"", "if UnitExists(unit) and UnitIsVisible(unit) then", string.Format(" inRange = IsSpellInRange(\"{0}\", unit)", spell.Name), " if inRange == nil then", " inRange = 2", " end", "end", }; var returnedValue = Lua.LuaDoString<int>(lua, "inRange"); Any spell without a range listed on the tooltip returns 2 (nil) from this snippet. For example, Revenge does not list a range, but it's description states that it will "deal damage to all enemies in front of you", and through testing has an effective range of 8m (plus the target's CombatReach). Similarly, the spell Shockwave (a talent) does not list a range on the tooltip, but the description says "Sends a wave of force in a frontal cone, causing 25,052 damage and stunning all enemies within 10 yards for 3 sec." It also returns a 2 (nil). And AoE spells like Demoralizing Shout and Thunder Clap list their effective range in the spell's description, but does not list an explicit range in the tooltip, and return 2 (nil) when calling IsSpellInRange(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now