Ejemplo n.º 1
0
        public void Fight()
        {
            if (_localPlayerCharacterView.IsMounted)
            {
                Core.Log("Player Mounted. Dismount now.");
                _localPlayerCharacterView.MountOrDismount();
                return;
            }

            if (_combatCooldown > 0 || _localPlayerCharacterView.bIsChanneling())
            {
                Core.LogOnce("Combat Cooldown > 0. Player is channeling: " + _localPlayerCharacterView.bIsChanneling());
                _combatCooldown -= UnityEngine.Time.deltaTime;
                return;
            }

            _combatPlayer = _localPlayerCharacterView.GetLocalPlayerCharacter();
            _combatTarget = _localPlayerCharacterView.GetAttackTarget();
            _combatSpells = _combatPlayer.GetSpellSlotsIndexed().Ready(_localPlayerCharacterView).Ignore("ESCAPE_DUNGEON").Ignore("PLAYER_COUPDEGRACE").Ignore("AMBUSH");

            if (_localPlayerCharacterView.IsCasting() || _combatPlayer.GetIsCasting())
            {
                Core.Log("You are casting. Wait for casting to finish");
                return;
            }

            if (_combatTarget != null && !_combatTarget.IsCasting())
            {
                //Ignore the Spell Interrupt to have it up if needed!
                _combatSpells = _combatSpells.Ignore("INTERRUPT");
            }
            else
            {
                //if Interrupt Spell is useable use it to interrupt the cast and dont run like a pussy and die.
                if (_combatTarget != null && _combatTarget.IsCasting() && _combatSpells.First().GetSpellDescriptor().TryGetName() == "INTERRUPT2")
                {
                    Core.Log("Interrupt ready. Use it!");
                }
                else if (_combatTarget != null && _combatTarget.IsCasting())
                {
                    Core.Log("Running away from Spell");
                    // Choose a random point behind Player.
                    Vector3 back      = _localPlayerCharacterView.transform.forward * 15f;
                    float   randAngle = UnityEngine.Random.Range(-75f, 75f);
                    back = Quaternion.AngleAxis(randAngle, Vector3.up) * back;
                    Vector3 randPos = back + _localPlayerCharacterView.transform.position;

                    _localPlayerCharacterView.StopAnyActionObject();
                    _localPlayerCharacterView.RequestMove(randPos);
                    _combatCooldown = 0.3f;
                }
            }

            if (_combatCooldown > 0 || _localPlayerCharacterView.bIsChanneling())
            {
                Core.LogOnce("Combat Cooldown > 0. Player is channeling: " + _localPlayerCharacterView.bIsChanneling());
                _combatCooldown -= UnityEngine.Time.deltaTime;
                return;
            }

            if (_combatTarget != null && !_combatTarget.IsDead() && SpellPriorityList.Any(s => TryToCastSpell(s.Item1, s.Item2, s.Item3)))
            {
                return;
            }

            if (_localPlayerCharacterView.IsUnderAttack(out FightingObjectView attacker))
            {
                Core.LogOnce("You are under attack. Attack the attacker");
                _localPlayerCharacterView.SetSelectedObject(attacker);
                _localPlayerCharacterView.AttackSelectedObject();
                return;
            }

            if (_combatPlayer.GetIsCasting())
            {
                Core.Log("You are casting. Wait for casting to finish");
                return;
            }

            if (_combatPlayer.GetHealth().GetValue() < (_combatPlayer.GetHealth().GetMaximum() * 0.8f))
            {
                Core.LogOnce("Health below 80%");
                var healSpell = _combatSpells.Target(SpellTarget.Self).Category(SpellCategory.Heal);

                if (healSpell.Any())
                {
                    Core.Log("Cast heal spell on self");
                    _localPlayerCharacterView.CastOnSelf(healSpell.FirstOrDefault().Slot);
                }
                return;
            }

            _currentTarget         = null;
            _harvestPathingRequest = null;

            Core.Log("[Eliminated]");
            _state.Fire(Trigger.EliminatedAttacker);
        }
Ejemplo n.º 2
0
        public void Fight()
        {
            if (_localPlayerCharacterView.IsMounted)
            {
                _localPlayerCharacterView.MountOrDismount();
                return;
            }

            if (_combatCooldown > 0)
            {
                _combatCooldown -= UnityEngine.Time.deltaTime;
                return;
            }
            //Core.Log($" Game Time Now {GameTimeStamp.Now.ToString()}");
            //Core.Log($" Cast End Time  {castEnd.ToString()}");
            //Core.Log($" Cast2 End Time  {castEnd2.ToString()}");


            //Core.Log($" Cast start Time  {castStart1.ToString()}");
            //Core.Log($" Cast2 start Time  {castStart2.ToString()}");


            //Core.Log($"{castEnd2.CompareTo(GameTimeStamp.Now)}");



            //if (castEnd2.CompareTo(GameTimeStamp.Now) == 1)
            //{
            //    Core.Log("Channelling");
            //    return;
            //}

            _combatPlayer = _localPlayerCharacterView.GetLocalPlayerCharacter();
            _combatTarget = _localPlayerCharacterView.GetAttackTarget();
            _combatSpells = _combatPlayer.GetSpellSlotsIndexed().Ready(_localPlayerCharacterView).Ignore("ESCAPE_DUNGEON").Ignore("PLAYER_COUPDEGRACE").Ignore("AMBUSH");

            foreach (var cs in _combatSpells)
            {
                // Core.Log($"{cs.GetSpellDescriptor().TryGetName()}");
                //Core.Log($"{cs.GetSpellDescriptor().TryGetTarget()}");
                //Core.Log($"{cs.GetSpellDescriptor().TryGetCategory()}");
            }



            if (_combatTarget != null && !_combatTarget.IsDead() && SpellPriorityList.Any(s => TryToCastSpell(s.Item1, s.Item2, s.Item3)))
            {
                return;
            }

            if (_localPlayerCharacterView.IsUnderAttack(out FightingObjectView attacker))
            {
                _localPlayerCharacterView.SetSelectedObject(attacker);
                _localPlayerCharacterView.AttackSelectedObject();
                return;
            }

            // if (GameTimeStamp.Now < channelEnd)
            // Core.Log($"{GameTimeStamp.Now.ToString()}");
            if (_combatPlayer.GetIsCasting())
            {
                return;
            }

            if (_combatPlayer.GetHealth().GetValue() < (_combatPlayer.GetHealth().GetMaximum() * 0.8f))
            {
                var healSpell = _combatSpells.Target(SpellTarget.Self).Category(SpellCategory.Heal);

                if (healSpell.Any())
                {
                    _localPlayerCharacterView.CastOnSelf(healSpell.FirstOrDefault().Slot);
                }
                return;
            }

            _currentTarget         = null;
            _harvestPathingRequest = null;

            Core.Log("[Eliminated]");
            _state.Fire(Trigger.EliminatedAttacker);
        }