public static void Handle(Entities.IEntity attacker, InteractionPacket interact) { if (interact == null) { return; } Maps.IMapObject attackermap = attacker as Maps.IMapObject; if (!attackermap.Screen.ContainsEntity(interact.TargetUID)) { return; } Maps.IMapObject target = null; if (!attackermap.Screen.GetEntity(interact.TargetUID, out target)) { return; } if (target is Entities.NPC) { return; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return; } if ((target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) { return; } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return; } } Entities.IEntity targetentity = target as Entities.IEntity; if (targetentity is Entities.BossMonster) { if (!(targetentity as Entities.BossMonster).CanBeAttacked) { return; } } if (!Core.Screen.ValidDistance(attackermap.X, attackermap.Y, target.X, target.Y)) { return; } if (!attacker.Alive) { return; } if (!targetentity.Alive) { return; } if (attacker is Entities.GameClient) { if (!ProcessClient((attacker as Entities.GameClient), interact)) { return; } } uint damage = Calculations.Battle.GetPhysicalDamage(attacker, targetentity); Combat.ProcessDamage(attacker, targetentity, ref damage); if (damage > 0) { if (attacker is Entities.GameClient && !(target is Entities.GameClient)) { Entities.GameClient client = attacker as Entities.GameClient; uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (targetentity.Level > (attacker.Level + 10)) { exp *= 2; } else if (attacker.Level > (targetentity.Level + 10)) { exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(1, (int)targetentity.Level); } if (interact.WeaponTypeRight > 0) { client.AddProfExp(interact.WeaponTypeRight, exp); } if (interact.WeaponTypeLeft > 0) { client.AddProfExp(interact.WeaponTypeLeft, exp); } } } interact.Data = damage; attacker.Screen.UpdateScreen(interact); if (attacker is Entities.GameClient) { (attacker as Entities.GameClient).Send(interact); } }
public static void Handle(Entities.IEntity attacker, InteractionPacket interact) { if (interact == null) { return; } Maps.IMapObject attackermap = attacker as Maps.IMapObject; if (!attackermap.Screen.ContainsEntity(interact.TargetUID)) { return; } Maps.IMapObject target = null; if (!attackermap.Screen.GetEntity(interact.TargetUID, out target)) { return; } if (target is Entities.NPC) { return; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return; } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return; } } Entities.IEntity targetentity = target as Entities.IEntity; if (targetentity is Entities.BossMonster) { if (!(targetentity as Entities.BossMonster).CanBeAttacked) { return; } } if (!Combat.FixTarget(attacker, targetentity)) { return; } if (!Core.Screen.ValidDistance(attackermap.X, attackermap.Y, target.X, target.Y)) { return; } if (!attacker.Alive) { return; } if (!targetentity.Alive) { return; } if (attacker is Entities.GameClient) { if (!ProcessClient((attacker as Entities.GameClient), interact)) { return; } } uint damage = Calculations.Battle.GetRangedDamage(attacker, targetentity); Combat.ProcessDamage(attacker, targetentity, ref damage); interact.Data = damage; attacker.Screen.UpdateScreen(interact); if (attacker is Entities.GameClient) { Entities.GameClient attackerclient = attacker as Entities.GameClient; if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (targetentity.Level > (attacker.Level + 10)) { exp *= 2; } else if (attacker.Level > (targetentity.Level + 10)) { exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(1, (int)targetentity.Level); } if (interact.WeaponTypeRight > 0) { attackerclient.AddProfExp(500, exp); // bow } } } Data.ItemInfo arrow = attackerclient.Equipments[Enums.ItemLocation.WeaponL]; arrow.CurrentDura--; Database.CharacterDatabase.SaveEquipment(attackerclient, arrow, Enums.ItemLocation.WeaponL); arrow.SendPacket(attackerclient, 3); attackerclient.Send(interact); //interact.Data = 0; interact.ActivationType = 0; interact.ActivationValue = 0; attackerclient.AttackPacket = interact; attackerclient.UseAutoAttack(interact); } }