Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[All] GetDistance getter method for WoWUnit

  • Version: All
  • Product: WRobot General
  • Type: Bug
  • Status: Confirmed

This is ONLY for WoWUnit and WoWPlayer, not ANY other type of WoWObject. 

@Droidz can you please fix WoWUnit.GetDistance.GetMethod? It needs to be this.Position.DistanceTo(ObjectManager.Me.Position) - this.CombatReach - ObjectManager.Me.CombatReach. ONLY on WoWUnit. I've tried creating a runtime patch for this, but unfortunately you cannot patch properties at runtime

User Feedback

Recommended Comments

Hello, GetDistance retourn "PositionWithoutType.DistanceTo(ObjectManager.Me.PositionWithoutType);"

You want than I add method to return "Position.DistanceTo(ObjectManager.Me.Position) - this.CombatReach - ObjectManager.Me.CombatReach"?

Matenia

Elite user
(edited)

GetDistance is the method wRobot uses for CustomClass to get close to the enemy. Due to hitbox differences (combatreach) it sometimes doesn't get close enough, then just stands there and says "out of range, out of range!".

There's 2 options:
- Add a new method "GetCombatDistance" and use this in CustomClass, Spell.IsDistanceGood, etc (and users can use this in their own stuff too) 
- for WoWUnit and WoWPlayer, fix GetDistance method and make it "PositionWithoutType.DistanceTo(ObjectManager.Me.PositionWithoutType) - this.CombatReach - ObjectManager.Me.CombatReach"

(I didn't know currently it uses PositionWithoutType, I thought it was just Position).

Currently this code returns real distance:

 

var RealRange = ObjectManager.Target.GetDistance - ObjectManager.Target.CombatReach - ObjectManager.Me.CombatReach;

 

Edited by Matenia

GetDistance is good it is distance from the center of player to the center of the unit.

I use PositionWithoutType to avoid useless step (check if fly or swimming) (for performance, but that does not change the result).

I'll add: 

        public float GeHitBoxtDistance
        {
            get
            {
                try
                {
                    var d = PositionWithoutType.DistanceTo(ObjectManager.Me.PositionWithoutType) - CombatReach - ObjectManager.Me.CombatReach;
                    if (d < 0)
                        d = 0;
                    return d;
                }
                catch (Exception e)
                {
                    Logging.WriteError("WoWUnit > GeHitBoxtDistance: " + e);
                    return 0;
                }
            }
        }

Current, for spell.isgooddistance I use:

        public bool IsDistanceGood
        {
            get
            {
                try
                {
                    if (ObjectManager.ObjectManager.Target.IsValid)
                    {
                        float combatReach = 0;
                        if (wManagerSetting.CurrentSetting.CalcuCombatRange)
                            combatReach = ObjectManager.ObjectManager.Target.CombatReach;
                        if (ObjectManager.ObjectManager.Target.GetDistance <= MaxRange + combatReach && (ObjectManager.ObjectManager.Target.GetDistance >= MinRange - combatReach))
                        {
                            return true;
                        }
                    }

                    return false;
                }
                catch (Exception exception)
                {
                    Logging.WriteError("Spell > IsDistanceGood: " + exception);
                    return true;
                }
            }
        }

And to get player combat range (from fightcalss settings):

        public static float GetRange
        {
            get
            {
                try
                {
                    if (_instanceFromOtherAssembly != null)
                    {
                        float range;
                        if (_instanceFromOtherAssembly.Range < 6.5f)
                        {
                            range = 2.7f;
                            if (wManagerSetting.CurrentSetting.CalcuCombatRange && ObjectManager.ObjectManager.Target.IsValid)
                            {
                                    range += ObjectManager.ObjectManager.Target.CombatReach;
                            }
                            if (range < 3.5)
                                range = 3.5f;
                        }
                        else
                        {
                            range = _instanceFromOtherAssembly.Range;
                            if (wManagerSetting.CurrentSetting.CalcuCombatRange && ObjectManager.ObjectManager.Target.IsValid)
                            {
                                range += ObjectManager.ObjectManager.Target.CombatReach - 1;
                            }
                        }
                        return range;
                    }
                        
                    return 4.5f;
                }
                catch (Exception exception)
                {
                    Logging.WriteError("CustomClass > GetRange: " + exception);
                    return 5.0f;
                }
            }
        }

I will check that (GetRange and isgooddistance), I take note

Matenia

Elite user

I want to prevent stuttering movement from my fightclass starting a cast when the bot is in range but for Frostbolt, but the fightclass thinks it's not in range, so it walks closer.
How do you decide when to walk closer to the target? You take CustomClass.GetRange and do (pseudo code) - I think?:

while (Me.GetDistance(ObjectManager.Target) > CustomClass.GetRange){
  MovementManager.MoveTo(ObjectManager.Target.Position);
}
MovementManager.StopMoveTo(false, 500);

So if I make my code:
 

public Spell Frostbolt = new Spell("Frosbolt");
public float HitBox => ObjectManager.Target.CombatReach + Me.CombatReach;
public float Range => .MaxRange + HitBox;

public void Rotation()
{
  if(Fight.InFight && GetGlobalCooldown() == 0 && ObjectManager.Target.GetDistance - HitBox <= Range)
  {
    Lua.LuaDoString($"CastSpellByName('{spell.Name}')");
  }
}

it should work and never cast before it's close enough, right?

Matenia

Elite user

I realized why this works perfectly for TBC, btw.
Warmane (only TBC server atm) calculates spell distance from center to center (like on Blizzard realms). Vanilla private servers calculate distance end to end (hitbox to hitbox). This is a bug that wRobot has to work around, unfortunately.
After re-considering this, it's good if you add 

GetHitBoxtDistance

but I don't think this needs to be fixed really.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.