Example #1
0
        public void NewTurn()
        {
            ActionPoints = ActionPointsPerTurn;


            bool keepBlock = ActiveBuffs.Any(s => s.Key.KeepBlockNextTurn);

            foreach (var buff in ActiveBuffs.Keys.Where(b => b.TickOnStartTurn).ToList())
            {
                ActiveBuffs[buff]--;
                if (ActiveBuffs[buff] <= 0 || buff.RemoveAllStacksOnTick)
                {
                    ActiveBuffs.Remove(buff);
                }
            }

            UpdateBuffsGUI();

            if (keepBlock)
            {
                // Nothing we have to keep block
            }
            else
            {
                Block = 0;
            }
        }
Example #2
0
        /// <summary>
        /// Updates player position. Saves change to database if needed.
        /// </summary>
        /// <param name="x">new x</param>
        /// <param name="y">new y</param>
        /// <param name="z">new z</param>
        /// <param name="saveChangesToDB">set it to true, if this change should be saved to database</param>
        private void UpdatePosition(float x, float y, float z, ushort angle, bool saveChangesToDB)
        {
            if (ActiveBuffs.Any(b => b.StateType == StateType.Immobilize || b.StateType == StateType.Sleep || b.StateType == StateType.Stun))
            {
                OnPositionChanged?.Invoke(this);
                return;
            }

            PosX  = x;
            PosY  = y;
            PosZ  = z;
            Angle = angle;

            if (IsDuelApproved && MathExtensions.Distance(PosX, DuelX, PosZ, DuelZ) >= 45)
            {
                FinishDuel(DuelCancelReason.TooFarAway);
            }

            //_logger.LogDebug($"Character {Id} moved to x={PosX} y={PosY} z={PosZ} angle={Angle}");

            if (saveChangesToDB)
            {
                _taskQueue.Enqueue(ActionType.SAVE_CHARACTER_MOVE,
                                   Id, x, y, z, angle);
            }

            OnPositionChanged?.Invoke(this);
        }
 private bool TestActiveBuffs(IPlayerPowerInfo powers)
 {
     if (ActiveBuffs != null)
     {
         return(AllActiveBuffs
             ? ActiveBuffs.All(buff => buff.Icon.HasValue ? powers.BuffIsActive(buff.Sno, buff.Icon.Value) : powers.BuffIsActive(buff.Sno))
             : ActiveBuffs.Any(buff => buff.Icon.HasValue ? powers.BuffIsActive(buff.Sno, buff.Icon.Value) : powers.BuffIsActive(buff.Sno)));
     }
     return(true);
 }
Example #4
0
        public int DealDamage(int damage, bool ignoreBlock = false)
        {
            int mod = 100;

            if (ActiveBuffs.Any(a => a.Key.MegaVulnerable))
            {
                mod += 50;
            }

            if (ActiveBuffs.Any(a => a.Key.Vulnerable))
            {
                mod += 25;
            }

            if (mod != 100)
            {
                damage = (damage * mod) / 100;
            }

            if (damage > 0 && ActiveBuffs.Any(b => b.Key.TakeNoDamage))
            {
                damage = 1;
            }

            if (!ignoreBlock)
            {
                int remain = Block - damage;
                if (remain > 0)
                {
                    Block  = remain;
                    damage = 0;
                }
                else
                {
                    Block  = 0;
                    damage = -remain;
                }
            }
            CurrentHealth -= damage;
            if (CurrentHealth <= 0)
            {
                Kill();
            }

            _damageAccumulator += damage;

            _damageTimer = 1.5f;

            return(damage);
        }
Example #5
0
        public bool IsVisible(IController controller)
        {
            if (HeroClass != HeroClass.None && Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass)
            {
                return(false);
            }
            if (controller.Game.IsInTown && !ShowInTown)
            {
                return(false);
            }
            //return true;
            var visible = true;
            var player  = controller.Game.Me;
            var powers  = player.Powers;

            if (EquippedSkills != null)
            {
                visible = AllEquippedSkills
                    ? EquippedSkills.All(skill => powers.UsedSkills.Any(playerSkill => (skill.Icon.HasValue ? playerSkill.SnoPower.Sno == skill.Sno && playerSkill.Rune == skill.Icon.Value : playerSkill.SnoPower.Sno == skill.Sno) && (!playerSkill.IsOnCooldown || !CheckSkillCooldowns)))
                    : EquippedSkills.Any(skill => powers.UsedSkills.Any(playerSkill => (skill.Icon.HasValue ? playerSkill.SnoPower.Sno == skill.Sno && playerSkill.Rune == skill.Icon.Value : playerSkill.SnoPower.Sno == skill.Sno) && (!playerSkill.IsOnCooldown || !CheckSkillCooldowns)));
            }

            if (visible && MissingSkills != null)
            {
                visible = MissingSkills.Any(skill => powers.UsedSkills.All(playerSkill => playerSkill.SnoPower.Sno != skill.Sno));
            }

            if (visible && EquippedPassives != null)
            {
                visible = EquippedPassives.All(passive => powers.UsedPassives.Any(playerPassive => playerPassive.Sno == passive));
            }

            if (visible && MissingPassives != null)
            {
                visible = MissingPassives.Any(passive => powers.UsedPassives.All(playerPassive => playerPassive.Sno != passive));
            }

            if (visible && ActiveBuffs != null)
            {
                visible = AllActiveBuffs
                    ? ActiveBuffs.All(buff => buff.Icon.HasValue ? powers.BuffIsActive(buff.Sno, buff.Icon.Value) : powers.BuffIsActive(buff.Sno))
                    : ActiveBuffs.Any(buff => buff.Icon.HasValue ? powers.BuffIsActive(buff.Sno, buff.Icon.Value) : powers.BuffIsActive(buff.Sno));
            }
            if (visible && InactiveBuffs != null)
            {
                visible = AllInactiveBuffs
                    ? InactiveBuffs.All(buff => buff.Icon.HasValue ? !powers.BuffIsActive(buff.Sno, buff.Icon.Value) : !powers.BuffIsActive(buff.Sno))
                    : InactiveBuffs.Any(buff => buff.Icon.HasValue ? !powers.BuffIsActive(buff.Sno, buff.Icon.Value) : !powers.BuffIsActive(buff.Sno));
            }

            if (visible && ActorSnoIds != null)
            {
                visible = Hud.Game.Actors.Any(a => ActorSnoIds.Contains(a.SnoActor.Sno));
            }

            if (visible && InvocationActorSnoIds != null)
            {
                visible = !Hud.Game.Actors.Any(a => a.SummonerAcdDynamicId == Hud.Game.Me.SummonerId && InvocationActorSnoIds.Contains(a.SnoActor.Sno));
            }

            if (visible && CustomCondition != null)
            {
                visible = CustomCondition.Invoke(Hud);
            }

            return(visible);
        }