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

Beginner questions about building a CC from scratch.

Shinugami

New Member
Joined
Mar 1, 2012
Messages
17
Reaction score
0
Hi, I've read all the guides I could find and I've tried reverse engineering other people's CC files however I'm having trouble understanding how Honorbuddy or the CC files target units. I know how to make systems to filter targets etc but I don't know how they actually say to HB or WoW "Target this unit now!" and get the toon to target a unit in-game. I'm starting off simple and I want to just tell my bot to target an NPC/Player/Mob etc.

I'm assuming it wasn't covered in the guides because maybe Honorbuddy selects targets but I do not like the way Honorbuddy selects targets and I'd like to incorporate my own systems. I'm aware other people have done this already but I'd like to learn how to do this too and I'm starting off simple.

So I have my CC file working, it loads up. It has no functions in it at all so nothing happens. I want to know how I can get it to select a target. So even if I manually control this AI/toon in the game, I want the AI to automatically target something. I'm assuming I'll need to put a command in the Pulse section so that it checks for units and targets something.

Any help would be greatly appreciated, I spent a lot of hours working with the CC files (maybe 1 week, atleast 4 hours a day) and this is my question at the moment. I'll give credit to people that help me.
 
Lets say you want to target a unit named Bob.

First you need to query HB's ObjectManager (the manager class that holds all WoW entities, simply put) and find any nearby unit with the name of Bob.

PHP:
var unitCalledBob = ObjectManager.GetObjectsOfType<WoWUnit>(true).FirstOrDefault(unit => unit.Name == "Bob");

Next you need to find out if the object manager has found a unit named Bob.

PHP:
var unitCalledBob = ObjectManager.GetObjectsOfType<WoWUnit>(true).FirstOrDefault(unit => unit.Name == "Bob");

if (unitCalledBob != null)
{
}

You should also check to make sure you are not already targetting Bob, because there is no reason to target Bob if you already have him targeted.

PHP:
var unitCalledBob = ObjectManager.GetObjectsOfType<WoWUnit>(true).FirstOrDefault(unit => unit.Name == "Bob");

if (unitCalledBob != null && StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.CurrentTarget.Guid != unitCalledBob.Guid)
{
}

Finally you need to implement the method to target Bob.

PHP:
var unitCalledBob = ObjectManager.GetObjectsOfType<WoWUnit>(true).FirstOrDefault(unit => unit.Name == "Bob");

if (unitCalledBob != null && StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.CurrentTarget.Guid != unitCalledBob.Guid)
{
   unitCalledBob.Target();
}

In a proper CC, this code would look something similar to the following.

PHP:
using System.Linq;
using Styx;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;

public override void Combat()
{
    var unitCalledBob = ObjectManager.GetObjectsOfType<WoWUnit>(true).FirstOrDefault(unit => unit.Name == "Bob");

    if (unitCalledBob != null && StyxWoW.Me.CurrentTarget != null && StyxWoW.Me.CurrentTarget.Guid != unitCalledBob.Guid)
    {
        unitCalledBob.Target();
    }
}

Note that whilst it is generally the CC's responsibility to target units in combat, occasionally the BotBase (depending which BotBase it is you are running) might mess with your targets. I think this occurs with BGBuddy. Don't be alarmed if this happens, it isn't your fault!

If you have any other questions feel free to ask.
 
Last edited:
<wowunit><wowunit><wowunit><wowunit><wowunit>
Note that whilst it is generally the CC's responsibility to target units in combat, occasionally the BotBase (depending which BotBase it is you are running) might mess with your targets. I think this occurs with BGBuddy. Don't be alarmed if this happens, it isn't your fault!

If you have any other questions feel free to ask.

Mostly true. Every BotBase should be implementing some form of target weighting (and all bots packaged with HB by default, do) so you can use Targeting.Instance.FirstUnit to get the "best target" according to the bot. There are times where this target may not be best (for example, healers and tanks may need different targeting logic), however, you can assume it safe to always target the FirstUnit, unless you have some reason to do otherwise.</wowunit></wowunit></wowunit></wowunit></wowunit>
 
Mostly true. Every BotBase should be implementing some form of target weighting (and all bots packaged with HB by default, do) so you can use Targeting.Instance.FirstUnit to get the "best target" according to the bot. There are times where this target may not be best (for example, healers and tanks may need different targeting logic), however, you can assume it safe to always target the FirstUnit, unless you have some reason to do otherwise.</wowunit></wowunit></wowunit></wowunit></wowunit>

That's really useful, I've updated my CC to make use of FirstUnit. Cheers!
 
Thanks for the reply. I'll give it a go and see if I can get it to work. I'll be back later and explain what I did and how I did it.
 
That's really useful, I've updated my CC to make use of FirstUnit. Cheers!

Remember to create a targeting backup system, as non-official bots rarely add such information to the system. For example I read the HighVoltz's fishing bot and I don't remember seeing it.
 
Back
Top