Jump to content

Seminko

Members
  • Posts

    225
  • Joined

  • Last visited

Posts posted by Seminko

  1. 3 minutes ago, Apexx said:

    I do believe Seminko did not define unitToAttack.

    Simply replace

    
    if (lowestHP != null && unitToAttack.IsValid && unitToAttack.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

    with:

    
    if (lowestHP != null && lowestHP.IsValid && lowestHP.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target

     

    Yea, that is my bad. Was copying stuff from my other FCs :) Let me update the original reply. Thx for correcting me.

  2. 14 hours ago, Lockem said:

    Like the title says...

    I'm working on a BM hunter fightclass. I'd like to find a way to make it prioritize low hp enemies when there are multiple aggro'd... I have no idea where to start though.

    Thanks,

    You need an OnFightLoop fight event.

    I'm not sure whether this is the correct way to handle events but it's the way I could come up with, since my knowledge of Csharp is very limited still... BUT, what I do is put the OnFightLoop event in a method and call it during initialization. Once it is called the events "are recognized" and will fire everytime you are in a fight loop.

    Disclaimer: this is not tested, put this together just now...

    public void TargetSwitcher() // needs to be called just once, ie during Initialize
    {
    	FightEvents.OnFightLoop += (unit, cancelable) => { // this code will loop everytime you are fighting
    		List<WoWUnit> attackers = ObjectManager.GetUnitAttackPlayer(); // gets all units attacking you
    		if (attackers.Count > 1) // if you are attacked by more than one mob
    		{
    			Logging.WriteDebug("More than 1 attackers detected.");
    			//WoWUnit highestHP = attackers.OrderBy(uo => uo.HealthPercent).LastOrDefault(); // sort the list based on HP from lowest to highest, pick highest
    			WoWUnit lowestHP = attackers.OrderBy(ou => ou.HealthPercent).FirstOrDefault(); // sort the list based on HP from lowest to highest, pick lowest
    			if (lowestHP != null && lowestHP.IsValid && lowestHP.IsAlive && !lowestHP.IsMyTarget) // if the lowest hp mob is valid, alive and NOT your current target
    			{
    				cancelable.Cancel = true; // not TOO sure about this one haha
    				Interact.InteractGameObject(lowestHP.GetBaseAddress); // switch to it
    				Fight.StartFight(lowestHP.GetBaseAddress); // start fighting it
    				Logging.WriteDebug("Switched to lowestHP target.");
    			}
    		}
    	};
    }

     

    As a bonus, check this post by Droidz. Might be usefull too.

     

    Let me know how it worked out for ya...

  3. I would like to report a bug.

    I've been working on a project non-stop today only to find out that GetIdByName is unreliable and apparently bugged.

    How to reproduce this bug (tried 4 times in a row and been indeed able to reproduce it):

    1. Close WRobot and open it afresh
    2. Go to Development Tools
    3. Run this code --> it returns 0
      var itemID = wManager.Wow.Helpers.ItemsManager.GetIdByName("Pet Rock");
      Logging.WriteDebug("[ItemID] " + itemID);

       

    4. Now run this code --> it properly returns "Pet Rock"
      var NameID = wManager.Wow.Helpers.ItemsManager.GetNameById(20030);
      Logging.WriteDebug("[NameID] " + NameID);

       

    5. Now run the first code again and it now correctly returns Pet Rock's item id 20030.

     

    Quote

    [D] 23:43:58 - [ItemID] 0
    [D] 23:44:03 - [NameID] Pet Rock
    [D] 23:44:07 - [ItemID] 20030

     

    Anyone who is reading this, I'd appreciate if you tried reproducing it and report back. Since we don't know if it's related to Vanilla only, any WoW version is fine for now.

    Thanks

    S.

     

    EDIT: tried with Empty Wallet as well... same thing

  4. 10 hours ago, reapler said:

    You may check first whether "sRogueSettings.CurrentSetting" is null:

    
        private void FoodManager()
        {
            try
            { 
                if (sRogueSettings.CurrentSetting == null)
                    robotManager.Helpful.Logging.Write("CurrentSetting is null");
                else
                    robotManager.Helpful.Logging.Write("CurrentSetting is not null");
            }
            catch (Exception e)
            {
                robotManager.Helpful.Logging.WriteError(e.ToString());
            }
        }

    You get probably "CurrentSetting is null" ;)

    So in this case this means you haven't initialized "CurrentSetting" = no instance to your object is given = "CurrentSetting" is null, hence you cannot accessing its properties.

    In the end you need to call "sRogueSettings.Load();" to create an instance.

    However If it's not the case, you may check for other variables against null.

    I'm stupid... did not have sRogueSettings.Load(); :wub:

  5. 1 hour ago, reapler said:

    Hello, if something crashes and it's not a stack overflow (recursive call) you may wrap your code in a try-catch statement:

    
        private void FoodManager()
        {
            try
            { 
                if (sRogueSettings.CurrentSetting.UseBuffFood && sRogueSettings.CurrentSetting.BuffFoodName != null && sRogueSettings.CurrentSetting.BuffFoodBuffName != null)
                {
                    uint foodID = wManager.Wow.Helpers.ItemsManager.GetIdByName(sRogueSettings.CurrentSetting.BuffFoodName);
                    if (!ObjectManager.Me.HaveBuff(sRogueSettings.CurrentSetting.BuffFoodBuffName) && ItemsManager.HasItemById(foodID) && wManagerSetting.CurrentSetting.FoodName != sRogueSettings.CurrentSetting.BuffFoodName)
                    {
                        wManagerSetting.CurrentSetting.FoodName = sRogueSettings.CurrentSetting.BuffFoodName;
                    }
                    else if (ObjectManager.Me.HaveBuff(sRogueSettings.CurrentSetting.BuffFoodBuffName) && wManagerSetting.CurrentSetting.FoodName != originalFoodSetting)
                    {
                        wManagerSetting.CurrentSetting.FoodName = originalFoodSetting;
                    }
                }
            }
            catch (Exception e)
            {
                robotManager.Helpful.Logging.WriteError(e.ToString());
            }
        }

    I think you have probably a null reference exception on your settings, so you would check for "sRogueSettings.CurrentSetting" whether it is null at first.

    And "sRogueSettings.CurrentSetting.BuffFoodName != null" is not necessary on a string, since checking against null will result always in false.

    Oh right, didn't think of that, still new and learning :)

    Yup, it was "Object reference not set to an instance of an object. in Main.FoodManager()"

    However still don't understand the exception. What is out of place? Everything seems to be set up correctly. How do I pinpoint where the error is?

  6. I'm at the end of my rope. For some reason this code crashes WRobot. I have it in a while loop. Log included...

    private void FoodManager()
    	{
    		if (sRogueSettings.CurrentSetting.UseBuffFood && sRogueSettings.CurrentSetting.BuffFoodName != null && sRogueSettings.CurrentSetting.BuffFoodBuffName != null)
    		{
    			uint foodID = wManager.Wow.Helpers.ItemsManager.GetIdByName(sRogueSettings.CurrentSetting.BuffFoodName);
    			if (!ObjectManager.Me.HaveBuff(sRogueSettings.CurrentSetting.BuffFoodBuffName) && ItemsManager.HasItemById(foodID) && wManagerSetting.CurrentSetting.FoodName != sRogueSettings.CurrentSetting.BuffFoodName)
    			{
    				wManagerSetting.CurrentSetting.FoodName = sRogueSettings.CurrentSetting.BuffFoodName;
    			}
    			else if (ObjectManager.Me.HaveBuff(sRogueSettings.CurrentSetting.BuffFoodBuffName) && wManagerSetting.CurrentSetting.FoodName != originalFoodSetting)
    			{
    				wManagerSetting.CurrentSetting.FoodName = originalFoodSetting;
    			}
    		}
    	}

     

    10 11 2017 21H30.log.html

  7. 1 hour ago, sjb211 said:

    Do you know how to solve the switching target to keep DOT way?
    Thanks if there is a way to share a complete solution

    I never got around to it as i gave my lock to a friend who leveled it further by hand.

    But with my current knowledge I would say look into FightEvents.OnFightLoop (or potentialy even FightEvents.OnFightEnd / FightEvents.OnFightStart).

    Just grab the number of targets you are willing to fight, put them in a list, and then cycle through that list using for example if (!u.HaveBuff("Corruption")) Then Interact.InteractGameObject(u). It also depends on how your fightclass is setup.

  8. On 3. 11. 2017 at 9:09 PM, krlitoz said:

    Blizzard just announced the development of Legacy Wow Servers at the 2017 Blizzcon.

    Do you plan on providing more support to the vanilla version of the bot for the official servers?

    I was just about to create a thread on this.

    I suspect they will use quite a bit of modern stuff in Classic. For example API / LUA. If a function get removed since Vanilla I don't pressume they will use it for classic just for the sake of remaining "pure". The thing to realize is that Classic WoW will not be the same game so a new Wrobot version will have to be created.

     

    However, I'm keen to hear @Droidz's take on this. Will a new version of Wrobot for Classic have to be created, since (pressumably) the offsets will be all messed up? If so, how long do you estimate it will take to get the bot up and running after release? Thanks mr.D

  9. Absolutely noob question.

    Inside the OnFightLoop I have WoWUnit currentTarget = etc.etc. What the heck do I need to do to be able to use it in an IF statement outside of the OnFightLoop?

    I want to test using it in my main rotation "if polyTarget.IsValid" (now gives an error) and if that is true I want to do "Interact.InteractGameObject(polyTarget.GetBaseAddress);" which also gives an error, saying it doesn't exist in the current context.

    Do I need to define it at the start? What type do I define it as?

  10. 4 minutes ago, Matenia said:

    You are actually subscribing to an event (hence the term event handler).
    https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/events/how-to-subscribe-to-and-unsubscribe-from-events

    So your entire code ALWAYS gets executed - but whatever follows this event (the original fighting code by wRobot) can be stopped by setting cancelable.Cancel to true.

    So both the OnFightLoop and my FightClass code will get executed, the only thing we are cancelling is wrobot's "default built in" fighting code / behavior? That's strange, kind of. If that is so, what would happen if I did:

    FightEvents.OnFightLoop += (unit, cancelable) => {
    	cancelable.Cancel = true;
    };

    Well, time to experiment...

  11. Sorry, I don't follow. My understanding is the OnFightLoop "loop" is acting like a while loop everytime I'm in combat, doing its thing continuously.

    Let's say, if I have the code below and the first argument would be true, cancelable.Cancel would be set to true, what would happen? It would skip the second if argument in the OnFightLoop and start right from the start?

    FightEvents.OnFightLoop += (unit, cancelable) => {
    	if (ObjectManager.Target.GetDistance <= 8 && (!ObjectManager.Target.HaveBuff("Frost Nova") || !ObjectManager.Target.HaveBuff("Frostbite")) && (_timerFrostNova == null || _timerFrostNova.IsReady) && ObjectManager.Target.HealthPercent >= 20)
    	{
    		Move.StrafeRight(Move.MoveAction.PressKey, 1250);
    		cancelable.Cancel = true;
    	}
    	
    	if (ObjectManager.Target.GetDistance <= 10 && (!ObjectManager.Target.HaveBuff("Frost Nova") || !ObjectManager.Target.HaveBuff("Frostbite")) && (_timerFrostNova == null || _timerFrostNova.IsReady) && ObjectManager.Target.HealthPercent >= 20)
    	{
    		Move.StrafeLeft(Move.MoveAction.PressKey, 1250);
    	}
    };

    If that is the case can I disable OnFightLoop? I'm looking at the += and thinking if I did -= it would somehow remove things from the OnFightLoop? If so, how?

     

    Btw guys, this is great, this is how I like to learn, not sitting in books, that doesn't work for me at all. I have to dive right in and figure things out on real life examples. ;) Thanks for being so helpful!

  12. 1 hour ago, Matenia said:

    cancelable.Cancel = true is correct. However, I recommend NOT breaking the OnFightLoop event handler UNTIL your target has been successfully polymorphed. You can solve this with a while loop (Thread.Sleep inside) until poly is on another target.

    Just so I understand... From my testing today I found out that if I have OnFightLoop it combines my BAU rotation with the OnFightLoop rotation. It doesn't really seem it superseeds the BAU rotation. So if I go cancelable.Cancel = true; what will it cancel? The OnFightLoop rotation or everything else except the OnFightLoop rotation?

    Can Cancel be used from within the OnFightLoop?

×
×
  • Create New...