예제 #1
0
        /// <summary>
        /// Remove a single friend and update the database.
        /// </summary>
        /// <param name="friendGuid">The ObjectGuid of the friend that is being removed</param>
        public void HandleActionRemoveFriend(uint friendGuid)
        {
            if (!Character.TryRemoveFriend(friendGuid, out var friendToRemove, CharacterDatabaseLock))
            {
                ChatPacket.SendServerMessage(Session, "That character is not in your friends list!", ChatMessageType.Broadcast);
                return;
            }

            CharacterChangesDetected = true;

            // send network message
            Session.Network.EnqueueSend(new GameEventFriendsListUpdate(Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendRemoved, friendToRemove));
        }
        public static void HandleTele(Session session, params string[] parameters)
        {
            // Used PhatAC source to implement most of this.  Thanks Pea!

            // usage: @tele [name] longitude latitude
            // This command teleports yourself (or the specified character) to the given longitude and latitude.
            // @tele - Teleports you(or a player) to some location.

            if (session.Player.IsAdvocate && session.Player.AdvocateLevel < 5)
            {
                return;
            }

            List <CommandParameterHelpers.ACECommandParameter> aceParams = new List <CommandParameterHelpers.ACECommandParameter>()
            {
                new CommandParameterHelpers.ACECommandParameter()
                {
                    Type         = CommandParameterHelpers.ACECommandParameterType.OnlinePlayerNameOrIid,
                    Required     = false,
                    DefaultValue = session.Player
                },
                new CommandParameterHelpers.ACECommandParameter()
                {
                    Type         = CommandParameterHelpers.ACECommandParameterType.Location,
                    Required     = true,
                    ErrorMessage = "You must supply a location to teleport to.\nExample: /tele 37s,67w"
                }
            };

            if (!CommandParameterHelpers.ResolveACEParameters(session, parameters, aceParams))
            {
                return;
            }

            // Check if water block
            var longcellid = ((ulong)session.Player.Location.Instance << 32) | aceParams[1].AsPosition.ObjCellID;
            var landblock  = LScape.get_landblock(longcellid);

            if (landblock.WaterType == LandDefs.WaterType.EntirelyWater)
            {
                ChatPacket.SendServerMessage(session, $"Landblock 0x{aceParams[1].AsPosition.Landblock:X4} is entirely filled with water, and is impassable", ChatMessageType.Broadcast);
                return;
            }

            ChatPacket.SendServerMessage(session, $"Position: [Cell: 0x{aceParams[1].AsPosition.Landblock:X4} | Offset: {aceParams[1].AsPosition.Pos.X}, " +
                                         $"{aceParams[1].AsPosition.Pos.Y}, {aceParams[1].AsPosition.Pos.Z} | Facing: {aceParams[1].AsPosition.Rotation.X}, {aceParams[1].AsPosition.Rotation.Y}, " +
                                         $"{ aceParams[1].AsPosition.Rotation.Z}, {aceParams[1].AsPosition.Rotation.W}]", ChatMessageType.Broadcast);

            aceParams[0].AsPlayer.Teleport(aceParams[1].AsPosition);
        }
예제 #3
0
파일: DebugCommands.cs 프로젝트: Zorgle/ACE
        public static void HandleGrantXp(Session session, params string[] parameters)
        {
            uint xp = 0;

            if (parameters?.Length > 0 && uint.TryParse(parameters[0], out xp))
            {
                session.Player.GrantXp(xp);
            }
            else
            {
                ChatPacket.SendServerMessage(session, "Usage: /grantxp 1234", ChatMessageType.Broadcast);
                return;
            }
        }
예제 #4
0
 public static void HandleGrantXp(Session session, params string[] parameters)
 {
     if (parameters?.Length > 0)
     {
         string xpAmountToParse = parameters[0].Length > 12 ? parameters[0].Substring(0, 12) : parameters[0];
         // 12 characters : xxxxxxxxxxxx : 191,226,310,247 for 275
         if (ulong.TryParse(xpAmountToParse, out var xp))
         {
             session.Player.GrantXp(xp);
             return;
         }
     }
     ChatPacket.SendServerMessage(session, "Usage: /grantxp 1234 (max 999999999999)", ChatMessageType.Broadcast);
 }
예제 #5
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;
            }
        }
