• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • [Request] Druid Herbalism Flight Form IGNORE COMBAT

    Discussion in 'Requests' started by asdfowkw, Sep 30, 2012.

    1. asdfowkw

      asdfowkw Community Developer

      Joined:
      Jan 15, 2010
      Messages:
      263
      Likes Received:
      0
      Trophy Points:
      16
      As the title probably sais it all its very short, i just want a working version of a plugin that makes the druid herbfriendly so it just herbs and fly away when entering combat.
       
    2. c4sper

      c4sper New Member

      Joined:
      Sep 13, 2012
      Messages:
      91
      Likes Received:
      0
      Trophy Points:
      0
      is there a possibility? on search function i can't find anything.
       
    3. asdfowkw

      asdfowkw Community Developer

      Joined:
      Jan 15, 2010
      Messages:
      263
      Likes Received:
      0
      Trophy Points:
      16
      There was a plugin that did this before but it dosnt work anymore.
       
    4. asdfowkw

      asdfowkw Community Developer

      Joined:
      Jan 15, 2010
      Messages:
      263
      Likes Received:
      0
      Trophy Points:
      16
      Here is the old plugin, if someone could check whats outdated please =)

      Code:
      /* * Druid Harvest Helper
       *      Will lock HB if we are within 10 yards of herb,
       *      in Flight Form and under fire (in combat) and
       *      attempt to harvest herb itself.
       *      
       *      As GB2's harvesting is not accessible from outside
       *      i had to write my own harvesting, 
       *      here are "implications":
       *      - GB2 might add those nodes to blacklist even if DHH
       *        successfully harvest them,
       *      - every 2 minutes DHH will verify GB2 blacklist
       *        removing those actually harvested by DHH,
       *        
       * thanks to bobby53 that i even started writing this :)
       *        
       * Author:  strix
       */
      
      
      using System;
      using System.Collections.Generic;
      using System.Drawing;
      using System.Linq;
      using Bots.Gatherbuddy;
      using Styx;
      using Styx.Combat.CombatRoutine;
      using Styx.Helpers;
      using Styx.Logic.BehaviorTree;
      using Styx.Logic.Combat;
      using Styx.Logic.Pathing;
      using Styx.Plugins.PluginClass;
      using Styx.WoWInternals;
      using Styx.WoWInternals.WoWObjects;
      
      
      namespace DruidHarvestHelper
      {
          public class DruidHarvestHelper : HBPlugin
          {
              public override string Name
              {
                  get { return "Druid's Harvest Helper"; }
              }
      
      
              public override string Author
              {
                  get { return "strix"; }
              }
      
      
              public override Version Version
              {
                  get { return new Version(2, 1, 3); }
              }
      
      
              public override bool WantButton
              {
                  get { return false; }
              }
      
      
              public LocalPlayer Me
              {
                  get { return ObjectManager.Me; }
              }
      
      
              private static bool _isHarvesting;
              private static bool _haveInitialized;
      
      
              private readonly HashSet<WoWPoint> _latestHarvests = new HashSet<WoWPoint>();
              private WoWGameObject _currentHerb;
      
      
              private readonly WaitTimer _wtVerifyGb2Blacklist = new WaitTimer(new TimeSpan(0, 2, 0));
              private readonly WaitTimer _wtHelper = new WaitTimer(new TimeSpan(0, 0, 3));
              private readonly WaitTimer _wtInteractHelper = StyxWoW.Me.Race == WoWRace.Tauren ? 
                  new WaitTimer(new TimeSpan(0, 0, 0, 1, 300))
                  : new WaitTimer(new TimeSpan(0, 0, 0, 2, 0));
      
      
              private bool _interactedFlag;
              private bool _shouldAbandonHerb;
              private int _failCounter;
      
      
              private const int MaxFailedAttempts = 5;
      
      
              public override void Pulse()
              {
                  if (!_haveInitialized)
                  {
                      _isHarvesting = TreeRoot.Current != null && 
                          "GATHERBUDDY2" == Left(TreeRoot.Current.Name, 12).ToUpper() &&
                          Me.Class == WoWClass.Druid;
                      if (_isHarvesting)
                      {
                          slog(
                               "Druid using Gatherbuddy 2 detected... locking HB and launching Druid Harvest Helper harvest if following conditions are met:");
                          slog(" - we are in Flight Form,");
                          slog(" - we are under fire,");
                          slog(" - there is herb withing 10 yards range,");
                      }
                      _haveInitialized = true;
                  }
      
      
                  ChooseForm();
      
      
                  if (_isHarvesting &&
                      (_interactedFlag || HerbWithinTen2DRange != null) &&
                      (Me.Shapeshift == ShapeshiftForm.FlightForm || Me.Shapeshift == ShapeshiftForm.EpicFlightForm))
                  {
                      Cast("Barkskin");
                      HarvestHerb();
                  }
                  
                  Reset();
      
      
                  if (!Me.Combat && _wtVerifyGb2Blacklist.IsFinished)
                      VerifyGB2BlacklistAndClearLatestHarvests();
              }
      
      
              private static string Left(string s, int c)
              {
                  return String.IsNullOrEmpty(s) ? s : s.Substring(0, Math.Min(c, s.Length));
              }
      
      
              private void slog(string format, params object[] args)
              {
                  Logging.Write(Color.Olive, "[Harvest Helper] " + format, args);
              }
      
      
              private void elog(string format, params object[] args)
              {
                  Logging.Write(Color.Red, "[Harvest Helper] " + format, args);
              }
      
      
              private void dlog(string format, params object[] args)
              {
                  Logging.WriteDebug(Color.Olive, "<Harvest Helper> " + format, args);
              }
      
      
              public static WoWGameObject HerbWithinInteractRange
              {
                  get
                  {
                      ObjectManager.Update();
                      IOrderedEnumerable<WoWGameObject> tars =
                          (from o in ObjectManager.GetObjectsOfType<WoWGameObject>(false, false)
                           where
                               o.IsHerb && o.WithinInteractRange &&
                               o.RequiredSkill <= StyxWoW.Me.GetSkill("Herbalism").CurrentValue
                           orderby o.DistanceSqr ascending
                           select o);
                      return tars.Count() > 0 ? tars.First() : null;
                  }
              }
      
      
              public static WoWGameObject HerbWithinTen2DRange
              {
                  get
                  {
                      ObjectManager.Update();
                      IOrderedEnumerable<WoWGameObject> tars =
                          (from o in ObjectManager.GetObjectsOfType<WoWGameObject>(false, false)
                           where
                               o.IsHerb && o.Distance2D < 10 &&
                               o.RequiredSkill <= StyxWoW.Me.GetSkill("Herbalism").CurrentValue
                           orderby o.DistanceSqr ascending
                           select o);
                      return tars.Count() > 0 ? tars.First() : null;
                  }
              }
      
      
              public static WoWGameObject Herb
              {
                  get
                  {
                      ObjectManager.Update();
                      IOrderedEnumerable<WoWGameObject> tars =
                          (from o in ObjectManager.GetObjectsOfType<WoWGameObject>(false, false)
                           where o.IsHerb && o.RequiredSkill <= StyxWoW.Me.GetSkill("Herbalism").CurrentValue
                           orderby o.DistanceSqr ascending
                           select o);
                      return tars.Count() > 0 ? tars.First() : null;
                  }
              }
      
      
              public void VerifyGB2BlacklistAndClearLatestHarvests()
              {
                  slog("Verifying GB2 blacklist.");
                  foreach (WoWPoint point in _latestHarvests)
                  {
                      GatherbuddyBot.BlacklistNodes.RemoveWhere(p => p == point);
                  }
                  _latestHarvests.Clear();
                  _wtVerifyGb2Blacklist.Reset();
              }
      
      
              public void HarvestHerb()
              {
                  if (!_interactedFlag && Me.Combat)
                  {
                      slog("Starting harvesting...");
                      dlog("HarvestHerb(): starting...");
                      if (_currentHerb == null)
                      {
                          dlog("HarvestHerb(): Assigning currentHerb...");
                          _currentHerb = Herb;
                      }
      
      
                      if (_currentHerb.Distance2D > 5)
                      {
                          WoWMovement.ClickToMove(WoWMathHelper.CalculatePointFrom(Me.Location, Herb.Location, 1));
                          dlog("HarvestHerb(): Getting within interaction range of herb...");
                          _wtHelper.Reset();
                          while (_currentHerb.Distance2D > 5)
                          {
                              if (_wtHelper.IsFinished)
                              {
                                  dlog("HarvestHerb(): currentHerb.Distance2d < 5 timed out...");
                                  break;
                              }
                          }
                      }
                      if (Me.IsFlying)
                      {
                          dlog("HarvestHerb(): Getting on the ground...");
                          ActuallyStopMoving();
                          Navigator.PlayerMover.Move(WoWMovement.MovementDirection.Descend);
                          _wtHelper.Reset();
                          while (Me.IsFlying && !_wtHelper.IsFinished) ;
                      }
                      dlog("HarvestHerb(): Interacting with currentHerb started..");
                      _failCounter = 0;
                      while (_currentHerb.IsValid && !_currentHerb.IsDisabled && _currentHerb.CanUseNow())
                      {
                          ObjectManager.Update();
                          _wtInteractHelper.Reset();
                          _currentHerb.Interact();
                          if (_failCounter > MaxFailedAttempts)
                          {
                              dlog("HarvestHerb(): Harvesting herb failed for " + _failCounter + " times, abandoning it...");
                              _shouldAbandonHerb = true;
                              break;
                          }
                          while (!Me.IsCasting)
                          {
                              if (_wtInteractHelper.IsFinished)
                              {
                                  _failCounter++;
                                  dlog("HarvestHerb(): failed for " + _failCounter + " time...");
                                  break;
                              }
                          }
                      }
                      if (!_shouldAbandonHerb)
                          dlog("HarvestHerb(): Interacting with currentHerb finished..");
                      _interactedFlag = true;
                  }
                  if (_interactedFlag)
                  {
                      if (!Me.IsFlying)
                      {
                          dlog("HarvestHerb(): JumpAscend to exit combat...");
                          _wtHelper.Reset();
                          while(Me.Combat && !_wtHelper.IsFinished)
                          {
                              //Navigator.PlayerMover.Move(
                              //    WoWMovement.MovementDirection.JumpAscend);
                              if (!Me.IsMoving) WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend, TimeSpan.FromMilliseconds(400)); System.Threading.Thread.Sleep(400);
                          }
                          //while (Me.Combat && !_wtHelper.IsFinished) ;
                          ActuallyStopMoving();
                      }
                      if (_shouldAbandonHerb)
                          _currentHerb = null;
                      if (_currentHerb != null)
                      {
                          if (_latestHarvests.Add(_currentHerb.Location))
                              dlog("Added currentHerb to latestHarvests");
                          _currentHerb = null;
                          _interactedFlag = false;
                      }
                      dlog("HarvestHerb() finished.");
                      slog("Harvesting finished.");
                      return;
                  }
              }
      
      
              public void ActuallyStopMoving()
              {
                  var timeout = new WaitTimer(new TimeSpan(0, 0, 3));
                  timeout.Reset();
                  dlog("Stopping movement...");
                  while(Me.IsMoving || timeout.IsFinished)
                  {
                      Navigator.PlayerMover.MoveStop();
                      WoWMovement.MoveStop();
                  }
                  if (!Me.IsMoving)
                      dlog("Movement stopped");
              }
      
      
              private void ChooseForm()
              {
                  if (_isHarvesting &&
                      !(Me.GotTarget &&
                        !Me.CurrentTarget.IsFriendly &&
                        !Me.CurrentTarget.Dead
                       ) &&
                      !Me.Combat &&
                      !Me.Mounted &&
                      !Me.HasAura("Aquatic Form") &&
                      !Me.HasAura("Travel Form") &&
                      Me.IsMoving)
                  {
                      if (Me.IsSwimming)
                          Cast("Aquatic Form");
      
      
                      if (!Me.IsSwimming)
                          if (!Cast("Swift Flight Form"))
                              Cast("Flight Form");
                  }
              }
      
      
              private void Reset()
              {
                  _interactedFlag = false;
                  _currentHerb = null;
                  _failCounter = 0;
                  _shouldAbandonHerb = false;
              }
      
      
              private bool Cast(string spellName)
              {
                  return
                      SpellManager.HasSpell(spellName) &&
                      SpellManager.CanCast(spellName) &&
                      SpellManager.Cast(spellName);
              }
          }
      }
       
    5. diablofan

      diablofan Member

      Joined:
      Apr 27, 2012
      Messages:
      446
      Likes Received:
      1
      Trophy Points:
      18
      Need this badly, pls someone update that plugin was great
       
    6. srvas

      srvas New Member

      Joined:
      Oct 7, 2012
      Messages:
      121
      Likes Received:
      0
      Trophy Points:
      0
      please :)
       
    7. Gatherit

      Gatherit New Member Buddy Store Developer

      Joined:
      Aug 28, 2010
      Messages:
      2,331
      Likes Received:
      68
      Trophy Points:
      0
      I agree. I loved this little plugin.
       
    8. srvas

      srvas New Member

      Joined:
      Oct 7, 2012
      Messages:
      121
      Likes Received:
      0
      Trophy Points:
      0
      we all do! let's beg for this plugin :p
       
    9. Niv

      Niv New Member

      Joined:
      Jul 8, 2012
      Messages:
      257
      Likes Received:
      9
      Trophy Points:
      0
      I did fix the references back when the API changes were first introduced. However, I dont have a max level druid right now so I cant check if this Plugin still works with the current HB Versions. It should be... Please let me know guys!

      View attachment DruidGatherHelper5_v5_0.cs

      edit: ha! Just loaded an old Uldum herb profile. It survived "The whiptail of death" Hotspot flawlessly! Have fun!
       
      Last edited: Oct 7, 2012
    10. Gatherit

      Gatherit New Member Buddy Store Developer

      Joined:
      Aug 28, 2010
      Messages:
      2,331
      Likes Received:
      68
      Trophy Points:
      0
      So far it wont show up in pugins after adding it to the folder.
       
      Last edited: Dec 21, 2012
    11. Niv

      Niv New Member

      Joined:
      Jul 8, 2012
      Messages:
      257
      Likes Received:
      9
      Trophy Points:
      0
      Did you put it in a sub folder inside plugins/ ?
      This changed from older Honorbuddy versions. It wont load plugins located directly in plugins/.
       
    12. Gatherit

      Gatherit New Member Buddy Store Developer

      Joined:
      Aug 28, 2010
      Messages:
      2,331
      Likes Received:
      68
      Trophy Points:
      0
      Testing now. I put it in a folder now it's showing up.
       
    13. Gatherit

      Gatherit New Member Buddy Store Developer

      Joined:
      Aug 28, 2010
      Messages:
      2,331
      Likes Received:
      68
      Trophy Points:
      0
      lol I died because it didnt dismount and it sat there and let the mobs beat on it instead. It worked fine the first few times it had aggro. I'll test a bit more.
       
    14. Gatherit

      Gatherit New Member Buddy Store Developer

      Joined:
      Aug 28, 2010
      Messages:
      2,331
      Likes Received:
      68
      Trophy Points:
      0
      The sad thing is all the mobs in mop interrupt the harvesting unlike cata where it was just a push back on harvesting. Sadly this wont work because in flight form it keeps trying until you eventually die from being interrupted. THis is a no go :(
       
    15. srvas

      srvas New Member

      Joined:
      Oct 7, 2012
      Messages:
      121
      Likes Received:
      0
      Trophy Points:
      0
      well, if you're a tauren druid with 0.5 sec herb, you won't have this problem
       
    16. asdfowkw

      asdfowkw Community Developer

      Joined:
      Jan 15, 2010
      Messages:
      263
      Likes Received:
      0
      Trophy Points:
      16
      Thanks alot for updating this :eek: gonna try it on one of my zillion taurens today <3<3<3
       
    17. srvas

      srvas New Member

      Joined:
      Oct 7, 2012
      Messages:
      121
      Likes Received:
      0
      Trophy Points:
      0
      Make me know if this works well on a tauren 90 druid please :D thanks
       
    18. undefined

      undefined Member

      Joined:
      Sep 23, 2012
      Messages:
      38
      Likes Received:
      0
      Trophy Points:
      6
      Code:
      [16:25:24.059 D] System.NullReferenceException: Object reference not set to an instance of an object.
         at DruidHarvestHelper.DruidHarvestHelper.<get_HerbWithinTen2DRange>b__4(WoWGameObject o) in d:\home\games\Honorbuddy\Honorbuddy_Latest\Plugins\DruidGatherHelper\DruidGatherHelper5_v5_0.cs:line 160
         at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
         at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
         at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
         at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
         at DruidHarvestHelper.DruidHarvestHelper.get_HerbWithinTen2DRange() in d:\home\games\Honorbuddy\Honorbuddy_Latest\Plugins\DruidGatherHelper\DruidGatherHelper5_v5_0.cs:line 164
         at DruidHarvestHelper.DruidHarvestHelper.Pulse() in d:\home\games\Honorbuddy\Honorbuddy_Latest\Plugins\DruidGatherHelper\DruidGatherHelper5_v5_0.cs:line 101
         at Styx.Plugins.PluginWrapper.Pulse()
       
    19. diablofan

      diablofan Member

      Joined:
      Apr 27, 2012
      Messages:
      446
      Likes Received:
      1
      Trophy Points:
      18
      IT FUCKING WORKS NOW !!! for Tauren druid !!! :)

      edit: sometimes its not working thou, + atm GB2 is broken as hell, still not worth boting
      Code:
      <Harvest Helper> HarvestHerb(): Interacting with currentHerb started..
      <Harvest Helper> is valid
      <Harvest Helper> is not disabled
      <Harvest Helper> can use now
      <Harvest Helper> in while loop
      <Harvest Helper> in while loop
      <Harvest Helper> HarvestHerb(): failed for 1 time...
      <Harvest Helper> in while loop
      <Harvest Helper> HarvestHerb(): failed for 2 time...
      <Harvest Helper> HarvestHerb(): Interacting with currentHerb finished..
      <Harvest Helper> HarvestHerb(): JumpAscend to exit combat...
      <Harvest Helper> Stopping movement...
      <Harvest Helper> Movement stopped
      <Harvest Helper> Added currentHerb to latestHarvests
      <Harvest Helper> HarvestHerb() finished.
      [Harvest Helper] Harvesting finished.
      MoveStop failed for JumpAscend
       
      Last edited: Oct 17, 2012
    20. srvas

      srvas New Member

      Joined:
      Oct 7, 2012
      Messages:
      121
      Likes Received:
      0
      Trophy Points:
      0
      not working for me
       

    Share This Page