コード例 #1
0
ファイル: Throttle.cs プロジェクト: aash/Singular
 public DecoratorIfElse(CanRunDecoratorDelegate runFunc, params Composite []children)
     : base(children)
 {
     Debug.Assert(runFunc != null);
     Debug.Assert(children.Count() == 2);
     Runner = runFunc;
 }
コード例 #2
0
ファイル: Spells.cs プロジェクト: LaoArchAngel/RogueAssassin
 public static Composite CastFocus(int spell, CanRunDecoratorDelegate condition)
 {
     return new Decorator(
         ret =>
         condition(ret) && SpellManager.CanCast(spell, Helpers.Focus) && SpellManager.Cast(spell, Helpers.Focus),
         new SpellLog(spell, Helpers.Focus));
 }
コード例 #3
0
ファイル: Spells.cs プロジェクト: sycs/kaihaider
        public static Composite Cast(int spellId, CanRunDecoratorDelegate cond, WoWUnitDelegate target)
        {
            return new Decorator(ret => target != null && cond(ret) && CanCast(spellId),
                new Action(ret =>
                    {
                        SpellManager.Cast(spellId, target(ret));
                        Logging.Write(LogLevel.Diagnostic, Colors.White, "" + WoWSpell.FromId(spellId).Name);
                        string temp;
                        if (target(ret).IsPlayer)
                            temp = "Casting " + WoWSpell.FromId(spellId).Name + " on Player at " +
                                             Math.Round(target(ret).HealthPercent, 0) + " with " + Helpers.Rogue.me.ComboPoints + "CP and " +
                                             Rogue.mCurrentEnergy + " energy";
                        else
                            temp = "Casting " + WoWSpell.FromId(spellId).Name + " on " + target(ret).Name + " at " +
                                             Math.Round(target(ret).HealthPercent, 0) + " with " + Helpers.Rogue.me.ComboPoints + "CP and " +
                                             Rogue.mCurrentEnergy + " energy";

                        Logging.Write(LogLevel.Normal, temp );
                    }
                )
            );
        }
コード例 #4
0
ファイル: utils.cs プロジェクト: Asphodan/Alphabuddy
 public Composite TargetAoEPummel(CanRunDecoratorDelegate extra)
 {
     return new Decorator(ret => extra(ret) && Me.CurrentTarget != ((WoWUnit)AoECastingAdds().FirstOrDefault()),
                          new Action(delegate
                          {
                              ((WoWUnit)AoECastingAdds().FirstOrDefault()).Target();
                              Logging.Write("[DWCC]: Targeting AoE Pummel target.");
                          }
                              ));
 }
コード例 #5
0
ファイル: Specials.cs プロジェクト: sycs/kaihaider
 public static Composite UseItem(WoWItemDelegate item, CanRunDecoratorDelegate cond)
 {
     return new Decorator(ret => item(ret) != null && cond(ret) && ItemUsable(item(ret)),
         new Action(ret =>
             {
                 item(ret).Use();
                 Logging.Write(LogLevel.Normal, item(ret).Name);
                 return RunStatus.Failure;
             }
         )
     );
 }
コード例 #6
0
ファイル: Wait.cs プロジェクト: KoalaHuman/TreeSharp-1
 /// <summary>
 ///   Creates a new Wait decorator using the specified timeout, run delegate, and child composite.
 /// </summary>
 /// <param name = "timeoutSeconds"></param>
 /// <param name = "runFunc"></param>
 /// <param name = "child"></param>
 public Wait(int timeoutSeconds, CanRunDecoratorDelegate runFunc, Composite child)
     : base(runFunc, child)
 {
     Timeout =  TimeSpan.FromSeconds(timeoutSeconds);
 }
コード例 #7
0
ファイル: Common.cs プロジェクト: superkhung/SingularMod3
 /// <summary>
 /// Allows waiting for SleepForLagDuration() but ending sooner if condition is met
 /// </summary>
 /// <param name="orUntil">if true will stop waiting sooner than lag maximum</param>
 /// <returns></returns>
 public static Composite CreateWaitForLagDuration( CanRunDecoratorDelegate orUntil)
 {
     return new WaitContinue(TimeSpan.FromMilliseconds((StyxWoW.WoWClient.Latency * 2) + 150), orUntil, new ActionAlwaysSucceed());
 }
