Exemple #1
0
 private void ApplySkill(Player player, SkillEntry skillEntry, Skill skill, IAttackable target)
 {
     if (target.CheckSkillTargetRestrictions(player, skill))
     {
         target.AttackBy(player, skillEntry);
         target.ApplyElementalEffects(player, skillEntry);
     }
 }
Exemple #2
0
 private void ApplySkill(Player player, SkillEntry skillEntry, IAttackable target, Point targetAreaCenter)
 {
     if (target.CheckSkillTargetRestrictions(player, skillEntry.Skill))
     {
         target.AttackBy(player, skillEntry);
         target.ApplyElementalEffects(player, skillEntry);
         player.GameContext.PlugInManager.GetStrategy <short, IAreaSkillPlugIn>(skillEntry.Skill.Number)?.AfterTargetGotAttacked(player, target, skillEntry, targetAreaCenter);
     }
 }
Exemple #3
0
        /// <summary>
        /// Performs the skill.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="target">The target.</param>
        /// <param name="skillId">The skill identifier.</param>
        public void PerformSkill(Player player, IAttackable target, ushort skillId)
        {
            using var loggerScope = player.Logger.BeginScope(this.GetType());
            var skillEntry = player.SkillList?.GetSkill(skillId);
            var skill      = skillEntry?.Skill;

            if (skill is null || skill.SkillType == SkillType.PassiveBoost)
            {
                return;
            }

            if (target is null)
            {
                return;
            }

            if (!target.IsActive())
            {
                return;
            }

            if (!target.CheckSkillTargetRestrictions(player, skill))
            {
                return;
            }

            if (!player.IsInRange(target.Position, skill.Range + 2))
            {
                // target position might be out of sync so we send the current coordinates to the client again.
                if (!(target is ISupportWalk walker && walker.IsWalking))
                {
                    player.ViewPlugIns.GetPlugIn <IObjectMovedPlugIn>()?.ObjectMoved(target, MoveType.Instant);
                }

                return;
            }

            // enough mana, ag etc?
            if (!player.TryConsumeForSkill(skill))
            {
                return;
            }

            player.ForEachWorldObserver(obs => obs.ViewPlugIns.GetPlugIn <IShowSkillAnimationPlugIn>()?.ShowSkillAnimation(player, target, skill), true);
            if (skill.MovesToTarget)
            {
                player.Move(target.Position);
            }

            if (skill.MovesTarget)
            {
                target.MoveRandomly();
            }

            this.ApplySkill(player, target, skillEntry !);
        }
        /// <summary>
        /// Performs the skill.
        /// </summary>
        /// <param name="player">The player.</param>
        /// <param name="target">The target.</param>
        /// <param name="skillId">The skill identifier.</param>
        public void PerformSkill(Player player, IAttackable target, ushort skillId)
        {
            SkillEntry skillEntry = player.SkillList.GetSkill(skillId);
            var        skill      = skillEntry.Skill;

            if (skill.SkillType == SkillType.PassiveBoost)
            {
                return;
            }

            if (target == null)
            {
                return;
            }

            if (!target.Alive)
            {
                return;
            }

            if (!target.CheckSkillTargetRestrictions(player, skill))
            {
                return;
            }

            if (!player.IsInRange(target.Position, skill.Range + 2))
            {
                // target position might be out of sync so we send the current coordinates to the client again.
                if (!(target is ISupportWalk walker && walker.IsWalking))
                {
                    player.WorldView.ObjectMoved(target, MoveType.Instant);
                }

                return;
            }

            // enough mana, ag etc?
            if (!player.TryConsumeForSkill(skill))
            {
                return;
            }

            player.ForEachWorldObserver(obs => obs.WorldView.ShowSkillAnimation(player, target, skill), true);
            if (skill.MovesToTarget)
            {
                player.Move(target.Position);
            }

            if (skill.MovesTarget)
            {
                target.MoveRandomly();
            }

            this.ApplySkill(player, target, skillEntry);
        }
        /// <summary>
        /// Attacks the target by the player with the specified skill.
        /// </summary>
        /// <param name="player">The player who is performing the skill.</param>
        /// <param name="target">The target.</param>
        /// <param name="skill">The skill.</param>
        public void AttackTarget(Player player, IAttackable target, SkillEntry skill)
        {
            if (skill.Skill.SkillType != SkillType.AreaSkillExplicitHits ||
                target is null ||
                !target.IsAlive)
            {
                return;
            }

            if (target.CheckSkillTargetRestrictions(player, skill.Skill))
            {
                target.AttackBy(player, skill);
                target.ApplyElementalEffects(player, skill);
            }
        }
Exemple #6
0
    /// <summary>
    /// Attacks the target by the player with the specified skill.
    /// </summary>
    /// <param name="player">The player who is performing the skill.</param>
    /// <param name="target">The target.</param>
    /// <param name="skill">The skill.</param>
    public async ValueTask AttackTargetAsync(Player player, IAttackable target, SkillEntry skill)
    {
        if (skill.Skill?.SkillType != SkillType.AreaSkillExplicitHits ||
            target is null ||
            !target.IsAlive ||
            target.IsAtSafezone())
        {
            return;
        }

        if (player.IsAtSafezone())
        {
            // It's possible, when the player did some area skill (Evil Spirit), and walked into the safezone.
            // We don't log it as hacker attempt, since the AreaSkillAttackAction already does handle this.
        }

        if (target.CheckSkillTargetRestrictions(player, skill.Skill))
        {
            await target.AttackByAsync(player, skill).ConfigureAwait(false);

            await target.TryApplyElementalEffectsAsync(player, skill).ConfigureAwait(false);
        }
    }