예제 #6
0
 /// <summary>
 /// This will determine where a command handler should output to, the console or a client session.<para />
 /// If the session is null, the output will be sent to the console. If the session is not null, and the session.Player is in the world, it will be sent to the session.<para />
 /// Messages sent to the console will be sent using log.Debug()
 /// </summary>
 public static void WriteOutputDebug(Session session, string output, ChatMessageType chatMessageType = ChatMessageType.Broadcast)
 {
     if (session != null)
     {
         if (session.State == Network.Enum.SessionState.WorldConnected && session.Player != null)
         {
             ChatPacket.SendServerMessage(session, output, chatMessageType);
         }
     }
     else
     {
         log.Debug(output);
     }
 }
예제 #7
0
        /// <summary>
        /// Handles teleporting a player to the lifestone (/ls or /lifestone command)
        /// </summary>
        public void HandleActionTeleToLifestone()
        {
            if (RecallsDisabled)
            {
                Session.Network.EnqueueSend(new GameEventWeenieError(Session, WeenieError.ExitTrainingAcademyToUseCommand));
                return;
            }

            if (Sanctuary != null)
            {
                // FIXME(ddevec): I should probably make a better interface for this
                UpdateVital(Mana, Mana.Current / 2);

                if (CombatMode != CombatMode.NonCombat)
                {
                    // this should be handled by a different thing, probably a function that forces player into peacemode
                    var updateCombatMode = new GameMessagePrivateUpdatePropertyInt(this, PropertyInt.CombatMode, (int)CombatMode.NonCombat);
                    SetCombatMode(CombatMode.NonCombat);
                    Session.Network.EnqueueSend(updateCombatMode);
                }

                EnqueueBroadcast(new GameMessageSystemChat($"{Name} is recalling to the lifestone.", ChatMessageType.Recall), 96.0f);
                EnqueueBroadcastMotion(motionLifestoneRecall);

                var startPos = new Position(Location);

                // Wait for animation
                ActionChain lifestoneChain = new ActionChain();

                // Then do teleport
                lifestoneChain.AddDelaySeconds(DatManager.PortalDat.ReadFromDat <MotionTable>(MotionTableId).GetAnimationLength(MotionCommand.LifestoneRecall));
                lifestoneChain.AddAction(this, () =>
                {
                    var endPos = new Position(Location);
                    if (startPos.SquaredDistanceTo(endPos) > RecallMoveThresholdSq)
                    {
                        Session.Network.EnqueueSend(new GameEventWeenieError(Session, WeenieError.YouHaveMovedTooFar));
                        return;
                    }

                    Teleport(Sanctuary);
                });

                lifestoneChain.EnqueueChain();
            }
            else
            {
                ChatPacket.SendServerMessage(Session, "Your spirit has not been attuned to a sanctuary location.", ChatMessageType.Broadcast);
            }
        }
예제 #8
0
        public static void HandleCharacterTokenization(Session session, params string[] parameters)
        {
            uint   characterId   = 0;
            string characterName = parameters[0];

            AccessLevel accessLevel = AccessLevel.Player;

            if (parameters.Length > 1)
            {
                if (Enum.TryParse(parameters[1], true, out accessLevel))
                {
                    if (!Enum.IsDefined(typeof(AccessLevel), accessLevel))
                    {
                        accessLevel = AccessLevel.Player;
                    }
                }
            }

            characterId = DatabaseManager.Character.SetCharacterAccessLevelByName(characterName.ToLower(), accessLevel);

            if (characterId > 0)
            {
                string articleAorAN = "a";
                if (accessLevel == AccessLevel.Advocate || accessLevel == AccessLevel.Admin || accessLevel == AccessLevel.Envoy)
                {
                    articleAorAN = "an";
                }

                if (session == null)
                {
                    Console.WriteLine("Character " + characterName + " has been made " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + ".");
                }
                else
                {
                    ChatPacket.SendServerMessage(session, "Character " + characterName + " has been made " + articleAorAN + " " + Enum.GetName(typeof(AccessLevel), accessLevel) + ".", ChatMessageType.Broadcast);
                }
            }
            else
            {
                if (session == null)
                {
                    Console.WriteLine("There is no character by the name of " + characterName + " found in the database. Has it been deleted?");
                }
                else
                {
                    ChatPacket.SendServerMessage(session, "There is no character by the name of " + characterName + " found in the database. Has it been deleted?", ChatMessageType.Broadcast);
                }
            }
        }