コード例 #8
0
ファイル: Spell.cs プロジェクト: aash/Singular
        public static Composite BuffSelfAndWait(SimpleStringDelegate name, SimpleBooleanDelegate requirements = null, int expirSecs = 0, CanRunDecoratorDelegate until = null, bool measure = false, HasGcd gcd = HasGcd.Yes)
        {
            if (requirements == null)
                requirements = req => true;

            if (until == null)
                until = u => StyxWoW.Me.HasAura(name(u));

            return new Sequence(
                BuffSelf(name, requirements, expirSecs, gcd),
                new PrioritySelector(
                    new DynaWait(
                        time => TimeSpan.FromMilliseconds(Me.Combat ? 500 : 1000),
                        until,
                        new ActionAlwaysSucceed(),
                        measure
                        ),
                    new Action(r =>
                    {
                        Logger.WriteDiagnostic("BuffSelfAndWait: buff of [{0}] failed", name(r));
                        return RunStatus.Failure;
                    })
                    )
                );
        }
コード例 #9
0
ファイル: Wait.cs プロジェクト: mcdonnellv/treesharp
 /// <summary>
 ///   Creates a new Wait decorator using the specified timeout, run delegate, and child composite.
 /// </summary>
 /// <param name = "timeoutSeconds"></param>
 /// <param name = "runFunc"></param>
 /// <param name = "child"></param>
 public Wait(int timeoutSeconds, CanRunDecoratorDelegate runFunc, Composite child)
     : base(runFunc, child)
 {
     Timeout = new TimeSpan(0, 0, timeoutSeconds);
 }
コード例 #10
0
ファイル: TargetBase.cs プロジェクト: Asphodan/Alphabuddy
 public Composite FindThreats(CanRunDecoratorDelegate cond, RefineFilter filter, Comparison<HealableUnit> compare, string reason, params Composite[] children)
 {
     return FindTarget(cond, TargetFilter.Threats, filter, compare, "[CLU TARGETING] " + CLU.Version + ": " + "Targeting THREAT {0}:  Max {1}, Current {2}, Defecit {3}, TimeTaken: {4} ms, REASON: " + reason, children);
 }
コード例 #11
0
ファイル: TargetBase.cs プロジェクト: Asphodan/Alphabuddy
 /// <summary>Targeting myself when no target</summary>
 /// <param name="cond">The conditions that must be true</param>
 /// <returns>Target myself</returns>
 public static Composite EnsureTarget(CanRunDecoratorDelegate cond)
 {
     return new Decorator(
                cond,
                new Sequence(
                    new Action(a => CLULogger.TroubleshootLog("[CLU] " + CLU.Version + ": CLU targeting activated. I dont have a target, someone must have died. Targeting myself")),
                    new Action(a => Me.Target())));
 }
コード例 #12
0
ファイル: Spells.cs プロジェクト: LaoArchAngel/RogueAssassin
 public static Composite Cast(int spell, WoWUnit target, CanRunDecoratorDelegate condition)
 {
     return new Decorator(
         ret => condition(ret) && SpellManager.CanCast(spell, target) && SpellManager.Cast(spell, target),
         new SpellLog(spell, target));
 }
コード例 #13
0
ファイル: Specials.cs プロジェクト: sycs/kaihaider
        public static Composite UseSpecialAbilities(CanRunDecoratorDelegate cond)
        {
            return new PrioritySelector(
                UseItem(ret => mTrinket1, ret => cond(ret) && mTrinket1Usable),
                UseItem(ret => mTrinket2, ret => cond(ret) && mTrinket2Usable),
                UseItem(ret => mGloves, ret => cond(ret) && mGlovesUsable),

                new Decorator(ret => mRacialName != null && Helpers.Rogue.mCurrentEnergy < 65 && mRacialName.Equals("Arcane Torrent"),
                    Spells.CastSelf(mRacialName)),

                new Decorator(ret => mRacialName != null && mRacialName.Length > 3 && !mRacialName.Equals("Arcane Torrent"),
                    Spells.CastSelf(mRacialName))
            );
        }
コード例 #14
0
ファイル: Spells.cs プロジェクト: LaoArchAngel/RogueAssassin
 /// <summary>
 /// Casts a spell and executes <paramref name="onSuccess"/> if successful.
 /// This method will not log anything by default.
 /// </summary>
 /// <param name="spell">Id of the spell to cast.</param>
 /// <param name="conditions">Conditions to test before casting.</param>
 /// <param name="onSuccess">Action to run on success.</param>
 /// <returns><see cref="Decorator"/> that casts a spell and performs a custom action.</returns>
 public static Composite Cast(int spell, CanRunDecoratorDelegate conditions, Action onSuccess)
 {
     return new Decorator(ret => conditions(ret) && SpellManager.CanCast(spell) && SpellManager.Cast(spell), onSuccess);
 }
