Evaexe 1 Posted April 17 Share Posted April 17 Hello Wrobot community, I'm currently working on a C# script for WoW 3.3.5a using the Wrobot framework. I've encountered an issue with my CanCast function, where it returns true even if the player is too far away from the target. Here's my original code: internal static bool CanCast(Spell spell, WoWUnit target, bool canMove = true, bool tank = false) { // Check if the caster is not stunned, not dead, not casting, the target is alive, the spell is usable, // the distance to the target is good, and there is no line of sight issue if (!ObjectManager.Me.IsStunned && !ObjectManager.Me.IsDead && !ObjectManager.Me.IsCast && !target.IsDead && spell.IsSpellUsable && spell.IsDistanceGood && !TraceLine.TraceLineGo(target.Position) && !target.IsMounted) { if (target.MaxHealth - target.Health != 0 || tank) { return true; } } // Return false, indicating the spell cannot be cast return false; } } The problem seems to be related to the spell.IsDistanceGood condition, which does not seem to be working as intended. I'd appreciate it if anyone could help me identify the issue and suggest a solution. Thank you in advance for your assistance! Link to comment Share on other sites More sharing options...
Matenia 611 Posted April 18 Share Posted April 18 It checks ingame 3D distance vs whatever the spell has as an attribute. That mostly doesn't work due to center-center calculations, hitboxes etc. Every server implements it differently too, so you just have to do your own calculation based on what you observe on your server. Good luck. Link to comment Share on other sites More sharing options...
Evaexe 1 Posted April 18 Author Share Posted April 18 I'm eventully trying to check distance with : playerToHeal.GetDistance <= 40; But i don't know if u should use : playerToHeal.GetDistance2D <= 40; or playerToHeal.GetDistanceZ <= 40; What is the difference between classic, 2D and Z ? Thanks Link to comment Share on other sites More sharing options...
Matenia 611 Posted April 18 Share Posted April 18 (edited) Yes, 2D ignores Z axis and I would generally recommend you never use it unless you specifically know you need it. PS: Figure out if your server calculates it including hitboxes and such. Otherwise you need to calculate the distance yourself based on Position. Edited April 18 by Matenia Link to comment Share on other sites More sharing options...
Zer0 137 Posted April 18 Share Posted April 18 GetDistance2D will return the distance from you to the target, ignoring the Z axis, only useful in very specific situations. GetDistanceZ will return only the Z distance from you to the target (ignoring X and Y), again, very specific. GetDistance will return the 3D distance from you to the target. This is the one you want. Link to comment Share on other sites More sharing options...
Evaexe 1 Posted April 18 Author Share Posted April 18 Thanks ! 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