예제 #9
0
        public void HandleActionRaiseVital(PropertyAttribute2nd attribute, uint amount)
        {
            var creatureVital = new CreatureVital(this, attribute);

            uint result = SpendVitalXp(creatureVital, amount);

            if (result > 0u)
            {
                GameMessage abilityUpdate = new GameMessagePrivateUpdateVital(this, attribute, creatureVital.Ranks, creatureVital.StartingValue, result, creatureVital.Current);

                // checks if max rank is achieved and plays fireworks w/ special text
                string messageText;

                if (IsVitalMaxRank(creatureVital.Ranks))
                {
                    // fireworks
                    PlayParticleEffect(ACE.Entity.Enum.PlayScript.WeddingBliss, Guid);
                    messageText = $"Your base {attribute.ToSentence()} is now {creatureVital.Base} and has reached its upper limit!";
                }
                else
                {
                    messageText = $"Your base {attribute.ToSentence()} is now {creatureVital.Base}!";
                }

                var soundEvent = new GameMessageSound(Guid, Sound.RaiseTrait, 1f);
                var message    = new GameMessageSystemChat(messageText, ChatMessageType.Advancement);

                // This seems to be needed to keep health up to date properly.
                // Needed when increasing health and endurance.
                //if (attribute == PropertyAttribute2nd.Endurance)
                //{
                //    var healthUpdate = new GameMessagePrivateUpdateVital(Session, Ability.Health, Health.Ranks, Health.StartingValue, Health.ExperienceSpent, Health.Current);
                //    Session.Network.EnqueueSend(abilityUpdate, soundEvent, message, healthUpdate);
                //}
                //else if (attribute == PropertyAttribute2nd.Self)
                //{
                //    var manaUpdate = new GameMessagePrivateUpdateVital(Session, Ability.Mana, Mana.Ranks, Mana.StartingValue, Mana.ExperienceSpent, Mana.Current);
                //    Session.Network.EnqueueSend(abilityUpdate, soundEvent, message, manaUpdate);
                //}
                //else
                //{
                Session.Network.EnqueueSend(abilityUpdate, soundEvent, message);
                //}
            }
            else
            {
                ChatPacket.SendServerMessage(Session, $"Your attempt to raise {attribute.ToSentence()} has failed.", ChatMessageType.Broadcast);
            }
        }
예제 #10
0
        public static void animation(Session session, params string[] parameters)
        {
            uint animationId;

            try
            {
                animationId = Convert.ToUInt32(parameters[0]);
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, $"Invalid Animation value", ChatMessageType.Broadcast);
                return;
            }
            session.Network.EnqueueSend(new GameMessageMotion(session.Player, session, (MotionCommand)animationId, 1.0f));
        }
예제 #11
0
 public static void HandleSetHealth(Session session, params string[] parameters)
 {
     if (parameters?.Length > 0)
     {
         if (ushort.TryParse(parameters[0], out var health))
         {
             session.Player.Health.Current = health;
             var updatePlayersHealth = new GameMessagePrivateUpdateAttribute2ndLevel(session, Vital.Health, session.Player.Health.Current);
             var message             = new GameMessageSystemChat($"Attempting to set health to {health}...", ChatMessageType.Broadcast);
             session.Network.EnqueueSend(updatePlayersHealth, message);
             return;
         }
     }
     ChatPacket.SendServerMessage(session, "Usage: /sethealth 200 (max Max Health)", ChatMessageType.Broadcast);
 }
