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

[Altec] - CC Code Request Help

altec

Community Developer
Joined
Jun 11, 2011
Messages
425
Reaction score
7
Ok, I am slowly learning this bot's syntax, so I am reading CodenameG's basic CC guide and it says:

Code:
        public void RangeCheck(int MobDistance, int MyDistance)
        {
            if (Me.CurrentTarget != null)
            {
                if (Me.CurrentTarget.Distance > MobDistance && !Me.IsMoving)
                {
                    Navigator.MoveTo(Me.CurrentTarget.Location, MyDistance);
                }
            }
        }

This will tell the bot to stop at a later defined "MyDistance". Well I type this in, but I get an error: "Not overload for method 'MoveTo' takes 2 arguments" when I add ", MyDistance" to the MoveTo. Am I forgetting something else to add in the CC?
 
Navigator.MoveTo only has 1 function, and no overloaders
and that is WoWPoint, there is no distance
 
Ok, here is what I get when I "copy / paste" the code into my CC:

Code:
        private static LocalPlayer Me
        {
            get { return ObjectManager.Me; }
        }


        public static void FaceTarget(WoWUnit target)
        {
            if (!Me.IsSafelyFacing(target, 70f) && !Me.IsMoving && target != null)
            {
                target.Face();
            }
        }


        public static void MovetoLos(WoWUnit target)
        {
            if (!target.InLineOfSpellSight && target != Me)//InLineOfSpellsight is better than the odd one because here we can make sure that we are in a "real" LOS
            {
                Navigator.MoveTo(target.Location);
            }
        }


        public static void Movetotarget(WoWPoint targetlocation, bool stopinrange, float range)
        {
            if (stopinrange && Me.Location.Distance(targetlocation) + 0.6f < range)
            {
                Navigator.PlayerMover.MoveStop();
            }
            else if (!Me.WithinInteractRange || !Me.IsWithinMeleeRange ||
                     Me.Location.Distance(targetlocation) + 0.6f > range)
            {
                Navigator.MoveTo(targetlocation);
            }
        }        
        
        public override void Pull()
        {
            FaceTarget([COLOR="#FF0000"]CurTarget[/COLOR]);
            MovetoLos([COLOR="#FF0000"]CurTarget[/COLOR]);
            //Your combat thing
            Movetotarget([COLOR="#FF0000"]CurTarget[/COLOR].Location, true, 5f);

        }

Error:

  1. The name 'CurTarget' does not exist in the current context.

Is there somewhere where I define what CurTarget is?


EDIT: if I change it from:

Code:
        public override void Pull()
        {
            FaceTarget([COLOR="#FF0000"]CurTarget[/COLOR]);
            MovetoLos([COLOR="#FF0000"]CurTarget[/COLOR]);
            //Your combat thing
            Movetotarget([COLOR="#FF0000"]CurTarget[/COLOR].Location, true, 5f);

        }

To:

Code:
        public override void Pull()
        {
            FaceTarget(Me.CurrentTarget);
            MovetoLos(Me.CurrentTarget);
            //Your combat thing
            Movetotarget(Me.CurrentTarget.Location, true, 5f);

        }

The error goes away. Is that what it is supposed to be?
 
Last edited:
From what i can see there should be no problem with using Me.CurrentTarget (That's what i'd use anyway).
 
CurTarget is something I use.
But it's obviously Styx.StyxWoW.Me.CurrentTarget, right? ;)

If you want to use "CurTarget" just add

Code:
        private static WoWUnit CurTarget
        {
            get { return StyxWoW.Me.CurrentTarget; }
        }

to your code.

greetz

Weischbier
 
Navigator.MoveTo only has 1 function, and no overloaders
and that is WoWPoint, there is no distance

I believe lots of new CC makers make this mistake, because CNG's guide states that you can do it like that.. I did reply in the thread to let him know but nothing happened.
 
From what i can see there should be no problem with using Me.CurrentTarget (That's what i'd use anyway).
as long as he has a current target there should be no issues. or else it will just null out.
 