コード例 #15
0
ファイル: Spells.cs プロジェクト: LaoArchAngel/RogueAssassin
 public static Composite Cast(int spell, CanRunDecoratorDelegate conditions)
 {
     return new Decorator(ret => conditions(ret) && SpellManager.CanCast(spell) && SpellManager.Cast(spell),
                          new SpellLog(spell));
 }
コード例 #16
0
ファイル: Item.cs プロジェクト: Asphodan/Alphabuddy
 /// <summary>Attempts to use the bag item provided it is usable and its not on cooldown</summary>
 /// <param name="name">the name of the bag item to use</param>
 /// <param name="cond">The conditions that must be true</param>
 /// <param name="label">A descriptive label for the clients GUI logging output</param>
 /// <returns>The use bag item.</returns>
 public static Composite UseBagItem(string name, CanRunDecoratorDelegate cond, string label)
 {
     WoWItem item = null;
     return new Decorator(
         delegate(object a) {
             if (!cond(a))
                 return false;
             item = Me.BagItems.FirstOrDefault(x => x.Name == name && x.Usable && x.Cooldown <= 0);
             return item != null;
     },
     new Sequence(
         new Action(a => CLULogger.Log(" [BagItem] {0} ", label)),
         new Action(a => item.UseContainerItem())));
 }
コード例 #17
0
ファイル: Item.cs プロジェクト: Asphodan/Alphabuddy
 /// <summary>Runs Lua MacroText</summary>
 /// <param name="macro">the macro text to run</param>
 /// <param name="cond">The conditions that must be true</param>
 /// <param name="label">A descriptive label for the clients GUI logging output</param>
 /// <returns>The run macro text.</returns>
 public static Composite RunMacroText(string macro, CanRunDecoratorDelegate cond, string label)
 {
     return new Decorator(
                cond,
                new Sequence(
                    new Action(a => CLULogger.Log(" [RunMacro] {0} ", label)),
                    new Action(a => Lua.DoString("RunMacroText(\"" + Spell.RealLuaEscape(macro) + "\")"))));
 }
コード例 #18
0
ファイル: Unit.cs プロジェクト: Asphodan/Alphabuddy
        /// <summary>
        /// Finds a target that does not have the specified spell and applys it.
        /// </summary>
        /// <param name="cond">The conditions that must be true</param>
        /// <param name="spell">The spell to be cast</param>
        /// <returns>success we have aquired a target and failure if not.</returns>
        public static Composite FindMultiDotTarget(CanRunDecoratorDelegate cond, string spell)
        {
            return new Decorator(
                       cond,
                       new Sequence(
                // get a target
                           new Action(
                            delegate
                            {
                                if (!CLUSettings.Instance.EnableMultiDotting)
                                {
                                    return RunStatus.Failure;
                                }

                                WoWUnit target = EnemyRangedUnits.FirstOrDefault(u => !u.HasAura(spell) && u.Distance2DSqr < 40 * 40);
                                if (target != null)
                                {
                                    CLULogger.DiagnosticLog(target.Name);
                                    target.Target();
                                    return RunStatus.Success;
                                }

                                return RunStatus.Failure;
                            }),
                           new Action(a => StyxWoW.SleepForLagDuration()),
                // if success, keep going. Else quit
                           new PrioritySelector(Buff.CastDebuff(spell, cond, spell))));
        }
