/// <summary> /// Handling the Marry action of the interaction packet. /// </summary> /// <param name="client">The client.</param> /// <param name="interact">The interaction packet.</param> public static void Handle(Entities.GameClient client, InteractionPacket interact) { //uint marryUID = interact.TargetUID; //Entities.GameClient marrytarget; Maps.IMapObject obj; if (client.Map.MapObjects.TryGetValue(interact.TargetUID, out obj)) { Entities.GameClient spouse = obj as Entities.GameClient; if (client.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_SELF_SPOUSE)) client.Send(fmsg); return; } if (spouse.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_TARGET_SPOUSE)) client.Send(fmsg); return; } client.SpouseDatabaseUID = spouse.DatabaseUID; spouse.SpouseDatabaseUID = client.DatabaseUID; //client.CharDB.AddSpouse(client.DatabaseUID, client.SpouseDatabaseUID); //spouse.CharDB.AddSpouse(spouse.DatabaseUID, spouse.SpouseDatabaseUID); Database.CharacterDatabase.AddSpouse(client, spouse); using (var mate = new Packets.StringPacket(new StringPacker(spouse.Name))) { mate.Data = client.EntityUID; mate.Action = Enums.StringAction.Mate; client.Send(mate); } using (var mate = new Packets.StringPacket(new StringPacker(client.Name))) { mate.Data = spouse.EntityUID; mate.Action = Enums.StringAction.Mate; spouse.Send(mate); } using (var fireworks = new Packets.StringPacket(new StringPacker("firework-2love"))) { fireworks.Action = Enums.StringAction.MapEffect; fireworks.PositionX = client.X; fireworks.PositionY = client.Y; client.SendToScreen(fireworks, true); fireworks.PositionX = spouse.X; fireworks.PositionY = spouse.Y; spouse.SendToScreen(fireworks, true); } using (var msg =Packets.Message.MessageCore.CreateSystem("ALL", string.Format(Core.MessageConst.MARRIAGE_CONGRATZ, client.Name, spouse.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } }
/// <summary> /// Handling the Marry action of the interaction packet. /// </summary> /// <param name="client">The client.</param> /// <param name="interact">The interaction packet.</param> public static void Handle(Entities.GameClient client, InteractionPacket interact) { //uint marryUID = interact.TargetUID; //Entities.GameClient marrytarget; Maps.IMapObject obj; if (client.Map.MapObjects.TryGetValue(interact.TargetUID, out obj)) { Entities.GameClient spouse = obj as Entities.GameClient; if (client.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_SELF_SPOUSE)) client.Send(fmsg); return; } if (spouse.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_TARGET_SPOUSE)) client.Send(fmsg); return; } client.SpouseDatabaseUID = spouse.DatabaseUID; spouse.SpouseDatabaseUID = client.DatabaseUID; //client.CharDB.AddSpouse(client.DatabaseUID, client.SpouseDatabaseUID); //spouse.CharDB.AddSpouse(spouse.DatabaseUID, spouse.SpouseDatabaseUID); Database.CharacterDatabase.AddSpouse(client, spouse); using (var mate = new Packets.StringPacket(new StringPacker(spouse.Name))) { mate.Data = client.EntityUID; mate.Action = Enums.StringAction.Mate; client.Send(mate); } using (var mate = new Packets.StringPacket(new StringPacker(client.Name))) { mate.Data = spouse.EntityUID; mate.Action = Enums.StringAction.Mate; spouse.Send(mate); } using (var fireworks = new Packets.StringPacket(new StringPacker("firework-2love"))) { fireworks.Action = Enums.StringAction.MapEffect; fireworks.PositionX = client.X; fireworks.PositionY = client.Y; client.SendToScreen(fireworks, true); fireworks.PositionX = spouse.X; fireworks.PositionY = spouse.Y; spouse.SendToScreen(fireworks, true); } using (var msg = Packets.Message.MessageCore.CreateSystem("ALL", string.Format(Core.MessageConst.MARRIAGE_CONGRATZ, client.Name, spouse.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } }
public static void BeginTravel(Entities.GameClient client, ushort mapid, ushort x, ushort y, int secs = 40) { uint dynamicid; Core.Kernel.Maps.selectorCollection1[999].CreateDynamic(out dynamicid); client.TeleportDynamic(dynamicid, 70, 60); int travelTime = (secs * 1000); /*for (int i = 0; i < (travelTime / 1000); i++) * { * ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => * { * using (var msg = Packets.Message.MessageCore.CreateCenter( * string.Format("Hitting destination in {0}", ((travelTime / 1000) - i)))) * { * client.Send(msg); * } * }, 1000 * i); * }*/ int j = 0; for (int i = secs; i > 0; i--) { int waitTime = (j * 1000); string message = string.Format(Core.MessageConst.TRAVEL_TIME, i); ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { using (var msg = Packets.Message.MessageCore.CreateCenter( message)) { client.Send(msg); } }, waitTime); j++; } ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { using (var msg = Packets.Message.MessageCore.CreateCenter( Core.MessageConst.TRAVEL_REACH)) { client.Send(msg); } }, travelTime); ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { client.Teleport(mapid, x, y); using (var str = new Packets.StringPacket(new Packets.StringPacker("autorun_end"))) { str.Action = Enums.StringAction.RoleEffect; str.Data = client.EntityUID; client.Send(str); } }, travelTime); }
public static void BeginTravel(Entities.GameClient client, ushort mapid, ushort x, ushort y, int secs = 40) { uint dynamicid; Core.Kernel.Maps.selectorCollection1[999].CreateDynamic(out dynamicid); client.TeleportDynamic(dynamicid, 70, 60); int travelTime = (secs * 1000); /*for (int i = 0; i < (travelTime / 1000); i++) { ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { using (var msg = Packets.Message.MessageCore.CreateCenter( string.Format("Hitting destination in {0}", ((travelTime / 1000) - i)))) { client.Send(msg); } }, 1000 * i); }*/ int j = 0; for (int i = secs; i > 0; i--) { int waitTime = (j * 1000); string message = string.Format(Core.MessageConst.TRAVEL_TIME, i); ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { using (var msg = Packets.Message.MessageCore.CreateCenter( message)) { client.Send(msg); } }, waitTime); j++; } ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { using (var msg = Packets.Message.MessageCore.CreateCenter( Core.MessageConst.TRAVEL_REACH)) { client.Send(msg); } }, travelTime); ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { client.Teleport(mapid, x, y); using (var str = new Packets.StringPacket(new Packets.StringPacker("autorun_end"))) { str.Action = Enums.StringAction.RoleEffect; str.Data = client.EntityUID; client.Send(str); } }, travelTime); }
public static void Handle(Entities.GameClient client, GuildPacket guild) { uint guilduid = guild.Data; if (guilduid > 0) { Data.Guild realguild; if (Core.Kernel.Guilds.TrySelect(guilduid, out realguild)) { using (var stringpacket = new Packets.StringPacket(new StringPacker(realguild.StringInfo))) { stringpacket.Action = Enums.StringAction.Guild; stringpacket.Data = guilduid; client.Send(stringpacket); } } } }
public static void ShowThunder(Maps.Map map) { if (map.ShowThunder) { foreach (Maps.IMapObject obj in map.MapObjects.Values) { if (obj is Entities.GameClient) { using (var thunder = new Packets.StringPacket(new Packets.StringPacker("lounder1"))) { thunder.Action = Enums.StringAction.MapEffect; thunder.PositionX = (ushort)(obj.X - 20); thunder.PositionY = obj.Y; (obj as Entities.GameClient).Send(thunder); } } } } }
/// <summary> /// Handling the QueryEquipment & QueryFriendEquip action from GeneralDataPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="General">The GeneralDataPacket.</param> public static void Handle(Entities.GameClient client, GeneralDataPacket General) { Entities.GameClient target; if (Core.Kernel.Clients.TrySelect(General.Data1, out target)) { client.Send(target.CreateSpawnPacket()); foreach (Data.ItemInfo equip in target.Equipments.Equips.Values) { equip.SendViewPacket(target.EntityUID, client); } using (var msg = Packets.Message.MessageCore.CreateSystem( target.Name, string.Format(Core.MessageConst.VIEW_EQUIP, client.Name))) target.Send(msg); using (var stringpacket = new Packets.StringPacket(new StringPacker(target.SpouseName))) { stringpacket.Action = Enums.StringAction.QueryMate; client.Send(stringpacket); } } }
public static void Divorce(Entities.GameClient client) { int spouse = client.SpouseDatabaseUID; if (spouse > 0) { using (var msg = Packets.Message.MessageCore.CreateSystem("ALL", string.Format(Core.MessageConst.DIVORCE, client.Name, client.SpouseName))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } uint euid = Database.CharacterDatabase.GetSpouseEntityUID(client); if (euid > 0) { Entities.GameClient sclient; if (Core.Kernel.Clients.TrySelect(euid, out sclient)) { if (sclient.DatabaseUID == spouse) { Database.CharacterDatabase.RemoveSpouse(sclient); using (var mate = new Packets.StringPacket(new StringPacker("None"))) { mate.Data = sclient.EntityUID; mate.Action = Enums.StringAction.Mate; sclient.Send(mate); } } } } using (var mate = new Packets.StringPacket(new StringPacker("None"))) { mate.Data = client.EntityUID; mate.Action = Enums.StringAction.Mate; client.Send(mate); } Database.CharacterDatabase.RemoveSpouse(client); } }
public void HandleImmunity() { if (!IsSpawned) { return; } if (!Alive) { return; } if (!CanBeAttacked) { using (var str = new Packets.StringPacket(new Packets.StringPacker("bossimmunity"))) { str.Action = Enums.StringAction.RoleEffect; str.Data = EntityUID; Screen.UpdateScreen(str); } } }
public static void Divorce(Entities.GameClient client) { int spouse = client.SpouseDatabaseUID; if (spouse > 0) { using (var msg =Packets.Message.MessageCore.CreateSystem("ALL", string.Format(Core.MessageConst.DIVORCE, client.Name, client.SpouseName))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } uint euid = Database.CharacterDatabase.GetSpouseEntityUID(client); if (euid > 0) { Entities.GameClient sclient; if (Core.Kernel.Clients.TrySelect(euid, out sclient)) { if (sclient.DatabaseUID == spouse) { Database.CharacterDatabase.RemoveSpouse(sclient); using (var mate = new Packets.StringPacket(new StringPacker("None"))) { mate.Data = sclient.EntityUID; mate.Action = Enums.StringAction.Mate; sclient.Send(mate); } } } } using (var mate = new Packets.StringPacket(new StringPacker("None"))) { mate.Data = client.EntityUID; mate.Action = Enums.StringAction.Mate; client.Send(mate); } Database.CharacterDatabase.RemoveSpouse(client); } }
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 SendGuildAssociations() { if (Guild != null) { Data.Guild[] allies = Guild.GetAllies(); foreach (Data.Guild allie in allies) { using (var alliepack = new Packets.StringPacket(new Packets.StringPacker(allie.StringInfo))) { alliepack.Action = Enums.StringAction.SetAlly; alliepack.Data = allie.GuildID; Send(alliepack); } } Data.Guild[] enemies = Guild.GetEnemies(); foreach (Data.Guild enemy in enemies) { using (var enemypack = new Packets.StringPacket(new Packets.StringPacker(enemy.StringInfo))) { enemypack.Action = Enums.StringAction.SetEnemy; enemypack.Data = enemy.GuildID; Send(enemypack); } } } }
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 ExecuteStart(ushort StartX, ushort StartY) { if (Range < 10) { return; } if (DestructionAreas != null) { DestructionAreas.Clear(); } else { DestructionAreas = new List <System.Drawing.Point>(); } if (SafeSpots != null) { SafeSpots.Clear(); } else { SafeSpots = new List <System.Drawing.Point>(); } if (DestructionEffectAreas != null) { DestructionEffectAreas.Clear(); } else { DestructionEffectAreas = new List <System.Drawing.Point>(); } for (int i = 0; i < (Range / 4); i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartX, (int)(StartX + Range)); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartY, (int)(StartY + Range)); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (SafeSpots.Contains(p)) { i--; } else { SafeSpots.Add(p); } } for (int i = 0; i < Range / 4; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartX - Range), (int)StartX); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartY - Range), (int)StartY); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (SafeSpots.Contains(p)) { i--; } else { SafeSpots.Add(p); } } for (int i = 0; i < Range / EffectRatio; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartX, (int)(StartX + Range)); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartY, (int)(StartY + Range)); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (DestructionEffectAreas.Contains(p)) { i--; } else { DestructionEffectAreas.Add(p); } } for (int i = 0; i < Range / EffectRatio; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartX - Range), (int)StartX); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartY - Range), (int)StartY); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (DestructionEffectAreas.Contains(p)) { i--; } else { DestructionEffectAreas.Add(p); } } for (ushort x = (ushort)(StartX - Range); x < (StartX + Range); x++) { for (ushort y = (ushort)(StartY - Range); y < (StartY + Range); y++) { System.Drawing.Point p = new System.Drawing.Point((int)x, (int)y); if (!SafeSpots.Contains(p)) { DestructionAreas.Add(p); } } } for (int i = 0; i < 5; i++) { ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { foreach (System.Drawing.Point p in SafeSpots) { using (var str = new Packets.StringPacket(new Packets.StringPacker(SafeAreaEffect))) { 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); } } } } } }, 1000 * i, 0); } ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(ExecuteDestruction, 5000, 0); }
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 }
public void ExecuteStart(ushort StartX, ushort StartY) { if (Range < 10) return; if (DestructionAreas != null) DestructionAreas.Clear(); else DestructionAreas = new List<System.Drawing.Point>(); if (SafeSpots != null) SafeSpots.Clear(); else SafeSpots = new List<System.Drawing.Point>(); if (DestructionEffectAreas != null) DestructionEffectAreas.Clear(); else DestructionEffectAreas = new List<System.Drawing.Point>(); for (int i = 0; i < (Range / 4); i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartX, (int)(StartX + Range)); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartY, (int)(StartY + Range)); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (SafeSpots.Contains(p)) i--; else SafeSpots.Add(p); } for (int i = 0; i < Range / 4; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartX - Range), (int)StartX); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartY - Range), (int)StartY); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (SafeSpots.Contains(p)) i--; else SafeSpots.Add(p); } for (int i = 0; i < Range / EffectRatio; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartX, (int)(StartX + Range)); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)StartY, (int)(StartY + Range)); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (DestructionEffectAreas.Contains(p)) i--; else DestructionEffectAreas.Add(p); } for (int i = 0; i < Range / EffectRatio; i++) { ushort X = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartX - Range), (int)StartX); ushort Y = (ushort)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)(StartY - Range), (int)StartY); System.Drawing.Point p = new System.Drawing.Point((int)X, (int)Y); if (DestructionEffectAreas.Contains(p)) i--; else DestructionEffectAreas.Add(p); } for (ushort x = (ushort)(StartX - Range); x < (StartX + Range); x++) { for (ushort y = (ushort)(StartY - Range); y < (StartY + Range); y++) { System.Drawing.Point p = new System.Drawing.Point((int)x, (int)y); if (!SafeSpots.Contains(p)) DestructionAreas.Add(p); } } for (int i = 0; i < 5; i++) { ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() => { foreach (System.Drawing.Point p in SafeSpots) { using (var str = new Packets.StringPacket(new Packets.StringPacker(SafeAreaEffect))) { 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); } } } } } }, 1000 * i, 0); } ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(ExecuteDestruction, 5000, 0); }