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

[CC] Moving to mob

jim87

New Member
Joined
Aug 26, 2011
Messages
445
Reaction score
7
Hello! I made a very simple war prot profile to farm Lovely Charm in Throne of the Tides, but the movement handler doesn't work very well: it lets the character stands still and only eventually it moves, even if it should run after the mob continuously till he's 2 yards to it... may you please suggest me how to change this behavior?

Thanks!

PHP:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Styx.Combat.CombatRoutine;
using TreeSharp;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Logic.Combat;
using Action = TreeSharp.Action;
using Styx.Logic.Pathing;
using Styx.Helpers;

namespace ProtWarFarm
{
    public class ProtWarFarm : CombatRoutine
    {
        LocalPlayer Me = ObjectManager.Me;
        List<WoWUnit> aroundMe = new List<WoWUnit>();
        int totalMobsAround = 0;

        public override WoWClass Class
        {
            get { return WoWClass.Warrior; }
        }

        public override string Name
        {
            get { return "ProtWarFarm"; }
        }

        public override TreeSharp.Composite CombatBehavior
        {
            get
            {
                return new Sequence(
                    // Refresh data
                    new Decorator(new Action(delegate {
                        aroundMe = ObjectManager.GetObjectsOfType<WoWUnit>(false, false)
                            .Where(unit => unit.Distance < 10 && unit.IsAlive).ToList();
                        totalMobsAround = aroundMe.Where(unit => unit.Distance < 5).ToList().Count;
                    })),
                    new PrioritySelector(
                        // Select a target
                        new Decorator(c => Me.CurrentTarget == null || !Me.CurrentTarget.IsValid, new Action(delegate {
                            Logging.Write("Searching for a new target");
                            WoWUnit nearest = aroundMe.FirstOrDefault();
                            foreach(WoWUnit u in aroundMe)
                                if(u.Distance < nearest.Distance)
                                    nearest = u;
                            nearest.Target();
                        })),

                        // Move to target
                        new Decorator(c => Me.CurrentTarget.IsValid && Me.CurrentTarget.Distance >= 3, new PrioritySelector(
                            // Charge
                            new Decorator(c => Me.CurrentTarget.Distance >= 8
                                && Me.CurrentTarget.Distance <= 15
                                && SpellManager.CanCast("Charge")
                                && SpellManager.GlobalCooldownLeft == TimeSpan.FromSeconds(0), new Action(delegate {
                                Logging.Write("Moving to target via Charge");
                                Me.CurrentTarget.Face();
                                SpellManager.Cast("Charge");
                            })),
                            // Move to
                            new Decorator(new Action(delegate {
                                Logging.Write("Moving to target via MoveTo");
                                Navigator.MoveTo(Me.CurrentTarget.Location);
                            })
                        ))),

                        // Stop Moving
                        new Decorator(c => Me.CurrentTarget.Distance < 2 && Me.IsMoving, new Action(delegate { WoWMovement.MoveStop(); })),
                        // Face
                        new Decorator(c => !Me.IsFacing(Me.CurrentTarget.Location), new Action(delegate { Me.CurrentTarget.Face(); })),
    
                        // Victory Rush (emergency)
                        new Decorator(c => Me.CurrentTarget.IsValid && Me.HealthPercent <= 50 && SpellManager.CanCast("Victory Rush") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Victory Rush");
                            })),
                        
                        // Battle Shout
                        new Decorator(c => Me.CurrentTarget.IsValid && SpellManager.CanCast("Battle Shout") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Battle Shout");
                            })),
                        // Revenge
                        new Decorator(c => Me.CurrentTarget.IsValid && SpellManager.CanCast("Revenge") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Revenge");
                            })),
                            
                        // Thunder Clap
                        new Decorator(c => totalMobsAround >= 4 && SpellManager.CanCast("Thunder Clap") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Thunder Clap");
                            })),
                            
                        // Victory Rush
                        new Decorator(c => Me.CurrentTarget.IsValid && SpellManager.CanCast("Victory Rush") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Victory Rush");
                            })),
                        // Cleave
                        new Decorator(c => Me.CurrentTarget.IsValid && SpellManager.CanCast("Cleave") && SpellManager.GlobalCooldownLeft == TimeSpan.Zero,
                            new Action(delegate {
                                SpellManager.Cast("Cleave");
                            }))
                    )
                );
            }
        }
    }
}
 
Last edited:
Back
Top