Beispiel #1
0
        protected override Composite CreateBehavior()
        {
            Composite[] children       = new Composite[2];
            Composite[] compositeArray = new Composite[2];
            compositeArray[0] = new Zeta.TreeSharp.Action(new ActionSucceedDelegate(FlagTagAsCompleted));
            children[0]       = new Zeta.TreeSharp.Decorator(new CanRunDecoratorDelegate(CheckDistanceWithinPathPrecision), new Sequence(compositeArray));
            ActionDelegate actionDelegateMove = new ActionDelegate(GilesMoveToLocation);
            Sequence       sequenceblank      = new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateMove)
                );

            children[1] = sequenceblank;
            return(new PrioritySelector(children));
        }
Beispiel #2
0
        protected override Composite CreateBehavior()
        {
            Composite[] children=new Composite[2];

            ActionDelegate actionDelegateCast=new ActionDelegate(Funky.FunkyTPBehavior);
            Sequence sequenceblank=new Sequence(
                new Zeta.TreeSharp.Action(actionDelegateCast)
                );

            children[0]=new Zeta.TreeSharp.Decorator(new CanRunDecoratorDelegate(Funky.FunkyTPOverlord), sequenceblank);
            children[1]=new Zeta.TreeSharp.Action(new ActionSucceedDelegate(FlagTagAsCompleted));

            return new PrioritySelector(children);
        }
Beispiel #3
0
        internal static void HookCombat()
        {
            CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = PreCombat.PreCombatOverlord;
            ActionDelegate          actionDelegateCoreTarget        = PreCombat.HandleTarget;
            Sequence sequencecombat = new Sequence
                                      (
                new Zeta.TreeSharp.Action(actionDelegateCoreTarget)
                                      );
            Decorator Precombat = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);

            //Record GUID for checking
            PrecombatCompositeGUID = Precombat.Guid;
            //Insert precombat!
            SetHookValue(HookType.Combat, 0, Precombat, true);
        }
Beispiel #4
0
 protected override Composite CreateBehavior()
 {
     //Funky.hashSkipAheadAreaCache=new HashSet<Funky.SkipAheadNavigation>();
     Composite[] children=new Composite[2];
     Composite[] compositeArray=new Composite[2];
     compositeArray[0]=new Zeta.TreeSharp.Action(new ActionSucceedDelegate(FlagTagAsCompleted));
     children[0]=new Zeta.TreeSharp.Decorator(new CanRunDecoratorDelegate(CheckDistanceWithinPathPrecision), new Sequence(compositeArray));
     ActionDelegate actionDelegateMove=new ActionDelegate(GilesMoveToLocation);
     Sequence sequenceblank=new Sequence(
         new Zeta.TreeSharp.Action(actionDelegateMove)
         );
     children[1]=sequenceblank;
     return new PrioritySelector(children);
 }
Beispiel #5
0
        internal static void HookBehaviorTree()
        {
            Logger.DBLog.InfoFormat("[Funky] Treehooks..");
            #region TreeHooks

            #region OutOfGame
            CanRunDecoratorDelegate shouldPreformOutOfGameBehavior = OutOfGame.OutOfGameOverlord;
            ActionDelegate          actionDelgateOOGBehavior       = OutOfGame.OutOfGameBehavior;
            Sequence sequenceOOG = new Sequence(
                new Action(actionDelgateOOGBehavior)
                );
            var OutOfGameInsert = new Decorator(shouldPreformOutOfGameBehavior, sequenceOOG);
            SetHookValue(HookType.OutOfGame, 0, OutOfGameInsert, true);
            Logger.DBLog.DebugFormat("Out of game tree hooked");
            #endregion

            #region Death
            Logger.DBLog.DebugFormat("Death...");
            //Insert Death Tally Counter At Beginning!
            CanRunDecoratorDelegate deathTallyDecoratorDelegate    = DeathBehavior.TallyDeathCanRunDecorator;
            ActionDelegate          actionDelegatedeathTallyAction = DeathBehavior.TallyDeathAction;
            Action    deathTallyAction    = new Action(actionDelegatedeathTallyAction);
            Decorator deathTallyDecorator = new Decorator(deathTallyDecoratorDelegate, deathTallyAction);

            //Death Wait..
            CanRunDecoratorDelegate deathWaitDecoratorDelegate = DeathBehavior.DeathShouldWait;
            ActionDelegate          deathWaitActionDelegate    = DeathBehavior.DeathWaitAction;
            Action    deathWaitAction    = new Action(deathWaitActionDelegate);
            Decorator deathWaitDecorator = new Decorator(deathWaitDecoratorDelegate, deathWaitAction);


            Sequence DeathSequence = new Sequence
                                     (
                deathTallyDecorator,
                deathWaitDecorator
                                     );
            SetHookValue(HookType.Death, 0, DeathSequence, true);
            //hook.Value.Add(deathTallyActionReset);
            Logger.DBLog.DebugFormat("Death tree hooked");
            #endregion


            if (RoutineManager.Current.Name == "Funky")
            {
                CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = CombatHandler.GlobalOverlord;
                ActionDelegate          actionDelegateCoreTarget        = CombatHandler.HandleTarget;
                Sequence sequencecombat = new Sequence
                                          (
                    new Action(actionDelegateCoreTarget)
                                          );
                var NewCombatComposite = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);
                SetHookValue(HookType.Combat, 0, NewCombatComposite);

                CanRunDecoratorDelegate canRunDelegateBlank = BlankDecorator;
                ActionDelegate          actionDelegateBlank = BlankAction;
                Sequence sequenceblank = new Sequence(
                    new Action(actionDelegateBlank)
                    );

                var NewLootComposite = new Decorator(canRunDelegateBlank, sequenceblank);
                SetHookValue(HookType.Loot, 0, NewLootComposite);
            }

            #endregion

            initTreeHooks = true;
        }
