public static void HandleDebugPortalRecall(Session session, params string[] parameters)
 {
     if (!session.Player.TeleToPosition(PositionType.LastPortal))
     // On error
     {
         // You are too powerful to interact with that portal!
         var portalRecallMessage = new GameEventDisplayStatusMessage(session, StatusMessageType1.YouMustLinkToPortalToRecall);
         session.Network.EnqueueSend(portalRecallMessage);
     }
 }
Example #2
0
 public static void HandleDebugPortalRecall(Session session, params string[] parameters)
 {
     session.Player.HandleActionTeleToPosition(PositionType.LastPortal, () =>
                                               // On error
     {
         // You are too powerful to interact with that portal!
         var portalRecallMessage = new GameEventDisplayStatusMessage(session, StatusMessageType1.Enum_04A3);
         session.Network.EnqueueSend(portalRecallMessage);
     });
 }
Example #3
0
        public override void Handle()
        {
            switch (groupChatType)
            {
            case GroupChatType.TellFellowship:
            {
                var statusMessage = new GameEventDisplayStatusMessage(Session, StatusMessageType1.YouDoNotBelongToAFellowship);
                NetworkManager.SendWorldMessages(Session, new GameMessage[] { statusMessage });

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellFellowship Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellPatron:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellPatron Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellMonarch:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellMonarch Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellCoVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellCoVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.AllegianceBroadcast:
            {
                // The client knows if we're in an allegiance or not, and will throw an error to the user if they try to /a, and no message will be dispatched to the server.

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel AllegianceBroadcast Needs work.", ChatMessageType.Broadcast);
            }
            break;

            default:
                Console.WriteLine($"Unhandled ChatChannel GroupChatType: 0x{(uint)groupChatType:X4}");
                break;
            }
        }
Example #4
0
        public static void HandleDebugPortalRecall(Session session, params string[] parameters)
        {
            Position lastPortalUsed = null;

            if (session.Player.Positions.TryGetValue(PositionType.LastPortal, out lastPortalUsed))
            {
                session.Player.Teleport(lastPortalUsed);
            }
            else
            {
                // You are too powerful to interact with that portal!
                var portalRecallMessage = new GameEventDisplayStatusMessage(session, StatusMessageType1.Enum_04A3);
                session.Network.EnqueueSend(portalRecallMessage);
            }
        }
Example #5
0
        public override void Handle()
        {
            var targetSession = WorldManager.FindByPlayerName(target);

            if (targetSession == null)
            {
                var statusMessage = new GameEventDisplayStatusMessage(Session, StatusMessageType1.CharacterNotAvailable);
                Session.WorldSession.EnqueueSend(statusMessage);
            }
            else
            {
                if (Session.Player != targetSession.Player)
                {
                    Session.WorldSession.EnqueueSend(new GameMessageSystemChat($"You tell {target}, \"{message}\"", ChatMessageType.OutgoingTell));
                }

                var tell = new GameEventTell(targetSession, message, Session.Player.Name, Session.Player.Guid.Full, targetSession.Player.Guid.Full, ChatMessageType.Tell);
                targetSession.WorldSession.EnqueueSend(tell);
            }
        }
Example #6
0
        public override void Handle()
        {
            var targetSession = WorldManager.FindByPlayerName(target);

            if (targetSession == null)
            {
                var statusMessage = new GameEventDisplayStatusMessage(Session, StatusMessageType1.CharacterNotAvailable);
                NetworkManager.SendWorldMessages(Session, new GameMessage[] { statusMessage });
            }
            else
            {
                if (Session.Player != targetSession.Player)
                {
                    ChatPacket.SendServerMessage(Session, $"You tell {target}, \"'{message}'\"", ChatMessageType.OutgoingTell);
                }

                var tell = new GameEventTell(targetSession, message, Session.Player.Name, Session.Player.Guid.Full, targetSession.Player.Guid.Full, ChatMessageType.PrivateTell);
                NetworkManager.SendWorldMessages(targetSession, new GameMessage[] { tell });
            }
        }
Example #7
0
        public static void Handle(ClientMessage clientMessage, Session session)
        {
            var message = clientMessage.Payload.ReadString16L(); // The client seems to do the trimming for us
            var target  = clientMessage.Payload.ReadString16L(); // Needs to be trimmed because it may contain white spaces after the name and before the ,

            target = target.Trim();
            var targetsession = WorldManager.FindByPlayerName(target);

            if (targetsession == null)
            {
                var statusMessage = new GameEventDisplayStatusMessage(session, StatusMessageType1.CharacterNotAvailable);
                session.Network.EnqueueSend(statusMessage);
            }
            else
            {
                if (session.Player != targetsession.Player)
                {
                    session.Network.EnqueueSend(new GameMessageSystemChat($"You tell {target}, \"{message}\"", ChatMessageType.OutgoingTell));
                }

                var tell = new GameEventTell(targetsession, message, session.Player.Name, session.Player.Guid.Full, targetsession.Player.Guid.Full, ChatMessageType.Tell);
                targetsession.Network.EnqueueSend(tell);
            }
        }
Example #8
0
        public override void Handle()
        {
            switch (groupChatType)
            {
            case GroupChatType.TellAbuse:
            {
                //TODO: Proper permissions check. This command should work for any character with AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdmin:
            {
                if (!Session.Player.IsAdmin)
                {
                    break;
                }

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
                //NetworkManager.SendWorldMessage(recipient, gameMessageSystemChat);
            }
            break;

            case GroupChatType.TellAudit:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Sentinel or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate2:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellAdvocate3:
            {
                //TODO: Proper permissions check. This command should work for any character AccessLevel.Advocate or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellSentinel:
            {
                //TODO: Proper permissions check. This command should work for any character with AccessLevel.Sentinel or higher
                //if (!Session.Player.IsAdmin)
                //    break;

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                    }
                    else
                    {
                        recipient.Network.EnqueueSend(new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
                    }
                }
            }
            break;

            case GroupChatType.TellHelp:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellHelp Needs work.", ChatMessageType.Broadcast);
                //TODO: I don't remember exactly how this was triggered. I don't think it sent back a "You say" message to the person who triggered it
                //TODO: Proper permissions check. Requesting urgent help should work for any character but only displays the "says" mesage for those subscribed to the Help channel
                //      which would be Advocates and above.
                //if (!Session.Player.IsAdmin)
                //    break;
                string onTheWhatChannel = "on the " + System.Enum.GetName(typeof(GroupChatType), groupChatType).Replace("Tell", "") + " channel";
                string whoSays          = Session.Player.Name + " says ";

                //ChatPacket.SendServerMessage(Session, $"You say {onTheWhatChannel}, \"{message}\"", ChatMessageType.OutgoingHelpSay);

                var gameMessageSystemChat = new GameMessages.Messages.GameMessageSystemChat(whoSays + onTheWhatChannel + ", \"" + message + "\"", ChatMessageType.Help);

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    if (recipient != Session)
                    {
                        recipient.Network.EnqueueSend(gameMessageSystemChat);
                    }
                }

                // again not sure what way to go with this.. the code below was added after I realized I should be handling things differently
                // and by handling differently I mean letting the client do all of the work it was already designed to do.

                //foreach (var recipient in WorldManager.GetAll())
                //    if (recipient != Session)
                //        NetworkManager.SendWorldMessage(recipient, new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, Session.Player.Name, message));
                //    else
                //        NetworkManager.SendWorldMessage(recipient, new GameEvent.Events.GameEventChannelBroadcast(recipient, groupChatType, "", message));
            }
            break;


            case GroupChatType.TellFellowship:
            {
                var statusMessage = new GameEventDisplayStatusMessage(Session, StatusMessageType1.YouDoNotBelongToAFellowship);
                Session.Network.EnqueueSend(statusMessage);

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellFellowship Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellPatron:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellPatron Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellMonarch:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellMonarch Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.TellCoVassals:
            {
                ChatPacket.SendServerMessage(Session, "GameActionChatChannel TellCoVassals Needs work.", ChatMessageType.Broadcast);
            }
            break;

            case GroupChatType.AllegianceBroadcast:
            {
                // The client knows if we're in an allegiance or not, and will throw an error to the user if they try to /a, and no message will be dispatched to the server.

                ChatPacket.SendServerMessage(Session, "GameActionChatChannel AllegianceBroadcast Needs work.", ChatMessageType.Broadcast);
            }
            break;

            default:
                Console.WriteLine($"Unhandled ChatChannel GroupChatType: 0x{(uint)groupChatType:X4}");
                break;
            }
        }
Example #9
0
        public override void HandleActionOnCollide(ObjectGuid playerId)
        {
            string serverMessage;

            ActionChain chain = new ActionChain();

            CurrentLandblock.ChainOnObject(chain, playerId, (WorldObject wo) =>
            {
                Player player = wo as Player;
                if (player == null)
                {
                    return;
                }
                if (Destination != null)
                {
#if DEBUG
                    serverMessage        = "Checking requirements for " + this.Name;
                    var usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                    player.Session.Network.EnqueueSend(usePortalMessage);
#endif
                    // Check player level -- requires remote query to player (ugh)...
                    if ((player.Level >= MinimumLevel) && ((player.Level <= MaximumLevel) || (MaximumLevel == 0)))
                    {
                        Position portalDest = Destination;
                        switch (WeenieClassId)
                        {
                        /// <summary>
                        /// Setup correct racial portal destination for the Central Courtyard in the Training Academy
                        /// </summary>
                        case (ushort)SpecialPortalWCID.CentralCourtyard:
                            {
                                uint playerLandblockId = player.Location.LandblockId.Raw;
                                switch (playerLandblockId)
                                {
                                case (uint)SpecialPortalLandblockID.ShoushiCCLaunch:            // Shoushi
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiCCLanding);
                                        break;
                                    }

                                case (uint)SpecialPortalLandblockID.YaraqCCLaunch:            // Yaraq
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqCCLanding);
                                        break;
                                    }

                                case (uint)SpecialPortalLandblockID.SanamarCCLaunch:            // Sanamar
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarCCLanding);
                                        break;
                                    }

                                default:                    // Holtburg
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgCCLanding);
                                        break;
                                    }
                                }

                                portalDest.PositionX = Destination.PositionX;
                                portalDest.PositionY = Destination.PositionY;
                                portalDest.PositionZ = Destination.PositionZ;
                                portalDest.RotationX = Destination.RotationX;
                                portalDest.RotationY = Destination.RotationY;
                                portalDest.RotationZ = Destination.RotationZ;
                                portalDest.RotationW = Destination.RotationW;
                                break;
                            }

                        /// <summary>
                        /// Setup correct racial portal destination for the Outer Courtyard in the Training Academy
                        /// </summary>
                        case (ushort)SpecialPortalWCID.OuterCourtyard:
                            {
                                uint playerLandblockId = player.Location.LandblockId.Raw;
                                switch (playerLandblockId)
                                {
                                case (uint)SpecialPortalLandblockID.ShoushiOCLaunch:            // Shoushi
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiOCLanding);
                                        break;
                                    }

                                case (uint)SpecialPortalLandblockID.YaraqOCLaunch:            // Yaraq
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqOCLanding);
                                        break;
                                    }

                                case (uint)SpecialPortalLandblockID.SanamarOCLaunch:            // Sanamar
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarOCLanding);
                                        break;
                                    }

                                default:                    // Holtburg
                                    {
                                        portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgOCLanding);
                                        break;
                                    }
                                }

                                portalDest.PositionX = Destination.PositionX;
                                portalDest.PositionY = Destination.PositionY;
                                portalDest.PositionZ = Destination.PositionZ;
                                portalDest.RotationX = Destination.RotationX;
                                portalDest.RotationY = Destination.RotationY;
                                portalDest.RotationZ = Destination.RotationZ;
                                portalDest.RotationW = Destination.RotationW;
                                break;
                            }

                        /// <summary>
                        /// All other portals don't need adjustments.
                        /// </summary>
                        default:
                            {
                                break;
                            }
                        }

