Guest User

demonhunter.cs

a guest
Jun 16th, 2012
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 8.31 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Belphegor.Dynamics;
  4. using Belphegor.Helpers;
  5. using Zeta;
  6. using Zeta.CommonBot;
  7. using Zeta.Internals.Actors;
  8. using Zeta.TreeSharp;
  9. using Action = Zeta.TreeSharp.Action;
  10. using Zeta.Common.Helpers;
  11.  
  12. namespace Belphegor.Routines
  13. {
  14.     public class DemonHunter
  15.     {
  16.         [Class(ActorClass.DemonHunter)]
  17.         [Behavior(BehaviorType.Buff)]
  18.         public static Composite DemonHunterBuffs()
  19.         {
  20.             return
  21.                 new PrioritySelector(
  22.                 Spell.Buff(SNOPower.DemonHunter_Companion,
  23.                     req => !HasCompanion
  24.                 )
  25.  
  26.                 /*
  27.                  * Vault disabled untill i can come up with method to ensure porting is "safe".
  28.                  *
  29.                  * Technically this is what's required need to make it work properly.
  30.                  *      - My position compare it against planned location. (Vault will make you jump 35 feets so if you jump too far bot will run back to reach its traveling route.)
  31.                  *      - If i am facing location.
  32.                  *      - If it's possible to travel to location using a straight line.
  33.                  *      - If all of the above is true its safe to use Vault or any other Spell that would make character jump from one location to another.
  34.                  */
  35.  
  36.                 /*
  37.                 Spell.CastAtLocation(SNOPower.DemonHunter_Vault,
  38.                     ctx => ZetaDia.Me.Position,
  39.                     require => !ZetaDia.Me.HasBuff(SNOPower.DemonHunter_Vault) && ZetaDia.Me.Movement.ACDTarget.Distance >= 35f
  40.                )
  41.                 */
  42.  
  43.                );
  44.         }
  45.  
  46.         [Class(ActorClass.DemonHunter)]
  47.         [Behavior(BehaviorType.Combat)]
  48.         public static Composite DemonHunterCombat()
  49.         {
  50.             return
  51.                new PrioritySelector(ctx => CombatTargeting.Instance.FirstNpc,
  52.  
  53.                     Common.CreateWaitWhileIncapacitated(),
  54.                     Common.CreateWaitForAttack(),
  55.                     Common.CreateUsePotion(),
  56.  
  57.                     new Decorator(ctx => ctx != null,
  58.                        new PrioritySelector(
  59.                             new Decorator(ctx => ctx != null && ((DiaUnit)ctx).Distance > 30f,
  60.                                Movement.MoveTo(ctx => ((DiaUnit)ctx).Position, 15f)
  61.                            ),
  62.  
  63.                            //These could use some better values, 0.50 = 50%
  64.                            Spell.Buff(SNOPower.DemonHunter_ShadowPower, extra => ZetaDia.Me.HitpointsCurrentPct <= 0.50),
  65.                            Spell.Buff(SNOPower.DemonHunter_SmokeScreen, extra => ZetaDia.Me.HitpointsCurrentPct <= 0.50),
  66.  
  67.                            new Decorator(ret => _markTimer.IsFinished && PowerManager.CanCast(SNOPower.DemonHunter_MarkedForDeath),
  68.                                new Sequence(
  69.                                    Spell.CastOnUnit(SNOPower.DemonHunter_MarkedForDeath, ctx => ((DiaUnit)ctx).ACDGuid, ctx => Common.IsElite((DiaUnit)ctx)),
  70.                                    new Action(ret => _markTimer.Reset()))),
  71.                            
  72.  
  73.                            // AOE
  74.                            Spell.CastAOESpell(SNOPower.DemonHunter_RainOfVengeance,
  75.                                extra => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 45f) >= 3
  76.                            ),
  77.                            Spell.CastOnUnit(SNOPower.DemonHunter_Strafe,
  78.                                ctx => ((DiaUnit)ctx).ACDGuid,
  79.                                req => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 45f) >= 2
  80.                            ),
  81.                            Spell.CastOnUnit(SNOPower.DemonHunter_Multishot,
  82.                                ctx => ((DiaUnit)ctx).ACDGuid,
  83.                                extra => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 45f) >= 2
  84.                            ),
  85.                            Spell.CastOnUnit(SNOPower.DemonHunter_Chakram,
  86.                                ctx => ((DiaUnit)ctx).ACDGuid,
  87.                                extra => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 25f) >= 2
  88.                            ),
  89.                            Spell.CastAOESpell(SNOPower.DemonHunter_Grenades,
  90.                                req => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 25f) >= 2
  91.                            ),
  92.                            Spell.CastOnUnit(SNOPower.DemonHunter_FanOfKnives,
  93.                                ctx => ((DiaUnit)ctx).ACDGuid,
  94.                                req => Clusters.GetClusterCount(ZetaDia.Me, CombatTargeting.Instance.LastObjects, ClusterType.Radius, 15f) >= 2
  95.                            ),
  96.  
  97.                            // Singles
  98.                            Spell.CastOnUnit(SNOPower.DemonHunter_Impale, ctx => ((DiaUnit)ctx).ACDGuid),
  99.                            Spell.CastOnUnit(SNOPower.DemonHunter_RapidFire, ctx => ((DiaUnit)ctx).ACDGuid),
  100.                            Spell.CastOnUnit(SNOPower.DemonHunter_ElementalArrow, ctx => ((DiaUnit)ctx).ACDGuid),
  101.                            Spell.CastOnUnit(SNOPower.DemonHunter_ClusterArrow, ctx => ((DiaUnit)ctx).ACDGuid),
  102.  
  103.                            // Hatred Generators
  104.                            Spell.CastOnUnit(SNOPower.DemonHunter_EvasiveFire, ctx => ((DiaUnit)ctx).ACDGuid),
  105.                            Spell.CastOnUnit(SNOPower.DemonHunter_HungeringArrow, ctx => ((DiaUnit)ctx).ACDGuid),
  106.                            Spell.CastOnUnit(SNOPower.DemonHunter_BolaShot, ctx => ((DiaUnit)ctx).ACDGuid),
  107.                            Spell.CastOnUnit(SNOPower.DemonHunter_EntanglingShot, ctx => ((DiaUnit)ctx).ACDGuid)
  108.                       )
  109.                   ),
  110.  
  111.                   new Action(ret => RunStatus.Success)
  112.                   );
  113.         }
  114.  
  115.         #region timmers
  116.         static DemonHunter()
  117.         {
  118.             GameEvents.OnGameLeft += OnGameLeft;
  119.             //GameEvents.OnPlayerDied += OnGameLeft;
  120.         }
  121.  
  122.         private static WaitTimer _markTimer = new WaitTimer(TimeSpan.FromSeconds(10));
  123.  
  124.         static void OnGameLeft(object sender, EventArgs e)
  125.         {
  126.             _markTimer.Stop();
  127.         }
  128.         #endregion
  129.  
  130.  
  131.  
  132.         public static bool HasCompanion
  133.         {
  134.             get
  135.             {
  136.                 int dynId = ZetaDia.Me.CommonData.DynamicId;
  137.                 //You only need to partialy reference the name string :)
  138.                 var companion = ZetaDia.Actors.GetActorsOfType<DiaUnit>().FirstOrDefault(u => u != null && u.Name.Contains("DH_Companion") && u.SummonedByACDId == dynId);
  139.                 return companion != null;
  140.             }
  141.         }
  142.  
  143.         public static void DemonHunterOnLevelUp(object sender, EventArgs e)
  144.         {
  145.             if (ZetaDia.Me.ActorClass != ActorClass.DemonHunter)
  146.                 return;
  147.  
  148.             int myLevel = ZetaDia.Me.Level;
  149.  
  150.             Logger.Write("Player leveled up, congrats! Your level is now: {0}",
  151.                 myLevel
  152.                 );
  153.  
  154.             if (myLevel == 2)
  155.             {
  156.                 ZetaDia.Me.SetActiveSkill(SNOPower.DemonHunter_Impale, -1, 1);
  157.                 Logger.Write("Setting Impale as Secondary skill");
  158.             }
  159.  
  160.             if (myLevel == 4)
  161.             {
  162.                 ZetaDia.Me.SetActiveSkill(SNOPower.DemonHunter_Caltrops, -1, 2);
  163.                 Logger.Write("Setting Caltrops as Defensive skill");
  164.             }
  165.  
  166.             if (myLevel == 5)
  167.             {
  168.                 ZetaDia.Me.SetActiveSkill(SNOPower.DemonHunter_RapidFire, -1, 1);
  169.                 Logger.Write("Setting Rapid Fire as Secondary skill");
  170.             }
  171.  
  172.             if (myLevel == 8)
  173.             {
  174.                 ZetaDia.Me.SetActiveSkill(SNOPower.DemonHunter_SmokeScreen, -1, 1);
  175.                 Logger.Write("Setting Smoke Screen as Defensive skill");
  176.             }
  177.  
  178.             if (myLevel == 9)
  179.             {
  180.                 ZetaDia.Me.SetActiveSkill(SNOPower.DemonHunter_Vault, -1, 3);
  181.                 Logger.Write("Setting Vault as Hunting skill");
  182.             }
  183.         }
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment