Esempio n. 1
0
        }   // for possile future messages consumed by game. /raist.

        #endregion

        #region player-handling

        /// <summary>
        /// Allows a player to join the game.
        /// </summary>
        /// <param name="joinedPlayer">The new player.</param>
        public void Enter(Player joinedPlayer)
        {
            this.Players.TryAdd(joinedPlayer.InGameClient, joinedPlayer);

            // send all players in the game to new player that just joined (including him)
            foreach (var pair in this.Players)
            {
                this.SendNewPlayerMessage(joinedPlayer, pair.Value);
            }

            // notify other players about our new player too.
            foreach (var pair in this.Players.Where(pair => pair.Value != joinedPlayer))
            {
                this.SendNewPlayerMessage(pair.Value, joinedPlayer);
            }

            var GameData = new GameSyncedData()
            {
                Field0 = 0x0,
                NowAct = 0x0,
                Field2 = 0x0,
                Field3 = 0x0,
                Field4 = 0x0,
                Field5 = 0x0,
                Field6 = 0x0,
                //Field7 = 0x0,
                Field7 = new[] { 0x0, 0x0 },
                Field8 = new[] { 0x0, 0x0 },
                //Field9 = new[] { 0x0, 0x0 },
                //Field10 = new[] { 0x0, 0x0 },
                //Field11 = new EntityId { High = 0,Low = 0 },
            };

            switch (joinedPlayer.Toon.ActiveAct)
            {
            case 100:
                GameData.NowAct = 100;
                break;

            case 200:
                GameData.NowAct = 200;
                break;

            case 300:
                GameData.NowAct = 300;
                break;
            }
            joinedPlayer.InGameClient.SendMessage(new GameSyncedDataMessage
            {
                Field0 = GameData
            });

            #region Загрузка лора игроков
            string LoreVar = joinedPlayer.Toon.LoreCollected;
            if (LoreVar != null & LoreVar != "")
            {
                string[] parts = LoreVar.Split(new char[] { '|' });
                foreach (var part in parts)
                {
                    joinedPlayer.AddLoreFromBase(Convert.ToInt32(part));
                }
            }
            #endregion
            if (joinedPlayer.PlayerIndex == 0)
            {
                if (joinedPlayer.Toon.ActiveAct == 0)
                {
                    #region Акт 1 Квест 1
                    if (joinedPlayer.Toon.ActiveQuest == 87700 & joinedPlayer.Toon.StepIDofQuest > 0)
                    {
                        StartingWorld.Leave(StartingWorld.GetActorByDynamicId(72));
                        //3739 - Rumford

                        var Capitan = StartingWorld.GetActorBySNO(3739);
                        Capitan.Attributes[Net.GS.Message.GameAttribute.MinimapActive] = true;
                        (Capitan as Core.GS.Actors.InteractiveNPC).Conversations.Clear();
                        (Capitan as Core.GS.Actors.InteractiveNPC).Conversations.Add(new Core.GS.Actors.Interactions.ConversationInteraction(198503));

                        Capitan.Attributes[Net.GS.Message.GameAttribute.Conversation_Icon, 0] = 1;
                        Capitan.Attributes.BroadcastChangedIfRevealed();
                    }
                    #endregion

                    #region Акт 1 Квест 2 - Наследие декарда каина
                    else if (joinedPlayer.Toon.ActiveQuest == 72095)
                    {
                        StartingWorld.Leave(StartingWorld.GetActorByDynamicId(72));

                        #region Перемотка ко второму квесту
                        for (int Rem = 0; Rem < 8; Rem++)
                        {
                            StartingWorld.Game.Quests.Advance(87700);
                        }
                        StartingWorld.Game.Quests.NotifyQuest(87700, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.InteractWithActor, 192164);
                        StartingWorld.Game.Quests.NotifyQuest(87700, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.HadConversation, 198521);

                        #endregion


                        //Берем нужную Лию =)
                        var LeahBrains = StartingWorld.GetActorByDynamicId(83);

                        Player MasterPlayer = joinedPlayer;
                        if (LeahBrains != null)
                        {
                            Logger.Debug("Вышибаем SNO {0}, мир содершит {1} ", LeahBrains.ActorSNO, StartingWorld.GetActorsBySNO(3739).Count);
                            StartingWorld.Leave(LeahBrains);
                        }
                        if (joinedPlayer.Toon.StepIDofQuest == -1 || joinedPlayer.Toon.StepIDofQuest == 28)
                        {
                            try
                            {
                                Hireling LeahFriend = new LeahParty(StartingWorld, LeahBrains.ActorSNO.Id, LeahBrains.Tags);
                                //LeahFriend.Brain = new HirelingBrain(LeahFriend);

                                LeahFriend.GBHandle.Type = 4;
                                LeahFriend.GBHandle.GBID = 717705071;
                                LeahFriend.Attributes[GameAttribute.Pet_Creator]        = joinedPlayer.PlayerIndex;
                                LeahFriend.Attributes[GameAttribute.Pet_Type]           = 0x8;
                                LeahFriend.Attributes[GameAttribute.Hitpoints_Max]      = 100f;
                                LeahFriend.Attributes[GameAttribute.Hitpoints_Cur]      = 80f;
                                LeahFriend.Attributes[GameAttribute.Attacks_Per_Second] = 1.6f;
                                LeahFriend.Attributes[GameAttribute.Pet_Owner]          = joinedPlayer.PlayerIndex;
                                LeahFriend.Attributes[GameAttribute.Untargetable]       = false;
                                LeahFriend.Position     = joinedPlayer.Position;
                                LeahFriend.RotationW    = LeahBrains.RotationW;
                                LeahFriend.RotationAxis = LeahBrains.RotationAxis;
                                LeahFriend.EnterWorld(LeahBrains.Position);
                                LeahFriend.Attributes[GameAttribute.Level]++;
                                joinedPlayer.ActiveHireling = LeahFriend;
                                LeahFriend.Brain.Activate();
                                MasterPlayer = joinedPlayer;
                                StartingWorld.Leave(LeahBrains);


                                var NewTristramPortal     = StartingWorld.GetActorBySNO(223757);
                                var ListenerUsePortalTask = Task <bool> .Factory.StartNew(() => OnUseTeleporterListener(NewTristramPortal.DynamicID, StartingWorld));

                                ListenerUsePortalTask.ContinueWith(delegate                //Once killed:
                                {
                                    Logger.Debug(" Waypoint_NewTristram Objective done "); // Waypoint_NewTristram
                                });
                                var ListenerEnterToOldTristram = Task <bool> .Factory.StartNew(() => OnListenerToEnter(joinedPlayer, StartingWorld));

                                ListenerEnterToOldTristram.ContinueWith(delegate   //Once killed:
                                {
                                    Logger.Debug("Enter to Road Objective done "); // Waypoint_OldTristram
                                    var ListenerEnterToAdriaEnter = Task <bool> .Factory.StartNew(() => OnListenerToAndriaEnter(joinedPlayer, StartingWorld));
                                });
                            }
                            catch
                            {
                                Logger.Warn("Ошибка создания спутника");

                                var NewTristramPortal     = StartingWorld.GetActorBySNO(223757);
                                var ListenerUsePortalTask = Task <bool> .Factory.StartNew(() => OnUseTeleporterListener(NewTristramPortal.DynamicID, StartingWorld));

                                ListenerUsePortalTask.ContinueWith(delegate                //Once killed:
                                {
                                    Logger.Debug(" Waypoint_NewTristram Objective done "); // Waypoint_NewTristram
                                });
                                var ListenerEnterToOldTristram = Task <bool> .Factory.StartNew(() => OnListenerToEnter(joinedPlayer, StartingWorld));

                                ListenerEnterToOldTristram.ContinueWith(delegate   //Once killed:
                                {
                                    Logger.Debug("Enter to Road Objective done "); // Waypoint_OldTristram
                                    var ListenerEnterToAdriaEnter = Task <bool> .Factory.StartNew(() => OnListenerToAndriaEnter(joinedPlayer, StartingWorld));
                                });
                            }
                        }
                        else if (joinedPlayer.Toon.StepIDofQuest == 51)
                        {
                            joinedPlayer.Toon.StepOfQuest = 6;
                            var Gate = StartingWorld.GetActorBySNO(108466);
                            Gate.Destroy();
                            StartingWorld.Leave(LeahBrains);
                        }
                        else
                        {
                            StartingWorld.Leave(LeahBrains);
                            LeahBrains.EnterWorld(LeahBrains.Position);
                        }
                    }

                    #endregion
                }
            }

            #region Прохождение игры 2.0 и Хард Фиксы
            if (joinedPlayer.Toon.ActiveQuest != -1)
            {
                if (joinedPlayer.Toon.ActiveAct == 0)
                {
                    joinedPlayer.EnterWorld(StartingWorld.StartingPoints.First().Position);

                    if (joinedPlayer.Toon.ActiveQuest != 87700)
                    {
                        #region Нижнии ворота тристрама
                        var DownGate = StartingWorld.GetActorBySNO(90419);
                        DownGate.Attributes[GameAttribute.Gizmo_State]  = 1;
                        DownGate.Attributes[GameAttribute.Untargetable] = true;
                        DownGate.Attributes.BroadcastChangedIfRevealed();
                        StartingWorld.BroadcastIfRevealed(new Net.GS.Message.Definitions.Animation.SetIdleAnimationMessage
                        {
                            ActorID      = DownGate.DynamicID,
                            AnimationSNO = Core.GS.Common.Types.TagMap.AnimationSetKeys.Open.ID
                        }, DownGate);
                        #endregion
                        //Убираем телегу
                        var FactorToShoot = StartingWorld.GetActorBySNO(81699);
                        FactorToShoot.Destroy();
                    }

                    #region Убираем телегу или делаем её нормальной.
                    if (joinedPlayer.Toon.ActiveQuest != 87700 && joinedPlayer.Toon.ActiveQuest != 72095 && joinedPlayer.Toon.ActiveQuest != -1)
                    {
                        var TELEGAS = StartingWorld.GetActorsBySNO(112131);
                        foreach (var TELEGA in TELEGAS)
                        {
                            TELEGA.Destroy();
                        }
                    }
                    else
                    {
                        var TELEGAS = StartingWorld.GetActorsBySNO(112131);
                        foreach (var TELEGA in TELEGAS)
                        {
                            TELEGA.Field2 = 0;
                        }
                    }
                    #endregion

                    if (joinedPlayer.Toon.StepIDofQuest != -1)
                    {
                        StartingWorld.Game.Quests[joinedPlayer.Toon.ActiveQuest].SwitchToStep(joinedPlayer.Toon.ActiveQuest, joinedPlayer.Toon.StepIDofQuest);
                    }
                    else
                    {
                        StartingWorld.Game.Quests[joinedPlayer.Toon.ActiveQuest].Advance();
                    }
                    if (joinedPlayer.Toon.ActiveQuest == 72546)
                    {
                        if (joinedPlayer.Toon.StepIDofQuest == 36)
                        {
                            joinedPlayer.Toon.StepOfQuest = 10;
                        }
                    }
                    if (joinedPlayer.Toon.ActiveQuest == 72061)
                    {
                        if (joinedPlayer.Toon.StepIDofQuest == 44)
                        {
                            StartingWorld.Game.Quests.NotifyQuest(72061, NullD.Common.MPQ.FileFormats.QuestStepObjectiveType.EnterWorld, 50585);
                        }
                    }
                }
            }
            else
            {
                joinedPlayer.EnterWorld(this.StartingWorld.StartingPoints.Find(x => x.ActorSNO.Name == "Start_Location_Team_0").Position);
                bool questConversation = true;
                var  Capitan           = this.StartingWorld.GetActorBySNO(3739);
                Capitan.Attributes[Net.GS.Message.GameAttribute.MinimapActive] = true;
                (Capitan as Core.GS.Actors.InteractiveNPC).Conversations.Clear();
                (Capitan as Core.GS.Actors.InteractiveNPC).Conversations.Add(new Core.GS.Actors.Interactions.ConversationInteraction(151087));

                Capitan.Attributes[Net.GS.Message.GameAttribute.Conversation_Icon, 0] = questConversation ? 1 : 0;
                Capitan.Attributes.BroadcastChangedIfRevealed();

                //Убираем эту заразу) wretchedMother
                StartingWorld.Leave(StartingWorld.GetActorBySNO(176889));
            }
            joinedPlayer.Toon.Side_StepOfQuest = 0;
            #endregion

            //Запуск игры
            joinedPlayer.InGameClient.TickingEnabled = true; // it seems bnet-servers only start ticking after player is completely in-game. /raist
        }