#if DEBUG
                        serverMessage    = "Portal sending player to destination";
                        usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                        player.Session.Network.EnqueueSend(usePortalMessage);
#endif
                        player.Session.Player.Teleport(portalDest);
                        // If the portal just used is able to be recalled to,
                        // save the destination coordinates to the LastPortal character position save table
                        if (IsRecallable)
                        {
                            player.SetCharacterPosition(PositionType.LastPortal, portalDest);
                        }
                    }
                    else if ((player.Level > MaximumLevel) && (MaximumLevel != 0))
                    {
                        // You are too powerful to interact with that portal!
                        var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AC);
                        player.Session.Network.EnqueueSend(failedUsePortalMessage);
                    }
                    else
                    {
                        // You are not powerful enough to interact with that portal!
                        var failedUsePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AB);
                        player.Session.Network.EnqueueSend(failedUsePortalMessage);
                    }
                }
                else
                {
                    serverMessage = "Portal destination for portal ID " + this.WeenieClassId + " not yet implemented!";
                    var failedUsePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                    player.Session.Network.EnqueueSend(failedUsePortalMessage);
                }
            });
            // Run on the player
            chain.EnqueueChain();
        }
Example #10
0
        public override void OnCollide(Player player)
        {
            // validate within use range :: set to a fixed value as static Portals are normally OnCollide usage
            float rangeCheck = 5.0f;

            if (player.Location.SquaredDistanceTo(Location) < rangeCheck)
            {
                if (portalDestination != null)
                {
                    if ((player.Level >= portalMinLvl) && ((player.Level <= portalMaxLvl) || (portalMaxLvl == 0)))
                    {
                        Position portalDest = portalDestination;
                        switch (WeenieClassid)
                        {
                        /// <summary>
                        /// Setup correct racial portal destination for the Central Courtyard in the Training Academy
                        /// </summary>
                        case (ushort)SpecialPortalWCID.CentralCourtyard:
                        {
                            uint playerLandblockId = player.Location.LandblockId.Raw;
                            switch (playerLandblockId)
                            {
                            case (uint)SpecialPortalLandblockID.ShoushiCCLaunch:                // Shoushi
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiCCLanding);
                                break;
                            }

                            case (uint)SpecialPortalLandblockID.YaraqCCLaunch:                // Yaraq
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqCCLanding);
                                break;
                            }

                            case (uint)SpecialPortalLandblockID.SanamarCCLaunch:                // Sanamar
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarCCLanding);
                                break;
                            }

                            default:                        // Holtburg
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgCCLanding);
                                break;
                            }
                            }

                            portalDest.PositionX = portalDestination.PositionX;
                            portalDest.PositionY = portalDestination.PositionY;
                            portalDest.PositionZ = portalDestination.PositionZ;
                            portalDest.RotationX = portalDestination.RotationX;
                            portalDest.RotationY = portalDestination.RotationY;
                            portalDest.RotationZ = portalDestination.RotationZ;
                            portalDest.RotationW = portalDestination.RotationW;
                            break;
                        }

                        /// <summary>
                        /// Setup correct racial portal destination for the Outer Courtyard in the Training Academy
                        /// </summary>
                        case (ushort)SpecialPortalWCID.OuterCourtyard:
                        {
                            uint playerLandblockId = player.Location.LandblockId.Raw;
                            switch (playerLandblockId)
                            {
                            case (uint)SpecialPortalLandblockID.ShoushiOCLaunch:                // Shoushi
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.ShoushiOCLanding);
                                break;
                            }

                            case (uint)SpecialPortalLandblockID.YaraqOCLaunch:                // Yaraq
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.YaraqOCLanding);
                                break;
                            }

                            case (uint)SpecialPortalLandblockID.SanamarOCLaunch:                // Sanamar
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.SanamarOCLanding);
                                break;
                            }

                            default:                        // Holtburg
                            {
                                portalDest.LandblockId = new LandblockId((uint)SpecialPortalLandblockID.HoltburgOCLanding);
                                break;
                            }
                            }

                            portalDest.PositionX = portalDestination.PositionX;
                            portalDest.PositionY = portalDestination.PositionY;
                            portalDest.PositionZ = portalDestination.PositionZ;
                            portalDest.RotationX = portalDestination.RotationX;
                            portalDest.RotationY = portalDestination.RotationY;
                            portalDest.RotationZ = portalDestination.RotationZ;
                            portalDest.RotationW = portalDestination.RotationW;
                            break;
                        }

                        /// <summary>
                        /// All other portals don't need adjustments.
                        /// </summary>
                        default:
                        {
                            break;
                        }
                        }

                        player.Session.Player.Teleport(portalDest);
                        // If the portal just used is able to be recalled to,
                        // save the destination coordinates to the LastPortal character position save table
                        if (Convert.ToBoolean(portalIsRecallable) == true)
                        {
                            player.SetCharacterPosition(PositionType.LastPortal, portalDest);
                        }
                        // always send useDone event
                        var sendUseDoneEvent = new GameEventUseDone(player.Session);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent);
                    }
                    else if ((player.Level > portalMaxLvl) && (portalMaxLvl != 0))
                    {
                        // You are too powerful to interact with that portal!
                        var usePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AC);
                        // always send useDone event
                        var sendUseDoneEvent = new GameEventUseDone(player.Session);
                        player.Session.Network.EnqueueSend(usePortalMessage, sendUseDoneEvent);
                    }
                    else
                    {
                        // You are not powerful enough to interact with that portal!
                        var usePortalMessage = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04AB);
                        // always send useDone event
                        var sendUseDoneEvent = new GameEventUseDone(player.Session);
                        player.Session.Network.EnqueueSend(usePortalMessage, sendUseDoneEvent);
                    }
                }
                else
                {
                    string serverMessage    = "Portal destination for portal ID " + this.WeenieClassid + " not yet implemented!";
                    var    usePortalMessage = new GameMessageSystemChat(serverMessage, ChatMessageType.System);
                    // always send useDone event
                    var sendUseDoneEvent = new GameEventUseDone(player.Session);
                    player.Session.Network.EnqueueSend(usePortalMessage, sendUseDoneEvent);
                }
            }
            else
            {
                // always send useDone event
                var sendUseDoneEvent = new GameEventUseDone(player.Session);
                player.Session.Network.EnqueueSend(sendUseDoneEvent);
            }
        }
