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

Adding autotarget to a CC

kakaboeie

New Member
Joined
Apr 10, 2010
Messages
67
Reaction score
0
Hey, I'm trying to add auto-targeting to "Fpsware Rogue" for use with LazyRaider but I'm having trouble figuring out how. I am adding the following (from ILoveAnimals CC):

ClassHelpers.cs
Code:
public static class CheckForTarget
            {
			
				public List<WoWUnit> EnemyUnits
					{
						get
						{
							return
								ObjectManager.GetObjectsOfType<WoWUnit>(true, false)
								.Where(unit =>
									!unit.IsFriendly
									&& (!unit.IsTargetingMeOrPet
									|| !unit.IsTargetingMyPartyMember
									|| !unit.IsTargetingMyRaidMember
									|| !unit.IsPlayer)
									&& !unit.IsNonCombatPet
									&& !unit.IsCritter
									&& unit.DistanceSqr
								<= 15 * 15).ToList();
						}
					}
		
					public WoWUnit FindClosestTarget()
					{
						return (from unit in EnemyUnits
								where unit.IsAlive
								orderby unit.Distance2D ascending
								select unit).FirstOrDefault();
					}
			
                public static void CheckForTargetNow()
                {

						WoWUnit ClosestTarget = FindClosestTarget();
							if ((Me.CurrentTarget == null
								|| !Me.CurrentTarget.IsAlive)
								&& ClosestTarget != null)
							{
								ClosestTarget.Target();
							}

                }
            }

CC.cs
Code:
Timers.Add("TargetCheck");
Code:
if (Timers.Expired("TargetCheck", 5000))
            {
                Timers.Reset("TargetCheck");
                if (!Me.Dead && !Me.IsGhost) ClassHelpers.Rogue.CheckForTarget.CheckForTargetNow();
            }

Resulting in this error:

Could not compile CC from F:\Documents and Settings\xp\Desktop\HB\CustomClasses\Fpsware Rogue!
File: ClassHelpers.cs Line: 312 Error: 'Hera.ClassHelpers.Rogue.CheckForTarget.EnemyUnits': cannot declare instance members in a static class
File: ClassHelpers.cs Line: 331 Error: 'FindClosestTarget': cannot declare instance members in a static class

I obviously am doing this all wrong since I don't have experience with C# yet, so some guidance would be much appreciated.
 
Personally, I would not do it that way. I would recommend you write a plugin. Much easier to understand. Something like this should do the trick.

Code:
if (Me.CurrentTarget == null || Me.CurrentTarget.Dead)
                {                   
                    if (Targeting.Instance.FirstUnit != null && Targeting.Instance.FirstUnit.Distance < 10 && !Targeting.Instance.FirstUnit.Dead)
                        Targeting.Instance.FirstUnit.Target();
                    return;
                }
 
Last edited:
Thanks alot for the tip, I'll try it later. If it's possible though, I would still like to do what I'm doing wrong. I'm trying to figure out how to alter CC's a little better.

It shouldn't be hard, it's just a check that should be executed every second or so, like the check if poisons are applied for Rogues, or if Kings is buffed for Paladins.
 
Back
Top