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

Coding Help!!

BPAlpha

New Member
Joined
Jan 15, 2010
Messages
594
Reaction score
41
im in process for writing a plugin for HB that makes bandages for Rogue and uses at less 55% health.. most the code is in place but what i want to know is how do i get plugin to check if firstaid skill is high enough to cast?? ie

woolen cloth has to be 80 skill but code i using it trying to make at 50??

any help would be great :)
 
I initially posted a code snippet but it didn't function as I thought so deleted it to avoid confusion. But take a look at AutoAngler code, that checks skill level etc to see if it should train/apply lure and whatnot.
 
Last edited:
codes in place now but ive added trainer function to it but keep trying to train all the time.. runs away from trainer then back again here is snipprt of code that im using for trainer any help would be great..

Code:
private void firsttrain()
        {
            List<WoWUnit> WoWUnitList = ObjectManager.GetObjectsOfType<WoWUnit>();
            foreach (WoWUnit nearby in WoWUnitList)
            {
                foreach (Trainer t in firsttrainer)
                {
                    if ((t.ID == nearby.Entry) && (t.team.Equals(meteam) || t.team.Equals("b")))
                    {
                        Logging.Write("Running to Trainer");
                        while (ObjectManager.Me.Location.Distance(nearby.Location) > 25)
                        {
                            Styx.Logic.Pathing.Navigator.MoveTo(nearby.Location);
                            Thread.Sleep(100);
                        }
                        ObjectManager.Update();
                        nearby.Target();
                        Thread.Sleep(2000);
                        nearby.Interact();
                        Thread.Sleep(2000);
                        try
                        {
                            if (GossipFrame.Instance.IsVisible)
                            {
                                foreach (var option in GossipFrame.Instance.GossipOptionEntries)
                                {
                                    if (option.Type == GossipEntry.GossipEntryType.Trainer)
                                    {
                                        GossipFrame.Instance.SelectGossipOption(option.Index);
                                        break;
                                    }
                                }
                            }
                        }
                        catch (Exception e) { Logging.Write(e.ToString()); }
                        Thread.Sleep(2000);
                        Logging.Write("Training First Aid");
                        Lua.DoString("BuyTrainerService(0)");
                        Thread.Sleep(5000);
                        Lua.DoString("CloseTrainer()");
                        
                    }
                }
            }
        
        }

        private bool needtrain()
        {
             if (((_firstAid.MaxValue == 50) && (_firstAid.CurrentValue >= 40)) || ((_firstAid.MaxValue == 50) && (_firstAid.CurrentValue >= 50)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 80)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 115)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 150)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 180)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 210)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 225)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 240)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 275)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 290)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 300)))
             {
                 return true;
             }
             return false;
         }
 
You could add a bool to act as a switch kind of thing. And have it like:
Code:
[COLOR="#4169e1"]private static bool goTrain = false;[/COLOR]
private void firsttrain()
        {
            List WoWUnitList = ObjectManager.GetObjectsOfType();
            foreach (WoWUnit nearby in WoWUnitList)
            {
                foreach (Trainer t in firsttrainer)
                {
                    if ((t.ID == nearby.Entry) && (t.team.Equals(meteam) || t.team.Equals("b")))
                    {
                        Logging.Write("Running to Trainer");
                        while (ObjectManager.Me.Location.Distance(nearby.Location) > 25)
                        {
                            Styx.Logic.Pathing.Navigator.MoveTo(nearby.Location);
                            Thread.Sleep(100);
                        }
                        ObjectManager.Update();
                        nearby.Target();
                        Thread.Sleep(2000);
                        nearby.Interact();
                        Thread.Sleep(2000);
                        try
                        {
                            if (GossipFrame.Instance.IsVisible)
                            {
                                foreach (var option in GossipFrame.Instance.GossipOptionEntries)
                                {
                                    if (option.Type == GossipEntry.GossipEntryType.Trainer)
                                    {
                                        GossipFrame.Instance.SelectGossipOption(option.Index);
                                        break;
                                    }
                                }
                            }
                        }
                        catch (Exception e) { Logging.Write(e.ToString()); }
                        Thread.Sleep(2000);
                        Logging.Write("Training First Aid");
                        Lua.DoString("BuyTrainerService(0)");
                        Thread.Sleep(5000);
                        Lua.DoString("CloseTrainer()");
                        [COLOR="#4169e1"]goTrain = false;[/COLOR]
                    }
                }
            }
        
        }

        private bool needtrain()
        {
             if (((_firstAid.MaxValue == 50) && (_firstAid.CurrentValue >= 40)) || ((_firstAid.MaxValue == 50) && (_firstAid.CurrentValue >= 50)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 80)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 115)) || ((_firstAid.MaxValue == 150) && (_firstAid.CurrentValue >= 150)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 180)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 210)) || ((_firstAid.MaxValue == 225) && (_firstAid.CurrentValue >= 225)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 240)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 275)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 290)) || ((_firstAid.MaxValue == 300) && (_firstAid.CurrentValue >= 300)))
             {
                 [COLOR="#4169e1"]goTrain = true;[/COLOR]
                 return true;
             }
             return false;
         }

And have something like
Code:
public override void Pulse()
{
     if (goTrain == true)
     {
          firsttrain();
     }
}

And use needtrain(); in the Pulse somewhere.
That probably wont work the way I've written it but something along those lines should work.
 
you problem lies here

Code:
while (ObjectManager.Me.Location.Distance(nearby.Location) > 25)
change to
Code:
while (ObjectManager.Me.Location.Distance(nearby.Location) > ObjectManager.Me.InteractRange)

or alternatively
Code:
while (!nearby.WithinInteractRange)
 
Last edited:
cheers highvoltz works great now m8 will release once bugs ironed out :)
 
Back
Top