Example #11
0
File: Key.cs Project: roidzilla/ACE
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();

            var keyCode = GetProperty(PropertyString.KeyCode);

            chain.AddAction(player, () =>
            {
                if (player == null)
                {
                    return;
                }

                if (!player.IsWithinUseRadiusOf(target))
                {
                    player.DoMoveTo(target);
                }
                else
                {
                    var sendUseDoneEvent = new GameEventUseDone(player.Session);

                    if (target.WeenieType == WeenieType.Door)
                    {
                        Door door = target as Door;

                        Door.UnlockDoorResults results = door.UnlockDoor(keyCode);

                        switch (results)
                        {
                        case WorldObjects.Door.UnlockDoorResults.UnlockSuccess:
                            Structure--;
                            if (Structure < 1)
                            {
                                player.RemoveItemFromInventory(Guid.Full, player.Guid.Full, 1);
                            }

                            player.Session.Network.EnqueueSend(sendUseDoneEvent);
                            player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(Sequences, Guid, PropertyInt.Structure, (int)Structure));
                            break;

                        case WorldObjects.Door.UnlockDoorResults.DoorOpen:
                            var messageDoorOpen = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.YouCannotLockWhatIsOpen);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageDoorOpen);
                            break;

                        case WorldObjects.Door.UnlockDoorResults.AlreadyUnlocked:
                            var messageAlreadyUnlocked = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.KeyDoesntFitThisLock);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageAlreadyUnlocked);
                            break;

                        default:
                            var messageIncorrectKey = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.KeyDoesntFitThisLock);
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageIncorrectKey);
                            break;
                        }
                    }
                    else if (target.WeenieType == WeenieType.Chest)
                    {
                        var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                    else
                    {
                        var message = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.YouCannotLockOrUnlockThat);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                }
            });

            chain.EnqueueChain();
        }
