public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (!attacker.Alive) { return(false); } if (target == null) { return(false); } if (target.Alive) { return(false); } if (attacker.EntityUID == target.EntityUID) { return(false); } if (!(target is Entities.GameClient)) { return(false); } Entities.GameClient TargetClient = (target as Entities.GameClient); TargetClient.ForceRevive(); usespell.AddTarget(TargetClient.EntityUID, 0); return(true); }
public static bool HandleSelf(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (target != null) { if (target is Entities.NPC) return false; if (target.EntityUID != attacker.EntityUID) return false; } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return false; } client.LastSmallLongSkill = DateTime.Now; } if (spell.ID == 1190 || spell.ID == 7016) attacker.HP += spell.Power; else attacker.MP += spell.Power; uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)spell.Power, (int)spell.Power * 2); if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); usespell.AddTarget(attacker.EntityUID, spell.Power); return true; }
public static bool Handle(Entities.GameClient client, UseSpellPacket usespell) { if (!client.Equipments.Contains(Enums.ItemLocation.Steed)) { return(false); } if (client.ContainsFlag1(Enums.Effect1.Riding)) { client.RemoveFlag1(Enums.Effect1.Riding); } else if (client.Stamina < 100) { return(false); } else { client.AddStatusEffect1(Enums.Effect1.Riding); } using (var vigor = new Packets.SteedVigorPacket()) { vigor.Type = 2; vigor.Amount = 9001; client.Send(vigor); } usespell.AddTarget(client.EntityUID, 0); return(true); }
/// <summary> /// Handles the single attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleMag(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) return false; if (target is Entities.NPC) return false; if (target is Entities.BossMonster) { if (!(target as Entities.BossMonster).CanBeAttacked) return false; } if (target is Entities.Monster) { if (((byte)(target as Entities.Monster).Behaviour) >= 3) return false; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) return false; if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) return false; if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return false; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return false; } if (!Combat.FixTarget(attacker, target)) return false; } damage = Calculations.Battle.GetMagicDamage(attacker, target, spell); Combat.ProcessDamage(attacker, target, ref damage, false); if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (target.Level > (attacker.Level + 10)) exp *= 2; if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(target.EntityUID, damage); } return true; }
public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (!attacker.Alive) return false; if (target == null) return false; if (!target.Alive) return false; if (!(target is Entities.GameClient)) return false; if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return false; } client.LastSmallLongSkill = DateTime.Now; } Entities.GameClient TargetClient = (target as Entities.GameClient); if (!TargetClient.LoggedIn) return false; switch (spell.SpellID) { case 1075: TargetClient.AddStatusEffect1(Enums.Effect1.PartiallyInvisible, spell.Duration * 1000); break; case 1085: TargetClient.AddStatusEffect1(Enums.Effect1.StarOfAccuracy, spell.Duration * 1000); break; case 1090: TargetClient.AddStatusEffect1(Enums.Effect1.Shield, spell.Duration * 1000); break; case 1095: TargetClient.AddStatusEffect1(Enums.Effect1.Stig, spell.Duration * 1000); break; default: return false; } byte level_target = (byte)(TargetClient.Level > 50 ? 50 : TargetClient.Level); uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)level_target, (int)level_target * 2); if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); usespell.AddTarget(TargetClient.EntityUID, damage); return true; }
/// <summary> /// Handles the archerbane attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleArcherBane(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) return false; if (!(target is Entities.GameClient)) return false; if (!(target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) return false; if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) return false; if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) return false; if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return false; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return false; } if (!Combat.FixTarget(attacker, target)) return false; } (target as Entities.GameClient).RemoveFlag1(Enums.Effect1.Fly); //damage = Calculations.Battle.GetPhysicalMagicDamage(attacker, target, spell); damage = (uint)(target.HP / 10); Combat.ProcessDamage(attacker, target, ref damage, false); if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (target.Level > (attacker.Level + 10)) exp *= 2; if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } } usespell.AddTarget(target.EntityUID, damage); return true; }
public static bool HandleSelf(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (target != null) { if (target is Entities.NPC) { return(false); } if (target.EntityUID != attacker.EntityUID) { return(false); } } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return(false); } client.LastSmallLongSkill = DateTime.Now; } if (spell.ID == 1190 || spell.ID == 7016) { attacker.HP += spell.Power; } else { attacker.MP += spell.Power; } uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)spell.Power, (int)spell.Power * 2); if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(attacker.EntityUID, spell.Power); return(true); }
public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (!attacker.Alive) return false; if (target == null) return false; if (target.Alive) return false; if (attacker.EntityUID == target.EntityUID) return false; if (!(target is Entities.GameClient)) return false; Entities.GameClient TargetClient = (target as Entities.GameClient); TargetClient.ForceRevive(); usespell.AddTarget(TargetClient.EntityUID, 0); return true; }
public static bool Handle(Entities.GameClient client, UseSpellPacket usespell) { if (!client.Equipments.Contains(Enums.ItemLocation.Steed)) return false; if (client.ContainsFlag1(Enums.Effect1.Riding)) client.RemoveFlag1(Enums.Effect1.Riding); else if (client.Stamina < 100) return false; else client.AddStatusEffect1(Enums.Effect1.Riding); using (var vigor = new Packets.SteedVigorPacket()) { vigor.Type = 2; vigor.Amount = 9001; client.Send(vigor); } usespell.AddTarget(client.EntityUID, 0); return true; }
/// <summary> /// Handles the poisonstar attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandlePoisonStar(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) { return(false); } if (!(target is Entities.GameClient)) { return(false); } if ((target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) { return(false); } if (Core.Screen.GetDistance(target.X, target.Y, attacker.X, attacker.Y) > spell.Distance) { return(false); } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return(false); } client.LastSmallLongSkill = DateTime.Now; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return(false); } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return(false); } if (!Combat.FixTarget(attacker, target)) { return(false); } } (target as Entities.GameClient).AddStatusEffect1(Enums.Effect1.NoPotion, (5000 * (spell.Level + 1))); uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)target.Level, (int)target.Level * 2); if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(target.EntityUID, 0); return(true); }
public static bool HandleSurrounding(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (target == null) return false; if (target is Entities.NPC) return false; if (target is Entities.Monster) { if (((byte)(target as Entities.Monster).Behaviour) >= 3) return false; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) return false; } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return false; } client.LastSmallLongSkill = DateTime.Now; } target.HP += spell.Power; uint targetcount = 1; if (spell.SpellID == 1055) { foreach (Maps.IMapObject obj in target.Screen.MapObjects.Values) { if (obj == null) continue; if (obj.EntityUID == attacker.EntityUID) continue; if (obj.EntityUID == target.EntityUID) continue; if (obj is Entities.NPC) continue; if (Core.Screen.GetDistance(obj.X, obj.Y, target.X, target.Y) > spell.Distance) continue; if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) continue; } if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) continue; } (obj as Entities.IEntity).HP += spell.Power; usespell.AddTarget(obj.EntityUID, spell.Power); targetcount++; } } uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)spell.Power, (int)spell.Power * 2); exp *= targetcount; if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); usespell.AddTarget(target.EntityUID, spell.Power); return true; }
/// <summary> /// Handles the single attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker is Entities.GameClient) { if (!Ranged.ProcessClient(attacker as Entities.GameClient, interaction, true)) { return(false); } } if (attacker.EntityUID == target.EntityUID) { return(false); } if (target is Entities.NPC) { return(false); } if (target is Entities.BossMonster) { if (!(target as Entities.BossMonster).CanBeAttacked) { return(false); } } if (target is Entities.Monster) { if (((byte)(target as Entities.Monster).Behaviour) >= 3) { return(false); } } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return(false); } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return(false); } if (!Combat.FixTarget(attacker, target)) { return(false); } } if (attacker is Entities.GameClient) { Ranged.DecreaseArrows(attacker as Entities.GameClient, 1); } damage = Calculations.Battle.GetRangedDamage(attacker, target); damage = (uint)(damage * 1.5); Combat.ProcessDamage(attacker, target, ref damage, false); if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (target.Level > (attacker.Level + 10)) { exp *= 2; } if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } } usespell.AddTarget(target.EntityUID, damage); } return(true); }
/// <summary> /// Handles the sector skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="targets">The targets. [not set yet]</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandlePhy(Entities.IEntity attacker, ConcurrentBag <Entities.IEntity> targets, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; bool self = (interaction.TargetUID == attacker.EntityUID); if (self) { return(false); } /*Calculations.InLineAlgorithm ila = new ProjectX_V3_Game.Calculations.InLineAlgorithm( * attacker.X, interaction.X, attacker.Y, interaction.Y, * (byte)spell.Range, Calculations.InLineAlgorithm.Algorithm.DDA);*/ Calculations.Sector sector = new ProjectX_V3_Game.Calculations.Sector(attacker.X, attacker.Y, interaction.X, interaction.Y); sector.Arrange(spell.Sector, spell.Range); byte count = 0; bool bluename = false; foreach (Maps.IMapObject obj in attacker.Screen.MapObjects.Values) { if (count > 28) { return(true); } if (!(obj as Entities.IEntity).Alive) { continue; } if (obj is Entities.NPC) { continue; } if (obj.EntityUID == attacker.EntityUID) { continue; } if (obj is Entities.BossMonster) { if (!(obj as Entities.BossMonster).CanBeAttacked) { continue; } } if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) { continue; } } if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) { continue; } if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) { continue; } if (obj.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { continue; } if (attacker is Entities.GameClient) { if ((attacker as Entities.GameClient).PKMode != Enums.PKMode.PK) { continue; } if (!Combat.FixTarget(attacker, obj as Entities.IEntity)) { continue; } } if (!(DateTime.Now >= (obj as Entities.GameClient).LoginProtection.AddSeconds(10))) { continue; } if (!(DateTime.Now >= (obj as Entities.GameClient).ReviveProtection.AddSeconds(5))) { continue; } if (!Combat.FixTarget(attacker, (obj as Entities.GameClient))) { continue; } if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.BlueName)) { bluename = true; } } //if (!ila.InLine(obj.X, obj.Y)) // continue; if (!sector.Inside(obj.X, obj.Y)) { continue; } Entities.IEntity targetentity = obj as Entities.IEntity; damage = Calculations.Battle.GetPhysicalDamage(attacker, targetentity); Combat.ProcessDamage(attacker, targetentity, ref damage, false); if (damage > 0) { if (!(targetentity 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; } if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } } usespell.AddTarget(targetentity.EntityUID, damage); targets.Add(targetentity); } count++; } if (attacker is Entities.GameClient && bluename) { (attacker as Entities.GameClient).AddStatusEffect1(Enums.Effect1.BlueName, 10000); } return(true); }
/// <summary> /// Handles the sector skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="targets">The targets. [not set yet]</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleMag(Entities.IEntity attacker, ConcurrentBag<Entities.IEntity> targets, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; bool self = (interaction.TargetUID == attacker.EntityUID); if (self) return false; if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastLongSkill.AddMilliseconds(Core.TimeIntervals.LongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return false; } client.LastLongSkill = DateTime.Now; } /*Calculations.InLineAlgorithm ila = new ProjectX_V3_Game.Calculations.InLineAlgorithm( attacker.X, interaction.X, attacker.Y, interaction.Y, (byte)spell.Range, Calculations.InLineAlgorithm.Algorithm.DDA);*/ Calculations.Sector sector = new ProjectX_V3_Game.Calculations.Sector(attacker.X, attacker.Y, interaction.X, interaction.Y); sector.Arrange(spell.Sector, spell.Range); byte count = 0; bool bluename = false; foreach (Maps.IMapObject obj in attacker.Screen.MapObjects.Values) { if (count > 28) return true; if(!(obj as Entities.IEntity).Alive) continue; if (obj is Entities.NPC) continue; if (obj.EntityUID == attacker.EntityUID) continue; if (obj is Entities.BossMonster) { if (!(obj as Entities.BossMonster).CanBeAttacked) continue; } if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) continue; } if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) continue; if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) continue; if (obj.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) continue; if (attacker is Entities.GameClient) { if ((attacker as Entities.GameClient).PKMode != Enums.PKMode.PK) continue; if (!Combat.FixTarget(attacker, obj as Entities.IEntity)) continue; } if (!(DateTime.Now >= (obj as Entities.GameClient).LoginProtection.AddSeconds(10))) { continue; } if (!(DateTime.Now >= (obj as Entities.GameClient).ReviveProtection.AddSeconds(5))) { continue; } if (!Combat.FixTarget(attacker, (obj as Entities.GameClient))) continue; if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.BlueName)) bluename = true; } //if (!ila.InLine(obj.X, obj.Y)) // continue; if (!sector.Inside(obj.X, obj.Y)) continue; Entities.IEntity targetentity = obj as Entities.IEntity; damage = Calculations.Battle.GetMagicDamage(attacker, targetentity, spell); Combat.ProcessDamage(attacker, targetentity, ref damage, false); if (damage > 0) { if (!(targetentity 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; if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(targetentity.EntityUID, damage); targets.Add(targetentity); } count++; } if (attacker is Entities.GameClient && bluename) (attacker as Entities.GameClient).AddStatusEffect1(Enums.Effect1.BlueName, 10000); return true; }
public static bool HandleSurrounding(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (target == null) { return(false); } if (target is Entities.NPC) { return(false); } if (target is Entities.Monster) { if (((byte)(target as Entities.Monster).Behaviour) >= 3) { return(false); } } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return(false); } } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return(false); } client.LastSmallLongSkill = DateTime.Now; } target.HP += spell.Power; uint targetcount = 1; if (spell.SpellID == 1055) { foreach (Maps.IMapObject obj in target.Screen.MapObjects.Values) { if (obj == null) { continue; } if (obj.EntityUID == attacker.EntityUID) { continue; } if (obj.EntityUID == target.EntityUID) { continue; } if (obj is Entities.NPC) { continue; } if (Core.Screen.GetDistance(obj.X, obj.Y, target.X, target.Y) > spell.Distance) { continue; } if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) { continue; } } if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) { continue; } } (obj as Entities.IEntity).HP += spell.Power; usespell.AddTarget(obj.EntityUID, spell.Power); targetcount++; } } uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)spell.Power, (int)spell.Power * 2); exp *= targetcount; if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(target.EntityUID, spell.Power); return(true); }
/// <summary> /// Handles the line skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="targets">The targets. [not set yet]</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool Handle(Entities.IEntity attacker, ConcurrentBag<Entities.IEntity> targets, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; bool self = (interaction.TargetUID == attacker.EntityUID); if (self) return false; Calculations.InLineAlgorithm ila = new ProjectX_V3_Game.Calculations.InLineAlgorithm( attacker.X, interaction.X, attacker.Y, interaction.Y, (byte)spell.Range, Calculations.InLineAlgorithm.Algorithm.DDA); byte count = 0; bool bluename = false; foreach (Maps.IMapObject obj in attacker.Screen.MapObjects.Values) { if (count > 28) return true; if(!(obj as Entities.IEntity).Alive) continue; if (obj is Entities.NPC) continue; if (obj.EntityUID == attacker.EntityUID) continue; if (obj is Entities.BossMonster) { if (!(obj as Entities.BossMonster).CanBeAttacked) continue; } if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) continue; } if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) continue; if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) continue; if (obj.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) continue; if (!(DateTime.Now >= (obj as Entities.GameClient).LoginProtection.AddSeconds(10))) { continue; } if (!(DateTime.Now >= (obj as Entities.GameClient).ReviveProtection.AddSeconds(5))) { continue; } if (!Combat.FixTarget(attacker, (obj as Entities.GameClient))) continue; if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.BlueName)) bluename = true; } if (!ila.InLine(obj.X, obj.Y)) continue; Entities.IEntity targetentity = obj as Entities.IEntity; damage = Calculations.Battle.GetPhysicalDamage(attacker, targetentity); Combat.ProcessDamage(attacker, targetentity, ref damage, false); if (damage > 0) { if (!(targetentity 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; if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(targetentity.EntityUID, damage); targets.Add(targetentity); } count++; } if (attacker is Entities.GameClient && bluename) (attacker as Entities.GameClient).AddStatusEffect1(Enums.Effect1.BlueName, 10000); return true; }
/// <summary> /// Handles the twofold attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleTwoFold(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) { return(false); } if (target is Entities.NPC) { return(false); } if (target is Entities.BossMonster) { if (!(target as Entities.BossMonster).CanBeAttacked) { return(false); } } if (target is Entities.Monster) { if (((byte)(target as Entities.Monster).Behaviour) >= 3) { return(false); } } if (Core.Screen.GetDistance(target.X, target.Y, attacker.X, attacker.Y) > spell.Distance) { return(false); } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return(false); } if ((target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) { return(false); } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return(false); } if (!Combat.FixTarget(attacker, target)) { return(false); } } damage = Calculations.Battle.GetPhysicalMagicDamage(attacker, target, spell); damage = (uint)((damage / 100) * (spell.Power - 30000)); Combat.ProcessDamage(attacker, target, ref damage, false); if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (target.Level > (attacker.Level + 10)) { exp *= 2; } if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } } usespell.AddTarget(target.EntityUID, damage); } return(true); }
/// <summary> /// Handles the circle skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="targets">The targets. [not set yet]</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleMag(Entities.IEntity attacker, ConcurrentBag<Entities.IEntity> targets, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker is Entities.GameClient) { if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360) { if (!Ranged.ProcessClient(attacker as Entities.GameClient, interaction, true, 3)) { return false; } } } /*Calculations.InLineAlgorithm ila = new ProjectX_V3_Game.Calculations.InLineAlgorithm( attacker.X, interaction.X, attacker.Y, interaction.Y, (byte)spell.Range, Calculations.InLineAlgorithm.Algorithm.DDA);*/ // Calculations.Sector sector = new ProjectX_V3_Game.Calculations.Sector(attacker.X, attacker.Y, interaction.X, interaction.Y); // sector.Arrange(spell.Sector, spell.Range); byte count = 0; bool bluename = false; foreach (Maps.IMapObject obj in attacker.Screen.MapObjects.Values) { if (count > 28) return true; if(!(obj as Entities.IEntity).Alive) continue; if (obj is Entities.NPC) continue; if (obj.EntityUID == attacker.EntityUID) continue; if (obj is Entities.BossMonster) { if (!(obj as Entities.BossMonster).CanBeAttacked) continue; } if (obj is Entities.Monster) { if (((byte)(obj as Entities.Monster).Behaviour) >= 3) continue; } if (!Core.Screen.ValidDistance(obj.X, obj.Y, attacker.X, attacker.Y)) continue; if (obj is Entities.GameClient) { if (!(obj as Entities.GameClient).LoggedIn) continue; if (obj.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) continue; if (attacker is Entities.GameClient) { if ((attacker as Entities.GameClient).PKMode != Enums.PKMode.PK) continue; if (!Combat.FixTarget(attacker, obj as Entities.IEntity)) continue; } if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) continue; if (!(DateTime.Now >= (obj as Entities.GameClient).LoginProtection.AddSeconds(10))) { continue; } if (!(DateTime.Now >= (obj as Entities.GameClient).ReviveProtection.AddSeconds(5))) { continue; } if (!Combat.FixTarget(attacker, (obj as Entities.GameClient))) continue; if ((obj as Entities.GameClient).ContainsFlag1(Enums.Effect1.BlueName)) bluename = true; } //if (!ila.InLine(obj.X, obj.Y)) // continue; //if (!sector.Inside(obj.X, obj.Y)) // continue; Entities.IEntity targetentity = obj as Entities.IEntity; if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360) damage = Calculations.Battle.GetRangedDamage(attacker, targetentity); else damage = Calculations.Battle.GetMagicDamage(attacker, targetentity, spell); Combat.ProcessDamage(attacker, targetentity, ref damage, false); if (damage > 0) { if (!(targetentity 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 ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(targetentity.EntityUID, damage); targets.Add(targetentity); } count++; } if (spell.SpellID == 8030 || spell.SpellID == 10308 || spell.SpellID == 7013 || spell.SpellID > 10360) { if (attacker is Entities.GameClient) { Ranged.DecreaseArrows(attacker as Entities.GameClient, 3); } } if (attacker is Entities.GameClient && bluename) (attacker as Entities.GameClient).AddStatusEffect1(Enums.Effect1.BlueName, 10000); return true; }
/// <summary> /// Handles the poisonstar attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandlePoisonStar(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) return false; if (!(target is Entities.GameClient)) return false; if ((target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) return false; if (Core.Screen.GetDistance(target.X, target.Y, attacker.X, attacker.Y) > spell.Distance) return false; if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return false; } client.LastSmallLongSkill = DateTime.Now; } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) return false; if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) return false; if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return false; } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return false; } if (!Combat.FixTarget(attacker, target)) return false; } (target as Entities.GameClient).AddStatusEffect1(Enums.Effect1.NoPotion, (5000 * (spell.Level + 1))); uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)target.Level, (int)target.Level * 2); if ((attacker is Entities.GameClient)) (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); usespell.AddTarget(target.EntityUID, 0); return true; }
/// <summary> /// Handles the archerbane attack skills. /// </summary> /// <param name="attacker">The attacker.</param> /// <param name="target">The target.</param> /// <param name="interaction">The interaction packet.</param> /// <param name="usespell">The usespell packet.</param> /// <param name="spell">The spell.</param> /// <param name="damage">The damage.</param> /// <returns>Returns true if the skill was used successfully.</returns> public static bool HandleArcherBane(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (attacker.EntityUID == target.EntityUID) { return(false); } if (!(target is Entities.GameClient)) { return(false); } if (!(target as Entities.GameClient).ContainsFlag1(Enums.Effect1.Fly)) { return(false); } if (target is Entities.GameClient) { if (!(target as Entities.GameClient).LoggedIn) { return(false); } if (target.Map.MapType == Enums.MapType.NoPK && (attacker is Entities.GameClient)) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).LoginProtection.AddSeconds(10))) { return(false); } if (!(DateTime.Now >= (target as Entities.GameClient).ReviveProtection.AddSeconds(5))) { return(false); } if (!Combat.FixTarget(attacker, target)) { return(false); } } (target as Entities.GameClient).RemoveFlag1(Enums.Effect1.Fly); //damage = Calculations.Battle.GetPhysicalMagicDamage(attacker, target, spell); damage = (uint)(target.HP / 10); Combat.ProcessDamage(attacker, target, ref damage, false); if (damage > 0) { if (!(target is Entities.GameClient)) { uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(damage / 2), (int)damage); if (target.Level > (attacker.Level + 10)) { exp *= 2; } if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } } } usespell.AddTarget(target.EntityUID, damage); return(true); }
public static bool Handle(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage) { damage = 0; if (!attacker.Alive) { return(false); } if (target == null) { return(false); } if (!target.Alive) { return(false); } if (!(target is Entities.GameClient)) { return(false); } if (attacker is Entities.GameClient) { Entities.GameClient client = (attacker as Entities.GameClient); if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null) { using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST)) client.Send(fmsg); return(false); } client.LastSmallLongSkill = DateTime.Now; } Entities.GameClient TargetClient = (target as Entities.GameClient); if (!TargetClient.LoggedIn) { return(false); } switch (spell.SpellID) { case 1075: TargetClient.AddStatusEffect1(Enums.Effect1.PartiallyInvisible, spell.Duration * 1000); break; case 1085: TargetClient.AddStatusEffect1(Enums.Effect1.StarOfAccuracy, spell.Duration * 1000); break; case 1090: TargetClient.AddStatusEffect1(Enums.Effect1.Shield, spell.Duration * 1000); break; case 1095: TargetClient.AddStatusEffect1(Enums.Effect1.Stig, spell.Duration * 1000); break; default: return(false); } byte level_target = (byte)(TargetClient.Level > 50 ? 50 : TargetClient.Level); uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)level_target, (int)level_target * 2); if ((attacker is Entities.GameClient)) { (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp); } usespell.AddTarget(TargetClient.EntityUID, damage); return(true); }