Beispiel #6
0
        internal static void HookBehaviorTree()
        {
            bool townportal = false, idenify = false, stash = false, vendor = false, salvage = false, looting = true, combat = true;

            using (XmlReader reader = XmlReader.Create(FolderPaths.sTrinityPluginPath + "Treehooks.xml"))
            {
                // Parse the XML document.  ReadString is used to
                // read the text content of the elements.
                reader.Read();
                reader.ReadStartElement("Treehooks");
                reader.Read();
                while (reader.LocalName != "Treehooks")
                {
                    switch (reader.LocalName)
                    {
                    case "Townportal":
                        townportal = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Identification":
                        idenify = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Stash":
                        stash = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Vendor":
                        vendor = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Salvage":
                        salvage = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Looting":
                        looting = Convert.ToBoolean(reader.ReadInnerXml());
                        break;

                    case "Combat":
                        combat = Convert.ToBoolean(reader.ReadInnerXml());
                        break;
                    }

                    reader.Read();
                }
            }

            Logger.DBLog.InfoFormat("[Funky] Replacing Treehooks..");
            #region TreeHooks
            foreach (var hook in TreeHooks.Instance.Hooks)
            {
                // Replace the combat behavior tree, as that happens first and so gets done quicker!
                if (hook.Key.Contains("Combat"))
                {
                    if (combat)
                    {
                        // Replace the pause just after identify stuff to ensure we wait before trying to run to vendor etc.
                        CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = GlobalOverlord;
                        ActionDelegate          actionDelegateCoreTarget        = HandleTarget;
                        Sequence sequencecombat = new Sequence(
                            new Action(actionDelegateCoreTarget)
                            );
                        hook.Value[0] = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);
                        Logger.DBLog.DebugFormat("Combat Tree replaced...");
                    }
                }                 // Vendor run hook
                // Wipe the vendorrun and loot behavior trees, since we no longer want them
                if (hook.Key.Contains("VendorRun"))
                {
                    Decorator GilesDecorator = hook.Value[0] as Decorator;
                    //PrioritySelector GilesReplacement = GilesDecorator.Children[0] as PrioritySelector;
                    PrioritySelector GilesReplacement = GilesDecorator.Children[0] as PrioritySelector;

                    //[1] == Return to town
                    if (townportal)
                    {
                        CanRunDecoratorDelegate canRunDelegateReturnToTown     = TownPortalBehavior.FunkyTPOverlord;
                        ActionDelegate          actionDelegateReturnTown       = TownPortalBehavior.FunkyTPBehavior;
                        ActionDelegate          actionDelegateTownPortalFinish = TownPortalBehavior.FunkyTownPortalTownRun;
                        Sequence sequenceReturnTown = new Sequence(
                            new Action(actionDelegateReturnTown),
                            new Action(actionDelegateTownPortalFinish)
                            );
                        GilesReplacement.Children[1] = new Decorator(canRunDelegateReturnToTown, sequenceReturnTown);
                        Logger.DBLog.DebugFormat("Town Run - Town Portal - hooked...");
                    }

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

                    if (idenify)
                    {
                        //[2] == IDing items in inventory
                        CanRunDecoratorDelegate canRunDelegateFunkyIDBehavior = ItemIdentifyBehavior.FunkyIDOverlord;
                        ActionDelegate          actionDelegateID = ItemIdentifyBehavior.FunkyIDBehavior;
                        Sequence sequenceIDItems = new Sequence(
                            new Action(actionDelegateID),
                            new Sequence(
                                new Action(actionDelegatePrePause),
                                new Action(actionDelegatePause)
                                )
                            );
                        GilesReplacement.Children[2] = new Decorator(canRunDelegateFunkyIDBehavior, sequenceIDItems);
                        Logger.DBLog.DebugFormat("Town Run - Idenify Items - hooked...");
                    }


                    // Replace the pause just after identify stuff to ensure we wait before trying to run to vendor etc.
                    CanRunDecoratorDelegate canRunDelegateStashGilesPreStashPause = TownRunManager.GilesPreStashPauseOverlord;
                    Sequence sequencepause = new Sequence(
                        new Action(actionDelegatePrePause),
                        new Action(actionDelegatePause)
                        );

                    GilesReplacement.Children[3] = new Decorator(canRunDelegateStashGilesPreStashPause, sequencepause);


                    if (stash)
                    {
                        // Replace DB stashing behavior tree with my optimized version with loot rule replacement
                        CanRunDecoratorDelegate canRunDelegateStashGilesOverlord = TownRunManager.GilesStashOverlord;
                        ActionDelegate          actionDelegatePreStash           = TownRunManager.GilesOptimisedPreStash;
                        ActionDelegate          actionDelegateStashing           = TownRunManager.GilesOptimisedStash;
                        ActionDelegate          actionDelegatePostStash          = TownRunManager.GilesOptimisedPostStash;
                        Sequence sequencestash = new Sequence(
                            new Action(actionDelegatePreStash),
                            new Action(actionDelegateStashing),
                            new Action(actionDelegatePostStash),
                            new Sequence(
                                new Action(actionDelegatePrePause),
                                new Action(actionDelegatePause)
                                )
                            );
                        GilesReplacement.Children[4] = new Decorator(canRunDelegateStashGilesOverlord, sequencestash);
                        Logger.DBLog.DebugFormat("Town Run - Stash - hooked...");
                    }

                    if (vendor)
                    {
                        // Replace DB vendoring behavior tree with my optimized & "one-at-a-time" version
                        CanRunDecoratorDelegate canRunDelegateSellGilesOverlord = TownRunManager.GilesSellOverlord;
                        ActionDelegate          actionDelegatePreSell           = TownRunManager.GilesOptimisedPreSell;
                        ActionDelegate          actionDelegateSell     = TownRunManager.GilesOptimisedSell;
                        ActionDelegate          actionDelegatePostSell = TownRunManager.GilesOptimisedPostSell;
                        Sequence sequenceSell = new Sequence(
                            new Action(actionDelegatePreSell),
                            new Action(actionDelegateSell),
                            new Action(actionDelegatePostSell),
                            new Sequence(
                                new Action(actionDelegatePrePause),
                                new Action(actionDelegatePause)
                                )
                            );
                        GilesReplacement.Children[5] = new Decorator(canRunDelegateSellGilesOverlord, sequenceSell);
                        Logger.DBLog.DebugFormat("Town Run - Vendor - hooked...");
                    }

                    if (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 Action(actionDelegatePreSalvage),
                            new Action(actionDelegateSalvage),
                            new Action(actionDelegatePostSalvage),
                            new Sequence(
                                new Action(actionDelegatePrePause),
                                new Action(actionDelegatePause)
                                )
                            );
                        GilesReplacement.Children[6] = new Decorator(canRunDelegateSalvageGilesOverlord, sequenceSalvage);
                        Logger.DBLog.DebugFormat("Town Run - Salvage - hooked...");
                    }


                    //Decorator FinishTownRun=GilesReplacement.Children[7] as Decorator;
                    //Decorator FinishTownRunCheck=FinishTownRun.Children[0] as Decorator;
                    //PrioritySelector FinishTownRunPrioritySelector=FinishTownRunCheck.DecoratedChild as PrioritySelector;
                    //Decorator FinishTownRunPrioritySelectorDecorator=FinishTownRunPrioritySelector.Children[0] as Decorator;
                    //Zeta.TreeSharp.Action FinishTownRunAction=FinishTownRunPrioritySelectorDecorator.Children[0] as Zeta.TreeSharp.Action;

                    //[7] == Return to Townportal if there is one..

                    //Setup our movement back to townportal
                    //CanRunDecoratorDelegate canRunDelegateUseTownPortalReturn = TownRunManager.FinishTownRunOverlord;
                    //ActionDelegate actionDelegateFinishTownRun = TownRunManager.TownRunFinishBehavior;
                    //Sequence sequenceFinishTownRun = new Sequence(
                    //   new Action(actionDelegateFinishTownRun)
                    //);

                    //We insert this before the demonbuddy townportal finishing behavior..
                    //GilesReplacement.InsertChild(7, new Decorator(canRunDelegateUseTownPortalReturn, sequenceFinishTownRun));



                    CanRunDecoratorDelegate canRunUnidBehavior          = TownRunManager.UnidItemOverlord;
                    ActionDelegate          actionDelegatePreUnidStash  = TownRunManager.UnidStashOptimisedPreStash;
                    ActionDelegate          actionDelegatePostUnidStash = TownRunManager.UnidStashOptimisedPostStash;
                    ActionDelegate          actionDelegateUnidBehavior  = TownRunManager.UnidStashBehavior;
                    Sequence sequenceUnidStash = new Sequence(
                        new Action(actionDelegatePreUnidStash),
                        new Action(actionDelegateUnidBehavior),
                        new Action(actionDelegatePostUnidStash),
                        new Sequence(
                            new Action(actionDelegatePrePause),
                            new Action(actionDelegatePause)
                            )
                        );
                    GilesReplacement.InsertChild(2, new Decorator(canRunUnidBehavior, sequenceUnidStash));


                    CanRunDecoratorDelegate canRunDelegateGilesTownRunCheck = TownRunManager.GilesTownRunCheckOverlord;
                    hook.Value[0] = new Decorator(canRunDelegateGilesTownRunCheck, new PrioritySelector(GilesReplacement));

                    Logger.DBLog.DebugFormat("Vendor Run tree hooked...");
                }                 // Vendor run hook
                if (hook.Key.Contains("Loot"))
                {
                    if (looting)
                    {
                        // Replace the loot behavior tree with a blank one, as we no longer need it
                        CanRunDecoratorDelegate canRunDelegateBlank = BlankDecorator;
                        ActionDelegate          actionDelegateBlank = BlankAction;
                        Sequence sequenceblank = new Sequence(
                            new Action(actionDelegateBlank)
                            );
                        hook.Value[0] = new Decorator(canRunDelegateBlank, sequenceblank);
                        Logger.DBLog.DebugFormat("Loot tree replaced...");
                    }
                    else
                    {
                        CanRunDecoratorDelegate canRunDelegateBlank = BlankDecorator;
                        hook.Value[0] = new Decorator(canRunDelegateBlank, BrainBehavior.CreateLootBehavior());
                    }
                }                 // Vendor run hook
                if (hook.Key.Contains("OutOfGame"))
                {
                    PrioritySelector CompositeReplacement = hook.Value[0] as PrioritySelector;

                    CanRunDecoratorDelegate shouldPreformOutOfGameBehavior = OutOfGame.OutOfGameOverlord;
                    ActionDelegate          actionDelgateOOGBehavior       = OutOfGame.OutOfGameBehavior;
                    Sequence sequenceOOG = new Sequence(
                        new Action(actionDelgateOOGBehavior)
                        );
                    CompositeReplacement.Children.Insert(0, new Decorator(shouldPreformOutOfGameBehavior, sequenceOOG));
                    hook.Value[0] = CompositeReplacement;

                    Logger.DBLog.DebugFormat("Out of game tree hooked");
                }
                if (hook.Key.Contains("Death"))
                {
                    PrioritySelector DeathPrioritySelector = hook.Value[0] as PrioritySelector;

                    //CanRunDecoratorDelegate canRunDeathBehavior=new CanRunDecoratorDelegate(Death.DeathOverlord);

                    //Sequence sequenceDeath=new Sequence(
                    //	 new Zeta.TreeSharp.Action(actionDelgateDeath)
                    //);
                    //DeathPrioritySelector.Children[0]=new Zeta.TreeSharp.Decorator(canRunDeathBehavior, sequenceDeath);

                    Decorator      DeathDecorator     = DeathPrioritySelector.Children[0] as Decorator;
                    Sequence       DeathSequence      = DeathDecorator.Children[0] as Sequence;
                    ActionDelegate actionDelgateDeath = EventHandlers.DeathHandler;
                    DeathSequence.InsertChild(0, new Action(actionDelgateDeath));

                    /*
                     * 17:10:24.548 N] Zeta.TreeSharp.Action
                     * [17:10:24.548 N] Zeta.TreeSharp.DecoratorContinue
                     * [17:10:24.548 N] Zeta.TreeSharp.Action
                     * [17:10:24.548 N] Zeta.TreeSharp.Sleep
                     * [17:10:24.548 N] Zeta.TreeSharp.Action
                     */
                    // foreach (var item in DeathSequence.Children)
                    //{
                    //	 Logger.DBLog.InfoFormat(item.GetType().ToString());
                    //}
                }
            }
            #endregion
            initTreeHooks = true;
        }