Example #12
0
File: Key.cs Project: dworkin/ACE
        public void HandleActionUseOnTarget(Player player, WorldObject target)
        {
            ActionChain chain = new ActionChain();

            chain.AddAction(player, () =>
            {
                if (player == null)
                {
                    return;
                }

                if (!player.IsWithinUseRadiusOf(target))
                {
                    player.DoMoveTo(target);
                }
                else
                {
                    var sendUseDoneEvent = new GameEventUseDone(player.Session);
                    if (target.WeenieType == WeenieType.Door)
                    {
                        Door door = target as Door;
                        Door.UnlockDoorResults results = door.UnlockDoor(KeyCode);
                        switch (results)
                        {
                        case Entity.Door.UnlockDoorResults.UnlockSuccess:
                            Structure--;
                            if (Structure < 1)
                            {
                                // Remove item from players
                                player.DestroyInventoryItem(this);
                                // Clean up the shard database.
                                DatabaseManager.Shard.DeleteObject(SnapShotOfAceObject(), null);
                            }
                            player.Session.Network.EnqueueSend(sendUseDoneEvent);
                            player.Session.Network.EnqueueSend(new GameMessagePublicUpdatePropertyInt(this.Sequences, Guid, PropertyInt.Structure, (uint)Structure));
                            break;

                        case Entity.Door.UnlockDoorResults.DoorOpen:
                            var messageDoorOpen = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0481);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageDoorOpen);
                            break;

                        case Entity.Door.UnlockDoorResults.AlreadyUnlocked:
                            var messageAlreadyUnlocked = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04B2);     // TODO: Messages are not quiet right. Need to find right one.
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageAlreadyUnlocked);
                            break;

                        default:
                            var messageIncorrectKey = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_04B2);
                            player.Session.Network.EnqueueSend(sendUseDoneEvent, messageIncorrectKey);
                            break;
                        }
                    }
                    else if (target.WeenieType == WeenieType.Chest)
                    {
                        var message = new GameMessageSystemChat($"Unlocking {target.Name} has not been implemented, yet!", ChatMessageType.System);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                    else
                    {
                        var message = new GameEventDisplayStatusMessage(player.Session, StatusMessageType1.Enum_0480);
                        player.Session.Network.EnqueueSend(sendUseDoneEvent, message);
                    }
                }
            });
            chain.EnqueueChain();
        }