Exemplo n.º 1
0
        public void SpendXp(Enum.Ability ability, uint amount)
        {
            uint baseValue   = character.Abilities[ability].Base;
            uint result      = character.Abilities[ability].SpendXp(amount);
            bool isSecondary = (ability == Enum.Ability.Health || ability == Enum.Ability.Stamina || ability == Enum.Ability.Mana);

            if (result > 0u)
            {
                uint            ranks    = character.Abilities[ability].Ranks;
                uint            newValue = character.Abilities[ability].UnbuffedValue;
                var             xpUpdate = new GameEventPrivateUpdatePropertyInt64(Session, PropertyInt64.AvailableExperience, character.AvailableExperience);
                GameEventPacket abilityUpdate;
                if (!isSecondary)
                {
                    abilityUpdate = new GameEventPrivateUpdateAbility(Session, ability, ranks, baseValue, result);
                }
                else
                {
                    abilityUpdate = new GameEventPrivateUpdateVital(Session, ability, ranks, baseValue, result, character.Abilities[ability].Current);
                }

                var soundEvent = new GameEventSound(Session, Network.Enum.Sound.AbilityIncrease, 1f);

                xpUpdate.Send();
                abilityUpdate.Send();
                soundEvent.Send();
                ChatPacket.SendSystemMessage(Session, $"Your base {ability} is now {newValue}!");
            }
            else
            {
                ChatPacket.SendSystemMessage(Session, $"Your attempt to raise {ability} has failed.");
            }
        }
Exemplo n.º 2
0
        public static void HandleDebugTeleportCoords(Session session, params string[] parameters)
        {
            string northSouth = parameters[0].ToLower();
            string eastWest   = parameters[1].ToLower();

            if (!northSouth.EndsWith("n") && !northSouth.EndsWith("s"))
            {
                ChatPacket.SendSystemMessage(session, "Missing n or s indicator on first parameter");
                return;
            }

            if (!eastWest.EndsWith("e") && !eastWest.EndsWith("w"))
            {
                ChatPacket.SendSystemMessage(session, "Missing e or w indicator on second parameter");
                return;
            }

            float coordNS;

            if (!float.TryParse(northSouth.Substring(0, northSouth.Length - 1), out coordNS))
            {
                ChatPacket.SendSystemMessage(session, "North/South coordinate is not a valid number.");
                return;
            }

            float coordEW;

            if (!float.TryParse(eastWest.Substring(0, eastWest.Length - 1), out coordEW))
            {
                ChatPacket.SendSystemMessage(session, "East/West coordinate is not a valid number.");
                return;
            }

            if (northSouth.EndsWith("s"))
            {
                coordNS *= -1.0f;
            }
            if (eastWest.EndsWith("w"))
            {
                coordEW *= -1.0f;
            }

            Position position = null;

            try
            {
                position = new Position(coordNS, coordEW);
            }
            catch (System.Exception)
            {
                ChatPacket.SendSystemMessage(session, "There was a problem teleporting to that location (bad coordinates?).");
                return;
            }

            // TODO: Check if water block?

            ChatPacket.SendSystemMessage(session, $"Position: [Cell: 0x{position.Cell.ToString("X4")} | Offset: {position.Offset.X}, {position.Offset.Y}, {position.Offset.Z} | Facing: {position.Facing.X}, {position.Facing.Y}, {position.Facing.Z}, {position.Facing.W}]");

            session.Player.Teleport(position);
        }
Exemplo n.º 3
0
        public void GrantXp(ulong amount)
        {
            character.GrantXp(amount);
            var xpAvailUpdate = new GameEventPrivateUpdatePropertyInt64(Session, PropertyInt64.AvailableExperience, character.AvailableExperience);
            var xpTotalUpdate = new GameEventPrivateUpdatePropertyInt64(Session, PropertyInt64.TotalExperience, character.TotalExperience);

            xpAvailUpdate.Send();
            xpTotalUpdate.Send();
            ChatPacket.SendSystemMessage(Session, $"{amount} experience granted.");
        }
