• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Focus cast - searched with no luck

    Discussion in 'Honorbuddy Support' started by Nightskine, Sep 18, 2011.

    1. Nightskine

      Nightskine Member

      Joined:
      Oct 30, 2010
      Messages:
      150
      Likes Received:
      1
      Trophy Points:
      18
      Hi all,

      I'm trying to cast spells on my focus target but am not having any luck.

      I searched the forums and found this code but I couldnt get it to work for me.

      Code:
      public WoWUnit GetFocus
              {
                  get
                  {
                      string name = Lua.GetReturnVal("return GetUnitName(\"" + "focus" + "\");",0);
                      WoW units = ObjectManager.GetObjectsOfType(true, true).First((unit) => unit.Name == name && name != null && name != string.Empty && name.ToLower() != "nil");
                      if (units != null)
                      {
                          return units;
                      }
                      return null;
                }
              }  
      What i need is a code to return WoWPlayer as who ever my focus target is and null if i have no target so I could later call them by WoWPlayer p = GetFocus();

      I appreciate any help since I've been stumped with this for quite a while now.

      Thanks,

      NightS
       
    2. Nightskine

      Nightskine Member

      Joined:
      Oct 30, 2010
      Messages:
      150
      Likes Received:
      1
      Trophy Points:
      18
      Bump .... help?
       
    3. raphus

      raphus Administrator Staff Member Moderator Buddy Core Dev

      Joined:
      Jun 17, 2010
      Messages:
      2,094
      Likes Received:
      492
      Trophy Points:
      83
      Code:
      SpellManager.Cast("ImbaStrike", StyxWoW.Me.FocusedUnit);
      
       
    4. strix

      strix New Member

      Joined:
      Feb 13, 2010
      Messages:
      442
      Likes Received:
      18
      Trophy Points:
      0
      i don't see anything like StyxWoW.Me.FocusedUnit in references, there is only SetFocus()

      I'm using that:
      Code:
      private WoWUnit FocusTarget
      {
          get
          {
          return ObjectManager.GetObjectByGuid<WoWUnit>( 
              ulong.Parse(
                  Lua.GetReturnValues("return UnitGUID(\"focus\")")[0].Replace("0x", ""),
                  System.Globalization.NumberStyles.HexNumber));
          }
      }
      Step by step:
      1. Get unit's GUID from Lua (string representing hexadecimal number),
      2. Cut the "0x",
      3. Convert to ulong,
      4. Get object by GUID,
       
    5. raphus

      raphus Administrator Staff Member Moderator Buddy Core Dev

      Joined:
      Jun 17, 2010
      Messages:
      2,094
      Likes Received:
      492
      Trophy Points:
      83
      latest hb release should have Me.FocusedUnit and Me.FocusedUnitGuid
       

    Share This Page