Пример #1
0
        private static bool UpdateOriginalHook(string hookName, Action <Composite> updater)
        {
            if (!OriginalHooks.ContainsKey(hookName))
            {
                return(false);
            }

            updater(OriginalHooks[hookName]);
            return(true);
        }
Пример #2
0
 protected override Composite CreateBehavior()
 {
     var children=new Composite[2];
     var compositeArray=new Composite[2];
     compositeArray[0]=new Action(new ActionSucceedDelegate(FlagTagAsCompleted));
     children[0]=new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray));
     ActionDelegate actionDelegateMove=GilesMoveToLocation;
     var sequenceblank=new Sequence(
         new Action(actionDelegateMove)
         );
     children[1]=sequenceblank;
     return new PrioritySelector(children);
 }
Пример #3
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);
        }
Пример #4
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));
        }
Пример #5
0
        protected override Composite CreateBehavior()
        {
            var children       = new Composite[2];
            var compositeArray = new Composite[2];

            compositeArray[0] = new Action(new ActionSucceedDelegate(FlagTagAsCompleted));
            children[0]       = new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray));
            ActionDelegate actionDelegateMove = GilesMoveToLocation;
            var            sequenceblank      = new Sequence(
                new Action(actionDelegateMove)
                );

            children[1] = sequenceblank;
            return(new PrioritySelector(children));
        }
Пример #6
0
 public Composite GenerateMoveToTargetBehavior()
 {
     var Behavior = new PrioritySelector();
     var MoveToMob = new Action(delegate(object context)
                                    {
                                        if (_context.CurrentTarget == null) return;
                                        if (_context.CurrentTarget.GetNativeObject() == null) return;
                                        Vector3 position = _context.CurrentTarget.GetPosition();
                                        BotManager.Legs.Walk(position.X, position.Y);
                                    });
     Behavior.AddChild(MoveToMob);
     Behavior.AddChild(new Sleep(200));
     return Behavior;
 }
Пример #7
0
        public Composite GenerateCheckAvailableTargetsBehavior(float range)
        {
            var checkAvailableTargetsBehavior = new Action(
                delegate(object context)
                    {
                        if (_context.CurrentTarget == null) return RunStatus.Success;
                        if (_context.CurrentTarget.GetNativeObject() == null) return RunStatus.Success;
                        try
                        {
                            if (_context.CurrentTarget.getDistance() >= range) return RunStatus.Success;
                        }
                        catch (Exception e)
                        {
                            return RunStatus.Success;
                        }
                        _context.IsActive = true;
                        context = _context;

                        return RunStatus.Failure;
                    });

            return checkAvailableTargetsBehavior;
        }
Пример #8
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);
 }
Пример #9
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;
        }
Пример #10
0
        public Composite GenerateTownPortalBehavior()
        {
            CanRunDecoratorDelegate InTown = delegate
                                                 {
                                                     bool timeOut = (_lastTP + TPTimer < Environment.TickCount);
                if (ZetaDia.Me == null) return false;
                if (!ZetaWrap.IsInTown() && (ZetaDia.Me.CommonData.AnimationState != AnimationState.Channeling || timeOut))
                {
                    _lastTP = Environment.TickCount;
                    return true;
                }
                return false;
            };

            var pSequence = new Sequence();
            var PortHome = new Action(delegate
            {
                ZetaDia.Me.UseTownPortal();
                return RunStatus.Success;
            });
            pSequence.AddChild(PortHome);
            return new DecoratorContinue(InTown, PortHome);
        }
Пример #11
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;
        }