Exemplo n.º 4
0
        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.SendSystemMessage(session, "Usage: /grantxp 1234");
                return;
            }
        }
Exemplo n.º 5
0
        public override void Handle()
        {
            // this check is also done clientside, see: PlayerDesc::PlayerIsPSR
            if (!session.Player.PropertiesBool.ContainsKey(PropertyBool.IsAdmin) && !session.Player.PropertiesBool.ContainsKey(PropertyBool.IsArch) && !session.Player.PropertiesBool.ContainsKey(PropertyBool.IsPsr))
            {
                return;
            }

            uint cell  = position.Cell;
            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.SendSystemMessage(session, "Teleporting...");
            session.Player.Teleport(position);
        }
Exemplo n.º 6
0
        public override void Handle()
        {
            Entity.Enum.Ability ability = Entity.Enum.Ability.None;
            switch (vital)
            {
            case Vital.MaxHealth:
                ability = Entity.Enum.Ability.Health;
                break;

            case Vital.MaxStamina:
                ability = Entity.Enum.Ability.Stamina;
                break;

            case Vital.MaxMana:
                ability = Entity.Enum.Ability.Mana;
                break;

            default:
                ChatPacket.SendSystemMessage(session, $"Unable to Handle GameActionRaiseVital for vital {vital}");
                return;
            }
            session.Player.SpendXp(ability, xpSpent);
        }
Exemplo n.º 7
0
        public override void Handle()
        {
            if (message.StartsWith("@"))
            {
                string   command;
                string[] parameters;
                CommandManager.ParseCommand(message.Remove(0, 1), out command, out parameters);

                CommandHandlerInfo commandHandler;
                var response = CommandManager.GetCommandHandler(session, command, parameters, out commandHandler);
                if (response == CommandHandlerResponse.Ok)
                {
                    ((CommandHandler)commandHandler.Handler).Invoke(session, parameters);
                }
                else
                {
                    switch (response)
                    {
                    case CommandHandlerResponse.InvalidCommand:
                        ChatPacket.SendSystemMessage(session, $"Invalid command {command}!");
                        break;

                    case CommandHandlerResponse.InvalidParameterCount:
                        ChatPacket.SendSystemMessage(session, $"Invalid parameter count, got {parameters.Length}, expected {commandHandler.Attribute.ParameterCount}!");
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                // TODO: broadcast message
            }
        }
Exemplo n.º 8
0
        public void SpendXp(Skill skill, uint amount)
        {
            uint baseValue = 0;
            uint result    = character.Skills[skill].SpendXp(amount);

            if (result > 0u)
            {
                uint ranks        = character.Skills[skill].Ranks;
                uint newValue     = character.Skills[skill].UnbuffedValue;
                var  status       = character.Skills[skill].Status;
                var  xpUpdate     = new GameEventPrivateUpdatePropertyInt64(Session, PropertyInt64.AvailableExperience, character.AvailableExperience);
                var  ablityUpdate = new GameEventPrivateUpdateSkill(Session, skill, status, ranks, baseValue, result);
                var  soundEvent   = new GameEventSound(Session, Network.Enum.Sound.AbilityIncrease, 1f);

                xpUpdate.Send();
                ablityUpdate.Send();
                soundEvent.Send();
                ChatPacket.SendSystemMessage(Session, $"Your base {skill} is now {newValue}!");
            }
            else
            {
                ChatPacket.SendSystemMessage(Session, $"Your attempt to raise {skill} has failed.");
            }
        }
Exemplo n.º 9
0
        public static void HandleDebugGPS(Session session, params string[] parameters)
        {
            var position = session.Player.Position;

            ChatPacket.SendSystemMessage(session, $"Position: [Cell: 0x{position.Cell.ToString("X4")} | Offset: {position.Offset.X}, {position.Offset.Y}, {position.Offset.Z} | Facing: {position.Facing.X}, {position.Facing.Y}, {position.Facing.Z}, {position.Facing.W}]");
        }