/// <summary> /// Handles the scatter skill. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="packet">The packet.</param> /// <param name="spellPacket">The spell packet.</param> /// <param name="spellInfo">The spell info.</param> /// <returns>True if the skill was handled correctly.</returns> public static bool Handle(AttackableEntityController attacker, Models.Packets.Entities.InteractionPacket packet, Models.Packets.Spells.SpellPacket spellPacket, Models.Spells.SpellInfo spellInfo) { spellPacket.Process = true; var attackerPlayer = attacker as Models.Entities.Player; if (attackerPlayer != null) { if (!Ranged.ProcessPlayer(attackerPlayer, packet, 3)) { return(false); } } var sector = new Tools.Sector(attacker.MapObject.X, attacker.MapObject.Y, packet.X, packet.Y); sector.Arrange(spellInfo.Sector, spellInfo.DbSpellInfo.Range); foreach (var possibleTarget in attacker.GetAllInScreen()) { if (spellPacket.Targets.Count > 8) { return(true); } var target = possibleTarget as AttackableEntityController; if (target != null) { if (!TargetValidation.Validate(attacker, target)) { continue; } if (target.ContainsStatusFlag(Enums.StatusFlag.Fly)) { continue; } if (!sector.Inside(target.MapObject.X, target.MapObject.Y)) { continue; } uint damage = Calculations.RangedCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity); Damage.Process(attacker, target, ref damage, false); if (damage > 0) { TargetFinalization.SkillFinalize(attacker, target, spellPacket, damage); } } } if (attackerPlayer != null && spellPacket.Targets.Count > 0) { Ranged.DecreaseArrows(attackerPlayer, 3); } return(true); }
/// <summary> /// Handles single skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="packet">The packet.</param> /// <param name="spellPacket">The spell packet.</param> /// <param name="spellInfo">The spell info.</param> /// <param name="isMagic">Boolean determining whether the single attack is magic.</param> /// <param name="isRanged">Boolean determining whether the single attack is ranged.</param> /// <returns>True if the skill was handled correctly.</returns> /// <remarks>If both isMagic and isRanged is set to false then it's assumed as a physical skill.</remarks> public static bool Handle(AttackableEntityController attacker, AttackableEntityController target, Models.Packets.Entities.InteractionPacket packet, Models.Packets.Spells.SpellPacket spellPacket, Models.Spells.SpellInfo spellInfo, bool isMagic, bool isRanged = false) { if (target == null) { return(false); } if (attacker.AttackableEntity.ClientId == target.AttackableEntity.ClientId) { return(false); } if (!TargetValidation.Validate(attacker, target)) { return(false); } var attackerPlayer = attacker as Models.Entities.Player; if (isRanged) { if (attackerPlayer != null) { if (!Ranged.ProcessPlayer(attackerPlayer, packet, 1)) { return(false); } } Ranged.DecreaseArrows(attackerPlayer, 1); } uint damage = isRanged ? Calculations.RangedCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity) : isMagic? Calculations.MagicCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity, spellInfo) : Calculations.PhysicalCalculations.GetDamage(attacker.AttackableEntity, target.AttackableEntity); if (!isMagic) { damage = (uint)Math.Max(1, (int)(((double)damage) * (1.1 + (0.1 * spellInfo.Level)))); if (spellInfo.Id == 1290 && damage > 0 && !isRanged) { double damagePercentage = (double)((damage / 100) * 26.6); damage += (uint)(damagePercentage * spellInfo.Level); } if (spellInfo.Id == 6000 && damage > 0 && !isRanged) { damage = (uint)((damage / 100) * (spellInfo.DbSpellInfo.Power - 30000)); } } Damage.Process(attacker, target, ref damage, true); if (damage > 0) { TargetFinalization.SkillFinalize(attacker, target, spellPacket, damage); return(true); } return(false); }