Exemplo n.º 1
0
        public static void OnDamage(NpcStrikeEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }

            TSPlayer player = TShock.Players[args.Player.whoAmI];

            int index = Plugin.Config.Warrior.FindIndex(p => p.PlayerName == player.Name);

            if (index == -1)
            {
                return;
            }

            Vocation character = Vocation.getVocation(index, Plugin.Config.settings[index].currentVocation);

            // Can only get XP from non-prohibited NPCs
            if (!NoXpTargets.Contains(args.Npc.netID))
            {
                character.XP += Vocation.getDamageXp(args.Damage);
                if (character.XP >= Vocation.getLevelXp(character.Level + 1))
                {
                    character.Level++;
                    character.XP = 0;
                    player.SendInfoMessage(VocationPlugin.Resources.INFO_LEVELUP, character.Level);
                }
            }

            character.InflictDamage(player, args);
        }
Exemplo n.º 2
0
        public static void ChangeVocation(CommandArgs args)
        {
            if (!args.Player.IsLoggedIn)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_NOT_LOGGED_IN);
                return;
            }

            if (args.Parameters.Count < 1)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.USAGE_CHANGE_VOCATION, TShockAPI.Commands.Specifier);
                return;
            }

            int index = Plugin.Config.Warrior.FindIndex(v => v.PlayerName == args.Player.Name);

            if (index == -1)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_NO_VOCATION);
                return;
            }

            var argVocation = args.Parameters[0].ToLower();

            try
            {
                Vocation.getVocation(index, argVocation);
            }
            catch (Exception)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_UNKNOWN_VOCATION);
                return;
            }

            string currentVocation = Plugin.Config.settings[index].currentVocation;

            if (currentVocation == argVocation)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_SAME_VOCATION, argVocation);
                return;
            }

            Plugin.Config.settings[index].currentVocation = argVocation;
            args.Player.SendSuccessMessage(VocationPlugin.Resources.INFO_VOCATION_CHANGED, argVocation);
        }
Exemplo n.º 3
0
        public static void Stats(CommandArgs args)
        {
            if (!args.Player.IsLoggedIn)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_NOT_LOGGED_IN);
                return;
            }

            int index = Plugin.Config.Warrior.FindIndex(v => v.PlayerName == args.Player.Name);

            if (index == -1)
            {
                args.Player.SendErrorMessage(VocationPlugin.Resources.ERR_NO_VOCATION);
                return;
            }

            Vocation character = Vocation.getVocation(index, Plugin.Config.settings[index].currentVocation);

            try {
                int pageNumber;
                if (!PaginationTools.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber))
                {
                    return;
                }

                var lines = new List <string> {
                    string.Format(VocationPlugin.Resources.INFO_STAT_LEVEL, character.Level, character.RemainingXp, character.RemainingXpPercent),
                    string.Format(VocationPlugin.Resources.INFO_STAT_ATTACK, "Magic", character.magic.Level, character.magic.getAttackLevelXp(character.MagicAttackMultiplier, XpFormat.Percent)),
                    string.Format(VocationPlugin.Resources.INFO_STAT_ATTACK, "Melee", character.melee.Level, character.melee.getAttackLevelXp(character.MeleeAttackMultiplier, XpFormat.Percent)),
                    string.Format(VocationPlugin.Resources.INFO_STAT_ATTACK, "Ranged", character.ranged.Level, character.ranged.getAttackLevelXp(character.RangedAttackMultiplier, XpFormat.Percent))
                };

                PaginationTools.SendPage(args.Player, pageNumber, lines, new PaginationTools.Settings {
                    HeaderFormat = args.Player.Name + " stats:"
                });
            }
            catch (Exception e) {
                args.Player.SendErrorMessage(e.Message);
                return;
            }
        }