Ok, glad to see it is acceptable now. Now, I am trying to dissect and understand what this code means that I copy / pasted. This is my little rant to help me understand, I answer some of my questions but I would like clarification on if I am correct or not.

Code:
public static void FaceTarget(WoWUnit target)
        {
            if (!Me.IsSafelyFacing(target, 70f) && !Me.IsMoving && target != null)
            {
                target.Face();
            }
        }

Ok, this should be simple, it checks if it is facing its' target. If I am not facing the target and I am not moving, and I have a target then run the "face the target" script. What does the 70f part mean exactly? The syntax shows it is the "view degrees" but I cannot understand it, does that mean the target is 70? from my current view line and I must turn there or can someone explain this better to me?

<hr />

Next:

Code:
        public static void MovetoLos(WoWUnit target)
        {
            if (!target.InLineOfSpellSight && target != Me)//InLineOfSpellsight is better than the odd one because here we can make sure that we are in a "real" LOS
            {
                Navigator.MoveTo(target.Location);
            }
        }

Ok, simple code as well, If the target is not in my Line of Sight for my spells and the target is not me, move to the target. This just puts you closer to the target, doesn't it? Instead of moving you side to side for LoS I would assume.

<hr />

Ok, last huge chunk of code here:

Code:
public static void Movetotarget(WoWPoint targetlocation, bool stopinrange, float range)
        {
            if (stopinrange && Me.Location.Distance(targetlocation) + 0.6f < range)
            {
                Navigator.PlayerMover.MoveStop();
            }
            else if (!Me.WithinInteractRange || !Me.IsWithinMeleeRange ||
                     Me.Location.Distance(targetlocation) + 0.6f > range)
            {
                Navigator.MoveTo(targetlocation);
            }
        }

