Exemple #1
0
        /// <summary>
        /// The Pulse should be responsible for updating the Buffs/Debuffs
        /// and calling CombatRoutine and LogicStrategy
        /// </summary>
        private void doPulse()
        {
            LogicRequest  LR;
            CombatRequest CR;

            while (true)
            {
                try
                {
                    // Populate all nearby units before doing anything else
                    getObjects();


                    // Out of combat stuff
                    if (this.isAlive())
                    {
                        // TODO: eat / drink call to cRoutine
                        while (((float)this.getHP() / (float)this.getMaxHP()) < 0.9f && this.isInCombat() == false)
                        {
                            Thread.Sleep(200);
                        }
                    }


                    /* Pulse the Logic Strategy
                     * This should return a request containing
                     * either a movement location or a unit to target.
                     */

                    // If we have no target, move to a new location while looking for a target
                    if (this.target == null)
                    {
                        LR = lStrat.getRequest(this);

                        // Found a target, set it and move on to the combat strategy.
                        if (LR.getTarget() != null)
                        {
                            target = LR.getTarget();
                            Debug.WriteLine("Targeting: " + LR.getTarget().getGUID().ToString("X16"));
                            this.targetUnit(LR.getTarget());
                        }
                        // Found no target, try moving instead
                        else if (LR.getMove() != null)
                        {
                            moveToLoc(LR.getMove());
                        }
                    }

                    /* Pulse the CombatRoutine strategy
                     * This should loop until the current target dies.
                     * This logic may change in the future but it is simple
                     * enough for now.
                     */

                    // We have a target
                    if (this.target != null)
                    {
                        while (((Mob)this.target).getHP() > 0 && this.isAlive())
                        {
                            Thread.Sleep(100);
                            CR = cRoutine.getRequest(this);

                            if (CR.getMove() != null)
                            {
                                moveToLoc(CR.getMove());
                            }

                            if (CR.getAbility() != '.')
                            {
                                faceLocation(this.target.getLocation());
                                castNoGCDByKey(CR.getAbility().ToString());
                                Thread.Sleep(1000); // TODO: Add GCD Logic Just for testing
                            }
                        }

                        // LOOOOOOOTS
                        Thread.Sleep(50);
                        //if(!this.isInCombat())
                        if (this.getUnitsTargetingPlayer().Count < 1 && this.isAlive())
                        {
                            LootUnit(this.target);
                        }

                        // Remove our current target since it is dead.
                        this.target = null;
                    }

                    // wait before next pulse is sent
                    Thread.Sleep(100);
                }
                catch (Exception ex)
                {
                    // TODO
                    Debug.Print("Exception in main Pulse: " + ex.Message);
                    Debug.Print("From: " + ex.TargetSite);
                }
            }
        }