コード例 #1
0
        public void HandleAttacking()
        {
            if (Me != null)
            {
                Me.Update();
            }
            if (Target != null)
            {
                Target.Update();
            }

            Unit unitToAttack = Target;

            // Get a target
            if (Me.TargetGuid == 0)
            {
                unitToAttack = CombatUtils.AssistParty(Me, AmeisenDataHolder.ActiveWoWObjects);
            }

            if (unitToAttack != null)
            {
                // Start autoattack
                if (!Me.InCombat)
                {
                    CombatUtils.FaceTarget(Me, unitToAttack);
                    CombatUtils.AttackTarget();
                }

                DoAttackRoutine();
            }
        }
コード例 #2
0
ファイル: ActionCombat.cs プロジェクト: IgorYunusov/wow-bot
        public override void DoThings()
        {
            // Updte me, target and pet
            Me?.Update();
            Target?.Update();
            Pet?.Update();

            // Handle pending movement actions
            if (WaypointQueue.Count > 0)
            {
                base.DoThings();
            }

            // Try to get a target
            if (AmeisenDataHolder.IsHealer)
            {
                CombatUtils.TargetTargetToHeal(Me, AmeisenDataHolder.ActiveWoWObjects);
                Me?.Update();
                Target?.Update();
            }
            else
            {
                // clear all friendly targets
                AmeisenCore.ClearTargetIfItIsFriendly();

                if (Me.TargetGuid == 0 || CombatUtils.IsUnitValid(Target))
                {
                    CombatUtils.AssistParty(Me, AmeisenDataHolder.ActiveWoWObjects, AmeisenDataHolder.Partymembers);
                    // clear all friendly targets again
                    AmeisenCore.ClearTargetIfItIsFriendly();
                    Me?.Update();
                    Target?.Update();
                }

                if (Me.TargetGuid == 0 || CombatUtils.IsUnitValid(Target))
                {
                    CombatUtils.TargetNearestEnemy();
                    Me?.Update();
                    Target?.Update();

                    if (Me.TargetGuid == 0 || CombatUtils.IsUnitValid(Target))
                    {
                        // by now we should have a target
                        return;
                    }
                }
            }

            // Attack target if we are no healer
            if (!Me.InCombat && !AmeisenDataHolder.IsHealer)
            {
                CombatUtils.AttackTarget();
            }

            // Cast the Spell selected for this Iteration
            if (CombatPackage.SpellStrategy != null)
            {
                Me?.Update();
                Target?.Update();

                Spell spellToUse = CombatPackage.SpellStrategy.DoRoutine(Me, Target, Pet);
                if (spellToUse != null)
                {
                    // try to get in line of sight
                    while (!IsInLineOfSight(Me, Target))
                    {
                        HandleMovement(Target.pos);
                        Thread.Sleep(500);
                    }

                    CombatUtils.CastSpellByName(Me, Target, spellToUse.Name, false, true);
                }
                else
                {
                    Thread.Sleep(200);
                }
            }

            // Handle Movement stuff
            if (CombatPackage.MovementStrategy != null)
            {
                Me?.Update();
                Target?.Update();
                HandleMovement(CombatPackage.MovementStrategy.CalculatePosition(Me, Target));
            }
        }