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

BotBase Programming, IsPrimaryType, RequirementsMet

Narayan

Member
Joined
Oct 26, 2010
Messages
405
Reaction score
2
Hi Guys,

I was wondering if anyone had any info of the implementation of IsPrimaryType, RequirementsMet in BotBases. I can't find anything in the wiki and not quite sure how I should be implementing it. I.e how do I give control back to the primary type and then take it back, how do I declare to bot base as a secondary type.
 
If the botbase returns false for IsPrimaryType, Mixed Mode will be checking for conditions in RequirementsMet in every tick. If RequirementsMet returns true, it will Start() the the bot. The bot will be running until RequirementsMet returns false and Stop() will be called.

This code snippet is from Instancebuddy. Basicly the RequirementsMet returns true while you are in an instance, you died in instance or you are not queued yet. Returns false otherwise, so main bot runs during that time

Code:
        public override bool IsPrimaryType
        {
            get
            {
                return false;
            }
        }

        public override bool RequirementsMet
        {
            get
            {
                if (Me.HasAura("Dungeon Deserter"))
                    return false;

                if (Me.IsInInstance)
                    return true;

                if (DiedInInstance)
                    return true;

                return Mode == null || Mode == "nil";
            }
        }
 
Hi Guys,

I was wondering if anyone had any info of the implementation of IsPrimaryType, RequirementsMet in BotBases. I can't find anything in the wiki and not quite sure how I should be implementing it. I.e how do I give control back to the primary type and then take it back, how do I declare to bot base as a secondary type.

It's used by MixedMode so it know if a bot is a primary or secondary type.
If you want your bot to be a secondary type you need to override 'IsPrimaryType' and make it return false, that way you can run it along with other bots such as the grindbot, quest, ab, gb etc.

RequirementsMet is the condition/s that needs to be fullfilled before Mixedmode switches to that bot.

Here's how we implement in the BgBot.

Code:
public override bool IsPrimaryType { get { return false; } }

public override bool RequirementsMet
{
    get
    {
        // Obviously. Any time we're in a BG, we should be running the BG bot. Period.
        if (Battlegrounds.IsInsideBattleground)
            return true;

        // If we're in combat, ignore this entire bot. (Only outside of BGs)
        // Above check makes sure this doesn't get hit while in BGs. So it should be safe to do this!
        // This stops us from dying stupidly.
        if (Me.Combat)
            return false;

        // Obviously if we are dead we can't run this bot, not even queue or accept bg ports.
        if (!Me.IsAlive)
            return false;

        // Ignore if we have deserter for some reason
        if (ObjectManager.Me.HasAura("Deserter"))
            return false;

        // Check for stuff we need to queue for
        int queueCount = 0;
        if (BGBotSettings.Instance.BG1 != BattlegroundType.None)
            queueCount++;
        if (BGBotSettings.Instance.BG2 != BattlegroundType.None)
            queueCount++;
        var queuedBgs = Battlegrounds.BattlegroundStatuses.Count(s => s == BattlegroundStatus.Queued);
        // Make sure we can queue up.
        if (queuedBgs < queueCount)
            return true;

        // And lastly... if we have a queue that popped, make sure we can get in it!
        return !Battlegrounds.IsInsideBattleground && Battlegrounds.GetBGIndexWithStatus(BattlegroundStatus.Confirm) != -1;
    }
}
 
Thanks Both, Didn't realise it ran on tick, that makes a lot more sense now! Cheers Guys!
 
Back
Top