Example #1
0
        void CopyBot(Player p, string botName, string newName)
        {
            if (newName == null)
            {
                p.Message("Name of new bot required."); return;
            }
            if (!Formatter.ValidName(p, newName, "bot"))
            {
                return;
            }

            PlayerBot bot = Matcher.FindBots(p, botName);

            if (bot == null)
            {
                return;
            }

            PlayerBot     clone = new PlayerBot(newName, p.level);
            BotProperties props = new BotProperties();

            props.FromBot(bot);
            props.ApplyTo(clone);
            clone.Owner = p.name;
            clone.SetModel(clone.Model);
            BotsFile.LoadAi(props, clone);
            // Preserve custom name tag
            if (bot.DisplayName == bot.name)
            {
                clone.DisplayName = newName;
            }
            TryAddBot(p, clone);
        }