예제 #12
0
        public static void TurbineChatReceived(ClientMessage clientMessage, Session session)
        {
            clientMessage.Payload.ReadUInt32(); // Bytes to follow
            var turbineChatType = (TurbineChatType)clientMessage.Payload.ReadUInt32();

            clientMessage.Payload.ReadUInt32(); // Always 2
            clientMessage.Payload.ReadUInt32(); // Always 1
            clientMessage.Payload.ReadUInt32(); // Always 0
            clientMessage.Payload.ReadUInt32(); // Always 0
            clientMessage.Payload.ReadUInt32(); // Always 0
            clientMessage.Payload.ReadUInt32(); // Always 0
            clientMessage.Payload.ReadUInt32(); // Bytes to follow

            if (turbineChatType == TurbineChatType.OutboundMessage)
            {
                clientMessage.Payload.ReadUInt32(); // 0x01 - 0x71 (maybe higher), typically though 0x01 - 0x0F
                clientMessage.Payload.ReadUInt32(); // Always 2
                clientMessage.Payload.ReadUInt32(); // Always 2
                var channelID = clientMessage.Payload.ReadUInt32();

                var messageLen   = clientMessage.Payload.ReadByte();
                var messageBytes = clientMessage.Payload.ReadBytes(messageLen * 2);
                var message      = Encoding.Unicode.GetString(messageBytes);

                clientMessage.Payload.ReadUInt32();                                                                      // Always 0x0C
                var senderID = clientMessage.Payload.ReadUInt32();
                clientMessage.Payload.ReadUInt32();                                                                      // Always 0
                clientMessage.Payload.ReadUInt32();                                                                      // Always 1 or 2

                if (channelID == 7)                                                                                      // TODO this is hardcoded right now
                {
                    ChatPacket.SendServerMessage(session, "You do not belong to a society.", ChatMessageType.Broadcast); // I don't know if this is how it was done on the live servers
                    return;
                }

                var gameMessageTurbineChat = new GameMessageTurbineChat(TurbineChatType.InboundMessage, channelID, session.Player.Name, message, senderID);

                // TODO This should check if the recipient is subscribed to the channel
                foreach (var recipient in WorldManager.GetAll())
                {
                    recipient.Network.EnqueueSend(gameMessageTurbineChat);
                }
            }
            else
            {
                Console.WriteLine($"Unhandled TurbineChatHandler TurbineChatType: 0x{(uint)turbineChatType:X4}");
            }
        }
예제 #13
0
        /// <summary>
        /// Handles the GameAction 0x44 - RaiseVital network message from client
        /// </summary>
        public bool HandleActionRaiseVital(PropertyAttribute2nd vital, uint amount)
        {
            if (!Vitals.TryGetValue(vital, out var creatureVital))
            {
                log.Error($"{Name}.HandleActionRaiseVital({vital}, {amount}) - invalid vital");
                return(false);
            }

            if (amount > AvailableExperience)
            {
                // there is a client bug for vitals only,

                // where the client will enable the button to raise a vital by 10
                // if the player only has enough AvailableExperience to raise it by 1

                ChatPacket.SendServerMessage(Session, $"Your attempt to raise {vital.ToSentence()} has failed.", ChatMessageType.Broadcast);

                log.Error($"{Name}.HandleActionRaiseVital({vital}, {amount}) - amount > AvailableExperience ({AvailableExperience})");
                return(false);
            }

            var prevRank = creatureVital.Ranks;

            if (!SpendVitalXp(creatureVital, amount))
            {
                return(false);
            }

            Session.Network.EnqueueSend(new GameMessagePrivateUpdateVital(this, creatureVital));

            if (prevRank != creatureVital.Ranks)
            {
                // checks if max rank is achieved and plays fireworks w/ special text
                var suffix = "";
                if (creatureVital.IsMaxRank)
                {
                    // fireworks
                    PlayParticleEffect(PlayScript.WeddingBliss, Guid);
                    suffix = $" and has reached its upper limit";
                }

                var sound = new GameMessageSound(Guid, Sound.RaiseTrait);
                var msg   = new GameMessageSystemChat($"Your base {vital.ToSentence()} is now {creatureVital.Base}{suffix}!", ChatMessageType.Advancement);

                Session.Network.EnqueueSend(sound, msg);
            }
            return(true);
        }
예제 #14
0
        public static void HandleSetCoin(Session session, params string[] parameters)
        {
            int coins;

            try
            {
                coins = Convert.ToInt32(parameters[0]);
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, "Not a valid number - must be a number between 0 - 2,147,483,647", ChatMessageType.Broadcast);
                return;
            }
            session.Player.CoinValue = coins;
            session.Network.EnqueueSend(new GameMessagePrivateUpdatePropertyInt(session.Player.Sequences, PropertyInt.CoinValue, coins));
        }
예제 #15
0
파일: DebugCommands.cs 프로젝트: Zorgle/ACE
        public static void playeffect(Session session, params string[] parameters)
        {
            uint effectid;

            try
            {
                effectid = Convert.ToUInt32(parameters[0]);
            }
            catch (Exception)
            {
                //ex...more info.. if needed..
                ChatPacket.SendServerMessage(session, $"Invalid Effect value", ChatMessageType.Broadcast);
                return;
            }

            session.Player.PlayParticleEffect(effectid);
        }
