What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

prevent dismount when attacked while gathering

joededsmoeded

New Member
Joined
Oct 15, 2015
Messages
3
Reaction score
0
How do I prevent dismount when getting attacked. I just want it to gather, and fly away and ignore the attacking mob. With the garrison stables you don't get dismounted so there is no reason to fight the mobs.
 
You could probably just modify the code I use in my Druid Harvest Assist plugin.

Replace all instances of "CancelShapeshiftForm" with "Dismount." Not 100% sure but it might work. I think that Honorbuddy invokes Dismount() once combat is called, but I'm not certain. I've modified my plugin below. Give it a try and see if it works.

Code:
using Styx;using Styx.Common;
using Styx.CommonBot;
using Styx.Plugins;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using System;
using System.Linq;


namespace DruidHarvestAssist
{
    public class DruidHarvestAssist : HBPlugin
    {
        private static bool Harvesting;
        private static bool Initialize;
        private bool On;
        public LocalPlayer Me { get { return StyxWoW.Me; } }


        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 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;
            }
        }


        private static string Left(string s, int c)
        {
            return String.IsNullOrEmpty(s) ? s : s.Substring(0, Math.Min(c, s.Length));
        }


        public override string Author
        {
            get { return "donnamonna & the community"; } 
        }
        public override string Name
        {
            get { return "Druid Harvest Assist"; }
        }
        public override Version Version
        {
            get { return new Version(0, 4); }
        }
        public override bool WantButton
        {
            get { return false; }
        }
        public override void Pulse()
        {
            if (!Initialize)
            {
                Harvesting = TreeRoot.Current != null &&
                    "GATHERBUDDY2" == Left(TreeRoot.Current.Name, 12).ToUpper();
                if (Harvesting)
                {
                    Logging.Write(System.Windows.Media.Colors.Aqua, "Druid Harvest Assist enabled");
                }
                On = false;
                Initialize = true;
            }
            SupressFormSwitch();
            Harvest();
            LeaveCombatHerb();
            LeaveCombatNoHerb();
        }


        private void Harvest()
        {
            if (!Me.IsValid || !StyxWoW.IsInGame || !StyxWoW.IsInWorld)
                return;
            if (Me.Combat && HerbWithinInteractRange != null && !Me.IsMoving)
            {
                try
                {
                    ObjectManager.Update();
                    Herb.Interact();
                    Logging.Write(System.Windows.Media.Colors.LightGreen, "<DHA> Forcing Herb Collection");
                }
                catch (Exception e)
                {
                    Logging.WriteException(e);
                    throw;
                }
            }
        }


        private void LeaveCombatNoHerb()
        {
            if (!Me.IsValid || !StyxWoW.IsInGame || !StyxWoW.IsInWorld)
                return;
            if (Me.Combat && !Me.IsMoving && HerbWithinInteractRange == null)
            {
                WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend, TimeSpan.FromMilliseconds(200));
                Logging.Write(System.Windows.Media.Colors.Pink, "<DHA> Exit Combat");
            }
        }


        private void SupressFormSwitch()
        {
            if (!Me.IsValid || !StyxWoW.IsInGame || !StyxWoW.IsInWorld)
                return;
            if (!Me.Combat)
            {
                if (!On)
                {
                    Lua.DoString("oldDismount = Dismount; Dismount = function() end");
                    On = true;
                    Logging.Write(System.Windows.Media.Colors.Aqua, "<DHA> SupressDismount disabled");
                }
            }
            else if (Me.Combat && On)
            {
                Lua.DoString("Dismount = oldDismount;");
                On = false;
                Logging.Write(System.Windows.Media.Colors.Aqua, "<DHA> SupressDismount enabled");
            }
        }


        private void LeaveCombatHerb()
        {
            if (!Me.IsValid || !StyxWoW.IsInGame || !StyxWoW.IsInWorld)
                return;
            if (Me.Combat && Me.HealthPercent < 90)
            {
                WoWMovement.Move(WoWMovement.MovementDirection.JumpAscend, TimeSpan.FromMilliseconds(200));
                Logging.Write(System.Windows.Media.Colors.Pink, "<DHA> Exit Combat");
            }
        }
    }
}

Be aware that this (if it works at all) will only work with herb gathering, not mining.
 
Last edited:
Thank you for attempting to help donnamonna, but now my character attacks while jumping. Didn't use to jump before. Kinda funny to watch though, just jumps up and down constantly while still fighting.
 
Use an empty Combat Routine like SitStupid and see if that helps. Sometimes once your CR gets a combat() call it will start casting spells which will dismount you.

SitStupid CR:

Code:
using Styx;
using Styx.CommonBot.Routines;


namespace SitStupid
{
    class SitStupid : CombatRoutine
    {
        public override void Combat()
        {
            // I just sit in a spot and play stupid!
        }
        public override sealed string Name { get { return "SitStupid"; } }
        public override WoWClass Class { get { return StyxWoW.Me.Class; } }
    }
}
 
Last edited:
That still hasn't solved everything but it has made my life easier for altering this profile. Thank you very much, its appreciated.
 
Back
Top