Esempio n. 2
0
        public override void Execute(Map.World world)
        {
            // Проверка на ненужную Лию
            if (world.HasActor(72))
            {
                world.GetActorByDynamicId(72).Destroy();
            }

            //Берем нужную Лию =)
            var LeahBrains = world.GetActorByDynamicId(83);

            //Берем путевую точку Нового Тристрама
            var NewTristramPortal = world.GetActorBySNO(223757);

            if (HadConversation)
            {
                HadConversation = false;
                Logger.Debug(" RESCUE CAIN QUEST STARTED ");
                world.Game.Quests.NotifyQuest(72095, QuestStepObjectiveType.EventReceived, -1);
            }

            #region Создаем Лею как подругу.
            Hireling LeahFriend = new LeahParty(world, LeahBrains.ActorSNO.Id, LeahBrains.Tags);
            //LeahFriend.Brain = new HirelingBrain(LeahFriend);
            foreach (var player in world.Players)
            {
                if (player.Value.PlayerIndex == 0)
                {
                    LeahFriend.GBHandle.Type = 4;
                    LeahFriend.GBHandle.GBID = 717705071;
                    LeahFriend.Attributes[GameAttribute.Pet_Creator]        = player.Value.PlayerIndex;
                    LeahFriend.Attributes[GameAttribute.Pet_Type]           = 0x8;
                    LeahFriend.Attributes[GameAttribute.Hitpoints_Max]      = 100f;
                    LeahFriend.Attributes[GameAttribute.Hitpoints_Cur]      = 80f;
                    LeahFriend.Attributes[GameAttribute.Attacks_Per_Second] = 1.6f;
                    LeahFriend.Attributes[GameAttribute.Pet_Owner]          = player.Value.PlayerIndex;
                    LeahFriend.Attributes[GameAttribute.Untargetable]       = false;
                    LeahFriend.Position     = RandomDirection(player.Value.Position, 3f, 8f);
                    LeahFriend.RotationW    = LeahBrains.RotationW;
                    LeahFriend.RotationAxis = LeahBrains.RotationAxis;
                    LeahFriend.EnterWorld(RandomDirection(player.Value.Position, 3f, 8f));
                    LeahFriend.Attributes[GameAttribute.Level]++;
                    player.Value.ActiveHireling = LeahFriend;
                    LeahFriend.Brain.Activate();
                    MasterPlayer = player.Value;
                }
                player.Value.Toon.ActiveQuest   = 72095;
                player.Value.Toon.StepOfQuest   = 1;
                player.Value.Toon.StepIDofQuest = 7;
            }
            #endregion
            // Убираем Лею NPC
            try { world.Leave(LeahBrains); }
            catch { }

            NewTristramPortal.Attributes[Net.GS.Message.GameAttribute.Gizmo_Has_Been_Operated] = false;
            var ListenerUsePortalTask = Task <bool> .Factory.StartNew(() => OnUseTeleporterListener(NewTristramPortal.DynamicID, world));

            ListenerUsePortalTask.ContinueWith(delegate                //Ждём использования телепорта:
            {
                Logger.Debug(" Waypoint_NewTristram Objective done "); // Waypoint_NewTristram
            });

            var ListenerEnterToOldTristram = Task <bool> .Factory.StartNew(() => OnListenerToEnter(MasterPlayer, world));

            ListenerEnterToOldTristram.ContinueWith(delegate //Once killed:
            {
                Logger.Debug("Enter to Road Objective done ");
                var ListenerEnterToAdriaEnter = Task <bool> .Factory.StartNew(() => OnListenerToAndriaEnter(MasterPlayer, world));
                ListenerEnterToAdriaEnter.ContinueWith(delegate //Once killed:
                {
                    Logger.Debug("Enter to Adria Objective done ");
                });
            });
        }