예제 #16
0
파일: Player.cs 프로젝트: Cloudxtreme/ACE-1
        /// <summary>
        /// Remove a single friend and update the database.
        /// </summary>
        /// <param name="friendId">The ObjectGuid of the friend that is being removed</param>
        public void HandleActionRemoveFriend(ObjectGuid friendId)
        {
            var friendToRemove = Biota.CharacterPropertiesFriendList.SingleOrDefault(f => f.FriendId == friendId.Full);

            // Not in friend list
            if (friendToRemove == null)
            {
                ChatPacket.SendServerMessage(Session, "That character is not in your friends list!", ChatMessageType.Broadcast);
                return;
            }

            // remove friend in DB
            RemoveFriend(friendId);

            // send network message
            Session.Network.EnqueueSend(new GameEventFriendsListUpdate(Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendRemoved, friendToRemove));
        }
예제 #17
0
        public static void Animation(Session session, params string[] parameters)
        {
            uint animationId;

            try
            {
                animationId = Convert.ToUInt32(parameters[0]);
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, $"Invalid Animation value", ChatMessageType.Broadcast);
                return;
            }
            UniversalMotion motion = new UniversalMotion(MotionStance.Standing, new MotionItem((MotionCommand)animationId));

            session.Player.EnqueueMovementEvent(motion, session.Player.Guid);
        }
예제 #18
0
파일: AdminCommands.cs 프로젝트: sr314/ACE
        public static void HandleTeleportLOC(Session session, params string[] parameters)
        {
            try
            {
                uint cell;
                //System.Diagnostics.Debug.WriteLine(int.Parse(parameters[0], System.Globalization.NumberStyles.HexNumber));
                //if (!uint.TryParse(parameters[0], out cell))
                //    return;

                if (parameters[0].StartsWith("0x"))
                {
                    string strippedcell = parameters[0].Substring(2);
                    cell = (uint)int.Parse(strippedcell, System.Globalization.NumberStyles.HexNumber);
                }
                else
                {
                    cell = (uint)int.Parse(parameters[0], System.Globalization.NumberStyles.HexNumber);
                }


                var positionData = new float[7];
                for (uint i = 0u; i < 7u; i++)
                {
                    float position;
                    if (!float.TryParse(parameters[i + 1].Trim(new Char[] { ' ', '[', ']' }), out position))
                    {
                        return;
                    }

                    positionData[i] = position;
                }

                //session.Player.Teleport(new Position(cell, positionData[0], positionData[1], positionData[2], positionData[3], positionData[4], positionData[5], positionData[6]));
                // ^ Zeroed out last 4 numbers due to odd results when portaling to the exact coords.

                session.Player.Teleport(new Position(cell, positionData[0], positionData[1], positionData[2], 0, 0, 0, 0));
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, "Invalid arguments for @teleloc", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Usage: @teleloc cell x y z [qx qy qz qw]", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 0x7F0401AD [12.319900 -28.482000 0.005000] -0.338946 0.000000 0.000000 -0.940806", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 0x7F0401AD 12.319900 -28.482000 0.005000 -0.338946 0.000000 0.000000 -0.940806", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 7F0401AD 12.319900 -28.482000 0.005000", ChatMessageType.Broadcast);
            }
        }
        public override void Handle()
        {
            // this check is also done clientside, see: PlayerDesc::PlayerIsPSR
            if (!Session.Player.IsAdmin && !Session.Player.IsArch && !Session.Player.IsPsr)
            {
                return;
            }

            uint cell  = position.LandblockId.Raw;
            uint cellX = (cell >> 3);

            // TODO: Wrap command in a check to confirm session.character IsAdvocate or higher access level

            // TODO: Maybe output to chat window coords teleported to.
            // ChatPacket.SendSystemMessage(session, $"Teleporting to: 0.0[N/S], 0.0[E/W]");
            ChatPacket.SendServerMessage(Session, "Teleporting...", ChatMessageType.Broadcast);
            Session.Player.Teleport(position);
        }
