private void ExecuteDestruction() { foreach (System.Drawing.Point p in DestructionEffectAreas) { using (var str = new Packets.StringPacket(new Packets.StringPacker(DestructionEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = (ushort)p.X; str.PositionY = (ushort)p.Y; foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { if (Core.Screen.GetDistance(MapObject.X, MapObject.Y, p.X, p.Y) <= 40) { (MapObject as Entities.GameClient).Send(str); } } } } } #region Shake, Dark, Zoom List<uint> UsedUIDs = new List<uint>(); if (Shake || Dark || Zoom) { using (var effect = new Packets.MapEffectPacket()) { effect.Shake = Shake; effect.Darkness = Dark; effect.Zoom = Zoom; effect.AppendFlags(); foreach (System.Drawing.Point p in DestructionAreas) { foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { if (Core.Screen.GetDistance(MapObject.X, MapObject.Y, p.X, p.Y) <= 40 && !UsedUIDs.Contains(MapObject.EntityUID)) { effect.X = MapObject.X; effect.Y = MapObject.Y; (MapObject as Entities.GameClient).Send(effect); UsedUIDs.Add(MapObject.EntityUID); } } } } } } #endregion foreach (System.Drawing.Point p in DestructionAreas) { foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { System.Drawing.Point p2 = new System.Drawing.Point((int)MapObject.X, (int)MapObject.Y); if (!SafeSpots.Contains(p2) && p == p2) { Entities.GameClient target = (MapObject as Entities.GameClient); int damage = DamageEffect; if (PercentTageEffect != -1 && target.HP > PercentTageEffect) { damage = ((target.HP / 100) * PercentTageEffect); } if (damage > 0) { target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(Killer, target, (uint)damage); } } } } } } }
public void Use(Entities.BossMonster boss, Entities.GameClient[] Targets) { if (Targets.Length == 0 && !SpreadSkill || MaxTargets == 0 && !SpreadSkill) return; if (DateTime.Now < CoolDownTime) return; CoolDownTime = DateTime.Now.AddSeconds(CoolDown); if (MapSkill != null) { MapSkill.ExecuteStart(boss.X, boss.Y); } AreaSkill area = new AreaSkill(); area.boss = boss; area.skill = this; #region Shake, Dark, Zoom if (Shake || Dark || Zoom) { using (var effect = new Packets.MapEffectPacket()) { effect.Shake = Shake; effect.Darkness = Dark; effect.Zoom = Zoom; effect.AppendFlags(); foreach (Entities.GameClient target in Targets) { effect.X = target.X; effect.Y = target.Y; target.Send(effect); } } } #endregion if (MaxTargets == 1) Array.Resize(ref Targets, 1); else if (MaxTargets > 0 && Targets.Length > MaxTargets) Array.Resize(ref Targets, MaxTargets); #region Explode // TODO: Explosion effect .. if (Explode) { if (PlayerExplode) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; foreach (Entities.GameClient target in Targets) { str.PositionX = target.X; str.PositionY = target.Y; target.SendToScreen(str, true, false); } } } else if (BossExplode) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = boss.X; str.PositionY = boss.Y; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } else { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = ExplodePos[0]; str.PositionY = ExplodePos[1]; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } } #endregion #region Creatures if (SummonCreatures) { int SpawnSize = (FixCreatureSize ? Targets.Length : (Targets.Length * 2)); if (MaxCreatures != -1) { if (SpawnSize > MaxCreatures) { SpawnSize = MaxCreatures; } } int count = 0; for (int i = 0; i < SpawnSize; i++) { Entities.BossCreature creature = (Entities.BossCreature)Creature.Copy(); if (!FixTargets) { Maps.MapPoint Location = boss.Map.CreateAvailableLocation<Entities.BossCreature>(boss.X, boss.Y, 9); creature.SetData(boss, null); creature.Teleport(Location); } else { try { Entities.GameClient Target = Targets[count]; if (!Target.Alive) continue; creature.SetData(boss, Target); Maps.MapPoint Location = boss.Map.CreateAvailableLocation<Entities.BossCreature>(Target.X, Target.Y, 9); creature.Teleport(Location); Entities.BossCreature creature2 = (Entities.BossCreature)Creature.Copy(); creature2.SetData(boss, Target); Location = boss.Map.CreateAvailableLocation<Entities.BossCreature>(Target.X, Target.Y, 9); creature2.Teleport(Location); i++; count++; } catch { } } } } #endregion #region MapEffect if (!string.IsNullOrWhiteSpace(MapEffect)) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = boss.X; str.PositionY = boss.Y; foreach (Entities.GameClient target in Targets) { if (ShowEffectAtPlayers) { str.PositionX = target.X; str.PositionY = target.Y; } target.SendToScreen(str, true, false); } } } #endregion if (!SpreadSkill) { #region SkillAnimation + Power if (RealSkill != -1) { var usespell = new Packets.UseSpellPacket(); usespell.EntityUID = boss.EntityUID; usespell.SpellID = (ushort)RealSkill; usespell.SpellX = boss.X; usespell.SpellY = boss.Y; usespell.SpellLevel = RealSkilllevel; foreach (Entities.GameClient target in Targets) { if (!target.Alive) continue; if (PercentTageEffect != -1) { int damage = ((target.HP / 100) * PercentTageEffect); if (damage <= 0) damage = 1; usespell.AddTarget(target.EntityUID, (uint)damage); target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else if (DamageEffect > 0) { int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect); usespell.AddTarget(target.EntityUID, (uint)damage); target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else usespell.AddTarget(target.EntityUID, 0); } boss.Screen.UpdateScreen(usespell); } else { foreach (Entities.GameClient target in Targets) { if (!target.Alive) continue; using (var interact = new Packets.InteractionPacket()) { interact.Action = Enums.InteractAction.Attack; interact.EntityUID = boss.EntityUID; interact.TargetUID = target.EntityUID; interact.UnPacked = true; interact.X = target.X; interact.Y = target.Y; if (PercentTageEffect != -1) { int damage = (target.HP / PercentTageEffect); interact.Data = (uint)damage; target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else if (DamageEffect > 0) { int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect); interact.Data = (uint)damage; target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else interact.Data = 0; boss.Screen.UpdateScreen(interact); } } } #endregion #region Freeze if (Freeze) { foreach (Entities.GameClient target in Targets) { if (!target.Alive) continue; target.AddStatusEffect1(Enums.Effect1.IceBlock, FreezeTime); } } #endregion #region Paralyze if (Paralyzed) { foreach (Entities.GameClient target in Targets) { if (!target.Alive) continue; target.ParalyzeClient(ParalyzeTime); } } #endregion } #region SpreadEffect if (!string.IsNullOrWhiteSpace(SpreadEffect)) { for (int i = 0; i < EffectPos.Length; i++) { using (var str = new Packets.StringPacket(new Packets.StringPacker(SpreadEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = EffectPos[i][0]; str.PositionY = EffectPos[i][1]; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } } #endregion #region SpreadSkill if (SpreadSkill) { for (int i = 0; i < SkillPos.Length; i++) { Core.PortalPoint p = new Core.PortalPoint(boss.Map.MapID, SkillPos[i][0], SkillPos[i][1]); AreaSkills.TryAdd(p, area); uint TaskID = 0; TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { Core.PortalPoint p2 = new Core.PortalPoint(boss.Map.MapID, SkillPos[i][0], SkillPos[i][1]); AreaSkill rArea; AreaSkills.TryRemove(p2, out rArea); }, SkillShowTime, 0); } } #endregion }
public void Use(Entities.BossMonster boss, Entities.GameClient[] Targets) { if (Targets.Length == 0 && !SpreadSkill || MaxTargets == 0 && !SpreadSkill) { return; } if (DateTime.Now < CoolDownTime) { return; } CoolDownTime = DateTime.Now.AddSeconds(CoolDown); if (MapSkill != null) { MapSkill.ExecuteStart(boss.X, boss.Y); } AreaSkill area = new AreaSkill(); area.boss = boss; area.skill = this; #region Shake, Dark, Zoom if (Shake || Dark || Zoom) { using (var effect = new Packets.MapEffectPacket()) { effect.Shake = Shake; effect.Darkness = Dark; effect.Zoom = Zoom; effect.AppendFlags(); foreach (Entities.GameClient target in Targets) { effect.X = target.X; effect.Y = target.Y; target.Send(effect); } } } #endregion if (MaxTargets == 1) { Array.Resize(ref Targets, 1); } else if (MaxTargets > 0 && Targets.Length > MaxTargets) { Array.Resize(ref Targets, MaxTargets); } #region Explode // TODO: Explosion effect .. if (Explode) { if (PlayerExplode) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; foreach (Entities.GameClient target in Targets) { str.PositionX = target.X; str.PositionY = target.Y; target.SendToScreen(str, true, false); } } } else if (BossExplode) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = boss.X; str.PositionY = boss.Y; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } else { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = ExplodePos[0]; str.PositionY = ExplodePos[1]; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } } #endregion #region Creatures if (SummonCreatures) { int SpawnSize = (FixCreatureSize ? Targets.Length : (Targets.Length * 2)); if (MaxCreatures != -1) { if (SpawnSize > MaxCreatures) { SpawnSize = MaxCreatures; } } int count = 0; for (int i = 0; i < SpawnSize; i++) { Entities.BossCreature creature = (Entities.BossCreature)Creature.Copy(); if (!FixTargets) { Maps.MapPoint Location = boss.Map.CreateAvailableLocation <Entities.BossCreature>(boss.X, boss.Y, 9); creature.SetData(boss, null); creature.Teleport(Location); } else { try { Entities.GameClient Target = Targets[count]; if (!Target.Alive) { continue; } creature.SetData(boss, Target); Maps.MapPoint Location = boss.Map.CreateAvailableLocation <Entities.BossCreature>(Target.X, Target.Y, 9); creature.Teleport(Location); Entities.BossCreature creature2 = (Entities.BossCreature)Creature.Copy(); creature2.SetData(boss, Target); Location = boss.Map.CreateAvailableLocation <Entities.BossCreature>(Target.X, Target.Y, 9); creature2.Teleport(Location); i++; count++; } catch { } } } } #endregion #region MapEffect if (!string.IsNullOrWhiteSpace(MapEffect)) { using (var str = new Packets.StringPacket(new Packets.StringPacker(MapEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = boss.X; str.PositionY = boss.Y; foreach (Entities.GameClient target in Targets) { if (ShowEffectAtPlayers) { str.PositionX = target.X; str.PositionY = target.Y; } target.SendToScreen(str, true, false); } } } #endregion if (!SpreadSkill) { #region SkillAnimation + Power if (RealSkill != -1) { var usespell = new Packets.UseSpellPacket(); usespell.EntityUID = boss.EntityUID; usespell.SpellID = (ushort)RealSkill; usespell.SpellX = boss.X; usespell.SpellY = boss.Y; usespell.SpellLevel = RealSkilllevel; foreach (Entities.GameClient target in Targets) { if (!target.Alive) { continue; } if (PercentTageEffect != -1) { int damage = ((target.HP / 100) * PercentTageEffect); if (damage <= 0) { damage = 1; } usespell.AddTarget(target.EntityUID, (uint)damage); target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else if (DamageEffect > 0) { int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect); usespell.AddTarget(target.EntityUID, (uint)damage); target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else { usespell.AddTarget(target.EntityUID, 0); } } boss.Screen.UpdateScreen(usespell); } else { foreach (Entities.GameClient target in Targets) { if (!target.Alive) { continue; } using (var interact = new Packets.InteractionPacket()) { interact.Action = Enums.InteractAction.Attack; interact.EntityUID = boss.EntityUID; interact.TargetUID = target.EntityUID; interact.UnPacked = true; interact.X = target.X; interact.Y = target.Y; if (PercentTageEffect != -1) { int damage = (target.HP / PercentTageEffect); interact.Data = (uint)damage; target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else if (DamageEffect > 0) { int damage = ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(DamageEffect / 2, DamageEffect); interact.Data = (uint)damage; target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(boss, target, (uint)damage); } } else { interact.Data = 0; } boss.Screen.UpdateScreen(interact); } } } #endregion #region Freeze if (Freeze) { foreach (Entities.GameClient target in Targets) { if (!target.Alive) { continue; } target.AddStatusEffect1(Enums.Effect1.IceBlock, FreezeTime); } } #endregion #region Paralyze if (Paralyzed) { foreach (Entities.GameClient target in Targets) { if (!target.Alive) { continue; } target.ParalyzeClient(ParalyzeTime); } } #endregion } #region SpreadEffect if (!string.IsNullOrWhiteSpace(SpreadEffect)) { for (int i = 0; i < EffectPos.Length; i++) { using (var str = new Packets.StringPacket(new Packets.StringPacker(SpreadEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = EffectPos[i][0]; str.PositionY = EffectPos[i][1]; foreach (Entities.GameClient target in Targets) { target.Send(str); } } } } #endregion #region SpreadSkill if (SpreadSkill) { for (int i = 0; i < SkillPos.Length; i++) { Core.PortalPoint p = new Core.PortalPoint(boss.Map.MapID, SkillPos[i][0], SkillPos[i][1]); AreaSkills.TryAdd(p, area); uint TaskID = 0; TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { Core.PortalPoint p2 = new Core.PortalPoint(boss.Map.MapID, SkillPos[i][0], SkillPos[i][1]); AreaSkill rArea; AreaSkills.TryRemove(p2, out rArea); }, SkillShowTime, 0); } } #endregion }
private void ExecuteDestruction() { foreach (System.Drawing.Point p in DestructionEffectAreas) { using (var str = new Packets.StringPacket(new Packets.StringPacker(DestructionEffect))) { str.Action = Enums.StringAction.MapEffect; str.PositionX = (ushort)p.X; str.PositionY = (ushort)p.Y; foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { if (Core.Screen.GetDistance(MapObject.X, MapObject.Y, p.X, p.Y) <= 40) { (MapObject as Entities.GameClient).Send(str); } } } } } #region Shake, Dark, Zoom List <uint> UsedUIDs = new List <uint>(); if (Shake || Dark || Zoom) { using (var effect = new Packets.MapEffectPacket()) { effect.Shake = Shake; effect.Darkness = Dark; effect.Zoom = Zoom; effect.AppendFlags(); foreach (System.Drawing.Point p in DestructionAreas) { foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { if (Core.Screen.GetDistance(MapObject.X, MapObject.Y, p.X, p.Y) <= 40 && !UsedUIDs.Contains(MapObject.EntityUID)) { effect.X = MapObject.X; effect.Y = MapObject.Y; (MapObject as Entities.GameClient).Send(effect); UsedUIDs.Add(MapObject.EntityUID); } } } } } } #endregion foreach (System.Drawing.Point p in DestructionAreas) { foreach (Maps.IMapObject MapObject in map.MapObjects.Values) { if (MapObject is Entities.GameClient) { System.Drawing.Point p2 = new System.Drawing.Point((int)MapObject.X, (int)MapObject.Y); if (!SafeSpots.Contains(p2) && p == p2) { Entities.GameClient target = (MapObject as Entities.GameClient); int damage = DamageEffect; if (PercentTageEffect != -1 && target.HP > PercentTageEffect) { damage = ((target.HP / 100) * PercentTageEffect); } if (damage > 0) { target.HP -= damage; if (target.HP <= 0) { Packets.Interaction.Battle.Combat.Kill(Killer, target, (uint)damage); } } } } } } }