public void Parse(ConnectionDataEventArgs e) { //Console.WriteLine(e.Data.Dump()); _incomingBuffer.AppendData(e.Data.ToArray()); while (_incomingBuffer.IsPacketAvailable()) { int end = _incomingBuffer.Position; end += _incomingBuffer.ReadInt(32) * 8; while ((end - _incomingBuffer.Position) >= 9) { var message = _incomingBuffer.ParseMessage(); if (message == null) { continue; } try { Logger.LogIncomingPacket(message); // change ConsoleTarget's level to Level.Dump in program.cs if u want to see messages on console. if (message.Consumer != Consumers.None) { if (message.Consumer == Consumers.ClientManager) { ClientManager.Instance.Consume(this, message); // Client should be greeted by ClientManager and sent initial game-setup messages. } else { this.Game.Route(this, message); } } else if (message is ISelfHandler) { (message as ISelfHandler).Handle(this); // if message is able to handle itself, let it do so. } // Кустарный перехват портала else if (message.Id == 87) { MooNetClient mooNetClient = BnetClient; Logger.Warn("Portal to New Tristram. Version 2.0.", message.GetType(), message.Id); Vector3D ToPortal = new Vector3D(2988.73f, 2798.009f, 24.66344f); try { //Search Old Portals var OldOTG = Player.World.GetActorsBySNO(5648); foreach (var OldP in OldOTG) { OldP.Destroy(); } }catch { } var ToHome = new Portal(Player.World, 5648, Player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.NameSNOId = 71150; ToHome.Scale = 0.9f; Vector3D PositionToPortal = new Vector3D(Player.Position.X, Player.Position.Y + 3, Player.Position.Z); ToHome.EnterWorld(PositionToPortal); /* * //Первая версия телепорта * if (mooNetClient.InGameClient.Game.GetWorld(71150) != mooNetClient.InGameClient.Player.World) * mooNetClient.InGameClient.Player.ChangeWorld(mooNetClient.InGameClient.Game.GetWorld(71150), ToPortal); * else * mooNetClient.InGameClient.Player.Teleport(ToPortal); */ } else { Logger.Warn("{0} - ID:{1} has no consumer or self-handler.", message.GetType(), message.Id); } } catch (NotImplementedException) { Logger.Warn("Unhandled game message: 0x{0:X4} {1}", message.Id, message.GetType().Name); } } _incomingBuffer.Position = end; } _incomingBuffer.ConsumeData(); }
public override IEnumerable <TickTimer> Main() { Player plr = (User as Player); Items.Item ScrollToHome = null; foreach (var item in plr.Inventory.GetBackPackItems()) { if (item.ActorSNO.Id == 5656) { ScrollToHome = item; break; } } if (ScrollToHome == null) { yield break; } Logger.Debug("Portal to New Tristram. Version 3.0"); int TargetWorld = -1; int TargetArea = -1; //Очистка от существующих порталов домой. var OldOTG = User.World.GetActorsBySNO(5648); if (OldOTG != null) { foreach (var OldP in OldOTG) { OldP.Destroy(); } } switch ((User as Player).Toon.ActiveAct) { case 0: TargetWorld = 71150; TargetArea = -1; break; case 100: TargetWorld = 161472; TargetArea = -1; break; case 200: TargetWorld = 172909; TargetArea = -1; break; case 300: TargetWorld = 178152; TargetArea = -1; break; } TagMap New = new TagMap(); New.Add(new TagKeySNO(526850), new TagMapEntry(526850, TargetWorld, 0)); New.Add(new TagKeySNO(526853), new TagMapEntry(526853, TargetArea, 0)); var ToHome = new Portal(User.World, 5648, New);// User.World.Game.GetWorld(TargetHome).StartingPoints[0].Tags); if (ScrollToHome.Attributes[GameAttribute.ItemStackQuantityLo] <= 1) { plr.Inventory.DestroyInventoryItem(ScrollToHome); } else { ScrollToHome.Attributes[GameAttribute.ItemStackQuantityLo]--; ScrollToHome.Attributes.SendChangedMessage(plr.InGameClient); } ToHome.Scale = 0.9f; Vector3D PositionToPortal = new Vector3D(User.Position.X, User.Position.Y + 3, User.Position.Z); ToHome.EnterWorld(PositionToPortal); yield break; }
public override void OnTargeted(Player player, TargetMessage message) { Logger.Debug("(OnTargeted) Portal has been activated "); var world = this.World.Game.GetWorld(this.Destination.WorldSNO); var startingPoint = world.GetStartingPointById(this.Destination.StartingPointActorTag); #region События //Подвал Адрии if (this.Destination.WorldSNO == 62751) { //Enter в Adrian's Hut bool QuestEnter = false; var Cauldron = world.GetActorBySNO(131123); if (player.PlayerIndex == 0) { if (player.Toon.ActiveQuest == 72095) { player.Toon.ActiveQuest = 72095; if (player.Toon.StepOfQuest == 5) { player.Toon.StepOfQuest = 6; player.Toon.StepIDofQuest = 51; QuestEnter = true; } var Leah_Cellar = world.GetActorBySNO(203030); Leah_Cellar.Position = new Vector3D(-200f, -200f, 3.051758E-05f); } } if (QuestEnter == true) { world.Game.Quests.NotifyQuest(72095, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); //world.Game.Quests.Advance(72095); } } #endregion #region Авто-Учёт перехода для Квест-Менеджера world.Game.Quests.NotifyQuest(player.Toon.ActiveQuest, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.EnterWorld, this.Destination.WorldSNO); #endregion if (world == null) { Logger.Warn("Portal's destination world does not exist (WorldSNO = {0})", this.Destination.WorldSNO); return; } #region Не санкционированные порталы) if (this.Destination.StartingPointActorTag == -100) { Vector3D ToPortal = new Vector3D(2985.6241f, 2795.627f, 24.04532f); Vector3D ToPortal2Act = new Vector3D(310.739f, 275.8123f, 0.09997072f); Vector3D ToPortal3Act = new Vector3D(390f, 402f, 0f); Vector3D ToPortal4Act = new Vector3D(390f, 402f, 0f); //Сохраняем в базу координаты для обратного портала. var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(player.Toon.PersistentID); var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); dbPortalOfToon.WorldDest = player.World.WorldSNO.Id; dbPortalOfToon.X = this.Position.X; dbPortalOfToon.Y = this.Position.Y; dbPortalOfToon.Z = this.Position.Z; dbPortalOfToon.PlayerIndex = player.PlayerIndex; DBSessions.AccountSession.SaveOrUpdate(dbPortalOfToon); Logger.Warn("Data for back portal Saved."); if (dbQuestProgress.ActiveAct == 0) { var TristramHome = player.World.Game.GetWorld(71150); var OldPortal = TristramHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(71150), 5648, player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(71150) != player.World) { /* * if (dbQuestProgress.ActiveQuest == 72221 & dbQuestProgress.StepOfQuest == 10 & player.PlayerIndex == 0) * { * player.World.Game.Quests.NotifyQuest(72221, DiIiS.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); * dbQuestProgress.StepOfQuest = 11; * }*/ player.ChangeWorld(player.World.Game.GetWorld(71150), ToPortal); if (dbQuestProgress.ActiveQuest == 72738 && dbQuestProgress.StepOfQuest == 18) { //player.World.Game.Quests.NotifyQuest(72738, DiIiS.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); dbQuestProgress.ActiveQuest = 73236; dbQuestProgress.StepOfQuest = -1; } player.ChangeWorld(player.World.Game.GetWorld(71150), ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } else { player.Teleport(ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.Teleport(ToPortal); } } } else if (dbQuestProgress.ActiveAct == 100) { var CaldeumHome = player.World.Game.GetWorld(161472); var OldPortal = CaldeumHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(161472), 5648, player.World.Game.GetWorld(161472).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal2Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(161472) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(161472), ToPortal2Act); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal2Act); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } } else if (dbQuestProgress.ActiveAct == 200) { var BastionHome = player.World.Game.GetWorld(172909); var OldPortal = BastionHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(172909), 5648, player.World.Game.GetWorld(172909).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal3Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(172909) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(172909), ToPortal3Act); } else { player.Teleport(ToPortal3Act); } } else if (dbQuestProgress.ActiveAct == 300) { var BastionHome = player.World.Game.GetWorld(178152); var OldPortal = BastionHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(178152), 5648, player.World.Game.GetWorld(178152).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = player.CurrentScene.Specification.SNOLevelAreas[0], StartingPointActorTag = -101 }; ToHome.EnterWorld(ToPortal4Act); if (PlayerBackPortalID == 0xFFFFFFFFFFFF) { ToHome.PlayerBackPortalID = player.Toon.PersistentID; } if (player.World.Game.GetWorld(178152) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(178152), ToPortal4Act); } else { player.Teleport(ToPortal4Act); } } DBSessions.AccountSession.Flush(); } //Портал из Города else if (this.Destination.StartingPointActorTag == -101) { if (PlayerBackPortalID == player.Toon.PersistentID) { this.Destroy(); } var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(PlayerBackPortalID); Vector3D ToPortal = new Vector3D(dbPortalOfToon.X, dbPortalOfToon.Y, dbPortalOfToon.Z); var DestWorld = player.World.Game.GetWorld(dbPortalOfToon.WorldDest); var oldPortals = DestWorld.GetActorsBySNO(5648); foreach (var OldP in oldPortals) { OldP.Destroy(); } if (player.World.Game.GetWorld(dbPortalOfToon.WorldDest) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(dbPortalOfToon.WorldDest), ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.ChangeWorld(world, ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } else { player.Teleport(ToPortal); if (player.ActiveHireling != null) { player.ActiveHireling.Teleport(ToPortal); player.InGameClient.SendMessage(new PetMessage() { Field0 = 0, Field1 = 0, PetId = player.ActiveHireling.DynamicID, Field3 = 0, }); } } } else { #endregion if (startingPoint != null) { player.ChangeWorld(world, startingPoint); } else { #region Использование умного телепорта if (this.Destination.StartingPointActorTag != 0) { StartingPoint NeededStartingPoint = world.GetStartingPointById(this.Destination.StartingPointActorTag); var DestWorld = world.Game.GetWorld(this.Destination.WorldSNO); var StartingPoints = DestWorld.GetActorsBySNO(5502); foreach (var ST in StartingPoints) { if (ST.CurrentScene.SceneSNO.Id == this.Destination.StartingPointActorTag) { NeededStartingPoint = (ST as StartingPoint); } } player.ChangeWorld(DestWorld, NeededStartingPoint); } #endregion else { Logger.Warn("Portal's tagged starting point does not exist (Tag = {0})", this.Destination.StartingPointActorTag); } } } }
public override void OnTargeted(Player player, TargetMessage message) { Logger.Debug("(OnTargeted) Portal has been activated "); var world = this.World.Game.GetWorld(this.Destination.WorldSNO); var now_world = player.World; if (this.Destination.WorldSNO == 71150) { if (this.ActorSNO.Id == 241660) { Vector3D Point = new Vector3D(2867.382f, 2398.66f, 1.813717f); player.Teleport(Point); //OnListenerToEnterGraveyard var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.StepOfQuest == 6) { var ListenerEnterToGraveyard = Task <bool> .Factory.StartNew(() => OnListenerToEnterGraveyard(player, world)); ListenerEnterToGraveyard.ContinueWith(delegate { Logger.Debug("Enter to Road Objective done "); }); } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); } if (this.ActorSNO.Id == 241661) { Vector3D Point = new Vector3D(2870.336f, 2498.836f, 3.700585f); player.Teleport(Point); } } if (this.Destination.WorldSNO == 72637) { // Вход в Оскверненный склеп var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.ActiveQuest == 72221) { if (dbQuestProgress.StepOfQuest == 7) { var Crypto = world.Game.GetWorld(72637); var ListenerEnterToBossZone = Task <bool> .Factory.StartNew(() => OnListenerToEnterBossScene(player, Crypto)); ListenerEnterToBossZone.ContinueWith(delegate { Logger.Debug("Founding Zone Objective done "); //156381 - Chancellor Eamon var Summoner = world.GetActorBySNO(5387); Crypto.SpawnMonster(156353, Summoner.Position); var ChancellorEamon = world.GetActorBySNO(156353); ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.Using_Bossbar] = true; ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.InBossEncounter] = true; // DOES NOT WORK it should be champion affixes or shit of this kind ... // Увеличиваем здоровье босса! ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.Hitpoints_Max] = 200f; ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.Hitpoints_Cur] = 200f; ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.Movement_Scalar_Reduction_Percent] -= 10f; ChancellorEamon.Attributes[Net.GS.Message.GameAttribute.Quest_Monster] = true; List <uint> Boss = new List <uint> { }; Boss.Add(ChancellorEamon.DynamicID); var BossKillEvent = Task <bool> .Factory.StartNew(() => OnKillListenerBossEamon(Boss, Crypto)); BossKillEvent.ContinueWith(delegate { dbQuestProgress.StepOfQuest = 9; world.Game.Quests.Advance(72221); }); }); } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); } if (this.Destination.WorldSNO == 62751) { //Enter в Adrian's Hut bool QuestEnter = false; var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.ActiveQuest == 72095) { dbQuestProgress.ActiveQuest = 72095; if (dbQuestProgress.StepOfQuest == 5) { dbQuestProgress.StepOfQuest = 6; QuestEnter = true; } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); if (QuestEnter == true) { world.Game.Quests.Advance(72095); QuestEnter = false; } } if (this.Destination.WorldSNO == 50579) { //Enter в Cathedral level 1 bool QuestEnter = false; var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.ActiveQuest == 72095) { dbQuestProgress.ActiveQuest = 72095; if (dbQuestProgress.StepOfQuest == 10) { dbQuestProgress.StepOfQuest = 11; QuestEnter = true; } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); if (QuestEnter == true) { world.Game.Quests.Advance(72095); QuestEnter = false; } var FakePortal = world.GetActorBySNO(168932); Portal RealPortal = new Portal(world.Game.GetWorld(50579), 5648, world.Game.GetWorld(60713).StartingPoints[0].Tags); // FakePortal.Destroy(); //80652 Vector3D RealPosition = new Vector3D(643.384f, 339.6074f, -6.970252f); RealPortal.Destination = new ResolvedPortalDestination { WorldSNO = 60713, DestLevelAreaSNO = 60885, StartingPointActorTag = -102 }; RealPortal.EnterWorld(FakePortal.Position); } if (this.Destination.WorldSNO == 136441) { //Входим в погреб проклятых var dest = world.Game.GetWorld(136441); var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.ActiveQuest == 72221) { if (dbQuestProgress.StepOfQuest == 2) { //98888 - BlacksmithWife //85900 - Mira Eamon Monster //174023,204605,204615,204607,204608,204606,204616,174023,204605 //6646 - Ravenous Dead List <uint> Deadly = new List <uint> { }; List <uint> Boss = new List <uint> { }; #region Собираем всех! var Preminions1 = dest.GetActorsBySNO(174023); var Preminions2 = dest.GetActorsBySNO(204605); var Preminions3 = dest.GetActorsBySNO(204615); var Preminions4 = dest.GetActorsBySNO(204607); var Preminions5 = dest.GetActorsBySNO(204608); var Preminions6 = dest.GetActorsBySNO(204606); var Preminions7 = dest.GetActorsBySNO(204616); var Preminions8 = dest.GetActorsBySNO(174023); var Preminions9 = dest.GetActorsBySNO(204605); var PreBoss = dest.GetActorBySNO(98888); #endregion #region Убираем мирных и заменяем их злыми) foreach (var minion in Preminions1) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions2) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions3) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions4) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions5) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions6) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions7) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions8) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } foreach (var minion in Preminions9) { dest.SpawnMonster(6646, minion.Position); dest.Leave(minion); } #endregion #region Заполняем массив монстрами var Minions = dest.GetActorsBySNO(6646); foreach (var Minion in Minions) { Deadly.Add(Minion.DynamicID); } #endregion var DeadlyKillEvent = Task <bool> .Factory.StartNew(() => OnKillListenerDeadly(Deadly, dest)); DeadlyKillEvent.ContinueWith(delegate { if (dbQuestProgress.StepOfQuest == 2) { world.Game.Quests.Advance(72221); dest.SpawnMonster(85900, PreBoss.Position); dest.Leave(PreBoss); var BOSSMira = dest.GetActorBySNO(85900); // Пытаемся привязать статус босса! BOSSMira.Attributes[Net.GS.Message.GameAttribute.Using_Bossbar] = true; BOSSMira.Attributes[Net.GS.Message.GameAttribute.InBossEncounter] = true; // DOES NOT WORK it should be champion affixes or shit of this kind ... // Увеличиваем здоровье босса! BOSSMira.Attributes[Net.GS.Message.GameAttribute.Hitpoints_Max] = 200f; BOSSMira.Attributes[Net.GS.Message.GameAttribute.Hitpoints_Cur] = 200f; BOSSMira.Attributes[Net.GS.Message.GameAttribute.Movement_Scalar_Reduction_Percent] -= 10f; BOSSMira.Attributes[Net.GS.Message.GameAttribute.Quest_Monster] = true; Boss.Add(BOSSMira.DynamicID); var BossSmithWifeKillEvent = Task <bool> .Factory.StartNew(() => OnKillListenerBossSmithWife(Boss, dest)); BossSmithWifeKillEvent.ContinueWith(delegate { world.Game.Quests.Advance(72221); dbQuestProgress.StepOfQuest = 4; }); } }); } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); } if (this.Destination.WorldSNO == 60395) { //Enter to Drowned Temple } if (this.Destination.WorldSNO == 60713) { //Enter to Leoric Hall var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.StepOfQuest > 12 || dbQuestProgress.ActiveQuest != 72095) { var BookShelf = world.GetActorBySNO(5723); world.BroadcastIfRevealed(new Net.GS.Message.Definitions.Animation.SetIdleAnimationMessage { ActorID = BookShelf.DynamicID, AnimationSNO = AnimationSetKeys.Open.ID }, BookShelf); var minions = world.GetActorsBySNO(80652); foreach (var minion in minions) { minion.Destroy(); } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); } if (this.Destination.WorldSNO == 50582) { //Enter to Cathedral Level 2 Vector3D Point = new Vector3D(1146.33f, 1539.594f, 0.2f); if (world.Game.GetWorld(50582).StartingPoints.Count == 0) { player.ChangeWorld(player.World.Game.GetWorld(50582), Point); } } if (world == null) { Logger.Warn("Portal's destination world does not exist (WorldSNO = {0})", this.Destination.WorldSNO); return; } //Portal to New Tristram if (this.Destination.StartingPointActorTag == -100) { Vector3D ToPortal = new Vector3D(2988.73f, 2798.009f, 24.66344f); //Сохраняем в базу координаты для обратного портала. var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(player.Toon.PersistentID); var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); dbPortalOfToon.WorldDest = now_world.WorldSNO.Id; dbPortalOfToon.X = this.Position.X; dbPortalOfToon.Y = this.Position.Y; dbPortalOfToon.Z = this.Position.Z; DBSessions.AccountSession.SaveOrUpdate(dbPortalOfToon); Logger.Warn("Data for back portal Saved."); if (player.World.Game.GetWorld(71150) != player.World) { try { if (player.ActiveHireling != null) { var HirelingToLeave = player.ActiveHireling; now_world.Leave(HirelingToLeave); } } catch { } if (dbQuestProgress.ActiveQuest == 72221 && dbQuestProgress.StepOfQuest == 10) { player.World.Game.Quests.NotifyQuest(72221, Mooege.Common.MPQ.FileFormats.QuestStepObjectiveType.EventReceived, -1); } player.ChangeWorld(player.World.Game.GetWorld(71150), ToPortal); } else { player.Teleport(ToPortal); } //Create Back Portal var TristramHome = player.World.Game.GetWorld(71150); var OldPortal = TristramHome.GetActorsBySNO(5648); foreach (var OldP in OldPortal) { OldP.Destroy(); } var ToHome = new Portal(player.World.Game.GetWorld(71150), 5648, player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.Destination = new ResolvedPortalDestination { WorldSNO = dbPortalOfToon.WorldDest, DestLevelAreaSNO = 172, StartingPointActorTag = -101 }; // Название локации, не работает( ToHome.NameSNOId = now_world.WorldSNO.Id; ToHome.EnterWorld(ToPortal); DBSessions.AccountSession.Flush(); } else if (this.Destination.StartingPointActorTag == -101) { var dbPortalOfToon = DBSessions.AccountSession.Get <DBPortalOfToon>(player.Toon.PersistentID); Vector3D ToPortal = new Vector3D(dbPortalOfToon.X, dbPortalOfToon.Y, dbPortalOfToon.Z); var DestWorld = player.World.Game.GetWorld(dbPortalOfToon.WorldDest); var oldPortals = DestWorld.GetActorsBySNO(5648); foreach (var OldP in oldPortals) { // OldP.Destroy(); } if (player.World.Game.GetWorld(dbPortalOfToon.WorldDest) != player.World) { player.ChangeWorld(player.World.Game.GetWorld(dbPortalOfToon.WorldDest), ToPortal); } else { player.Teleport(ToPortal); } } else if (this.Destination.StartingPointActorTag == -102) { var dest = world.Game.GetWorld(60713); Vector3D Point = new Vector3D(237.3005f, 200.94f, 31.17498f); bool QuestEnter = false; var dbQuestProgress = DBSessions.AccountSession.Get <DBProgressToon>(player.Toon.PersistentID); if (dbQuestProgress.ActiveQuest == 72095) { dbQuestProgress.ActiveQuest = 72095; if (dbQuestProgress.StepOfQuest == 11) { dbQuestProgress.StepOfQuest = 12; QuestEnter = true; var minions = dest.GetActorsBySNO(80652); List <uint> SkilletKiller = new List <uint> { }; var CainBrains = world.GetActorBySNO(102386); foreach (var minion in minions) { SkilletKiller.Add(minion.DynamicID); var facingAngle = Actors.Movement.MovementHelpers.GetFacingAngle(minion, CainBrains.Position); minion.Move(CainBrains.Position, facingAngle); } var CainKillerEvent = Task <bool> .Factory.StartNew(() => OnKillListenerCain(SkilletKiller, dest)); CainKillerEvent.ContinueWith(delegate { if (dbQuestProgress.StepOfQuest == 12) { world.Game.Quests.Advance(72095); dbQuestProgress.StepOfQuest = 13; } }); } else { QuestEnter = false; } } DBSessions.AccountSession.SaveOrUpdate(dbQuestProgress); DBSessions.AccountSession.Flush(); if (QuestEnter == true) { world.Game.Quests.Advance(72095); QuestEnter = false; } player.ChangeWorld(player.World.Game.GetWorld(60713), Point); } else if (this.Destination.StartingPointActorTag == -103) { Vector3D Point = new Vector3D(1769.139f, 2914.95f, 20.16885f); player.ChangeWorld(player.World.Game.GetWorld(71150), Point); } else if (this.Destination.StartingPointActorTag == -104) { Vector3D Point = new Vector3D(1769.139f, 2914.95f, 20.16885f); player.ChangeWorld(player.World.Game.GetWorld(71150), Point); } else { var startingPoint = world.GetStartingPointById(this.Destination.StartingPointActorTag); if (startingPoint != null) { try { if (player.ActiveHireling != null) { var HirelingToLeave = player.ActiveHireling; now_world.Leave(HirelingToLeave); var NewTristram = player.InGameClient.Game.GetWorld(71150); var Leah_Back = NewTristram.GetActorByDynamicId(83); Leah_Back.EnterWorld(Leah_Back.Position); } } catch { } player.ChangeWorld(world, startingPoint); } else { Logger.Warn("Portal's tagged starting point does not exist (Tag = {0})", this.Destination.StartingPointActorTag); } } }
public virtual void OnRequestUse(Player player, Item target, int actionId, WorldPlace worldPlace) { if (this.ItemType.Name == "HealthPotion") { if (player.Attributes[GameAttribute.Hitpoints_Cur] == player.Attributes[GameAttribute.Hitpoints_Max]) { return; // TODO Error msg? /fasbat } player.Attributes[GameAttribute.Hitpoints_Cur] = player.Attributes[GameAttribute.Hitpoints_Cur] + this.Attributes[GameAttribute.Hitpoints_Granted]; player.Attributes.BroadcastChangedIfRevealed(); if (this.Attributes[GameAttribute.ItemStackQuantityLo] <= 1) { player.Inventory.DestroyInventoryItem(this); // No more potions! } else { this.Attributes[GameAttribute.ItemStackQuantityLo]--; // Just remove one this.Attributes.SendChangedMessage(player.InGameClient); } } else if (this.ActorSNO.Id == 5656) { //LogNetClient LogNetClient = BnetClient; Logger.Warn("Portal to New Tristram. Version 2.2."); //Vector3D ToPortal = new Vector3D(2985.6241f, 2795.627f, 24.04532f); try { //Search Old Portals var OldOTG = player.World.GetActorsBySNO(5648); foreach (var OldP in OldOTG) { OldP.Destroy(); } } catch { } var ToHome = new Portal(player.World, 5648, player.World.Game.GetWorld(71150).StartingPoints[0].Tags); ToHome.Scale = 0.9f; Vector3D PositionToPortal = new Vector3D(player.Position.X, player.Position.Y + 3, player.Position.Z); ToHome.EnterWorld(PositionToPortal); if (this.Attributes[GameAttribute.ItemStackQuantityLo] <= 1) { player.Inventory.DestroyInventoryItem(this); } else { this.Attributes[GameAttribute.ItemStackQuantityLo]--; this.Attributes.SendChangedMessage(player.InGameClient); } } else { throw new System.NotImplementedException(); } }