public void Initialize() { if (MapInstance.MapInstanceType == MapInstanceType.BaseMapInstance && ServerManager.Instance.MapBossVNums.Contains(NpcVNum)) { MapCell randomCell = MapInstance.Map.GetRandomPosition(); if (randomCell != null) { if (MapInstance.Portals.Any(s => Map.GetDistance(new MapCell { X = s.SourceX, Y = s.SourceY }, new MapCell { X = randomCell.X, Y = randomCell.Y }) < 5)) { randomCell = MapInstance.Map.GetRandomPosition(); } MapX = randomCell.X; MapY = randomCell.Y; } } _random = new Random(MapNpcId); Npc = ServerManager.GetNpcMonster(NpcVNum); MaxHp = Npc.MaxHP; MaxMp = Npc.MaxMP; if (MapInstance?.MapInstanceType == MapInstanceType.TimeSpaceInstance) { if (IsProtected) { MaxHp *= 8; MaxMp *= 8; } } IsAlive = true; CurrentHp = MaxHp; CurrentMp = MaxMp; LastEffect = DateTime.Now; LastProtectedEffect = DateTime.Now; LastMove = DateTime.Now; LastSkill = DateTime.Now; IsHostile = Npc.IsHostile; ShouldRespawn = ShouldRespawn ?? true; FirstX = MapX; FirstY = MapY; EffectActivated = true; _movetime = ServerManager.RandomNumber(500, 3000); Path = new List <Node>(); Recipes = ServerManager.Instance.GetRecipesByMapNpcId(MapNpcId); Target = -1; Teleporters = ServerManager.Instance.GetTeleportersByNpcVNum(MapNpcId); Shop shop = ServerManager.Instance.GetShopByMapNpcId(MapNpcId); if (shop != null) { shop.Initialize(); Shop = shop; } Skills = new List <NpcMonsterSkill>(); foreach (NpcMonsterSkill ski in Npc.Skills) { Skills.Add(new NpcMonsterSkill { SkillVNum = ski.SkillVNum, Rate = ski.Rate }); } BattleEntity = new BattleEntity(this); if (AliveTime > 0) { Thread AliveTimeThread = new Thread(() => AliveTimeCheck()); AliveTimeThread.Start(); } if (NpcVNum == 1408) { OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(621, new MapCell { X = MapX, Y = MapY }, null, move: true))); } if (NpcVNum == 1409) { OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(622, new MapCell { X = MapX, Y = MapY }, null, move: true))); } if (NpcVNum == 1410) { OnDeathEvents.Add(new EventContainer(MapInstance, EventActionType.SPAWNMONSTER, new MonsterToSummon(623, new MapCell { X = MapX, Y = MapY }, null, move: true))); } if (OnSpawnEvents.Any()) { OnSpawnEvents.ToList().ForEach(e => { EventHelper.Instance.RunEvent(e, npc: this); }); OnSpawnEvents.Clear(); } }