private void SpawnSheep(int round) { if (_map != null) { if (Spawn == true) { MapCell cell = _map.Map.GetRandomPosition(); int SheepId = _map.GetNextId(); MapMonster sheep = new MapMonster { MonsterVNum = 9, MapX = cell.X, MapY = cell.Y, MapMonsterId = SheepId, IsHostile = false, IsMoving = true, ShouldRespawn = false }; sheep.Initialize(_map); //sheep.NoAggresiveIcon = true; _map.AddMonster(sheep); _map.Broadcast(sheep.GenerateIn()); } } }
private void spawnCircle(int round) { if (_map != null) { MapCell cell = _map.Map.GetRandomPosition(); int circleId = _map.GetNextId(); MapMonster circle = new MapMonster { MonsterVNum = 2018, MapX = cell.X, MapY = cell.Y, MapMonsterId = circleId, IsHostile = false, IsMoving = false, ShouldRespawn = false }; circle.Initialize(_map); //circle = true; _map.AddMonster(circle); _map.Broadcast(circle.GenerateIn()); _map.Broadcast(StaticPacketHelper.GenerateEff(UserType.Monster, circleId, 4660)); Observable.Timer(TimeSpan.FromSeconds(3)).Subscribe(observer => { if (_map != null) { _map.Broadcast(StaticPacketHelper.SkillUsed(UserType.Monster, circleId, 3, circleId, 1220, 220, 0, 4983, cell.X, cell.Y, true, 0, 65535, 0, 0)); foreach (Character character in _map.GetCharactersInRange(cell.X, cell.Y, 2)) { if (!_map.Sessions.Skip(3).Any()) { // Your reward for the last three living players } character.IsCustomSpeed = false; character.RemoveVehicle(); character.GetDamage(655350, character.BattleEntity.Entity); Observable.Timer(TimeSpan.FromMilliseconds(1000)).Subscribe(o => ServerManager.Instance.AskRevive(character.CharacterId)); } _map.RemoveMonster(circle); _map.Broadcast(StaticPacketHelper.Out(UserType.Monster, circle.MapMonsterId)); } }); } }
public void TargetHit(IBattleEntity target, TargetHitType hitType, Skill skill, short?skillEffect = null, short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false, bool isPvp = false) { if (!target.IsTargetable(Entity.SessionType(), isPvp) || (target.Faction == Entity.Faction && ServerManager.Instance.Act4Maps.Any(m => m == Entity.MapInstance))) { if (Session is Character cha) { cha.Session.SendPacket($"cancel 2 {target.GetId()}"); } return; } MapInstance mapInstance = target.MapInstance; int hitmode = 0; bool onyxWings = false; ushort damage = GenerateDamage(target, skill, ref hitmode, ref onyxWings); if (Session is Character charact && onyxWings && mapInstance != null) { short onyxX = (short)(charact.PositionX + 2); short onyxY = (short)(charact.PositionY + 2); int onyxId = mapInstance.GetNextId(); var onyx = new MapMonster { MonsterVNum = 2371, MapX = onyxX, MapY = onyxY, MapMonsterId = onyxId, IsHostile = false, IsMoving = false, ShouldRespawn = false }; mapInstance.Broadcast($"guri 31 1 {charact.CharacterId} {onyxX} {onyxY}"); onyx.Initialize(mapInstance); mapInstance.AddMonster(onyx); mapInstance.Broadcast(onyx.GenerateIn()); target.GetDamage(damage / 2, Entity, false); Observable.Timer(TimeSpan.FromMilliseconds(350)).Subscribe(o => { mapInstance.Broadcast($"su 3 {onyxId} 3 {target.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {damage / 2} 0 0"); mapInstance.RemoveMonster(onyx); mapInstance.Broadcast(onyx.GenerateOut()); }); } if (target.GetSession() is Character character) { damage = (ushort)(character.HasGodMode ? 0 : damage); if (character.IsSitting) { character.IsSitting = false; character.MapInstance.Broadcast(character.GenerateRest()); } } else if (target.GetSession() is Mate mate) { if (mate.IsSitting) { mate.IsSitting = false; mate.Owner.MapInstance.Broadcast(mate.GenerateRest()); } } int castTime = 0; if (skill != null && skill.CastEffect != 0) { Entity.MapInstance.Broadcast(Entity.GenerateEff(skill.CastEffect), Entity.GetPos().X, Entity.GetPos().Y); castTime = skill.CastTime * 100; } Observable.Timer(TimeSpan.FromMilliseconds(castTime)).Subscribe(o => TargetHit2(target, hitType, skill, damage, hitmode, skillEffect, mapX, mapY, skillCombo, showTargetAnimation, isPvp)); }
public void TargetHit(IBattleEntity target, TargetHitType hitType, Skill skill, short?skillEffect = null, short?mapX = null, short?mapY = null, ComboDTO skillCombo = null, bool showTargetAnimation = false, bool isPvp = false) { if (target == null || Entity == null) { return; } if (!target.IsTargetable(Entity.SessionType(), isPvp) || target.Faction == Entity.Faction && ServerManager.Instance.Act4Maps.Any(m => m == Entity.MapInstance)) { if (Session is Character cha) { cha.Session.SendPacket($"cancel 2 {target.GetId()}"); } return; } MapInstance mapInstance = target.MapInstance; int hitmode = 0; bool onyxWings = false; int damage = DamageHelper.Instance.GenerateDamage(this, target, skill, ref hitmode, ref onyxWings); if (skill != null && SkillHelper.Instance.NoDamageSkills != null) { if (SkillHelper.Instance.NoDamageSkills.Any(s => s == skill.SkillVNum)) { target.DealtDamage = 0; damage = 0; } } if (Session is Character charact && mapInstance != null && hitmode != 1) { target.RemoveBuff(548); if (onyxWings) { short onyxX = (short)(charact.PositionX + 2); short onyxY = (short)(charact.PositionY + 2); int onyxId = mapInstance.GetNextId(); var onyx = new MapMonster { MonsterVNum = 2371, MapX = onyxX, MapY = onyxY, MapMonsterId = onyxId, IsHostile = false, IsMoving = false, ShouldRespawn = false }; mapInstance.Broadcast($"guri 31 1 {charact.CharacterId} {onyxX} {onyxY}"); onyx.Initialize(mapInstance); mapInstance.AddMonster(onyx); mapInstance.Broadcast(onyx.GenerateIn()); target.GetDamage(target.DealtDamage / 2, Entity, false); Observable.Timer(TimeSpan.FromMilliseconds(350)).Subscribe(o => { mapInstance.Broadcast( $"su 3 {onyxId} {(target is Character ? "1" : "3")} {target.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(target.CurrentHp / (double)target.MaxHp * 100)} {(target.BattleEntity.IsReflecting ? 0 : target.DealtDamage) / 2} 0 0"); mapInstance.RemoveMonster(onyx); mapInstance.Broadcast(onyx.GenerateOut()); }); } if (target is Character tchar) { if (tchar.ReflectiveBuffs.Any()) { int?multiplier = 0; foreach (KeyValuePair <short, int?> entry in tchar.ReflectiveBuffs) { multiplier += entry.Value; } ushort damaged = (ushort)(damage > tchar.Level * multiplier ? tchar.Level * multiplier : damage); mapInstance.Broadcast( $"su 1 {tchar.GetId()} 1 {charact.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(tchar.Hp / (double)target.MaxHp * 100)} {damaged} 0 1"); charact.Hp = charact.Hp - damaged <= 0 ? 1 : charact.Hp - damaged; charact.Session.SendPacket(charact.GenerateStat()); target.DealtDamage = 0; } } else if (target is MapMonster tmon) { if (tmon.ReflectiveBuffs.Any()) { int?multiplier = 0; foreach (KeyValuePair <short, int?> entry in tmon.ReflectiveBuffs) { multiplier += entry.Value; } ushort damaged = (ushort)(damage > tmon.Monster.Level * multiplier ? tmon.Monster.Level * multiplier : damage); charact.Hp -= charact.Hp - damaged <= 0 ? 1 : charact.Hp - damaged; charact.Session.SendPacket(charact.GenerateStat()); mapInstance.Broadcast( $"su 3 {tmon.GetId()} 1 {charact.GetId()} -1 0 -1 {skill.Effect} -1 -1 1 {(int)(tmon.CurrentHp / (double)target.MaxHp * 100)} {damaged} 0 1"); target.DealtDamage = 0; } } } if (target.GetSession() is Character character) { damage = (ushort)(character.HasGodMode ? 0 : damage); target.DealtDamage = (ushort)(character.HasGodMode ? 0 : damage); if (character.IsSitting) { character.IsSitting = false; character.MapInstance.Broadcast(character.GenerateRest()); } } else if (target.GetSession() is Mate mate) { if (mate.IsSitting) { mate.IsSitting = false; mate.Owner.MapInstance.Broadcast(mate.GenerateRest()); } } int castTime = 0; if (skill != null && skill.CastEffect != 0) { Entity.MapInstance.Broadcast(Entity.GenerateEff(skill.CastEffect), Entity.GetPos().X, Entity.GetPos().Y); castTime = skill.CastTime * 100; } Observable.Timer(TimeSpan.FromMilliseconds(castTime)).Subscribe(o => TargetHit2(target, hitType, skill, damage, hitmode, skillEffect, mapX, mapY, skillCombo, showTargetAnimation, isPvp)); }
public void GenerateRaid(byte type, byte faction) { Act4Guardians = new List <MapMonster>(); ScriptedInstance raid = ServerManager.Instance.Act4Raids.FirstOrDefault(r => r.Id == type); MapInstance lobby = ServerManager.Instance.Act4Maps.FirstOrDefault(m => m.Map.MapId == 134); if (raid == null || lobby == null) { Logger.Log.Error(raid == null ? $"Act4 raids is missing - type : {type}" : "There is no map in Act4Maps with MapId == 134"); return; } ServerManager.Instance.Act4RaidStart = DateTime.Now; lobby.CreatePortal(new Portal { SourceMapId = 134, SourceX = 139, SourceY = 100, Type = (short)(9 + faction) }, 3600, true); #region Guardian Spawning Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 147, MapY = 88, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 149, MapY = 94, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 147, MapY = 101, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 139, MapY = 105, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 132, MapY = 101, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 129, MapY = 94, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); Act4Guardians.Add(new MapMonster { MonsterVNum = (short)(678 + faction), MapX = 132, MapY = 88, MapId = 134, Position = 2, IsMoving = false, MapMonsterId = lobby.GetNextId(), ShouldRespawn = false, IsHostile = true }); foreach (MapMonster monster in Act4Guardians) { if (monster == null) { continue; } monster.Initialize(); lobby.AddMonster(monster); lobby.Broadcast(monster.GenerateIn()); } Observable.Timer(TimeSpan.FromMinutes(60)).Subscribe(s => { foreach (MapMonster monster in Act4Guardians) { lobby.RemoveMonster(monster); lobby.Broadcast(monster.GenerateOut()); } Act4Guardians.Clear(); }); #endregion foreach (MapInstance map in ServerManager.Instance.Act4Maps) { map.Sessions.Where(s => s?.Character?.Faction == (FactionType)faction).ToList().ForEach(s => s.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("ACT4_RAID_OPEN"), ((Act4RaidType)type).ToString()), 0))); } lock (ServerManager.Instance.FamilyList) { foreach (Family family in ServerManager.Instance.FamilyList.GetAllItems()) { if (family == null) { continue; } family.Act4Raid = ServerManager.Instance.Act4Raids.FirstOrDefault(r => r.Id == type)?.GetClone(); family.Act4Raid?.LoadScript(MapInstanceType.RaidInstance); if (family.Act4Raid?.FirstMap == null) { continue; } family.Act4Raid.FirstMap.InstanceBag.Lock = true; } } Observable.Timer(TimeSpan.FromSeconds(3600)).Subscribe(s => { foreach (Family family in ServerManager.Instance.FamilyList.GetAllItems()) { if (family == null) { continue; } family.Act4Raid?.MapInstanceDictionary?.Values.ToList().ForEach(m => m?.Dispose()); family.Act4Raid = null; } }); }