예제 #20
0
        public static void EquipTest(Session session, params string[] parameters)
        {
            if (!(parameters?.Length > 0))
            {
                ChatPacket.SendServerMessage(session, "Usage: @equiptest (hex)clothingTableId [palette_index].\neg '@equiptest 0x100005fd'",
                                             ChatMessageType.Broadcast);
                return;
            }

            uint modelId;

            try
            {
                if (parameters[0].StartsWith("0x"))
                {
                    string strippedmodelid = parameters[0].Substring(2);
                    modelId = UInt32.Parse(strippedmodelid, System.Globalization.NumberStyles.HexNumber);
                }
                else
                {
                    modelId = UInt32.Parse(parameters[0], System.Globalization.NumberStyles.HexNumber);
                }

                int palOption = -1;
                if (parameters.Length > 1)
                {
                    palOption = Int32.Parse(parameters[1]);
                }

                if ((modelId >= 0x10000001) && (modelId <= 0x1000086B))
                {
                    session.Player.TestWieldItem(session, modelId, palOption);
                }
                else
                {
                    ChatPacket.SendServerMessage(session, "Please enter a value greater than 0x10000000 and less than 0x1000086C",
                                                 ChatMessageType.Broadcast);
                }
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, "Please enter a value greater than 0x10000000 and less than 0x1000086C", ChatMessageType.Broadcast);
            }
        }
예제 #21
0
        public static void SetVital(Session session, params string[] parameters)
        {
            string paramVital = parameters[0].ToLower();
            string paramValue = parameters[1];

            bool relValue = paramValue[0] == '+' || paramValue[0] == '-';
            int  value    = int.MaxValue;

            if (!int.TryParse(paramValue, out value))
            {
                ChatPacket.SendServerMessage(session, "setvital Error: Invalid set value", ChatMessageType.Broadcast);
                return;
            }

            // Parse args...
            CreatureVital vital = null;

            if (paramVital == "health" || paramVital == "hp")
            {
                vital = session.Player.Health;
            }
            else if (paramVital == "stamina" || paramVital == "stam" || paramVital == "sp")
            {
                vital = session.Player.Stamina;
            }
            else if (paramVital == "mana" || paramVital == "mp")
            {
                vital = session.Player.Mana;
            }
            else
            {
                ChatPacket.SendServerMessage(session, "setvital Error: Invalid vital", ChatMessageType.Broadcast);
                return;
            }

            if (!relValue)
            {
                session.Player.UpdateVital(vital, (uint)value);
            }
            else
            {
                session.Player.DeltaVital(vital, value);
            }
        }
예제 #22
0
        public async override void Handle()
        {
            var result = await Session.Player.AddFriend(friendName);

            switch (result)
            {
            case Enum.AddFriendResult.AlreadyInList:
                ChatPacket.SendServerMessage(Session, "That character is already in your friends list", ChatMessageType.Broadcast);
                break;

            case Enum.AddFriendResult.FriendWithSelf:
                ChatPacket.SendServerMessage(Session, "Sorry, but you can't be friends with yourself.", ChatMessageType.Broadcast);
                break;

            case Enum.AddFriendResult.CharacterDoesNotExist:
                ChatPacket.SendServerMessage(Session, "That character does not exist", ChatMessageType.Broadcast);
                break;
            }
        }
예제 #23
0
        public void SpendXp(Enum.Ability ability, uint amount)
        {
            uint   baseValue   = character.Abilities[ability].Base;
            uint   result      = SpendAbilityXp(character.Abilities[ability], amount);
            bool   isSecondary = (ability == Enum.Ability.Health || ability == Enum.Ability.Stamina || ability == Enum.Ability.Mana);
            uint   ranks       = character.Abilities[ability].Ranks;
            uint   newValue    = character.Abilities[ability].UnbuffedValue;
            string messageText = "";

            if (result > 0u)
            {
                GameMessage abilityUpdate;
                if (!isSecondary)
                {
                    abilityUpdate = new GameMessagePrivateUpdateAbility(Session, ability, ranks, baseValue, result);
                }
                else
                {
                    abilityUpdate = new GameMessagePrivateUpdateVital(Session, ability, ranks, baseValue, result, character.Abilities[ability].Current);
                }

                // checks if max rank is achieved and plays fireworks w/ special text
                if (IsAbilityMaxRank(ranks, isSecondary))
                {
                    // fireworks
                    PlayParticleEffect(Effect.WeddingBliss);
                    messageText = $"Your base {ability} is now {newValue} and has reached its upper limit!";
                }
                else
                {
                    messageText = $"Your base {ability} is now {newValue}!";
                }
                var xpUpdate   = new GameMessagePrivateUpdatePropertyInt64(Session, PropertyInt64.AvailableExperience, character.AvailableExperience);
                var soundEvent = new GameMessageSound(this.Guid, Network.Enum.Sound.RaiseTrait, 1f);
                var message    = new GameMessageSystemChat(messageText, ChatMessageType.Advancement);
                Session.Network.EnqueueSend(abilityUpdate, xpUpdate, soundEvent, message);
            }
            else
            {
                ChatPacket.SendServerMessage(Session, $"Your attempt to raise {ability} has failed.", ChatMessageType.Broadcast);
            }
        }