コード例 #19
0
ファイル: TargetBase.cs プロジェクト: Asphodan/Alphabuddy
 /// <summary>
 /// Finds a Party that needs healing
 /// </summary>
 /// <param name="cond">The conditions that must be true</param>
 /// <param name="minAverageHealth">Minimum Average health of the Party Members</param>
 /// <param name="maxAverageHealth">MaximumAverage health of the Party Members</param>
 /// <param name="maxDistanceBetweenPlayers">The maximum distance between other party members from the targeted party member</param>
 /// <param name="minUnits">Minumum units to be affected</param>
 /// <param name="reason">text to indicate the reason for using this method </param>
 /// <param name="children">Execute the child subroutines</param>
 /// <returns>A party member</returns>
 public Composite FindParty(CanRunDecoratorDelegate cond, int minAverageHealth, int maxAverageHealth, float maxDistanceBetweenPlayers, int minUnits, string reason, params Composite[] children)
 {
     return new Decorator(
                cond,
                new Sequence(
                    new PrioritySelector(
                        FindPartySubroutine(0, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 1 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(1, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 2 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(2, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 3 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(3, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 4 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(4, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 5 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(5, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 6 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(6, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 7 MEMBER: {0} REASON: " + reason),
                        FindPartySubroutine(7, minAverageHealth, maxAverageHealth, maxDistanceBetweenPlayers, minUnits, "[CLU TARGETING] " + CLU.Version + ": " + "Target PARTY 8 MEMBER: {0} REASON: " + reason)
                    ),
                    new Action(a => StyxWoW.SleepForLagDuration()),
         // if success, keep going. Else quit sub routine
                    new PrioritySelector(children)
                )
            );
 }
コード例 #20
0
ファイル: Spells.cs プロジェクト: LaoArchAngel/RogueAssassin
 public static Composite CastStatus(int spell, CanRunDecoratorDelegate conditions)
 {
     return new Decorator(ret => conditions(ret) && SpellManager.CanCast(spell),
                          new Action(context =>
                                         {
                                             if (SpellManager.Cast(spell))
                                             {
                                                 LogSpell(spell);
                                                 return RunStatus.Success;
                                             }
                                             return RunStatus.Failure;
                                         }));
 }
コード例 #21
0
ファイル: TargetBase.cs プロジェクト: Asphodan/Alphabuddy
        private static Composite FindTarget(CanRunDecoratorDelegate cond, TargetFilter filter, RefineFilter refineFilter, Comparison<HealableUnit> compare, string label, params Composite[] children)
        {
            return new Decorator(
                       cond,
                       new Sequence(
                         // get a target
                           new Action(
                            delegate
                            {
                                var targetPerformanceTimer = new Stopwatch(); // lets see if we can get some performance on this one.
                                targetPerformanceTimer.Start(); // lets see if we can get some performance on this one.

                                //CrabbyProfiler.Instance.Runs.Add(new Run("FindTarget"));

                                // Nothing to filter against
                                if (!UnitsFilter(filter).Any())
                                {
                                    HealableUnit.HealTarget = null;
                                    return RunStatus.Failure;
                                }

                                // Filter the Healable Units
                                var raid = UnitsFilter(filter).Where(x => x != null && (ObjectManager.ObjectList.Any(y => y.Guid == x.ToUnit().Guid) && refineFilter(x)) && x.ToUnit().Distance2DSqr < 40 * 40 && !x.ToUnit().ToPlayer().IsGhost && !x.ToUnit().HasAura("Deep Corruption")).ToList();

                                // Nothing to heal.
                                if (!IsPlayingWoW() || !raid.Any())
                                {
                                    HealableUnit.HealTarget = null;
                                    return RunStatus.Failure;
                                }

                                raid.Sort(compare);
                                var target = raid.FirstOrDefault();
                                if (target != null)
                                {
                                    Log(
                                        label,
                                        CLULogger.SafeName(target.ToUnit()),
                                        target.MaxHealth,
                                        target.CurrentHealth,
                                        target.MaxHealth - target.CurrentHealth,
                                        targetPerformanceTimer.ElapsedMilliseconds); // lets see if we can get some performance on this one.

                                    //target.ToUnit().Target();
                                    HealableUnit.HealTarget = target;
                                    return RunStatus.Success;
                                }
                                HealableUnit.HealTarget = null;
                                //CrabbyProfiler.Instance.EndLast();
                                return RunStatus.Failure;
                            }),
                           new Action(a => StyxWoW.SleepForLagDuration()),
                // if success, keep going. Else quit sub routine
                           new PrioritySelector(children)));
        }
コード例 #22
0
 public DecoratorContinue(CanRunDecoratorDelegate func, Composite decorated)
     : base(func, decorated)
 {
 }
コード例 #23
0
ファイル: Spell.cs プロジェクト: aash/Singular
 public static Composite BuffSelfAndWait(string name, SimpleBooleanDelegate requirements = null, int expirSecs = 0, CanRunDecoratorDelegate until = null, bool measure = false, HasGcd gcd = HasGcd.Yes)
 {
     return BuffSelfAndWait(b => name, requirements, expirSecs, until, measure, gcd);
 }
コード例 #24
0
ファイル: TreeHooks.cs プロジェクト: herbfunk/FunkyItemPlugin
        internal static void HookBehaviorTree()
        {
            HookHandler.StoreHook(HookHandler.HookType.VendorRun);

            Logger.DBLog.InfoFormat("[FunkyTownRun] Treehooks..");
            #region VendorRun

            // Wipe the vendorrun and loot behavior trees, since we no longer want them

            Logger.DBLog.DebugFormat("[FunkyTownRun] VendorRun...");

            Decorator GilesDecorator = HookHandler.ReturnHookValue(HookHandler.HookType.VendorRun)[0] as Decorator;
            //PrioritySelector GilesReplacement = GilesDecorator.Children[0] as PrioritySelector;
            PrioritySelector GilesReplacement = GilesDecorator.Children[0] as PrioritySelector;
            //HookHandler.PrintChildrenTypes(GilesReplacement.Children);

            CanRunDecoratorDelegate canRunDelegateReturnToTown = TownPortalBehavior.FunkyTPOverlord;
            ActionDelegate actionDelegateReturnTown = TownPortalBehavior.FunkyTPBehavior;
            ActionDelegate actionDelegateTownPortalFinish = TownPortalBehavior.FunkyTownPortalTownRun;
            Sequence sequenceReturnTown = new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateReturnTown),
                new Zeta.TreeSharp.Action(actionDelegateTownPortalFinish)
                );
            GilesReplacement.Children[1] = new Decorator(canRunDelegateReturnToTown, sequenceReturnTown);
            Logger.DBLog.DebugFormat("[FunkyTownRun] Town Portal - hooked...");

            ActionDelegate actionDelegatePrePause = TownRunManager.GilesStashPrePause;
            ActionDelegate actionDelegatePause = TownRunManager.GilesStashPause;

            #region Idenify

            CanRunDecoratorDelegate canRunDelegateFunkyIDManual = TownRunManager.IdenifyItemManualOverlord;
            ActionDelegate actionDelegateIDManual = TownRunManager.IdenifyItemManualBehavior;
            ActionDelegate actionDelegateIDFinish = TownRunManager.IdenifyItemManualFinishBehavior;
            Sequence sequenceIDManual = new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateIDManual),
                new Zeta.TreeSharp.Action(actionDelegateIDFinish)
            );

            CanRunDecoratorDelegate canRunDelegateFunkyIDBookOfCain = TownRunManager.IdenifyItemBookOfCainOverlord;
            ActionDelegate actionDelegateIDBookOfCainMovement = TownRunManager.IdenifyItemBookOfCainMovementBehavior;
            ActionDelegate actionDelegateIDBookOfCainInteraction = TownRunManager.IdenifyItemBookOfCainInteractionBehavior;
            Sequence sequenceIDBookOfCain = new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateIDBookOfCainMovement),
                new Zeta.TreeSharp.Action(actionDelegateIDBookOfCainInteraction),
                new Zeta.TreeSharp.Action(actionDelegateIDFinish)
            );

            PrioritySelector priorityIDItems = new PrioritySelector(
                new Decorator(canRunDelegateFunkyIDManual, sequenceIDManual),
                new Decorator(canRunDelegateFunkyIDBookOfCain, sequenceIDBookOfCain)
            );

            CanRunDecoratorDelegate canRunDelegateFunkyIDOverlord = TownRunManager.IdenifyItemOverlord;
            GilesReplacement.Children[2] = new Decorator(canRunDelegateFunkyIDOverlord, priorityIDItems);

            Logger.DBLog.DebugFormat("[FunkyTownRun] Idenify Items - hooked...");

            #endregion

            // Replace the pause just after identify stuff to ensure we wait before trying to run to vendor etc.
            CanRunDecoratorDelegate canRunDelegateEvaluateAction = TownRunManager.ActionsEvaluatedOverlord;
            ActionDelegate actionDelegateEvaluateAction = TownRunManager.ActionsEvaluatedBehavior;

            Sequence sequenceEvaluate = new Sequence(
                        new Zeta.TreeSharp.Action(actionDelegatePrePause),
                        new Zeta.TreeSharp.Action(actionDelegatePause),
                        new Zeta.TreeSharp.Action(actionDelegateEvaluateAction)
                    );

            GilesReplacement.Children[3] = new Decorator(canRunDelegateEvaluateAction, sequenceEvaluate);

            #region Salvage

            // Replace DB salvaging behavior tree with my optimized & "one-at-a-time" version
            CanRunDecoratorDelegate canRunDelegateSalvageGilesOverlord = TownRunManager.GilesSalvageOverlord;
            ActionDelegate actionDelegatePreSalvage = TownRunManager.GilesOptimisedPreSalvage;
            ActionDelegate actionDelegateSalvage = TownRunManager.GilesOptimisedSalvage;
            ActionDelegate actionDelegatePostSalvage = TownRunManager.GilesOptimisedPostSalvage;
            Sequence sequenceSalvage = new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePreSalvage),
                    new Zeta.TreeSharp.Action(actionDelegateSalvage),
                    new Zeta.TreeSharp.Action(actionDelegatePostSalvage),
                    new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePrePause),
                    new Zeta.TreeSharp.Action(actionDelegatePause)
                    )
                    );
            GilesReplacement.Children[4] = new Decorator(canRunDelegateSalvageGilesOverlord, sequenceSalvage);
            Logger.DBLog.DebugFormat("[FunkyTownRun] Salvage - hooked...");

            #endregion

            #region Stash

            // Replace DB stashing behavior tree with my optimized version with loot rule replacement
            CanRunDecoratorDelegate canRunDelegateStashGilesOverlord = TownRunManager.StashOverlord;
            ActionDelegate actionDelegatePreStash = TownRunManager.PreStash;
            ActionDelegate actionDelegatePostStash = TownRunManager.PostStash;

            ActionDelegate actionDelegateStashMovement = TownRunManager.StashMovement;
            ActionDelegate actionDelegateStashUpdate = TownRunManager.StashUpdate;
            ActionDelegate actionDelegateStashItems = TownRunManager.StashItems;

            Sequence sequencestash = new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePreStash),
                    new Zeta.TreeSharp.Action(actionDelegateStashMovement),
                    new Zeta.TreeSharp.Action(actionDelegateStashUpdate),
                    new Zeta.TreeSharp.Action(actionDelegateStashItems),
                    new Zeta.TreeSharp.Action(actionDelegatePostStash),
                    new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePrePause),
                    new Zeta.TreeSharp.Action(actionDelegatePause)
                    )
                    );
            GilesReplacement.Children[5] = new Decorator(canRunDelegateStashGilesOverlord, sequencestash);
            Logger.DBLog.DebugFormat("[FunkyTownRun] Stash - hooked...");

            #endregion

            #region Vendor

            // Replace DB vendoring behavior tree with my optimized & "one-at-a-time" version
            CanRunDecoratorDelegate canRunDelegateSellGilesOverlord = TownRunManager.GilesSellOverlord;
            ActionDelegate actionDelegatePreSell = TownRunManager.GilesOptimisedPreSell;
            ActionDelegate actionDelegateMovement = TownRunManager.VendorMovement;
            ActionDelegate actionDelegateSell = TownRunManager.GilesOptimisedSell;
            ActionDelegate actionDelegatePostSell = TownRunManager.GilesOptimisedPostSell;
            Sequence sequenceSell = new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePreSell),
                    new Zeta.TreeSharp.Action(actionDelegateMovement),
                    new Zeta.TreeSharp.Action(actionDelegateSell),
                    new Zeta.TreeSharp.Action(actionDelegatePostSell),
                    new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegatePrePause),
                    new Zeta.TreeSharp.Action(actionDelegatePause)
                    )
                    );
            GilesReplacement.Children[6] = new Decorator(canRunDelegateSellGilesOverlord, sequenceSell);
            Logger.DBLog.DebugFormat("[FunkyTownRun] Vendor - hooked...");

            #endregion

            #region Interaction Behavior
            CanRunDecoratorDelegate canRunDelegateInteraction = TownRunManager.InteractionOverlord;
            ActionDelegate actionDelegateInteractionMovementhBehavior = TownRunManager.InteractionMovement;
            ActionDelegate actionDelegateInteractionClickBehaviorBehavior = TownRunManager.InteractionClickBehavior;
            ActionDelegate actionDelegateInteractionLootingBehaviorBehavior = TownRunManager.InteractionLootingBehavior;
            ActionDelegate actionDelegateInteractionFinishBehaviorBehavior = TownRunManager.InteractionFinishBehavior;

            Sequence sequenceInteraction = new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegateInteractionFinishBehaviorBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateInteractionMovementhBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateInteractionClickBehaviorBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateInteractionLootingBehaviorBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateInteractionFinishBehaviorBehavior)
                );
            GilesReplacement.InsertChild(7, new Decorator(canRunDelegateInteraction, sequenceInteraction));
            Logger.DBLog.DebugFormat("[FunkyTownRun] Interaction Behavior - Inserted...");

            #endregion

            #region Gambling Behavior

            CanRunDecoratorDelegate canRunDelegateGambling = TownRunManager.GamblingRunOverlord;
            ActionDelegate actionDelegateGamblingMovementBehavior = TownRunManager.GamblingMovement;
            ActionDelegate actionDelegateGamblingInteractionBehavior = TownRunManager.GamblingInteraction;
            ActionDelegate actionDelegateGamblingStartBehavior = TownRunManager.GamblingStart;
            ActionDelegate actionDelegateGamblingFinishBehavior = TownRunManager.GamblingFinish;

            Sequence sequenceGambling = new Sequence(
                    new Zeta.TreeSharp.Action(actionDelegateGamblingStartBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateGamblingMovementBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateGamblingInteractionBehavior),
                    new Zeta.TreeSharp.Action(actionDelegateGamblingFinishBehavior)
                );
            GilesReplacement.InsertChild(8, new Decorator(canRunDelegateGambling, sequenceGambling));
            Logger.DBLog.DebugFormat("[FunkyTownRun] Gambling Behavior - Inserted...");

            #endregion

            #region Finish Behavior

            int childrenCount = GilesReplacement.Children.Count;
            ActionDelegate actionFinishReset = TownRunManager.ActionsEvaluatedEndingBehavior;
            ActionDelegate actionDelegateFinishBehavior = TownRunManager.FinishBehavior;
            var finish = GilesReplacement.Children[childrenCount - 1];

            Sequence FinishSequence = new Sequence
            (
                finish,
                new Zeta.TreeSharp.Action(actionFinishReset),
                new Zeta.TreeSharp.Action(actionDelegateFinishBehavior)
            );
            GilesReplacement.Children[childrenCount - 1] = FinishSequence;
            Logger.DBLog.DebugFormat("[FunkyTownRun] Created Sequence Finish Behavior.");

            #endregion

            CanRunDecoratorDelegate canRunDelegateGilesTownRunCheck = TownRunManager.TownRunCheckOverlord;
            VendorCanRunDelegate = canRunDelegateGilesTownRunCheck;
            VendorPrioritySelector = GilesReplacement;
            var VendorComposite = new Decorator(canRunDelegateGilesTownRunCheck, GilesReplacement);
            VendorGUID = VendorComposite.Guid;

            HookHandler.SetHookValue(HookHandler.HookType.VendorRun, 0, VendorComposite);
            Logger.DBLog.DebugFormat("[FunkyTownRun] Vendor Run tree hooking finished.");
            #endregion

            initTreeHooks = true;
        }
