//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.GameLogic.PlayerActions.Skills;
///
/// Action to hit targets with an area skill, which requires explicit hits .
///
public class AreaSkillHitAction
{
///
/// Attacks the target by the player with the specified skill.
///
/// The player who is performing the skill.
/// The target.
/// The skill.
public async ValueTask AttackTargetAsync(Player player, IAttackable target, SkillEntry skill)
{
if (skill.Skill?.SkillType != SkillType.AreaSkillExplicitHits
|| !target.IsAlive
|| target.IsAtSafezone()
|| (target is Player && !player.GameContext.Configuration.AreaSkillHitsPlayer))
{
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))
{
var hitInfo = await target.AttackByAsync(player, skill, false).ConfigureAwait(false);
await target.TryApplyElementalEffectsAsync(player, skill, hitInfo).ConfigureAwait(false);
}
}
}