Beispiel #7
0
 internal static void HookCombat()
 {
     CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = PreCombat.PreCombatOverlord;
     ActionDelegate actionDelegateCoreTarget = PreCombat.HandleTarget;
     Sequence sequencecombat = new Sequence
     (
         new Zeta.TreeSharp.Action(actionDelegateCoreTarget)
     );
     Decorator Precombat = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);
     //Record GUID for checking
     PrecombatCompositeGUID = Precombat.Guid;
     //Insert precombat!
     SetHookValue(HookType.Combat, 0, Precombat, true);
 }
Beispiel #8
0
        internal static void HookBehaviorTree()
        {
            Logger.DBLog.InfoFormat("[Funky] Treehooks..");
            #region TreeHooks

            #region OutOfGame
            CanRunDecoratorDelegate shouldPreformOutOfGameBehavior = OutOfGame.OutOfGameOverlord;
            ActionDelegate actionDelgateOOGBehavior = OutOfGame.OutOfGameBehavior;
            Sequence sequenceOOG = new Sequence(
                    new Action(actionDelgateOOGBehavior)
            );
            var OutOfGameInsert = new Decorator(shouldPreformOutOfGameBehavior, sequenceOOG);
            SetHookValue(HookType.OutOfGame, 0, OutOfGameInsert, true);
            Logger.DBLog.DebugFormat("Out of game tree hooked");
            #endregion

            #region Death
            Logger.DBLog.DebugFormat("Death...");
            //Insert Death Tally Counter At Beginning!
            CanRunDecoratorDelegate deathTallyDecoratorDelegate = DeathBehavior.TallyDeathCanRunDecorator;
            ActionDelegate actionDelegatedeathTallyAction = DeathBehavior.TallyDeathAction;
            Action deathTallyAction = new Action(actionDelegatedeathTallyAction);
            Decorator deathTallyDecorator = new Decorator(deathTallyDecoratorDelegate, deathTallyAction);

            //Death Wait..
            CanRunDecoratorDelegate deathWaitDecoratorDelegate = DeathBehavior.DeathShouldWait;
            ActionDelegate deathWaitActionDelegate = DeathBehavior.DeathWaitAction;
            Action deathWaitAction = new Action(deathWaitActionDelegate);
            Decorator deathWaitDecorator = new Decorator(deathWaitDecoratorDelegate, deathWaitAction);

            Sequence DeathSequence = new Sequence
            (
                deathTallyDecorator,
                deathWaitDecorator
            );
            SetHookValue(HookType.Death, 0, DeathSequence, true);
            //hook.Value.Add(deathTallyActionReset);
            Logger.DBLog.DebugFormat("Death tree hooked");
            #endregion

            if (RoutineManager.Current.Name == "Funky")
            {
                CanRunDecoratorDelegate canRunDelegateCombatTargetCheck = CombatHandler.GlobalOverlord;
                ActionDelegate actionDelegateCoreTarget = CombatHandler.HandleTarget;
                Sequence sequencecombat = new Sequence
                (
                    new Action(actionDelegateCoreTarget)
                );
                var NewCombatComposite = new Decorator(canRunDelegateCombatTargetCheck, sequencecombat);
                SetHookValue(HookType.Combat, 0, NewCombatComposite);

                CanRunDecoratorDelegate canRunDelegateBlank = BlankDecorator;
                ActionDelegate actionDelegateBlank = BlankAction;
                Sequence sequenceblank = new Sequence(
                        new Action(actionDelegateBlank)
                        );

                var NewLootComposite = new Decorator(canRunDelegateBlank, sequenceblank);
                SetHookValue(HookType.Loot, 0, NewLootComposite);
            }

            #endregion

            initTreeHooks = true;
        }