예제 #24
0
        public static void HandleTele(Session session, params string[] parameters)
        {
            // Used PhatAC source to implement most of this.  Thanks Pea!

            // usage: @tele [name] longitude latitude
            // This command teleports yourself (or the specified character) to the given longitude and latitude.
            // @tele - Teleports you(or a player) to some location.

            if (session.Player.IsAdvocate && session.Player.AdvocateLevel < 5)
            {
                return;
            }

            List <CommandParameterHelpers.ACECommandParameter> aceParams = new List <CommandParameterHelpers.ACECommandParameter>()
            {
                new CommandParameterHelpers.ACECommandParameter()
                {
                    Type         = CommandParameterHelpers.ACECommandParameterType.Player,
                    Required     = false,
                    DefaultValue = session.Player
                },
                new CommandParameterHelpers.ACECommandParameter()
                {
                    Type         = CommandParameterHelpers.ACECommandParameterType.Location,
                    Required     = true,
                    ErrorMessage = "You must supply a location to teleport to.\nExample: /tele 37s,67w"
                }
            };

            if (!CommandParameterHelpers.ResolveACEParameters(session, parameters, aceParams))
            {
                return;
            }

            // TODO: Check if water block?

            ChatPacket.SendServerMessage(session, $"Position: [Cell: 0x{aceParams[1].AsPosition.LandblockId.Landblock:X4} | Offset: {aceParams[1].AsPosition.PositionX}, " +
                                         $"{aceParams[1].AsPosition.PositionY}, {aceParams[1].AsPosition.PositionZ} | Facing: {aceParams[1].AsPosition.RotationX}, {aceParams[1].AsPosition.RotationY}, " +
                                         $"{ aceParams[1].AsPosition.RotationZ}, {aceParams[1].AsPosition.RotationW}]", ChatMessageType.Broadcast);

            aceParams[0].AsPlayer.Teleport(aceParams[1].AsPosition);
        }
예제 #25
0
        public static void CreateStaticCreature(Session session, params string[] parameters)
        {
            Creature newC = null;

            if (!(parameters?.Length > 0))
            {
                ChatPacket.SendServerMessage(session, "Usage: @createcreature [static] weenieClassId",
                                             ChatMessageType.Broadcast);
                return;
            }
            if (parameters?[0] == "static")
            {
                if (parameters?.Length > 1)
                {
                    uint weenie = Convert.ToUInt32(parameters[1]);
                    newC = MonsterFactory.SpawnCreature(weenie, true, session.Player.Location.InFrontOf(2.0f));
                }
                else
                {
                    ChatPacket.SendServerMessage(session, "Specify a valid weenieClassId after the static option.",
                                                 ChatMessageType.Broadcast);
                    return;
                }
            }
            else
            {
                uint weenie = Convert.ToUInt32(parameters[0]);
                newC = MonsterFactory.SpawnCreature(weenie, false, session.Player.Location.InFrontOf(2.0f));
            }

            if (newC != null)
            {
                ChatPacket.SendServerMessage(session, $"Now spawning {newC.Name}.",
                                             ChatMessageType.Broadcast);
                LandblockManager.AddObject(newC);
            }
            else
            {
                ChatPacket.SendServerMessage(session, "Couldn't find that creature in the database or save it's location.",
                                             ChatMessageType.Broadcast);
            }
        }
예제 #26
0
        public static async void Handle(ClientMessage message, Session session)
        {
            var friendName = message.Payload.ReadString16L().Trim();
            var result     = await session.Player.AddFriend(friendName);

            switch (result)
            {
            case Enum.AddFriendResult.AlreadyInList:
                ChatPacket.SendServerMessage(session, "That character is already in your friends list", ChatMessageType.Broadcast);
                break;

            case Enum.AddFriendResult.FriendWithSelf:
                ChatPacket.SendServerMessage(session, "Sorry, but you can't be friends with yourself.", ChatMessageType.Broadcast);
                break;

            case Enum.AddFriendResult.CharacterDoesNotExist:
                ChatPacket.SendServerMessage(session, "That character does not exist", ChatMessageType.Broadcast);
                break;
            }
        }