Let me see if I understand this part of the code. The public static void of the title is telling the bot to MoveToTarget(target's location, stop at X range, with an adjustable stopping range? Or did I chop that all up and misunderstand it?) Ok, back to the core code of this line. If (stopinrange [where is this value at?] and me.location.distance(targetlocation) [should my distance be the location of my target?] + 0.6f < range [again, what does the 0.6f represent and what value is range?] then run Navigator.PlayerMover.MoveStop(); [telling the script to stop moving your player]. Else, if my interact range [where is interact's range value?] OR I am not within melee range [where is this value for the range?] OR my location distance form my target +0.6f [cant understand this one either] is > range [again, where is range's value?] then move to the target's location. So, saying if you are in casting range, stop moving and start casting, else, move to the target. I understand that simple code but the jumble in the middle confuse me.

<hr />

Ok, now for the runtime command under Pull() [for me this is where I have it, it can probably be placed in other places as well but to keep it simple I just left it here until I understand it]

Code:
        public override void Pull()
        {
            FaceTarget(Me.CurrentTarget);
            MovetoLos(Me.CurrentTarget);
            //Your combat thing
            Movetotarget(Me.CurrentTarget.Location, true, 5f);

        }

Ok, duing the Pull() runtime, it checks if I am facing the current target, got it. Then it checks if I am in LoS of the target, got it, then it tells me to move to my range of the target, gives the stopinrange command a value of true, meaning use this stopping range, and the value of it is 5f [and the F represents a float value, again, no idea what this means can someone explain it to me?] Then the rest of my code goes into there under the MoveToTarget command line, meaning I am already in optimal range of the mob, start engaging.
 
Everything that you ask for comes from knowledge of the programming language and nothing else.
Go read a book about C# because if you would release a CC right now, I would recommend that people keep their distance from it since when the developer doesn't know the basics it will turn out like garbage.

Scenario:
HB update, pretty hefty changes to the LoS (A couple of patches ago?) detection.
Do you just launch VS or w/e to fix the problem or do you wait for the others CC's to be updated since you don't actually know how to do it,
therefore you come here not knowing that the crap is CurTarget when anyone else would've at least guessed it to be Me.CurrentFreakingTarget and then Go To Definition.
 
Everything that you ask for comes from knowledge of the programming language and nothing else.
Go read a book about C# because if you would release a CC right now, I would recommend that people keep their distance from it since when the developer doesn't know the basics it will turn out like garbage.

Scenario:
HB update, pretty hefty changes to the LoS (A couple of patches ago?) detection.
Do you just launch VS or w/e to fix the problem or do you wait for the others CC's to be updated since you don't actually know how to do it,
therefore you come here not knowing that the crap is CurTarget when anyone else would've at least guessed it to be Me.CurrentFreakingTarget and then Go To Definition.

You're Mr. Nice Guy huh?


@Altec: Give me some minutes and I'll explain it to you. Most of the stuff you got right, some needs clarification.

greetz

Weischbier
 
Hey, some people learn from reading, studying, and planning. Others learn form doing, I am the type that learns from doing. Sure I can read a book, but I will retain little to none of what I read if I do not code stuff, understand it, and troubleshoot it myself. Then again, that would put me in the catagory of not-a-hobby and more of a required desire. Every CC released was horrible at some time, till people tested it, suggested new things, and what not. I am learning here, trying to build a community of people helping each other, not a community that says "read a darn book and learn from there"
 
So lets start.

Me.IsSafelyFacing

Look at that nice little picture i made you^^
View attachment 40238

MovetoLoS
-You got that right.

MoveToTarget

-Ok, quite difficult one.

Code:
Movetotarget(Me.CurrentTarget.Location, true, 5f)
1. range is a value you specifie. Like above. 5f is melee range, 29f would be a safe caster range.
2. 0.6f is just to not stand IN the target. Its just some sort of "safe distance".
3. stopinrange is a bool to make sure that we actually not getting in the target. It cooperates with the 0.6f value.
4. Everyting else is a fail safe. Withinmeleerange is pre defined value inside HB that you cannot access, same as interactrange.

I hope I explained it to you quite correctly. If not, just ask again :D

greetz

Weischbier
 
Lovely sir (ma'am?), love how you explained it so I can understand with ease, as well as the picture so I can view the values. +rep for you!
 
Ok, working on the Combat() code. This is what I have, it is crude / archaic, but it is where I am at so far.

Code:
        public override void Combat()
        {
            if (Me.ComboPoints >= 1 && !Me.HasAura("Slice and Dice")) CastMeUp("Slice and Dice");
            if (Me.HasAura("Slice and Dice") && Me.ComboPoints >= 1) CastMeUp("Envenom");
            if (Me.ComboPoints > 3) CastMeUp("Envenom");
            CastMeUp("Mutilate");
        }

Spam key is Mutilate if none of the above conditions are met. First condition is to put SnD up if it is not already up, anything over 1 combo point will suffice. Next is to check is SnD is active, [here is where I bug out] detect the duration left on the buff, if under X seconds, then cast Envenom if you have more then 1 combo point. Else, if I have > 3 combo points [4 / 5] then cast your finisher Envenom. I do not know how to check the condition of a bufftimer. Any suggestions?

<hr / >

Edit: Ok, found out with help from some few kind souls.

This is what I now have:

Code:
        public override void Combat()
        {
            Attack();
        }

        public Composite Attack()
        {
            return
                new TreeSharp.Action(ret =>
                    {
                        //get SnD buff up on character
                        if (Me.ComboPoints > 0 && !Me.HasAura("Slice and Dice"))
                            CastMeUp("Slice and Dice");
                        //cast Envenom to refresh the buff on SnD -- need to have this check talent build if spec'd into "Cut to the Chase"
                        if (Me.HasAura("Slice and Dice") && Me.ActiveAuras["Slice and Dice"].TimeLeft.TotalSeconds < 3 && Me.ComboPoints > 0)
                            CastMeUp("Envenom");
                        //cast Envenom if there is 4 or 5 combo points on the target
                        if (Me.ComboPoints > 3) 
                            CastMeUp("Envenom");
                        //cast Mutilate if all above conditions fail
                        CastMeUp("Mutilate");
                        return RunStatus.Running;
                    });
        }

Where do I add in code to check if the user is spec'd into "Cut to the Chase" before it runs that command line?
 
Last edited:
Back
Top