コード例 #25
0
ファイル: Spell.cs プロジェクト: aash/Singular
        public static Composite BuffSelfAndWaitPassive(SimpleStringDelegate name, SimpleBooleanDelegate requirements = null, int expirSecs = 0, CanRunDecoratorDelegate until = null, HasGcd gcd = HasGcd.Yes)
        {
            if (requirements == null)
                requirements = req => true;

            if (until == null)
                until = u => StyxWoW.Me.HasAura(u as string);

            return new PrioritySelector(
                ctx => 
                {
                    string spellName = name(ctx);
                    SpellFindResults sfr;
                    if (SpellManager.FindSpell(spellName, out sfr))
                    {
                        spellName = (sfr.Override ?? sfr.Original).Name;
                    }
                    return spellName;
                },
                new Decorator(
                    req => SpellManager.HasSpell( req as string)
                        && !Me.HasAura(req as string)
                        && !DoubleCastContains(Me, req as string),
                    new Sequence(
                        Spell.Cast( sp => sp as string, mov => true, on => Me, requirements, cancel => false, LagTolerance.Yes, false, null, gcd: gcd),
                        new PrioritySelector(
                            new DynaWait(
                                time => TimeSpan.FromMilliseconds(Me.Combat ? 500 : 1000),
                                until,
                                new Action( r => UpdateDoubleCast( r as string, Me, 3000 ))
                                ),
                            new Action(r =>
                            {
                                Logger.WriteDiagnostic("BuffSelfAndWaitPassive: buff of [{0}] failed", name(r));
                                return RunStatus.Failure;
                            })
                            )
                        )
                    )
                );
        }