예제 #27
0
        public static void TestCorpse(Session session, params string[] parameters)
        {
            if (session.Player.SelectedTarget != 0)
            {
                var target = new ObjectGuid(session.Player.SelectedTarget);
                var wo     = LandblockManager.GetWorldObject(session, target);

                if (target.IsCreature())
                {
                    if (wo != null)
                    {
                        (wo as Creature).OnKill(session);
                    }
                }
            }
            else
            {
                ChatPacket.SendServerMessage(session, "No creature selected.", ChatMessageType.Broadcast);
            }
        }
예제 #28
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 });
            }
        }
예제 #29
0
파일: Player.cs 프로젝트: zarlant/ACE
        /// <summary>
        /// Adds a friend and updates the database.
        /// </summary>
        /// <param name="friendName">The name of the friend that is being added.</param>
        public void HandleActionAddFriend(string friendName)
        {
            if (string.Equals(friendName, Name, StringComparison.CurrentCultureIgnoreCase))
            {
                ChatPacket.SendServerMessage(Session, "Sorry, but you can't be friends with yourself.", ChatMessageType.Broadcast);
            }

            // Check if friend exists
            if (Friends.SingleOrDefault(f => string.Equals(f.Name, friendName, StringComparison.CurrentCultureIgnoreCase)) != null)
            {
                ChatPacket.SendServerMessage(Session, "That character is already in your friends list", ChatMessageType.Broadcast);
            }

            // TODO: check if player is online first to avoid database hit??
            // Get character record from DB
            throw new System.NotImplementedException();

            /* TODO fix for new EF model
             * DatabaseManager.Shard.GetObjectInfoByName(friendName, ((ObjectInfo friendInfo) =>
             * {
             *  if (friendInfo == null)
             *  {
             *      ChatPacket.SendServerMessage(Session, "That character does not exist", ChatMessageType.Broadcast);
             *      return;
             *  }
             *
             *  Friend newFriend = new Friend();
             *  newFriend.Name = friendInfo.Name;
             *  newFriend.Id = new ObjectGuid(friendInfo.Guid);
             *
             *  // Save to DB, assume success
             *  DatabaseManager.Shard.AddFriend(Guid.Low, newFriend.Id.Low, (() =>
             *  {
             *      // Add to character object
             *      Character.AddFriend(newFriend);
             *
             *      // Send packet
             *      Session.Network.EnqueueSend(new GameEventFriendsListUpdate(Session, GameEventFriendsListUpdate.FriendsUpdateTypeFlag.FriendAdded, newFriend));
             *  }));
             * }));*/
        }
예제 #30
0
        public static void HandleTeleportLOC(Session session, params string[] parameters)
        {
            try
            {
                uint cell;

                if (parameters[0].StartsWith("0x"))
                {
                    string strippedcell = parameters[0].Substring(2);
                    cell = (uint)int.Parse(strippedcell, System.Globalization.NumberStyles.HexNumber);
                }
                else
                {
                    cell = (uint)int.Parse(parameters[0], System.Globalization.NumberStyles.HexNumber);
                }


                var positionData = new float[7];
                for (uint i = 0u; i < 7u; i++)
                {
                    float position;
                    if (!float.TryParse(parameters[i + 1].Trim(new Char[] { ' ', '[', ']' }), out position))
                    {
                        return;
                    }

                    positionData[i] = position;
                }

                session.Player.Teleport(new Position(cell, positionData[0], positionData[1], positionData[2], positionData[4], positionData[5], positionData[6], positionData[3]));
            }
            catch (Exception)
            {
                ChatPacket.SendServerMessage(session, "Invalid arguments for @teleloc", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Hint: @teleloc follows the same number order as displayed from @loc output", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Usage: @teleloc cell [x y z] (qw qx qy qz)", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 0x7F0401AD [12.319900 -28.482000 0.005000] -0.338946 0.000000 0.000000 -0.940806", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 0x7F0401AD 12.319900 -28.482000 0.005000 -0.338946 0.000000 0.000000 -0.940806", ChatMessageType.Broadcast);
                ChatPacket.SendServerMessage(session, "Example: @teleloc 7F0401AD 12.319900 -28.482000 0.005000", ChatMessageType.Broadcast);
            }
        }