April 17, 20232 yr 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!
April 18, 20232 yr 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.
April 18, 20232 yr Author 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
April 18, 20232 yr 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, 20232 yr by Matenia
April 18, 20232 yr 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.
Create an account or sign in to comment