コード例 #26
0
ファイル: utils.cs プロジェクト: Asphodan/Alphabuddy
 public static Composite HeroicLeap(CanRunDecoratorDelegate cond)
 {
     return new Decorator(ret => Me.CurrentTarget != null && SpellManager.CanCast("Heroic Leap") && !Me.CurrentTarget.HasAura("Charge Stun") && Me.CurrentTarget.Attackable && cond(ret) && !Me.CurrentTarget.IsFlying && Me.CurrentTarget.Distance < 40 && Me.CurrentTarget.Distance >= 8,
     new Sequence(
         new Action(a => Logging.Write("[DWCC]: Heroic Leap.")),
         new Action(a => SpellManager.Cast("Heroic Leap")),
         new Action(ret => SpellManager.ClickRemoteLocation(Me.CurrentTarget.Location))));
 }
コード例 #27
0
        public DecoratorThrottled(TimeSpan                  throttleTime,
                                  CanRunDecoratorDelegate   canRun,
                                  Composite                 composite)
            :base(canRun, composite)
        {
            _throttleTime = throttleTime;

            _throttle = new Stopwatch();
            _throttle.Reset();
            _throttle.Start();
        }
コード例 #28
0
ファイル: utils.cs プロジェクト: Asphodan/Alphabuddy
 public Composite CreateSpellCheckAndCast(string name, CanRunDecoratorDelegate extra)
 {
     return new Decorator(ret => extra(ret) && SpellManager.CanCast(name),
                          new Action(delegate
                          {
                              SpellManager.Cast(name);
                              Logging.Write("[DWCC]: " + name + ".");
                              Logging.WriteDiagnostic("[DWCC]: Attempting to cast " + name + " on " + Me.CurrentTarget.Name.Remove(3, Me.CurrentTarget.Name.Length - 3) + "*** @ " + Me.CurrentTarget.CurrentHealth + "/" + Me.CurrentTarget.MaxHealth + " (" + Math.Round(Me.CurrentTarget.HealthPercent, 2) + "%)");
                              Logging.WriteDiagnostic("[DWCC]: Target: IsCasting: " + Me.CurrentTarget.IsCasting + " | IsPlayer: " + Me.CurrentTarget.IsPlayer + " | Distance: " + Math.Round(Me.CurrentTarget.Distance, 2) + " | Level: " + Me.CurrentTarget.Level + " | IsElite: " + Me.CurrentTarget.Elite + " | Adds: " + detectAdds().Count);
                              Logging.WriteDiagnostic("[DWCC]: We are in: " + Me.ZoneText + " | Instance: " + Me.IsInInstance + " | Outdoors: " + Me.IsOutdoors + " | Battleground: " + Styx.WoWInternals.Battlegrounds.IsInsideBattleground + " | Indoors: " + Me.IsIndoors + " | Party: " + Me.GroupInfo.IsInParty + " | Raid: " + Me.GroupInfo.IsInRaid + " | Members: " + Me.PartyMembers.Count + "/" + Me.RaidMembers.Count + " | Health: " + Me.CurrentHealth + "/" + Me.MaxHealth + " (" + Math.Round(Me.HealthPercent, 2) + "%) | BattleStance: " + BattleStance + " | DefStance: " + DefStance + " | BerserkerStance: " + BersiStance);
                          }
                              ));
 }
コード例 #29
0
ファイル: Wait.cs プロジェクト: KoalaHuman/TreeSharp-1
 /// <summary>
 ///   Creates a new Wait decorator with an 'infinite' timeout, the specified run delegate, and a child composite.
 /// </summary>
 /// <param name = "runFunc"></param>
 /// <param name = "child"></param>
 public Wait(CanRunDecoratorDelegate runFunc, Composite child)
     : this(int.MaxValue, runFunc, child)
 {
 }
コード例 #30
0
ファイル: utils.cs プロジェクト: Asphodan/Alphabuddy
 public Composite FaceAoEPummel(CanRunDecoratorDelegate extra)
 {
     return new Decorator(ret => extra(ret) && !Me.IsFacing((WoWUnit)AoECastingAdds().FirstOrDefault()),
                          new Action(delegate
                          {
                              ((WoWUnit)AoECastingAdds().FirstOrDefault()).Face();
                              Logging.Write("[DWCC]: Facing AoE Pummel target.");
                          }
                              ));
 }